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

331 lines
7.7 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
2017-12-03 13:02:11 -07:00
trans(i18n: { [key: string]: string | undefined }): Trans
2017-02-21 04:21:59 -07:00
numberFormat(n: number): string
once(key: string): boolean
quietMode: boolean
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;
2018-01-10 09:41:33 -07:00
redirect(o: string | { url: string, cookie: Cookie }): void;
2018-11-05 12:09:07 -07:00
loadScript(url: string, opts?: AssetUrlOpts): any
compiledScript(path: string): string
2017-04-25 08:10:14 -06:00
keyboardMove: any
slider(): any
raf(f: () => void): void;
requestIdleCallback(f: () => void): void;
loadCss(path: string): void;
loadCssPath(path: string): void;
2019-04-14 18:19:28 -06:00
loadedCss: {
[key: string]: boolean;
}
escapeHtml(str: string): string
2019-02-28 03:27:57 -07:00
debounce(func: (...args: any[]) => void, wait: number, immediate?: boolean): (...args: any[]) => void;
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;
2019-02-24 00:02:59 -07:00
makeChat(data: any, callback?: (chat: any) => void): 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
}
2018-01-16 16:33:30 -07:00
advantageChart: {
update(data: any): void;
2018-01-16 16:33:30 -07:00
(data: any, trans: Trans, el: HTMLElement): void;
}
2019-02-26 00:55:29 -07:00
dispatchEvent(el: HTMLElement | Window, eventName: string): void;
2019-01-22 18:18:55 -07:00
RoundNVUI(redraw: () => void): {
2019-01-25 01:06:31 -07:00
render(ctrl: any): any;
}
AnalyseNVUI(redraw: () => void): {
render(ctrl: any): any;
}
2019-04-28 21:20:01 -06:00
playMusic(): any;
LichessSpeech?: LichessSpeech;
2019-02-22 20:57:09 -07:00
spinnerHtml: string;
movetimeChart: any;
hasTouchEvents: boolean;
mousedownEvent: 'mousedown' | 'touchstart';
2019-05-02 18:03:48 -06:00
isCol1(): boolean;
pushSubscribe(ask: boolean): void;
formAjax(form: JQuery): any;
2017-02-21 04:21:59 -07:00
}
interface LichessSpeech {
say(t: string, cut: boolean): void;
step(s: { san?: San }, cut: boolean): void;
}
2018-01-10 09:41:33 -07:00
interface Cookie {
name: string;
value: string;
maxAge: number;
}
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;
2019-07-27 01:08:27 -06:00
type TransNoArg = (key: string) => string;
2017-12-03 13:02:11 -07:00
interface Trans {
(key: string, ...args: Array<string | number>): string;
2019-07-27 01:08:27 -06:00
noarg: TransNoArg;
2017-12-03 13:02:11 -07:00
plural(key: string, count: number, ...args: Array<string | number>): string;
vdom<T>(key: string, ...args: T[]): (string | T)[];
2017-12-30 08:49:33 -07:00
vdomPlural<T>(key: string, count: number, countArg: T, ...args: T[]): (string | T)[];
2017-12-03 13:02:11 -07:00
}
type PubsubCallback = (...data: any[]) => void;
2017-02-21 04:21:59 -07:00
interface Pubsub {
on(msg: string, f: PubsubCallback): void;
off(msg: string, f: PubsubCallback): 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;
makeBoolean(k: string): LichessBooleanStorage;
2019-05-02 01:56:10 -06:00
get(k: string): string | null;
set(k: string, v: string): void;
2017-03-28 06:32:59 -06:00
remove(k: string): void;
}
interface LichessStorage {
2019-05-02 01:56:10 -06:00
get(): string | null;
set(v: string): void;
2017-03-28 06:32:59 -06:00
remove(): void;
listen(f: (e: StorageEvent) => void): void;
}
interface LichessBooleanStorage {
get(): boolean;
2019-04-29 09:46:20 -06:00
set(v: boolean): boolean;
toggle(): 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;
[key: string]: any; // TODO
2017-02-18 07:03:17 -07:00
}
interface LightUser {
id: string
name: string
title?: string
patron?: boolean
}
2017-02-23 04:31:53 -07:00
2019-04-28 21:22:49 -06:00
declare var SharedArrayBuffer: any | undefined;
declare var Atomics: any | undefined;
2017-04-04 15:25:35 -06:00
2018-11-22 12:19:05 -07:00
declare type VariantKey = 'standard' | 'chess960' | 'antichess' | 'fromPosition' | 'kingOfTheHill' | 'threeCheck' | 'atomic' | 'horde' | 'racingKings' | 'crazyhouse';
2017-04-04 15:25:35 -06:00
2018-11-22 12:19:05 -07:00
declare type Speed = 'bullet' | 'blitz' | 'classical' | 'correspondence' | 'unlimited';
2017-04-04 15:25:35 -06:00
2018-11-22 12:19:05 -07:00
declare type Perf = 'bullet' | 'blitz' | 'classical' | 'correspondence' | 'chess960' | 'antichess' | 'fromPosition' | 'kingOfTheHill' | 'threeCheck' | 'atomic' | 'horde' | 'racingKings' | 'crazyhouse';
2017-04-04 15:25:35 -06:00
2018-11-22 12:19:05 -07:00
declare type Color = 'white' | 'black';
2017-04-04 15:25:35 -06:00
2018-11-22 12:19:05 -07: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';
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
}
2018-11-22 03:06:27 -07:00
interface Paginator<A> {
currentPage: number
maxPerPage: number
2019-02-10 05:58:33 -07:00
currentPageResults: Array<A>
2018-11-22 03:06:27 -07:00
nbResults: number
previousPage?: number
nextPage?: number
nbPages: number
}
2017-04-04 15:25:35 -06:00
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 TablebaseHit {
winner: Color | undefined;
best?: Uci;
}
2017-04-04 15:25:35 -06:00
export interface Node {
id: string;
2017-06-22 08:40:51 -06:00
ply: Ply;
2017-12-30 06:18:24 -07:00
uci?: Uci;
2017-06-22 08:40:51 -06:00
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;
2017-12-30 06:18:24 -07:00
check?: boolean;
2017-04-04 15:25:35 -06:00
threat?: ClientEval;
ceval?: ClientEval;
eval?: ServerEval;
2018-08-16 05:54:15 -06:00
tbhit: TablebaseHit | undefined | null;
2017-04-04 15:25:35 -06:00
opening?: Opening;
glyphs?: Glyph[];
clock?: Clock;
parentClock?: Clock;
forceVariation: boolean;
2017-04-04 15:25:35 -06:00
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;
}
2018-01-14 15:26:55 -07:00
type GlyphId = number;
interface Glyph {
id: GlyphId;
2017-04-04 15:25:35 -06:00
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 {
}
}
interface JQueryStatic {
modal: LichessModal;
powerTip: any;
}
interface LichessModal {
2019-04-23 02:15:06 -06:00
(html: string | JQuery, cls?: string): JQuery;
close(): void;
}
interface JQuery {
powerTip(options?: PowerTip.Options | 'show' | 'hide'): JQuery;
typeahead: any;
sparkline: any;
clock: any;
watchers(): JQuery;
watchers(method: 'set', data: any): void;
2018-01-16 19:55:14 -07:00
highcharts(conf?: any): any;
}
declare namespace PowerTip {
type Placement = 'n' | 'e' | 's' | 'w' | 'nw' | 'ne' | 'sw' | 'se' | 'nw-alt' | 'ne-alt' | 'sw-alt' | 'se-alt';
interface Options {
followMouse?: boolean;
mouseOnToPopup?: boolean;
placement?: Placement;
smartPlacement?: boolean;
popupId?: string;
poupClass?: string;
offset?: number;
fadeInTime?: number;
fadeOutTime?: number;
closeDelay?: number;
intentPollInterval?: number;
intentSensitivity?: number;
manual?: boolean;
openEvents?: string[];
closeEvents?: string[];
}
}
interface Array<T> {
includes(t: T): boolean;
}