Refactor Settings, FileTree, GitPanel, Shell, and CodeEditor components (#402)

This commit is contained in:
Haileyesus
2026-02-25 19:07:07 +03:00
committed by GitHub
parent 23801e9cc1
commit 5e3a7b69d7
149 changed files with 11627 additions and 8453 deletions

View File

@@ -0,0 +1,32 @@
import { IS_PLATFORM } from '../../../constants/config';
import type { ShellIncomingMessage, ShellOutgoingMessage } from '../types/types';
export function getShellWebSocketUrl(): string | null {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
if (IS_PLATFORM) {
return `${protocol}//${window.location.host}/shell`;
}
const token = localStorage.getItem('auth-token');
if (!token) {
console.error('No authentication token found for Shell WebSocket connection');
return null;
}
return `${protocol}//${window.location.host}/shell?token=${encodeURIComponent(token)}`;
}
export function parseShellMessage(payload: string): ShellIncomingMessage | null {
try {
return JSON.parse(payload) as ShellIncomingMessage;
} catch {
return null;
}
}
export function sendSocketMessage(ws: WebSocket | null, message: ShellOutgoingMessage): void {
if (ws && ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(message));
}
}