2025-12-04 02:32:03 +00:00
|
|
|
import type { Archon } from '@modrinth/api-client'
|
|
|
|
|
import type { ComputedRef, Reactive, Ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
import { createContext } from '.'
|
|
|
|
|
|
|
|
|
|
export type BackupTaskState = {
|
|
|
|
|
progress: number
|
|
|
|
|
state: Archon.Backups.v1.BackupState
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type BackupProgressEntry = {
|
|
|
|
|
file?: BackupTaskState
|
|
|
|
|
create?: BackupTaskState
|
|
|
|
|
restore?: BackupTaskState
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type BackupsState = Map<string, BackupProgressEntry>
|
|
|
|
|
|
2026-01-06 00:35:51 +00:00
|
|
|
export interface FilesystemAuth {
|
|
|
|
|
url: string
|
|
|
|
|
token: string
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-04 02:32:03 +00:00
|
|
|
export interface ModrinthServerContext {
|
|
|
|
|
readonly serverId: string
|
|
|
|
|
readonly server: Ref<Archon.Servers.v0.Server>
|
|
|
|
|
|
|
|
|
|
// Websocket state
|
|
|
|
|
readonly isConnected: Ref<boolean>
|
|
|
|
|
readonly powerState: Ref<Archon.Websocket.v0.PowerState>
|
|
|
|
|
readonly isServerRunning: ComputedRef<boolean>
|
|
|
|
|
readonly backupsState: Reactive<BackupsState>
|
|
|
|
|
markBackupCancelled: (backupId: string) => void
|
2026-01-06 00:35:51 +00:00
|
|
|
|
|
|
|
|
// Filesystem state
|
|
|
|
|
readonly fsAuth: Ref<FilesystemAuth | null>
|
|
|
|
|
readonly fsOps: Ref<Archon.Websocket.v0.FilesystemOperation[]>
|
|
|
|
|
readonly fsQueuedOps: Ref<Archon.Websocket.v0.QueuedFilesystemOp[]>
|
|
|
|
|
refreshFsAuth: () => Promise<void>
|
2025-12-04 02:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const [injectModrinthServerContext, provideModrinthServerContext] =
|
|
|
|
|
createContext<ModrinthServerContext>('[id].vue', 'modrinthServerContext')
|