2017-02-18 07:03:17 -07:00
|
|
|
interface Lichess {
|
2019-12-03 19:03:00 -07:00
|
|
|
// standalones/util.js
|
2019-04-29 09:26:07 -06:00
|
|
|
requestIdleCallback(f: () => void): void;
|
2019-12-03 19:03:00 -07:00
|
|
|
dispatchEvent(el: HTMLElement | Window, eventName: string): void;
|
|
|
|
hasTouchEvents: boolean;
|
2019-12-29 03:42:30 -07:00
|
|
|
sri: string;
|
2019-12-03 19:03:00 -07:00
|
|
|
isCol1(): boolean;
|
|
|
|
storage: LichessStorageHelper;
|
|
|
|
tempStorage: LichessStorageHelper; // TODO: unused
|
|
|
|
once(key: string, mod?: 'always'): boolean;
|
|
|
|
debounce(func: (...args: any[]) => void, wait: number, immediate?: boolean): (...args: any[]) => void;
|
|
|
|
powertip: any;
|
|
|
|
widget: unknown;
|
|
|
|
hoverable?: boolean;
|
|
|
|
isHoverable(): boolean;
|
|
|
|
spinnerHtml: string;
|
|
|
|
assetUrl(url: string, opts?: AssetUrlOpts): string;
|
2020-08-28 04:03:10 -06:00
|
|
|
soundUrl: string;
|
2019-12-03 19:03:00 -07:00
|
|
|
loadedCss: { [key: string]: boolean };
|
2019-04-29 09:26:07 -06:00
|
|
|
loadCss(path: string): void;
|
|
|
|
loadCssPath(path: string): void;
|
2020-08-03 01:44:30 -06:00
|
|
|
jsModule(name: string): string;
|
2019-12-03 19:03:00 -07:00
|
|
|
loadScript(url: string, opts?: AssetUrlOpts): Promise<unknown>;
|
|
|
|
hopscotch: any;
|
|
|
|
slider(): any;
|
|
|
|
makeChat(data: any, callback?: (chat: any) => void): void;
|
|
|
|
formAjax(form: JQuery): any;
|
|
|
|
numberFormat(n: number): string;
|
|
|
|
idleTimer(delay: number, onIdle: () => void, onWakeUp: () => void): void;
|
|
|
|
pubsub: Pubsub;
|
|
|
|
hasToReload: boolean;
|
|
|
|
redirect(o: string | { url: string, cookie: Cookie }): void;
|
|
|
|
reload(): void;
|
|
|
|
escapeHtml(str: string): string;
|
2020-04-04 04:44:15 -06:00
|
|
|
announce(d: LichessAnnouncement): void;
|
2019-12-03 19:03:00 -07:00
|
|
|
|
|
|
|
// standalones/trans.js
|
|
|
|
trans(i18n: { [key: string]: string | undefined }): Trans
|
|
|
|
|
|
|
|
// main.js
|
|
|
|
socket: any;
|
|
|
|
sound: any;
|
2020-08-27 06:43:11 -06:00
|
|
|
soundBox: {
|
|
|
|
load(name: string, path: string): Promise<void>;
|
|
|
|
loadOggOrMp3(name: string, path: string): Promise<void>;
|
2020-08-27 07:07:25 -06:00
|
|
|
play(name: string): void;
|
2020-08-27 06:43:11 -06:00
|
|
|
};
|
2019-12-03 19:03:00 -07:00
|
|
|
userAutocomplete: any;
|
2020-08-17 11:30:29 -06:00
|
|
|
miniBoard: {
|
|
|
|
init(node: HTMLElement): void;
|
|
|
|
initAll(): void;
|
|
|
|
};
|
2020-08-16 02:10:50 -06:00
|
|
|
miniGame: {
|
|
|
|
init(node: HTMLElement, data?: string): string;
|
|
|
|
initAll(): void;
|
|
|
|
update(node: HTMLElement, data: { fen: string, lm: string, wc?: number, bc?: number }): void;
|
|
|
|
finish(node: HTMLElement, win?: Color): void;
|
|
|
|
};
|
2019-12-03 19:03:00 -07:00
|
|
|
challengeApp: any;
|
|
|
|
ab?: any;
|
|
|
|
|
|
|
|
// socket.js
|
2017-06-28 07:47:14 -06:00
|
|
|
StrongSocket: {
|
2020-07-01 03:09:08 -06:00
|
|
|
(url: string, version: number | false, cfg: any): any;
|
|
|
|
defaults: {
|
|
|
|
events: {
|
|
|
|
fen(e: any): void;
|
|
|
|
}
|
2020-08-16 11:07:19 -06:00
|
|
|
},
|
|
|
|
firstConnect: Promise<(tpe: string, data: any) => void>
|
2017-06-28 07:47:14 -06:00
|
|
|
}
|
2019-12-03 19:03:00 -07:00
|
|
|
|
|
|
|
// timeago.js
|
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;
|
2017-10-01 13:55:20 -06:00
|
|
|
absolute(date: number | Date): string;
|
2017-07-25 10:40:38 -06:00
|
|
|
}
|
2019-12-03 19:03:00 -07:00
|
|
|
|
|
|
|
// misc
|
2018-01-16 16:33:30 -07:00
|
|
|
advantageChart: {
|
2019-05-07 04:09:15 -06:00
|
|
|
update(data: any): void;
|
2018-01-16 16:33:30 -07:00
|
|
|
(data: any, trans: Trans, el: HTMLElement): void;
|
|
|
|
}
|
2019-12-03 19:03:00 -07:00
|
|
|
movetimeChart: any;
|
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-01-11 23:22:13 -07:00
|
|
|
}
|
2019-04-28 21:20:01 -06:00
|
|
|
playMusic(): any;
|
2019-12-03 19:03:00 -07:00
|
|
|
quietMode?: boolean;
|
|
|
|
keyboardMove?: any;
|
2020-02-20 14:43:53 -07:00
|
|
|
notifyApp: {
|
|
|
|
setMsgRead(user: string): void;
|
|
|
|
}
|
2017-02-21 04:21:59 -07:00
|
|
|
}
|
|
|
|
|
2019-04-29 09:26:07 -06:00
|
|
|
interface LichessSpeech {
|
|
|
|
say(t: string, cut: boolean): void;
|
|
|
|
step(s: { san?: San }, cut: boolean): void;
|
|
|
|
}
|
|
|
|
|
2019-08-07 09:10:30 -06:00
|
|
|
interface PalantirOpts {
|
|
|
|
uid: string;
|
|
|
|
redraw(): void;
|
|
|
|
}
|
2019-08-02 17:03:49 -06:00
|
|
|
interface Palantir {
|
2019-08-08 08:22:55 -06:00
|
|
|
render(h: any): any;
|
2019-08-02 17:03:49 -06:00
|
|
|
}
|
|
|
|
|
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;
|
2017-12-03 13:02:11 -07:00
|
|
|
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
|
|
|
}
|
2017-02-21 15:22:50 -07:00
|
|
|
|
2019-04-24 20:17:52 -06:00
|
|
|
type PubsubCallback = (...data: any[]) => void;
|
|
|
|
|
2017-02-21 04:21:59 -07:00
|
|
|
interface Pubsub {
|
2019-04-29 09:26:07 -06:00
|
|
|
on(msg: string, f: PubsubCallback): void;
|
|
|
|
off(msg: string, f: PubsubCallback): void;
|
2019-07-04 21:26:42 -06:00
|
|
|
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;
|
2019-04-29 08:03:56 -06:00
|
|
|
makeBoolean(k: string): LichessBooleanStorage;
|
2019-05-02 01:56:10 -06:00
|
|
|
get(k: string): string | null;
|
|
|
|
set(k: string, v: string): void;
|
2019-12-29 03:42:30 -07:00
|
|
|
fire(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;
|
2019-10-09 19:36:23 -06:00
|
|
|
set(v: any): void;
|
2017-03-28 06:32:59 -06:00
|
|
|
remove(): void;
|
2019-12-29 03:42:30 -07:00
|
|
|
listen(f: (e: LichessStorageEvent) => void): void;
|
|
|
|
fire(v?: string): void;
|
2017-03-28 06:32:59 -06:00
|
|
|
}
|
|
|
|
|
2019-04-29 08:03:56 -06:00
|
|
|
interface LichessBooleanStorage {
|
|
|
|
get(): boolean;
|
2019-04-29 09:46:20 -06:00
|
|
|
set(v: boolean): boolean;
|
2019-04-29 08:03:56 -06:00
|
|
|
toggle(): void;
|
|
|
|
}
|
|
|
|
|
2019-12-29 03:42:30 -07:00
|
|
|
interface LichessStorageEvent {
|
|
|
|
sri: string;
|
|
|
|
nonce: number;
|
|
|
|
value?: string;
|
|
|
|
}
|
|
|
|
|
2020-04-04 04:44:15 -06:00
|
|
|
interface LichessAnnouncement {
|
|
|
|
msg?: string;
|
|
|
|
date?: string;
|
|
|
|
}
|
|
|
|
|
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-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;
|
2019-08-02 17:03:49 -06:00
|
|
|
LichessSpeech?: LichessSpeech;
|
|
|
|
palantir?: {
|
2019-08-07 09:10:30 -06:00
|
|
|
palantir(opts: PalantirOpts): Palantir
|
2019-08-02 17:03:49 -06:00
|
|
|
};
|
2017-12-05 18:19:01 -07:00
|
|
|
|
|
|
|
[key: string]: any; // TODO
|
2017-02-18 07:03:17 -07:00
|
|
|
}
|
2017-02-21 15:22:50 -07:00
|
|
|
|
2017-02-22 05:00:27 -07:00
|
|
|
interface LightUser {
|
|
|
|
id: string
|
|
|
|
name: string
|
|
|
|
title?: string
|
|
|
|
patron?: boolean
|
|
|
|
}
|
2017-02-23 04:31:53 -07:00
|
|
|
|
2019-11-22 09:53:32 -07:00
|
|
|
declare var SharedArrayBuffer: any | undefined;
|
|
|
|
declare var Atomics: any | undefined;
|
2017-04-04 15:25:35 -06:00
|
|
|
|
2020-01-15 16:16:00 -07:00
|
|
|
interface Navigator {
|
|
|
|
deviceMemory: number;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-04-14 21:14:14 -06:00
|
|
|
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;
|
2020-03-30 15:19:04 -06:00
|
|
|
drops?: string | null;
|
|
|
|
check?: Key;
|
2017-04-04 15:25:35 -06:00
|
|
|
threat?: ClientEval;
|
|
|
|
ceval?: ClientEval;
|
|
|
|
eval?: ServerEval;
|
2020-03-30 15:19:04 -06:00
|
|
|
tbhit?: TablebaseHit | null;
|
2017-04-04 15:25:35 -06:00
|
|
|
glyphs?: Glyph[];
|
|
|
|
clock?: Clock;
|
|
|
|
parentClock?: Clock;
|
2020-03-30 15:19:04 -06:00
|
|
|
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;
|
2020-03-30 08:19:35 -06:00
|
|
|
puzzle?: 'win' | 'fail' | 'good' | 'retry';
|
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;
|
2017-08-19 20:16:14 -06:00
|
|
|
shapes?: Shape[]
|
2017-08-14 18:44:04 -06:00
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
}
|
|
|
|
}
|
2017-12-05 18:19:01 -07:00
|
|
|
|
|
|
|
interface JQueryStatic {
|
|
|
|
modal: LichessModal;
|
|
|
|
powerTip: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface LichessModal {
|
2020-07-01 03:09:08 -06:00
|
|
|
(html: string | JQuery, cls?: string, onClose?: () => void): JQuery;
|
2017-12-05 18:19:01 -07:00
|
|
|
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;
|
2019-11-23 07:42:44 -07:00
|
|
|
slider(key: string, value: any): any;
|
|
|
|
slider(opts: any): any;
|
2020-05-15 12:15:14 -06:00
|
|
|
flatpickr(opts: any): any;
|
2017-12-05 18:19:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
declare namespace PowerTip {
|
|
|
|
type Placement = 'n' | 'e' | 's' | 'w' | 'nw' | 'ne' | 'sw' | 'se' | 'nw-alt' | 'ne-alt' | 'sw-alt' | 'se-alt';
|
|
|
|
|
|
|
|
interface Options {
|
|
|
|
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[];
|
|
|
|
}
|
|
|
|
}
|