Custom signal-based runtime (no i18n dependency): shared src/shared/i18n dictionaries, ui I18nService.t() reactive by construction so language switches live, and a backend i18n.ts for native menus + thrown errors. Every user-facing string keyed across templates, toasts, dialogs, file kinds, columns, macOS menu/context menus, and errors. Language picker in Options (auto-detects OS locale, falls back to English); switching relabels the webview and native chrome instantly. English/Spanish/French/ German fully drafted; Chinese/Japanese/Basque drafted, flagged for native review. Docs updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { t } from "../i18n";
|
|
import { LocalProvider } from "./local";
|
|
import type { FileSystemProvider } from "./provider";
|
|
|
|
export const LOCAL_SESSION_ID = "local";
|
|
|
|
/**
|
|
* Maps sessionId -> provider. "local" is always available; each SFTP connect
|
|
* adds a new session (one SSH connection per panel-connect, no refcounting).
|
|
*/
|
|
export class SessionRegistry {
|
|
private sessions = new Map<string, FileSystemProvider>([
|
|
[LOCAL_SESSION_ID, new LocalProvider()],
|
|
]);
|
|
private counter = 0;
|
|
|
|
get(sessionId: string): FileSystemProvider {
|
|
const provider = this.sessions.get(sessionId);
|
|
if (!provider) throw new Error(t("errors.sessionNotConnected", { id: sessionId }));
|
|
return provider;
|
|
}
|
|
|
|
add(provider: FileSystemProvider): string {
|
|
const id = `sftp-${++this.counter}`;
|
|
this.sessions.set(id, provider);
|
|
return id;
|
|
}
|
|
|
|
async remove(sessionId: string): Promise<void> {
|
|
if (sessionId === LOCAL_SESSION_ID)
|
|
throw new Error(t("errors.localCannotDisconnect"));
|
|
const provider = this.sessions.get(sessionId);
|
|
if (!provider) return;
|
|
this.sessions.delete(sessionId);
|
|
await provider.dispose();
|
|
}
|
|
|
|
/** Remove without dispose — for sessions that died on their own. */
|
|
drop(sessionId: string): void {
|
|
if (sessionId === LOCAL_SESSION_ID) return;
|
|
this.sessions.delete(sessionId);
|
|
}
|
|
}
|