Fix TypeScript build errors

This commit is contained in:
Joan
2025-11-28 10:52:23 +01:00
parent 0d7133cc0e
commit 592591cb92
26 changed files with 10 additions and 9045 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -31,8 +31,8 @@ export const useGameWebSocket = ({
}: UseGameWebSocketProps): UseGameWebSocketReturn => {
const [isConnected, setIsConnected] = useState(false);
const wsRef = useRef<WebSocket | null>(null);
const reconnectTimeoutRef = useRef<number | null>(null);
const heartbeatIntervalRef = useRef<number | null>(null);
const reconnectTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const heartbeatIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
const reconnectAttemptsRef = useRef(0);
const maxReconnectAttempts = 5;
const reconnectDelay = 3000; // 3 seconds
@@ -40,14 +40,14 @@ export const useGameWebSocket = ({
// Get WebSocket URL based on current environment
const getWebSocketUrl = useCallback(() => {
const API_BASE = import.meta.env.VITE_API_URL || (
import.meta.env.PROD
? 'https://api-staging.echoesoftheash.com'
import.meta.env.PROD
? 'https://api-staging.echoesoftheash.com'
: 'http://localhost:8000'
);
// Remove /api suffix if present and convert http(s) to ws(s)
const wsBase = API_BASE.replace(/\/api$/, '').replace(/^http/, 'ws');
return `${wsBase}/ws/game/${token}`;
}, [token]);
@@ -65,7 +65,7 @@ export const useGameWebSocket = ({
try {
const wsUrl = getWebSocketUrl();
console.log('🔌 Connecting to WebSocket:', wsUrl);
const ws = new WebSocket(wsUrl);
wsRef.current = ws;
@@ -81,7 +81,7 @@ export const useGameWebSocket = ({
ws.onmessage = (event) => {
try {
const message: WebSocketMessage = JSON.parse(event.data);
// Handle heartbeat acks silently
if (message.type === 'heartbeat_ack' || message.type === 'pong') {
return;
@@ -114,7 +114,7 @@ export const useGameWebSocket = ({
console.log(
`🔄 Reconnecting... (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts})`
);
reconnectTimeoutRef.current = setTimeout(() => {
connect();
}, reconnectDelay);

View File

@@ -56,6 +56,7 @@ export interface LoginResponse {
token_type: string
account: Account
characters: Character[]
needs_character_creation?: boolean
}
export interface RegisterResponse {