up
All checks were successful
Deploy to Production / deploy (push) Successful in 8s

This commit is contained in:
lubukhu
2026-01-24 13:35:11 +07:00
parent 6c3e93636e
commit 65fd0158a3
145 changed files with 10262 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
/**
* Game Iframe SDK - React Hook
* Custom hook để sử dụng SDK trong React components
*
* @example
* ```tsx
* import { useGameIframeSDK } from 'game-iframe-sdk/react';
*
* function GamePlayer() {
* const iframeRef = useRef<HTMLIFrameElement>(null);
*
* const {
* isReady,
* sendGameData,
* sendLeaderboard
* } = useGameIframeSDK({
* iframeRef,
* iframeOrigin: 'http://senaai.vn:1357',
* onGameReady: () => console.log('Game ready!'),
* onAnswerReport: (data) => submitToServer(data),
* onFinalResult: (data) => showResults(data),
* });
*
* return <iframe ref={iframeRef} src={gameUrl} />;
* }
* ```
*/
import { GameIframeSDK } from './GameIframeSDK';
import { GameIframeSDKConfig, PushDataPayload, LeaderboardData, AnswerReportData, FinalResultData } from './types';
export interface UseGameIframeSDKOptions extends Omit<GameIframeSDKConfig, 'iframeOrigin'> {
/**
* Ref to iframe element
*/
iframeRef: React.RefObject<HTMLIFrameElement>;
/**
* Origin of iframe (required)
*/
iframeOrigin: string;
/**
* Callback when game is ready
*/
onGameReady?: () => void;
/**
* Callback when user answers a question
*/
onAnswerReport?: (data: AnswerReportData) => void;
/**
* Callback when game ends
*/
onFinalResult?: (data: FinalResultData) => void;
/**
* Callback when game requests leaderboard
*/
onLeaderboardRequest?: (top: number) => void;
/**
* Callback for errors
*/
onError?: (error: {
message: string;
error?: any;
}) => void;
}
export interface UseGameIframeSDKReturn {
/**
* SDK instance
*/
sdk: GameIframeSDK | null;
/**
* Whether game is ready
*/
isReady: boolean;
/**
* Send game data to iframe
*/
sendGameData: (data: PushDataPayload) => boolean;
/**
* Send leaderboard data
*/
sendLeaderboard: (data: LeaderboardData) => boolean;
/**
* Queue data to send when ready
*/
queueGameData: (data: PushDataPayload) => void;
/**
* Force reload iframe
*/
reloadIframe: () => boolean;
}
export declare function useGameIframeSDK(options: UseGameIframeSDKOptions): UseGameIframeSDKReturn;
export default useGameIframeSDK;
//# sourceMappingURL=useGameIframeSDK.d.ts.map