svelte4-chess
Version:
Fully playable chess component for Svelte 4. Powered by Chess.js logic, Chessground chessboard and optionally Stockfish chess AI.
99 lines (98 loc) • 3.26 kB
TypeScript
import { SvelteComponent } from "svelte";
export type GameOverEvent = CustomEvent<GameOver>;
export type MoveEvent = CustomEvent<Move>;
export type UciEvent = CustomEvent<string>;
export type { Square, Color, PieceSymbol, Move, GameOver };
export { Engine } from "./engine.js";
import type { Config } from "chessground/config";
import { type Square, type Color, type PieceSymbol, type Move, type GameOver } from "./api.js";
import type { Engine } from "./engine.js";
import { type Key } from "chessground/types";
declare const __propDef: {
props: {
moveNumber?: number;
turn?: Color;
inCheck?: boolean;
history?: string[];
isGameOver?: boolean;
fen?: string;
orientation?: Color;
config?: Config;
engine?: Engine | undefined;
class?: string | undefined;
load?: (newFen: string) => void;
moveFromTo?: (from: Key, to: Key) => void;
setOwnColor?: (color: "white" | "black") => void;
ownColor?: "white" | "black";
setConfig?: (config: Config) => void;
moveLan?: (moveLan: string) => void;
move?: (moveSan: string) => void;
getHistory?: {
(): string[];
({ verbose }: {
verbose: true;
}): Move[];
({ verbose }: {
verbose: false;
}): string[];
({ verbose, }: {
verbose: boolean;
}): string[] | Move[];
};
getBoard?: () => ({
square: Square;
type: PieceSymbol;
color: Color;
} | null)[][];
undo?: () => Move | null;
reset?: () => void;
toggleOrientation?: () => void;
playEngineMove?: () => Promise<void>;
playPremove?: () => void;
};
events: {
move: CustomEvent<Move>;
gameOver: CustomEvent<GameOver>;
ready: CustomEvent<{}>;
uci: CustomEvent<string>;
update: CustomEvent<{}>;
} & {
[evt: string]: CustomEvent<any>;
};
slots: {};
exports?: {} | undefined;
bindings?: string | undefined;
};
export type ChessProps = typeof __propDef.props;
export type ChessEvents = typeof __propDef.events;
export type ChessSlots = typeof __propDef.slots;
export default class Chess extends SvelteComponent<ChessProps, ChessEvents, ChessSlots> {
get load(): (newFen: string) => void;
get moveFromTo(): (from: Key, to: Key) => void;
get setOwnColor(): (color: "white" | "black") => void;
get setConfig(): (config: Config) => void;
get moveLan(): (moveLan: string) => void;
get move(): (moveSan: string) => void;
get getHistory(): {
(): string[];
({ verbose }: {
verbose: true;
}): Move[];
({ verbose }: {
verbose: false;
}): string[];
({ verbose, }: {
verbose: boolean;
}): string[] | Move[];
};
get getBoard(): () => ({
square: Square;
type: PieceSymbol;
color: Color;
} | null)[][];
get undo(): () => Move | null;
get reset(): () => void;
get toggleOrientation(): () => void;
get playEngineMove(): () => Promise<void>;
get playPremove(): () => void;
}