mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 19:25:56 +00:00
feat(client): drop built-in client download, point players to the community launcher
The community moved the game client behind its official launcher (account sign-in, signed manifest, its own CDN), so the public manifest now answers 404 and the Manager must not pose as the launcher. Remove the client download and update path (clientdl, plan/sync/download/cancel commands, update job and progress UI, version tracking) and reduce "Set up the game client" to: open coa-development.org for the launcher, or pick a folder that already has the game. Linking a folder, realmlist switch, companion addon and the custom-race patch are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f0f9e6fe2
commit
7cdf854eb0
22 files changed
+116
-1985
No files matched your search
+1
-34
@@ -421,36 +421,8 @@ export interface ClientInfo {
|
||||
}
|
||||
|
||||
export interface ClientStatus {
|
||||
/** A usable client folder is linked. */
|
||||
linked: boolean;
|
||||
managed: boolean;
|
||||
installed_version: string | null;
|
||||
latest_version: string | null;
|
||||
latest_bytes: number | null;
|
||||
update_available: boolean;
|
||||
}
|
||||
|
||||
export interface ClientPlan {
|
||||
version: string;
|
||||
items: { path: string; size: number; kind: "missing" | "changed" | "modified" }[];
|
||||
download_bytes: number;
|
||||
total_files: number;
|
||||
up_to_date_files: number;
|
||||
kept_files: number;
|
||||
}
|
||||
|
||||
export interface ClientStep {
|
||||
phase: "scan" | "download" | "finish";
|
||||
done: number;
|
||||
total: number;
|
||||
bytes_per_sec: number;
|
||||
file: string | null;
|
||||
}
|
||||
|
||||
export interface ClientDownloadCheck {
|
||||
needed_bytes: number;
|
||||
free_bytes: number;
|
||||
version: string;
|
||||
dest: string;
|
||||
}
|
||||
|
||||
export type ClientPatchState = "not-installed" | "enabled" | "disabled" | "partially-installed";
|
||||
@@ -614,11 +586,6 @@ export const api = {
|
||||
setRealmlist: (id: string, host: string) => invoke<string[]>("client_realmlist", { id, host }),
|
||||
installAddon: (id: string) => invoke<void>("client_install_addon", { id }),
|
||||
clientStatus: (id: string) => invoke<ClientStatus>("client_status", { id }),
|
||||
clientDownloadCheck: (parent: string) => invoke<ClientDownloadCheck>("client_download_check", { parent }),
|
||||
clientPlan: (id: string) => invoke<ClientPlan>("client_plan", { id }),
|
||||
clientSync: (id: string, keepModified: boolean) => invoke<void>("client_sync", { id, keepModified }),
|
||||
clientDownload: (id: string, parent: string) => invoke<ClientInfo>("client_download", { id, parent }),
|
||||
clientCancel: () => invoke<void>("client_cancel"),
|
||||
customRacesStatus: (id: string) => invoke<CustomRacesClientStatus | null>("custom_races_status", { id }),
|
||||
customRacesUninstall: (id: string) => invoke<void>("custom_races_uninstall", { id }),
|
||||
customRacesInstall: (id: string) => invoke<void>("custom_races_install", { id }),
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
import { startAfterUpdate } from "./updatePrefs";
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { api, asUiError, type ClientPlan, type ClientStep, type UiError } from "@/lib/api";
|
||||
import { checkClient } from "@/lib/clientUpdate";
|
||||
|
||||
/**
|
||||
* Updating the game client from the main screen, without a window over everything: the "Update client" button turns into
|
||||
* a progress bar (as in a game launcher). Only a choice that needs the owner's word (files they changed) is shown, in
|
||||
* place, below the buttons. The first-time linking of a client keeps its dialog (ClientDialog).
|
||||
*/
|
||||
export type ClientJobPhase = "idle" | "scanning" | "choose" | "working" | "done" | "current" | "stopped" | "failed";
|
||||
|
||||
export interface ClientJob {
|
||||
phase: ClientJobPhase;
|
||||
step: ClientStep | null;
|
||||
plan: ClientPlan | null;
|
||||
error: UiError | null;
|
||||
}
|
||||
|
||||
const IDLE: ClientJob = { phase: "idle", step: null, plan: null, error: null };
|
||||
const jobs = new Map<string, ClientJob>();
|
||||
const listeners = new Set<() => void>();
|
||||
const cancelled = new Set<string>();
|
||||
|
||||
const get = (id: string) => jobs.get(id) ?? IDLE;
|
||||
function set(id: string, next: Partial<ClientJob>) {
|
||||
jobs.set(id, { ...get(id), ...next });
|
||||
listeners.forEach((l) => l());
|
||||
}
|
||||
|
||||
let unlisten: (() => void) | null = null;
|
||||
async function followProgress(id: string) {
|
||||
if (unlisten) return;
|
||||
try {
|
||||
unlisten = await listen<ClientStep>("client-progress", (e) => {
|
||||
const phase = get(id).phase;
|
||||
if (phase === "scanning" || phase === "working") set(id, { step: e.payload });
|
||||
});
|
||||
} catch {
|
||||
/* no event bridge (a plain browser): the bar just stays at zero */
|
||||
}
|
||||
}
|
||||
|
||||
function fail(id: string, e: unknown) {
|
||||
if (cancelled.has(id)) set(id, { phase: "stopped", step: null });
|
||||
else set(id, { phase: "failed", step: null, error: asUiError(e) });
|
||||
}
|
||||
|
||||
async function refresh(id: string) {
|
||||
await checkClient(id);
|
||||
}
|
||||
|
||||
/** Look at what differs from the published client; update at once when nothing needs a decision. */
|
||||
export async function startClientUpdate(id: string): Promise<void> {
|
||||
const now = get(id).phase;
|
||||
if (now === "scanning" || now === "working") return;
|
||||
cancelled.delete(id);
|
||||
set(id, { phase: "scanning", step: null, plan: null, error: null });
|
||||
void followProgress(id);
|
||||
try {
|
||||
const plan = await api.clientPlan(id);
|
||||
if (plan.items.length === 0) {
|
||||
set(id, { phase: "current", plan, step: null });
|
||||
void refresh(id);
|
||||
setTimeout(() => {
|
||||
if (get(id).phase === "current") set(id, { phase: "idle" });
|
||||
}, 5000);
|
||||
return;
|
||||
}
|
||||
if (plan.items.some((i) => i.kind === "modified")) {
|
||||
set(id, { phase: "choose", plan, step: null });
|
||||
return;
|
||||
}
|
||||
await syncClient(id, true);
|
||||
} catch (e) {
|
||||
fail(id, e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Download what is missing or changed; `keepModified` keeps the files the owner changed. */
|
||||
export async function syncClient(id: string, keepModified: boolean): Promise<void> {
|
||||
cancelled.delete(id);
|
||||
set(id, { phase: "working", step: null, error: null });
|
||||
void followProgress(id);
|
||||
try {
|
||||
await api.clientSync(id, keepModified);
|
||||
set(id, { phase: "done", step: null });
|
||||
if (startAfterUpdate("client", id)) void api.play(id).catch(() => undefined);
|
||||
void refresh(id);
|
||||
setTimeout(() => {
|
||||
if (get(id).phase === "done") set(id, { phase: "idle" });
|
||||
}, 6000);
|
||||
} catch (e) {
|
||||
fail(id, e);
|
||||
}
|
||||
}
|
||||
|
||||
export function stopClientJob(id: string) {
|
||||
cancelled.add(id);
|
||||
void api.clientCancel().catch(() => undefined);
|
||||
}
|
||||
|
||||
export function dismissClientJob(id: string) {
|
||||
set(id, { phase: "idle", error: null, plan: null, step: null });
|
||||
}
|
||||
|
||||
export function useClientJob(id: string): ClientJob {
|
||||
return useSyncExternalStore(
|
||||
(l) => {
|
||||
listeners.add(l);
|
||||
return () => listeners.delete(l);
|
||||
},
|
||||
() => get(id),
|
||||
);
|
||||
}
|
||||
+3
-11
@@ -2,8 +2,8 @@ import { useSyncExternalStore } from "react";
|
||||
import { api, type ClientStatus } from "@/lib/api";
|
||||
|
||||
/**
|
||||
* Game client status for the main screen: which client is linked and, for a client the Manager keeps up to date,
|
||||
* whether a newer one has been published. Checked at start and every five minutes (one small request; no game file is read).
|
||||
* Whether a game client is linked, for the main screen. The Manager does not download or update the client (the
|
||||
* community's official launcher does), so this is a local check only.
|
||||
*/
|
||||
interface State {
|
||||
status: ClientStatus | null;
|
||||
@@ -13,7 +13,6 @@ interface State {
|
||||
const EMPTY: State = { status: null, checking: false };
|
||||
const states = new Map<string, State>();
|
||||
const listeners = new Set<() => void>();
|
||||
const CHECK_EVERY_MS = 5 * 60 * 1000;
|
||||
|
||||
const get = (id: string) => states.get(id) ?? EMPTY;
|
||||
function set(id: string, next: Partial<State>) {
|
||||
@@ -27,19 +26,12 @@ export async function checkClient(id: string): Promise<void> {
|
||||
try {
|
||||
set(id, { status: await api.clientStatus(id) });
|
||||
} catch {
|
||||
// offline: keep what we knew
|
||||
// keep what we knew
|
||||
} finally {
|
||||
set(id, { checking: false });
|
||||
}
|
||||
}
|
||||
|
||||
/** Check now and then every five minutes. Returns the function that stops it. */
|
||||
export function startClientPolling(id: string): () => void {
|
||||
void checkClient(id);
|
||||
const t = setInterval(() => void checkClient(id), CHECK_EVERY_MS);
|
||||
return () => clearInterval(t);
|
||||
}
|
||||
|
||||
export function useClientStatus(id: string): State {
|
||||
return useSyncExternalStore(
|
||||
(l) => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useState } from "react";
|
||||
|
||||
/**
|
||||
* Whether a finished update starts things. Off by default for both: updating a stopped server leaves it stopped (a
|
||||
* server that was running is started again, as the update had to stop it) and a client update does not open the game.
|
||||
* Whether a finished server update starts the server. Off by default: updating a stopped server leaves it stopped (a
|
||||
* server that was running is started again, as the update had to stop it).
|
||||
*/
|
||||
export type AfterUpdate = "server" | "client";
|
||||
export type AfterUpdate = "server";
|
||||
|
||||
const key = (kind: AfterUpdate, id: string) => `coa-start-after-${kind}-update:${id}`;
|
||||
const fallback = (_kind: AfterUpdate) => false;
|
||||
|
||||
Reference in new issue
Block a user