Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15b6575824 | ||
|
|
5bd785d780 | ||
|
|
94cbcef324 | ||
|
|
d8a6d44890 | ||
|
|
9b75ca4f3f | ||
|
|
913e0071dd | ||
|
|
bb6b8cb8d2 | ||
|
|
efbf998ebb | ||
|
|
ce0f41c973 | ||
|
|
2efaa4fb35 | ||
|
|
2d52d16933 | ||
|
|
bbb9e5c054 | ||
|
|
15c375bca5 | ||
|
|
d2a319a4d5 | ||
|
|
2359b80250 |
No files matched your search
@@ -351,6 +351,29 @@ jobs:
|
|||||||
release-check/update-server-catalog.json
|
release-check/update-server-catalog.json
|
||||||
node scripts/axolotl/create-update-server-catalog.test.mjs
|
node scripts/axolotl/create-update-server-catalog.test.mjs
|
||||||
|
|
||||||
|
- name: Build complete skin-site update package
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
version="${GITHUB_REF_NAME#v}"
|
||||||
|
bundle_root="release-check/skin-site-update"
|
||||||
|
bundle_name="Starlight_Launcher_${version}_skin-site-update.zip"
|
||||||
|
|
||||||
|
mkdir -p "${bundle_root}/files"
|
||||||
|
gh release download "${GITHUB_REF_NAME}" --dir "${bundle_root}/files"
|
||||||
|
find "${bundle_root}/files" -maxdepth 1 -type f \
|
||||||
|
\( -name 'latest.json' -o -name '*_skin-site-update.zip' \) -delete
|
||||||
|
|
||||||
|
cp release-check/latest.json "${bundle_root}/latest.json"
|
||||||
|
cp release-check/update-server-catalog.json "${bundle_root}/update-server-catalog.json"
|
||||||
|
cp release-check/release.json "${bundle_root}/release.json"
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "${bundle_root}"
|
||||||
|
zip -r -9 "../${bundle_name}" latest.json update-server-catalog.json release.json files
|
||||||
|
)
|
||||||
|
gh release upload "${GITHUB_REF_NAME}" "release-check/${bundle_name}" --clobber
|
||||||
|
|
||||||
- name: Notify Update Server to publish release assets
|
- name: Notify Update Server to publish release assets
|
||||||
if: ${{ env.UPDATE_SERVER_URL != '' && env.UPDATE_SERVER_WEBHOOK_SECRET != '' }}
|
if: ${{ env.UPDATE_SERVER_URL != '' && env.UPDATE_SERVER_WEBHOOK_SECRET != '' }}
|
||||||
env:
|
env:
|
||||||
|
|||||||
Generated
+2
-2
@@ -6795,7 +6795,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theseus"
|
name = "theseus"
|
||||||
version = "1.0.0-beta12"
|
version = "1.0.0-beta15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ariadne",
|
"ariadne",
|
||||||
"async-minecraft-ping",
|
"async-minecraft-ping",
|
||||||
@@ -6899,7 +6899,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "theseus_gui"
|
name = "theseus_gui"
|
||||||
version = "1.0.0-beta12"
|
version = "1.0.0-beta15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ashpd",
|
"ashpd",
|
||||||
"async_zip",
|
"async_zip",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@modrinth/app-frontend",
|
"name": "@modrinth/app-frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0-beta12",
|
"version": "1.0.0-beta15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ import { hideAllPoppers } from 'floating-vue'
|
|||||||
import { computed, nextTick, onMounted, onUnmounted, provide, ref, watch } from 'vue'
|
import { computed, nextTick, onMounted, onUnmounted, provide, ref, watch } from 'vue'
|
||||||
import { type RouteLocationNormalizedLoaded, RouterView, useRoute, useRouter } from 'vue-router'
|
import { type RouteLocationNormalizedLoaded, RouterView, useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
import InstancePlayerModal from '@/components/instance/InstancePlayerModal.vue'
|
||||||
|
import TaggedModDownloadsModal from '@/components/instance/TaggedModDownloadsModal.vue'
|
||||||
import InstanceExportModal from '@/components/lab/recipe-generator/InstanceExportModal.vue'
|
import InstanceExportModal from '@/components/lab/recipe-generator/InstanceExportModal.vue'
|
||||||
import AccountsCard from '@/components/ui/AccountsCard.vue'
|
import AccountsCard from '@/components/ui/AccountsCard.vue'
|
||||||
import AppActionBar from '@/components/ui/AppActionBar.vue'
|
import AppActionBar from '@/components/ui/AppActionBar.vue'
|
||||||
@@ -79,7 +81,6 @@ import MinecraftAuthErrorModal from '@/components/ui/minecraft-auth-error-modal/
|
|||||||
import MinecraftCrashModal from '@/components/ui/MinecraftCrashModal.vue'
|
import MinecraftCrashModal from '@/components/ui/MinecraftCrashModal.vue'
|
||||||
import AuthGrantFlowWaitModal from '@/components/ui/modal/AuthGrantFlowWaitModal.vue'
|
import AuthGrantFlowWaitModal from '@/components/ui/modal/AuthGrantFlowWaitModal.vue'
|
||||||
import CurseForgeManualDownloadsModal from '@/components/ui/modal/CurseForgeManualDownloadsModal.vue'
|
import CurseForgeManualDownloadsModal from '@/components/ui/modal/CurseForgeManualDownloadsModal.vue'
|
||||||
import TaggedModDownloadsModal from '@/components/instance/TaggedModDownloadsModal.vue'
|
|
||||||
import InstallToPlayModal from '@/components/ui/modal/InstallToPlayModal.vue'
|
import InstallToPlayModal from '@/components/ui/modal/InstallToPlayModal.vue'
|
||||||
import InstanceIconPickerModal from '@/components/ui/modal/InstanceIconPickerModal.vue'
|
import InstanceIconPickerModal from '@/components/ui/modal/InstanceIconPickerModal.vue'
|
||||||
import JavaDownloadConfirmationModal from '@/components/ui/modal/JavaDownloadConfirmationModal.vue'
|
import JavaDownloadConfirmationModal from '@/components/ui/modal/JavaDownloadConfirmationModal.vue'
|
||||||
@@ -90,9 +91,9 @@ import NavButton from '@/components/ui/NavButton.vue'
|
|||||||
import NavRail from '@/components/ui/NavRail.vue'
|
import NavRail from '@/components/ui/NavRail.vue'
|
||||||
import OnboardingOverlay from '@/components/ui/onboarding/OnboardingOverlay.vue'
|
import OnboardingOverlay from '@/components/ui/onboarding/OnboardingOverlay.vue'
|
||||||
import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
|
import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
|
||||||
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
|
||||||
import SkinSiteSessionFrame from '@/components/ui/SkinSiteSessionFrame.vue'
|
import SkinSiteSessionFrame from '@/components/ui/SkinSiteSessionFrame.vue'
|
||||||
import InstancePlayerModal from '@/components/instance/InstancePlayerModal.vue'
|
import StartupAnnouncementModal from '@/components/ui/StartupAnnouncementModal.vue'
|
||||||
|
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
||||||
import WindowControls from '@/components/ui/WindowControls.vue'
|
import WindowControls from '@/components/ui/WindowControls.vue'
|
||||||
import { useCheckDisableMouseover } from '@/composables/macCssFix.js'
|
import { useCheckDisableMouseover } from '@/composables/macCssFix.js'
|
||||||
import { useDropImport } from '@/composables/useDropImport'
|
import { useDropImport } from '@/composables/useDropImport'
|
||||||
@@ -138,9 +139,9 @@ import {
|
|||||||
isDev,
|
isDev,
|
||||||
isElevated,
|
isElevated,
|
||||||
isNetworkMetered,
|
isNetworkMetered,
|
||||||
restartApp,
|
|
||||||
setRestartAfterPendingUpdate,
|
setRestartAfterPendingUpdate,
|
||||||
} from '@/helpers/utils.js'
|
} from '@/helpers/utils.js'
|
||||||
|
import { installUiScale } from '@/helpers/ui-scale'
|
||||||
import { start_join_server, start_join_singleplayer_world } from '@/helpers/worlds.ts'
|
import { start_join_server, start_join_singleplayer_world } from '@/helpers/worlds.ts'
|
||||||
import i18n, { resolveInitialLocale } from '@/i18n.config'
|
import i18n, { resolveInitialLocale } from '@/i18n.config'
|
||||||
import {
|
import {
|
||||||
@@ -490,9 +491,16 @@ onMounted(async () => {
|
|||||||
document.querySelector('body').addEventListener('auxclick', handleAuxClick)
|
document.querySelector('body').addEventListener('auxclick', handleAuxClick)
|
||||||
window.addEventListener(DIRECT_LINKS_SYNCED_EVENT, handleDirectLinkSyncReport)
|
window.addEventListener(DIRECT_LINKS_SYNCED_EVENT, handleDirectLinkSyncReport)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await stateInitialization
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
checkUpdates()
|
checkUpdates()
|
||||||
void warnIfRunningElevated()
|
void warnIfRunningElevated()
|
||||||
startDirectLinkSync()
|
startDirectLinkSync()
|
||||||
|
maybeShowStartupAnnouncement()
|
||||||
})
|
})
|
||||||
|
|
||||||
let directLinkSync: (() => Promise<void>) | undefined
|
let directLinkSync: (() => Promise<void>) | undefined
|
||||||
@@ -1264,6 +1272,9 @@ provide(
|
|||||||
)
|
)
|
||||||
provide('previewMinecraftCrashModal', () => minecraftCrashModal.value?.showPreview())
|
provide('previewMinecraftCrashModal', () => minecraftCrashModal.value?.showPreview())
|
||||||
provide('showLauncherPopup', (_request: unknown) => {})
|
provide('showLauncherPopup', (_request: unknown) => {})
|
||||||
|
provide('showStartupAnnouncement', () => startupAnnouncementModal.value?.show())
|
||||||
|
|
||||||
|
installUiScale()
|
||||||
|
|
||||||
const stateFailed = ref(false)
|
const stateFailed = ref(false)
|
||||||
stateInitialization
|
stateInitialization
|
||||||
@@ -1533,6 +1544,33 @@ const updateToPlayModal = ref()
|
|||||||
|
|
||||||
const modrinthLoginFlowWaitModal = ref()
|
const modrinthLoginFlowWaitModal = ref()
|
||||||
|
|
||||||
|
const startupAnnouncementModal = ref<InstanceType<typeof StartupAnnouncementModal> | null>(null)
|
||||||
|
const STARTUP_ANNOUNCEMENT_KEY = 'starlight-startup-announcement-seen-v1'
|
||||||
|
|
||||||
|
function maybeShowStartupAnnouncement() {
|
||||||
|
let alreadySeen = false
|
||||||
|
try {
|
||||||
|
alreadySeen = localStorage.getItem(STARTUP_ANNOUNCEMENT_KEY) !== null
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to read startup announcement flag', error)
|
||||||
|
}
|
||||||
|
if (alreadySeen) return
|
||||||
|
|
||||||
|
const modal = startupAnnouncementModal.value
|
||||||
|
if (!modal) {
|
||||||
|
// The modal component has not mounted yet; try again on the next tick.
|
||||||
|
void nextTick(maybeShowStartupAnnouncement)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.show()
|
||||||
|
try {
|
||||||
|
localStorage.setItem(STARTUP_ANNOUNCEMENT_KEY, '1')
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to write startup announcement flag', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── Drop import system ──────────────────────────────────────────────────
|
// ── Drop import system ──────────────────────────────────────────────────
|
||||||
const dropImport = useDropImport({
|
const dropImport = useDropImport({
|
||||||
notificationManager,
|
notificationManager,
|
||||||
@@ -1701,6 +1739,7 @@ onMounted(() => {
|
|||||||
setServerUpdateToPlayModal(updateToPlayModal.value)
|
setServerUpdateToPlayModal(updateToPlayModal.value)
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
|
await stateInitialization
|
||||||
const ready = await invoke<{
|
const ready = await invoke<{
|
||||||
pending_crashes: { instance_id: string; uuid: string }[]
|
pending_crashes: { instance_id: string; uuid: string }[]
|
||||||
pending_commands: Parameters<typeof handleCommand>[0][]
|
pending_commands: Parameters<typeof handleCommand>[0][]
|
||||||
@@ -2161,6 +2200,7 @@ provideAppUpdateDownloadProgress(appUpdateDownload)
|
|||||||
<SplashScreen v-if="!stateFailed" ref="splashScreen" data-tauri-drag-region />
|
<SplashScreen v-if="!stateFailed" ref="splashScreen" data-tauri-drag-region />
|
||||||
<SkinSiteSessionFrame v-if="stateInitialized" />
|
<SkinSiteSessionFrame v-if="stateInitialized" />
|
||||||
<InstancePlayerModal v-if="stateInitialized" />
|
<InstancePlayerModal v-if="stateInitialized" />
|
||||||
|
<StartupAnnouncementModal ref="startupAnnouncementModal" />
|
||||||
<div id="teleports"></div>
|
<div id="teleports"></div>
|
||||||
<div
|
<div
|
||||||
v-if="stateInitialized && themeStore.customBackgroundPath && !themeStore.transparentBackground"
|
v-if="stateInitialized && themeStore.customBackgroundPath && !themeStore.transparentBackground"
|
||||||
@@ -2423,9 +2463,13 @@ provideAppUpdateDownloadProgress(appUpdateDownload)
|
|||||||
{{ formatMessage(messages.authUnreachableBody) }}
|
{{ formatMessage(messages.authUnreachableBody) }}
|
||||||
</Admonition>
|
</Admonition>
|
||||||
<div class="page-transition-grid grid min-h-full">
|
<div class="page-transition-grid grid min-h-full">
|
||||||
<RouterView v-slot="{ Component, route }">
|
<RouterView v-slot="{ Component, route: currentRoute }">
|
||||||
<Transition name="page-slide" :css="themeStore.getFeatureFlag('page_transitions')">
|
<Transition name="page-slide" :css="themeStore.getFeatureFlag('page_transitions')">
|
||||||
<div v-if="Component" :key="getPageTransitionKey(route)" class="page-transition-layer">
|
<div
|
||||||
|
v-if="Component"
|
||||||
|
:key="getPageTransitionKey(currentRoute)"
|
||||||
|
class="page-transition-layer"
|
||||||
|
>
|
||||||
<Suspense @pending="onSuspensePending" @resolve="onSuspenseResolve">
|
<Suspense @pending="onSuspensePending" @resolve="onSuspenseResolve">
|
||||||
<component :is="Component"></component>
|
<component :is="Component"></component>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
@@ -2489,7 +2533,7 @@ provideAppUpdateDownloadProgress(appUpdateDownload)
|
|||||||
:on-error-action="exportNotificationErrorLogs"
|
:on-error-action="exportNotificationErrorLogs"
|
||||||
:error-action-label="formatMessage(messages.exportErrorLogs)"
|
:error-action-label="formatMessage(messages.exportErrorLogs)"
|
||||||
/>
|
/>
|
||||||
<MinecraftCrashModal ref="minecraftCrashModal" @error="handleError" />
|
<MinecraftCrashModal v-if="stateInitialized" ref="minecraftCrashModal" @error="handleError" />
|
||||||
<JavaDownloadConfirmationModal ref="javaDownloadConfirmationModal" />
|
<JavaDownloadConfirmationModal ref="javaDownloadConfirmationModal" />
|
||||||
<NewModal
|
<NewModal
|
||||||
ref="closeChoiceModal"
|
ref="closeChoiceModal"
|
||||||
@@ -2577,7 +2621,7 @@ provideAppUpdateDownloadProgress(appUpdateDownload)
|
|||||||
@install="handleContentInstallModpackInstall"
|
@install="handleContentInstallModpackInstall"
|
||||||
@cancel="handleContentInstallModpackInstallCancel"
|
@cancel="handleContentInstallModpackInstallCancel"
|
||||||
/>
|
/>
|
||||||
<TaggedModDownloadsModal />
|
<TaggedModDownloadsModal v-if="stateInitialized" />
|
||||||
<CurseForgeManualDownloadsModal
|
<CurseForgeManualDownloadsModal
|
||||||
ref="contentInstallCurseForgeManualDownloadsModal"
|
ref="contentInstallCurseForgeManualDownloadsModal"
|
||||||
@view-instance="handleContentInstallModpackDuplicateGoToInstance"
|
@view-instance="handleContentInstallModpackDuplicateGoToInstance"
|
||||||
|
|||||||
@@ -32,6 +32,110 @@ export const ANNOUNCEMENT_CHANGE_TYPES: readonly AnnouncementChangeType[] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
|
export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
|
||||||
|
{
|
||||||
|
id: 'launcher-1.0.1-beta3',
|
||||||
|
version: '1.0.1-beta3',
|
||||||
|
publishedAt: '2026-09-30',
|
||||||
|
title: {
|
||||||
|
'en-US': 'Starlight Launcher 1.0.1-beta3',
|
||||||
|
'zh-CN': 'Starlight Launcher 1.0.1-beta3',
|
||||||
|
},
|
||||||
|
changes: {
|
||||||
|
added: [
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Added a launcher UI scale setting under Appearance, which also helps when embedded pages are cut off.',
|
||||||
|
'zh-CN': '在“界面与外观”中新增启动器缩放设置,同时可缓解内嵌网页被裁切的问题。',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Added a one-time welcome announcement on first launch, with an entry in the home sidebar.',
|
||||||
|
'zh-CN': '新增首次启动时的欢迎公告弹窗,并在主页侧栏提供入口。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fixed: [
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Fixed the browse page going blank without a CurseForge API key; the navigation tabs now stay visible.',
|
||||||
|
'zh-CN': '修复未配置 CurseForge API Key 时浏览页整页空白的问题,导航栏现在保持可见。',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Fixed the about page license links and the update changelog link to point at the correct repository.',
|
||||||
|
'zh-CN': '修复关于页许可证链接与更新日志链接,改为指向正确的仓库。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'launcher-1.0.1-beta2',
|
||||||
|
version: '1.0.1-beta2',
|
||||||
|
publishedAt: '2026-09-28',
|
||||||
|
title: {
|
||||||
|
'en-US': 'Starlight Launcher 1.0.1-beta2',
|
||||||
|
'zh-CN': 'Starlight Launcher 1.0.1-beta2',
|
||||||
|
},
|
||||||
|
changes: {
|
||||||
|
added: [
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'GitHub releases now include one complete update package for publishing to the StarLight skin site.',
|
||||||
|
'zh-CN': 'GitHub 发布现会生成一个可直接发布到 StarLight 皮肤站的完整更新包。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fixed: [
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Improved the reliability of live logs and database switching.',
|
||||||
|
'zh-CN': '提高实时日志与数据库切换的可靠性。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'launcher-1.0.1-beta1',
|
||||||
|
version: '1.0.1-beta1',
|
||||||
|
publishedAt: '2026-09-27',
|
||||||
|
title: {
|
||||||
|
'en-US': 'Starlight Launcher 1.0.1-beta1',
|
||||||
|
'zh-CN': 'Starlight Launcher 1.0.1-beta1',
|
||||||
|
},
|
||||||
|
changes: {
|
||||||
|
added: [
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Added a one-time welcome announcement on first launch, covering the development team, the StarLight-only note, the rulebook update, and server connection addresses.',
|
||||||
|
'zh-CN':
|
||||||
|
'新增首次启动时的欢迎公告弹窗,包含开发团队、StarLight 专用说明、服规更新与服务器连接地址。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'launcher-1.0.0',
|
||||||
|
version: '1.0.0',
|
||||||
|
publishedAt: '2026-09-26',
|
||||||
|
title: {
|
||||||
|
'en-US': 'Starlight Launcher 1.0.0',
|
||||||
|
'zh-CN': 'Starlight Launcher 1.0.0',
|
||||||
|
},
|
||||||
|
changes: {
|
||||||
|
added: [
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Enabled the built-in automatic updater. The launcher can now check for and install new versions from the update channel.',
|
||||||
|
'zh-CN': '启用内置自动更新,启动器现在可以从更新通道检查并安装新版本。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fixed: [
|
||||||
|
{
|
||||||
|
'en-US':
|
||||||
|
'Fixed a crash on startup caused by the updater running before launcher state finished initializing.',
|
||||||
|
'zh-CN': '修复了更新器在启动器状态初始化完成前运行导致的启动崩溃。',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'launcher-1.0.0-beta15',
|
id: 'launcher-1.0.0-beta15',
|
||||||
version: '1.0.0-beta15',
|
version: '1.0.0-beta15',
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { NewspaperIcon, RightArrowIcon } from '@modrinth/assets'
|
||||||
|
import { inject } from 'vue'
|
||||||
|
|
||||||
|
const showAnnouncement = inject<(() => void) | undefined>('showStartupAnnouncement')
|
||||||
|
|
||||||
|
function open() {
|
||||||
|
showAnnouncement?.()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section
|
||||||
|
class="flex min-w-0 flex-col gap-3 border-0 border-b-[1px] border-solid border-[--brand-gradient-border] p-4"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="group flex w-full cursor-pointer flex-col gap-2 border-0 bg-transparent p-0 text-left"
|
||||||
|
@click="open"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<NewspaperIcon class="size-4 shrink-0 text-secondary" aria-hidden="true" />
|
||||||
|
<h2 class="m-0 truncate text-lg">公告</h2>
|
||||||
|
<RightArrowIcon
|
||||||
|
class="ml-auto size-4 shrink-0 text-secondary transition-transform group-hover:translate-x-0.5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p class="m-0 text-sm leading-relaxed text-secondary">点击查看最新公告</p>
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
@@ -28,8 +28,8 @@ import { useNetworkStatus } from '@/composables/useNetworkStatus'
|
|||||||
import { process_listener } from '@/helpers/events'
|
import { process_listener } from '@/helpers/events'
|
||||||
import { install_existing_instance, install_pack_to_existing_instance } from '@/helpers/install'
|
import { install_existing_instance, install_pack_to_existing_instance } from '@/helpers/install'
|
||||||
import { kill, run } from '@/helpers/instance'
|
import { kill, run } from '@/helpers/instance'
|
||||||
import { get_by_instance_id } from '@/helpers/process'
|
|
||||||
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
||||||
|
import { get_by_instance_id } from '@/helpers/process'
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
import { handleSevereError } from '@/store/error'
|
import { handleSevereError } from '@/store/error'
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ const props = withDefaults(
|
|||||||
limit?: HomeRecentLimit
|
limit?: HomeRecentLimit
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
|
dashboardSize: null,
|
||||||
limit: HOME_RECENT_DEFAULT_LIMIT,
|
limit: HOME_RECENT_DEFAULT_LIMIT,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -146,11 +147,17 @@ async function stopInstance(instance: GameInstance) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="home-recent-worlds flex min-w-0 min-h-0 h-full flex-col gap-3" :data-size="dashboardSize">
|
<section
|
||||||
|
class="home-recent-worlds flex min-w-0 min-h-0 h-full flex-col gap-3"
|
||||||
|
:data-size="dashboardSize"
|
||||||
|
>
|
||||||
<div class="home-widget-heading flex min-w-0 h-8 flex-none items-center gap-2">
|
<div class="home-widget-heading flex min-w-0 h-8 flex-none items-center gap-2">
|
||||||
<h2>{{ formatMessage(messages.recentTitle) }}</h2>
|
<h2>{{ formatMessage(messages.recentTitle) }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="recentItems.length > 0" class="home-recent-list flex min-w-0 min-h-0 flex-1 flex-col gap-1 overflow-x-hidden overflow-y-auto pr-1">
|
<div
|
||||||
|
v-if="recentItems.length > 0"
|
||||||
|
class="home-recent-list flex min-w-0 min-h-0 flex-1 flex-col gap-1 overflow-x-hidden overflow-y-auto pr-1"
|
||||||
|
>
|
||||||
<template
|
<template
|
||||||
v-for="item in recentItems"
|
v-for="item in recentItems"
|
||||||
:key="item.type === 'world' ? worldKey(item.world) : `${item.instance.id}:instance`"
|
:key="item.type === 'world' ? worldKey(item.world) : `${item.instance.id}:instance`"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ProgressBar, defineMessages, useVIntl } from '@modrinth/ui'
|
import { defineMessages, ProgressBar, useVIntl } from '@modrinth/ui'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
import { injectDownloadManager } from '@/providers/download-manager'
|
import { injectDownloadManager } from '@/providers/download-manager'
|
||||||
|
|
||||||
const props = defineProps<{ instanceId?: string; active?: boolean }>()
|
const props = defineProps<{ instanceId?: string; active?: boolean }>()
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ import {
|
|||||||
import { users } from '@/helpers/auth'
|
import { users } from '@/helpers/auth'
|
||||||
import { getInstanceMode } from '@/helpers/hosted-packs'
|
import { getInstanceMode } from '@/helpers/hosted-packs'
|
||||||
import {
|
import {
|
||||||
|
type InstancePlayer,
|
||||||
|
type PlayerChoice,
|
||||||
PlayerSelectionNavigatedAwayError,
|
PlayerSelectionNavigatedAwayError,
|
||||||
registerInstancePlayerPicker,
|
registerInstancePlayerPicker,
|
||||||
saveInstancePlayer,
|
saveInstancePlayer,
|
||||||
waitForSkinSiteSession,
|
waitForSkinSiteSession,
|
||||||
type InstancePlayer,
|
|
||||||
type PlayerChoice,
|
|
||||||
} from '@/helpers/instance-player'
|
} from '@/helpers/instance-player'
|
||||||
|
|
||||||
import { playerMessages as messages } from './instance-player-messages'
|
import { playerMessages as messages } from './instance-player-messages'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ButtonStyled, useVIntl } from '@modrinth/ui'
|
import { ButtonStyled, useVIntl } from '@modrinth/ui'
|
||||||
import { onUnmounted, ref, watch } from 'vue'
|
import { onUnmounted, ref, watch } from 'vue'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
chooseInstancePlayer,
|
chooseInstancePlayer,
|
||||||
getInstancePlayer,
|
getInstancePlayer,
|
||||||
onInstancePlayerChanged,
|
|
||||||
type InstancePlayer,
|
type InstancePlayer,
|
||||||
|
onInstancePlayerChanged,
|
||||||
} from '@/helpers/instance-player'
|
} from '@/helpers/instance-player'
|
||||||
|
|
||||||
import { playerMessages as messages } from './instance-player-messages'
|
import { playerMessages as messages } from './instance-player-messages'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NewModal, ProgressBar, ButtonStyled, defineMessages, useVIntl } from '@modrinth/ui'
|
import { ButtonStyled, defineMessages, NewModal, ProgressBar, useVIntl } from '@modrinth/ui'
|
||||||
import { onMounted, onUnmounted, nextTick, ref, shallowRef } from 'vue'
|
import { nextTick, onMounted, onUnmounted, ref, shallowRef } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
import { loading_listener } from '@/helpers/events'
|
import { loading_listener } from '@/helpers/events'
|
||||||
import { progress_bars_list } from '@/helpers/state'
|
|
||||||
import { onHostedPackAttemptStarted } from '@/helpers/hosted-packs'
|
import { onHostedPackAttemptStarted } from '@/helpers/hosted-packs'
|
||||||
|
import { progress_bars_list } from '@/helpers/state'
|
||||||
import {
|
import {
|
||||||
createTaggedModProgress,
|
createTaggedModProgress,
|
||||||
type TaggedProgressEvent,
|
type TaggedProgressEvent,
|
||||||
|
|||||||
@@ -12,10 +12,14 @@
|
|||||||
>
|
>
|
||||||
{{ formatMessage(messages.score, { score }) }}
|
{{ formatMessage(messages.score, { score }) }}
|
||||||
</span>
|
</span>
|
||||||
<span class="shrink-0 whitespace-nowrap rounded-full bg-surface-3 px-2 py-0.5 tabular-nums text-secondary">
|
<span
|
||||||
|
class="shrink-0 whitespace-nowrap rounded-full bg-surface-3 px-2 py-0.5 tabular-nums text-secondary"
|
||||||
|
>
|
||||||
{{ formatMessage(messages.highestLevel, { level: highestLevel + 1 }) }}
|
{{ formatMessage(messages.highestLevel, { level: highestLevel + 1 }) }}
|
||||||
</span>
|
</span>
|
||||||
<span class="shrink-0 whitespace-nowrap rounded-full bg-surface-3 px-2 py-0.5 tabular-nums text-secondary">
|
<span
|
||||||
|
class="shrink-0 whitespace-nowrap rounded-full bg-surface-3 px-2 py-0.5 tabular-nums text-secondary"
|
||||||
|
>
|
||||||
{{ formatMessage(messages.best, { score: bestScore }) }}
|
{{ formatMessage(messages.best, { score: bestScore }) }}
|
||||||
</span>
|
</span>
|
||||||
<NewButton type="base" size="sm" class="shrink-0" @click="settleGame">
|
<NewButton type="base" size="sm" class="shrink-0" @click="settleGame">
|
||||||
@@ -80,7 +84,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
<div v-if="gameOver && !endedManually" class="tide-drain pointer-events-none absolute inset-0 z-20" />
|
<div
|
||||||
|
v-if="gameOver && !endedManually"
|
||||||
|
class="tide-drain pointer-events-none absolute inset-0 z-20"
|
||||||
|
/>
|
||||||
<Transition name="panel">
|
<Transition name="panel">
|
||||||
<div
|
<div
|
||||||
v-if="gameOver"
|
v-if="gameOver"
|
||||||
@@ -115,16 +122,26 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="grid w-full min-w-0 grid-cols-3 gap-1.5">
|
<div class="grid w-full min-w-0 grid-cols-3 gap-1.5">
|
||||||
<div class="flex min-w-0 flex-col items-center rounded-lg bg-surface-3 px-1 py-1">
|
<div class="flex min-w-0 flex-col items-center rounded-lg bg-surface-3 px-1 py-1">
|
||||||
<span class="text-[9px] text-secondary">{{ formatMessage(messages.levelLabel) }}</span>
|
<span class="text-[9px] text-secondary">{{
|
||||||
<span class="text-sm font-bold tabular-nums text-contrast">{{ highestLevel + 1 }}</span>
|
formatMessage(messages.levelLabel)
|
||||||
|
}}</span>
|
||||||
|
<span class="text-sm font-bold tabular-nums text-contrast">{{
|
||||||
|
highestLevel + 1
|
||||||
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex min-w-0 flex-col items-center rounded-lg bg-surface-3 px-1 py-1">
|
<div class="flex min-w-0 flex-col items-center rounded-lg bg-surface-3 px-1 py-1">
|
||||||
<span class="text-[9px] text-secondary">{{ formatMessage(messages.bestLabel) }}</span>
|
<span class="text-[9px] text-secondary">{{
|
||||||
|
formatMessage(messages.bestLabel)
|
||||||
|
}}</span>
|
||||||
<span class="text-sm font-bold tabular-nums text-contrast">{{ bestScore }}</span>
|
<span class="text-sm font-bold tabular-nums text-contrast">{{ bestScore }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex min-w-0 flex-col items-center rounded-lg bg-surface-3 px-1 py-1">
|
<div class="flex min-w-0 flex-col items-center rounded-lg bg-surface-3 px-1 py-1">
|
||||||
<span class="text-[9px] text-secondary">{{ formatMessage(messages.overtimesLabel) }}</span>
|
<span class="text-[9px] text-secondary">{{
|
||||||
<span class="text-sm font-bold tabular-nums text-contrast">{{ overtimeCount }}</span>
|
formatMessage(messages.overtimesLabel)
|
||||||
|
}}</span>
|
||||||
|
<span class="text-sm font-bold tabular-nums text-contrast">{{
|
||||||
|
overtimeCount
|
||||||
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-wrap justify-center gap-2">
|
<div class="flex flex-wrap justify-center gap-2">
|
||||||
@@ -150,8 +167,8 @@ import blueStar from '@/assets/stars/blue.png'
|
|||||||
import greenStar from '@/assets/stars/green.png'
|
import greenStar from '@/assets/stars/green.png'
|
||||||
import pinkStar from '@/assets/stars/pink.png'
|
import pinkStar from '@/assets/stars/pink.png'
|
||||||
import redStar from '@/assets/stars/red.png'
|
import redStar from '@/assets/stars/red.png'
|
||||||
import yellowStar from '@/assets/stars/yellow.png'
|
|
||||||
import superStar from '@/assets/stars/super.png'
|
import superStar from '@/assets/stars/super.png'
|
||||||
|
import yellowStar from '@/assets/stars/yellow.png'
|
||||||
|
|
||||||
interface Piece {
|
interface Piece {
|
||||||
id: number
|
id: number
|
||||||
@@ -396,7 +413,14 @@ function mergePieces(a: Piece, b: Piece) {
|
|||||||
score.value += points[level]
|
score.value += points[level]
|
||||||
highestLevel.value = Math.max(highestLevel.value, level)
|
highestLevel.value = Math.max(highestLevel.value, level)
|
||||||
const isRainbow = level === colors.length - 1
|
const isRainbow = level === colors.length - 1
|
||||||
spawnBurst(x, y, isRainbow ? rainbowColors : [colors[level]], 10 + level * 3, 130 + level * 20, 3.4)
|
spawnBurst(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
isRainbow ? rainbowColors : [colors[level]],
|
||||||
|
10 + level * 3,
|
||||||
|
130 + level * 20,
|
||||||
|
3.4,
|
||||||
|
)
|
||||||
spawnShockwave(x, y, 46 + level * 26, 'rgba(255, 255, 255, 0.9)', Math.min(3, 1.4 + level * 0.3))
|
spawnShockwave(x, y, 46 + level * 26, 'rgba(255, 255, 255, 0.9)', Math.min(3, 1.4 + level * 0.3))
|
||||||
shakePower = Math.max(shakePower, Math.min(2 + level * 1.2, 7))
|
shakePower = Math.max(shakePower, Math.min(2 + level * 1.2, 7))
|
||||||
spawnFloater(x, y, `+${points[level]}`, 15 + level * 3, colors[level])
|
spawnFloater(x, y, `+${points[level]}`, 15 + level * 3, colors[level])
|
||||||
@@ -423,7 +447,14 @@ function easeOutBack(t: number) {
|
|||||||
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2)
|
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnBurst(x: number, y: number, palette: string[], count: number, speed: number, size: number) {
|
function spawnBurst(
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
palette: string[],
|
||||||
|
count: number,
|
||||||
|
speed: number,
|
||||||
|
size: number,
|
||||||
|
) {
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
if (particles.length >= 260) return
|
if (particles.length >= 260) return
|
||||||
const angle = Math.random() * Math.PI * 2
|
const angle = Math.random() * Math.PI * 2
|
||||||
@@ -508,7 +539,8 @@ function update(delta: number) {
|
|||||||
if (overtimeStartAt >= 0) {
|
if (overtimeStartAt >= 0) {
|
||||||
const overtimeElapsed = elapsed - overtimeStartAt
|
const overtimeElapsed = elapsed - overtimeStartAt
|
||||||
if (overtimeElapsed < 0.8) {
|
if (overtimeElapsed < 0.8) {
|
||||||
surfaceRatio = overtimeFromRatio + (0.05 - overtimeFromRatio) * easeInOutCubic(overtimeElapsed / 0.8)
|
surfaceRatio =
|
||||||
|
overtimeFromRatio + (0.05 - overtimeFromRatio) * easeInOutCubic(overtimeElapsed / 0.8)
|
||||||
} else {
|
} else {
|
||||||
overtimeStartAt = -1
|
overtimeStartAt = -1
|
||||||
}
|
}
|
||||||
@@ -670,17 +702,7 @@ function prepareBallSprite(src: string, level: number) {
|
|||||||
sprite.height = Math.max(1, Math.round(bounds.h * scale))
|
sprite.height = Math.max(1, Math.round(bounds.h * scale))
|
||||||
const ctx = sprite.getContext('2d')
|
const ctx = sprite.getContext('2d')
|
||||||
if (!ctx) return
|
if (!ctx) return
|
||||||
ctx.drawImage(
|
ctx.drawImage(image, bounds.x, bounds.y, bounds.w, bounds.h, 0, 0, sprite.width, sprite.height)
|
||||||
image,
|
|
||||||
bounds.x,
|
|
||||||
bounds.y,
|
|
||||||
bounds.w,
|
|
||||||
bounds.h,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
sprite.width,
|
|
||||||
sprite.height,
|
|
||||||
)
|
|
||||||
ballSprites[level] = sprite
|
ballSprites[level] = sprite
|
||||||
}
|
}
|
||||||
image.src = src
|
image.src = src
|
||||||
@@ -692,9 +714,7 @@ function drawMergePiece(piece: Piece) {
|
|||||||
const spawnProgress = Math.min(1, (elapsed - piece.spawnAt) / 0.22)
|
const spawnProgress = Math.min(1, (elapsed - piece.spawnAt) / 0.22)
|
||||||
const spawnScale = spawnProgress >= 1 ? 1 : easeOutBack(spawnProgress)
|
const spawnScale = spawnProgress >= 1 ? 1 : easeOutBack(spawnProgress)
|
||||||
const radius =
|
const radius =
|
||||||
piece.radius *
|
piece.radius * spawnScale * (isRainbow ? 1 + 0.05 * Math.sin(elapsed * 3.2 + piece.id) : 1)
|
||||||
spawnScale *
|
|
||||||
(isRainbow ? 1 + 0.05 * Math.sin(elapsed * 3.2 + piece.id) : 1)
|
|
||||||
context.save()
|
context.save()
|
||||||
context.translate(piece.x, piece.y)
|
context.translate(piece.x, piece.y)
|
||||||
const hue = (elapsed * 55) % 360
|
const hue = (elapsed * 55) % 360
|
||||||
@@ -792,9 +812,7 @@ function draw() {
|
|||||||
context.beginPath()
|
context.beginPath()
|
||||||
for (let x = 0; x <= width; x += 8) {
|
for (let x = 0; x <= width; x += 8) {
|
||||||
const waveY =
|
const waveY =
|
||||||
surfaceY +
|
surfaceY + Math.sin(x * 0.045 + elapsed * 1.8) * 2.5 + Math.sin(x * 0.013 + elapsed * 0.9) * 2
|
||||||
Math.sin(x * 0.045 + elapsed * 1.8) * 2.5 +
|
|
||||||
Math.sin(x * 0.013 + elapsed * 0.9) * 2
|
|
||||||
if (x === 0) context.moveTo(x, waveY)
|
if (x === 0) context.moveTo(x, waveY)
|
||||||
else context.lineTo(x, waveY)
|
else context.lineTo(x, waveY)
|
||||||
}
|
}
|
||||||
@@ -807,7 +825,12 @@ function draw() {
|
|||||||
const progress = Math.min(1, (elapsed - waveStart) / 0.8)
|
const progress = Math.min(1, (elapsed - waveStart) / 0.8)
|
||||||
const waveY = height * (1 - progress)
|
const waveY = height * (1 - progress)
|
||||||
const bandHeight = Math.max(22, height * 0.1)
|
const bandHeight = Math.max(22, height * 0.1)
|
||||||
const gradient = context.createLinearGradient(0, waveY - bandHeight, 0, waveY + bandHeight * 0.5)
|
const gradient = context.createLinearGradient(
|
||||||
|
0,
|
||||||
|
waveY - bandHeight,
|
||||||
|
0,
|
||||||
|
waveY + bandHeight * 0.5,
|
||||||
|
)
|
||||||
gradient.addColorStop(0, 'rgba(255, 255, 255, 0)')
|
gradient.addColorStop(0, 'rgba(255, 255, 255, 0)')
|
||||||
gradient.addColorStop(0.55, 'rgba(96, 178, 255, 0.5)')
|
gradient.addColorStop(0.55, 'rgba(96, 178, 255, 0.5)')
|
||||||
gradient.addColorStop(1, 'rgba(255, 255, 255, 0)')
|
gradient.addColorStop(1, 'rgba(255, 255, 255, 0)')
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import {
|
|||||||
StyledInput,
|
StyledInput,
|
||||||
useVIntl,
|
useVIntl,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
import { save } from '@tauri-apps/plugin-dialog'
|
|
||||||
import { join } from '@tauri-apps/api/path'
|
import { join } from '@tauri-apps/api/path'
|
||||||
|
import { save } from '@tauri-apps/plugin-dialog'
|
||||||
import { readDir, stat } from '@tauri-apps/plugin-fs'
|
import { readDir, stat } from '@tauri-apps/plugin-fs'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import { process_listener } from '@/helpers/events'
|
|||||||
import { install_existing_instance, install_pack_to_existing_instance } from '@/helpers/install'
|
import { install_existing_instance, install_pack_to_existing_instance } from '@/helpers/install'
|
||||||
import { kill, run } from '@/helpers/instance'
|
import { kill, run } from '@/helpers/instance'
|
||||||
import { getDisplayInstanceIcon } from '@/helpers/instance-icons'
|
import { getDisplayInstanceIcon } from '@/helpers/instance-icons'
|
||||||
import { get_by_instance_id } from '@/helpers/process'
|
|
||||||
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
||||||
|
import { get_by_instance_id } from '@/helpers/process'
|
||||||
import { showInstanceInFolder } from '@/helpers/utils.js'
|
import { showInstanceInFolder } from '@/helpers/utils.js'
|
||||||
import { handleSevereError } from '@/store/error.js'
|
import { handleSevereError } from '@/store/error.js'
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ const checkProcess = async () => {
|
|||||||
if (Array.isArray(runningProcesses)) internalPlaying.value = runningProcesses.length > 0
|
if (Array.isArray(runningProcesses)) internalPlaying.value = runningProcesses.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const play = async (e, context) => {
|
const play = async (e) => {
|
||||||
e?.stopPropagation()
|
e?.stopPropagation()
|
||||||
if (loading.value) return
|
if (loading.value) return
|
||||||
await run(props.instance.id).catch(async (err) => {
|
await run(props.instance.id).catch(async (err) => {
|
||||||
@@ -111,7 +111,7 @@ const play = async (e, context) => {
|
|||||||
await checkProcess()
|
await checkProcess()
|
||||||
}
|
}
|
||||||
|
|
||||||
const stop = async (e, context) => {
|
const stop = async (e) => {
|
||||||
e?.stopPropagation()
|
e?.stopPropagation()
|
||||||
await kill(props.instance.id).catch(handleError)
|
await kill(props.instance.id).catch(handleError)
|
||||||
await checkProcess()
|
await checkProcess()
|
||||||
@@ -205,7 +205,7 @@ onUnmounted(() => unlisten())
|
|||||||
: formatMessage(isPlaying ? messages.launchAnother : commonMessages.playButton)
|
: formatMessage(isPlaying ? messages.launchAnother : commonMessages.playButton)
|
||||||
"
|
"
|
||||||
:disabled="offline && !installed"
|
:disabled="offline && !installed"
|
||||||
@click="(e) => play(e, 'InstanceCard')"
|
@click="play"
|
||||||
@mousehover="checkProcess"
|
@mousehover="checkProcess"
|
||||||
>
|
>
|
||||||
<!-- Translate for optical centering -->
|
<!-- Translate for optical centering -->
|
||||||
@@ -295,7 +295,7 @@ onUnmounted(() => unlisten())
|
|||||||
'scale-75 opacity-0 transition-all group-hover:scale-100 group-hover:opacity-100':
|
'scale-75 opacity-0 transition-all group-hover:scale-100 group-hover:opacity-100':
|
||||||
!disabled,
|
!disabled,
|
||||||
}"
|
}"
|
||||||
@click="(e) => play(e, 'InstanceCard')"
|
@click="play"
|
||||||
@mousehover="checkProcess"
|
@mousehover="checkProcess"
|
||||||
>
|
>
|
||||||
<PlayIcon class="translate-x-[1px]" />
|
<PlayIcon class="translate-x-[1px]" />
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ async function copyShareUrl(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _openAIAnalysis(): void {
|
function openAIAnalysis(): void {
|
||||||
if (!lastAnalysis?.combined_log) {
|
if (!lastAnalysis?.combined_log) {
|
||||||
notifyNoLogContent()
|
notifyNoLogContent()
|
||||||
return
|
return
|
||||||
@@ -603,7 +603,7 @@ onUnmounted(() => {
|
|||||||
unlistenProcess?.()
|
unlistenProcess?.()
|
||||||
})
|
})
|
||||||
|
|
||||||
defineExpose({ handleLaunchError, handleWarning, isLaunchFailure, showPreview, openAIAnalysis: _openAIAnalysis })
|
defineExpose({ handleLaunchError, handleWarning, isLaunchFailure, showPreview, openAIAnalysis })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import { clearHostedSession } from '@/helpers/hosted-packs'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
receiveSkinSiteMessage,
|
receiveSkinSiteMessage,
|
||||||
@@ -10,6 +9,7 @@ import {
|
|||||||
skinSiteStatus,
|
skinSiteStatus,
|
||||||
skinSiteUser,
|
skinSiteUser,
|
||||||
} from '@/composables/skin-site-session'
|
} from '@/composables/skin-site-session'
|
||||||
|
import { clearHostedSession } from '@/helpers/hosted-packs'
|
||||||
|
|
||||||
const frame = ref<HTMLIFrameElement>()
|
const frame = ref<HTMLIFrameElement>()
|
||||||
let lastMessage = 0
|
let lastMessage = 0
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ExternalIcon, UsersIcon, XIcon } from '@modrinth/assets'
|
||||||
|
import { Avatar, ButtonStyled, NewModal } from '@modrinth/ui'
|
||||||
|
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
import { teamMembers } from '@/data/about'
|
||||||
|
|
||||||
|
const modal = ref<InstanceType<typeof NewModal>>()
|
||||||
|
|
||||||
|
const SERVER_IPS: { label: string; host: string }[] = [
|
||||||
|
{ label: '直连 IPv4', host: 'slv4.starlight.cool' },
|
||||||
|
{ label: '直连 IPv6', host: 'slv6.starlight.cool' },
|
||||||
|
{ label: '北方代理 IPv4', host: 'north.starlight.cool' },
|
||||||
|
{ label: '南方代理 IPv4', host: 'south.starlight.cool' },
|
||||||
|
{ label: '美国代理 IPv4', host: 'usa.starlight.cool' },
|
||||||
|
]
|
||||||
|
|
||||||
|
const RULES_URL = 'https://kdocs.cn/l/cmT6lVdryHJu'
|
||||||
|
const QQ_GROUP = '535392227'
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
modal.value?.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
modal.value?.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
function openLink(url: string) {
|
||||||
|
void openUrl(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ show })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NewModal ref="modal" header="欢迎使用 Starlight Launcher" width="640px" max-width="640px">
|
||||||
|
<div class="flex min-w-0 flex-col gap-5">
|
||||||
|
<!-- 1. 开发组 -->
|
||||||
|
<section class="flex flex-col gap-2">
|
||||||
|
<h3 class="m-0 flex items-center gap-2 text-sm font-semibold text-contrast">
|
||||||
|
<UsersIcon class="size-4 text-secondary" />
|
||||||
|
开发团队
|
||||||
|
</h3>
|
||||||
|
<p class="m-0 text-sm text-secondary">
|
||||||
|
本启动器由
|
||||||
|
<span class="font-semibold text-contrast">Ax_Tps</span>
|
||||||
|
和
|
||||||
|
<span class="font-semibold text-contrast">Disy920</span>
|
||||||
|
基于 Axolotl 开发。
|
||||||
|
</p>
|
||||||
|
<div class="grid gap-3 sm:grid-cols-2">
|
||||||
|
<a
|
||||||
|
v-for="member in teamMembers"
|
||||||
|
:key="member.name"
|
||||||
|
:href="member.url ?? undefined"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
class="flex min-w-0 items-center gap-3 rounded-xl bg-surface-4 p-3 transition-colors hover:bg-surface-5"
|
||||||
|
@click.prevent="member.url && openLink(member.url)"
|
||||||
|
>
|
||||||
|
<Avatar :src="member.avatarUrl" :alt="member.name" size="2.5rem" circle no-shadow />
|
||||||
|
<span class="min-w-0 flex-1 truncate font-semibold text-contrast">{{ member.name }}</span>
|
||||||
|
<ExternalIcon v-if="member.url" class="size-4 shrink-0 text-secondary" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- 2. SLS 专属 -->
|
||||||
|
<section class="flex flex-col gap-2">
|
||||||
|
<h3 class="m-0 text-sm font-semibold text-contrast">Starlight 专用启动器</h3>
|
||||||
|
<p class="m-0 text-sm text-secondary">
|
||||||
|
该启动器为 Starlight 专用。如果您还未加入 StarLight,请前往我们的 QQ 审核群
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="cursor-pointer border-0 bg-transparent p-0 font-semibold text-brand underline"
|
||||||
|
@click="openLink(`https://qm.qq.com/q/${QQ_GROUP}`)"
|
||||||
|
>
|
||||||
|
{{ QQ_GROUP }}
|
||||||
|
</button>
|
||||||
|
。
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- 3. 服规更新 -->
|
||||||
|
<section class="flex flex-col gap-2">
|
||||||
|
<h3 class="m-0 text-sm font-semibold text-contrast">StarLight 总则章程更新</h3>
|
||||||
|
<p class="m-0 text-sm text-secondary">
|
||||||
|
StarLight 总则章程(即“服规”)更新至第 15 版。该版服规进一步完善与严格了聚落建立、改组、招新与运营的全链条要求,请大家注意阅读并遵守!本版服规自
|
||||||
|
2026 年 9 月 27 日 0 点起开始试行。
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex w-fit cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-sm font-semibold text-brand underline"
|
||||||
|
@click="openLink(RULES_URL)"
|
||||||
|
>
|
||||||
|
查看服规链接
|
||||||
|
<ExternalIcon class="size-3.5" />
|
||||||
|
</button>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- 4. 服务器连接 -->
|
||||||
|
<section class="flex flex-col gap-2">
|
||||||
|
<h3 class="m-0 text-sm font-semibold text-contrast">服务器连接</h3>
|
||||||
|
<p class="m-0 text-sm text-secondary">服务器目前下列几项 IP 可用:</p>
|
||||||
|
<ul class="m-0 flex flex-col gap-1 pl-5 text-sm text-secondary">
|
||||||
|
<li v-for="ip in SERVER_IPS" :key="ip.host">
|
||||||
|
<span class="text-contrast">{{ ip.label }}</span>
|
||||||
|
:<code class="text-brand">{{ ip.host }}</code>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p class="m-0 text-sm text-secondary">
|
||||||
|
请注意,我们优先推荐您尝试直连 IP(包括 v4 和 v6,哪个可用用哪个)。若没有出现高延迟或延迟波动严重的问题,尽量避免使用代理
|
||||||
|
IP(代理 IP 是流量计费的,使用会给服务器带来更大的经济压力)。
|
||||||
|
</p>
|
||||||
|
<p class="m-0 text-sm text-secondary">
|
||||||
|
若必须使用代理 IP,按以往经验,河北(含)以北的我国省份,在选用代理 IP 时建议优先选用北方代理,否则请使用南方代理。
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #actions>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<ButtonStyled color="brand">
|
||||||
|
<button @click="hide">
|
||||||
|
<XIcon />
|
||||||
|
我知道了
|
||||||
|
</button>
|
||||||
|
</ButtonStyled>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NewModal>
|
||||||
|
</template>
|
||||||
@@ -61,7 +61,7 @@ const historyAnnouncements = computed(() =>
|
|||||||
<UpdateAnnouncementContent
|
<UpdateAnnouncementContent
|
||||||
:announcement="currentAnnouncement"
|
:announcement="currentAnnouncement"
|
||||||
:version="currentVersion"
|
:version="currentVersion"
|
||||||
:external-url="currentAnnouncement?.externalUrl ?? AxolotlBrandConfig.website"
|
:external-url="currentAnnouncement?.externalUrl ?? AxolotlBrandConfig.releasesUrl"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ const historyAnnouncements = computed(() =>
|
|||||||
<UpdateAnnouncementContent
|
<UpdateAnnouncementContent
|
||||||
:announcement="announcement"
|
:announcement="announcement"
|
||||||
:show-header="false"
|
:show-header="false"
|
||||||
:external-url="announcement.externalUrl"
|
:external-url="announcement.externalUrl ?? `${AxolotlBrandConfig.releasesUrl}/tag/v${announcement.version}`"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ withDefaults(
|
|||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
count: 1,
|
count: 1,
|
||||||
|
symlinkTarget: null,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ interface IconBackground {
|
|||||||
style: Record<string, string>
|
style: Record<string, string>
|
||||||
}
|
}
|
||||||
|
|
||||||
function background(
|
function makeBackground(
|
||||||
id: string,
|
id: string,
|
||||||
name: MessageDescriptor,
|
name: MessageDescriptor,
|
||||||
top: string,
|
top: string,
|
||||||
@@ -171,16 +171,16 @@ const backgrounds = [
|
|||||||
backgroundSize: '16px 16px',
|
backgroundSize: '16px 16px',
|
||||||
},
|
},
|
||||||
} satisfies IconBackground,
|
} satisfies IconBackground,
|
||||||
background('grass', backgroundNames.grass, '#7fc95b', '#2f7d32'),
|
makeBackground('grass', backgroundNames.grass, '#7fc95b', '#2f7d32'),
|
||||||
background('ocean', backgroundNames.ocean, '#55b7ff', '#3157c8'),
|
makeBackground('ocean', backgroundNames.ocean, '#55b7ff', '#3157c8'),
|
||||||
background('amethyst', backgroundNames.amethyst, '#c084fc', '#6d28d9'),
|
makeBackground('amethyst', backgroundNames.amethyst, '#c084fc', '#6d28d9'),
|
||||||
background('sunset', backgroundNames.sunset, '#ffba52', '#e94b64'),
|
makeBackground('sunset', backgroundNames.sunset, '#ffba52', '#e94b64'),
|
||||||
background('cherry', backgroundNames.cherry, '#ff9ec4', '#b93670'),
|
makeBackground('cherry', backgroundNames.cherry, '#ff9ec4', '#b93670'),
|
||||||
background('nether', backgroundNames.nether, '#ef5a46', '#6d1717'),
|
makeBackground('nether', backgroundNames.nether, '#ef5a46', '#6d1717'),
|
||||||
background('slime', backgroundNames.slime, '#b6ee55', '#44972f'),
|
makeBackground('slime', backgroundNames.slime, '#b6ee55', '#44972f'),
|
||||||
background('deep-dark', backgroundNames.deepDark, '#245369', '#0c1f2b'),
|
makeBackground('deep-dark', backgroundNames.deepDark, '#245369', '#0c1f2b'),
|
||||||
background('stone', backgroundNames.stone, '#aeb5bd', '#525b66'),
|
makeBackground('stone', backgroundNames.stone, '#aeb5bd', '#525b66'),
|
||||||
background('midnight', backgroundNames.midnight, '#4d5f8f', '#171b2d'),
|
makeBackground('midnight', backgroundNames.midnight, '#4d5f8f', '#171b2d'),
|
||||||
]
|
]
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import { computed, ref, watch } from 'vue'
|
|||||||
|
|
||||||
import { get, set } from '@/helpers/settings.ts'
|
import { get, set } from '@/helpers/settings.ts'
|
||||||
import { getOS } from '@/helpers/utils'
|
import { getOS } from '@/helpers/utils'
|
||||||
|
import { setUiScale, uiScale } from '@/helpers/ui-scale'
|
||||||
import { useTheming } from '@/store/state'
|
import { useTheming } from '@/store/state'
|
||||||
import {
|
import {
|
||||||
type AccentColor,
|
type AccentColor,
|
||||||
@@ -209,6 +210,15 @@ const messages = defineMessages({
|
|||||||
defaultMessage:
|
defaultMessage:
|
||||||
'Enables advanced rendering such as blur effects that may cause performance issues without hardware-accelerated rendering.',
|
'Enables advanced rendering such as blur effects that may cause performance issues without hardware-accelerated rendering.',
|
||||||
},
|
},
|
||||||
|
uiScaleTitle: {
|
||||||
|
id: 'app.appearance-settings.ui-scale.title',
|
||||||
|
defaultMessage: 'Launcher scale',
|
||||||
|
},
|
||||||
|
uiScaleDescription: {
|
||||||
|
id: 'app.appearance-settings.ui-scale.description',
|
||||||
|
defaultMessage:
|
||||||
|
'Scale the whole launcher interface. A smaller scale fits more content, which helps when embedded pages are cut off.',
|
||||||
|
},
|
||||||
pageTransitionsTitle: {
|
pageTransitionsTitle: {
|
||||||
id: 'app.appearance-settings.page-transitions.title',
|
id: 'app.appearance-settings.page-transitions.title',
|
||||||
defaultMessage: 'Page transition animations',
|
defaultMessage: 'Page transition animations',
|
||||||
@@ -1020,6 +1030,43 @@ watch(
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</SettingsRow>
|
</SettingsRow>
|
||||||
|
<SettingsRow stacked>
|
||||||
|
<template #label>
|
||||||
|
<span id="settings-target-appearance-ui-scale" tabindex="-1">
|
||||||
|
{{ formatMessage(messages.uiScaleTitle) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #description>{{ formatMessage(messages.uiScaleDescription) }}</template>
|
||||||
|
<template #control>
|
||||||
|
<div class="flex w-full flex-col gap-3">
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<button
|
||||||
|
v-for="preset in [100, 110, 125, 150]"
|
||||||
|
:key="preset"
|
||||||
|
type="button"
|
||||||
|
class="min-w-16 rounded-lg border border-solid px-3 py-1.5 text-sm font-semibold transition-colors"
|
||||||
|
:class="
|
||||||
|
uiScale === preset
|
||||||
|
? 'border-brand bg-brand-highlight text-brand'
|
||||||
|
: 'border-surface-4 bg-surface-3 text-secondary hover:border-surface-5 hover:text-contrast'
|
||||||
|
"
|
||||||
|
@click="setUiScale(preset)"
|
||||||
|
>
|
||||||
|
{{ preset }}%
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<Slider
|
||||||
|
id="ui-scale"
|
||||||
|
:model-value="uiScale"
|
||||||
|
:min="50"
|
||||||
|
:max="200"
|
||||||
|
:step="5"
|
||||||
|
unit="%"
|
||||||
|
@update:model-value="(value) => setUiScale(Number(value))"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</SettingsRow>
|
||||||
<SettingsRow>
|
<SettingsRow>
|
||||||
<template #label>
|
<template #label>
|
||||||
<span id="settings-target-appearance-page-transitions" tabindex="-1">
|
<span id="settings-target-appearance-page-transitions" tabindex="-1">
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import {
|
|||||||
import { getVersion } from '@tauri-apps/api/app'
|
import { getVersion } from '@tauri-apps/api/app'
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import { fetch as tauriFetch } from '@tauri-apps/plugin-http'
|
import { fetch as tauriFetch } from '@tauri-apps/plugin-http'
|
||||||
import { inject, nextTick, ref, watch } from 'vue'
|
import { nextTick, ref, watch } from 'vue'
|
||||||
|
|
||||||
import UpdateAnnouncementHistory from '@/components/ui/announcement/UpdateAnnouncementHistory.vue'
|
import UpdateAnnouncementHistory from '@/components/ui/announcement/UpdateAnnouncementHistory.vue'
|
||||||
import {
|
import {
|
||||||
betaDatabaseExists,
|
betaDatabaseExists,
|
||||||
copyReleaseDatabaseToBeta,
|
|
||||||
copyDatabaseBetweenChannels,
|
copyDatabaseBetweenChannels,
|
||||||
|
copyReleaseDatabaseToBeta,
|
||||||
getCurrentAppDatabasePath,
|
getCurrentAppDatabasePath,
|
||||||
getUpdateChannel,
|
getUpdateChannel,
|
||||||
getUpdatePreferences,
|
getUpdatePreferences,
|
||||||
@@ -446,11 +446,14 @@ async function confirmDatabaseOperation() {
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const detail = error instanceof Error ? error.message : String(error)
|
||||||
handleError(
|
handleError(
|
||||||
new Error(
|
new Error(
|
||||||
targetChannel === activeChannel
|
`${
|
||||||
? formatMessage(messages.databaseOperationActiveTarget)
|
targetChannel === activeChannel
|
||||||
: formatMessage(messages.databaseOperationFailed),
|
? formatMessage(messages.databaseOperationActiveTarget)
|
||||||
|
: formatMessage(messages.databaseOperationFailed)
|
||||||
|
}: ${detail}`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -468,7 +471,7 @@ function cancelDatabaseOperation() {
|
|||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-6">
|
||||||
<SettingsSection :title="formatMessage(messages.title)">
|
<SettingsSection :title="formatMessage(messages.title)">
|
||||||
<div class="update-channel-panel">
|
<div class="update-channel-panel">
|
||||||
<p id="settings-target-updates-channel" class="m-0 text-sm leading-[1.45] text-secondary">
|
<p id="settings-target-updates-source" class="m-0 text-sm leading-[1.45] text-secondary">
|
||||||
{{ formatMessage(messages.description) }}
|
{{ formatMessage(messages.description) }}
|
||||||
</p>
|
</p>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { defineMessage, type MessageDescriptor } from '@modrinth/ui'
|
import type { MessageDescriptor } from '@modrinth/ui'
|
||||||
|
|
||||||
export type SettingsCategoryId =
|
export type SettingsCategoryId =
|
||||||
| 'interface'
|
| 'interface'
|
||||||
@@ -28,100 +28,100 @@ export interface SettingsCategoryDefinition {
|
|||||||
export const settingsCategoryDefinitions: SettingsCategoryDefinition[] = [
|
export const settingsCategoryDefinitions: SettingsCategoryDefinition[] = [
|
||||||
{
|
{
|
||||||
id: 'interface',
|
id: 'interface',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.interface',
|
id: 'app.settings.tabs.interface',
|
||||||
defaultMessage: 'Interface & appearance',
|
defaultMessage: 'Interface & appearance',
|
||||||
}),
|
},
|
||||||
group: 'launcher',
|
group: 'launcher',
|
||||||
onboardingId: 'settings-tab-interface',
|
onboardingId: 'settings-tab-interface',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'home-navigation',
|
id: 'home-navigation',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.home-navigation',
|
id: 'app.settings.tabs.home-navigation',
|
||||||
defaultMessage: 'Home & navigation',
|
defaultMessage: 'Home & navigation',
|
||||||
}),
|
},
|
||||||
group: 'launcher',
|
group: 'launcher',
|
||||||
onboardingId: 'settings-tab-home-navigation',
|
onboardingId: 'settings-tab-home-navigation',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'language-translation',
|
id: 'language-translation',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.language-translation',
|
id: 'app.settings.tabs.language-translation',
|
||||||
defaultMessage: 'Language & translation',
|
defaultMessage: 'Language & translation',
|
||||||
}),
|
},
|
||||||
group: 'launcher',
|
group: 'launcher',
|
||||||
onboardingId: 'settings-tab-language-translation',
|
onboardingId: 'settings-tab-language-translation',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'ai',
|
id: 'ai',
|
||||||
name: defineMessage({ id: 'app.settings.tabs.ai', defaultMessage: 'AI' }),
|
name: { id: 'app.settings.tabs.ai', defaultMessage: 'AI' },
|
||||||
group: 'launcher',
|
group: 'launcher',
|
||||||
flushContent: true,
|
flushContent: true,
|
||||||
onboardingId: 'settings-tab-ai',
|
onboardingId: 'settings-tab-ai',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'java-performance',
|
id: 'java-performance',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.java-performance',
|
id: 'app.settings.tabs.java-performance',
|
||||||
defaultMessage: 'Java & performance',
|
defaultMessage: 'Java & performance',
|
||||||
}),
|
},
|
||||||
group: 'game',
|
group: 'game',
|
||||||
onboardingId: 'settings-tab-java-performance',
|
onboardingId: 'settings-tab-java-performance',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'launch-defaults',
|
id: 'launch-defaults',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.launch-defaults',
|
id: 'app.settings.tabs.launch-defaults',
|
||||||
defaultMessage: 'Launch & instance defaults',
|
defaultMessage: 'Launch & instance defaults',
|
||||||
}),
|
},
|
||||||
group: 'game',
|
group: 'game',
|
||||||
onboardingId: 'settings-tab-launch-defaults',
|
onboardingId: 'settings-tab-launch-defaults',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'content-downloads',
|
id: 'content-downloads',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.content-downloads',
|
id: 'app.settings.tabs.content-downloads',
|
||||||
defaultMessage: 'Content & downloads',
|
defaultMessage: 'Content & downloads',
|
||||||
}),
|
},
|
||||||
group: 'game',
|
group: 'game',
|
||||||
onboardingId: 'settings-tab-content-downloads',
|
onboardingId: 'settings-tab-content-downloads',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'network-multiplayer',
|
id: 'network-multiplayer',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.network-multiplayer',
|
id: 'app.settings.tabs.network-multiplayer',
|
||||||
defaultMessage: 'Network & multiplayer',
|
defaultMessage: 'Network & multiplayer',
|
||||||
}),
|
},
|
||||||
group: 'game',
|
group: 'game',
|
||||||
onboardingId: 'settings-tab-network-multiplayer',
|
onboardingId: 'settings-tab-network-multiplayer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'storage-backups',
|
id: 'storage-backups',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'app.settings.tabs.storage-backups',
|
id: 'app.settings.tabs.storage-backups',
|
||||||
defaultMessage: 'Storage & backups',
|
defaultMessage: 'Storage & backups',
|
||||||
}),
|
},
|
||||||
group: 'data-privacy',
|
group: 'data-privacy',
|
||||||
onboardingId: 'settings-tab-storage-backups',
|
onboardingId: 'settings-tab-storage-backups',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'updates',
|
id: 'updates',
|
||||||
name: defineMessage({ id: 'app.settings.tabs.updates', defaultMessage: 'Updates' }),
|
name: { id: 'app.settings.tabs.updates', defaultMessage: 'Updates' },
|
||||||
group: 'support',
|
group: 'support',
|
||||||
onboardingId: 'settings-tab-updates',
|
onboardingId: 'settings-tab-updates',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'about',
|
id: 'about',
|
||||||
name: defineMessage({ id: 'app.settings.tabs.about', defaultMessage: 'About' }),
|
name: { id: 'app.settings.tabs.about', defaultMessage: 'About' },
|
||||||
group: 'support',
|
group: 'support',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'feature-flags',
|
id: 'feature-flags',
|
||||||
name: defineMessage({
|
name: {
|
||||||
id: 'settings.feature-flags.title',
|
id: 'settings.feature-flags.title',
|
||||||
defaultMessage: 'Feature flags',
|
defaultMessage: 'Feature flags',
|
||||||
}),
|
},
|
||||||
group: 'developer',
|
group: 'developer',
|
||||||
developerOnly: true,
|
developerOnly: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import {
|
|||||||
UsersIcon,
|
UsersIcon,
|
||||||
} from '@modrinth/assets'
|
} from '@modrinth/assets'
|
||||||
import { commonMessages, defineMessages, type MessageDescriptor } from '@modrinth/ui'
|
import { commonMessages, defineMessages, type MessageDescriptor } from '@modrinth/ui'
|
||||||
import { defineAsyncComponent, type Component } from 'vue'
|
import { type Component, defineAsyncComponent } from 'vue'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getVisibleSettingsCategoryDefinitions,
|
getVisibleSettingsCategoryDefinitions,
|
||||||
type SettingsCategoryDefinition,
|
type SettingsCategoryDefinition,
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import { useMinecraftLaunchError } from '@/composables/useMinecraftLaunchError'
|
|||||||
import { get_project } from '@/helpers/cache'
|
import { get_project } from '@/helpers/cache'
|
||||||
import { process_listener } from '@/helpers/events'
|
import { process_listener } from '@/helpers/events'
|
||||||
import { kill, run } from '@/helpers/instance'
|
import { kill, run } from '@/helpers/instance'
|
||||||
import { get_by_instance_id } from '@/helpers/process'
|
|
||||||
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
||||||
|
import { get_by_instance_id } from '@/helpers/process'
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
import { showInstanceInFolder } from '@/helpers/utils'
|
import { showInstanceInFolder } from '@/helpers/utils'
|
||||||
import { handleSevereError } from '@/store/error'
|
import { handleSevereError } from '@/store/error'
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
import assert from 'node:assert/strict'
|
|
||||||
import test from 'node:test'
|
|
||||||
|
|
||||||
import { createLatestLogReader } from './latest-log-reader.ts'
|
|
||||||
|
|
||||||
test('follows file-only output after startup, re-entry, clear and file rotation', async () => {
|
|
||||||
let file = ''
|
|
||||||
let displayed = 'stdout startup'
|
|
||||||
const reader = createLatestLogReader(
|
|
||||||
async (cursor) => ({
|
|
||||||
cursor: file.length,
|
|
||||||
output: file.slice(cursor > file.length ? 0 : cursor),
|
|
||||||
new_file: cursor > file.length,
|
|
||||||
}),
|
|
||||||
(output, replace) => {
|
|
||||||
displayed = (replace ? '' : displayed) + output
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(reader.active, false)
|
|
||||||
file = 'Startup complete\n'
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(reader.active, true)
|
|
||||||
assert.equal(displayed, file) // Replaces stdout, not appended a second time.
|
|
||||||
file += 'Joined world\nDisconnected\n'
|
|
||||||
await reader.refresh()
|
|
||||||
await reader.refresh() // Re-entering the view must not replay history.
|
|
||||||
assert.equal(displayed, file)
|
|
||||||
reader.clear()
|
|
||||||
displayed = ''
|
|
||||||
file += 'After clear\n'
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(displayed, 'After clear\n')
|
|
||||||
file = 'Rotated\n'
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(displayed, file)
|
|
||||||
file = ''
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(displayed, '')
|
|
||||||
assert.equal(reader.active, false)
|
|
||||||
file = 'File recreated\n'
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(displayed, file)
|
|
||||||
reader.reset()
|
|
||||||
assert.equal(reader.active, false)
|
|
||||||
file = 'New session with a longer file\n'
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(displayed, file)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('serializes reads, ignores pre-restart responses, consumes pre-clear responses', async () => {
|
|
||||||
const resolvers: ((value: { cursor: number; output: string; new_file: boolean }) => void)[] = []
|
|
||||||
const cursors: number[] = []
|
|
||||||
const output: string[] = []
|
|
||||||
const reader = createLatestLogReader(
|
|
||||||
(cursor) => {
|
|
||||||
cursors.push(cursor)
|
|
||||||
return new Promise((resolve) => resolvers.push(resolve))
|
|
||||||
},
|
|
||||||
(text) => output.push(text),
|
|
||||||
)
|
|
||||||
const old = reader.refresh()
|
|
||||||
const concurrent = reader.refresh()
|
|
||||||
assert.deepEqual(cursors, [0])
|
|
||||||
reader.reset()
|
|
||||||
const fresh = reader.refresh()
|
|
||||||
resolvers[0]({ cursor: 100, output: 'old session', new_file: false })
|
|
||||||
await Promise.all([old, concurrent])
|
|
||||||
assert.deepEqual(output, [])
|
|
||||||
reader.clear()
|
|
||||||
resolvers[1]({ cursor: 20, output: 'before clear', new_file: false })
|
|
||||||
await fresh
|
|
||||||
assert.deepEqual(output, [])
|
|
||||||
const next = reader.refresh()
|
|
||||||
assert.deepEqual(cursors, [0, 0, 20])
|
|
||||||
resolvers[2]({ cursor: 40, output: 'after clear\n', new_file: false })
|
|
||||||
await next
|
|
||||||
assert.deepEqual(output, ['after clear\n'])
|
|
||||||
})
|
|
||||||
|
|
||||||
test('a temporary read failure keeps the cursor and retries without duplicating output', async () => {
|
|
||||||
let failed = true
|
|
||||||
const output: string[] = []
|
|
||||||
const reader = createLatestLogReader(
|
|
||||||
async (cursor) => {
|
|
||||||
assert.equal(cursor, 0)
|
|
||||||
if (failed) throw new Error('file temporarily unavailable')
|
|
||||||
return { cursor: 6, output: 'ready\n', new_file: false }
|
|
||||||
},
|
|
||||||
(text) => output.push(text),
|
|
||||||
)
|
|
||||||
await assert.rejects(reader.refresh())
|
|
||||||
assert.equal(reader.active, false)
|
|
||||||
failed = false
|
|
||||||
await reader.refresh()
|
|
||||||
assert.deepEqual(output, ['ready\n'])
|
|
||||||
})
|
|
||||||
|
|
||||||
test('joins split lines and flushes the final unterminated line on exit', async () => {
|
|
||||||
let chunk = 'Startup\n[Render thread/INFO] Join'
|
|
||||||
let cursor = 0
|
|
||||||
let displayed = ''
|
|
||||||
const reader = createLatestLogReader(
|
|
||||||
async () => ({
|
|
||||||
cursor: (cursor += chunk.length),
|
|
||||||
output: chunk,
|
|
||||||
new_file: false,
|
|
||||||
}),
|
|
||||||
(text, replace) => {
|
|
||||||
displayed = (replace ? '' : displayed) + text
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(displayed, 'Startup\n')
|
|
||||||
chunk = 'ed world\nLast line'
|
|
||||||
await reader.refresh()
|
|
||||||
assert.equal(displayed, 'Startup\n[Render thread/INFO] Joined world\n')
|
|
||||||
reader.flush()
|
|
||||||
assert.equal(displayed, 'Startup\n[Render thread/INFO] Joined world\nLast line')
|
|
||||||
})
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
interface LogCursor {
|
|
||||||
cursor: number
|
|
||||||
output: string
|
|
||||||
new_file: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/** One authoritative stream: use process events until latest.log becomes available. */
|
|
||||||
export function createLatestLogReader(
|
|
||||||
read: (cursor: number) => Promise<LogCursor>,
|
|
||||||
append: (output: string, replace: boolean) => void,
|
|
||||||
) {
|
|
||||||
let cursor = 0
|
|
||||||
let active = false
|
|
||||||
let session = 0
|
|
||||||
let cleared = 0
|
|
||||||
let partialLine = ''
|
|
||||||
let replaceOnAppend = false
|
|
||||||
let pending: Promise<void> | null = null
|
|
||||||
|
|
||||||
function refresh(): Promise<void> {
|
|
||||||
if (pending) return pending
|
|
||||||
const requestSession = session
|
|
||||||
const requestClear = cleared
|
|
||||||
const request = (async () => {
|
|
||||||
const result = await read(cursor)
|
|
||||||
if (requestSession !== session) return
|
|
||||||
const rotated = result.new_file || result.cursor < cursor
|
|
||||||
const replace = !active || rotated
|
|
||||||
cursor = result.cursor
|
|
||||||
if (result.cursor === 0 && !result.output) {
|
|
||||||
if (rotated) {
|
|
||||||
active = false
|
|
||||||
partialLine = ''
|
|
||||||
replaceOnAppend = false
|
|
||||||
if (requestClear === cleared) append('', true)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
active = true
|
|
||||||
// Clearing during a read consumes its bytes without restoring cleared text.
|
|
||||||
if (requestClear === cleared && (result.output || result.new_file)) {
|
|
||||||
if (replace) {
|
|
||||||
partialLine = ''
|
|
||||||
replaceOnAppend = true
|
|
||||||
}
|
|
||||||
partialLine += result.output
|
|
||||||
// File writes can end mid-line. Do not turn the next chunk into a
|
|
||||||
// separate log entry; bound unterminated output just like the console.
|
|
||||||
const end =
|
|
||||||
partialLine.length > 64 * 1024 ? partialLine.length : partialLine.lastIndexOf('\n') + 1
|
|
||||||
if (end > 0) {
|
|
||||||
append(partialLine.slice(0, end), replaceOnAppend)
|
|
||||||
partialLine = partialLine.slice(end)
|
|
||||||
replaceOnAppend = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
pending = request
|
|
||||||
return request.finally(() => {
|
|
||||||
if (pending === request) pending = null
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
refresh,
|
|
||||||
get active() {
|
|
||||||
return active
|
|
||||||
},
|
|
||||||
clear() {
|
|
||||||
cleared++
|
|
||||||
partialLine = ''
|
|
||||||
replaceOnAppend = false
|
|
||||||
},
|
|
||||||
flush() {
|
|
||||||
if (partialLine) append(partialLine, replaceOnAppend)
|
|
||||||
partialLine = ''
|
|
||||||
replaceOnAppend = false
|
|
||||||
},
|
|
||||||
reset() {
|
|
||||||
session++
|
|
||||||
cursor = 0
|
|
||||||
active = false
|
|
||||||
partialLine = ''
|
|
||||||
replaceOnAppend = false
|
|
||||||
pending = null
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
import {
|
||||||
|
createLiveLogReconciler,
|
||||||
|
type LiveLogSnapshot,
|
||||||
|
} from './live-log-reconciler.ts'
|
||||||
|
|
||||||
|
test('merges the authoritative snapshot with queued events without gaps or duplicates', async () => {
|
||||||
|
let resolveSnapshot!: (snapshot: LiveLogSnapshot) => void
|
||||||
|
const displayed: number[] = []
|
||||||
|
const reconciler = createLiveLogReconciler(
|
||||||
|
() =>
|
||||||
|
new Promise((resolve) => {
|
||||||
|
resolveSnapshot = resolve
|
||||||
|
}),
|
||||||
|
(snapshot) => {
|
||||||
|
displayed.splice(
|
||||||
|
0,
|
||||||
|
displayed.length,
|
||||||
|
...snapshot.lines.map((line) => line.sequence),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
(event) => displayed.push(event.last_sequence),
|
||||||
|
)
|
||||||
|
|
||||||
|
const syncing = reconciler.sync()
|
||||||
|
reconciler.accept({ first_sequence: 3, last_sequence: 3 })
|
||||||
|
resolveSnapshot({
|
||||||
|
lines: [
|
||||||
|
{ sequence: 1, message: 'one' },
|
||||||
|
{ sequence: 2, message: 'two' },
|
||||||
|
],
|
||||||
|
last_sequence: 2,
|
||||||
|
})
|
||||||
|
await syncing
|
||||||
|
assert.deepEqual(displayed, [1, 2, 3])
|
||||||
|
|
||||||
|
await reconciler.accept({ first_sequence: 3, last_sequence: 3 })
|
||||||
|
assert.deepEqual(displayed, [1, 2, 3])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('resynchronizes when an event sequence reveals a missed batch', async () => {
|
||||||
|
const displayed: number[] = []
|
||||||
|
let loads = 0
|
||||||
|
const reconciler = createLiveLogReconciler(
|
||||||
|
async () => {
|
||||||
|
loads++
|
||||||
|
return {
|
||||||
|
lines: [1, 2, 3, 4].map((sequence) => ({
|
||||||
|
sequence,
|
||||||
|
message: String(sequence),
|
||||||
|
})),
|
||||||
|
last_sequence: 4,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(snapshot) => {
|
||||||
|
displayed.splice(
|
||||||
|
0,
|
||||||
|
displayed.length,
|
||||||
|
...snapshot.lines.map((line) => line.sequence),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
(event) => displayed.push(event.last_sequence),
|
||||||
|
)
|
||||||
|
|
||||||
|
await reconciler.accept({ first_sequence: 4, last_sequence: 4 })
|
||||||
|
assert.equal(loads, 1)
|
||||||
|
assert.deepEqual(displayed, [1, 2, 3, 4])
|
||||||
|
})
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
export interface LiveLogSnapshot {
|
||||||
|
lines: Array<{ sequence: number; message: string }>
|
||||||
|
last_sequence: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SequencedLogEvent {
|
||||||
|
first_sequence: number
|
||||||
|
last_sequence: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createLiveLogReconciler<T extends SequencedLogEvent>(
|
||||||
|
loadSnapshot: () => Promise<LiveLogSnapshot>,
|
||||||
|
replace: (snapshot: LiveLogSnapshot) => void,
|
||||||
|
append: (event: T) => void,
|
||||||
|
) {
|
||||||
|
let lastSequence = 0
|
||||||
|
let queued: T[] = []
|
||||||
|
let syncing: Promise<void> | null = null
|
||||||
|
let disposed = false
|
||||||
|
|
||||||
|
function drainQueued(): boolean {
|
||||||
|
const events = queued
|
||||||
|
queued = []
|
||||||
|
for (let index = 0; index < events.length; index++) {
|
||||||
|
const event = events[index]!
|
||||||
|
if (event.last_sequence <= lastSequence) continue
|
||||||
|
if (event.first_sequence > lastSequence + 1) {
|
||||||
|
queued.push(...events.slice(index))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
append(event)
|
||||||
|
lastSequence = event.last_sequence
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
function sync(): Promise<void> {
|
||||||
|
if (syncing) return syncing
|
||||||
|
const request = (async () => {
|
||||||
|
do {
|
||||||
|
const snapshot = await loadSnapshot()
|
||||||
|
if (disposed) return
|
||||||
|
replace(snapshot)
|
||||||
|
lastSequence = snapshot.last_sequence
|
||||||
|
} while (!drainQueued())
|
||||||
|
})()
|
||||||
|
const completion = request.finally(() => {
|
||||||
|
if (syncing === completion) syncing = null
|
||||||
|
})
|
||||||
|
syncing = completion
|
||||||
|
return completion
|
||||||
|
}
|
||||||
|
|
||||||
|
function resync(): Promise<void> {
|
||||||
|
return syncing ? syncing.then(sync) : sync()
|
||||||
|
}
|
||||||
|
|
||||||
|
function accept(event: T): Promise<void> | undefined {
|
||||||
|
if (disposed || event.last_sequence <= lastSequence) return
|
||||||
|
if (syncing) {
|
||||||
|
queued.push(event)
|
||||||
|
return syncing
|
||||||
|
}
|
||||||
|
if (event.first_sequence > lastSequence + 1) {
|
||||||
|
queued.push(event)
|
||||||
|
return sync()
|
||||||
|
}
|
||||||
|
append(event)
|
||||||
|
lastSequence = event.last_sequence
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
accept,
|
||||||
|
resync,
|
||||||
|
sync,
|
||||||
|
dispose() {
|
||||||
|
disposed = true
|
||||||
|
queued = []
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,20 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
import { useHostedSync } from './useHostedSync.ts'
|
|
||||||
import { useHostedCreation, forgetHostedCreation } from './useHostedCreation.ts'
|
|
||||||
import {
|
import {
|
||||||
clearHostedSession,
|
clearHostedSession,
|
||||||
|
HOSTED_ACCOUNT_REQUIRED_MESSAGE,
|
||||||
hostedCreate,
|
hostedCreate,
|
||||||
hostedDefault,
|
hostedDefault,
|
||||||
hostedSync,
|
hostedSync,
|
||||||
onHostedPackAttemptStarted,
|
onHostedPackAttemptStarted,
|
||||||
setInstanceMode,
|
setInstanceMode,
|
||||||
} from '../helpers/hosted-packs.ts'
|
} from '../helpers/hosted-packs.ts'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
openSkinSiteLogin,
|
openSkinSiteLogin,
|
||||||
receiveSkinSiteMessage,
|
receiveSkinSiteMessage,
|
||||||
requestSkinSiteLuck,
|
|
||||||
requestSkinSiteDownloadToken,
|
requestSkinSiteDownloadToken,
|
||||||
|
requestSkinSiteLuck,
|
||||||
requestSkinSitePlayers,
|
requestSkinSitePlayers,
|
||||||
requestSkinSiteSkinUpdate,
|
requestSkinSiteSkinUpdate,
|
||||||
resetSkinSiteSession,
|
resetSkinSiteSession,
|
||||||
@@ -27,6 +26,8 @@ import {
|
|||||||
skinSiteStatus,
|
skinSiteStatus,
|
||||||
skinSiteUser,
|
skinSiteUser,
|
||||||
} from './skin-site-session.ts'
|
} from './skin-site-session.ts'
|
||||||
|
import { forgetHostedCreation, useHostedCreation } from './useHostedCreation.ts'
|
||||||
|
import { useHostedSync } from './useHostedSync.ts'
|
||||||
|
|
||||||
test('reconnecting the same skin site frame waits for verification instead of reporting signed out', () => {
|
test('reconnecting the same skin site frame waits for verification instead of reporting signed out', () => {
|
||||||
const frame = { postMessage() {} } as unknown as Window
|
const frame = { postMessage() {} } as unknown as Window
|
||||||
@@ -46,6 +47,10 @@ test('hosted installation sends the JWT to native commands while Local needs no
|
|||||||
let createdId = 'instance'
|
let createdId = 'instance'
|
||||||
let instanceExists = false
|
let instanceExists = false
|
||||||
let tokenRequests = 0
|
let tokenRequests = 0
|
||||||
|
let accounts: Array<{
|
||||||
|
account_type: string
|
||||||
|
yggdrasil?: { api_root: string }
|
||||||
|
}> = [{ account_type: 'microsoft' }]
|
||||||
const frame = {
|
const frame = {
|
||||||
postMessage(data: { type: string; requestId: string }) {
|
postMessage(data: { type: string; requestId: string }) {
|
||||||
if (data.type !== 'starlight-pack-token-request') return
|
if (data.type !== 'starlight-pack-token-request') return
|
||||||
@@ -70,6 +75,14 @@ test('hosted installation sends the JWT to native commands while Local needs no
|
|||||||
__TAURI_INTERNALS__: {
|
__TAURI_INTERNALS__: {
|
||||||
async invoke(command: string, args: Record<string, unknown>) {
|
async invoke(command: string, args: Record<string, unknown>) {
|
||||||
calls.push({ command, args })
|
calls.push({ command, args })
|
||||||
|
if (command === 'plugin:install|hosted_has_game_account')
|
||||||
|
return accounts.some(
|
||||||
|
(account) =>
|
||||||
|
account.account_type === 'microsoft' ||
|
||||||
|
(account.account_type === 'yggdrasil' &&
|
||||||
|
account.yggdrasil?.api_root.replace(/\/+$/, '') ===
|
||||||
|
'https://skin.starlight.cool/yggdrasil'),
|
||||||
|
)
|
||||||
if (command === 'plugin:install|hosted_sync' && syncResponse) return syncResponse()
|
if (command === 'plugin:install|hosted_sync' && syncResponse) return syncResponse()
|
||||||
if (command === 'plugin:instance|instance_get')
|
if (command === 'plugin:instance|instance_get')
|
||||||
return instanceExists ? { id: args.instanceId } : null
|
return instanceExists ? { id: args.instanceId } : null
|
||||||
@@ -99,7 +112,13 @@ test('hosted installation sends the JWT to native commands while Local needs no
|
|||||||
await setInstanceMode('instance', 'starlight')
|
await setInstanceMode('instance', 'starlight')
|
||||||
assert.equal(tokenRequests, 4)
|
assert.equal(tokenRequests, 4)
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
calls.map(({ command }) => command),
|
calls
|
||||||
|
.map(({ command }) => command)
|
||||||
|
.filter(
|
||||||
|
(command) =>
|
||||||
|
command.startsWith('plugin:install|') &&
|
||||||
|
command !== 'plugin:install|hosted_has_game_account',
|
||||||
|
),
|
||||||
[
|
[
|
||||||
'hosted_set_session',
|
'hosted_set_session',
|
||||||
'hosted_default',
|
'hosted_default',
|
||||||
@@ -210,9 +229,35 @@ test('hosted installation sends the JWT to native commands while Local needs no
|
|||||||
assert.equal(tokenRequests, requestsBeforeLogout)
|
assert.equal(tokenRequests, requestsBeforeLogout)
|
||||||
const attempts: string[] = []
|
const attempts: string[] = []
|
||||||
const stopListening = onHostedPackAttemptStarted((id) => attempts.push(id))
|
const stopListening = onHostedPackAttemptStarted((id) => attempts.push(id))
|
||||||
|
accounts = []
|
||||||
|
const installCallsBeforeAccountFailure = calls.filter(
|
||||||
|
({ command }) =>
|
||||||
|
command.startsWith('plugin:install|') &&
|
||||||
|
command !== 'plugin:install|hosted_has_game_account',
|
||||||
|
).length
|
||||||
|
await assert.rejects(hostedSync('failed-instance'), {
|
||||||
|
message: HOSTED_ACCOUNT_REQUIRED_MESSAGE,
|
||||||
|
})
|
||||||
|
await assert.rejects(hostedCreate(), {
|
||||||
|
message: HOSTED_ACCOUNT_REQUIRED_MESSAGE,
|
||||||
|
})
|
||||||
|
assert.deepEqual(attempts, [])
|
||||||
|
assert.equal(
|
||||||
|
calls.filter(
|
||||||
|
({ command }) =>
|
||||||
|
command.startsWith('plugin:install|') &&
|
||||||
|
command !== 'plugin:install|hosted_has_game_account',
|
||||||
|
).length,
|
||||||
|
installCallsBeforeAccountFailure,
|
||||||
|
)
|
||||||
|
const unauthenticatedCreation = useHostedCreation()
|
||||||
|
await unauthenticatedCreation.install()
|
||||||
|
assert.equal(unauthenticatedCreation.installError.value, HOSTED_ACCOUNT_REQUIRED_MESSAGE)
|
||||||
|
assert.equal(unauthenticatedCreation.createdInstance.value, undefined)
|
||||||
|
accounts = [{ account_type: 'microsoft' }]
|
||||||
const unauthenticatedRetry = hostedSync('failed-instance')
|
const unauthenticatedRetry = hostedSync('failed-instance')
|
||||||
assert.deepEqual(attempts, ['failed-instance'])
|
|
||||||
await assert.rejects(unauthenticatedRetry)
|
await assert.rejects(unauthenticatedRetry)
|
||||||
|
assert.deepEqual(attempts, ['failed-instance'])
|
||||||
stopListening()
|
stopListening()
|
||||||
await assert.rejects(hostedSync('failed-instance'))
|
await assert.rejects(hostedSync('failed-instance'))
|
||||||
assert.equal(attempts.length, 1)
|
assert.equal(attempts.length, 1)
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import type {
|
|||||||
SymlinkMethodChoice,
|
SymlinkMethodChoice,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
import { useDebugLogger, useGlobalDrop, useInstanceContext, useVIntl } from '@modrinth/ui'
|
import { useDebugLogger, useGlobalDrop, useInstanceContext, useVIntl } from '@modrinth/ui'
|
||||||
|
import { join } from '@tauri-apps/api/path'
|
||||||
import { computed, type ComputedRef, nextTick, ref } from 'vue'
|
import { computed, type ComputedRef, nextTick, ref } from 'vue'
|
||||||
import type { Router } from 'vue-router'
|
import type { Router } from 'vue-router'
|
||||||
import { join } from '@tauri-apps/api/path'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
classifyDroppedItem,
|
classifyDroppedItem,
|
||||||
@@ -1412,10 +1412,7 @@ export function useDropImport(options: DropImportOptions) {
|
|||||||
cleanupLauncherZipTemp()
|
cleanupLauncherZipTemp()
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolvedInstancePath(
|
function resolvedInstancePath(inst: SelectedInstance): string | undefined {
|
||||||
inst: SelectedInstance,
|
|
||||||
ctx: ImportContext | null,
|
|
||||||
): string | undefined {
|
|
||||||
if (inst.compatibleMode) return inst.versionPath
|
if (inst.compatibleMode) return inst.versionPath
|
||||||
return inst.path
|
return inst.path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ const createdInstance = ref<string>()
|
|||||||
const completed = ref(false)
|
const completed = ref(false)
|
||||||
let generation = 0
|
let generation = 0
|
||||||
|
|
||||||
|
function errorMessage(cause: unknown) {
|
||||||
|
return cause instanceof Error ? cause.message : String(cause)
|
||||||
|
}
|
||||||
|
|
||||||
export function forgetHostedCreation(instanceId: string) {
|
export function forgetHostedCreation(instanceId: string) {
|
||||||
if (createdInstance.value !== instanceId) return
|
if (createdInstance.value !== instanceId) return
|
||||||
generation++
|
generation++
|
||||||
@@ -27,7 +31,7 @@ export function markHostedCreationCompleted(instanceId: string) {
|
|||||||
export function markHostedCreationFailed(instanceId: string, cause: unknown) {
|
export function markHostedCreationFailed(instanceId: string, cause: unknown) {
|
||||||
if (createdInstance.value !== instanceId) return
|
if (createdInstance.value !== instanceId) return
|
||||||
completed.value = false
|
completed.value = false
|
||||||
installError.value = String(cause)
|
installError.value = errorMessage(cause)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useHostedCreation() {
|
export function useHostedCreation() {
|
||||||
@@ -63,7 +67,7 @@ export function useHostedCreation() {
|
|||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
if (attempt === generation) {
|
if (attempt === generation) {
|
||||||
if (createdInstance.value) markHostedCreationFailed(createdInstance.value, cause)
|
if (createdInstance.value) markHostedCreationFailed(createdInstance.value, cause)
|
||||||
else installError.value = String(cause)
|
else installError.value = errorMessage(cause)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
installing.value = false
|
installing.value = false
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import { createConsoleState } from '@modrinth/ui'
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
clear_log_buffer,
|
clear_log_buffer,
|
||||||
get_live_log_buffer,
|
get_live_log_snapshot,
|
||||||
get_logs,
|
get_logs,
|
||||||
get_minecraft_latest_log_cursor,
|
|
||||||
} from '@/helpers/logs'
|
} from '@/helpers/logs'
|
||||||
|
|
||||||
import { createLatestLogReader } from './latest-log-reader'
|
import {
|
||||||
|
createLiveLogReconciler,
|
||||||
|
type SequencedLogEvent,
|
||||||
|
} from './live-log-reconciler'
|
||||||
|
|
||||||
type ConsoleState = ReturnType<typeof createConsoleState>
|
type ConsoleState = ReturnType<typeof createConsoleState>
|
||||||
|
|
||||||
@@ -25,8 +27,17 @@ interface InstanceConsoleEntry {
|
|||||||
historicalConsole: ConsoleState
|
historicalConsole: ConsoleState
|
||||||
historicalCache: Map<string, string>
|
historicalCache: Map<string, string>
|
||||||
logList: LogEntry[] | null
|
logList: LogEntry[] | null
|
||||||
liveHistoryHydration: Promise<void> | null
|
liveLog: ReturnType<typeof createLiveLogReconciler<ProcessLogPayload>>
|
||||||
latestLog: ReturnType<typeof createLatestLogReader>
|
}
|
||||||
|
|
||||||
|
interface ProcessLogPayload extends SequencedLogEvent {
|
||||||
|
type: 'log4j' | 'legacy'
|
||||||
|
message?: string
|
||||||
|
logger_name?: string
|
||||||
|
level?: string
|
||||||
|
thread_name?: string
|
||||||
|
timestamp_millis?: number
|
||||||
|
throwable?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const instances = new Map<string, InstanceConsoleEntry>()
|
const instances = new Map<string, InstanceConsoleEntry>()
|
||||||
@@ -36,19 +47,28 @@ function getOrCreate(instanceId: string): InstanceConsoleEntry {
|
|||||||
if (entry) return entry
|
if (entry) return entry
|
||||||
|
|
||||||
const liveConsole = createConsoleState()
|
const liveConsole = createConsoleState()
|
||||||
|
const liveLog = createLiveLogReconciler<ProcessLogPayload>(
|
||||||
|
() => get_live_log_snapshot(instanceId),
|
||||||
|
(snapshot) => {
|
||||||
|
liveConsole.clear()
|
||||||
|
void liveConsole.addLegacyLog(
|
||||||
|
snapshot.lines.map((line) => line.message).join('\n'),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
(payload) => {
|
||||||
|
if (payload.type === 'log4j') {
|
||||||
|
liveConsole.addLog4jEvent(payload)
|
||||||
|
} else if (payload.message !== undefined) {
|
||||||
|
void liveConsole.addLegacyLog(payload.message)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
entry = {
|
entry = {
|
||||||
liveConsole,
|
liveConsole,
|
||||||
historicalConsole: createConsoleState(),
|
historicalConsole: createConsoleState(),
|
||||||
historicalCache: new Map(),
|
historicalCache: new Map(),
|
||||||
logList: null,
|
logList: null,
|
||||||
liveHistoryHydration: null,
|
liveLog,
|
||||||
latestLog: createLatestLogReader(
|
|
||||||
(cursor) => get_minecraft_latest_log_cursor(instanceId, cursor),
|
|
||||||
(output, replace) => {
|
|
||||||
if (replace) liveConsole.clear()
|
|
||||||
void liveConsole.addLegacyLog(output)
|
|
||||||
},
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
instances.set(instanceId, entry)
|
instances.set(instanceId, entry)
|
||||||
return entry
|
return entry
|
||||||
@@ -56,28 +76,7 @@ function getOrCreate(instanceId: string): InstanceConsoleEntry {
|
|||||||
|
|
||||||
async function hydrate(instanceId: string): Promise<void> {
|
async function hydrate(instanceId: string): Promise<void> {
|
||||||
const entry = getOrCreate(instanceId)
|
const entry = getOrCreate(instanceId)
|
||||||
if (entry.liveHistoryHydration) {
|
await entry.liveLog.sync()
|
||||||
return entry.liveHistoryHydration
|
|
||||||
}
|
|
||||||
|
|
||||||
const hydration = (async () => {
|
|
||||||
await entry.latestLog.refresh().catch(console.warn)
|
|
||||||
if (!entry.latestLog.active && entry.liveConsole.output.value.length === 0) {
|
|
||||||
const buffer = await get_live_log_buffer(instanceId)
|
|
||||||
if (!entry.latestLog.active && entry.liveConsole.output.value.length === 0) {
|
|
||||||
await entry.liveConsole.addLegacyLog(buffer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
|
|
||||||
entry.liveHistoryHydration = hydration
|
|
||||||
try {
|
|
||||||
await hydration
|
|
||||||
} finally {
|
|
||||||
if (entry.liveHistoryHydration === hydration) {
|
|
||||||
entry.liveHistoryHydration = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getHistoricalLogs(instanceId: string): Promise<LogEntry[]> {
|
async function getHistoricalLogs(instanceId: string): Promise<LogEntry[]> {
|
||||||
@@ -109,15 +108,13 @@ function invalidate(instanceId: string): void {
|
|||||||
|
|
||||||
async function clearLive(instanceId: string): Promise<void> {
|
async function clearLive(instanceId: string): Promise<void> {
|
||||||
const entry = getOrCreate(instanceId)
|
const entry = getOrCreate(instanceId)
|
||||||
entry.latestLog.clear()
|
await clear_log_buffer(instanceId)
|
||||||
entry.liveConsole.clear()
|
await entry.liveLog.resync()
|
||||||
await clear_log_buffer(instanceId).catch(() => {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function destroy(instanceId: string): Promise<void> {
|
function destroy(instanceId: string): void {
|
||||||
instances.get(instanceId)?.latestLog.reset()
|
instances.get(instanceId)?.liveLog.dispose()
|
||||||
instances.delete(instanceId)
|
instances.delete(instanceId)
|
||||||
await clear_log_buffer(instanceId).catch(() => {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useInstanceConsole(instanceId: string) {
|
export function useInstanceConsole(instanceId: string) {
|
||||||
@@ -130,13 +127,8 @@ export function useInstanceConsole(instanceId: string) {
|
|||||||
getHistoricalContent: (filename: string) => getHistoricalContent(instanceId, filename),
|
getHistoricalContent: (filename: string) => getHistoricalContent(instanceId, filename),
|
||||||
invalidate: () => invalidate(instanceId),
|
invalidate: () => invalidate(instanceId),
|
||||||
clearLive: () => clearLive(instanceId),
|
clearLive: () => clearLive(instanceId),
|
||||||
refreshLive: () => entry.latestLog.refresh(),
|
appendLive: (payload: ProcessLogPayload) => entry.liveLog.accept(payload),
|
||||||
flushLive: () => entry.latestLog.flush(),
|
resyncLive: () => entry.liveLog.resync(),
|
||||||
acceptsProcessLogs: () => !entry.latestLog.active,
|
|
||||||
resetLive: () => {
|
|
||||||
entry.latestLog.reset()
|
|
||||||
entry.liveConsole.clear()
|
|
||||||
},
|
|
||||||
destroy: () => destroy(instanceId),
|
destroy: () => destroy(instanceId),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,8 @@ export const AxolotlBrandConfig = Object.freeze({
|
|||||||
productName: 'Starlight Launcher',
|
productName: 'Starlight Launcher',
|
||||||
shortProductName: 'Starlight',
|
shortProductName: 'Starlight',
|
||||||
website: 'https://skin.starlight.cool/',
|
website: 'https://skin.starlight.cool/',
|
||||||
repositoryUrl: 'https://git.starlight.cool/Disy/StarLight-Yggdrasil-Server',
|
repositoryUrl: 'https://github.com/ApTx2012/Starlight_Lancher',
|
||||||
|
releasesUrl: 'https://github.com/ApTx2012/Starlight_Lancher/releases',
|
||||||
supportUrl: 'https://skin.starlight.cool/',
|
supportUrl: 'https://skin.starlight.cool/',
|
||||||
qqGroupNumber: '000000000',
|
qqGroupNumber: '000000000',
|
||||||
qqChannelUrl: 'https://skin.starlight.cool/',
|
qqChannelUrl: 'https://skin.starlight.cool/',
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
|
|
||||||
import { createHostedDownloadFailures } from './hosted-download-failures.ts'
|
import { createHostedDownloadFailures } from './hosted-download-failures.ts'
|
||||||
|
|
||||||
test('retry clears only its own failure before progress arrives and ignores late old events', () => {
|
test('retry clears only its own failure before progress arrives and ignores late old events', () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
requestSkinSiteDownloadToken,
|
requestSkinSiteDownloadToken,
|
||||||
skinSiteStatus,
|
skinSiteStatus,
|
||||||
@@ -6,6 +7,8 @@ import {
|
|||||||
waitForSkinSiteSession,
|
waitForSkinSiteSession,
|
||||||
} from '../composables/skin-site-session.ts'
|
} from '../composables/skin-site-session.ts'
|
||||||
|
|
||||||
|
export const HOSTED_ACCOUNT_REQUIRED_MESSAGE = '您需要登录正版或皮肤站账号后才能操作'
|
||||||
|
|
||||||
let sessionUpdate: Promise<void> = Promise.resolve()
|
let sessionUpdate: Promise<void> = Promise.resolve()
|
||||||
const attemptListeners = new Set<(instanceId: string) => void>()
|
const attemptListeners = new Set<(instanceId: string) => void>()
|
||||||
|
|
||||||
@@ -20,6 +23,13 @@ function startHostedPackAttempt(instanceId: string) {
|
|||||||
for (const listener of attemptListeners) listener(instanceId)
|
for (const listener of attemptListeners) listener(instanceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function requireHostedGameAccount(): Promise<void> {
|
||||||
|
const available = await invokeHosted<boolean>('plugin:install|hosted_has_game_account')
|
||||||
|
if (!available) {
|
||||||
|
throw new Error(HOSTED_ACCOUNT_REQUIRED_MESSAGE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function clearHostedSession(): Promise<void> {
|
export function clearHostedSession(): Promise<void> {
|
||||||
const update = sessionUpdate
|
const update = sessionUpdate
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
@@ -99,13 +109,16 @@ export interface HostedSyncResult {
|
|||||||
}
|
}
|
||||||
export const hostedDefault = () =>
|
export const hostedDefault = () =>
|
||||||
invokeWithSession<HostedPublication>('plugin:install|hosted_default')
|
invokeWithSession<HostedPublication>('plugin:install|hosted_default')
|
||||||
export const hostedCreate = (gameDirRoot?: string | null) =>
|
export const hostedCreate = async (gameDirRoot?: string | null) => {
|
||||||
invokeWithSession<string>('plugin:install|hosted_create', {
|
await requireHostedGameAccount()
|
||||||
|
return invokeWithSession<string>('plugin:install|hosted_create', {
|
||||||
gameDirRoot: gameDirRoot ?? null,
|
gameDirRoot: gameDirRoot ?? null,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
export const hostedBinding = (instanceId: string) =>
|
export const hostedBinding = (instanceId: string) =>
|
||||||
invokeHosted<HostedBinding | null>('plugin:install|hosted_binding', { instanceId })
|
invokeHosted<HostedBinding | null>('plugin:install|hosted_binding', { instanceId })
|
||||||
export const hostedSync = (instanceId: string) => {
|
export const hostedSync = async (instanceId: string) => {
|
||||||
|
await requireHostedGameAccount()
|
||||||
startHostedPackAttempt(instanceId)
|
startHostedPackAttempt(instanceId)
|
||||||
return invokeWithSession<HostedSyncResult>('plugin:install|hosted_sync', { instanceId })
|
return invokeWithSession<HostedSyncResult>('plugin:install|hosted_sync', { instanceId })
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
|
|
||||||
import { isInstanceLaunching, launchOnce } from './instance-launch-state.ts'
|
import { isInstanceLaunching, launchOnce } from './instance-launch-state.ts'
|
||||||
|
|
||||||
test('launches different instances concurrently and coalesces repeated pending clicks', async () => {
|
test('launches different instances concurrently and coalesces repeated pending clicks', async () => {
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
import { useNetworkStatus } from '../composables/useNetworkStatus.ts'
|
|
||||||
import {
|
import {
|
||||||
setSkinSiteFrame,
|
|
||||||
resetSkinSiteSession,
|
|
||||||
receiveSkinSiteMessage,
|
receiveSkinSiteMessage,
|
||||||
|
resetSkinSiteSession,
|
||||||
|
setSkinSiteFrame,
|
||||||
SKIN_SITE_ORIGIN,
|
SKIN_SITE_ORIGIN,
|
||||||
} from '../composables/skin-site-session.ts'
|
} from '../composables/skin-site-session.ts'
|
||||||
|
import { useNetworkStatus } from '../composables/useNetworkStatus.ts'
|
||||||
import {
|
import {
|
||||||
|
type InstancePlayer,
|
||||||
|
onInstancePlayerChanged,
|
||||||
prepareInstancePlayer,
|
prepareInstancePlayer,
|
||||||
registerInstancePlayerPicker,
|
registerInstancePlayerPicker,
|
||||||
saveInstancePlayer,
|
saveInstancePlayer,
|
||||||
onInstancePlayerChanged,
|
|
||||||
type InstancePlayer,
|
|
||||||
} from './instance-player.ts'
|
} from './instance-player.ts'
|
||||||
|
|
||||||
test('instance player selection persists independently from the globally selected account', async () => {
|
test('instance player selection persists independently from the globally selected account', async () => {
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import { detectGcStrategy, GC_STRATEGY_DEFINITIONS } from '@/helpers/gc/strategi
|
|||||||
import type { GcContext, ResolvedGcStrategyId } from '@/helpers/gc/types'
|
import type { GcContext, ResolvedGcStrategyId } from '@/helpers/gc/types'
|
||||||
import { setLastGcLaunchReport } from '@/helpers/gc-notice'
|
import { setLastGcLaunchReport } from '@/helpers/gc-notice'
|
||||||
import { getInstanceMode, prepareHostedSession } from '@/helpers/hosted-packs'
|
import { getInstanceMode, prepareHostedSession } from '@/helpers/hosted-packs'
|
||||||
import { prepareInstancePlayer } from '@/helpers/instance-player'
|
|
||||||
import { launchOnce } from '@/helpers/instance-launch-state'
|
import { launchOnce } from '@/helpers/instance-launch-state'
|
||||||
|
import { prepareInstancePlayer } from '@/helpers/instance-player'
|
||||||
import { AUTO_GC_PRESET_ARG } from '@/helpers/java-arguments'
|
import { AUTO_GC_PRESET_ARG } from '@/helpers/java-arguments'
|
||||||
import { get_jre, get_memory_status } from '@/helpers/jre.js'
|
import { get_jre, get_memory_status } from '@/helpers/jre.js'
|
||||||
import { get as getSettings } from '@/helpers/settings'
|
import { get as getSettings } from '@/helpers/settings'
|
||||||
|
|||||||
@@ -64,14 +64,9 @@ export async function get_latest_log_cursor(instanceId, cursor) {
|
|||||||
return await invoke('plugin:logs|logs_get_latest_log_cursor', { instanceId, cursor })
|
return await invoke('plugin:logs|logs_get_latest_log_cursor', { instanceId, cursor })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read Minecraft's logs/latest.log from a cursor.
|
/// Get the authoritative sequenced live-log snapshot from the Rust ring buffer.
|
||||||
export async function get_minecraft_latest_log_cursor(instanceId, cursor) {
|
export async function get_live_log_snapshot(instanceId) {
|
||||||
return await invoke('plugin:logs|logs_get_minecraft_latest_log_cursor', { instanceId, cursor })
|
return await invoke('plugin:logs|logs_get_live_log_snapshot', { instanceId })
|
||||||
}
|
|
||||||
|
|
||||||
/// Get all buffered live log lines for an instance from the Rust ring buffer
|
|
||||||
export async function get_live_log_buffer(instanceId) {
|
|
||||||
return await invoke('plugin:logs|logs_get_live_log_buffer', { instanceId })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear the live log buffer for an instance on the Rust side
|
/// Clear the live log buffer for an instance on the Rust side
|
||||||
|
|||||||
@@ -82,20 +82,20 @@ test('notice query uses the target instance value and registered Tauri command',
|
|||||||
assert.match(tauriSource, /tauri::generate_handler!\[[\s\S]*instance_get_post_upgrade_notice/)
|
assert.match(tauriSource, /tauri::generate_handler!\[[\s\S]*instance_get_post_upgrade_notice/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('result uses Modrinth Card and Accordion for collapsed compatibility warnings', () => {
|
test('result collections use Modrinth Card and Accordion for collapsed compatibility warnings', () => {
|
||||||
const source = readFileSync(
|
const source = readFileSync(
|
||||||
new URL('../pages/instance/upgrade/UpgradeResultDetails.vue', import.meta.url),
|
new URL('../pages/instance/upgrade/UpgradeResultCollections.vue', import.meta.url),
|
||||||
'utf8',
|
'utf8',
|
||||||
)
|
)
|
||||||
assert.match(source, /<Card v-if="warningRows\.length"/)
|
assert.match(source, /<Card v-if="warnings\.length"/)
|
||||||
assert.match(source, /<Accordion[\s\S]*:open-by-default="warningsExpandedByDefault"/)
|
assert.match(source, /<Accordion[\s\S]*:open-by-default="warningsDefaultOpen"/)
|
||||||
assert.match(source, /<TriangleAlertIcon/)
|
assert.match(source, /<TriangleAlertIcon/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('runtime icon references use names exported by the assets package', () => {
|
test('runtime icon references use names exported by the assets package', () => {
|
||||||
const downloadsSource = readFileSync(new URL('../pages/Downloads.vue', import.meta.url), 'utf8')
|
const downloadsSource = readFileSync(new URL('../pages/Downloads.vue', import.meta.url), 'utf8')
|
||||||
const resultSource = readFileSync(
|
const resultSource = readFileSync(
|
||||||
new URL('../pages/instance/upgrade/UpgradeResultDetails.vue', import.meta.url),
|
new URL('../pages/instance/upgrade/UpgradeResultCollections.vue', import.meta.url),
|
||||||
'utf8',
|
'utf8',
|
||||||
)
|
)
|
||||||
const assetsSource = readFileSync(
|
const assetsSource = readFileSync(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
|
|
||||||
import { createTaggedModProgress } from './tagged-mod-progress.ts'
|
import { createTaggedModProgress } from './tagged-mod-progress.ts'
|
||||||
|
|
||||||
const parent = (id = 'parent', fraction: number | null = 0, error = '') => ({
|
const parent = (id = 'parent', fraction: number | null = 0, error = '') => ({
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动器界面缩放(百分比)。
|
||||||
|
* 这是纯本地的显示偏好,用 localStorage 保存即可,无需写入后端设置数据库。
|
||||||
|
*/
|
||||||
|
const UI_SCALE_STORAGE_KEY = 'starlight-ui-scale'
|
||||||
|
const MIN_UI_SCALE = 50
|
||||||
|
const MAX_UI_SCALE = 200
|
||||||
|
const DEFAULT_UI_SCALE = 100
|
||||||
|
|
||||||
|
/** 把缩放值限制在允许范围内。 */
|
||||||
|
function clampUiScale(value: number): number {
|
||||||
|
if (!Number.isFinite(value)) return DEFAULT_UI_SCALE
|
||||||
|
return Math.min(MAX_UI_SCALE, Math.max(MIN_UI_SCALE, Math.round(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从 localStorage 读取已保存的缩放值。 */
|
||||||
|
function readStoredUiScale(): number {
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(UI_SCALE_STORAGE_KEY)
|
||||||
|
if (raw === null) return DEFAULT_UI_SCALE
|
||||||
|
return clampUiScale(Number(raw))
|
||||||
|
} catch {
|
||||||
|
return DEFAULT_UI_SCALE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const uiScale = ref(readStoredUiScale())
|
||||||
|
|
||||||
|
export function setUiScale(value: number): void {
|
||||||
|
uiScale.value = clampUiScale(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resetUiScale(): void {
|
||||||
|
setUiScale(DEFAULT_UI_SCALE)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { DEFAULT_UI_SCALE, MAX_UI_SCALE, MIN_UI_SCALE }
|
||||||
|
|
||||||
|
/** 把缩放应用到文档根节点,并在变化时持久化。 */
|
||||||
|
export function installUiScale(): void {
|
||||||
|
const apply = (value: number) => {
|
||||||
|
const factor = String(value / 100)
|
||||||
|
const root = document.documentElement
|
||||||
|
root.style.setProperty('--ui-scale', factor)
|
||||||
|
// 用 CSS zoom 整体缩放界面(含内嵌网页),在 WebView2/WebKit 上最可靠。
|
||||||
|
root.style.setProperty('zoom', factor)
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(uiScale.value)
|
||||||
|
watch(uiScale, (value) => {
|
||||||
|
apply(value)
|
||||||
|
try {
|
||||||
|
localStorage.setItem(UI_SCALE_STORAGE_KEY, String(value))
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('保存界面缩放失败', error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -4,9 +4,9 @@ import { invoke } from '@tauri-apps/api/core'
|
|||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
import { isOfflineMode } from '@/composables/useNetworkStatus'
|
import { isOfflineMode } from '@/composables/useNetworkStatus'
|
||||||
import { prepareInstancePlayer } from '@/helpers/instance-player'
|
|
||||||
import { getInstanceMode, prepareHostedSession } from '@/helpers/hosted-packs'
|
import { getInstanceMode, prepareHostedSession } from '@/helpers/hosted-packs'
|
||||||
import { get_full_path, resolveGcLaunchIntent } from '@/helpers/instance'
|
import { get_full_path, resolveGcLaunchIntent } from '@/helpers/instance'
|
||||||
|
import { prepareInstancePlayer } from '@/helpers/instance-player'
|
||||||
import { openPath } from '@/helpers/utils'
|
import { openPath } from '@/helpers/utils'
|
||||||
|
|
||||||
type BaseWorld = {
|
type BaseWorld = {
|
||||||
@@ -20,7 +20,6 @@ type BaseWorld = {
|
|||||||
export type WorldType = 'singleplayer' | 'server'
|
export type WorldType = 'singleplayer' | 'server'
|
||||||
export type DisplayStatus = 'normal' | 'hidden' | 'favorite'
|
export type DisplayStatus = 'normal' | 'hidden' | 'favorite'
|
||||||
|
|
||||||
|
|
||||||
export type SingleplayerWorld = BaseWorld & {
|
export type SingleplayerWorld = BaseWorld & {
|
||||||
type: 'singleplayer'
|
type: 'singleplayer'
|
||||||
path: string
|
path: string
|
||||||
@@ -251,7 +250,7 @@ export async function start_join_singleplayer_world(
|
|||||||
world: string,
|
world: string,
|
||||||
): Promise<unknown> {
|
): Promise<unknown> {
|
||||||
await prepareInstancePlayer(instanceId)
|
await prepareInstancePlayer(instanceId)
|
||||||
if (await getInstanceMode(instanceId) === 'starlight') await prepareHostedSession()
|
if ((await getInstanceMode(instanceId)) === 'starlight') await prepareHostedSession()
|
||||||
const { args, gcIntent } = await resolveGcLaunchIntent(instanceId)
|
const { args, gcIntent } = await resolveGcLaunchIntent(instanceId)
|
||||||
return await invoke('plugin:worlds|start_join_singleplayer_world', {
|
return await invoke('plugin:worlds|start_join_singleplayer_world', {
|
||||||
instanceId,
|
instanceId,
|
||||||
@@ -264,7 +263,7 @@ export async function start_join_singleplayer_world(
|
|||||||
|
|
||||||
export async function start_join_server(instanceId: string, address: string): Promise<unknown> {
|
export async function start_join_server(instanceId: string, address: string): Promise<unknown> {
|
||||||
await prepareInstancePlayer(instanceId)
|
await prepareInstancePlayer(instanceId)
|
||||||
if (await getInstanceMode(instanceId) === 'starlight') await prepareHostedSession()
|
if ((await getInstanceMode(instanceId)) === 'starlight') await prepareHostedSession()
|
||||||
const { args, gcIntent } = await resolveGcLaunchIntent(instanceId)
|
const { args, gcIntent } = await resolveGcLaunchIntent(instanceId)
|
||||||
return await invoke('plugin:worlds|start_join_server', {
|
return await invoke('plugin:worlds|start_join_server', {
|
||||||
instanceId,
|
instanceId,
|
||||||
|
|||||||
@@ -773,6 +773,12 @@
|
|||||||
"app.appearance-settings.transparent-background.title": {
|
"app.appearance-settings.transparent-background.title": {
|
||||||
"message": "Transparent background"
|
"message": "Transparent background"
|
||||||
},
|
},
|
||||||
|
"app.appearance-settings.ui-scale.title": {
|
||||||
|
"message": "Launcher scale"
|
||||||
|
},
|
||||||
|
"app.appearance-settings.ui-scale.description": {
|
||||||
|
"message": "Scale the whole launcher interface. A smaller scale fits more content, which helps when embedded pages are cut off."
|
||||||
|
},
|
||||||
"app.appearance-settings.unknown-pack-warning.description": {
|
"app.appearance-settings.unknown-pack-warning.description": {
|
||||||
"message": "If you attempt to install a Modrinth Pack file (.mrpack) that isn't hosted on Modrinth, we'll make sure you understand the risks before installing it."
|
"message": "If you attempt to install a Modrinth Pack file (.mrpack) that isn't hosted on Modrinth, we'll make sure you understand the risks before installing it."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -805,6 +805,12 @@
|
|||||||
"app.appearance-settings.transparent-background.title": {
|
"app.appearance-settings.transparent-background.title": {
|
||||||
"message": "透明背景"
|
"message": "透明背景"
|
||||||
},
|
},
|
||||||
|
"app.appearance-settings.ui-scale.title": {
|
||||||
|
"message": "启动器缩放"
|
||||||
|
},
|
||||||
|
"app.appearance-settings.ui-scale.description": {
|
||||||
|
"message": "缩放整个启动器界面。缩小后能显示更多内容,适合内嵌网页被裁切的情况。"
|
||||||
|
},
|
||||||
"app.appearance-settings.unknown-pack-warning.description": {
|
"app.appearance-settings.unknown-pack-warning.description": {
|
||||||
"message": "如果你尝试安装一个未托管在 Modrinth 上的 Modrinth 整合包文件(.mrpack),我们会确保你在安装之前了解相关风险。"
|
"message": "如果你尝试安装一个未托管在 Modrinth 上的 Modrinth 整合包文件(.mrpack),我们会确保你在安装之前了解相关风险。"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3093,7 +3093,7 @@ provideBrowseManager({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div data-onboarding-id="browse-content" class="flex flex-col gap-3 p-6">
|
<div data-onboarding-id="browse-content" class="flex flex-col gap-3 p-6">
|
||||||
<BrowsePageLayout v-if="!isWorldMapBrowse || curseForgeCapability.configured">
|
<BrowsePageLayout>
|
||||||
<template #nav-tabs-actions>
|
<template #nav-tabs-actions>
|
||||||
<ButtonStyled size="large" type="transparent">
|
<ButtonStyled size="large" type="transparent">
|
||||||
<button :disabled="translationLoading" @click="toggleTranslation">
|
<button :disabled="translationLoading" @click="toggleTranslation">
|
||||||
@@ -3193,14 +3193,14 @@ provideBrowseManager({
|
|||||||
{{ formatMessage(messages.fuzzySearchSuffix) }}
|
{{ formatMessage(messages.fuzzySearchSuffix) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<EmptyState
|
||||||
|
v-if="isWorldMapBrowse && !curseForgeCapability.configured"
|
||||||
|
type="empty-inbox"
|
||||||
|
:heading="formatMessage(messages.mapsUnavailable)"
|
||||||
|
:description="formatMessage(messages.mapsUnavailableDescription)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</BrowsePageLayout>
|
</BrowsePageLayout>
|
||||||
<EmptyState
|
|
||||||
v-else
|
|
||||||
type="empty-inbox"
|
|
||||||
:heading="formatMessage(messages.mapsUnavailable)"
|
|
||||||
:description="formatMessage(messages.mapsUnavailableDescription)"
|
|
||||||
/>
|
|
||||||
<CreationFlowModal
|
<CreationFlowModal
|
||||||
v-if="isServerContext && projectType === 'modpack'"
|
v-if="isServerContext && projectType === 'modpack'"
|
||||||
ref="serverSetupModalRef"
|
ref="serverSetupModalRef"
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ import { FolderOpenIcon, LeftArrowIcon, SparklesIcon } from '@modrinth/assets'
|
|||||||
import { BigOptionButton, Button, defineMessages, useVIntl } from '@modrinth/ui'
|
import { BigOptionButton, Button, defineMessages, useVIntl } from '@modrinth/ui'
|
||||||
import { inject, ref, watch } from 'vue'
|
import { inject, ref, watch } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import InstanceModeOptions from '@/components/instance/InstanceModeOptions.vue'
|
|
||||||
import HostedGameDirModal from '@/components/instance/HostedGameDirModal.vue'
|
import HostedGameDirModal from '@/components/instance/HostedGameDirModal.vue'
|
||||||
import HostedPackProgress from '@/components/instance/HostedPackProgress.vue'
|
import HostedPackProgress from '@/components/instance/HostedPackProgress.vue'
|
||||||
import type { InstanceMode } from '@/helpers/hosted-packs'
|
import InstanceModeOptions from '@/components/instance/InstanceModeOptions.vue'
|
||||||
import { useHostedCreation } from '@/composables/useHostedCreation'
|
import { useHostedCreation } from '@/composables/useHostedCreation'
|
||||||
|
import type { InstanceMode } from '@/helpers/hosted-packs'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -187,8 +188,8 @@ function handleImportExisting() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<BigOptionButton
|
<BigOptionButton
|
||||||
data-onboarding-id="creation-method-import"
|
|
||||||
v-if="instanceMode === 'local'"
|
v-if="instanceMode === 'local'"
|
||||||
|
data-onboarding-id="creation-method-import"
|
||||||
:icon="FolderOpenIcon"
|
:icon="FolderOpenIcon"
|
||||||
:title="formatMessage(messages.importTitle)"
|
:title="formatMessage(messages.importTitle)"
|
||||||
:description="formatMessage(messages.importDescription)"
|
:description="formatMessage(messages.importDescription)"
|
||||||
@@ -197,10 +198,7 @@ function handleImportExisting() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<HostedGameDirModal
|
<HostedGameDirModal ref="hostedGameDirModal" @confirm="installHostedWithGameDir" />
|
||||||
ref="hostedGameDirModal"
|
|
||||||
@confirm="installHostedWithGameDir"
|
|
||||||
/>
|
|
||||||
<HostedPackProgress :instance-id="createdInstance" :active="installing" />
|
<HostedPackProgress :instance-id="createdInstance" :active="installing" />
|
||||||
<p v-if="installError" class="m-0 text-red" role="alert">{{ installError }}</p>
|
<p v-if="installError" class="m-0 text-red" role="alert">{{ installError }}</p>
|
||||||
<p v-if="instanceMode === 'local'" class="m-0 text-sm text-secondary">
|
<p v-if="instanceMode === 'local'" class="m-0 text-sm text-secondary">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { computed, onUnmounted, ref } from 'vue'
|
|||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
import { getActivePlayerName } from '@/components/home/home-utils'
|
import { getActivePlayerName } from '@/components/home/home-utils'
|
||||||
import HomeDailyChallenge from '@/components/home/HomeDailyChallenge.vue'
|
import HomeAnnouncementEntry from '@/components/home/HomeAnnouncementEntry.vue'
|
||||||
import HomeInstancePickerModal from '@/components/home/HomeInstancePickerModal.vue'
|
import HomeInstancePickerModal from '@/components/home/HomeInstancePickerModal.vue'
|
||||||
import HomeLaunchProgress from '@/components/home/HomeLaunchProgress.vue'
|
import HomeLaunchProgress from '@/components/home/HomeLaunchProgress.vue'
|
||||||
import HomeMinecraftNews from '@/components/home/HomeMinecraftNews.vue'
|
import HomeMinecraftNews from '@/components/home/HomeMinecraftNews.vue'
|
||||||
@@ -202,7 +202,7 @@ onUnmounted(() => {
|
|||||||
>
|
>
|
||||||
<HomeLaunchProgress />
|
<HomeLaunchProgress />
|
||||||
<HomePlayInsights />
|
<HomePlayInsights />
|
||||||
<HomeDailyChallenge />
|
<HomeAnnouncementEntry />
|
||||||
<HomeMinecraftNews />
|
<HomeMinecraftNews />
|
||||||
</div>
|
</div>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ onMounted(() => {
|
|||||||
/>
|
/>
|
||||||
<div class="flex flex-col gap-1.5">
|
<div class="flex flex-col gap-1.5">
|
||||||
<ButtonStyled color="brand">
|
<ButtonStyled color="brand">
|
||||||
<button class="start-button" @click="startTranslation" :disabled="!canStart">
|
<button class="start-button" :disabled="!canStart" @click="startTranslation">
|
||||||
<PlayIcon />{{ formatMessage(messages.start) }}
|
<PlayIcon />{{ formatMessage(messages.start) }}
|
||||||
</button>
|
</button>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ import {
|
|||||||
defineMessages,
|
defineMessages,
|
||||||
DropdownSelect,
|
DropdownSelect,
|
||||||
injectNotificationManager,
|
injectNotificationManager,
|
||||||
|
type MessageDescriptor,
|
||||||
PopoutMenu,
|
PopoutMenu,
|
||||||
Slider,
|
Slider,
|
||||||
StyledInput,
|
StyledInput,
|
||||||
Toggle,
|
Toggle,
|
||||||
type MessageDescriptor,
|
|
||||||
useRelativeTime,
|
useRelativeTime,
|
||||||
useVIntl,
|
useVIntl,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
import { UsersIcon } from '@modrinth/assets'
|
import { UsersIcon } from '@modrinth/assets'
|
||||||
import { defineMessages, NavTabs, useVIntl } from '@modrinth/ui'
|
import { defineMessages, NavTabs, useVIntl } from '@modrinth/ui'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { RouterView, useRoute, useRouter } from 'vue-router'
|
import { RouterView, useRouter } from 'vue-router'
|
||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const route = useRoute()
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
@@ -13,7 +12,6 @@ const messages = defineMessages({
|
|||||||
roomsTab: { id: 'app.multiplayer.tab.rooms', defaultMessage: 'Rooms' },
|
roomsTab: { id: 'app.multiplayer.tab.rooms', defaultMessage: 'Rooms' },
|
||||||
})
|
})
|
||||||
|
|
||||||
const activeTab = computed(() => (route.path.startsWith('/multiplayer/rooms') ? 'rooms' : 'rooms'))
|
|
||||||
const tabLinks = computed(() => [
|
const tabLinks = computed(() => [
|
||||||
{ label: formatMessage(messages.roomsTab), href: '/multiplayer/rooms', icon: UsersIcon },
|
{ label: formatMessage(messages.roomsTab), href: '/multiplayer/rooms', icon: UsersIcon },
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -163,7 +163,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
<ButtonStyled v-else-if="!isServerInstance" color="brand" size="large">
|
<ButtonStyled v-else-if="!isServerInstance" color="brand" size="large">
|
||||||
<button @click="startInstance('InstancePage')">
|
<button @click="startInstance">
|
||||||
<PlayIcon />
|
<PlayIcon />
|
||||||
{{ formatMessage(playing ? messages.launchAnother : commonMessages.playButton) }}
|
{{ formatMessage(playing ? messages.launchAnother : commonMessages.playButton) }}
|
||||||
</button>
|
</button>
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'launch_instance',
|
id: 'launch_instance',
|
||||||
action: () => startInstance('InstancePage'),
|
action: startInstance,
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
</div>
|
</div>
|
||||||
<ButtonStyled v-if="playing" color="red" size="large">
|
<ButtonStyled v-if="playing" color="red" size="large">
|
||||||
<button :disabled="stopping || loading" @click="stopInstance('InstancePage')">
|
<button :disabled="stopping || loading" @click="stopInstance">
|
||||||
<StopCircleIcon />
|
<StopCircleIcon />
|
||||||
{{ formatMessage(stopping ? messages.stopping : messages.stopAll) }}
|
{{ formatMessage(stopping ? messages.stopping : messages.stopAll) }}
|
||||||
</button>
|
</button>
|
||||||
@@ -294,7 +294,7 @@
|
|||||||
:is-server-instance="isServerInstance"
|
:is-server-instance="isServerInstance"
|
||||||
:open-settings="() => settingsModal?.show(1)"
|
:open-settings="() => settingsModal?.show(1)"
|
||||||
@play="updatePlayState"
|
@play="updatePlayState"
|
||||||
@stop="() => stopInstance('InstanceSubpage')"
|
@stop="stopInstance"
|
||||||
></component>
|
></component>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</template>
|
</template>
|
||||||
@@ -400,9 +400,9 @@ import {
|
|||||||
getFreshCachedServerStatus,
|
getFreshCachedServerStatus,
|
||||||
} from '@/composables/instances/use-server-status-query'
|
} from '@/composables/instances/use-server-status-query'
|
||||||
import { useInstanceConsole } from '@/composables/useInstanceConsole'
|
import { useInstanceConsole } from '@/composables/useInstanceConsole'
|
||||||
|
import { useInstanceMode } from '@/composables/useInstanceMode'
|
||||||
import { useMinecraftLaunchError } from '@/composables/useMinecraftLaunchError'
|
import { useMinecraftLaunchError } from '@/composables/useMinecraftLaunchError'
|
||||||
import { useNetworkStatus } from '@/composables/useNetworkStatus'
|
import { useNetworkStatus } from '@/composables/useNetworkStatus'
|
||||||
import { useInstanceMode } from '@/composables/useInstanceMode'
|
|
||||||
import { postUpgradeNoticeQueryKey, usePostUpgradeNotice } from '@/composables/usePostUpgradeNotice'
|
import { postUpgradeNoticeQueryKey, usePostUpgradeNotice } from '@/composables/usePostUpgradeNotice'
|
||||||
import { useSymlinkWarningDismiss } from '@/composables/useSymlinkWarningDismiss'
|
import { useSymlinkWarningDismiss } from '@/composables/useSymlinkWarningDismiss'
|
||||||
import { get_project_v3 } from '@/helpers/cache.js'
|
import { get_project_v3 } from '@/helpers/cache.js'
|
||||||
@@ -421,8 +421,8 @@ import {
|
|||||||
run,
|
run,
|
||||||
} from '@/helpers/instance'
|
} from '@/helpers/instance'
|
||||||
import { getDisplayInstanceIcon } from '@/helpers/instance-icons'
|
import { getDisplayInstanceIcon } from '@/helpers/instance-icons'
|
||||||
import { get_by_instance_id } from '@/helpers/process'
|
|
||||||
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
import { isInstanceLaunching } from '@/helpers/instance-launch-state'
|
||||||
|
import { get_by_instance_id } from '@/helpers/process'
|
||||||
import type { GameInstance } from '@/helpers/types'
|
import type { GameInstance } from '@/helpers/types'
|
||||||
import { createInstanceShortcut, showInstanceInFolder } from '@/helpers/utils.js'
|
import { createInstanceShortcut, showInstanceInFolder } from '@/helpers/utils.js'
|
||||||
import { refreshWorlds, type ServerStatus } from '@/helpers/worlds'
|
import { refreshWorlds, type ServerStatus } from '@/helpers/worlds'
|
||||||
@@ -733,7 +733,7 @@ watch(
|
|||||||
|
|
||||||
const options = ref<InstanceType<typeof ContextMenu> | null>(null)
|
const options = ref<InstanceType<typeof ContextMenu> | null>(null)
|
||||||
|
|
||||||
const startInstance = async (context: string) => {
|
const startInstance = async () => {
|
||||||
if (!instance.value || loading.value) return
|
if (!instance.value || loading.value) return
|
||||||
const id = props.id
|
const id = props.id
|
||||||
const name = instance.value.name
|
const name = instance.value.name
|
||||||
@@ -780,7 +780,7 @@ watch(
|
|||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
const stopInstance = async (context: string) => {
|
const stopInstance = async () => {
|
||||||
stopping.value = true
|
stopping.value = true
|
||||||
await kill(props.id).catch(handleError)
|
await kill(props.id).catch(handleError)
|
||||||
stopping.value = false
|
stopping.value = false
|
||||||
@@ -882,10 +882,10 @@ const handleRightClick = (event: MouseEvent) => {
|
|||||||
const handleOptionsClick = async (args: { option: string; item: unknown }) => {
|
const handleOptionsClick = async (args: { option: string; item: unknown }) => {
|
||||||
switch (args.option) {
|
switch (args.option) {
|
||||||
case 'play':
|
case 'play':
|
||||||
await startInstance('InstancePageContextMenu')
|
await startInstance()
|
||||||
break
|
break
|
||||||
case 'stop':
|
case 'stop':
|
||||||
await stopInstance('InstancePageContextMenu')
|
await stopInstance()
|
||||||
break
|
break
|
||||||
case 'add_content':
|
case 'add_content':
|
||||||
await router.push({
|
await router.push({
|
||||||
|
|||||||
@@ -86,13 +86,16 @@ const {
|
|||||||
getHistoricalContent,
|
getHistoricalContent,
|
||||||
invalidate,
|
invalidate,
|
||||||
clearLive,
|
clearLive,
|
||||||
refreshLive,
|
appendLive,
|
||||||
flushLive,
|
resyncLive,
|
||||||
acceptsProcessLogs,
|
|
||||||
resetLive,
|
|
||||||
} = useInstanceConsole(instanceId.value)
|
} = useInstanceConsole(instanceId.value)
|
||||||
|
|
||||||
await hydrate()
|
const unlistenLog = await log_listener((payload) => {
|
||||||
|
if (payload.instance_id !== instanceId.value) return
|
||||||
|
void appendLive(payload)?.catch(console.warn)
|
||||||
|
})
|
||||||
|
|
||||||
|
await hydrate().catch(handleError)
|
||||||
|
|
||||||
function buildLogList(rawLogs) {
|
function buildLogList(rawLogs) {
|
||||||
return [
|
return [
|
||||||
@@ -219,28 +222,16 @@ if (!props.playing) {
|
|||||||
void analyseForCrash()
|
void analyseForCrash()
|
||||||
}
|
}
|
||||||
|
|
||||||
const unlistenLog = await log_listener((payload) => {
|
|
||||||
if (payload.instance_id !== instanceId.value) return
|
|
||||||
if (!acceptsProcessLogs()) return
|
|
||||||
|
|
||||||
if (payload.type === 'log4j') {
|
|
||||||
liveConsole.addLog4jEvent(payload)
|
|
||||||
} else if (payload.type === 'legacy') {
|
|
||||||
void liveConsole.addLegacyLog(payload.message)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const unlistenProcesses = await process_listener(async (e) => {
|
const unlistenProcesses = await process_listener(async (e) => {
|
||||||
if (e.instance_id !== instanceId.value) return
|
if (e.instance_id !== instanceId.value) return
|
||||||
if (e.event === 'launched') {
|
if (e.event === 'launched') {
|
||||||
resetLive()
|
await resyncLive().catch(console.warn)
|
||||||
clearCrashAnalysis()
|
clearCrashAnalysis()
|
||||||
invalidate()
|
invalidate()
|
||||||
selectedLogIndex.value = 0
|
selectedLogIndex.value = 0
|
||||||
}
|
}
|
||||||
if (e.event === 'finished') {
|
if (e.event === 'finished') {
|
||||||
await refreshLive().catch(console.warn)
|
await resyncLive().catch(console.warn)
|
||||||
flushLive()
|
|
||||||
invalidate()
|
invalidate()
|
||||||
const freshLogs = await getHistoricalLogs()
|
const freshLogs = await getHistoricalLogs()
|
||||||
logs.value = buildLogList(freshLogs)
|
logs.value = buildLogList(freshLogs)
|
||||||
@@ -248,20 +239,7 @@ const unlistenProcesses = await process_listener(async (e) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Keep following the file even when a mod stops writing to stdout after startup.
|
|
||||||
// Schedule after each read so slow disk/IPC cannot pile up concurrent requests.
|
|
||||||
let disposed = false
|
|
||||||
let refreshTimer
|
|
||||||
async function followLatestLog() {
|
|
||||||
await refreshLive().catch(console.warn)
|
|
||||||
if (!props.playing) flushLive()
|
|
||||||
if (!disposed) refreshTimer = setTimeout(followLatestLog, 1000)
|
|
||||||
}
|
|
||||||
void followLatestLog()
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
disposed = true
|
|
||||||
clearTimeout(refreshTimer)
|
|
||||||
unlistenLog()
|
unlistenLog()
|
||||||
unlistenProcesses()
|
unlistenProcesses()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1408,7 +1408,8 @@ async function getUpdaterProjectVersions(
|
|||||||
|
|
||||||
if (!versions) {
|
if (!versions) {
|
||||||
versions = (await get_project_versions(projectId).catch(() => null)) as
|
versions = (await get_project_versions(projectId).catch(() => null)) as
|
||||||
Labrinth.Versions.v2.Version[] | null
|
| Labrinth.Versions.v2.Version[]
|
||||||
|
| null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!versions && fetchError) {
|
if (!versions && fetchError) {
|
||||||
@@ -1719,9 +1720,6 @@ async function applyToggleDisableBatch(items: ContentItem[], enabled: boolean) {
|
|||||||
resultById,
|
resultById,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
for (const operation of operations) {
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
for (const operation of operations) {
|
for (const operation of operations) {
|
||||||
operation.optimisticPath = operation.originalFilePath
|
operation.optimisticPath = operation.originalFilePath
|
||||||
|
|||||||
@@ -845,7 +845,7 @@ async function installSelected(fileId: string | null) {
|
|||||||
}
|
}
|
||||||
if (isWorldMap.value) {
|
if (isWorldMap.value) {
|
||||||
installing.value = true
|
installing.value = true
|
||||||
await installCurseForgeWorld(project.value.id, fileId, instanceId.value, 'ProjectPage', () => {
|
await installCurseForgeWorld(project.value.id, fileId, instanceId.value, () => {
|
||||||
installing.value = false
|
installing.value = false
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
installing.value = false
|
installing.value = false
|
||||||
|
|||||||
@@ -414,8 +414,8 @@ import {
|
|||||||
ProjectSidebarServerInfo,
|
ProjectSidebarServerInfo,
|
||||||
ProjectSidebarTags,
|
ProjectSidebarTags,
|
||||||
requestInstall,
|
requestInstall,
|
||||||
SelectedProjectsFloatingBar,
|
|
||||||
ScrollToTopButton,
|
ScrollToTopButton,
|
||||||
|
SelectedProjectsFloatingBar,
|
||||||
usesTargetGameVersion,
|
usesTargetGameVersion,
|
||||||
useVIntl,
|
useVIntl,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
@@ -567,7 +567,7 @@ const messages = defineMessages({
|
|||||||
favoritesLoading: {
|
favoritesLoading: {
|
||||||
id: 'app.content-favorites.loading',
|
id: 'app.content-favorites.loading',
|
||||||
defaultMessage: 'Updating favorites…',
|
defaultMessage: 'Updating favorites…',
|
||||||
},
|
},
|
||||||
viewDependents: {
|
viewDependents: {
|
||||||
id: 'project.actions.view-dependents',
|
id: 'project.actions.view-dependents',
|
||||||
defaultMessage: 'View dependents',
|
defaultMessage: 'View dependents',
|
||||||
|
|||||||
@@ -72,12 +72,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import { CheckIcon, DownloadIcon, ExternalIcon, MoreVerticalIcon } from '@modrinth/assets'
|
||||||
CheckIcon,
|
|
||||||
DownloadIcon,
|
|
||||||
ExternalIcon,
|
|
||||||
MoreVerticalIcon,
|
|
||||||
} from '@modrinth/assets'
|
|
||||||
import {
|
import {
|
||||||
ButtonStyled,
|
ButtonStyled,
|
||||||
commonMessages,
|
commonMessages,
|
||||||
@@ -108,7 +103,7 @@ const messages = defineMessages({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const props = defineProps({
|
defineProps({
|
||||||
project: {
|
project: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
|
|||||||
@@ -517,7 +517,6 @@ export interface ContentInstallContext {
|
|||||||
projectId: string | number,
|
projectId: string | number,
|
||||||
fileId?: string | number | null,
|
fileId?: string | number | null,
|
||||||
instanceId?: string | null,
|
instanceId?: string | null,
|
||||||
source?: string,
|
|
||||||
callback?: ContentInstallCallback,
|
callback?: ContentInstallCallback,
|
||||||
) => Promise<void>
|
) => Promise<void>
|
||||||
installingItems: Ref<Map<string, ContentItem[]>>
|
installingItems: Ref<Map<string, ContentItem[]>>
|
||||||
@@ -1884,7 +1883,6 @@ export function createContentInstall(opts: {
|
|||||||
markInstanceContentChanged(instance.id)
|
markInstanceContentChanged(instance.id)
|
||||||
incompatibilityWarningModalRef?.hide()
|
incompatibilityWarningModalRef?.hide()
|
||||||
removeInstallingItems(instance.id, [project.id])
|
removeInstallingItems(instance.id, [project.id])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleIncompatibilityWarningCancel() {
|
function handleIncompatibilityWarningCancel() {
|
||||||
@@ -2056,7 +2054,6 @@ export function createContentInstall(opts: {
|
|||||||
: `/instance/${encodeURIComponent(id)}`,
|
: `/instance/${encodeURIComponent(id)}`,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
settleCurrentCallback(version.id, installedProjectIds)
|
settleCurrentCallback(version.id, installedProjectIds)
|
||||||
modalRef?.hide()
|
modalRef?.hide()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -2116,10 +2113,14 @@ export function createContentInstall(opts: {
|
|||||||
if (project.project_type === 'modpack') {
|
if (project.project_type === 'modpack') {
|
||||||
if (shouldShowInstallTargetModal) hideContentInstallModal()
|
if (shouldShowInstallTargetModal) hideContentInstallModal()
|
||||||
const [versions, packs] = await Promise.all([
|
const [versions, packs] = await Promise.all([
|
||||||
get_version_many(project.versions, 'must_revalidate') as Promise<Labrinth.Versions.v2.Version[]>,
|
get_version_many(project.versions, 'must_revalidate') as Promise<
|
||||||
|
Labrinth.Versions.v2.Version[]
|
||||||
|
>,
|
||||||
list(),
|
list(),
|
||||||
])
|
])
|
||||||
const sortedVersions = versions.sort((a, b) => dayjs(b.date_published).valueOf() - dayjs(a.date_published).valueOf())
|
const sortedVersions = versions.sort(
|
||||||
|
(a, b) => dayjs(b.date_published).valueOf() - dayjs(a.date_published).valueOf(),
|
||||||
|
)
|
||||||
pendingModpackInstall = {
|
pendingModpackInstall = {
|
||||||
project,
|
project,
|
||||||
version: versionId ?? sortedVersions[0]?.id ?? '',
|
version: versionId ?? sortedVersions[0]?.id ?? '',
|
||||||
@@ -2132,7 +2133,10 @@ export function createContentInstall(opts: {
|
|||||||
sortedVersions.map((version) => [
|
sortedVersions.map((version) => [
|
||||||
version.id,
|
version.id,
|
||||||
packs
|
packs
|
||||||
.filter((pack) => pack.link?.project_id === project.id && pack.link?.version_id === version.id)
|
.filter(
|
||||||
|
(pack) =>
|
||||||
|
pack.link?.project_id === project.id && pack.link?.version_id === version.id,
|
||||||
|
)
|
||||||
.map((pack) => ({ id: pack.id, name: pack.name })),
|
.map((pack) => ({ id: pack.id, name: pack.name })),
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
@@ -2391,7 +2395,6 @@ export function createContentInstall(opts: {
|
|||||||
projectId: string | number,
|
projectId: string | number,
|
||||||
fileId?: string | number | null,
|
fileId?: string | number | null,
|
||||||
instanceId?: string | null,
|
instanceId?: string | null,
|
||||||
source: string = 'unknown',
|
|
||||||
callback: ContentInstallCallback = () => {},
|
callback: ContentInstallCallback = () => {},
|
||||||
) {
|
) {
|
||||||
const modalSessionId = instanceId ? null : beginInstallSession(callback)
|
const modalSessionId = instanceId ? null : beginInstallSession(callback)
|
||||||
@@ -2486,11 +2489,10 @@ export function createContentInstall(opts: {
|
|||||||
projectId: string | number,
|
projectId: string | number,
|
||||||
fileId?: string | number | null,
|
fileId?: string | number | null,
|
||||||
instanceId?: string | null,
|
instanceId?: string | null,
|
||||||
source: string = 'unknown',
|
|
||||||
callback: ContentInstallCallback = () => {},
|
callback: ContentInstallCallback = () => {},
|
||||||
) {
|
) {
|
||||||
return guardInstallRequest(
|
return guardInstallRequest(
|
||||||
() => installCurseForgeWorldInternal(projectId, fileId, instanceId, source, callback),
|
() => installCurseForgeWorldInternal(projectId, fileId, instanceId, callback),
|
||||||
callback,
|
callback,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -2532,8 +2534,7 @@ export function createContentInstall(opts: {
|
|||||||
handleCurseForgeManualDownloadsImported,
|
handleCurseForgeManualDownloadsImported,
|
||||||
async handleModpackInstall(versionId: string, name: string) {
|
async handleModpackInstall(versionId: string, name: string) {
|
||||||
if (!pendingModpackInstall) return
|
if (!pendingModpackInstall) return
|
||||||
const { project, source, callback, createInstanceCallback, provider } =
|
const { project, source, callback, createInstanceCallback, provider } = pendingModpackInstall
|
||||||
pendingModpackInstall
|
|
||||||
pendingModpackInstall = null
|
pendingModpackInstall = null
|
||||||
if (provider === 'curseforge') {
|
if (provider === 'curseforge') {
|
||||||
const numericProjectId = Number(project.id.replace(/^curseforge:/, ''))
|
const numericProjectId = Number(project.id.replace(/^curseforge:/, ''))
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "theseus_gui"
|
name = "theseus_gui"
|
||||||
# The actual version is set by the theseus-build workflow on tagging
|
# The actual version is set by the theseus-build workflow on tagging
|
||||||
version = "1.0.0-beta12"
|
version = "1.0.0-beta15"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
description = "Axolotl Launcher is a cross-platform Minecraft launcher"
|
description = "Axolotl Launcher is a cross-platform Minecraft launcher"
|
||||||
homepage = "https://www.ghs.red"
|
homepage = "https://www.ghs.red"
|
||||||
|
|||||||
+1
-2
@@ -292,8 +292,7 @@ fn main() {
|
|||||||
"logs_delete_logs",
|
"logs_delete_logs",
|
||||||
"logs_delete_logs_by_filename",
|
"logs_delete_logs_by_filename",
|
||||||
"logs_get_latest_log_cursor",
|
"logs_get_latest_log_cursor",
|
||||||
"logs_get_minecraft_latest_log_cursor",
|
"logs_get_live_log_snapshot",
|
||||||
"logs_get_live_log_buffer",
|
|
||||||
"logs_clear_live_log_buffer",
|
"logs_clear_live_log_buffer",
|
||||||
"logs_analyze_crash",
|
"logs_analyze_crash",
|
||||||
"logs_get_crash_analysis_ai_settings",
|
"logs_get_crash_analysis_ai_settings",
|
||||||
|
|||||||
@@ -547,6 +547,7 @@ fn keyring_error(
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
fn parse_custom_uuid(uuid: Option<String>) -> Result<Option<uuid::Uuid>> {
|
fn parse_custom_uuid(uuid: Option<String>) -> Result<Option<uuid::Uuid>> {
|
||||||
let Some(uuid) = uuid else {
|
let Some(uuid) = uuid else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
|||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
hosted_default,
|
hosted_default,
|
||||||
hosted_set_session,
|
hosted_set_session,
|
||||||
|
hosted_has_game_account,
|
||||||
hosted_create,
|
hosted_create,
|
||||||
hosted_binding,
|
hosted_binding,
|
||||||
hosted_sync,
|
hosted_sync,
|
||||||
@@ -65,6 +66,11 @@ pub async fn hosted_default() -> Result<theseus::pack::hosted::Publication> {
|
|||||||
Ok(theseus::pack::hosted::default_publication().await?)
|
Ok(theseus::pack::hosted::default_publication().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn hosted_has_game_account() -> Result<bool> {
|
||||||
|
Ok(theseus::pack::hosted::has_game_account().await?)
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn hosted_create(game_dir_root: Option<String>) -> Result<String> {
|
pub async fn hosted_create(game_dir_root: Option<String>) -> Result<String> {
|
||||||
Ok(theseus::pack::hosted::create(game_dir_root).await?)
|
Ok(theseus::pack::hosted::create(game_dir_root).await?)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
|||||||
use theseus::logs::LogType;
|
use theseus::logs::LogType;
|
||||||
use theseus::logs::{
|
use theseus::logs::{
|
||||||
self, CensoredString, CrashAnalysis, CrashAnalysisAiExplanation,
|
self, CensoredString, CrashAnalysis, CrashAnalysisAiExplanation,
|
||||||
CrashAnalysisAiSettings, LatestLogCursor, Logs,
|
CrashAnalysisAiSettings, LatestLogCursor, LiveLogSnapshot, Logs,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -26,8 +26,7 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
|||||||
logs_delete_logs,
|
logs_delete_logs,
|
||||||
logs_delete_logs_by_filename,
|
logs_delete_logs_by_filename,
|
||||||
logs_get_latest_log_cursor,
|
logs_get_latest_log_cursor,
|
||||||
logs_get_minecraft_latest_log_cursor,
|
logs_get_live_log_snapshot,
|
||||||
logs_get_live_log_buffer,
|
|
||||||
logs_clear_live_log_buffer,
|
logs_clear_live_log_buffer,
|
||||||
logs_analyze_crash,
|
logs_analyze_crash,
|
||||||
logs_get_crash_analysis_ai_settings,
|
logs_get_crash_analysis_ai_settings,
|
||||||
@@ -95,24 +94,12 @@ pub async fn logs_get_latest_log_cursor(
|
|||||||
Ok(logs::get_latest_log_cursor(instance_id, cursor).await?)
|
Ok(logs::get_latest_log_cursor(instance_id, cursor).await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get Minecraft's logs/latest.log from a cursor.
|
|
||||||
#[tauri::command]
|
|
||||||
pub async fn logs_get_minecraft_latest_log_cursor(
|
|
||||||
instance_id: &str,
|
|
||||||
cursor: u64, // 0 to start at beginning of file
|
|
||||||
) -> Result<LatestLogCursor> {
|
|
||||||
Ok(
|
|
||||||
logs::get_generic_live_log_cursor(instance_id, "latest.log", cursor)
|
|
||||||
.await?,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get all buffered live log lines for an instance.
|
/// Get all buffered live log lines for an instance.
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn logs_get_live_log_buffer(
|
pub async fn logs_get_live_log_snapshot(
|
||||||
instance_id: &str,
|
instance_id: &str,
|
||||||
) -> Result<CensoredString> {
|
) -> Result<LiveLogSnapshot> {
|
||||||
Ok(logs::get_live_log_buffer(instance_id).await?)
|
Ok(logs::get_live_log_snapshot(instance_id).await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear the live log buffer for an instance.
|
/// Clear the live log buffer for an instance.
|
||||||
|
|||||||
@@ -548,6 +548,10 @@ fn schedule_tray_menu_update(app: &AppHandle) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn state_initialized(app: &AppHandle) {
|
||||||
|
schedule_tray_menu_update(app);
|
||||||
|
}
|
||||||
|
|
||||||
async fn rebuild_tray_menu(
|
async fn rebuild_tray_menu(
|
||||||
app: &AppHandle,
|
app: &AppHandle,
|
||||||
active: bool,
|
active: bool,
|
||||||
@@ -708,7 +712,6 @@ pub fn init(app: &AppHandle) {
|
|||||||
.build(app)
|
.build(app)
|
||||||
.expect("failed to create system tray");
|
.expect("failed to create system tray");
|
||||||
let _tray = tray;
|
let _tray = tray;
|
||||||
schedule_tray_menu_update(app);
|
|
||||||
let app_handle = app.clone();
|
let app_handle = app.clone();
|
||||||
app.listen("process", move |event| {
|
app.listen("process", move |event| {
|
||||||
let Ok(payload) =
|
let Ok(payload) =
|
||||||
|
|||||||
+10
-4
@@ -315,6 +315,8 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
|||||||
app.fs_scope()
|
app.fs_scope()
|
||||||
.allow_directory(state.directories.servers_dir(), true)?;
|
.allow_directory(state.directories.servers_dir(), true)?;
|
||||||
|
|
||||||
|
lightweight_mode::state_initialized(&app);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,10 +571,9 @@ fn is_dev() -> bool {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn are_updates_enabled() -> bool {
|
fn are_updates_enabled() -> bool {
|
||||||
// Temporarily disabled: enabling the built-in updater causes an immediate
|
// The frontend waits for launcher state initialization before starting
|
||||||
// crash on Windows (c0000409) at startup, pending a fix.
|
// the built-in updater.
|
||||||
// StarLight launcher ships without the built-in update checker.
|
true
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "updater")]
|
#[cfg(feature = "updater")]
|
||||||
@@ -910,6 +911,11 @@ fn main() {
|
|||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[cfg(feature = "updater")]
|
||||||
|
{
|
||||||
|
builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
|
||||||
|
}
|
||||||
|
|
||||||
builder = builder
|
builder = builder
|
||||||
.plugin(api::ai::init())
|
.plugin(api::ai::init())
|
||||||
.plugin(api::auth::init())
|
.plugin(api::auth::init())
|
||||||
|
|||||||
@@ -71,6 +71,13 @@
|
|||||||
"schemes": ["starlight"]
|
"schemes": ["starlight"]
|
||||||
},
|
},
|
||||||
"mobile": []
|
"mobile": []
|
||||||
|
},
|
||||||
|
"updater": {
|
||||||
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEQ0NDhERTUxN0E3MERBNDYKUldSRzJuQjZVZDVJMUpKSUJ6blVpVzJQSTgvSjlyeVRGK0ozRzcwVWtpbTJjbUl0V0NRcC9OQVoK",
|
||||||
|
"endpoints": ["https://skin.starlight.cool/starlight/launcher/latest"],
|
||||||
|
"windows": {
|
||||||
|
"installMode": "quiet"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
|
|||||||
@@ -1,6 +1,100 @@
|
|||||||
{
|
{
|
||||||
"updated_at": "2026-09-26T01:53:59.007Z",
|
"updated_at": "2026-09-30T15:12:17.359Z",
|
||||||
"announcements": [
|
"announcements": [
|
||||||
|
{
|
||||||
|
"id": "launcher-1.0.1-beta3",
|
||||||
|
"version": "1.0.1-beta3",
|
||||||
|
"publishedAt": "2026-09-30",
|
||||||
|
"title": {
|
||||||
|
"en-US": "Starlight Launcher 1.0.1-beta3",
|
||||||
|
"zh-CN": "Starlight Launcher 1.0.1-beta3"
|
||||||
|
},
|
||||||
|
"changes": {
|
||||||
|
"added": [
|
||||||
|
{
|
||||||
|
"en-US": "Added a launcher UI scale setting under Appearance, which also helps when embedded pages are cut off.",
|
||||||
|
"zh-CN": "在“界面与外观”中新增启动器缩放设置,同时可缓解内嵌网页被裁切的问题。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"en-US": "Added a one-time welcome announcement on first launch, with an entry in the home sidebar.",
|
||||||
|
"zh-CN": "新增首次启动时的欢迎公告弹窗,并在主页侧栏提供入口。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fixed": [
|
||||||
|
{
|
||||||
|
"en-US": "Fixed the browse page going blank without a CurseForge API key; the navigation tabs now stay visible.",
|
||||||
|
"zh-CN": "修复未配置 CurseForge API Key 时浏览页整页空白的问题,导航栏现在保持可见。"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"en-US": "Fixed the about page license links and the update changelog link to point at the correct repository.",
|
||||||
|
"zh-CN": "修复关于页许可证链接与更新日志链接,改为指向正确的仓库。"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "launcher-1.0.1-beta2",
|
||||||
|
"version": "1.0.1-beta2",
|
||||||
|
"publishedAt": "2026-09-28",
|
||||||
|
"title": {
|
||||||
|
"en-US": "Starlight Launcher 1.0.1-beta2",
|
||||||
|
"zh-CN": "Starlight Launcher 1.0.1-beta2"
|
||||||
|
},
|
||||||
|
"changes": {
|
||||||
|
"added": [
|
||||||
|
{
|
||||||
|
"en-US": "GitHub releases now include one complete update package for publishing to the StarLight skin site.",
|
||||||
|
"zh-CN": "GitHub 发布现会生成一个可直接发布到 StarLight 皮肤站的完整更新包。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fixed": [
|
||||||
|
{
|
||||||
|
"en-US": "Improved the reliability of live logs and database switching.",
|
||||||
|
"zh-CN": "提高实时日志与数据库切换的可靠性。"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "launcher-1.0.1-beta1",
|
||||||
|
"version": "1.0.1-beta1",
|
||||||
|
"publishedAt": "2026-09-27",
|
||||||
|
"title": {
|
||||||
|
"en-US": "Starlight Launcher 1.0.1-beta1",
|
||||||
|
"zh-CN": "Starlight Launcher 1.0.1-beta1"
|
||||||
|
},
|
||||||
|
"changes": {
|
||||||
|
"added": [
|
||||||
|
{
|
||||||
|
"en-US": "Added a one-time welcome announcement on first launch, covering the development team, the StarLight-only note, the rulebook update, and server connection addresses.",
|
||||||
|
"zh-CN": "新增首次启动时的欢迎公告弹窗,包含开发团队、StarLight 专用说明、服规更新与服务器连接地址。"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "launcher-1.0.0",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"publishedAt": "2026-09-26",
|
||||||
|
"title": {
|
||||||
|
"en-US": "Starlight Launcher 1.0.0",
|
||||||
|
"zh-CN": "Starlight Launcher 1.0.0"
|
||||||
|
},
|
||||||
|
"changes": {
|
||||||
|
"added": [
|
||||||
|
{
|
||||||
|
"en-US": "Enabled the built-in automatic updater. The launcher can now check for and install new versions from the update channel.",
|
||||||
|
"zh-CN": "启用内置自动更新,启动器现在可以从更新通道检查并安装新版本。"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fixed": [
|
||||||
|
{
|
||||||
|
"en-US": "Fixed a crash on startup caused by the updater running before launcher state finished initializing.",
|
||||||
|
"zh-CN": "修复了更新器在启动器状态初始化完成前运行导致的启动崩溃。"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "launcher-1.0.0-beta15",
|
"id": "launcher-1.0.0-beta15",
|
||||||
"version": "1.0.0-beta15",
|
"version": "1.0.0-beta15",
|
||||||
|
|||||||
@@ -1,34 +1,33 @@
|
|||||||
{
|
{
|
||||||
"tag_name": "v1.9.5",
|
"tag_name": "v1.0.0",
|
||||||
"assets": [
|
"assets": [
|
||||||
"Axolotl.Launcher-1.9.5-1.aarch64.rpm",
|
"Axolotl_Launcher_1.0.0_x64_modern-setup.exe",
|
||||||
"Axolotl.Launcher-1.9.5-1.aarch64.rpm.sig",
|
"Axolotl_Launcher_1.0.0_x64_modern-setup.exe.sig",
|
||||||
"Axolotl.Launcher-1.9.5-1.x86_64.rpm",
|
"Axolotl_Launcher_1.0.0_x64_nsis-setup.exe",
|
||||||
"Axolotl.Launcher-1.9.5-1.x86_64.rpm.sig",
|
"Axolotl_Launcher_1.0.0_x64_nsis-setup.exe.sig",
|
||||||
"Axolotl.Launcher_1.9.5_aarch64.AppImage",
|
"Axolotl_Launcher_1.0.0_x64_portable.zip",
|
||||||
"Axolotl.Launcher_1.9.5_aarch64.AppImage.sig",
|
"Starlight.Launcher-1.0.0-1.aarch64.rpm",
|
||||||
"Axolotl.Launcher_1.9.5_aarch64.AppImage.tar.gz",
|
"Starlight.Launcher-1.0.0-1.aarch64.rpm.sig",
|
||||||
"Axolotl.Launcher_1.9.5_aarch64.AppImage.tar.gz.sig",
|
"Starlight.Launcher-1.0.0-1.x86_64.rpm",
|
||||||
"Axolotl.Launcher_1.9.5_amd64.AppImage",
|
"Starlight.Launcher-1.0.0-1.x86_64.rpm.sig",
|
||||||
"Axolotl.Launcher_1.9.5_amd64.AppImage.sig",
|
"Starlight.Launcher_1.0.0_aarch64.AppImage",
|
||||||
"Axolotl.Launcher_1.9.5_amd64.AppImage.tar.gz",
|
"Starlight.Launcher_1.0.0_aarch64.AppImage.sig",
|
||||||
"Axolotl.Launcher_1.9.5_amd64.AppImage.tar.gz.sig",
|
"Starlight.Launcher_1.0.0_aarch64.AppImage.tar.gz",
|
||||||
"Axolotl.Launcher_1.9.5_amd64.deb",
|
"Starlight.Launcher_1.0.0_aarch64.AppImage.tar.gz.sig",
|
||||||
"Axolotl.Launcher_1.9.5_amd64.deb.sig",
|
"Starlight.Launcher_1.0.0_amd64.AppImage",
|
||||||
"Axolotl.Launcher_1.9.5_arm64.deb",
|
"Starlight.Launcher_1.0.0_amd64.AppImage.sig",
|
||||||
"Axolotl.Launcher_1.9.5_arm64.deb.sig",
|
"Starlight.Launcher_1.0.0_amd64.AppImage.tar.gz",
|
||||||
"Axolotl.Launcher_1.9.5_universal.dmg",
|
"Starlight.Launcher_1.0.0_amd64.AppImage.tar.gz.sig",
|
||||||
"Axolotl.Launcher_1.9.5_x64-setup.exe",
|
"Starlight.Launcher_1.0.0_amd64.deb",
|
||||||
"Axolotl.Launcher_1.9.5_x64-setup.exe.sig",
|
"Starlight.Launcher_1.0.0_amd64.deb.sig",
|
||||||
"Axolotl.Launcher_1.9.5_x64-setup.nsis.zip",
|
"Starlight.Launcher_1.0.0_arm64.deb",
|
||||||
"Axolotl.Launcher_1.9.5_x64-setup.nsis.zip.sig",
|
"Starlight.Launcher_1.0.0_arm64.deb.sig",
|
||||||
"Axolotl.Launcher_universal.app.tar.gz",
|
"Starlight.Launcher_1.0.0_universal.dmg",
|
||||||
"Axolotl.Launcher_universal.app.tar.gz.sig",
|
"Starlight.Launcher_1.0.0_x64-setup.exe",
|
||||||
"Axolotl_Launcher_1.9.5_x64_modern-setup.exe",
|
"Starlight.Launcher_1.0.0_x64-setup.exe.sig",
|
||||||
"Axolotl_Launcher_1.9.5_x64_modern-setup.exe.sig",
|
"Starlight.Launcher_1.0.0_x64-setup.nsis.zip",
|
||||||
"Axolotl_Launcher_1.9.5_x64_nsis-setup.exe",
|
"Starlight.Launcher_1.0.0_x64-setup.nsis.zip.sig",
|
||||||
"Axolotl_Launcher_1.9.5_x64_nsis-setup.exe.sig",
|
"Starlight.Launcher_universal.app.tar.gz",
|
||||||
"Axolotl_Launcher_1.9.5_x64_portable.zip",
|
"Starlight.Launcher_universal.app.tar.gz.sig"
|
||||||
"latest.json"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "theseus"
|
name = "theseus"
|
||||||
# The actual version is set by the theseus-build workflow on tagging
|
# The actual version is set by the theseus-build workflow on tagging
|
||||||
version = "1.0.0-beta12"
|
version = "1.0.0-beta15"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -441,13 +441,14 @@ impl ZipEntrySet {
|
|||||||
let mut seen: std::collections::HashSet<&str> =
|
let mut seen: std::collections::HashSet<&str> =
|
||||||
std::collections::HashSet::new();
|
std::collections::HashSet::new();
|
||||||
for dir in &self.dirs {
|
for dir in &self.dirs {
|
||||||
if let Some(rest) = dir.strip_prefix(base)
|
if let Some(rest) = dir.strip_prefix(base) {
|
||||||
&& let Some((first, _)) = rest.split_once('/')
|
let first = rest.split('/').next().unwrap_or_default();
|
||||||
&& !first.is_empty()
|
if !first.is_empty()
|
||||||
&& !is_noise_entry(first)
|
&& !is_noise_entry(first)
|
||||||
&& seen.insert(first)
|
&& seen.insert(first)
|
||||||
{
|
{
|
||||||
children.push(first.to_string());
|
children.push(first.to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for path in &self.files {
|
for path in &self.files {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use crate::state::{
|
|||||||
};
|
};
|
||||||
use crate::util::{fetch::write_cached_icon, io};
|
use crate::util::{fetch::write_cached_icon, io};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|||||||
@@ -54,6 +54,18 @@ pub struct LatestLogCursor {
|
|||||||
pub new_file: bool,
|
pub new_file: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Debug)]
|
||||||
|
pub struct LiveLogLine {
|
||||||
|
pub sequence: u64,
|
||||||
|
pub message: CensoredString,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Debug)]
|
||||||
|
pub struct LiveLogSnapshot {
|
||||||
|
pub lines: Vec<LiveLogLine>,
|
||||||
|
pub last_sequence: u64,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug)] // Not deserialize
|
#[derive(Serialize, Debug)] // Not deserialize
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct CensoredString(String);
|
pub struct CensoredString(String);
|
||||||
@@ -651,31 +663,31 @@ pub async fn delete_logs_by_filename(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub async fn get_live_log_buffer(
|
pub async fn get_live_log_snapshot(
|
||||||
instance_id: &str,
|
instance_id: &str,
|
||||||
) -> crate::Result<CensoredString> {
|
) -> crate::Result<LiveLogSnapshot> {
|
||||||
let state = State::get().await?;
|
let state = State::get().await?;
|
||||||
let lines = crate::state::get_log_buffer(instance_id);
|
|
||||||
let joined = lines.join("\n");
|
|
||||||
let compacted =
|
|
||||||
cap_log_for_display(compact_duplicate_lines(&joined), false);
|
|
||||||
|
|
||||||
let credentials = Credentials::get_all(&state.pool)
|
let credentials = Credentials::get_all(&state.pool)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| x.1)
|
.map(|x| x.1)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
maybe_emit_log_compaction_warning("live log", compacted.stats).await;
|
let snapshot = crate::state::get_live_log_snapshot(instance_id);
|
||||||
maybe_emit_log_display_truncation_warning(
|
Ok(LiveLogSnapshot {
|
||||||
"live log",
|
lines: snapshot
|
||||||
compacted.display_truncated,
|
.lines
|
||||||
)
|
.into_iter()
|
||||||
.await;
|
.map(|line| LiveLogLine {
|
||||||
Ok(CensoredString::censor(compacted.output, &credentials))
|
sequence: line.sequence,
|
||||||
|
message: CensoredString::censor(line.message, &credentials),
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
last_sequence: snapshot.last_sequence,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_live_log_buffer(instance_id: &str) {
|
pub fn clear_live_log_buffer(instance_id: &str) {
|
||||||
crate::state::remove_log_buffer(instance_id);
|
crate::state::clear_log_buffer(instance_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ mod transport;
|
|||||||
use crate::{
|
use crate::{
|
||||||
State,
|
State,
|
||||||
state::{
|
state::{
|
||||||
AppliedContentSetPatch, EditInstance, InstanceInstallStage,
|
AppliedContentSetPatch, Credentials, EditInstance,
|
||||||
InstanceLaunchOverridesPatch, InstanceMode, ModLoader,
|
InstanceInstallStage, InstanceLaunchOverridesPatch, InstanceMode,
|
||||||
|
MinecraftAccountType, ModLoader,
|
||||||
},
|
},
|
||||||
util::fetch::{
|
util::fetch::{
|
||||||
DownloadRequest, Integrity, ResourceClass, configured_client,
|
DownloadRequest, Integrity, ResourceClass, configured_client,
|
||||||
@@ -31,6 +32,9 @@ use tokio::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
const API: &str = "https://skin.starlight.cool/starlight/mod/packs";
|
const API: &str = "https://skin.starlight.cool/starlight/mod/packs";
|
||||||
|
const STARLIGHT_YGGDRASIL_API_ROOT: &str =
|
||||||
|
"https://skin.starlight.cool/yggdrasil";
|
||||||
|
const ACCOUNT_REQUIRED_MESSAGE: &str = "您需要登录正版或皮肤站账号后才能操作";
|
||||||
const BINDING: &str = ".starlight-pack.json";
|
const BINDING: &str = ".starlight-pack.json";
|
||||||
const JOURNAL: &str = ".starlight-pack-pending.json";
|
const JOURNAL: &str = ".starlight-pack-pending.json";
|
||||||
const MAX_HOSTED_CONCURRENT_FILES: usize = 8;
|
const MAX_HOSTED_CONCURRENT_FILES: usize = 8;
|
||||||
@@ -426,10 +430,46 @@ pub async fn default_publication() -> crate::Result<Publication> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_supported_game_account(
|
||||||
|
account_type: MinecraftAccountType,
|
||||||
|
yggdrasil_api_root: Option<&str>,
|
||||||
|
) -> bool {
|
||||||
|
account_type == MinecraftAccountType::Microsoft
|
||||||
|
|| (account_type == MinecraftAccountType::Yggdrasil
|
||||||
|
&& yggdrasil_api_root.map(|value| value.trim_end_matches('/'))
|
||||||
|
== Some(STARLIGHT_YGGDRASIL_API_ROOT))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn has_game_account_in(state: &State) -> crate::Result<bool> {
|
||||||
|
let accounts = Credentials::get_all_without_refresh(&state.pool).await?;
|
||||||
|
Ok(accounts.values().any(|account| {
|
||||||
|
is_supported_game_account(
|
||||||
|
account.account_type,
|
||||||
|
account
|
||||||
|
.yggdrasil
|
||||||
|
.as_ref()
|
||||||
|
.map(|value| value.api_root.as_str()),
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn has_game_account() -> crate::Result<bool> {
|
||||||
|
let state = State::get().await?;
|
||||||
|
has_game_account_in(&state).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn require_game_account(state: &State) -> crate::Result<()> {
|
||||||
|
if !has_game_account_in(state).await? {
|
||||||
|
return Err(invalid(ACCOUNT_REQUIRED_MESSAGE));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn create(game_dir_root: Option<String>) -> crate::Result<String> {
|
pub async fn create(game_dir_root: Option<String>) -> crate::Result<String> {
|
||||||
|
let state = State::get().await?;
|
||||||
|
require_game_account(&state).await?;
|
||||||
let publication = default_publication().await?;
|
let publication = default_publication().await?;
|
||||||
let runtime = &publication.manifest.runtime;
|
let runtime = &publication.manifest.runtime;
|
||||||
let state = State::get().await?;
|
|
||||||
// The pack's game files live in their own folder under the chosen root,
|
// The pack's game files live in their own folder under the chosen root,
|
||||||
// e.g. `<root>/<pack name>`. Avoid a `versions/<name>` layout: that shape
|
// e.g. `<root>/<pack name>`. Avoid a `versions/<name>` layout: that shape
|
||||||
// is reserved for externally linked launcher instances and would make the
|
// is reserved for externally linked launcher instances and would make the
|
||||||
@@ -728,6 +768,8 @@ async fn recover(instance_id: &str) -> crate::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn synchronize(instance_id: &str) -> crate::Result<SyncResult> {
|
pub async fn synchronize(instance_id: &str) -> crate::Result<SyncResult> {
|
||||||
|
let state = State::get().await?;
|
||||||
|
require_game_account(&state).await?;
|
||||||
let _guard = instance_gate(instance_id).lock_owned().await;
|
let _guard = instance_gate(instance_id).lock_owned().await;
|
||||||
if instance_mode(instance_id).await? != InstanceMode::StarLight {
|
if instance_mode(instance_id).await? != InstanceMode::StarLight {
|
||||||
return Err(invalid(
|
return Err(invalid(
|
||||||
@@ -1492,6 +1534,27 @@ async fn synchronize_with_progress(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hosted_operations_accept_only_microsoft_or_starlight_accounts() {
|
||||||
|
assert!(is_supported_game_account(
|
||||||
|
MinecraftAccountType::Microsoft,
|
||||||
|
None
|
||||||
|
));
|
||||||
|
assert!(is_supported_game_account(
|
||||||
|
MinecraftAccountType::Yggdrasil,
|
||||||
|
Some("https://skin.starlight.cool/yggdrasil/")
|
||||||
|
));
|
||||||
|
assert!(!is_supported_game_account(
|
||||||
|
MinecraftAccountType::Yggdrasil,
|
||||||
|
Some("https://auth.example.com/yggdrasil")
|
||||||
|
));
|
||||||
|
assert!(!is_supported_game_account(
|
||||||
|
MinecraftAccountType::Offline,
|
||||||
|
None
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn running_pack_checks_tag_changes_without_writing_live_files() {
|
async fn running_pack_checks_tag_changes_without_writing_live_files() {
|
||||||
let root = tempfile::tempdir().unwrap();
|
let root = tempfile::tempdir().unwrap();
|
||||||
|
|||||||
@@ -409,6 +409,8 @@ mod log_types {
|
|||||||
#[derive(Serialize, Clone)]
|
#[derive(Serialize, Clone)]
|
||||||
pub struct LogPayload {
|
pub struct LogPayload {
|
||||||
pub instance_id: String,
|
pub instance_id: String,
|
||||||
|
pub first_sequence: u64,
|
||||||
|
pub last_sequence: u64,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub event: LogEvent,
|
pub event: LogEvent,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1590,6 +1590,15 @@ mod tests {
|
|||||||
#[cfg(not(feature = "tauri"))]
|
#[cfg(not(feature = "tauri"))]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn import_api_trusts_persisted_job_context_and_keeps_other_missing_files_waiting()
|
async fn import_api_trusts_persisted_job_context_and_keeps_other_missing_files_waiting()
|
||||||
|
{
|
||||||
|
Box::pin(
|
||||||
|
run_import_api_trusts_persisted_job_context_and_keeps_other_missing_files_waiting(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "tauri"))]
|
||||||
|
async fn run_import_api_trusts_persisted_job_context_and_keeps_other_missing_files_waiting()
|
||||||
{
|
{
|
||||||
crate::event::EventState::init().await.unwrap();
|
crate::event::EventState::init().await.unwrap();
|
||||||
let root = tempfile::tempdir().unwrap().keep();
|
let root = tempfile::tempdir().unwrap().keep();
|
||||||
@@ -1788,18 +1797,17 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(observed.pending, 1);
|
assert_eq!(observed.pending, 1);
|
||||||
let (scan_result, manual_result) = tokio::join!(
|
let scan = Box::pin(scan_missing_modpack_files_in_at(
|
||||||
scan_missing_modpack_files_in_at(
|
job_id,
|
||||||
job_id,
|
&race_downloads,
|
||||||
&race_downloads,
|
first_seen + DOWNLOAD_STABILITY_WINDOW,
|
||||||
first_seen + DOWNLOAD_STABILITY_WINDOW,
|
));
|
||||||
),
|
let manual = Box::pin(import_missing_modpack_file(
|
||||||
import_missing_modpack_file(
|
job_id,
|
||||||
job_id,
|
first.item_id.clone(),
|
||||||
first.item_id.clone(),
|
selected,
|
||||||
selected,
|
));
|
||||||
)
|
let (scan_result, manual_result) = tokio::join!(scan, manual);
|
||||||
);
|
|
||||||
let scan_result = scan_result.unwrap();
|
let scan_result = scan_result.unwrap();
|
||||||
assert!(manual_result.is_ok());
|
assert!(manual_result.is_ok());
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ use crate::state::{
|
|||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use modrinth_content_management::{ContentType, ResolutionPreferences};
|
use modrinth_content_management::{ContentType, ResolutionPreferences};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{collections::HashMap, path::PathBuf};
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
path::PathBuf,
|
||||||
|
};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub type InstallModpackPreview = CreatePackInstance;
|
pub type InstallModpackPreview = CreatePackInstance;
|
||||||
@@ -483,7 +486,7 @@ mod tests {
|
|||||||
assert_eq!(summary.bytes_total, Some(300));
|
assert_eq!(summary.bytes_total, Some(300));
|
||||||
let items = job.download_items();
|
let items = job.download_items();
|
||||||
assert_eq!(items.len(), 3);
|
assert_eq!(items.len(), 3);
|
||||||
assert_eq!(items[0].status, DownloadItemStatus::Verifying);
|
assert_eq!(items[0].status, DownloadItemStatus::Completed);
|
||||||
assert_eq!(items[0].attempt, Some(1));
|
assert_eq!(items[0].attempt, Some(1));
|
||||||
assert_eq!(items[0].max_attempts, Some(4));
|
assert_eq!(items[0].max_attempts, Some(4));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -2395,6 +2398,7 @@ impl InstallJobState {
|
|||||||
fn download_items_from_events(&self) -> Vec<DownloadItemSnapshot> {
|
fn download_items_from_events(&self) -> Vec<DownloadItemSnapshot> {
|
||||||
let mut items = Vec::<DownloadItemSnapshot>::new();
|
let mut items = Vec::<DownloadItemSnapshot>::new();
|
||||||
let mut indices = HashMap::<String, usize>::new();
|
let mut indices = HashMap::<String, usize>::new();
|
||||||
|
let mut content_items = HashSet::<String>::new();
|
||||||
for event in &self.events {
|
for event in &self.events {
|
||||||
match &event.kind {
|
match &event.kind {
|
||||||
InstallJobEventKind::ContentFileQueued {
|
InstallJobEventKind::ContentFileQueued {
|
||||||
@@ -2402,6 +2406,7 @@ impl InstallJobState {
|
|||||||
bytes_total,
|
bytes_total,
|
||||||
max_attempts,
|
max_attempts,
|
||||||
} => {
|
} => {
|
||||||
|
content_items.insert(path.clone());
|
||||||
if let Some(item) = indices
|
if let Some(item) = indices
|
||||||
.get(path)
|
.get(path)
|
||||||
.and_then(|&index| items.get_mut(index))
|
.and_then(|&index| items.get_mut(index))
|
||||||
@@ -2482,6 +2487,7 @@ impl InstallJobState {
|
|||||||
attempt,
|
attempt,
|
||||||
max_attempts,
|
max_attempts,
|
||||||
} => {
|
} => {
|
||||||
|
content_items.insert(path.clone());
|
||||||
if let Some(item) = indices
|
if let Some(item) = indices
|
||||||
.get(path)
|
.get(path)
|
||||||
.and_then(|&index| items.get_mut(index))
|
.and_then(|&index| items.get_mut(index))
|
||||||
@@ -2562,10 +2568,14 @@ impl InstallJobState {
|
|||||||
.get(path)
|
.get(path)
|
||||||
.and_then(|&index| items.get_mut(index))
|
.and_then(|&index| items.get_mut(index))
|
||||||
{
|
{
|
||||||
// Network transfer completion is not content
|
// Content downloads still need verification and DB
|
||||||
// finalization. `ContentFileCompleted` is the event
|
// registration. Standalone Java/Minecraft requests
|
||||||
// that confirms verification and DB registration.
|
// are final once the request itself finishes.
|
||||||
item.status = DownloadItemStatus::Verifying;
|
item.status = if content_items.contains(path) {
|
||||||
|
DownloadItemStatus::Verifying
|
||||||
|
} else {
|
||||||
|
DownloadItemStatus::Completed
|
||||||
|
};
|
||||||
item.bytes_downloaded = *bytes;
|
item.bytes_downloaded = *bytes;
|
||||||
item.bytes_total = item.bytes_total.or(Some(*bytes));
|
item.bytes_total = item.bytes_total.or(Some(*bytes));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1361,12 +1361,11 @@ mod tests {
|
|||||||
assert_eq!(persisted.status, InstallJobStatus::Canceled);
|
assert_eq!(persisted.status, InstallJobStatus::Canceled);
|
||||||
assert!(persisted.state.rollback.as_ref().unwrap().content.is_none());
|
assert!(persisted.state.rollback.as_ref().unwrap().content.is_none());
|
||||||
assert!(persisted.state.rollback_error.is_none());
|
assert!(persisted.state.rollback_error.is_none());
|
||||||
assert_eq!(
|
assert!(
|
||||||
crate::state::list_instances(&state.pool)
|
crate::state::get_instance(&instance_id, &state.pool)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.len(),
|
.is_some()
|
||||||
1
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let new_instance = crate::api::instance::create(
|
let new_instance = crate::api::instance::create(
|
||||||
|
|||||||
@@ -1107,12 +1107,17 @@ mod tests {
|
|||||||
"org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209:{classifier}"
|
"org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209:{classifier}"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert!(
|
let (declared_path, declared_sha1) = match classifier.as_str() {
|
||||||
plan.destination
|
"natives-linux" => (
|
||||||
.to_string_lossy()
|
"org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar",
|
||||||
.ends_with(format!("{classifier}.jar").as_str())
|
"aaa",
|
||||||
);
|
),
|
||||||
assert_eq!(plan.sha1.as_deref(), Some("aaa"));
|
"natives-osx" => ("x-osx.jar", "bbb"),
|
||||||
|
"natives-windows" => ("x-win.jar", "ccc"),
|
||||||
|
other => panic!("unexpected native classifier {other}"),
|
||||||
|
};
|
||||||
|
assert!(plan.destination.to_string_lossy().ends_with(declared_path));
|
||||||
|
assert_eq!(plan.sha1.as_deref(), Some(declared_sha1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -1940,13 +1940,16 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
direct.version_json,
|
direct.version_json,
|
||||||
Some(
|
Some(
|
||||||
version_dir
|
crate::util::io::canonicalize(
|
||||||
.join("1.20.1-fabric.json")
|
version_dir.join("1.20.1-fabric.json"),
|
||||||
.canonicalize()
|
)
|
||||||
.unwrap()
|
.unwrap(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert_eq!(direct.dot_minecraft, root.path().canonicalize().unwrap());
|
assert_eq!(
|
||||||
|
direct.dot_minecraft,
|
||||||
|
crate::util::io::canonicalize(root.path()).unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2002,6 +2005,15 @@ mod tests {
|
|||||||
let root = tempfile::tempdir().unwrap();
|
let root = tempfile::tempdir().unwrap();
|
||||||
let version = root.path().join("versions/demo");
|
let version = root.path().join("versions/demo");
|
||||||
std::fs::create_dir_all(&version).unwrap();
|
std::fs::create_dir_all(&version).unwrap();
|
||||||
|
std::fs::write(
|
||||||
|
version.join("demo.json"),
|
||||||
|
serde_json::to_vec(&json!({
|
||||||
|
"id": "demo",
|
||||||
|
"mainClass": "net.minecraft.client.main.Main"
|
||||||
|
}))
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_content_game_dir(root.path(), &version).unwrap(),
|
resolve_content_game_dir(root.path(), &version).unwrap(),
|
||||||
@@ -2469,7 +2481,13 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
candidates,
|
candidates,
|
||||||
vec![launcher.path().join("runtime/jdk17/bin/java")]
|
vec![
|
||||||
|
launcher
|
||||||
|
.path()
|
||||||
|
.join("runtime/jdk17")
|
||||||
|
.join("bin")
|
||||||
|
.join(PCL_JAVA_BIN)
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// A relative path escaping the launcher directory degrades to the
|
// A relative path escaping the launcher directory degrades to the
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use sqlx::migrate::{Migration, Migrator};
|
|||||||
use sqlx::sqlite::{
|
use sqlx::sqlite::{
|
||||||
SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions,
|
SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions,
|
||||||
};
|
};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{ConnectOptions, Connection, Pool, Sqlite};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@@ -126,17 +126,7 @@ pub async fn copy_release_database_to_beta(
|
|||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let release_pool = open_app_db_pool(&release_path).await?;
|
copy_app_database(&release_path, &beta_path).await?;
|
||||||
let escaped_path = beta_path.to_string_lossy().replace('\'', "''");
|
|
||||||
sqlx::query(&format!("VACUUM INTO '{escaped_path}'"))
|
|
||||||
.execute(&release_pool)
|
|
||||||
.await?;
|
|
||||||
release_pool.close().await;
|
|
||||||
|
|
||||||
if let Err(error) = open_app_db_pool(&beta_path).await {
|
|
||||||
let _ = tokio::fs::remove_file(&beta_path).await;
|
|
||||||
return Err(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
source = %release_path.display(),
|
source = %release_path.display(),
|
||||||
@@ -207,16 +197,7 @@ pub async fn copy_database_between_channels(
|
|||||||
}
|
}
|
||||||
|
|
||||||
crate::util::io::create_dir_all(&target_dir).await?;
|
crate::util::io::create_dir_all(&target_dir).await?;
|
||||||
let temporary_path = target_dir.join(format!("{LEGACY_APP_DB_FILE}.tmp"));
|
copy_app_database(&source_path, &target_path).await?;
|
||||||
let source_pool = open_app_db_pool(&source_path).await?;
|
|
||||||
let escaped_path = temporary_path.to_string_lossy().replace('\'', "''");
|
|
||||||
let result = sqlx::query(&format!("VACUUM INTO '{escaped_path}'"))
|
|
||||||
.execute(&source_pool)
|
|
||||||
.await;
|
|
||||||
source_pool.close().await;
|
|
||||||
result?;
|
|
||||||
|
|
||||||
tokio::fs::rename(&temporary_path, &target_path).await?;
|
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
source = %source_path.display(),
|
source = %source_path.display(),
|
||||||
destination = %target_path.display(),
|
destination = %target_path.display(),
|
||||||
@@ -225,6 +206,87 @@ pub async fn copy_database_between_channels(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn copy_app_database(source: &Path, target: &Path) -> crate::Result<()> {
|
||||||
|
let temporary = sidecar_path(target, ".copying");
|
||||||
|
remove_database_files(&temporary).await?;
|
||||||
|
|
||||||
|
let source_pool = open_app_db_pool(source).await?;
|
||||||
|
let escaped_path = temporary.to_string_lossy().replace('\'', "''");
|
||||||
|
let snapshot_result = sqlx::query(&format!("VACUUM INTO '{escaped_path}'"))
|
||||||
|
.execute(&source_pool)
|
||||||
|
.await;
|
||||||
|
source_pool.close().await;
|
||||||
|
if let Err(error) = snapshot_result {
|
||||||
|
let _ = remove_database_files(&temporary).await;
|
||||||
|
return Err(error.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(error) = verify_database_file(&temporary).await {
|
||||||
|
let _ = remove_database_files(&temporary).await;
|
||||||
|
return Err(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
let previous = sidecar_path(target, ".replacing");
|
||||||
|
remove_database_files(&previous).await?;
|
||||||
|
let had_target = target.try_exists()?;
|
||||||
|
if had_target {
|
||||||
|
super::db_backup::archive_database_files(target, &previous).await?;
|
||||||
|
} else {
|
||||||
|
super::db_backup::remove_database_sidecars(target).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(error) = tokio::fs::rename(&temporary, target).await {
|
||||||
|
if had_target {
|
||||||
|
super::db_backup::restore_archived_database_files(
|
||||||
|
&previous, target,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
let _ = remove_database_files(&temporary).await;
|
||||||
|
return Err(error.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(error) = remove_database_files(&previous).await {
|
||||||
|
tracing::warn!(
|
||||||
|
database = %previous.display(),
|
||||||
|
error = %error,
|
||||||
|
"Copied channel database but could not remove the previous snapshot"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn verify_database_file(path: &Path) -> crate::Result<()> {
|
||||||
|
let options = SqliteConnectOptions::new()
|
||||||
|
.filename(path)
|
||||||
|
.busy_timeout(Duration::from_secs(30))
|
||||||
|
.read_only(true)
|
||||||
|
.create_if_missing(false);
|
||||||
|
let mut connection = options.connect().await?;
|
||||||
|
let rows = sqlx::query_scalar::<_, String>("PRAGMA quick_check(1)")
|
||||||
|
.fetch_all(&mut connection)
|
||||||
|
.await?;
|
||||||
|
connection.close().await?;
|
||||||
|
if rows.as_slice() != ["ok"] {
|
||||||
|
return Err(crate::ErrorKind::FSError(format!(
|
||||||
|
"Database snapshot {} failed its integrity check: {}",
|
||||||
|
path.display(),
|
||||||
|
rows.join("; ")
|
||||||
|
))
|
||||||
|
.into());
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn remove_database_files(database: &Path) -> crate::Result<()> {
|
||||||
|
match tokio::fs::remove_file(database).await {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
|
||||||
|
Err(error) => return Err(error.into()),
|
||||||
|
}
|
||||||
|
super::db_backup::remove_database_sidecars(database).await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn backup_current_app_db_for_update(
|
pub async fn backup_current_app_db_for_update(
|
||||||
app_identifier: &str,
|
app_identifier: &str,
|
||||||
target_version: &str,
|
target_version: &str,
|
||||||
@@ -1461,6 +1523,53 @@ mod tests {
|
|||||||
const INSTANCE_POST_UPGRADE_NOTICES_MIGRATION_VERSION: i64 = 20260824000000;
|
const INSTANCE_POST_UPGRADE_NOTICES_MIGRATION_VERSION: i64 = 20260824000000;
|
||||||
const MCARCHIVE_PROVIDER_FILE_ID_MIGRATION_VERSION: i64 = 20260823020000;
|
const MCARCHIVE_PROVIDER_FILE_ID_MIGRATION_VERSION: i64 = 20260823020000;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn channel_copy_replaces_database_and_removes_stale_sidecars() {
|
||||||
|
let temp = tempfile::tempdir().unwrap();
|
||||||
|
let source = temp.path().join("beta").join(LEGACY_APP_DB_FILE);
|
||||||
|
let target = temp.path().join("release").join(LEGACY_APP_DB_FILE);
|
||||||
|
tokio::fs::create_dir_all(source.parent().unwrap())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
tokio::fs::create_dir_all(target.parent().unwrap())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
for (path, marker) in [(&source, "beta"), (&target, "release")] {
|
||||||
|
let pool = open_app_db_pool(path).await.unwrap();
|
||||||
|
sqlx::query("CREATE TABLE marker (value TEXT NOT NULL)")
|
||||||
|
.execute(&pool)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
sqlx::query("INSERT INTO marker (value) VALUES (?)")
|
||||||
|
.bind(marker)
|
||||||
|
.execute(&pool)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
pool.close().await;
|
||||||
|
}
|
||||||
|
tokio::fs::write(sidecar_path(&target, "-wal"), b"stale wal")
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
tokio::fs::write(sidecar_path(&target, "-shm"), b"stale shm")
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
copy_app_database(&source, &target).await.unwrap();
|
||||||
|
|
||||||
|
assert!(!sidecar_path(&target, "-wal").exists());
|
||||||
|
assert!(!sidecar_path(&target, "-shm").exists());
|
||||||
|
let pool = open_app_db_pool(&target).await.unwrap();
|
||||||
|
let marker: String = sqlx::query_scalar("SELECT value FROM marker")
|
||||||
|
.fetch_one(&pool)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
pool.close().await;
|
||||||
|
assert_eq!(marker, "beta");
|
||||||
|
assert!(!sidecar_path(&target, ".copying").exists());
|
||||||
|
assert!(!sidecar_path(&target, ".replacing").exists());
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn post_upgrade_notices_migrate_fresh_and_existing_databases() {
|
async fn post_upgrade_notices_migrate_fresh_and_existing_databases() {
|
||||||
for previous_schema in [false, true] {
|
for previous_schema in [false, true] {
|
||||||
@@ -3956,7 +4065,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
translation,
|
translation,
|
||||||
(
|
(
|
||||||
"microsoft".to_string(),
|
"google".to_string(),
|
||||||
String::new(),
|
String::new(),
|
||||||
String::new(),
|
String::new(),
|
||||||
String::new(),
|
String::new(),
|
||||||
@@ -4065,7 +4174,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
translation,
|
translation,
|
||||||
(
|
(
|
||||||
"microsoft".to_string(),
|
"google".to_string(),
|
||||||
String::new(),
|
String::new(),
|
||||||
String::new(),
|
String::new(),
|
||||||
"https://api.openai.com/v1".to_string(),
|
"https://api.openai.com/v1".to_string(),
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ async fn restore_corrupt_app_db_from(
|
|||||||
"App database integrity check failed"
|
"App database integrity check failed"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if restore_app_db_without_corrupt_sidecars(db_path, backup_dir).await? {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let Some(backup_path) = latest_healthy_app_db_backup(backup_dir).await?
|
let Some(backup_path) = latest_healthy_app_db_backup(backup_dir).await?
|
||||||
else {
|
else {
|
||||||
return Err(crate::ErrorKind::FSError(format!(
|
return Err(crate::ErrorKind::FSError(format!(
|
||||||
@@ -98,6 +102,49 @@ async fn restore_corrupt_app_db_from(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn restore_app_db_without_corrupt_sidecars(
|
||||||
|
db_path: &Path,
|
||||||
|
backup_dir: &Path,
|
||||||
|
) -> crate::Result<bool> {
|
||||||
|
let mut has_sidecars = false;
|
||||||
|
for suffix in ["-wal", "-shm"] {
|
||||||
|
has_sidecars |= sqlite_sidecar_path(db_path, suffix).try_exists()?;
|
||||||
|
}
|
||||||
|
if !has_sidecars {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
let staging_path = next_restore_staging_path(db_path).await?;
|
||||||
|
tokio::fs::copy(db_path, &staging_path).await?;
|
||||||
|
let healthy_main = matches!(
|
||||||
|
check_database_integrity(&staging_path).await?,
|
||||||
|
IntegrityStatus::Healthy
|
||||||
|
) && is_app_database(&staging_path).await?;
|
||||||
|
if !healthy_main {
|
||||||
|
cleanup_staged_database(&staging_path).await;
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
crate::util::io::create_dir_all(backup_dir).await?;
|
||||||
|
let corrupt_path = next_corrupt_database_path(backup_dir).await?;
|
||||||
|
if let Err(error) = archive_database_files(db_path, &corrupt_path).await {
|
||||||
|
cleanup_staged_database(&staging_path).await;
|
||||||
|
return Err(error);
|
||||||
|
}
|
||||||
|
if let Err(error) = tokio::fs::rename(&staging_path, db_path).await {
|
||||||
|
restore_archived_database_files(&corrupt_path, db_path).await?;
|
||||||
|
cleanup_staged_database(&staging_path).await;
|
||||||
|
return Err(error.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
tracing::warn!(
|
||||||
|
database = %db_path.display(),
|
||||||
|
corrupt_archive = %corrupt_path.display(),
|
||||||
|
"Recovered app database by removing corrupt SQLite sidecars"
|
||||||
|
);
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
async fn check_database_integrity(
|
async fn check_database_integrity(
|
||||||
db_path: &Path,
|
db_path: &Path,
|
||||||
) -> crate::Result<IntegrityStatus> {
|
) -> crate::Result<IntegrityStatus> {
|
||||||
@@ -200,7 +247,7 @@ async fn is_app_database(db_path: &Path) -> crate::Result<bool> {
|
|||||||
Ok(table_count == REQUIRED_APP_DB_TABLES.len() as i64)
|
Ok(table_count == REQUIRED_APP_DB_TABLES.len() as i64)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn archive_database_files(
|
pub(crate) async fn archive_database_files(
|
||||||
db_path: &Path,
|
db_path: &Path,
|
||||||
archive_path: &Path,
|
archive_path: &Path,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
@@ -226,7 +273,7 @@ async fn archive_database_files(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn restore_archived_database_files(
|
pub(crate) async fn restore_archived_database_files(
|
||||||
archive_path: &Path,
|
archive_path: &Path,
|
||||||
db_path: &Path,
|
db_path: &Path,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
@@ -285,7 +332,9 @@ fn sqlite_sidecar_path(db_path: &Path, suffix: &str) -> PathBuf {
|
|||||||
PathBuf::from(path)
|
PathBuf::from(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn remove_database_sidecars(db_path: &Path) -> crate::Result<()> {
|
pub(crate) async fn remove_database_sidecars(
|
||||||
|
db_path: &Path,
|
||||||
|
) -> crate::Result<()> {
|
||||||
for suffix in ["-wal", "-shm"] {
|
for suffix in ["-wal", "-shm"] {
|
||||||
let path = sqlite_sidecar_path(db_path, suffix);
|
let path = sqlite_sidecar_path(db_path, suffix);
|
||||||
match tokio::fs::remove_file(path).await {
|
match tokio::fs::remove_file(path).await {
|
||||||
@@ -766,6 +815,45 @@ mod tests {
|
|||||||
assert_eq!(tokio::fs::read(&db_path).await.unwrap(), corrupt_bytes);
|
assert_eq!(tokio::fs::read(&db_path).await.unwrap(), corrupt_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn corrupt_sidecars_recover_from_the_healthy_main_database() {
|
||||||
|
let temp = tempfile::tempdir().unwrap();
|
||||||
|
let db_path = temp.path().join("release").join("app.db");
|
||||||
|
let backup_dir =
|
||||||
|
temp.path().join("Backups").join("app-db").join("release");
|
||||||
|
tokio::fs::create_dir_all(db_path.parent().unwrap())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
create_test_app_db(&db_path, "release").await;
|
||||||
|
tokio::fs::write(sqlite_sidecar_path(&db_path, "-wal"), b"bad wal")
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
tokio::fs::write(sqlite_sidecar_path(&db_path, "-shm"), b"bad shm")
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
restore_app_db_without_corrupt_sidecars(&db_path, &backup_dir)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(read_marker(&db_path).await, "release");
|
||||||
|
assert!(!sqlite_sidecar_path(&db_path, "-wal").exists());
|
||||||
|
assert!(!sqlite_sidecar_path(&db_path, "-shm").exists());
|
||||||
|
let mut entries = tokio::fs::read_dir(&backup_dir).await.unwrap();
|
||||||
|
let mut archived_database = false;
|
||||||
|
let mut archived_wal = false;
|
||||||
|
let mut archived_shm = false;
|
||||||
|
while let Some(entry) = entries.next_entry().await.unwrap() {
|
||||||
|
let name = entry.file_name().to_string_lossy().into_owned();
|
||||||
|
archived_database |= name.ends_with(".db");
|
||||||
|
archived_wal |= name.ends_with(".db-wal");
|
||||||
|
archived_shm |= name.ends_with(".db-shm");
|
||||||
|
}
|
||||||
|
assert!(archived_database && archived_wal && archived_shm);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn update_backup_creates_a_healthy_channel_snapshot() {
|
async fn update_backup_creates_a_healthy_channel_snapshot() {
|
||||||
let temp = tempfile::tempdir().unwrap();
|
let temp = tempfile::tempdir().unwrap();
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ use chrono::{DateTime, TimeZone, Utc};
|
|||||||
use sqlx::{Executor, Row, Sqlite, SqlitePool, Transaction};
|
use sqlx::{Executor, Row, Sqlite, SqlitePool, Transaction};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
async fn begin_content_write(
|
||||||
|
pool: &SqlitePool,
|
||||||
|
) -> crate::Result<Transaction<'static, Sqlite>> {
|
||||||
|
Ok(pool.begin_with("BEGIN IMMEDIATE").await?)
|
||||||
|
}
|
||||||
|
|
||||||
/// Ensures the instance a content write is about to reference still exists.
|
/// Ensures the instance a content write is about to reference still exists.
|
||||||
///
|
///
|
||||||
/// Runs inside the write transaction so a concurrent instance deletion that
|
/// Runs inside the write transaction so a concurrent instance deletion that
|
||||||
@@ -662,7 +668,7 @@ pub(crate) async fn upsert_instance_file_from_parts(
|
|||||||
input: UpsertInstanceFile<'_>,
|
input: UpsertInstanceFile<'_>,
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
) -> crate::Result<InstanceFile> {
|
) -> crate::Result<InstanceFile> {
|
||||||
let mut tx = pool.begin().await?;
|
let mut tx = begin_content_write(pool).await?;
|
||||||
let file =
|
let file =
|
||||||
upsert_instance_file_from_parts_in_transaction(input, &mut tx).await?;
|
upsert_instance_file_from_parts_in_transaction(input, &mut tx).await?;
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
@@ -726,7 +732,7 @@ pub(crate) async fn rename_instance_file(
|
|||||||
enabled: bool,
|
enabled: bool,
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
) -> crate::Result<Option<InstanceFile>> {
|
) -> crate::Result<Option<InstanceFile>> {
|
||||||
let mut tx = pool.begin().await?;
|
let mut tx = begin_content_write(pool).await?;
|
||||||
|
|
||||||
let file = rename_instance_file_in_transaction(
|
let file = rename_instance_file_in_transaction(
|
||||||
instance_id,
|
instance_id,
|
||||||
@@ -1106,7 +1112,7 @@ pub(crate) async fn upsert_content_entry_from_parts(
|
|||||||
input: UpsertContentEntry<'_>,
|
input: UpsertContentEntry<'_>,
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
) -> crate::Result<ContentEntry> {
|
) -> crate::Result<ContentEntry> {
|
||||||
let mut tx = pool.begin().await?;
|
let mut tx = begin_content_write(pool).await?;
|
||||||
let entry =
|
let entry =
|
||||||
upsert_content_entry_from_parts_in_transaction(input, &mut tx).await?;
|
upsert_content_entry_from_parts_in_transaction(input, &mut tx).await?;
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
@@ -1230,7 +1236,7 @@ pub(crate) async fn upsert_content_provider_ref(
|
|||||||
origin: bool,
|
origin: bool,
|
||||||
pool: &SqlitePool,
|
pool: &SqlitePool,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
let mut tx = pool.begin().await?;
|
let mut tx = begin_content_write(pool).await?;
|
||||||
upsert_content_provider_ref_in_transaction(
|
upsert_content_provider_ref_in_transaction(
|
||||||
content_entry_id,
|
content_entry_id,
|
||||||
provider_ref,
|
provider_ref,
|
||||||
@@ -2583,6 +2589,7 @@ mod tests {
|
|||||||
provider TEXT NOT NULL,
|
provider TEXT NOT NULL,
|
||||||
provider_project_id TEXT NOT NULL,
|
provider_project_id TEXT NOT NULL,
|
||||||
provider_release_id TEXT NULL,
|
provider_release_id TEXT NULL,
|
||||||
|
provider_file_id TEXT NULL,
|
||||||
is_origin INTEGER NOT NULL DEFAULT 0
|
is_origin INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
CREATE UNIQUE INDEX instance_content_provider_refs_identity
|
CREATE UNIQUE INDEX instance_content_provider_refs_identity
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ pub(crate) async fn persist_resolved_plan_dependency_edges(
|
|||||||
.chain(plan.dependencies.iter())
|
.chain(plan.dependencies.iter())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let mut tx = state.pool.begin().await?;
|
let mut tx = begin_content_write(&state.pool).await?;
|
||||||
for (index, dependency) in plan.dependencies.iter().enumerate() {
|
for (index, dependency) in plan.dependencies.iter().enumerate() {
|
||||||
let Some(parent) = dependency
|
let Some(parent) = dependency
|
||||||
.dependent_on_version_id
|
.dependent_on_version_id
|
||||||
|
|||||||
@@ -254,8 +254,8 @@ mod tests {
|
|||||||
instance_rows::get_instance_by_id(&instance.id, &state.pool)
|
instance_rows::get_instance_by_id(&instance.id, &state.pool)
|
||||||
.await?
|
.await?
|
||||||
.expect("instance row");
|
.expect("instance row");
|
||||||
let canonical_root = minecraft.path().canonicalize()?;
|
let canonical_root = crate::util::io::canonicalize(minecraft.path())?;
|
||||||
let canonical_json = json_path.canonicalize()?;
|
let canonical_json = crate::util::io::canonicalize(&json_path)?;
|
||||||
assert_eq!(stored.linked_launcher.as_deref(), Some("generic"));
|
assert_eq!(stored.linked_launcher.as_deref(), Some("generic"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
stored.linked_launcher_root.as_deref(),
|
stored.linked_launcher_root.as_deref(),
|
||||||
|
|||||||
@@ -87,11 +87,6 @@ pub(crate) async fn sync_instance_content_files(
|
|||||||
.as_deref()
|
.as_deref()
|
||||||
.map(str::trim)
|
.map(str::trim)
|
||||||
.is_some_and(|linked| !linked.is_empty());
|
.is_some_and(|linked| !linked.is_empty());
|
||||||
let instance_files_root = if is_direct_linked {
|
|
||||||
content_root.clone()
|
|
||||||
} else {
|
|
||||||
state.directories.instances_dir().join(&instance.path)
|
|
||||||
};
|
|
||||||
let cache_key_path = if is_direct_linked {
|
let cache_key_path = if is_direct_linked {
|
||||||
content_root.to_string_lossy().into_owned()
|
content_root.to_string_lossy().into_owned()
|
||||||
} else {
|
} else {
|
||||||
@@ -168,8 +163,9 @@ pub(crate) async fn sync_instance_content_files(
|
|||||||
let hash_key = file.hash_cache_key.trim_end_matches(".disabled");
|
let hash_key = file.hash_cache_key.trim_end_matches(".disabled");
|
||||||
let existing_file = existing_files_by_path.get(&file.relative_path);
|
let existing_file = existing_files_by_path.get(&file.relative_path);
|
||||||
let (scanned_sha1, scanned_size) = if existing_file.is_some() {
|
let (scanned_sha1, scanned_size) = if existing_file.is_some() {
|
||||||
let path =
|
// Read from the resolved game directory. Managed StarLight
|
||||||
join_content_path(&instance_files_root, &file.relative_path);
|
// instances may keep their files outside the launcher data root.
|
||||||
|
let path = join_content_path(&content_root, &file.relative_path);
|
||||||
let (_, sha1) = fetch::sha1_file_async(&path).await?;
|
let (_, sha1) = fetch::sha1_file_async(&path).await?;
|
||||||
(sha1, file.size)
|
(sha1, file.size)
|
||||||
} else {
|
} else {
|
||||||
@@ -748,7 +744,9 @@ mod tests {
|
|||||||
base_path: minecraft.path().to_path_buf(),
|
base_path: minecraft.path().to_path_buf(),
|
||||||
instance_folder: "versions/1.12.2-linked".to_string(),
|
instance_folder: "versions/1.12.2-linked".to_string(),
|
||||||
instance_path: None,
|
instance_path: None,
|
||||||
game_dir_mode: None,
|
game_dir_mode: Some(
|
||||||
|
crate::launcher::ExternalGameDirMode::Shared,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
&state,
|
&state,
|
||||||
)
|
)
|
||||||
@@ -875,6 +873,59 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn refresh_reconciles_externally_replaced_profile_mods() {
|
||||||
|
let state = global_state().await;
|
||||||
|
let metadata = crate::api::instance::create(
|
||||||
|
format!("sync-external {}", uuid::Uuid::new_v4()),
|
||||||
|
"1.20.1".to_string(),
|
||||||
|
crate::state::ModLoader::Vanilla,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
crate::state::InstanceLink::Unmanaged,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let instance = &metadata.instance;
|
||||||
|
let mods = state.directories.instance_game_dir(instance).join("mods");
|
||||||
|
fs::create_dir_all(&mods).unwrap();
|
||||||
|
fs::write(mods.join("old-version.jar"), "old").unwrap();
|
||||||
|
fs::write(mods.join("same-name.jar"), "old").unwrap();
|
||||||
|
let initial =
|
||||||
|
sync_instance_content_files(instance, &state).await.unwrap();
|
||||||
|
assert_eq!(initial.len(), 2);
|
||||||
|
|
||||||
|
fs::remove_file(mods.join("old-version.jar")).unwrap();
|
||||||
|
fs::write(mods.join("new-version.jar"), "new version").unwrap();
|
||||||
|
fs::write(mods.join("same-name.jar"), "new").unwrap();
|
||||||
|
let refreshed =
|
||||||
|
sync_instance_content_files(instance, &state).await.unwrap();
|
||||||
|
assert_eq!(refreshed.len(), 2);
|
||||||
|
assert!(
|
||||||
|
refreshed
|
||||||
|
.iter()
|
||||||
|
.any(|file| file.relative_path == "mods/new-version.jar")
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!refreshed
|
||||||
|
.iter()
|
||||||
|
.any(|file| file.relative_path == "mods/old-version.jar")
|
||||||
|
);
|
||||||
|
let before = initial
|
||||||
|
.iter()
|
||||||
|
.find(|file| file.relative_path == "mods/same-name.jar")
|
||||||
|
.unwrap();
|
||||||
|
let after = refreshed
|
||||||
|
.iter()
|
||||||
|
.find(|file| file.relative_path == "mods/same-name.jar")
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(before.id, after.id);
|
||||||
|
assert_ne!(before.sha1, after.sha1);
|
||||||
|
assert_eq!(before.size, after.size);
|
||||||
|
}
|
||||||
|
|
||||||
/// Regression probe: an instance whose `game_dir_override` points to an
|
/// Regression probe: an instance whose `game_dir_override` points to an
|
||||||
/// external `.minecraft` root must have its content scanned from that root,
|
/// external `.minecraft` root must have its content scanned from that root,
|
||||||
/// not from the (empty) managed instance folder. This is the split-brain
|
/// not from the (empty) managed instance folder. This is the split-brain
|
||||||
@@ -947,6 +998,48 @@ mod tests {
|
|||||||
"expected the override-root mod to be scanned"
|
"expected the override-root mod to be scanned"
|
||||||
);
|
);
|
||||||
assert!(files[0].relative_path.ends_with("mods/my-mod.jar"));
|
assert!(files[0].relative_path.ends_with("mods/my-mod.jar"));
|
||||||
|
|
||||||
|
let refreshed =
|
||||||
|
sync_instance_content_files(&instance, &state).await.expect(
|
||||||
|
"repeat refresh must hash files in the actual game directory",
|
||||||
|
);
|
||||||
|
assert_eq!(refreshed[0].sha1, files[0].sha1);
|
||||||
|
|
||||||
|
fs::write(mods_dir.join("my-mod.jar"), "new").unwrap();
|
||||||
|
fs::write(mods_dir.join("added.jar"), "added mod").unwrap();
|
||||||
|
let replaced = sync_instance_content_files(&instance, &state)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(replaced.len(), 2);
|
||||||
|
let updated = replaced
|
||||||
|
.iter()
|
||||||
|
.find(|file| file.relative_path == "mods/my-mod.jar")
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(updated.id, files[0].id);
|
||||||
|
assert_ne!(updated.sha1, files[0].sha1);
|
||||||
|
assert_eq!(updated.size, files[0].size);
|
||||||
|
|
||||||
|
fs::remove_file(mods_dir.join("my-mod.jar")).unwrap();
|
||||||
|
fs::rename(
|
||||||
|
mods_dir.join("added.jar"),
|
||||||
|
mods_dir.join("added.jar.disabled"),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let removed = sync_instance_content_files(&instance, &state)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(removed.len(), 1);
|
||||||
|
assert_eq!(removed[0].relative_path, "mods/added.jar.disabled");
|
||||||
|
assert!(!removed[0].enabled);
|
||||||
|
let stored =
|
||||||
|
sqlite::content_rows::get_instance_files(&instance.id, &state.pool)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert!(
|
||||||
|
stored
|
||||||
|
.iter()
|
||||||
|
.any(|file| file.id == files[0].id && file.missing)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -117,8 +117,21 @@ async fn record_post_upgrade_launch_best_effort(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct LogRingBuffer {
|
struct LogRingBuffer {
|
||||||
lines: VecDeque<String>,
|
lines: VecDeque<SequencedLogLine>,
|
||||||
byte_len: usize,
|
byte_len: usize,
|
||||||
|
last_sequence: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub struct SequencedLogLine {
|
||||||
|
pub sequence: u64,
|
||||||
|
pub message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
pub struct LiveLogSnapshot {
|
||||||
|
pub lines: Vec<SequencedLogLine>,
|
||||||
|
pub last_sequence: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LogRingBuffer {
|
impl LogRingBuffer {
|
||||||
@@ -126,25 +139,37 @@ impl LogRingBuffer {
|
|||||||
Self {
|
Self {
|
||||||
lines: VecDeque::new(),
|
lines: VecDeque::new(),
|
||||||
byte_len: 0,
|
byte_len: 0,
|
||||||
|
last_sequence: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push(&mut self, line: String) {
|
fn push(&mut self, message: String) -> u64 {
|
||||||
let line_len = line.len();
|
self.last_sequence = self.last_sequence.saturating_add(1);
|
||||||
|
let sequence = self.last_sequence;
|
||||||
|
let line = SequencedLogLine { sequence, message };
|
||||||
|
let line_len = line.message.len();
|
||||||
while self.lines.len() >= LOG_BUFFER_CAPACITY
|
while self.lines.len() >= LOG_BUFFER_CAPACITY
|
||||||
|| self.byte_len.saturating_add(line_len) > LOG_BUFFER_BYTE_CAPACITY
|
|| self.byte_len.saturating_add(line_len) > LOG_BUFFER_BYTE_CAPACITY
|
||||||
{
|
{
|
||||||
let Some(removed) = self.lines.pop_front() else {
|
let Some(removed) = self.lines.pop_front() else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
self.byte_len = self.byte_len.saturating_sub(removed.len());
|
self.byte_len = self.byte_len.saturating_sub(removed.message.len());
|
||||||
}
|
}
|
||||||
self.byte_len += line_len;
|
self.byte_len += line_len;
|
||||||
self.lines.push_back(line);
|
self.lines.push_back(line);
|
||||||
|
sequence
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_all(&self) -> Vec<String> {
|
fn get_all(&self) -> Vec<String> {
|
||||||
self.lines.iter().cloned().collect()
|
self.lines.iter().map(|line| line.message.clone()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn snapshot(&self) -> LiveLogSnapshot {
|
||||||
|
LiveLogSnapshot {
|
||||||
|
lines: self.lines.iter().cloned().collect(),
|
||||||
|
last_sequence: self.last_sequence,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear(&mut self) {
|
fn clear(&mut self) {
|
||||||
@@ -157,11 +182,24 @@ static LOG_BUFFERS: LazyLock<DashMap<String, LogRingBuffer>> =
|
|||||||
LazyLock::new(DashMap::new);
|
LazyLock::new(DashMap::new);
|
||||||
|
|
||||||
pub fn push_log_line(instance_id: &str, line: String) {
|
pub fn push_log_line(instance_id: &str, line: String) {
|
||||||
let line = truncate_live_log_text(&line);
|
push_log_lines(instance_id, std::iter::once(line));
|
||||||
LOG_BUFFERS
|
}
|
||||||
|
|
||||||
|
fn push_log_lines(
|
||||||
|
instance_id: &str,
|
||||||
|
lines: impl IntoIterator<Item = String>,
|
||||||
|
) -> Option<(u64, u64)> {
|
||||||
|
let mut buffer = LOG_BUFFERS
|
||||||
.entry(instance_id.to_string())
|
.entry(instance_id.to_string())
|
||||||
.or_insert_with(LogRingBuffer::new)
|
.or_insert_with(LogRingBuffer::new);
|
||||||
.push(line);
|
let mut first_sequence = None;
|
||||||
|
let mut last_sequence = 0;
|
||||||
|
for line in lines {
|
||||||
|
let sequence = buffer.push(truncate_live_log_text(&line));
|
||||||
|
first_sequence.get_or_insert(sequence);
|
||||||
|
last_sequence = sequence;
|
||||||
|
}
|
||||||
|
first_sequence.map(|first| (first, last_sequence))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn truncate_live_log_text(value: &str) -> String {
|
fn truncate_live_log_text(value: &str) -> String {
|
||||||
@@ -228,6 +266,16 @@ pub fn get_log_buffer(instance_id: &str) -> Vec<String> {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_live_log_snapshot(instance_id: &str) -> LiveLogSnapshot {
|
||||||
|
LOG_BUFFERS
|
||||||
|
.get(instance_id)
|
||||||
|
.map(|buffer| buffer.snapshot())
|
||||||
|
.unwrap_or(LiveLogSnapshot {
|
||||||
|
lines: Vec::new(),
|
||||||
|
last_sequence: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn clear_log_buffer(instance_id: &str) {
|
pub fn clear_log_buffer(instance_id: &str) {
|
||||||
if let Some(mut buf) = LOG_BUFFERS.get_mut(instance_id) {
|
if let Some(mut buf) = LOG_BUFFERS.get_mut(instance_id) {
|
||||||
buf.clear();
|
buf.clear();
|
||||||
@@ -920,14 +968,20 @@ impl Process {
|
|||||||
event.throwable =
|
event.throwable =
|
||||||
event.throwable.as_deref().map(truncate_live_log_text);
|
event.throwable.as_deref().map(truncate_live_log_text);
|
||||||
|
|
||||||
|
let mut lines = Vec::new();
|
||||||
if let Some(formatted) = Self::format_log4j_entry(&event) {
|
if let Some(formatted) = Self::format_log4j_entry(&event) {
|
||||||
push_log_line(instance_id, formatted.trim_end().to_string());
|
lines.push(formatted.trim_end().to_string());
|
||||||
}
|
}
|
||||||
if let Some(ref throwable) = event.throwable {
|
if let Some(ref throwable) = event.throwable {
|
||||||
for line in throwable.lines().filter(|l| !l.is_empty()) {
|
for line in throwable.lines().filter(|l| !l.is_empty()) {
|
||||||
push_log_line(instance_id, line.to_string());
|
lines.push(line.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let Some((first_sequence, last_sequence)) =
|
||||||
|
push_log_lines(instance_id, lines)
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "tauri")]
|
#[cfg(feature = "tauri")]
|
||||||
{
|
{
|
||||||
@@ -936,6 +990,8 @@ impl Process {
|
|||||||
"log",
|
"log",
|
||||||
LogPayload {
|
LogPayload {
|
||||||
instance_id: instance_id.to_string(),
|
instance_id: instance_id.to_string(),
|
||||||
|
first_sequence,
|
||||||
|
last_sequence,
|
||||||
event: LogEvent::Log4j(event),
|
event: LogEvent::Log4j(event),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -943,13 +999,17 @@ impl Process {
|
|||||||
}
|
}
|
||||||
#[cfg(not(feature = "tauri"))]
|
#[cfg(not(feature = "tauri"))]
|
||||||
{
|
{
|
||||||
let _ = (instance_id, event);
|
let _ = (instance_id, event, first_sequence, last_sequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_legacy_log(instance_id: &str, message: &str) {
|
fn emit_legacy_log(instance_id: &str, message: &str) {
|
||||||
let message = truncate_live_log_text(message);
|
let message = truncate_live_log_text(message);
|
||||||
push_log_line(instance_id, message.clone());
|
let Some((first_sequence, last_sequence)) =
|
||||||
|
push_log_lines(instance_id, std::iter::once(message.clone()))
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "tauri")]
|
#[cfg(feature = "tauri")]
|
||||||
{
|
{
|
||||||
@@ -958,6 +1018,8 @@ impl Process {
|
|||||||
"log",
|
"log",
|
||||||
LogPayload {
|
LogPayload {
|
||||||
instance_id: instance_id.to_string(),
|
instance_id: instance_id.to_string(),
|
||||||
|
first_sequence,
|
||||||
|
last_sequence,
|
||||||
event: LogEvent::Legacy { message },
|
event: LogEvent::Legacy { message },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -965,7 +1027,7 @@ impl Process {
|
|||||||
}
|
}
|
||||||
#[cfg(not(feature = "tauri"))]
|
#[cfg(not(feature = "tauri"))]
|
||||||
{
|
{
|
||||||
let _ = (instance_id, message);
|
let _ = (instance_id, message, first_sequence, last_sequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1312,6 +1374,49 @@ fn take_next_log4j_frame(buffer: &mut String) -> Option<String> {
|
|||||||
mod post_upgrade_tests {
|
mod post_upgrade_tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn live_log_snapshot_sequences_batches_and_preserves_position_after_clear()
|
||||||
|
{
|
||||||
|
let instance_id = Uuid::new_v4().to_string();
|
||||||
|
assert_eq!(
|
||||||
|
push_log_lines(
|
||||||
|
&instance_id,
|
||||||
|
["first".to_string(), "second".to_string()]
|
||||||
|
),
|
||||||
|
Some((1, 2))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
get_live_log_snapshot(&instance_id),
|
||||||
|
LiveLogSnapshot {
|
||||||
|
lines: vec![
|
||||||
|
SequencedLogLine {
|
||||||
|
sequence: 1,
|
||||||
|
message: "first".to_string(),
|
||||||
|
},
|
||||||
|
SequencedLogLine {
|
||||||
|
sequence: 2,
|
||||||
|
message: "second".to_string(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
last_sequence: 2,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
clear_log_buffer(&instance_id);
|
||||||
|
push_log_line(&instance_id, "third".to_string());
|
||||||
|
assert_eq!(
|
||||||
|
get_live_log_snapshot(&instance_id),
|
||||||
|
LiveLogSnapshot {
|
||||||
|
lines: vec![SequencedLogLine {
|
||||||
|
sequence: 3,
|
||||||
|
message: "third".to_string(),
|
||||||
|
}],
|
||||||
|
last_sequence: 3,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
remove_log_buffer(&instance_id);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn waiting_for_one_process_leaves_registry_available() {
|
async fn waiting_for_one_process_leaves_registry_available() {
|
||||||
|
|||||||
@@ -958,6 +958,34 @@ fn official_fallback_route(routes: &[DownloadRoute]) -> Option<DownloadRoute> {
|
|||||||
.cloned()
|
.cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn integrity_fallback_route(
|
||||||
|
routes: &[DownloadRoute],
|
||||||
|
current_index: usize,
|
||||||
|
terminal_routes: &HashSet<String>,
|
||||||
|
) -> Option<DownloadRoute> {
|
||||||
|
let current = routes.get(current_index)?;
|
||||||
|
if !is_official_route(current)
|
||||||
|
&& let Some(official) = routes.iter().enumerate().find_map(
|
||||||
|
|(candidate_index, candidate)| {
|
||||||
|
(candidate_index != current_index
|
||||||
|
&& is_official_route(candidate)
|
||||||
|
&& !terminal_routes.contains(&candidate.url))
|
||||||
|
.then(|| candidate.clone())
|
||||||
|
},
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return Some(official);
|
||||||
|
}
|
||||||
|
|
||||||
|
((current_index + 1)..routes.len())
|
||||||
|
.chain(0..current_index)
|
||||||
|
.find_map(|candidate_index| {
|
||||||
|
let candidate = &routes[candidate_index];
|
||||||
|
(!terminal_routes.contains(&candidate.url))
|
||||||
|
.then(|| candidate.clone())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn url_with_base(original: &Url, base: &str, path: &str) -> Option<String> {
|
fn url_with_base(original: &Url, base: &str, path: &str) -> Option<String> {
|
||||||
let mut target = Url::parse(base).ok()?;
|
let mut target = Url::parse(base).ok()?;
|
||||||
target.set_path(path);
|
target.set_path(path);
|
||||||
@@ -5855,7 +5883,7 @@ async fn download_to_path_inner(
|
|||||||
can_switch_route,
|
can_switch_route,
|
||||||
retry_with_single_thread,
|
retry_with_single_thread,
|
||||||
);
|
);
|
||||||
while attempts < file_attempt_budget {
|
if attempts < file_attempt_budget {
|
||||||
attempts += 1;
|
attempts += 1;
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
path = %destination.display(),
|
path = %destination.display(),
|
||||||
@@ -6048,13 +6076,15 @@ async fn download_to_path_inner(
|
|||||||
);
|
);
|
||||||
last_error = Some(error);
|
last_error = Some(error);
|
||||||
terminal_routes.insert(route.url.clone());
|
terminal_routes.insert(route.url.clone());
|
||||||
if !is_official_route(route)
|
if let Some(fallback) = integrity_fallback_route(
|
||||||
&& let Some(official) =
|
&routes,
|
||||||
official_fallback_route(&routes)
|
route_index,
|
||||||
{
|
&terminal_routes,
|
||||||
|
) {
|
||||||
remove_if_exists(&part_path).await?;
|
remove_if_exists(&part_path).await?;
|
||||||
official_integrity_retry = true;
|
official_integrity_retry =
|
||||||
preferred_route = Some(official);
|
is_official_route(&fallback);
|
||||||
|
preferred_route = Some(fallback);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if official_integrity_retry {
|
if official_integrity_retry {
|
||||||
@@ -6210,6 +6240,9 @@ async fn download_to_path_inner(
|
|||||||
"File download request failed; trying the next source or retry"
|
"File download request failed; trying the next source or retry"
|
||||||
);
|
);
|
||||||
last_error = Some(error);
|
last_error = Some(error);
|
||||||
|
if can_switch_route {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
@@ -6244,6 +6277,9 @@ async fn download_to_path_inner(
|
|||||||
"File download stalled before receiving a response"
|
"File download stalled before receiving a response"
|
||||||
);
|
);
|
||||||
last_error = Some(error);
|
last_error = Some(error);
|
||||||
|
if can_switch_route {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -6346,6 +6382,11 @@ async fn download_to_path_inner(
|
|||||||
Some(http_version),
|
Some(http_version),
|
||||||
);
|
);
|
||||||
last_error = Some(error);
|
last_error = Some(error);
|
||||||
|
if (terminal_status || cooldown_and_switch)
|
||||||
|
&& can_switch_route
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6773,19 +6814,24 @@ async fn download_to_path_inner(
|
|||||||
} else {
|
} else {
|
||||||
remove_if_exists(&part_path).await?;
|
remove_if_exists(&part_path).await?;
|
||||||
}
|
}
|
||||||
let official = (!is_official_route(route))
|
let fallback = integrity_fallback_route(
|
||||||
.then(|| official_fallback_route(&routes))
|
&routes,
|
||||||
.flatten();
|
route_index,
|
||||||
let decision = if official.is_some() {
|
&terminal_routes,
|
||||||
"fallback_official"
|
);
|
||||||
} else if attempts >= 2
|
let decision =
|
||||||
|| (is_official_route(route)
|
if fallback.as_ref().is_some_and(is_official_route) {
|
||||||
&& official_integrity_retry)
|
"fallback_official"
|
||||||
{
|
} else if fallback.is_some() {
|
||||||
"drop_route_after_clean_retry"
|
"switch_route"
|
||||||
} else {
|
} else if attempts >= 2
|
||||||
"clear_partial_and_retry"
|
|| (is_official_route(route)
|
||||||
};
|
&& official_integrity_retry)
|
||||||
|
{
|
||||||
|
"drop_route_after_clean_retry"
|
||||||
|
} else {
|
||||||
|
"clear_partial_and_retry"
|
||||||
|
};
|
||||||
record_download_attempt_failure(
|
record_download_attempt_failure(
|
||||||
&mut attempt_history,
|
&mut attempt_history,
|
||||||
route,
|
route,
|
||||||
@@ -6803,10 +6849,10 @@ async fn download_to_path_inner(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
last_error = Some(error);
|
last_error = Some(error);
|
||||||
if let Some(official) = official {
|
if let Some(fallback) = fallback {
|
||||||
terminal_routes.insert(route.url.clone());
|
terminal_routes.insert(route.url.clone());
|
||||||
official_integrity_retry = true;
|
official_integrity_retry = is_official_route(&fallback);
|
||||||
preferred_route = Some(official);
|
preferred_route = Some(fallback);
|
||||||
} else if (is_official_route(route)
|
} else if (is_official_route(route)
|
||||||
&& official_integrity_retry)
|
&& official_integrity_retry)
|
||||||
|| attempts >= 2
|
|| attempts >= 2
|
||||||
@@ -8121,7 +8167,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn h2_fallback_is_limited_to_one_second() {
|
fn h2_fallback_uses_the_configured_ttl() {
|
||||||
let _guard = H2_FALLBACK_TEST_LOCK.lock();
|
let _guard = H2_FALLBACK_TEST_LOCK.lock();
|
||||||
let authority = "h2-cooldown.example:443";
|
let authority = "h2-cooldown.example:443";
|
||||||
record_authority_h2_failure(authority);
|
record_authority_h2_failure(authority);
|
||||||
@@ -8131,7 +8177,8 @@ mod tests {
|
|||||||
.get(authority)
|
.get(authority)
|
||||||
.map(|until| until.saturating_duration_since(Instant::now()))
|
.map(|until| until.saturating_duration_since(Instant::now()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(remaining <= MAX_FAILURE_COOLDOWN);
|
assert!(remaining <= H2_FALLBACK_TTL);
|
||||||
|
assert!(remaining > H2_FALLBACK_TTL - Duration::from_secs(1));
|
||||||
H2_FALLBACK_AUTHORITIES.lock().remove(authority);
|
H2_FALLBACK_AUTHORITIES.lock().remove(authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::minecraft::{
|
|||||||
};
|
};
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/// The latest version of the format the fabric model structs deserialize to
|
/// The latest version of the format the fabric model structs deserialize to
|
||||||
pub const CURRENT_FABRIC_FORMAT_VERSION: usize = 1;
|
pub const CURRENT_FABRIC_FORMAT_VERSION: usize = 1;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
|
const source = readFileSync(
|
||||||
|
new URL('./LogViewport.vue', import.meta.url),
|
||||||
|
'utf8',
|
||||||
|
)
|
||||||
|
|
||||||
|
test('log rows use content-driven grid height for wrapped lines', () => {
|
||||||
|
assert.match(source, /grid-template-columns:\s*52px minmax\(0, 1fr\)/)
|
||||||
|
assert.match(source, /\.log-line-content\s*\{[^}]*display:\s*block/s)
|
||||||
|
assert.match(
|
||||||
|
source,
|
||||||
|
/\.log-viewport-wrap \.log-line\s*\{[^}]*white-space:\s*pre-wrap/s,
|
||||||
|
)
|
||||||
|
assert.doesNotMatch(
|
||||||
|
source,
|
||||||
|
/content-visibility|contain-intrinsic-size|estimateHeight|heightPrefix/,
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -6,7 +6,10 @@
|
|||||||
:style="{ fontSize: fontSize + 'px' }"
|
:style="{ fontSize: fontSize + 'px' }"
|
||||||
@scroll="handleScroll"
|
@scroll="handleScroll"
|
||||||
>
|
>
|
||||||
<div v-if="lines.length === 0" class="flex items-center justify-center h-full">
|
<div
|
||||||
|
v-if="lines.length === 0"
|
||||||
|
class="flex items-center justify-center h-full"
|
||||||
|
>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
v-if="emptyStateType === 'instance'"
|
v-if="emptyStateType === 'instance'"
|
||||||
:heading="formatMessage(consoleMessages.emptyInstanceTitle)"
|
:heading="formatMessage(consoleMessages.emptyInstanceTitle)"
|
||||||
@@ -26,22 +29,19 @@
|
|||||||
v-for="item in lines"
|
v-for="item in lines"
|
||||||
:key="item.originalIndex"
|
:key="item.originalIndex"
|
||||||
:data-line="item.originalIndex + 1"
|
:data-line="item.originalIndex + 1"
|
||||||
class="log-line flex items-stretch whitespace-pre"
|
class="log-line"
|
||||||
:class="entryClass(item.line)"
|
:class="entryClass(item.line)"
|
||||||
>
|
>
|
||||||
<span
|
<span class="log-line-number">{{ item.originalIndex + 1 }}</span>
|
||||||
class="flex shrink-0 w-[52px] items-center justify-end leading-none text-right text-secondary bg-surface-3 border-r border-solid border-surface-3 select-none overflow-hidden"
|
<span class="log-line-content" v-html="renderLine(item)"></span>
|
||||||
>{{ item.originalIndex + 1 }}</span
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="log-line-content flex-1 px-2 break-all [overflow-wrap:anywhere]"
|
|
||||||
v-html="renderLine(item)"
|
|
||||||
></span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Transition name="scroll-to-bottom-fade">
|
<Transition name="scroll-to-bottom-fade">
|
||||||
<div v-if="lines.length > 0 && !stickToBottom" class="absolute bottom-4 right-4 z-10">
|
<div
|
||||||
|
v-if="lines.length > 0 && !stickToBottom"
|
||||||
|
class="absolute bottom-4 right-4 z-10"
|
||||||
|
>
|
||||||
<ButtonStyled circular type="highlight" size="large">
|
<ButtonStyled circular type="highlight" size="large">
|
||||||
<button aria-label="Scroll to bottom" @click="scrollToBottom">
|
<button aria-label="Scroll to bottom" @click="scrollToBottom">
|
||||||
<ChevronDownIcon />
|
<ChevronDownIcon />
|
||||||
@@ -197,8 +197,35 @@ defineExpose({
|
|||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-viewport-wrap .log-line-content {
|
.log-line {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 52px minmax(0, 1fr);
|
||||||
|
align-items: stretch;
|
||||||
|
min-height: 1.4em;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-line-number {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: flex-end;
|
||||||
|
overflow: hidden;
|
||||||
|
border-right: 1px solid var(--surface-3);
|
||||||
|
background: var(--surface-3);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
line-height: inherit;
|
||||||
|
text-align: right;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-line-content {
|
||||||
|
display: block;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
line-height: inherit;
|
||||||
|
white-space: inherit;
|
||||||
|
word-break: break-all;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-line.entry-error {
|
.log-line.entry-error {
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ function updaterTargets(filename) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSkinSiteUpdateBundle(filename) {
|
||||||
|
return filename.endsWith('_skin-site-update.zip')
|
||||||
|
}
|
||||||
|
|
||||||
function describe(filename) {
|
function describe(filename) {
|
||||||
const targets = updaterTargets(filename)
|
const targets = updaterTargets(filename)
|
||||||
if (targets) {
|
if (targets) {
|
||||||
@@ -69,7 +73,7 @@ function digest(asset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const assets = release.assets
|
const assets = release.assets
|
||||||
.filter((asset) => asset.name !== 'latest.json')
|
.filter((asset) => asset.name !== 'latest.json' && !isSkinSiteUpdateBundle(asset.name))
|
||||||
.map((asset) => ({
|
.map((asset) => ({
|
||||||
filename: asset.name,
|
filename: asset.name,
|
||||||
size: asset.size,
|
size: asset.size,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const files = [
|
|||||||
'Axolotl_Launcher_1.9.5-beta.1_x64_nsis-setup.exe',
|
'Axolotl_Launcher_1.9.5-beta.1_x64_nsis-setup.exe',
|
||||||
'Axolotl_Launcher_1.9.5-beta.1_x64_nsis-setup.exe.sig',
|
'Axolotl_Launcher_1.9.5-beta.1_x64_nsis-setup.exe.sig',
|
||||||
'Axolotl_Launcher_1.9.5-beta.1_x64_portable.zip',
|
'Axolotl_Launcher_1.9.5-beta.1_x64_portable.zip',
|
||||||
|
'Starlight_Launcher_1.9.5-beta.1_skin-site-update.zip',
|
||||||
]
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -59,7 +60,11 @@ try {
|
|||||||
assert.equal(result.status, 0, result.stderr)
|
assert.equal(result.status, 0, result.stderr)
|
||||||
const catalog = JSON.parse(fs.readFileSync(output, 'utf8'))
|
const catalog = JSON.parse(fs.readFileSync(output, 'utf8'))
|
||||||
assert.equal(catalog.version, '1.9.5-beta.1')
|
assert.equal(catalog.version, '1.9.5-beta.1')
|
||||||
assert.equal(catalog.files.length, files.length)
|
assert.equal(catalog.files.length, files.length - 1)
|
||||||
|
assert.equal(
|
||||||
|
catalog.files.some((artifact) => artifact.filename.endsWith('_skin-site-update.zip')),
|
||||||
|
false,
|
||||||
|
)
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
catalog.artifacts.find((artifact) => artifact.filename.endsWith('_amd64.AppImage.tar.gz'))
|
catalog.artifacts.find((artifact) => artifact.filename.endsWith('_amd64.AppImage.tar.gz'))
|
||||||
.targetPlatforms,
|
.targetPlatforms,
|
||||||
|
|||||||
Reference in new issue
Block a user