47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import { GameApiConfig } from '../api';
|
|
export interface SessionStatus {
|
|
type: 'new' | 'resumed' | 'timeout' | 'completed' | 'assignment_ended' | 'not_started';
|
|
message: string;
|
|
data?: {
|
|
answered?: number;
|
|
total?: number;
|
|
score?: number;
|
|
remainingTime?: number;
|
|
startedAt?: string;
|
|
};
|
|
}
|
|
export interface GamePlayerError {
|
|
type: 'network' | 'api' | 'timeout' | 'session' | 'not_started' | 'unknown';
|
|
code?: number;
|
|
message: string;
|
|
details?: any;
|
|
canRetry?: boolean;
|
|
}
|
|
export declare const SessionErrorCodes: {
|
|
readonly SESSION_NOT_STARTED: -60;
|
|
readonly SESSION_ENDED: -61;
|
|
readonly SESSION_COMPLETED: -62;
|
|
readonly SESSION_TIMEOUT: -63;
|
|
readonly SESSION_NOT_FOUND: -64;
|
|
readonly SESSION_ALREADY_ANSWERED: -65;
|
|
};
|
|
export interface GamePlayerProps {
|
|
apiConfig: GameApiConfig;
|
|
assignmentId: number;
|
|
studentId: string;
|
|
className?: string;
|
|
style?: React.CSSProperties;
|
|
debug?: boolean;
|
|
onComplete?: (result: any) => void;
|
|
onError?: (error: GamePlayerError) => void;
|
|
onGameLoaded?: (gameInfo: any) => void;
|
|
extraGameData?: Record<string, any>;
|
|
onLog?: (message: string, type?: 'info' | 'success' | 'error' | 'warning') => void;
|
|
onSessionStatus?: (status: SessionStatus) => void;
|
|
renderLoading?: () => React.ReactNode;
|
|
renderError?: (error: GamePlayerError, retry: () => void) => React.ReactNode;
|
|
loadingTimeout?: number;
|
|
}
|
|
export declare const GamePlayer: React.FC<GamePlayerProps>;
|
|
//# sourceMappingURL=GamePlayer.d.ts.map
|