lila/ui/@types/lichess/index.d.ts

241 lines
5.5 KiB
TypeScript
Raw Normal View History

2017-02-18 07:03:17 -07:00
interface Lichess {
2017-02-21 04:21:59 -07:00
pubsub: Pubsub
trans: Trans
2017-02-21 04:21:59 -07:00
numberFormat(n: number): string
once(key: string): boolean
quietMode: boolean
2017-07-08 09:04:16 -06:00
desktopNotification(txt: string | (() => string)): void
2017-03-28 06:32:59 -06:00
engineName: string;
assetUrl(url: string, opts?: AssetUrlOpts): string;
storage: LichessStorageHelper
2017-04-10 06:53:04 -06:00
reload(): void;
2017-04-25 08:10:14 -06:00
loadScript(url: string): any
keyboardMove: any
2017-05-04 04:56:49 -06:00
slider: () => any
reloadOtherTabs: () => void
2017-07-02 06:43:40 -06:00
raf(f: () => void): void
2017-05-04 11:44:46 -06:00
requestIdleCallback(f: () => void): void
2017-06-27 04:50:43 -06:00
loadCss(path: string): void
unloadCss(path: string): void
loadedCss: [string];
2017-06-28 06:42:08 -06:00
escapeHtml(html: string): string
toYouTubeEmbedUrl(url: string): string
2017-03-28 06:32:59 -06:00
fp: {
debounce(func: (...args: any[]) => void, wait: number, immediate?: boolean): (...args: any[]) => void;
contains<T>(list: T[], needle: T): boolean;
}
2017-03-28 06:32:59 -06:00
sound: any
2017-02-22 00:34:57 -07:00
powertip: any
2017-06-28 06:42:08 -06:00
userAutocomplete: any
2017-06-28 07:47:14 -06:00
StrongSocket: {
sri: string
2017-07-09 03:30:02 -06:00
(url: string, version: number, cfg: any): any;
2017-06-28 07:47:14 -06:00
}
2017-07-08 09:04:16 -06:00
socket: any;
idleTimer(delay: number, onIdle: () => void, onWakeUp: () => void): void;
2017-07-05 06:23:33 -06:00
parseFen(el: any): void;
2017-07-08 06:49:10 -06:00
hasToReload: boolean;
2017-07-08 09:04:16 -06:00
ab: any;
challengeApp: any;
hopscotch: any;
2017-07-09 08:16:08 -06:00
makeChat(id: string, data: any, callback?: (chat: any) => void): void;
2017-07-09 03:30:02 -06:00
topMenuIntent(): void;
2017-07-25 10:40:38 -06:00
timeago: {
render(nodes: HTMLElement | HTMLElement[]): void;
2017-10-01 16:07:55 -06:00
format(date: number | Date): string;
absolute(date: number | Date): string;
2017-07-25 10:40:38 -06:00
}
2017-02-21 04:21:59 -07:00
}
2017-03-28 06:32:59 -06:00
interface AssetUrlOpts {
sameDomain?: boolean;
noVersion?: boolean;
}
2017-07-08 03:06:36 -06:00
declare type SocketSend = (type: string, data?: any, opts?: any, noRetry?: boolean) => void;
declare type Trans = any; // todo
2017-02-21 04:21:59 -07:00
interface Pubsub {
on(msg: string, f: (data: any) => void): void
emit(msg: string): (...args: any[]) => void
2017-02-18 07:03:17 -07:00
}
2017-03-28 06:32:59 -06:00
interface LichessStorageHelper {
make(k: string): LichessStorage;
get(k: string): string;
set(k: string, v: string): string;
remove(k: string): void;
}
interface LichessStorage {
get(): string;
set(v: string): string;
remove(): void;
listen(f: (e: StorageEvent) => void): void;
}
2017-02-18 07:03:17 -07:00
interface Window {
lichess: Lichess
2017-03-28 06:32:59 -06:00
2017-02-21 04:21:59 -07:00
moment: any
2017-02-18 07:03:17 -07:00
Mousetrap: any
2017-06-28 06:42:08 -06:00
Howl: any
2017-04-24 07:11:52 -06:00
Chessground: any
2017-05-04 06:32:10 -06:00
Highcharts: any
2017-06-27 04:27:48 -06:00
lichessReplayMusic: () => {
jump(node: Tree.Node): void
}
2017-07-08 09:04:16 -06:00
hopscotch: any;
2017-07-12 07:30:18 -06:00
lichessPlayMusic(): void;
2017-07-12 07:38:36 -06:00
[key: string]: any;
2017-02-18 07:03:17 -07:00
}
interface Paginator<T> {
currentPage: number
maxPerPage: number
currentPageResults: Array<T>
nbResults: number
previousPage: number
nextPage: number
nbPages: number
}
interface LightUser {
id: string
name: string
title?: string
patron?: boolean
}
2017-02-23 04:31:53 -07:00
interface Array<T> {
find(f: (t: T) => boolean): T | undefined;
}
2017-03-28 06:32:59 -06:00
2017-04-10 06:53:04 -06:00
interface Math {
log2?: (x: number) => number;
}
2017-03-28 06:32:59 -06:00
interface WebAssemblyStatic {
validate: (code: Uint8Array) => boolean;
}
declare var WebAssembly: WebAssemblyStatic | undefined;
2017-04-04 15:25:35 -06:00
declare type VariantKey = 'standard' | 'chess960' | 'antichess' | 'fromPosition' | 'kingOfTheHill' | 'threeCheck' | 'atomic' | 'horde' | 'racingKings' | 'crazyhouse'
declare type Speed = 'bullet' | 'blitz' | 'classical' | 'correspondence' | 'unlimited'
declare type Perf = 'bullet' | 'blitz' | 'classical' | 'correspondence' | 'chess960' | 'antichess' | 'fromPosition' | 'kingOfTheHill' | 'threeCheck' | 'atomic' | 'horde' | 'racingKings' | 'crazyhouse'
declare type Color = 'white' | 'black';
2017-06-26 05:02:52 -06:00
declare type Key = 'a0' | 'a1' | 'b1' | 'c1' | 'd1' | 'e1' | 'f1' | 'g1' | 'h1' | 'a2' | 'b2' | 'c2' | 'd2' | 'e2' | 'f2' | 'g2' | 'h2' | 'a3' | 'b3' | 'c3' | 'd3' | 'e3' | 'f3' | 'g3' | 'h3' | 'a4' | 'b4' | 'c4' | 'd4' | 'e4' | 'f4' | 'g4' | 'h4' | 'a5' | 'b5' | 'c5' | 'd5' | 'e5' | 'f5' | 'g5' | 'h5' | 'a6' | 'b6' | 'c6' | 'd6' | 'e6' | 'f6' | 'g6' | 'h6' | 'a7' | 'b7' | 'c7' | 'd7' | 'e7' | 'f7' | 'g7' | 'h7' | 'a8' | 'b8' | 'c8' | 'd8' | 'e8' | 'f8' | 'g8' | 'h8';
2017-06-22 08:40:51 -06:00
declare type Uci = string;
2017-06-26 05:02:52 -06:00
declare type San = string;
2017-06-22 08:40:51 -06:00
declare type Fen = string;
declare type Ply = number;
2017-04-04 15:25:35 -06:00
interface Variant {
key: VariantKey
name: string
short: string
title?: string
}
declare namespace Tree {
export type Path = string;
export interface ClientEval {
2017-06-22 08:40:51 -06:00
fen: Fen;
2017-04-04 15:25:35 -06:00
maxDepth: number;
depth: number;
knps: number;
nodes: number;
millis: number;
pvs: PvData[];
cloud?: boolean;
cp?: number;
mate?: number;
2017-06-26 05:02:52 -06:00
retried?: boolean;
2017-04-04 15:25:35 -06:00
}
export interface ServerEval {
cp?: number;
mate?: number;
2017-06-26 05:02:52 -06:00
best?: Uci;
2017-04-04 15:25:35 -06:00
}
export interface PvData {
moves: string[];
mate?: number;
cp?: number;
}
export interface Node {
id: string;
2017-06-22 08:40:51 -06:00
ply: Ply;
uci: Uci;
fen: Fen;
2017-04-04 15:25:35 -06:00
children: Node[];
comments?: Comment[];
2017-08-14 18:44:04 -06:00
gamebook?: Gamebook;
2017-06-24 06:20:20 -06:00
dests?: string;
2017-04-04 15:25:35 -06:00
drops: string | undefined | null;
check: boolean;
threat?: ClientEval;
ceval?: ClientEval;
eval?: ServerEval;
opening?: Opening;
glyphs?: Glyph[];
clock?: Clock;
parentClock?: Clock;
shapes?: Shape[];
comp?: boolean;
2017-04-05 16:07:13 -06:00
san?: string;
2017-06-24 05:10:09 -06:00
threefold?: boolean;
2017-06-28 07:34:50 -06:00
fail?: boolean;
puzzle?: string;
2017-10-16 17:57:41 -06:00
crazy?: NodeCrazy;
}
export interface NodeCrazy {
pockets: [CrazyPocket, CrazyPocket];
}
export interface CrazyPocket {
[role: string]: number;
2017-04-04 15:25:35 -06:00
}
export interface Comment {
id: string;
2017-06-28 06:42:08 -06:00
by: string | {
id: string;
name: string;
};
2017-04-04 15:25:35 -06:00
text: string;
}
2017-08-14 18:44:04 -06:00
export interface Gamebook {
deviation?: string;
2017-08-18 16:28:17 -06:00
hint?: string;
shapes?: Shape[]
2017-08-14 18:44:04 -06:00
}
2017-04-04 15:25:35 -06:00
export interface Opening {
2017-07-10 06:27:54 -06:00
name: string;
2017-04-04 15:25:35 -06:00
eco: string;
}
export interface Glyph {
name: string;
symbol: string;
}
2017-07-02 05:59:36 -06:00
export type Clock = number;
2017-04-04 15:25:35 -06:00
export interface Shape {
}
}