import type { Archon, UploadState } from '@modrinth/api-client' import type { Stats } from '@modrinth/utils' import type { ComputedRef, Reactive, Ref } from 'vue' import type { MessageDescriptor } from '#ui/composables/i18n' import type { FileOperation } from '#ui/layouts/shared/files-tab/types' import { createContext } from '.' export interface BusyReason { reason: MessageDescriptor } export type BackupTaskState = { progress: number state: Archon.Backups.v1.BackupState } export type BackupProgressEntry = { file?: BackupTaskState create?: BackupTaskState restore?: BackupTaskState } export type BackupsState = Map export interface FilesystemAuth { url: string token: string } export interface ModrinthServerContext { readonly serverId: string readonly worldId: Ref readonly server: Ref // Websocket state readonly isConnected: Ref readonly isWsAuthIncorrect: Ref readonly powerState: Ref readonly powerStateDetails: Ref<{ oom_killed?: boolean; exit_code?: number } | undefined> readonly isServerRunning: ComputedRef readonly stats: Ref readonly uptimeSeconds: Ref readonly backupsState: Reactive markBackupCancelled: (backupId: string) => void // Content sync state readonly isSyncingContent: Ref // Busy state — when non-empty, all write operations should be disabled readonly busyReasons: ComputedRef // Filesystem state readonly fsAuth: Ref readonly fsOps: Ref readonly fsQueuedOps: Ref refreshFsAuth: () => Promise // File upload state readonly uploadState: Ref readonly cancelUpload: Ref<(() => void) | null> // File operations (extract, move, etc.) readonly activeOperations: ComputedRef dismissOperation: (opId: string, action: 'dismiss' | 'cancel') => Promise } export const [injectModrinthServerContext, provideModrinthServerContext] = createContext('[id].vue', 'modrinthServerContext')