diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 8a8640ca72b..1f065a14e5d 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -5,5 +5,21 @@ "arrowParens": "avoid", "endOfLine": "lf", "ignorePatterns": ["**/public", "COPYING.md", "README.md"], - "experimentalSortPackageJson": false + "sortPackageJson": false, + "sortImports": { + "customGroups": [ + { + "groupName": "libs", + "elementNamePattern": ["lib", "lib/**"] + } + ], + "groups": [ + ["builtin", "external"], + ["libs"], + ["internal", "subpath"], + ["parent", "sibling", "index"], + "style", + "unknown" + ] + } } diff --git a/bin/i18n-file-gen.ts b/bin/i18n-file-gen.ts index 52c11f88b6f..6dbf4f30be7 100644 --- a/bin/i18n-file-gen.ts +++ b/bin/i18n-file-gen.ts @@ -1,6 +1,6 @@ +import { XMLParser } from 'fast-xml-parser'; import { readdirSync, readFileSync, writeFileSync } from 'fs'; import path from 'path'; -import { XMLParser } from 'fast-xml-parser'; import { fileURLToPath } from 'url'; interface TranslationXml { diff --git a/bin/ublog-automod.mjs b/bin/ublog-automod.mjs index bb2369eb4f9..210e0ccbff9 100755 --- a/bin/ublog-automod.mjs +++ b/bin/ublog-automod.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env node import { MongoClient } from 'mongodb'; -import { setTimeout as sleep } from 'node:timers/promises'; -import fs from 'node:fs'; import crypto from 'node:crypto'; +import fs from 'node:fs'; +import { setTimeout as sleep } from 'node:timers/promises'; // consider a wrapper script to provide common options (like the together.ai api key). // bin/ublog-automod (with no extension) is .gitignored for this purpose. diff --git a/ui/.build/src/build.ts b/ui/.build/src/build.ts index 45016edbed9..5fbb1667937 100644 --- a/ui/.build/src/build.ts +++ b/ui/.build/src/build.ts @@ -1,19 +1,20 @@ +import { execSync } from 'node:child_process'; import fs from 'node:fs'; import { relative, join } from 'node:path'; -import { execSync } from 'node:child_process'; import { chdir } from 'node:process'; -import { parsePackages } from './parse.ts'; -import { makeTask, stopTask } from './task.ts'; -import { tsc, stopTsc } from './tsc.ts'; -import { sass, stopSass } from './sass.ts'; -import { esbuild, stopEsbuild } from './esbuild.ts'; -import { sync } from './sync.ts'; -import { hash } from './hash.ts'; -import { stopManifest } from './manifest.ts'; -import { env, errorMark, c } from './env.ts'; -import { i18n } from './i18n.ts'; + import { definedUnique } from './algo.ts'; import { clean } from './clean.ts'; +import { env, errorMark, c } from './env.ts'; +import { esbuild, stopEsbuild } from './esbuild.ts'; +import { hash } from './hash.ts'; +import { i18n } from './i18n.ts'; +import { stopManifest } from './manifest.ts'; +import { parsePackages } from './parse.ts'; +import { sass, stopSass } from './sass.ts'; +import { sync } from './sync.ts'; +import { makeTask, stopTask } from './task.ts'; +import { tsc, stopTsc } from './tsc.ts'; export async function build(pkgs: string[]): Promise { env.startTime = Date.now(); diff --git a/ui/.build/src/clean.ts b/ui/.build/src/clean.ts index 018b7f23cf3..27eb72870fa 100644 --- a/ui/.build/src/clean.ts +++ b/ui/.build/src/clean.ts @@ -1,5 +1,6 @@ -import { promises as fs } from 'node:fs'; import fg from 'fast-glob'; +import { promises as fs } from 'node:fs'; + import { env, c } from './env.ts'; const globOpts: fg.Options = { diff --git a/ui/.build/src/console.ts b/ui/.build/src/console.ts index 82fee2424c4..c43b9367ff9 100644 --- a/ui/.build/src/console.ts +++ b/ui/.build/src/console.ts @@ -1,7 +1,8 @@ -import { createServer, IncomingMessage, ServerResponse } from 'node:http'; -import { env, errorMark, warnMark, c } from './env.ts'; import { transform } from 'esbuild'; import stringify from 'json-stringify-pretty-compact'; +import { createServer, IncomingMessage, ServerResponse } from 'node:http'; + +import { env, errorMark, warnMark, c } from './env.ts'; export async function startConsole() { if (!env.remoteLog || !env.watch) return; diff --git a/ui/.build/src/env.ts b/ui/.build/src/env.ts index d272fc40a96..36d66799105 100644 --- a/ui/.build/src/env.ts +++ b/ui/.build/src/env.ts @@ -1,9 +1,10 @@ -import type { Package } from './parse.ts'; import fs from 'node:fs'; -import ps from 'node:process'; import { join, resolve, dirname } from 'node:path'; +import ps from 'node:process'; + import { definedUnique, isEquivalent } from './algo.ts'; import { updateManifest } from './manifest.ts'; +import type { Package } from './parse.ts'; import { taskOk } from './task.ts'; // state, logging, status diff --git a/ui/.build/src/esbuild.ts b/ui/.build/src/esbuild.ts index e086913c2c0..e95900be22b 100644 --- a/ui/.build/src/esbuild.ts +++ b/ui/.build/src/esbuild.ts @@ -1,10 +1,11 @@ import es from 'esbuild'; import fs from 'node:fs'; import { join, basename } from 'node:path'; + +import { definedMap } from './algo.ts'; import { env, errorMark, warnMark, c } from './env.ts'; import { type Manifest, updateManifest } from './manifest.ts'; import { makeTask, stopTask } from './task.ts'; -import { definedMap } from './algo.ts'; let esbuildCtx: es.BuildContext | undefined; diff --git a/ui/.build/src/hash.ts b/ui/.build/src/hash.ts index b552f40a1d7..997c18e2f4e 100644 --- a/ui/.build/src/hash.ts +++ b/ui/.build/src/hash.ts @@ -1,11 +1,12 @@ -import fs from 'node:fs'; import crypto from 'node:crypto'; +import fs from 'node:fs'; import { relative, join, resolve } from 'node:path'; -import { makeTask } from './task.ts'; -import { type Manifest, updateManifest } from './manifest.ts'; -import { env, c } from './env.ts'; -import { type Package, isClose } from './parse.ts'; + import { isEquivalent } from './algo.ts'; +import { env, c } from './env.ts'; +import { type Manifest, updateManifest } from './manifest.ts'; +import { type Package, isClose } from './parse.ts'; +import { makeTask } from './task.ts'; export async function hash(): Promise { if (!env.begin('hash')) return; diff --git a/ui/.build/src/i18n.ts b/ui/.build/src/i18n.ts index 20c386abd4e..d3ba2bdaa7e 100644 --- a/ui/.build/src/i18n.ts +++ b/ui/.build/src/i18n.ts @@ -1,14 +1,15 @@ +import { transform } from 'esbuild'; +import fg from 'fast-glob'; +import { XMLParser } from 'fast-xml-parser'; import crypto from 'node:crypto'; import fs from 'node:fs'; -import fg from 'fast-glob'; import { join, basename } from 'node:path'; -import { XMLParser } from 'fast-xml-parser'; + +import { zip } from './algo.ts'; import { env } from './env.ts'; +import { type Manifest, updateManifest } from './manifest.ts'; import { readable, isClose } from './parse.ts'; import { makeTask } from './task.ts'; -import { type Manifest, updateManifest } from './manifest.ts'; -import { zip } from './algo.ts'; -import { transform } from 'esbuild'; type PluralMode = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'; type Plural = Record; diff --git a/ui/.build/src/main.ts b/ui/.build/src/main.ts index ccc7cc190b2..eaf39fdf2ee 100644 --- a/ui/.build/src/main.ts +++ b/ui/.build/src/main.ts @@ -1,6 +1,7 @@ import ps from 'node:process'; -import { deepClean, clean } from './clean.ts'; + import { build, stopBuild } from './build.ts'; +import { deepClean, clean } from './clean.ts'; import { startConsole } from './console.ts'; import { env, errorMark } from './env.ts'; import { tasksIdle } from './task.ts'; diff --git a/ui/.build/src/manifest.ts b/ui/.build/src/manifest.ts index f597481a36d..315d8b2854e 100644 --- a/ui/.build/src/manifest.ts +++ b/ui/.build/src/manifest.ts @@ -1,11 +1,12 @@ import cps from 'node:child_process'; -import fs from 'node:fs'; import crypto from 'node:crypto'; +import fs from 'node:fs'; import { join } from 'node:path'; -import { env, c } from './env.ts'; -import { jsLogger } from './console.ts'; -import { taskOk } from './task.ts'; + import { shallowSort, isContained } from './algo.ts'; +import { jsLogger } from './console.ts'; +import { env, c } from './env.ts'; +import { taskOk } from './task.ts'; const manifest = { i18n: {} as Manifest, diff --git a/ui/.build/src/parse.ts b/ui/.build/src/parse.ts index fa32407a0e8..4d50c29ae3d 100644 --- a/ui/.build/src/parse.ts +++ b/ui/.build/src/parse.ts @@ -1,6 +1,7 @@ +import fg from 'fast-glob'; import fs from 'node:fs'; import { dirname, join, basename } from 'node:path'; -import fg from 'fast-glob'; + import { env } from './env.ts'; export interface Package { diff --git a/ui/.build/src/sass.ts b/ui/.build/src/sass.ts index 916f3f8da1e..a19d09013f1 100644 --- a/ui/.build/src/sass.ts +++ b/ui/.build/src/sass.ts @@ -4,6 +4,7 @@ import fs from 'node:fs'; import { basename, dirname, join, relative, resolve } from 'node:path'; import ps from 'node:process'; import clr from 'tinycolor2'; + import { clamp, isEquivalent } from './algo.ts'; import { c, env, errorMark, trimLines } from './env.ts'; import { hashedBasename, symlinkTargetHashes } from './hash.ts'; diff --git a/ui/.build/src/sync.ts b/ui/.build/src/sync.ts index 9430950b050..c37cd27bbdd 100644 --- a/ui/.build/src/sync.ts +++ b/ui/.build/src/sync.ts @@ -1,9 +1,10 @@ import fs from 'node:fs'; import { join, dirname } from 'node:path'; -import { makeTask } from './task.ts'; + +import { isEquivalent } from './algo.ts'; import { env, c } from './env.ts'; import { isGlob, isFolder, isClose } from './parse.ts'; -import { isEquivalent } from './algo.ts'; +import { makeTask } from './task.ts'; export async function sync(): Promise { if (!env.begin('sync')) return; diff --git a/ui/.build/src/task.ts b/ui/.build/src/task.ts index 3570e9102ed..9f8af57098e 100644 --- a/ui/.build/src/task.ts +++ b/ui/.build/src/task.ts @@ -2,9 +2,10 @@ import fg from 'fast-glob'; import mm from 'micromatch'; import fs from 'node:fs'; import { join, relative, basename } from 'node:path'; -import { type Package, glob, isFolder, subfolders, isClose } from './parse.ts'; + import { randomToken, definedUnique } from './algo.ts'; import { type Context, env, c, errorMark } from './env.ts'; +import { type Package, glob, isFolder, subfolders, isClose } from './parse.ts'; const fsWatches = new Map(); const tasks = new Map(); diff --git a/ui/.build/src/tsc.ts b/ui/.build/src/tsc.ts index f81749e41c4..7b5bc62cb43 100644 --- a/ui/.build/src/tsc.ts +++ b/ui/.build/src/tsc.ts @@ -1,12 +1,13 @@ +import fg from 'fast-glob'; import fs from 'node:fs'; import os from 'node:os'; import { join, resolve, dirname, basename, relative } from 'node:path'; -import ts from 'typescript'; -import fg from 'fast-glob'; import { Worker } from 'node:worker_threads'; +import ts from 'typescript'; + +import { clamp } from './algo.ts'; import { env, c, errorMark } from './env.ts'; import { folderSize } from './parse.ts'; -import { clamp } from './algo.ts'; import type { WorkerData, Message, ErrorMessage } from './tscWorker.ts'; const workers: Worker[] = []; diff --git a/ui/.build/src/tscWorker.ts b/ui/.build/src/tscWorker.ts index 189fb746f00..bf7659d05b5 100644 --- a/ui/.build/src/tscWorker.ts +++ b/ui/.build/src/tscWorker.ts @@ -1,5 +1,5 @@ -import { parentPort, workerData } from 'worker_threads'; import ts from 'typescript'; +import { parentPort, workerData } from 'worker_threads'; export interface WorkerData { projects: string[]; diff --git a/ui/.test/runner.mjs b/ui/.test/runner.mjs index 9112033b427..dd0ee08bdf7 100755 --- a/ui/.test/runner.mjs +++ b/ui/.test/runner.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env node -import { readdirSync } from 'node:fs'; import { spawn } from 'node:child_process'; -import { fileURLToPath } from 'node:url'; +import { readdirSync } from 'node:fs'; import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; process.chdir(dirname(dirname(fileURLToPath(import.meta.url)))); diff --git a/ui/analyse/src/analyse.gifDialog.ts b/ui/analyse/src/analyse.gifDialog.ts index 77fe10a166d..cb0e6fe434d 100644 --- a/ui/analyse/src/analyse.gifDialog.ts +++ b/ui/analyse/src/analyse.gifDialog.ts @@ -1,10 +1,12 @@ -import { storedBooleanProp } from 'lib/storage'; -import { url as xhrUrl } from 'lib/xhr'; -import * as licon from 'lib/licon'; -import type AnalyseCtrl from './ctrl'; -import { domDialog, type Dialog } from 'lib/view'; import { opposite } from 'chessops'; +import * as licon from 'lib/licon'; +import { storedBooleanProp } from 'lib/storage'; +import { domDialog, type Dialog } from 'lib/view'; +import { url as xhrUrl } from 'lib/xhr'; + +import type AnalyseCtrl from './ctrl'; + export function initModule(ctrl: AnalyseCtrl): void { let gifOrientation: Color = ctrl.bottomColor(); diff --git a/ui/analyse/src/analyse.nvui.ts b/ui/analyse/src/analyse.nvui.ts index 0165180b84b..f07c6ce124a 100644 --- a/ui/analyse/src/analyse.nvui.ts +++ b/ui/analyse/src/analyse.nvui.ts @@ -1,9 +1,10 @@ +import { type Prop, prop } from 'lib'; +import { type NvuiContext, makeContext } from 'lib/nvui/chess'; + import type AnalyseCtrl from './ctrl'; import type { NvuiPlugin } from './interfaces'; -import { type NvuiContext, makeContext } from 'lib/nvui/chess'; import type * as studyDeps from './study/studyDeps'; import { renderNvui, initNvui } from './view/nvuiView'; -import { type Prop, prop } from 'lib'; export type AnalyseNvuiContext = NvuiContext & Readonly<{ diff --git a/ui/analyse/src/analyse.user.ts b/ui/analyse/src/analyse.user.ts index b2a62fa8abc..ac9e368f41d 100644 --- a/ui/analyse/src/analyse.user.ts +++ b/ui/analyse/src/analyse.user.ts @@ -1,7 +1,8 @@ -import { patch } from './view/util'; +import { wsConnect } from 'lib/socket'; + import makeBoot from './boot'; import makeStart from './start'; -import { wsConnect } from 'lib/socket'; +import { patch } from './view/util'; export { patch }; diff --git a/ui/analyse/src/api.ts b/ui/analyse/src/api.ts index 08091817ed7..f8f0c7e69c0 100644 --- a/ui/analyse/src/api.ts +++ b/ui/analyse/src/api.ts @@ -1,5 +1,5 @@ -import AnalyseCtrl from './ctrl'; import * as control from './control'; +import AnalyseCtrl from './ctrl'; export default function (ctrl: AnalyseCtrl) { return { diff --git a/ui/analyse/src/autoShape.ts b/ui/analyse/src/autoShape.ts index 33ed5ba2e43..8e5132c968b 100644 --- a/ui/analyse/src/autoShape.ts +++ b/ui/analyse/src/autoShape.ts @@ -1,14 +1,16 @@ -import { parseUci, makeSquare } from 'chessops/util'; -import { isDrop, type Square } from 'chessops/types'; -import { winningChances } from 'lib/ceval'; -import { opposite } from '@lichess-org/chessground/util'; import type { DrawModifiers, DrawShape } from '@lichess-org/chessground/draw'; -import { annotationShapes, analysisGlyphs } from 'lib/game/glyphs'; -import type AnalyseCtrl from './ctrl'; -import { isUci } from 'lib/game/chess'; -import { parseFen } from 'chessops/fen'; -import type { ServerEval } from 'lib/tree/types'; +import { opposite } from '@lichess-org/chessground/util'; import { between, ray, knightAttacks } from 'chessops/attacks'; +import { parseFen } from 'chessops/fen'; +import { isDrop, type Square } from 'chessops/types'; +import { parseUci, makeSquare } from 'chessops/util'; + +import { winningChances } from 'lib/ceval'; +import { isUci } from 'lib/game/chess'; +import { annotationShapes, analysisGlyphs } from 'lib/game/glyphs'; +import type { ServerEval } from 'lib/tree/types'; + +import type AnalyseCtrl from './ctrl'; const pieceDrop = (key: Key, role: Role, color: Color): DrawShape => ({ orig: key, diff --git a/ui/analyse/src/autoplay.ts b/ui/analyse/src/autoplay.ts index 87df72e08bf..01297e2a5e1 100644 --- a/ui/analyse/src/autoplay.ts +++ b/ui/analyse/src/autoplay.ts @@ -1,4 +1,5 @@ import type { TreeNode } from 'lib/tree/types'; + import type AnalyseCtrl from './ctrl'; export type AutoplayDelay = number | 'realtime' | 'cpl'; diff --git a/ui/analyse/src/boot.ts b/ui/analyse/src/boot.ts index e902e03d6e0..c371092d23c 100644 --- a/ui/analyse/src/boot.ts +++ b/ui/analyse/src/boot.ts @@ -1,5 +1,6 @@ -import type { AnalyseApi, AnalyseOpts } from './interfaces'; import { wsConnect } from 'lib/socket'; + +import type { AnalyseApi, AnalyseOpts } from './interfaces'; import type { AnalyseSocketSend } from './socket'; export default function (start: (opts: AnalyseOpts) => AnalyseApi) { diff --git a/ui/analyse/src/control.ts b/ui/analyse/src/control.ts index 4507e68690f..6c2713c9ae0 100644 --- a/ui/analyse/src/control.ts +++ b/ui/analyse/src/control.ts @@ -1,7 +1,7 @@ -import type { TreeNode } from 'lib/tree/types'; -import type AnalyseCtrl from './ctrl'; - import { path as treePath } from 'lib/tree/tree'; +import type { TreeNode } from 'lib/tree/types'; + +import type AnalyseCtrl from './ctrl'; export function next(ctrl: AnalyseCtrl): void { if (ctrl.retro?.preventGoingToNextMove()) return; diff --git a/ui/analyse/src/crazy/crazyCtrl.ts b/ui/analyse/src/crazy/crazyCtrl.ts index c6838046d0e..f0bdd0d31df 100644 --- a/ui/analyse/src/crazy/crazyCtrl.ts +++ b/ui/analyse/src/crazy/crazyCtrl.ts @@ -1,7 +1,8 @@ import { dragNewPiece } from '@lichess-org/chessground/drag'; -import type AnalyseCtrl from '../ctrl'; import type { MouchEvent } from '@lichess-org/chessground/types'; +import type AnalyseCtrl from '../ctrl'; + export function drag(ctrl: AnalyseCtrl, color: Color, e: MouchEvent): void { if (e.button !== undefined && e.button !== 0) return; // only touch or left click if (ctrl.chessground.state.movable.color !== color) return; diff --git a/ui/analyse/src/crazy/crazyView.ts b/ui/analyse/src/crazy/crazyView.ts index 191628b9d2a..0b7270360c3 100644 --- a/ui/analyse/src/crazy/crazyView.ts +++ b/ui/analyse/src/crazy/crazyView.ts @@ -1,7 +1,9 @@ -import { drag } from './crazyCtrl'; import { h } from 'snabbdom'; + import { onInsert } from 'lib/view'; + import type AnalyseCtrl from '../ctrl'; +import { drag } from './crazyCtrl'; const eventNames = ['mousedown', 'touchstart'] as const; const oKeys = ['pawn', 'knight', 'bishop', 'rook', 'queen'] as const; diff --git a/ui/analyse/src/ctrl.ts b/ui/analyse/src/ctrl.ts index b953e7e7afc..963231f05dd 100644 --- a/ui/analyse/src/ctrl.ts +++ b/ui/analyse/src/ctrl.ts @@ -1,24 +1,16 @@ -import { playable, playedTurns, fenToEpd, validUci } from 'lib/game'; -import * as keyboard from './keyboard'; -import { treeReconstruct, addCrazyData } from './util'; -import { plural } from './view/util'; -import type GamebookPlayCtrl from './study/gamebook/gamebookPlayCtrl'; -import type StudyCtrl from './study/studyCtrl'; -import type { AnalyseOpts, AnalyseData, ServerEvalData, JustCaptured, NvuiPlugin } from './interfaces'; +import { Result } from '@badrap/result'; import type { Api as ChessgroundApi } from '@lichess-org/chessground/api'; -import { Autoplay, type AutoplayDelay } from './autoplay'; -import { makeTree, treePath, treeOps, type TreeWrapper } from 'lib/tree'; -import { compute as computeAutoShapes } from './autoShape'; import type { Config as ChessgroundConfig } from '@lichess-org/chessground/config'; -import { - CevalCtrl, - isEvalBetter, - sanIrreversible, - type CevalHandler, - type EvalMeta, - type CevalOpts, -} from 'lib/ceval'; -import { TreeView } from './treeView/treeView'; +import type { DrawShape } from '@lichess-org/chessground/draw'; +import { uciToMove } from '@lichess-org/chessground/util'; +import { makeFen } from 'chessops/fen'; +import type { PgnError } from 'chessops/pgn'; +import { makeSanAndPlay } from 'chessops/san'; +import { isNormal, type Move } from 'chessops/types'; +import { opposite, parseUci, makeSquare, roleToChar, makeUci, parseSquare } from 'chessops/util'; +import { normalizeMove } from 'chessops/variant'; +import { type ArrowKey, type KeyboardMove, ctrl as makeKeyboardMove } from 'keyboardMove'; + import { defined, prop, @@ -30,40 +22,50 @@ import { type Prop, type Toggle, } from 'lib'; +import { + CevalCtrl, + isEvalBetter, + sanIrreversible, + type CevalHandler, + type EvalMeta, + type CevalOpts, +} from 'lib/ceval'; +import { ChatCtrl } from 'lib/chat/chatCtrl'; +import { displayColumns } from 'lib/device'; +import { playable, playedTurns, fenToEpd, validUci } from 'lib/game'; +import { PromotionCtrl } from 'lib/game/promotion'; import { pubsub } from 'lib/pubsub'; -import type { DrawShape } from '@lichess-org/chessground/draw'; +import { storedBooleanProp, storedBooleanPropWithEffect } from 'lib/storage'; +import { makeTree, treePath, treeOps, type TreeWrapper } from 'lib/tree'; +import { completeNode } from 'lib/tree/node'; +import type { ClientEval, LocalEval, ServerEval, TreeNode, TreePath } from 'lib/tree/types'; +import { confirm } from 'lib/view'; + +import api from './api'; +import { Autoplay, type AutoplayDelay } from './autoplay'; +import { compute as computeAutoShapes } from './autoShape'; +import * as control from './control'; +import { valid as crazyValid } from './crazy/crazyCtrl'; import EvalCache from './evalCache'; +import ExplorerCtrl from './explorer/explorerCtrl'; +import ForecastCtrl from './forecast/forecastCtrl'; import { ForkCtrl } from './fork'; +import { IdbTree } from './idbTree'; +import type { AnalyseOpts, AnalyseData, ServerEvalData, JustCaptured, NvuiPlugin } from './interfaces'; +import * as keyboard from './keyboard'; +import MotifCtrl from './motif/motifCtrl'; +import { nextGlyphSymbol, add3or5FoldGlyphs } from './nodeFinder'; +import pgnImport from './pgnImport'; import { make as makePractice, type PracticeCtrl } from './practice/practiceCtrl'; import { make as makeRetro, type RetroCtrl } from './retrospect/retroCtrl'; import { make as makeSocket, type Socket } from './socket'; -import { nextGlyphSymbol, add3or5FoldGlyphs } from './nodeFinder'; -import { opposite, parseUci, makeSquare, roleToChar, makeUci, parseSquare } from 'chessops/util'; -import { isNormal, type Move } from 'chessops/types'; -import { makeFen } from 'chessops/fen'; -import { normalizeMove } from 'chessops/variant'; -import { storedBooleanProp, storedBooleanPropWithEffect } from 'lib/storage'; +import type GamebookPlayCtrl from './study/gamebook/gamebookPlayCtrl'; import type { AnaMove } from './study/interfaces'; -import { valid as crazyValid } from './crazy/crazyCtrl'; -import { PromotionCtrl } from 'lib/game/promotion'; +import type StudyCtrl from './study/studyCtrl'; +import { TreeView } from './treeView/treeView'; +import { treeReconstruct, addCrazyData } from './util'; +import { plural } from './view/util'; import wikiTheory, { wikiClear, type WikiTheory } from './wiki'; -import ExplorerCtrl from './explorer/explorerCtrl'; -import { uciToMove } from '@lichess-org/chessground/util'; -import { IdbTree } from './idbTree'; -import pgnImport from './pgnImport'; -import ForecastCtrl from './forecast/forecastCtrl'; -import { type ArrowKey, type KeyboardMove, ctrl as makeKeyboardMove } from 'keyboardMove'; -import * as control from './control'; -import type { PgnError } from 'chessops/pgn'; -import { ChatCtrl } from 'lib/chat/chatCtrl'; -import { confirm } from 'lib/view'; -import api from './api'; -import { displayColumns } from 'lib/device'; -import MotifCtrl from './motif/motifCtrl'; -import { makeSanAndPlay } from 'chessops/san'; -import type { ClientEval, LocalEval, ServerEval, TreeNode, TreePath } from 'lib/tree/types'; -import { completeNode } from 'lib/tree/node'; -import { Result } from '@badrap/result'; export default class AnalyseCtrl implements CevalHandler { data: AnalyseData; diff --git a/ui/analyse/src/evalCache.ts b/ui/analyse/src/evalCache.ts index 1ffb832357c..5b16655b751 100644 --- a/ui/analyse/src/evalCache.ts +++ b/ui/analyse/src/evalCache.ts @@ -1,10 +1,11 @@ import { defined, prop } from 'lib'; import { throttle } from 'lib/async'; -import type { EvalHit, EvalGetData, EvalPutData } from './interfaces'; -import type { AnalyseSocketSend } from './socket'; import { pubsub } from 'lib/pubsub'; import type { ClientEval, PvData, ServerEval, TreeNode, TreePath } from 'lib/tree/types'; +import type { EvalHit, EvalGetData, EvalPutData } from './interfaces'; +import type { AnalyseSocketSend } from './socket'; + export interface EvalCacheOpts { variant: VariantKey; receive(ev: ClientEval, path: TreePath): void; diff --git a/ui/analyse/src/explorer/explorerConfig.ts b/ui/analyse/src/explorer/explorerConfig.ts index 146650b2cb0..bee5cf7aed5 100644 --- a/ui/analyse/src/explorer/explorerConfig.ts +++ b/ui/analyse/src/explorer/explorerConfig.ts @@ -1,15 +1,17 @@ -import { h, type VNode } from 'snabbdom'; -import { myUsername, type Prop, prop } from 'lib'; -import * as licon from 'lib/licon'; -import { type Dialog, snabDialog, bind, dataIcon, iconTag, onInsert } from 'lib/view'; -import { storedProp, storedJsonProp, type StoredProp, storedStringProp } from 'lib/storage'; -import type { ExplorerDb, ExplorerSpeed, ExplorerMode } from './interfaces'; -import AnalyseCtrl from '../ctrl'; -import perfIcons from 'lib/game/perfIcons'; -import { ucfirst } from './explorerUtil'; import { opposite } from '@lichess-org/chessground/util'; +import { h, type VNode } from 'snabbdom'; + +import { myUsername, type Prop, prop } from 'lib'; +import perfIcons from 'lib/game/perfIcons'; +import * as licon from 'lib/licon'; +import { storedProp, storedJsonProp, type StoredProp, storedStringProp } from 'lib/storage'; +import { type Dialog, snabDialog, bind, dataIcon, iconTag, onInsert } from 'lib/view'; import { userComplete } from 'lib/view/userComplete'; +import AnalyseCtrl from '../ctrl'; +import { ucfirst } from './explorerUtil'; +import type { ExplorerDb, ExplorerSpeed, ExplorerMode } from './interfaces'; + const allSpeeds: ExplorerSpeed[] = ['ultraBullet', 'bullet', 'blitz', 'rapid', 'classical', 'correspondence']; const allModes: ExplorerMode[] = ['casual', 'rated']; const allRatings = [400, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2500]; diff --git a/ui/analyse/src/explorer/explorerCtrl.ts b/ui/analyse/src/explorer/explorerCtrl.ts index 901b282250a..c9ff51a3c2e 100644 --- a/ui/analyse/src/explorer/explorerCtrl.ts +++ b/ui/analyse/src/explorer/explorerCtrl.ts @@ -1,15 +1,17 @@ -import { type Prop, prop, defined, myUserId } from 'lib'; -import { storedBooleanProp } from 'lib/storage'; -import { pieceCount, fenColor } from 'lib/game/chess'; -import { debounce, defer, sync, type Sync } from 'lib/async'; import { opposite } from '@lichess-org/chessground/util'; -import * as xhr from './explorerXhr'; -import { winnerOf } from './explorerUtil'; + +import { type Prop, prop, defined, myUserId } from 'lib'; +import { debounce, defer, sync, type Sync } from 'lib/async'; import { replayable } from 'lib/game'; +import { pieceCount, fenColor } from 'lib/game/chess'; +import { storedBooleanProp } from 'lib/storage'; + import type AnalyseCtrl from '../ctrl'; -import type { Hovering, ExplorerData, OpeningData, SimpleTablebaseHit, ExplorerOpts } from './interfaces'; import { ExplorerConfigCtrl } from './explorerConfig'; +import { winnerOf } from './explorerUtil'; import { clearLastShow } from './explorerView'; +import * as xhr from './explorerXhr'; +import type { Hovering, ExplorerData, OpeningData, SimpleTablebaseHit, ExplorerOpts } from './interfaces'; export const MAX_DEPTH = 50; diff --git a/ui/analyse/src/explorer/explorerUtil.ts b/ui/analyse/src/explorer/explorerUtil.ts index cb9aa48a463..ed4a7177675 100644 --- a/ui/analyse/src/explorer/explorerUtil.ts +++ b/ui/analyse/src/explorer/explorerUtil.ts @@ -1,8 +1,10 @@ -import type { TablebaseMoveStats } from './interfaces'; import { opposite } from 'chessops/util'; -import { fenColor } from 'lib/game/chess'; import type { VNode } from 'snabbdom'; + +import { fenColor } from 'lib/game/chess'; + import type AnalyseCtrl from '../ctrl'; +import type { TablebaseMoveStats } from './interfaces'; export function winnerOf(fen: FEN, move: TablebaseMoveStats): Color | undefined { const stm = fenColor(fen); diff --git a/ui/analyse/src/explorer/explorerView.ts b/ui/analyse/src/explorer/explorerView.ts index 5a0fb7749e0..bca5291d299 100644 --- a/ui/analyse/src/explorer/explorerView.ts +++ b/ui/analyse/src/explorer/explorerView.ts @@ -1,11 +1,14 @@ import type { VNode } from 'snabbdom'; -import * as licon from 'lib/licon'; -import { displayLocale, numberFormat } from 'lib/i18n'; + import perfIcons from 'lib/game/perfIcons'; +import { displayLocale, numberFormat } from 'lib/i18n'; +import * as licon from 'lib/licon'; import { bind, dataIcon, type MaybeVNode, type LooseVNodes, hl } from 'lib/view'; -import { view as renderConfig } from './explorerConfig'; -import { moveArrowAttributes, ucfirst } from './explorerUtil'; + import type AnalyseCtrl from '../ctrl'; +import { view as renderConfig } from './explorerConfig'; +import ExplorerCtrl, { MAX_DEPTH } from './explorerCtrl'; +import { moveArrowAttributes, ucfirst } from './explorerUtil'; import { isOpening, isTablebase, @@ -15,7 +18,6 @@ import { type OpeningGame, type ExplorerDb, } from './interfaces'; -import ExplorerCtrl, { MAX_DEPTH } from './explorerCtrl'; import { showTablebase } from './tablebaseView'; function resultBar(move: OpeningMoveStats): VNode { diff --git a/ui/analyse/src/explorer/explorerXhr.ts b/ui/analyse/src/explorer/explorerXhr.ts index 895ad69afe4..494f9a123af 100644 --- a/ui/analyse/src/explorer/explorerXhr.ts +++ b/ui/analyse/src/explorer/explorerXhr.ts @@ -1,7 +1,8 @@ -import type { ExplorerDb, OpeningData, TablebaseData } from './interfaces'; import * as xhr from 'lib/xhr'; import { readNdJson } from 'lib/xhr'; + import type { ExplorerConfigData } from './explorerConfig'; +import type { ExplorerDb, OpeningData, TablebaseData } from './interfaces'; interface OpeningXhrOpts { endpoint: string; diff --git a/ui/analyse/src/explorer/tablebaseView.ts b/ui/analyse/src/explorer/tablebaseView.ts index 24f53d57058..708a1925050 100644 --- a/ui/analyse/src/explorer/tablebaseView.ts +++ b/ui/analyse/src/explorer/tablebaseView.ts @@ -1,4 +1,5 @@ import { h, type VNode } from 'snabbdom'; + import type AnalyseCtrl from '../ctrl'; import { moveArrowAttributes, winnerOf } from './explorerUtil'; import type { TablebaseMoveStats } from './interfaces'; diff --git a/ui/analyse/src/forecast/forecastCtrl.ts b/ui/analyse/src/forecast/forecastCtrl.ts index a7145f6aafa..f5640715a6b 100644 --- a/ui/analyse/src/forecast/forecastCtrl.ts +++ b/ui/analyse/src/forecast/forecastCtrl.ts @@ -1,10 +1,11 @@ import { prop, notEmpty, type Prop } from 'lib'; -import { json as xhrJson } from 'lib/xhr'; -import type { ForecastData, ForecastList, ForecastStep } from './interfaces'; -import type { AnalyseData } from '../interfaces'; -import type { TreeWrapper } from 'lib/tree/tree'; import { completeNode } from 'lib/tree/node'; +import type { TreeWrapper } from 'lib/tree/tree'; import type { TreePath } from 'lib/tree/types'; +import { json as xhrJson } from 'lib/xhr'; + +import type { AnalyseData } from '../interfaces'; +import type { ForecastData, ForecastList, ForecastStep } from './interfaces'; export default class ForecastCtrl { forecasts: Prop = prop([]); diff --git a/ui/analyse/src/forecast/forecastView.ts b/ui/analyse/src/forecast/forecastView.ts index 1c95027c551..1aa5fea6f41 100644 --- a/ui/analyse/src/forecast/forecastView.ts +++ b/ui/analyse/src/forecast/forecastView.ts @@ -1,12 +1,14 @@ import { h, type VNode } from 'snabbdom'; + +import { playable } from 'lib/game'; +import { fixCrazySan } from 'lib/game/chess'; import * as licon from 'lib/licon'; import { bind, dataIcon, spinnerVdom as spinner } from 'lib/view'; -import type { ForecastStep } from './interfaces'; + import type AnalyseCtrl from '../ctrl'; import { renderNodesHtml } from '../pgnExport'; -import { fixCrazySan } from 'lib/game/chess'; import type ForecastCtrl from './forecastCtrl'; -import { playable } from 'lib/game'; +import type { ForecastStep } from './interfaces'; function onMyTurn(fctrl: ForecastCtrl, cNodes: ForecastStep[]): VNode | undefined { const firstNode = cNodes[0]; diff --git a/ui/analyse/src/fork.ts b/ui/analyse/src/fork.ts index 5d966b1a002..c4964dd71e6 100644 --- a/ui/analyse/src/fork.ts +++ b/ui/analyse/src/fork.ts @@ -1,11 +1,12 @@ import { defined } from 'lib'; -import { onInsert, hl } from 'lib/view'; -import type AnalyseCtrl from './ctrl'; -import type { ConcealOf } from './interfaces'; -import { renderIndexAndMove } from './view/components'; import { isTouchDevice } from 'lib/device'; import { addPointerListeners } from 'lib/pointer'; import type { TreeNode } from 'lib/tree/types'; +import { onInsert, hl } from 'lib/view'; + +import type AnalyseCtrl from './ctrl'; +import type { ConcealOf } from './interfaces'; +import { renderIndexAndMove } from './view/components'; export class ForkCtrl { selectedIndex = 0; diff --git a/ui/analyse/src/ground.ts b/ui/analyse/src/ground.ts index 83fdf34425f..4e35f5a58ad 100644 --- a/ui/analyse/src/ground.ts +++ b/ui/analyse/src/ground.ts @@ -1,10 +1,12 @@ -import { h, type VNode } from 'snabbdom'; -import type { Elements } from '@lichess-org/chessground/types'; -import resizeHandle from 'lib/chessgroundResize'; -import { storage } from 'lib/storage'; -import type AnalyseCtrl from './ctrl'; -import * as Prefs from 'lib/prefs'; import { Chessground as makeChessground } from '@lichess-org/chessground'; +import type { Elements } from '@lichess-org/chessground/types'; +import { h, type VNode } from 'snabbdom'; + +import resizeHandle from 'lib/chessgroundResize'; +import * as Prefs from 'lib/prefs'; +import { storage } from 'lib/storage'; + +import type AnalyseCtrl from './ctrl'; export const render = (ctrl: AnalyseCtrl): VNode => h('div.cg-wrap.cgv' + ctrl.cgVersion.js, { diff --git a/ui/analyse/src/idbTree.ts b/ui/analyse/src/idbTree.ts index 39c0774d284..9c673093024 100644 --- a/ui/analyse/src/idbTree.ts +++ b/ui/analyse/src/idbTree.ts @@ -1,8 +1,9 @@ -import type { TreeNode, TreeNodeIncomplete, TreePath } from 'lib/tree/types'; -import type AnalyseCtrl from './ctrl'; import { objectStorage, type ObjectStorage } from 'lib/objectStorage'; -import * as treeOps from 'lib/tree/ops'; import { completeNode } from 'lib/tree/node'; +import * as treeOps from 'lib/tree/ops'; +import type { TreeNode, TreeNodeIncomplete, TreePath } from 'lib/tree/types'; + +import type AnalyseCtrl from './ctrl'; export type DiscloseState = undefined | 'expanded' | 'collapsed'; diff --git a/ui/analyse/src/interfaces.ts b/ui/analyse/src/interfaces.ts index eeabcfad3b9..29dc401034b 100644 --- a/ui/analyse/src/interfaces.ts +++ b/ui/analyse/src/interfaces.ts @@ -1,19 +1,20 @@ import type { VNode } from 'snabbdom'; -import type { Player, Status, Source, Clock } from 'lib/game'; -import type { ForecastData } from './forecast/interfaces'; -import type { StudyPracticeData, Goal as PracticeGoal } from './study/practice/interfaces'; -import type { RelayData } from './study/relay/interfaces'; -import type { ChatCtrl, ChatPlugin, ChatOpts } from 'lib/chat/interfaces'; -import type { ExplorerOpts } from './explorer/interfaces'; -import type { StudyDataFromServer } from './study/interfaces'; -import type { AnalyseSocketSend } from './socket'; + import type { ExternalEngineInfo } from 'lib/ceval'; +import type { ChatCtrl, ChatPlugin, ChatOpts } from 'lib/chat/interfaces'; +import type { Player, Status, Source, Clock } from 'lib/game'; import type { Coords, MoveEvent } from 'lib/prefs'; import type { EnhanceOpts } from 'lib/richText'; - -import type * as studyDeps from './study/studyDeps'; import type { PvDataServer, ServerEval, TreeNode, TreeNodeIncomplete, TreePath } from 'lib/tree/types'; +import type { ExplorerOpts } from './explorer/interfaces'; +import type { ForecastData } from './forecast/interfaces'; +import type { AnalyseSocketSend } from './socket'; +import type { StudyDataFromServer } from './study/interfaces'; +import type { StudyPracticeData, Goal as PracticeGoal } from './study/practice/interfaces'; +import type { RelayData } from './study/relay/interfaces'; +import type * as studyDeps from './study/studyDeps'; + export interface NvuiPlugin { render(deps?: typeof studyDeps): VNode; } diff --git a/ui/analyse/src/keyboard.ts b/ui/analyse/src/keyboard.ts index d220d7f940d..a9e41b93d05 100644 --- a/ui/analyse/src/keyboard.ts +++ b/ui/analyse/src/keyboard.ts @@ -1,9 +1,11 @@ +import type { VNode } from 'snabbdom'; + +import { pubsub } from 'lib/pubsub'; +import { snabDialog } from 'lib/view'; +import * as xhr from 'lib/xhr'; + import * as control from './control'; import type AnalyseCtrl from './ctrl'; -import * as xhr from 'lib/xhr'; -import { snabDialog } from 'lib/view'; -import type { VNode } from 'snabbdom'; -import { pubsub } from 'lib/pubsub'; export const keyToMouseEvent = (key: string, eventName: string, selector: string) => window.site.mousetrap.bind(key, () => diff --git a/ui/analyse/src/motif/boardAnalysis.ts b/ui/analyse/src/motif/boardAnalysis.ts index 4cf0eccca5b..32b3a7ddac1 100644 --- a/ui/analyse/src/motif/boardAnalysis.ts +++ b/ui/analyse/src/motif/boardAnalysis.ts @@ -1,5 +1,3 @@ -import { parseSquare, opposite, squareRank, squareFile, squareFromCoords } from 'chessops/util'; -import { SquareSet } from 'chessops/squareSet'; import { attacks, ray, @@ -13,7 +11,10 @@ import { import { Board } from 'chessops/board'; import { Chess } from 'chessops/chess'; import { chessgroundDests } from 'chessops/compat'; +import { SquareSet } from 'chessops/squareSet'; import { type Role, type Color, type Piece, type NormalMove, COLORS, type Square } from 'chessops/types'; +import { parseSquare, opposite, squareRank, squareFile, squareFromCoords } from 'chessops/util'; + import type { Pin, Undefended, Checkable } from './interfaces'; export const boardAnalysisVariants = [ diff --git a/ui/analyse/src/motif/motifCtrl.ts b/ui/analyse/src/motif/motifCtrl.ts index a5b1f3e7f40..a85250f2458 100644 --- a/ui/analyse/src/motif/motifCtrl.ts +++ b/ui/analyse/src/motif/motifCtrl.ts @@ -1,8 +1,9 @@ -import type { Prop } from 'lib'; - -import { storedBooleanPropWithEffect } from 'lib/storage'; -import { boardAnalysisVariants, detectCheckable, detectPins, detectUndefended } from './boardAnalysis'; import type { Board, Square, SquareSet } from 'chessops'; + +import type { Prop } from 'lib'; +import { storedBooleanPropWithEffect } from 'lib/storage'; + +import { boardAnalysisVariants, detectCheckable, detectPins, detectUndefended } from './boardAnalysis'; import type { Checkable, Pin, Undefended } from './interfaces'; export default class MotifCtrl { diff --git a/ui/analyse/src/motif/motifView.ts b/ui/analyse/src/motif/motifView.ts index df5038648f6..c8cdad8ab96 100644 --- a/ui/analyse/src/motif/motifView.ts +++ b/ui/analyse/src/motif/motifView.ts @@ -1,8 +1,9 @@ -import type AnalyseCtrl from '@/ctrl'; import { displayColumns } from 'lib/device'; import { hl, type LooseVNodes } from 'lib/view'; import { cmnToggleWrap } from 'lib/view/cmn-toggle'; +import type AnalyseCtrl from '@/ctrl'; + export const config = (ctrl: AnalyseCtrl): LooseVNodes => [ displayColumns() > 1 && hl('h2', i18n.site.visualMotifs), cmnToggleWrap({ diff --git a/ui/analyse/src/nodeFinder.ts b/ui/analyse/src/nodeFinder.ts index 39c4baced34..f8deb65b3c7 100644 --- a/ui/analyse/src/nodeFinder.ts +++ b/ui/analyse/src/nodeFinder.ts @@ -1,7 +1,7 @@ -import { winningChances } from 'lib/ceval'; -import { fenToEpd } from 'lib/game/chess'; import { defined } from 'lib'; import { zip } from 'lib/algo'; +import { winningChances } from 'lib/ceval'; +import { fenToEpd } from 'lib/game/chess'; import type { TreeNode } from 'lib/tree/types'; const hasCompChild = (node: TreeNode): boolean => node.children.some(c => !!c.comp); diff --git a/ui/analyse/src/pgnExport.ts b/ui/analyse/src/pgnExport.ts index e93fb1c9d3a..78a2c90b7bd 100644 --- a/ui/analyse/src/pgnExport.ts +++ b/ui/analyse/src/pgnExport.ts @@ -1,10 +1,12 @@ -import type AnalyseCtrl from './ctrl'; -import { h } from 'snabbdom'; -import { fixCrazySan, plyToTurn } from 'lib/game/chess'; -import { type MaybeVNodes } from 'lib/view'; import { INITIAL_FEN } from 'chessops/fen'; -import type { Game } from './interfaces'; +import { h } from 'snabbdom'; + +import { fixCrazySan, plyToTurn } from 'lib/game/chess'; import type { TreeNode } from 'lib/tree/types'; +import { type MaybeVNodes } from 'lib/view'; + +import type AnalyseCtrl from './ctrl'; +import type { Game } from './interfaces'; interface PgnNode { ply: Ply; diff --git a/ui/analyse/src/pgnImport.ts b/ui/analyse/src/pgnImport.ts index 87ab5af52da..b3ea17215b2 100644 --- a/ui/analyse/src/pgnImport.ts +++ b/ui/analyse/src/pgnImport.ts @@ -1,12 +1,14 @@ -import type { AnalyseData, Game } from './interfaces'; -import { makeFen } from 'chessops/fen'; -import { makeSanAndPlay, parseSan } from 'chessops/san'; import { makeUci } from 'chessops'; -import { makeVariant, parsePgn, startingPosition, type ChildNode, type PgnNodeData } from 'chessops/pgn'; import { IllegalSetup, type Position } from 'chessops/chess'; +import { makeFen } from 'chessops/fen'; +import { makeVariant, parsePgn, startingPosition, type ChildNode, type PgnNodeData } from 'chessops/pgn'; +import { makeSanAndPlay, parseSan } from 'chessops/san'; + import type { Player } from 'lib/game'; -import type { TreeNode } from 'lib/tree/types'; import { completeNode } from 'lib/tree/node'; +import type { TreeNode } from 'lib/tree/types'; + +import type { AnalyseData, Game } from './interfaces'; const readNode = ( variant: VariantKey, diff --git a/ui/analyse/src/practice/practiceCtrl.ts b/ui/analyse/src/practice/practiceCtrl.ts index a849fe0de28..09a83d3c972 100644 --- a/ui/analyse/src/practice/practiceCtrl.ts +++ b/ui/analyse/src/practice/practiceCtrl.ts @@ -1,15 +1,17 @@ -import { winningChances, type CustomCeval } from 'lib/ceval'; -import { path as treePath } from 'lib/tree/tree'; -import { detectThreefold } from '../nodeFinder'; -import { tablebaseGuaranteed } from '../explorer/explorerCtrl'; -import type AnalyseCtrl from '../ctrl'; -import { defined, prop, type Prop, requestIdleCallback } from 'lib'; -import { parseUci } from 'chessops/util'; import { makeSan } from 'chessops/san'; +import { parseUci } from 'chessops/util'; + +import { defined, prop, type Prop, requestIdleCallback } from 'lib'; +import { winningChances, type CustomCeval } from 'lib/ceval'; import { storedBooleanPropWithEffect } from 'lib/storage'; -import { renderCustomPearl, renderCustomStatus } from './practiceView'; +import { path as treePath } from 'lib/tree/tree'; import type { TablebaseHit, TreeNode, TreePath } from 'lib/tree/types'; +import type AnalyseCtrl from '../ctrl'; +import { tablebaseGuaranteed } from '../explorer/explorerCtrl'; +import { detectThreefold } from '../nodeFinder'; +import { renderCustomPearl, renderCustomStatus } from './practiceView'; + declare type Verdict = 'goodMove' | 'inaccuracy' | 'mistake' | 'blunder'; export interface Comment { diff --git a/ui/analyse/src/practice/practiceView.ts b/ui/analyse/src/practice/practiceView.ts index a982018159d..dfa7a4fdd61 100644 --- a/ui/analyse/src/practice/practiceView.ts +++ b/ui/analyse/src/practice/practiceView.ts @@ -1,10 +1,12 @@ import type { Outcome } from 'chessops/types'; + +import type { Prop } from 'lib'; +import { fixCrazySan } from 'lib/game/chess'; import { hl, type VNode, bind, type MaybeVNodes } from 'lib/view'; -import type { PracticeCtrl, Comment } from './practiceCtrl'; + import type AnalyseCtrl from '../ctrl'; import { renderNextChapter } from '../study/nextChapter'; -import { fixCrazySan } from 'lib/game/chess'; -import type { Prop } from 'lib'; +import type { PracticeCtrl, Comment } from './practiceCtrl'; const commentBest = (c: Comment, ctrl: PracticeCtrl): MaybeVNodes => c.best diff --git a/ui/analyse/src/retrospect/nvuiRetroView.ts b/ui/analyse/src/retrospect/nvuiRetroView.ts index a9367b53eca..f07d346568c 100644 --- a/ui/analyse/src/retrospect/nvuiRetroView.ts +++ b/ui/analyse/src/retrospect/nvuiRetroView.ts @@ -1,10 +1,12 @@ -import type { AnalyseNvuiContext } from '../analyse.nvui'; -import { type LooseVNodes, hl } from 'lib/view'; import { type VNodeData } from 'snabbdom'; -import type AnalyseCtrl from '../ctrl'; -import type { RetroCtrl } from '../retrospect/retroCtrl'; + import { renderSan } from 'lib/nvui/chess'; import { liveText } from 'lib/nvui/notify'; +import { type LooseVNodes, hl } from 'lib/view'; + +import type { AnalyseNvuiContext } from '../analyse.nvui'; +import type AnalyseCtrl from '../ctrl'; +import type { RetroCtrl } from '../retrospect/retroCtrl'; import { clickHook, renderCurrentNode } from '../view/nvuiView'; export function renderRetro(nvuiCtx: AnalyseNvuiContext): LooseVNodes { diff --git a/ui/analyse/src/retrospect/retroCtrl.ts b/ui/analyse/src/retrospect/retroCtrl.ts index 1a0c7185a05..bdfb57e47c3 100644 --- a/ui/analyse/src/retrospect/retroCtrl.ts +++ b/ui/analyse/src/retrospect/retroCtrl.ts @@ -1,12 +1,14 @@ import { opposite } from '@lichess-org/chessground/util'; -import { evalSwings } from '../nodeFinder'; + +import { isEmpty, type Prop, prop } from 'lib'; import { winningChances } from 'lib/ceval'; import { path as treePath } from 'lib/tree/tree'; -import { isEmpty, type Prop, prop } from 'lib'; -import type { OpeningData } from '../explorer/interfaces'; -import type AnalyseCtrl from '../ctrl'; import type { TreeNode } from 'lib/tree/types'; +import type AnalyseCtrl from '../ctrl'; +import type { OpeningData } from '../explorer/interfaces'; +import { evalSwings } from '../nodeFinder'; + export interface RetroCtrl { isSolving(): boolean; current: Prop; diff --git a/ui/analyse/src/retrospect/retroView.ts b/ui/analyse/src/retrospect/retroView.ts index 76d6420050e..eb76aa868f3 100644 --- a/ui/analyse/src/retrospect/retroView.ts +++ b/ui/analyse/src/retrospect/retroView.ts @@ -1,9 +1,10 @@ +import * as licon from 'lib/licon'; +import type { TreeNode } from 'lib/tree/types'; +import { bind, dataIcon, hl, type VNode, spinnerVdom as spinner } from 'lib/view'; + +import type AnalyseCtrl from '../ctrl'; import { renderIndexAndMove } from '../view/components'; import type { RetroCtrl } from './retroCtrl'; -import type AnalyseCtrl from '../ctrl'; -import * as licon from 'lib/licon'; -import { bind, dataIcon, hl, type VNode, spinnerVdom as spinner } from 'lib/view'; -import type { TreeNode } from 'lib/tree/types'; const skipOrViewSolution = (ctrl: RetroCtrl): VNode => hl('div.choices', [ diff --git a/ui/analyse/src/serverSideUnderboard.ts b/ui/analyse/src/serverSideUnderboard.ts index 7af1dcc6ec3..3554b33c5d5 100644 --- a/ui/analyse/src/serverSideUnderboard.ts +++ b/ui/analyse/src/serverSideUnderboard.ts @@ -1,13 +1,15 @@ -import type AnalyseCtrl from './ctrl'; -import { baseUrl } from './view/util'; -import * as licon from 'lib/licon'; -import { url as xhrUrl, textRaw as xhrTextRaw } from 'lib/xhr'; -import type { AnalyseData } from './interfaces'; import type { ChartGame, AcplChart } from 'chart'; -import { spinnerHtml, domDialog, alert, confirm } from 'lib/view'; + import { escapeHtml } from 'lib'; -import { storage } from 'lib/storage'; +import * as licon from 'lib/licon'; import { pubsub } from 'lib/pubsub'; +import { storage } from 'lib/storage'; +import { spinnerHtml, domDialog, alert, confirm } from 'lib/view'; +import { url as xhrUrl, textRaw as xhrTextRaw } from 'lib/xhr'; + +import type AnalyseCtrl from './ctrl'; +import type { AnalyseData } from './interfaces'; +import { baseUrl } from './view/util'; export const stockfishName = 'Stockfish 18'; diff --git a/ui/analyse/src/socket.ts b/ui/analyse/src/socket.ts index 83cc54804e4..aad11688c55 100644 --- a/ui/analyse/src/socket.ts +++ b/ui/analyse/src/socket.ts @@ -1,9 +1,10 @@ import { ops as treeOps } from 'lib/tree/tree'; +import type { Shape } from 'lib/tree/types'; + import type AnalyseCtrl from './ctrl'; import type { EvalGetData, EvalPutData, Opening, ServerEvalData } from './interfaces'; import type { AnaDrop, AnaMove, ChapterData, EditChapterData } from './study/interfaces'; import type { FormData as StudyFormData } from './study/studyForm'; -import type { Shape } from 'lib/tree/types'; interface MoveOpts { write?: false; diff --git a/ui/analyse/src/start.ts b/ui/analyse/src/start.ts index c0ba0b5707e..106de8dc8d3 100644 --- a/ui/analyse/src/start.ts +++ b/ui/analyse/src/start.ts @@ -1,9 +1,11 @@ -import makeCtrl from './ctrl'; -import menuHover from 'lib/menuHover'; -import makeView from './view/main'; -import type { AnalyseApi, AnalyseOpts } from './interfaces'; import type { VNode } from 'snabbdom'; + +import menuHover from 'lib/menuHover'; + +import makeCtrl from './ctrl'; +import type { AnalyseApi, AnalyseOpts } from './interfaces'; import type * as studyDeps from './study/studyDeps'; +import makeView from './view/main'; export default function ( patch: (oldVnode: VNode | Element | DocumentFragment, vnode: VNode) => VNode, diff --git a/ui/analyse/src/study/analyse.study.topic.form.ts b/ui/analyse/src/study/analyse.study.topic.form.ts index e1901e16a23..0389d89f7c3 100644 --- a/ui/analyse/src/study/analyse.study.topic.form.ts +++ b/ui/analyse/src/study/analyse.study.topic.form.ts @@ -1,8 +1,9 @@ -import debounce from 'debounce-promise'; -import { json as xhrJson, url as xhrUrl } from 'lib/xhr'; import Tagify from '@yaireo/tagify'; +import debounce from 'debounce-promise'; import Sortable from 'sortablejs'; +import { json as xhrJson, url as xhrUrl } from 'lib/xhr'; + site.load.then(() => { const input = document.getElementById('form3-topics') as HTMLInputElement; const tagify = new Tagify(input, { diff --git a/ui/analyse/src/study/analyse.study.tour.ts b/ui/analyse/src/study/analyse.study.tour.ts index 66ba7f77810..dfa7d67ff16 100644 --- a/ui/analyse/src/study/analyse.study.tour.ts +++ b/ui/analyse/src/study/analyse.study.tour.ts @@ -1,8 +1,10 @@ -import type AnalyseCtrl from '../ctrl'; import Shepherd from 'shepherd.js'; -import type { ChapterTab, StudyTour, Tab } from './interfaces'; -import { pubsub } from 'lib/pubsub'; + import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; + +import type AnalyseCtrl from '../ctrl'; +import type { ChapterTab, StudyTour, Tab } from './interfaces'; export function initModule(): StudyTour { return { diff --git a/ui/analyse/src/study/analyse.study.ts b/ui/analyse/src/study/analyse.study.ts index e43756bc877..d091f6efd46 100644 --- a/ui/analyse/src/study/analyse.study.ts +++ b/ui/analyse/src/study/analyse.study.ts @@ -1,9 +1,10 @@ -import { patch } from '../view/util'; -import makeStart from '../start'; +import { wsConnect } from 'lib/socket'; + import type { AnalyseOpts } from '../interfaces'; import type { AnalyseSocketSend } from '../socket'; +import makeStart from '../start'; +import { patch } from '../view/util'; import * as studyDeps from './studyDeps'; -import { wsConnect } from 'lib/socket'; export { patch }; diff --git a/ui/analyse/src/study/chapterEditForm.ts b/ui/analyse/src/study/chapterEditForm.ts index 4c469083d11..237a5b0ba50 100644 --- a/ui/analyse/src/study/chapterEditForm.ts +++ b/ui/analyse/src/study/chapterEditForm.ts @@ -1,6 +1,12 @@ -import { fieldValue, modeChoices } from './chapterNewForm'; +import { COLORS } from 'chessops'; +import { h, type VNode } from 'snabbdom'; + +import { defined, prop } from 'lib'; import { bind, bindSubmit, onInsert, spinnerVdom as spinner, snabDialog, confirm } from 'lib/view'; + +import type { StudySocketSend } from '../socket'; import { option, emptyRedButton } from '../view/util'; +import { fieldValue, modeChoices } from './chapterNewForm'; import type { ChapterMode, EditChapterData, @@ -8,10 +14,6 @@ import type { StudyChapterConfig, ChapterPreview, } from './interfaces'; -import { defined, prop } from 'lib'; -import { h, type VNode } from 'snabbdom'; -import type { StudySocketSend } from '../socket'; -import { COLORS } from 'chessops'; export class StudyChapterEditForm { current = prop(null); diff --git a/ui/analyse/src/study/chapterNewForm.ts b/ui/analyse/src/study/chapterNewForm.ts index 4f3cc5d465b..628b8f147fe 100644 --- a/ui/analyse/src/study/chapterNewForm.ts +++ b/ui/analyse/src/study/chapterNewForm.ts @@ -1,5 +1,10 @@ import { parseFen } from 'chessops/fen'; +import type { LichessEditor } from 'editor'; + import { defined, prop, type Prop, toggle } from 'lib'; +import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { storedProp } from 'lib/storage'; import { snabDialog, alert, @@ -12,17 +17,14 @@ import { type Dialog, type VNode, } from 'lib/view'; -import * as licon from 'lib/licon'; -import { storedProp } from 'lib/storage'; import { json as xhrJson, text as xhrText } from 'lib/xhr'; + import type AnalyseCtrl from '../ctrl'; import type { StudySocketSend } from '../socket'; import { option } from '../view/util'; import type { ChapterData, ChapterMode, ChapterTab, Orientation, StudyTour } from './interfaces'; -import { importPgn, variants as xhrVariants } from './studyXhr'; import type { StudyChapters } from './studyChapters'; -import type { LichessEditor } from 'editor'; -import { pubsub } from 'lib/pubsub'; +import { importPgn, variants as xhrVariants } from './studyXhr'; export const modeChoices = [ ['normal', i18n.study.normalAnalysis], diff --git a/ui/analyse/src/study/commentForm.ts b/ui/analyse/src/study/commentForm.ts index 18ed67b67e0..7ae86bed428 100644 --- a/ui/analyse/src/study/commentForm.ts +++ b/ui/analyse/src/study/commentForm.ts @@ -1,12 +1,14 @@ -import { prop } from 'lib'; -import { onInsert } from 'lib/view'; -import { throttle } from 'lib/async'; import { h, type VNode } from 'snabbdom'; -import type AnalyseCtrl from '../ctrl'; -import { currentComments, isAuthorObj } from './studyComments'; + +import { prop } from 'lib'; +import { throttle } from 'lib/async'; import { storage } from 'lib/storage'; import type { TreeNode, TreePath } from 'lib/tree/types'; +import { onInsert } from 'lib/view'; + +import type AnalyseCtrl from '../ctrl'; import type { ChapterId } from './interfaces'; +import { currentComments, isAuthorObj } from './studyComments'; interface Current { chapterId: ChapterId; diff --git a/ui/analyse/src/study/description.ts b/ui/analyse/src/study/description.ts index 11a6b79206e..17222b59090 100644 --- a/ui/analyse/src/study/description.ts +++ b/ui/analyse/src/study/description.ts @@ -1,6 +1,7 @@ import * as licon from 'lib/licon'; -import { type VNode, bind, onInsert, hl, confirm } from 'lib/view'; import { richHTML } from 'lib/richText'; +import { type VNode, bind, onInsert, hl, confirm } from 'lib/view'; + import type StudyCtrl from './studyCtrl'; export type Save = (t: string) => void; diff --git a/ui/analyse/src/study/gamebook/gamebookButtons.ts b/ui/analyse/src/study/gamebook/gamebookButtons.ts index 10376250c28..d9bdce0a3ca 100644 --- a/ui/analyse/src/study/gamebook/gamebookButtons.ts +++ b/ui/analyse/src/study/gamebook/gamebookButtons.ts @@ -1,6 +1,8 @@ import * as licon from 'lib/licon'; import { bind, dataIcon, type VNode, hl } from 'lib/view'; + import type AnalyseCtrl from '@/ctrl'; + import type StudyCtrl from '../studyCtrl'; export function playButtons(root: AnalyseCtrl): VNode | undefined { diff --git a/ui/analyse/src/study/gamebook/gamebookEdit.ts b/ui/analyse/src/study/gamebook/gamebookEdit.ts index ac635d6416d..6c5b3d006e5 100644 --- a/ui/analyse/src/study/gamebook/gamebookEdit.ts +++ b/ui/analyse/src/study/gamebook/gamebookEdit.ts @@ -1,11 +1,13 @@ +import { h, type Hooks, type VNode } from 'snabbdom'; + +import { requestIdleCallback } from 'lib'; +import { throttle } from 'lib/async'; +import * as licon from 'lib/licon'; +import type { Gamebook, TreeNode } from 'lib/tree/types'; +import { iconTag, bind, type MaybeVNodes } from 'lib/view'; + import { prev } from '@/control'; import type AnalyseCtrl from '@/ctrl'; -import { requestIdleCallback } from 'lib'; -import * as licon from 'lib/licon'; -import { throttle } from 'lib/async'; -import { iconTag, bind, type MaybeVNodes } from 'lib/view'; -import { h, type Hooks, type VNode } from 'snabbdom'; -import type { Gamebook, TreeNode } from 'lib/tree/types'; export const running = (ctrl: AnalyseCtrl): boolean => !!ctrl.study && diff --git a/ui/analyse/src/study/gamebook/gamebookPlayCtrl.ts b/ui/analyse/src/study/gamebook/gamebookPlayCtrl.ts index b6b35a222b2..fa853132ecf 100644 --- a/ui/analyse/src/study/gamebook/gamebookPlayCtrl.ts +++ b/ui/analyse/src/study/gamebook/gamebookPlayCtrl.ts @@ -1,8 +1,9 @@ -import type AnalyseCtrl from '@/ctrl'; import { path as treePath } from 'lib/tree/tree'; -import { makeShapesFromUci } from '@/autoShape'; import type { Shape, TreePath } from 'lib/tree/types'; +import { makeShapesFromUci } from '@/autoShape'; +import type AnalyseCtrl from '@/ctrl'; + export type Feedback = 'play' | 'good' | 'bad' | 'end'; export interface State { diff --git a/ui/analyse/src/study/gamebook/gamebookPlayView.ts b/ui/analyse/src/study/gamebook/gamebookPlayView.ts index fcce27d46fb..af0a0e78c97 100644 --- a/ui/analyse/src/study/gamebook/gamebookPlayView.ts +++ b/ui/analyse/src/study/gamebook/gamebookPlayView.ts @@ -1,7 +1,8 @@ -import GamebookPlayCtrl, { type State } from './gamebookPlayCtrl'; import * as licon from 'lib/licon'; -import { type VNode, iconTag, bind, dataIcon, hl, requiresI18n } from 'lib/view'; import { richHTML } from 'lib/richText'; +import { type VNode, iconTag, bind, dataIcon, hl, requiresI18n } from 'lib/view'; + +import GamebookPlayCtrl, { type State } from './gamebookPlayCtrl'; export function render(ctrl: GamebookPlayCtrl): VNode { const state = ctrl.state; diff --git a/ui/analyse/src/study/interfaces.ts b/ui/analyse/src/study/interfaces.ts index 3af195ba387..c7dee345ac9 100644 --- a/ui/analyse/src/study/interfaces.ts +++ b/ui/analyse/src/study/interfaces.ts @@ -1,9 +1,10 @@ import type { Prop } from 'lib'; +import type { TreeNodeIncomplete, TreePath } from 'lib/tree/types'; + +import type AnalyseCtrl from '../ctrl'; +import type { Opening } from '../explorer/interfaces'; import type { AnalyseData } from '../interfaces'; import type { GamebookOverride } from './gamebook/interfaces'; -import type { Opening } from '../explorer/interfaces'; -import type AnalyseCtrl from '../ctrl'; -import type { TreeNodeIncomplete, TreePath } from 'lib/tree/types'; export type Tab = 'intro' | 'members' | 'chapters'; export type ChapterTab = 'init' | 'edit' | 'game' | 'fen' | 'pgn'; diff --git a/ui/analyse/src/study/inviteForm.ts b/ui/analyse/src/study/inviteForm.ts index c5a97fb71c8..c85d209d140 100644 --- a/ui/analyse/src/study/inviteForm.ts +++ b/ui/analyse/src/study/inviteForm.ts @@ -1,13 +1,15 @@ -import * as licon from 'lib/licon'; -import { bind, onInsert, snabDialog } from 'lib/view'; -import { titleNameToId } from '../view/util'; import { h, type VNode } from 'snabbdom'; + import { prop, type Prop } from 'lib'; -import type { StudyMemberMap } from './interfaces'; -import type { AnalyseSocketSend } from '../socket'; -import { storedSet, type StoredSet } from 'lib/storage'; -import { userComplete } from 'lib/view/userComplete'; +import * as licon from 'lib/licon'; import { pubsub } from 'lib/pubsub'; +import { storedSet, type StoredSet } from 'lib/storage'; +import { bind, onInsert, snabDialog } from 'lib/view'; +import { userComplete } from 'lib/view/userComplete'; + +import type { AnalyseSocketSend } from '../socket'; +import { titleNameToId } from '../view/util'; +import type { StudyMemberMap } from './interfaces'; export interface StudyInviteFormCtrl { open: Prop; diff --git a/ui/analyse/src/study/multiBoard.ts b/ui/analyse/src/study/multiBoard.ts index cb49fb48aa4..cdee3f10500 100644 --- a/ui/analyse/src/study/multiBoard.ts +++ b/ui/analyse/src/study/multiBoard.ts @@ -1,23 +1,25 @@ -import * as licon from 'lib/licon'; -import { otbClockIsRunning, formatMs } from 'lib/game/clock/clockWidget'; +import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { opposite as cgOpposite, uciToMove } from '@lichess-org/chessground/util'; +import type { Color } from 'chessops'; +import { EMPTY_BOARD_FEN } from 'chessops/fen'; +import { h } from 'snabbdom'; + +import { type Prop, type Toggle, defined, notNull, prop, toggle } from 'lib'; import { fenColor } from 'lib/game/chess'; +import { otbClockIsRunning, formatMs } from 'lib/game/clock/clockWidget'; +import * as licon from 'lib/licon'; +import { storage, storedBooleanProp } from 'lib/storage'; import { type MaybeVNode, type VNode, bind, dataIcon, onInsert, hl } from 'lib/view'; import { cmnToggleWrapProp } from 'lib/view/cmn-toggle'; -import { opposite as cgOpposite, uciToMove } from '@lichess-org/chessground/util'; -import type { ChapterId, ChapterPreview, StudyPlayer } from './interfaces'; -import type StudyCtrl from './studyCtrl'; -import { type CloudEval, type MultiCloudEval, renderScore } from './multiCloudEval'; -import { type Prop, type Toggle, defined, notNull, prop, toggle } from 'lib'; -import type { Color } from 'chessops'; -import { type StudyChapters, gameLinkAttrs, gameLinksListener } from './studyChapters'; -import { playerFedFlag } from './playerBars'; import { userTitle } from 'lib/view/userLink'; -import { h } from 'snabbdom'; -import { storage, storedBooleanProp } from 'lib/storage'; -import { Chessground as makeChessground } from '@lichess-org/chessground'; -import { EMPTY_BOARD_FEN } from 'chessops/fen'; + +import type { ChapterId, ChapterPreview, StudyPlayer } from './interfaces'; +import { type CloudEval, type MultiCloudEval, renderScore } from './multiCloudEval'; +import { playerFedFlag } from './playerBars'; import { playerColoredResult } from './relay/customScoreStatus'; import type { RelayRound } from './relay/interfaces'; +import { type StudyChapters, gameLinkAttrs, gameLinksListener } from './studyChapters'; +import type StudyCtrl from './studyCtrl'; export class MultiBoardCtrl { playing: Toggle = toggle(false); diff --git a/ui/analyse/src/study/multiCloudEval.ts b/ui/analyse/src/study/multiCloudEval.ts index 7ee5ca89f28..b646237240b 100644 --- a/ui/analyse/src/study/multiCloudEval.ts +++ b/ui/analyse/src/study/multiCloudEval.ts @@ -1,12 +1,13 @@ import { type Prop, defined } from 'lib'; -import type { EvalHitMulti } from '../interfaces'; -import { storedBooleanPropWithEffect } from 'lib/storage'; -import { povChances } from 'lib/ceval/winningChances'; -import type { StudyChapters } from './studyChapters'; import { debounce } from 'lib/async'; -import type { ServerNodeMsg } from './interfaces'; +import { povChances } from 'lib/ceval/winningChances'; +import { storedBooleanPropWithEffect } from 'lib/storage'; import type { ClientEval, TreeNode } from 'lib/tree/types'; +import type { EvalHitMulti } from '../interfaces'; +import type { ServerNodeMsg } from './interfaces'; +import type { StudyChapters } from './studyChapters'; + export interface CloudEval extends EvalHitMulti { chances: number; } diff --git a/ui/analyse/src/study/nextChapter.ts b/ui/analyse/src/study/nextChapter.ts index b26ad3c2c44..4ace1f27bdf 100644 --- a/ui/analyse/src/study/nextChapter.ts +++ b/ui/analyse/src/study/nextChapter.ts @@ -1,8 +1,10 @@ import { h } from 'snabbdom'; + import * as licon from 'lib/licon'; -import { bind } from 'lib/view'; -import type AnalyseCtrl from '../ctrl'; import { ops as treeOps } from 'lib/tree/tree'; +import { bind } from 'lib/view'; + +import type AnalyseCtrl from '../ctrl'; export const renderNextChapter = (ctrl: AnalyseCtrl) => !ctrl.opts.relay && ctrl.study?.hasNextChapter() diff --git a/ui/analyse/src/study/playerBars.ts b/ui/analyse/src/study/playerBars.ts index 0d95a90f4df..4e01a943221 100644 --- a/ui/analyse/src/study/playerBars.ts +++ b/ui/analyse/src/study/playerBars.ts @@ -1,22 +1,24 @@ +import { COLORS } from 'chessops'; import type { VNode } from 'snabbdom'; + +import { defined } from 'lib'; +import { intersection } from 'lib/tree/path'; +import type { TreePath } from 'lib/tree/types'; import { hl } from 'lib/view'; -import renderClocks from '../view/clocks'; +import { userTitle } from 'lib/view/userLink'; + import type AnalyseCtrl from '../ctrl'; +import renderClocks from '../view/clocks'; import { renderMaterialDiffs } from '../view/components'; import type { StudyPlayers, Federation, StudyPlayer, StatusStr, TagMap } from './interfaces'; -import { looksLikeLichessGame } from './studyChapters'; -import { userTitle } from 'lib/view/userLink'; -import RelayPlayers, { fidePageLinkAttrs, playerId, playerPhotoOrFallback } from './relay/relayPlayers'; -import { StudyCtrl } from './studyDeps'; -import { intersection } from 'lib/tree/path'; -import { defined } from 'lib'; -import { resultTag } from './studyView'; -import type { RelayRound } from './relay/interfaces'; import { playerColoredResult } from './relay/customScoreStatus'; -import type { TreePath } from 'lib/tree/types'; -import { tagsToMap } from './studyTags'; -import { COLORS } from 'chessops'; +import type { RelayRound } from './relay/interfaces'; +import RelayPlayers, { fidePageLinkAttrs, playerId, playerPhotoOrFallback } from './relay/relayPlayers'; import RelayTeamLeaderboard from './relay/relayTeamLeaderboard'; +import { looksLikeLichessGame } from './studyChapters'; +import { StudyCtrl } from './studyDeps'; +import { tagsToMap } from './studyTags'; +import { resultTag } from './studyView'; export default function (ctrl: AnalyseCtrl): VNode[] | undefined { const study = ctrl.study; diff --git a/ui/analyse/src/study/practice/studyPracticeCtrl.ts b/ui/analyse/src/study/practice/studyPracticeCtrl.ts index 5c5439e79b5..f02f741094e 100644 --- a/ui/analyse/src/study/practice/studyPracticeCtrl.ts +++ b/ui/analyse/src/study/practice/studyPracticeCtrl.ts @@ -1,11 +1,13 @@ -import { practiceComplete } from '../studyXhr'; import { type Prop, prop } from 'lib'; import { storedBooleanProp } from 'lib/storage'; -import makeSuccess from './studyPracticeSuccess'; -import { readOnlyProp } from '@/util'; -import type { StudyPracticeData, Goal } from './interfaces'; -import type { StudyData } from '../interfaces'; + import type AnalyseCtrl from '@/ctrl'; +import { readOnlyProp } from '@/util'; + +import type { StudyData } from '../interfaces'; +import { practiceComplete } from '../studyXhr'; +import type { StudyPracticeData, Goal } from './interfaces'; +import makeSuccess from './studyPracticeSuccess'; export default class StudyPracticeCtrl { goal: Prop; diff --git a/ui/analyse/src/study/practice/studyPracticeSuccess.ts b/ui/analyse/src/study/practice/studyPracticeSuccess.ts index d4aa898010b..074b64817ab 100644 --- a/ui/analyse/src/study/practice/studyPracticeSuccess.ts +++ b/ui/analyse/src/study/practice/studyPracticeSuccess.ts @@ -1,8 +1,10 @@ -import type AnalyseCtrl from '@/ctrl'; -import type { Goal } from './interfaces'; -import type { Comment } from '@/practice/practiceCtrl'; import type { TreeNode } from 'lib/tree/types'; +import type AnalyseCtrl from '@/ctrl'; +import type { Comment } from '@/practice/practiceCtrl'; + +import type { Goal } from './interfaces'; + // returns null if not deep enough to know const isDrawish = (node: TreeNode): boolean | null => hasSolidEval(node) ? !node.ceval!.mate && Math.abs(node.ceval!.cp!) < 150 : null; diff --git a/ui/analyse/src/study/practice/studyPracticeView.ts b/ui/analyse/src/study/practice/studyPracticeView.ts index 925fb2a2736..a4075304798 100644 --- a/ui/analyse/src/study/practice/studyPracticeView.ts +++ b/ui/analyse/src/study/practice/studyPracticeView.ts @@ -1,12 +1,15 @@ +import { h, thunk, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; +import { richHTML } from 'lib/richText'; import { bind, bindNonPassive, type MaybeVNodes, spinnerVdom as spinner } from 'lib/view'; import { cmnToggleWrapProp } from 'lib/view/cmn-toggle'; -import { h, thunk, type VNode } from 'snabbdom'; -import { richHTML } from 'lib/richText'; + import { option, plural } from '@/view/util'; + import { view as descView } from '../description'; -import type { StudyPracticeData } from './interfaces'; import type StudyCtrl from '../studyCtrl'; +import type { StudyPracticeData } from './interfaces'; import type StudyPracticeCtrl from './studyPracticeCtrl'; const selector = (data: StudyPracticeData) => diff --git a/ui/analyse/src/study/relay/customScoreStatus.ts b/ui/analyse/src/study/relay/customScoreStatus.ts index 2229ab5e1c5..a9a2d9646d4 100644 --- a/ui/analyse/src/study/relay/customScoreStatus.ts +++ b/ui/analyse/src/study/relay/customScoreStatus.ts @@ -1,7 +1,9 @@ +import { opposite } from 'chessops/util'; + import { hl, type LooseVNodes, type VNodeChildElement } from 'lib/view'; + import type { GamePointsStr } from '../interfaces'; import type { CustomScoring, RelayRound } from './interfaces'; -import { opposite } from 'chessops/util'; type ServerPoint = '1' | '0' | '½'; const points = (point: ServerPoint) => parseFloat(point.replace('½', '.5')); diff --git a/ui/analyse/src/study/relay/liveboardPlugin.ts b/ui/analyse/src/study/relay/liveboardPlugin.ts index e279c566e45..375f69794b3 100644 --- a/ui/analyse/src/study/relay/liveboardPlugin.ts +++ b/ui/analyse/src/study/relay/liveboardPlugin.ts @@ -1,8 +1,10 @@ -import { hl, type VNode, getChessground, initMiniBoardWith, spinnerVdom } from 'lib/view'; -import { fenColor, uciToMove } from 'lib/game/chess'; import { type ChatPlugin } from 'lib/chat/interfaces'; -import type AnalyseCtrl from '@/ctrl'; +import { fenColor, uciToMove } from 'lib/game/chess'; import { mainlineNodeList } from 'lib/tree/ops'; +import { hl, type VNode, getChessground, initMiniBoardWith, spinnerVdom } from 'lib/view'; + +import type AnalyseCtrl from '@/ctrl'; + import { type ChapterId } from '../interfaces'; type BoardConfig = CgConfig & { lastUci?: Uci }; diff --git a/ui/analyse/src/study/relay/relayCtrl.ts b/ui/analyse/src/study/relay/relayCtrl.ts index ff66443847e..80c8c035454 100644 --- a/ui/analyse/src/study/relay/relayCtrl.ts +++ b/ui/analyse/src/study/relay/relayCtrl.ts @@ -1,15 +1,18 @@ -import type { RelayData, LogEvent, RelaySync, RelayRound } from './interfaces'; -import type { BothClocks, ChapterId, ServerClockMsg } from '@/study/interfaces'; -import { type Prop, type Toggle, myUserId, notNull, prop, toggle } from 'lib'; -import RelayTeams from './relayTeams'; -import RelayPlayers from './relayPlayers'; -import type StudyCtrl from '@/study/studyCtrl'; -import { VideoPlayer } from './videoPlayer'; -import RelayStats from './relayStats'; -import { LiveboardPlugin } from './liveboardPlugin'; -import { pubsub } from 'lib/pubsub'; import { COLORS } from 'chessops'; + +import { type Prop, type Toggle, myUserId, notNull, prop, toggle } from 'lib'; +import { pubsub } from 'lib/pubsub'; + +import type { BothClocks, ChapterId, ServerClockMsg } from '@/study/interfaces'; +import type StudyCtrl from '@/study/studyCtrl'; + +import type { RelayData, LogEvent, RelaySync, RelayRound } from './interfaces'; +import { LiveboardPlugin } from './liveboardPlugin'; +import RelayPlayers from './relayPlayers'; +import RelayStats from './relayStats'; import RelayTeamLeaderboard from './relayTeamLeaderboard'; +import RelayTeams from './relayTeams'; +import { VideoPlayer } from './videoPlayer'; export const relayTabs = ['overview', 'boards', 'teams', 'players', 'stats', 'team-results'] as const; export type RelayTab = (typeof relayTabs)[number]; diff --git a/ui/analyse/src/study/relay/relayGames.ts b/ui/analyse/src/study/relay/relayGames.ts index c0ca6681231..9bb382eecbc 100644 --- a/ui/analyse/src/study/relay/relayGames.ts +++ b/ui/analyse/src/study/relay/relayGames.ts @@ -1,15 +1,17 @@ -import type { StudyCtrl } from '../studyDeps'; -import type RelayCtrl from './relayCtrl'; -import { userTitle } from 'lib/view/userLink'; -import { defined, scrollToInnerSelector } from 'lib'; -import { renderClock, verticalEvalGauge } from '../multiBoard'; -import type { ChapterPreview } from '../interfaces'; -import { gameLinkAttrs } from '../studyChapters'; -import { playerFedFlag } from '../playerBars'; -import { hl } from 'lib/view'; -import { playerColoredResult } from './customScoreStatus'; import { COLORS } from 'chessops'; +import { defined, scrollToInnerSelector } from 'lib'; +import { hl } from 'lib/view'; +import { userTitle } from 'lib/view/userLink'; + +import type { ChapterPreview } from '../interfaces'; +import { renderClock, verticalEvalGauge } from '../multiBoard'; +import { playerFedFlag } from '../playerBars'; +import { gameLinkAttrs } from '../studyChapters'; +import type { StudyCtrl } from '../studyDeps'; +import { playerColoredResult } from './customScoreStatus'; +import type RelayCtrl from './relayCtrl'; + export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => { const chapters = study.chapters.list.all(); const cloudEval = study.multiCloudEval?.thisIfShowEval(); diff --git a/ui/analyse/src/study/relay/relayManagerView.ts b/ui/analyse/src/study/relay/relayManagerView.ts index aec11bbd6ae..0a59a52967e 100644 --- a/ui/analyse/src/study/relay/relayManagerView.ts +++ b/ui/analyse/src/study/relay/relayManagerView.ts @@ -1,11 +1,12 @@ +import { memoize } from 'lib'; import * as licon from 'lib/licon'; import { hl, bind, onInsert, dataIcon, type MaybeVNode } from 'lib/view'; + +import type StudyCtrl from '../studyCtrl'; +import { studySideNodes } from '../studyView'; +import { broadcasterDeepLink } from './deepLink'; import type { LogEvent } from './interfaces'; import type RelayCtrl from './relayCtrl'; -import { memoize } from 'lib'; -import { studySideNodes } from '../studyView'; -import type StudyCtrl from '../studyCtrl'; -import { broadcasterDeepLink } from './deepLink'; export default function (ctrl: RelayCtrl, study: StudyCtrl): MaybeVNode { const contributor = study.members.canContribute(), diff --git a/ui/analyse/src/study/relay/relayPlayers.ts b/ui/analyse/src/study/relay/relayPlayers.ts index ed29e385f3c..2e6e9add31e 100644 --- a/ui/analyse/src/study/relay/relayPlayers.ts +++ b/ui/analyse/src/study/relay/relayPlayers.ts @@ -1,6 +1,20 @@ -import { type VNode, dataIcon, hl, onInsert, spinnerVdom as spinner, type LooseVNodes } from 'lib/view'; -import { json as xhrJson } from 'lib/xhr'; +import { type Attrs, type Hooks, init as initSnabbdom, attributesModule, type VNodeData } from 'snabbdom'; +import type { Tablesort } from 'tablesort'; + +import { defined } from 'lib'; +import { isTouchDevice } from 'lib/device'; +import perfIcons from 'lib/game/perfIcons'; import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { sortTable, extendTablesortNumber } from 'lib/tablesort'; +import { type VNode, dataIcon, hl, onInsert, spinnerVdom as spinner, type LooseVNodes } from 'lib/view'; +import { userLink, userTitle } from 'lib/view/userLink'; +import { json as xhrJson } from 'lib/xhr'; + +import type { ChapterId, FideId, PointsStr, StudyPlayer, StudyPlayerFromServer } from '../interfaces'; +import { playerFedFlag } from '../playerBars'; +import { convertPlayerFromServer } from '../studyChapters'; +import { playerColoredResult } from './customScoreStatus'; import type { FideTC, Photo, @@ -10,19 +24,7 @@ import type { RoundId, StatByFideTC, } from './interfaces'; -import { playerColoredResult } from './customScoreStatus'; -import { playerFedFlag } from '../playerBars'; -import { userLink, userTitle } from 'lib/view/userLink'; -import type { ChapterId, FideId, PointsStr, StudyPlayer, StudyPlayerFromServer } from '../interfaces'; -import { sortTable, extendTablesortNumber } from 'lib/tablesort'; -import { defined } from 'lib'; -import { type Attrs, type Hooks, init as initSnabbdom, attributesModule, type VNodeData } from 'snabbdom'; -import { convertPlayerFromServer } from '../studyChapters'; -import { isTouchDevice } from 'lib/device'; -import { pubsub } from 'lib/pubsub'; import { teamLinkData } from './relayTeamLeaderboard'; -import perfIcons from 'lib/game/perfIcons'; -import type { Tablesort } from 'tablesort'; export type RelayPlayerId = FideId | string; diff --git a/ui/analyse/src/study/relay/relayStats.ts b/ui/analyse/src/study/relay/relayStats.ts index f344db74023..54f2003cf3c 100644 --- a/ui/analyse/src/study/relay/relayStats.ts +++ b/ui/analyse/src/study/relay/relayStats.ts @@ -1,8 +1,10 @@ -import { spinnerVdom as spinner } from 'lib/view'; -import type { RelayRound } from './interfaces'; -import { json as xhrJson } from 'lib/xhr'; import { h } from 'snabbdom'; + import { numberFormat } from 'lib/i18n'; +import { spinnerVdom as spinner } from 'lib/view'; +import { json as xhrJson } from 'lib/xhr'; + +import type { RelayRound } from './interfaces'; type Data = { viewers: any; diff --git a/ui/analyse/src/study/relay/relayTeamLeaderboard.ts b/ui/analyse/src/study/relay/relayTeamLeaderboard.ts index 80dd46cd194..17953f783a8 100644 --- a/ui/analyse/src/study/relay/relayTeamLeaderboard.ts +++ b/ui/analyse/src/study/relay/relayTeamLeaderboard.ts @@ -1,12 +1,14 @@ -import { dataIcon, hl, onInsert, requiresI18n, spinnerVdom, type VNode, type VNodeData } from 'lib/view'; -import { Group, StudyBoard } from 'lib/licon'; -import { json as xhrJson } from 'lib/xhr'; -import type { RelayTeamName, RelayTeamStandings, TourId } from './interfaces'; -import RelayPlayers, { renderPlayers, tableAugment, type RelayPlayer } from './relayPlayers'; +import type { Tablesort } from 'tablesort'; + import { throttle } from 'lib'; +import { Group, StudyBoard } from 'lib/licon'; +import { dataIcon, hl, onInsert, requiresI18n, spinnerVdom, type VNode, type VNodeData } from 'lib/view'; +import { json as xhrJson } from 'lib/xhr'; + import type { StudyPlayerFromServer } from '../interfaces'; import { convertPlayerFromServer } from '../studyChapters'; -import type { Tablesort } from 'tablesort'; +import type { RelayTeamName, RelayTeamStandings, TourId } from './interfaces'; +import RelayPlayers, { renderPlayers, tableAugment, type RelayPlayer } from './relayPlayers'; export default class RelayTeamLeaderboard { standings: RelayTeamStandings | undefined; diff --git a/ui/analyse/src/study/relay/relayTeams.ts b/ui/analyse/src/study/relay/relayTeams.ts index 97a2c3663d3..112275d3f99 100644 --- a/ui/analyse/src/study/relay/relayTeams.ts +++ b/ui/analyse/src/study/relay/relayTeams.ts @@ -1,13 +1,14 @@ import { type MaybeVNodes, type VNode, onInsert, hl, spinnerVdom as spinner } from 'lib/view'; +import { userTitle } from 'lib/view/userLink'; import { json as xhrJson } from 'lib/xhr'; -import type { RelayRound, RelayTour } from './interfaces'; + import type { ChapterId, ChapterPreview, StudyPlayer, ChapterSelect } from '../interfaces'; import { type MultiCloudEval, renderScore } from '../multiCloudEval'; import { playerFedFlag } from '../playerBars'; import { gameLinkAttrs, gameLinksListener, StudyChapters } from '../studyChapters'; -import { userTitle } from 'lib/view/userLink'; -import type RelayPlayers from './relayPlayers'; import { coloredStatusStr } from './customScoreStatus'; +import type { RelayRound, RelayTour } from './interfaces'; +import type RelayPlayers from './relayPlayers'; import { teamLinkData } from './relayTeamLeaderboard'; interface TeamWithPoints { diff --git a/ui/analyse/src/study/relay/relayTourView.ts b/ui/analyse/src/study/relay/relayTourView.ts index 90869aa5ea9..40d54c1cb44 100644 --- a/ui/analyse/src/study/relay/relayTourView.ts +++ b/ui/analyse/src/study/relay/relayTourView.ts @@ -1,10 +1,26 @@ -import type AnalyseCtrl from '@/ctrl'; -import RelayCtrl, { type RelayTab } from './relayCtrl'; +import type { VNode } from 'snabbdom'; + +import { defined, memoize } from 'lib'; +import { renderChat } from 'lib/chat/renderChat'; +import { displayColumns } from 'lib/device'; +import { commonDateFormat, timeago } from 'lib/i18n'; import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { innerHTML, richHTML } from 'lib/richText'; import { bind, dataIcon, onInsert, hl, type LooseVNode, copyMeInput } from 'lib/view'; import { cmnToggleWrap } from 'lib/view/cmn-toggle'; -import type { VNode } from 'snabbdom'; -import { innerHTML, richHTML } from 'lib/richText'; +import { userLink } from 'lib/view/userLink'; +import { verticalResize } from 'lib/view/verticalResize'; +import { watchers } from 'lib/view/watchers'; +import { text as xhrText } from 'lib/xhr'; + +import type AnalyseCtrl from '@/ctrl'; +import { type RelayViewContext } from '@/view/components'; +import { baseUrl } from '@/view/util'; + +import { view as multiBoardView } from '../multiBoard'; +import { gameLinksListener } from '../studyChapters'; +import type StudyCtrl from '../studyCtrl'; import type { RelayData, RelayGroup, @@ -13,25 +29,12 @@ import type { RelayTourInfo, RelayTourPreview, } from './interfaces'; -import { view as multiBoardView } from '../multiBoard'; -import { defined, memoize } from 'lib'; -import type StudyCtrl from '../studyCtrl'; -import { text as xhrText } from 'lib/xhr'; -import { teamsView } from './relayTeams'; -import { statsView } from './relayStats'; -import { type RelayViewContext } from '@/view/components'; +import RelayCtrl, { type RelayTab } from './relayCtrl'; import { gamesList } from './relayGames'; -import { renderStreamerMenu } from './relayView'; import { playersView } from './relayPlayers'; -import { gameLinksListener } from '../studyChapters'; -import { baseUrl } from '@/view/util'; -import { commonDateFormat, timeago } from 'lib/i18n'; -import { renderChat } from 'lib/chat/renderChat'; -import { displayColumns } from 'lib/device'; -import { verticalResize } from 'lib/view/verticalResize'; -import { watchers } from 'lib/view/watchers'; -import { userLink } from 'lib/view/userLink'; -import { pubsub } from 'lib/pubsub'; +import { statsView } from './relayStats'; +import { teamsView } from './relayTeams'; +import { renderStreamerMenu } from './relayView'; export function renderRelayTour(ctx: RelayViewContext): VNode | undefined { const tab = ctx.relay.tab(); diff --git a/ui/analyse/src/study/relay/relayView.ts b/ui/analyse/src/study/relay/relayView.ts index d8f2c857c8b..358a839f666 100644 --- a/ui/analyse/src/study/relay/relayView.ts +++ b/ui/analyse/src/study/relay/relayView.ts @@ -1,11 +1,11 @@ -import { view as cevalView } from 'lib/ceval'; import { onClickAway } from 'lib'; -import { bind, dataIcon, hl, onInsert, type VNode } from 'lib/view'; +import { view as cevalView } from 'lib/ceval'; +import { displayColumns, isTouchDevice } from 'lib/device'; import * as licon from 'lib/licon'; +import { bind, dataIcon, hl, onInsert, type VNode } from 'lib/view'; + import type AnalyseCtrl from '@/ctrl'; import { view as keyboardView } from '@/keyboard'; -import type * as studyDeps from '../studyDeps'; -import { tourSide, renderRelayTour } from './relayTourView'; import { type RelayViewContext, viewContext, @@ -14,10 +14,12 @@ import { renderTools, renderUnderboard, } from '@/view/components'; -import { displayColumns, isTouchDevice } from 'lib/device'; -import type RelayCtrl from './relayCtrl'; import { renderControls } from '@/view/controls'; +import type * as studyDeps from '../studyDeps'; +import type RelayCtrl from './relayCtrl'; +import { tourSide, renderRelayTour } from './relayTourView'; + export function relayView( ctrl: AnalyseCtrl, study: studyDeps.StudyCtrl, diff --git a/ui/analyse/src/study/relay/videoPlayer.ts b/ui/analyse/src/study/relay/videoPlayer.ts index 5b3ae786791..8735fd5d31e 100644 --- a/ui/analyse/src/study/relay/videoPlayer.ts +++ b/ui/analyse/src/study/relay/videoPlayer.ts @@ -1,4 +1,5 @@ import { hl, type VNode, onInsert } from 'lib/view'; + import { allowVideo } from './relayView'; export class VideoPlayer { diff --git a/ui/analyse/src/study/serverEval.ts b/ui/analyse/src/study/serverEval.ts index 0ff90f2ee93..241a107f0ac 100644 --- a/ui/analyse/src/study/serverEval.ts +++ b/ui/analyse/src/study/serverEval.ts @@ -1,13 +1,15 @@ -import * as licon from 'lib/licon'; -import { bind, onInsert, spinnerVdom } from 'lib/view'; -import { requestIdleCallback } from 'lib'; -import { h, type VNode } from 'snabbdom'; -import type AnalyseCtrl from '../ctrl'; import type { ChartGame, AcplChart } from 'chart'; -import type { AnalyseData } from '../interfaces'; +import { h, type VNode } from 'snabbdom'; + +import { requestIdleCallback } from 'lib'; +import * as licon from 'lib/licon'; import { pubsub } from 'lib/pubsub'; -import { stockfishName } from '../serverSideUnderboard'; import type { TreeNode } from 'lib/tree/types'; +import { bind, onInsert, spinnerVdom } from 'lib/view'; + +import type AnalyseCtrl from '../ctrl'; +import type { AnalyseData } from '../interfaces'; +import { stockfishName } from '../serverSideUnderboard'; export const chartSpinner = (): VNode => h('div#acpl-chart-container-loader', [ diff --git a/ui/analyse/src/study/studyChapters.ts b/ui/analyse/src/study/studyChapters.ts index d2497fbe749..56486ea4f8e 100644 --- a/ui/analyse/src/study/studyChapters.ts +++ b/ui/analyse/src/study/studyChapters.ts @@ -1,10 +1,17 @@ +import { INITIAL_FEN } from 'chessops/fen'; +import { opposite } from 'chessops/util'; +import type Sortable from 'sortablejs'; + import { blurIfPrimaryClick, defined, prop, type Prop, scrollToInnerSelector } from 'lib'; +import { fenColor } from 'lib/game/chess'; import * as licon from 'lib/licon'; import { type VNode, bind, dataIcon, iconTag, hl, alert } from 'lib/view'; + import type AnalyseCtrl from '../ctrl'; import type { StudySocketSend } from '../socket'; import { StudyChapterEditForm } from './chapterEditForm'; import { StudyChapterNewForm } from './chapterNewForm'; +import { federations, localizedName } from './fideFeds'; import type { LocalPaths, StudyChapter, @@ -20,11 +27,6 @@ import type { StatusStr, } from './interfaces'; import type StudyCtrl from './studyCtrl'; -import { opposite } from 'chessops/util'; -import { fenColor } from 'lib/game/chess'; -import type Sortable from 'sortablejs'; -import { INITIAL_FEN } from 'chessops/fen'; -import { federations, localizedName } from './fideFeds'; /* read-only interface for external use */ export class StudyChapters { diff --git a/ui/analyse/src/study/studyComments.ts b/ui/analyse/src/study/studyComments.ts index 521a762fc6c..482e411e205 100644 --- a/ui/analyse/src/study/studyComments.ts +++ b/ui/analyse/src/study/studyComments.ts @@ -1,7 +1,9 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; -import { bind, confirm } from 'lib/view'; import { richHTML } from 'lib/richText'; +import { bind, confirm } from 'lib/view'; + import type AnalyseCtrl from '../ctrl'; import { nodeFullName } from '../view/util'; import type StudyCtrl from './studyCtrl'; diff --git a/ui/analyse/src/study/studyCtrl.ts b/ui/analyse/src/study/studyCtrl.ts index f2eb5e5a21d..072a7a9da3f 100644 --- a/ui/analyse/src/study/studyCtrl.ts +++ b/ui/analyse/src/study/studyCtrl.ts @@ -1,20 +1,23 @@ import type { DrawShape } from '@lichess-org/chessground/draw'; +import { opposite } from 'chessops/util'; + import { prop, defined } from 'lib'; import { debounce, throttle, throttlePromiseDelay } from 'lib/async'; -import type AnalyseCtrl from '../ctrl'; -import { StudyMemberCtrl } from './studyMembers'; -import StudyPracticeCtrl from './practice/studyPracticeCtrl'; -import type { StudyPracticeData } from './practice/interfaces'; -import { CommentForm } from './commentForm'; -import { GlyphForm } from './studyGlyph'; -import { StudyForm } from './studyForm'; -import TopicsCtrl from './topics'; -import { NotifCtrl } from './notif'; -import { StudyShare } from './studyShare'; -import { TagsForm } from './studyTags'; -import ServerEval from './serverEval'; -import * as xhr from './studyXhr'; +import { displayColumns } from 'lib/device'; +import { pubsub } from 'lib/pubsub'; +import { storedMap } from 'lib/storage'; +import { completeNode } from 'lib/tree/node'; import { path as treePath, ops as treeOps } from 'lib/tree/tree'; +import type { Glyph, Shape, TreeComment, TreeNode, TreePath } from 'lib/tree/types'; +import { alert } from 'lib/view'; + +import type AnalyseCtrl from '../ctrl'; +import type { EvalHitMulti, EvalHitMultiArray } from '../interfaces'; +import type { StudySocketSendParams } from '../socket'; +import { CommentForm } from './commentForm'; +import { DescriptionCtrl } from './description'; +import GamebookPlayCtrl from './gamebook/gamebookPlayCtrl'; +import type { GamebookOverride } from './gamebook/interfaces'; import type { StudyVm, Tab, @@ -36,25 +39,24 @@ import type { ChapterPreviewFromServer, ChapterSelect, } from './interfaces'; -import GamebookPlayCtrl from './gamebook/gamebookPlayCtrl'; -import { DescriptionCtrl } from './description'; -import RelayCtrl from './relay/relayCtrl'; -import type { RelayData } from './relay/interfaces'; import { MultiBoardCtrl } from './multiBoard'; -import type { StudySocketSendParams } from '../socket'; -import { storedMap } from 'lib/storage'; -import { opposite } from 'chessops/util'; -import StudyChaptersCtrl, { isFinished } from './studyChapters'; -import { SearchCtrl } from './studySearch'; -import type { GamebookOverride } from './gamebook/interfaces'; -import type { EvalHitMulti, EvalHitMultiArray } from '../interfaces'; import { MultiCloudEval } from './multiCloudEval'; -import { pubsub } from 'lib/pubsub'; -import { alert } from 'lib/view'; -import { displayColumns } from 'lib/device'; -import type { Glyph, Shape, TreeComment, TreeNode, TreePath } from 'lib/tree/types'; -import { completeNode } from 'lib/tree/node'; +import { NotifCtrl } from './notif'; +import type { StudyPracticeData } from './practice/interfaces'; +import StudyPracticeCtrl from './practice/studyPracticeCtrl'; +import type { RelayData } from './relay/interfaces'; +import RelayCtrl from './relay/relayCtrl'; +import ServerEval from './serverEval'; +import StudyChaptersCtrl, { isFinished } from './studyChapters'; +import { StudyForm } from './studyForm'; +import { GlyphForm } from './studyGlyph'; import studyKeyboard from './studyKeyboard'; +import { StudyMemberCtrl } from './studyMembers'; +import { SearchCtrl } from './studySearch'; +import { StudyShare } from './studyShare'; +import { TagsForm } from './studyTags'; +import * as xhr from './studyXhr'; +import TopicsCtrl from './topics'; interface Handlers { path(d: WithWhoAndPos): void; diff --git a/ui/analyse/src/study/studyDeps.ts b/ui/analyse/src/study/studyDeps.ts index 0d785aab209..ec575de27db 100644 --- a/ui/analyse/src/study/studyDeps.ts +++ b/ui/analyse/src/study/studyDeps.ts @@ -1,5 +1,5 @@ -import relayManager from './relay/relayManagerView'; import renderPlayerBars from './playerBars'; +import relayManager from './relay/relayManagerView'; import StudyCtrl from './studyCtrl'; export { relayManager, renderPlayerBars, StudyCtrl }; diff --git a/ui/analyse/src/study/studyForm.ts b/ui/analyse/src/study/studyForm.ts index 60747a9a78e..f964918f6b0 100644 --- a/ui/analyse/src/study/studyForm.ts +++ b/ui/analyse/src/study/studyForm.ts @@ -1,7 +1,9 @@ -import * as licon from 'lib/licon'; -import { toggle } from 'lib'; -import { snabDialog, confirm, prompt, type VNode, bindSubmit, bindNonPassive, onInsert, hl } from 'lib/view'; import flairPickerLoader from 'bits/flairPicker'; + +import { toggle } from 'lib'; +import * as licon from 'lib/licon'; +import { snabDialog, confirm, prompt, type VNode, bindSubmit, bindNonPassive, onInsert, hl } from 'lib/view'; + import { emptyRedButton } from '../view/util'; import type { StudyData } from './interfaces'; import type RelayCtrl from './relay/relayCtrl'; diff --git a/ui/analyse/src/study/studyGlyph.ts b/ui/analyse/src/study/studyGlyph.ts index 31685f1cf4a..48556b09abd 100644 --- a/ui/analyse/src/study/studyGlyph.ts +++ b/ui/analyse/src/study/studyGlyph.ts @@ -1,10 +1,12 @@ -import { blurIfPrimaryClick, prop } from 'lib'; -import { bind, spinnerVdom } from 'lib/view'; -import { throttle } from 'lib/async'; import { h, type VNode } from 'snabbdom'; + +import { blurIfPrimaryClick, prop } from 'lib'; +import { throttle } from 'lib/async'; +import type { Glyph, GlyphId, TreeNode } from 'lib/tree/types'; +import { bind, spinnerVdom } from 'lib/view'; + import type AnalyseCtrl from '../ctrl'; import { glyphs as xhrGlyphs } from './studyXhr'; -import type { Glyph, GlyphId, TreeNode } from 'lib/tree/types'; interface AllGlyphs { move: Glyph[]; diff --git a/ui/analyse/src/study/studyKeyboard.ts b/ui/analyse/src/study/studyKeyboard.ts index b2b90b13ed2..4000f0ea8a0 100644 --- a/ui/analyse/src/study/studyKeyboard.ts +++ b/ui/analyse/src/study/studyKeyboard.ts @@ -1,4 +1,5 @@ import { keyToMouseEvent } from '@/keyboard'; + import type StudyCtrl from './studyCtrl'; export default function studyKeyboard(ctrl: StudyCtrl) { diff --git a/ui/analyse/src/study/studyMembers.ts b/ui/analyse/src/study/studyMembers.ts index 0c955dc3ba8..75c5eb02f2b 100644 --- a/ui/analyse/src/study/studyMembers.ts +++ b/ui/analyse/src/study/studyMembers.ts @@ -1,17 +1,18 @@ -import type { AnalyseSocketSend } from '../socket'; -import * as licon from 'lib/licon'; -import { type VNode, iconTag, bind, onInsert, dataIcon, bindNonPassive, hl } from 'lib/view'; -import { makeCtrl as inviteFormCtrl, type StudyInviteFormCtrl } from './inviteForm'; -import type { NotifCtrl } from './notif'; import { prop, type Prop, scrollTo } from 'lib'; +import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { once } from 'lib/storage'; +import { type VNode, iconTag, bind, onInsert, dataIcon, bindNonPassive, hl } from 'lib/view'; +import { cmnToggleWrap } from 'lib/view/cmn-toggle'; +import { userLink } from 'lib/view/userLink'; +import { textRaw as xhrTextRaw } from 'lib/xhr'; + +import type { AnalyseSocketSend } from '../socket'; import { titleNameToId } from '../view/util'; import type { StudyMember, StudyMemberMap, Tab } from './interfaces'; -import { textRaw as xhrTextRaw } from 'lib/xhr'; -import { userLink } from 'lib/view/userLink'; +import { makeCtrl as inviteFormCtrl, type StudyInviteFormCtrl } from './inviteForm'; +import type { NotifCtrl } from './notif'; import type StudyCtrl from './studyCtrl'; -import { once } from 'lib/storage'; -import { pubsub } from 'lib/pubsub'; -import { cmnToggleWrap } from 'lib/view/cmn-toggle'; interface Opts { initDict: StudyMemberMap; diff --git a/ui/analyse/src/study/studySearch.ts b/ui/analyse/src/study/studySearch.ts index 42197eabb51..1b98048ea3c 100644 --- a/ui/analyse/src/study/studySearch.ts +++ b/ui/analyse/src/study/studySearch.ts @@ -1,7 +1,9 @@ +import { h, type VNode } from 'snabbdom'; + import { type Prop, type Toggle, propWithEffect, toggle } from 'lib'; import * as licon from 'lib/licon'; import { bind, dataIcon, enter, onInsert, snabDialog } from 'lib/view'; -import { h, type VNode } from 'snabbdom'; + import type { ChapterPreview } from './interfaces'; import type { StudyChapters } from './studyChapters'; diff --git a/ui/analyse/src/study/studyShare.ts b/ui/analyse/src/study/studyShare.ts index 38b6f7aa03c..d4a9e3724be 100644 --- a/ui/analyse/src/study/studyShare.ts +++ b/ui/analyse/src/study/studyShare.ts @@ -1,14 +1,15 @@ import { prop } from 'lib'; import * as licon from 'lib/licon'; +import type { TreeNode } from 'lib/tree/types'; import { type VNode, bind, dataIcon, hl, copyMeInput, type MaybeVNode } from 'lib/view'; +import { cmnToggleProp } from 'lib/view/cmn-toggle'; import { writeTextClipboard, url as xhrUrl } from 'lib/xhr'; + import { renderIndexAndMove } from '../view/components'; import { baseUrl } from '../view/util'; import type { ChapterPreview, StudyData } from './interfaces'; import type RelayCtrl from './relay/relayCtrl'; -import type { TreeNode } from 'lib/tree/types'; import { relayIframe } from './relay/relayTourView'; -import { cmnToggleProp } from 'lib/view/cmn-toggle'; function fromPly(ctrl: StudyShare): MaybeVNode { if (!ctrl.onMainline()) return; diff --git a/ui/analyse/src/study/studyTags.ts b/ui/analyse/src/study/studyTags.ts index e4b63d0aba7..ddbb9744de2 100644 --- a/ui/analyse/src/study/studyTags.ts +++ b/ui/analyse/src/study/studyTags.ts @@ -1,11 +1,13 @@ -import { enter, onInsert } from 'lib/view'; -import { throttle } from 'lib/async'; import { type Attrs, h, thunk, type VNode } from 'snabbdom'; -import { option } from '../view/util'; -import { looksLikeLichessGame } from './studyChapters'; + import { prop } from 'lib'; -import type StudyCtrl from './studyCtrl'; +import { throttle } from 'lib/async'; +import { enter, onInsert } from 'lib/view'; + +import { option } from '../view/util'; import type { TagArray, TagMap } from './interfaces'; +import { looksLikeLichessGame } from './studyChapters'; +import type StudyCtrl from './studyCtrl'; export const tagsToMap = (tags: TagArray[]): TagMap => { const map = new Map(); diff --git a/ui/analyse/src/study/studyView.ts b/ui/analyse/src/study/studyView.ts index 5eb38f69e13..433a405aca9 100644 --- a/ui/analyse/src/study/studyView.ts +++ b/ui/analyse/src/study/studyView.ts @@ -1,41 +1,43 @@ -import * as commentForm from './commentForm'; -import * as glyphForm from './studyGlyph'; -import * as practiceView from './practice/studyPracticeView'; +import { render as renderKeyboardMove } from 'keyboardMove'; + +import { blurIfPrimaryClick } from 'lib'; +import { view as cevalView } from 'lib/ceval'; +import { renderChat } from 'lib/chat/renderChat'; +import { displayColumns, shareIcon } from 'lib/device'; import * as licon from 'lib/licon'; -import type * as studyDeps from '../study/studyDeps'; -import type AnalyseCtrl from '../ctrl'; -import type { Tab, ToolTab } from './interfaces'; +import type { TreeNode, TreePath } from 'lib/tree/types'; import { type VNode, iconTag, bind, dataIcon, type LooseVNodes, onInsert, hl } from 'lib/view'; -import { playButtons as gbPlayButtons, overrideButton as gbOverrideButton } from './gamebook/gamebookButtons'; +import { verticalResize } from 'lib/view/verticalResize'; +import { watchers } from 'lib/view/watchers'; + +import crazyView from '../crazy/crazyView'; +import type AnalyseCtrl from '../ctrl'; +import { view as keyboardView } from '../keyboard'; +import type * as studyDeps from '../study/studyDeps'; +import { viewContext, renderBoard, renderMain, renderTools, renderUnderboard } from '../view/components'; +import { renderControls } from '../view/controls'; +import { render as trainingView } from '../view/roundTraining'; +import { wikiToggleBox } from '../wiki'; import { view as chapterEditFormView } from './chapterEditForm'; import { view as chapterNewFormView } from './chapterNewForm'; -import { view as chapterView } from './studyChapters'; +import * as commentForm from './commentForm'; import { view as descView } from './description'; +import { playButtons as gbPlayButtons, overrideButton as gbOverrideButton } from './gamebook/gamebookButtons'; +import type { Tab, ToolTab } from './interfaces'; import { view as inviteFormView } from './inviteForm'; -import { view as memberView } from './studyMembers'; import { view as multiBoardView } from './multiBoard'; import { view as notifView } from './notif'; +import * as practiceView from './practice/studyPracticeView'; import { view as serverEvalView } from './serverEval'; +import { view as chapterView } from './studyChapters'; +import type StudyCtrl from './studyCtrl'; import { view as studyFormView } from './studyForm'; +import * as glyphForm from './studyGlyph'; +import { view as memberView } from './studyMembers'; +import { view as searchView } from './studySearch'; import { view as studyShareView } from './studyShare'; import { view as tagsView } from './studyTags'; import { view as topicsView, formView as topicsFormView } from './topics'; -import { view as searchView } from './studySearch'; -import { view as keyboardView } from '../keyboard'; -import { view as cevalView } from 'lib/ceval'; -import { render as trainingView } from '../view/roundTraining'; -import { render as renderKeyboardMove } from 'keyboardMove'; -import { renderChat } from 'lib/chat/renderChat'; -import { wikiToggleBox } from '../wiki'; -import crazyView from '../crazy/crazyView'; -import { watchers } from 'lib/view/watchers'; -import type StudyCtrl from './studyCtrl'; -import { verticalResize } from 'lib/view/verticalResize'; -import { displayColumns, shareIcon } from 'lib/device'; -import { viewContext, renderBoard, renderMain, renderTools, renderUnderboard } from '../view/components'; -import { renderControls } from '../view/controls'; -import type { TreeNode, TreePath } from 'lib/tree/types'; -import { blurIfPrimaryClick } from 'lib'; export function studyView(ctrl: AnalyseCtrl, study: StudyCtrl, deps: typeof studyDeps): VNode { const ctx = viewContext(ctrl, deps); diff --git a/ui/analyse/src/study/studyXhr.ts b/ui/analyse/src/study/studyXhr.ts index 3d81a900f6b..0ab31eccf59 100644 --- a/ui/analyse/src/study/studyXhr.ts +++ b/ui/analyse/src/study/studyXhr.ts @@ -1,6 +1,7 @@ -import type { StudyChapterConfig, ReloadData } from './interfaces'; import { text as xhrText, json as xhrJson, form as xhrForm, textRaw as xhrRaw } from 'lib/xhr'; +import type { StudyChapterConfig, ReloadData } from './interfaces'; + export const reload = ( baseUrl: string, id: string, diff --git a/ui/analyse/src/study/topics.ts b/ui/analyse/src/study/topics.ts index fcf58ad162f..0fd33d9cd97 100644 --- a/ui/analyse/src/study/topics.ts +++ b/ui/analyse/src/study/topics.ts @@ -1,7 +1,9 @@ +import { h, type VNode } from 'snabbdom'; + import { prop } from 'lib'; import { bind, bindSubmit, onInsert, snabDialog } from 'lib/view'; import { json as xhrJson, url as xhrUrl } from 'lib/xhr'; -import { h, type VNode } from 'snabbdom'; + import type { Topic } from './interfaces'; import type StudyCtrl from './studyCtrl'; diff --git a/ui/analyse/src/treeView/columnView.ts b/ui/analyse/src/treeView/columnView.ts index f66857e244b..42e36f58aec 100644 --- a/ui/analyse/src/treeView/columnView.ts +++ b/ui/analyse/src/treeView/columnView.ts @@ -1,9 +1,10 @@ +import type { TreeNode } from 'lib/tree/types'; import { type LooseVNodes, hl, type VNode } from 'lib/view'; + import type AnalyseCtrl from '../ctrl'; import type { ConcealOf } from '../interfaces'; import { renderIndex } from '../view/components'; import { InlineView, type Args } from './inlineView'; -import type { TreeNode } from 'lib/tree/types'; export function renderColumnView(ctrl: AnalyseCtrl, concealOf: ConcealOf = () => () => null): VNode { const renderer = new ColumnView(ctrl, concealOf); diff --git a/ui/analyse/src/treeView/contextMenu.ts b/ui/analyse/src/treeView/contextMenu.ts index 49bda137034..61c7a05c323 100644 --- a/ui/analyse/src/treeView/contextMenu.ts +++ b/ui/analyse/src/treeView/contextMenu.ts @@ -1,11 +1,12 @@ +import { isTouchDevice } from 'lib/device'; import * as licon from 'lib/licon'; +import type { TreePath } from 'lib/tree/types'; import { type VNode, onInsert, hl } from 'lib/view'; + import type AnalyseCtrl from '../ctrl'; +import { renderVariationPgn } from '../pgnExport'; import * as studyView from '../study/studyView'; import { patch, nodeFullName } from '../view/util'; -import { renderVariationPgn } from '../pgnExport'; -import { isTouchDevice } from 'lib/device'; -import type { TreePath } from 'lib/tree/types'; export function renderContextMenu(e: MouseEvent, ctrl: AnalyseCtrl, path: TreePath): void { let pos = getPosition(e); diff --git a/ui/analyse/src/treeView/inlineView.ts b/ui/analyse/src/treeView/inlineView.ts index 26d75779b11..bc8cc75e46b 100644 --- a/ui/analyse/src/treeView/inlineView.ts +++ b/ui/analyse/src/treeView/inlineView.ts @@ -1,15 +1,17 @@ -import type AnalyseCtrl from '../ctrl'; -import { type VNode, type LooseVNodes, hl } from 'lib/view'; import type { Classes, Hooks } from 'snabbdom'; -import { ops as treeOps, path as treePath } from 'lib/tree/tree'; + import { isSafari } from 'lib/device'; -import { enrichText, innerHTML } from 'lib/richText'; -import { authorText } from '../study/studyComments'; import { playable } from 'lib/game'; -import type { Conceal } from '../interfaces'; -import type { DiscloseState } from '../idbTree'; -import { renderMoveNodes, renderIndex } from '../view/components'; +import { enrichText, innerHTML } from 'lib/richText'; +import { ops as treeOps, path as treePath } from 'lib/tree/tree'; import type { TreeComment, TreeNode, TreePath } from 'lib/tree/types'; +import { type VNode, type LooseVNodes, hl } from 'lib/view'; + +import type AnalyseCtrl from '../ctrl'; +import type { DiscloseState } from '../idbTree'; +import type { Conceal } from '../interfaces'; +import { authorText } from '../study/studyComments'; +import { renderMoveNodes, renderIndex } from '../view/components'; export function renderInlineView(ctrl: AnalyseCtrl): VNode { const renderer = new InlineView(ctrl); diff --git a/ui/analyse/src/treeView/treeView.ts b/ui/analyse/src/treeView/treeView.ts index 469c51d3322..4bb2046e7b5 100644 --- a/ui/analyse/src/treeView/treeView.ts +++ b/ui/analyse/src/treeView/treeView.ts @@ -1,16 +1,18 @@ -import type AnalyseCtrl from '../ctrl'; import type { VNode, Hooks } from 'snabbdom'; + import { defined } from 'lib'; import { throttle } from 'lib/async'; import { isTouchDevice } from 'lib/device'; -import { storedProp } from 'lib/storage'; -import type { ConcealOf } from '../interfaces'; -import { renderContextMenu } from './contextMenu'; -import { renderColumnView } from './columnView'; -import { renderInlineView } from './inlineView'; import { addPointerListeners } from 'lib/pointer'; +import { storedProp } from 'lib/storage'; import type { TreePath } from 'lib/tree/types'; +import type AnalyseCtrl from '../ctrl'; +import type { ConcealOf } from '../interfaces'; +import { renderColumnView } from './columnView'; +import { renderContextMenu } from './contextMenu'; +import { renderInlineView } from './inlineView'; + export class TreeView { constructor(readonly ctrl: AnalyseCtrl) {} private autoScrollRequest: ScrollBehavior | false = false; diff --git a/ui/analyse/src/util.ts b/ui/analyse/src/util.ts index 9678379ff85..35b87b3d48f 100644 --- a/ui/analyse/src/util.ts +++ b/ui/analyse/src/util.ts @@ -1,6 +1,7 @@ import { Position } from 'chessops'; -import type { TreeNode, TreeNodeIncomplete } from 'lib/tree/types'; + import { completeNode } from 'lib/tree/node'; +import type { TreeNode, TreeNodeIncomplete } from 'lib/tree/types'; export function readOnlyProp(value: A): () => A { return () => value; diff --git a/ui/analyse/src/view/actionMenu.ts b/ui/analyse/src/view/actionMenu.ts index 6955e8381c7..e6db59e0f2c 100644 --- a/ui/analyse/src/view/actionMenu.ts +++ b/ui/analyse/src/view/actionMenu.ts @@ -1,14 +1,15 @@ import { isEmpty } from 'lib'; -import * as licon from 'lib/licon'; +import { clamp } from 'lib/algo'; import { displayColumns } from 'lib/device'; +import { cont as contRoute } from 'lib/game/router'; +import * as licon from 'lib/licon'; import { domDialog, bind, dataIcon, hl, type VNode, type LooseVNodes, type MaybeVNodes } from 'lib/view'; import { cmnToggleWrapProp, cmnToggleWrap } from 'lib/view/cmn-toggle'; + import type { AutoplayDelay } from '../autoplay'; import type AnalyseCtrl from '../ctrl'; -import { cont as contRoute } from 'lib/game/router'; -import * as pgnExport from '../pgnExport'; -import { clamp } from 'lib/algo'; import { config as motifConfig } from '../motif/motifView'; +import * as pgnExport from '../pgnExport'; interface AutoplaySpeed { name: keyof I18n['site']; diff --git a/ui/analyse/src/view/clocks.ts b/ui/analyse/src/view/clocks.ts index 95e3b14b6ed..602fe5ce6e8 100644 --- a/ui/analyse/src/view/clocks.ts +++ b/ui/analyse/src/view/clocks.ts @@ -1,10 +1,12 @@ import { h, type VNode } from 'snabbdom'; -import type AnalyseCtrl from '../ctrl'; + import { defined, notNull } from 'lib'; -import * as licon from 'lib/licon'; -import { iconTag, type MaybeVNode, type MaybeVNodes } from 'lib/view'; import { formatClockTimeVerbal } from 'lib/game/clock/clockView'; +import * as licon from 'lib/licon'; import type { TreePath } from 'lib/tree/types'; +import { iconTag, type MaybeVNode, type MaybeVNodes } from 'lib/view'; + +import type AnalyseCtrl from '../ctrl'; interface ClockOpts { centis: number | undefined; diff --git a/ui/analyse/src/view/components.ts b/ui/analyse/src/view/components.ts index 29aa403684d..6414597719b 100644 --- a/ui/analyse/src/view/components.ts +++ b/ui/analyse/src/view/components.ts @@ -1,7 +1,19 @@ -import { view as cevalView, renderEval as normalizeEval } from 'lib/ceval'; import { parseFen } from 'chessops/fen'; +import { h } from 'snabbdom'; + import { defined } from 'lib'; +import { view as cevalView, renderEval as normalizeEval } from 'lib/ceval'; +import { dispatchChessgroundResize } from 'lib/chessgroundResize'; +import { isMobile } from 'lib/device'; +import { playable } from 'lib/game'; +import { fixCrazySan, plyToTurn } from 'lib/game/chess'; +import * as materialView from 'lib/game/view/material'; +import statusView from 'lib/game/view/status'; import * as licon from 'lib/licon'; +import * as Prefs from 'lib/prefs'; +import { storage } from 'lib/storage'; +import { path as treePath } from 'lib/tree/tree'; +import type { ClientEval, ServerEval, TreeNode, TreePath } from 'lib/tree/types'; import { type VNode, type LooseVNode, @@ -14,36 +26,26 @@ import { spinnerVdom as spinner, stepwiseScroll, } from 'lib/view'; -import { playable } from 'lib/game'; -import { isMobile } from 'lib/device'; -import * as materialView from 'lib/game/view/material'; -import { path as treePath } from 'lib/tree/tree'; -import { view as actionMenu } from './actionMenu'; -import retroView from '../retrospect/retroView'; -import practiceView from '../practice/practiceView'; + +import * as control from '../control'; +import type AnalyseCtrl from '../ctrl'; import explorerView from '../explorer/explorerView'; import { view as forkView } from '../fork'; -import renderClocks from './clocks'; -import * as control from '../control'; import * as chessground from '../ground'; -import type AnalyseCtrl from '../ctrl'; import type { ConcealOf } from '../interfaces'; import * as pgnExport from '../pgnExport'; -import * as Prefs from 'lib/prefs'; -import statusView from 'lib/game/view/status'; -import { renderNextChapter } from '../study/nextChapter'; -import { dispatchChessgroundResize } from 'lib/chessgroundResize'; -import serverSideUnderboard from '../serverSideUnderboard'; -import type StudyCtrl from '../study/studyCtrl'; -import type RelayCtrl from '../study/relay/relayCtrl'; -import type * as studyDeps from '../study/studyDeps'; import { renderPgnError } from '../pgnImport'; -import { storage } from 'lib/storage'; +import practiceView from '../practice/practiceView'; +import retroView from '../retrospect/retroView'; +import serverSideUnderboard from '../serverSideUnderboard'; +import { renderNextChapter } from '../study/nextChapter'; +import type RelayCtrl from '../study/relay/relayCtrl'; import { backToLiveView } from '../study/relay/relayView'; import { findTag } from '../study/studyChapters'; -import { fixCrazySan, plyToTurn } from 'lib/game/chess'; -import type { ClientEval, ServerEval, TreeNode, TreePath } from 'lib/tree/types'; -import { h } from 'snabbdom'; +import type StudyCtrl from '../study/studyCtrl'; +import type * as studyDeps from '../study/studyDeps'; +import { view as actionMenu } from './actionMenu'; +import renderClocks from './clocks'; export interface ViewContext { ctrl: AnalyseCtrl; diff --git a/ui/analyse/src/view/controls.ts b/ui/analyse/src/view/controls.ts index ac8050a8592..52035ea4ff1 100644 --- a/ui/analyse/src/view/controls.ts +++ b/ui/analyse/src/view/controls.ts @@ -1,9 +1,10 @@ -import { renderEval, view as cevalView } from 'lib/ceval'; import { repeater, myUserId, blurIfPrimaryClick } from 'lib'; -import * as licon from 'lib/licon'; -import { type VNode, type LooseVNode, onInsert, hl, domDialog } from 'lib/view'; +import { renderEval, view as cevalView } from 'lib/ceval'; import { displayColumns, isTouchDevice } from 'lib/device'; +import * as licon from 'lib/licon'; import { addPointerListeners } from 'lib/pointer'; +import { type VNode, type LooseVNode, onInsert, hl, domDialog } from 'lib/view'; + import * as control from '../control'; import type AnalyseCtrl from '../ctrl'; diff --git a/ui/analyse/src/view/main.ts b/ui/analyse/src/view/main.ts index b06e4e3b304..b8683392ef5 100644 --- a/ui/analyse/src/view/main.ts +++ b/ui/analyse/src/view/main.ts @@ -1,23 +1,25 @@ +import { render as renderKeyboardMove } from 'keyboardMove'; + import { view as cevalView } from 'lib/ceval'; -import * as licon from 'lib/licon'; -import { type VNode, onInsert, hl } from 'lib/view'; +import { renderChat } from 'lib/chat/renderChat'; +import { displayColumns } from 'lib/device'; import { playable } from 'lib/game'; import * as router from 'lib/game/router'; -import { render as trainingView } from './roundTraining'; +import * as licon from 'lib/licon'; +import { type VNode, onInsert, hl } from 'lib/view'; +import { watchers } from 'lib/view/watchers'; + import crazyView from '../crazy/crazyView'; import type AnalyseCtrl from '../ctrl'; import forecastView from '../forecast/forecastView'; import { view as keyboardView } from '../keyboard'; -import { render as renderKeyboardMove } from 'keyboardMove'; -import type * as studyDeps from '../study/studyDeps'; import { relayView } from '../study/relay/relayView'; +import type * as studyDeps from '../study/studyDeps'; import { studyView } from '../study/studyView'; -import { viewContext, renderBoard, renderMain, renderTools, renderUnderboard } from './components'; import { wikiToggleBox } from '../wiki'; -import { watchers } from 'lib/view/watchers'; -import { renderChat } from 'lib/chat/renderChat'; -import { displayColumns } from 'lib/device'; +import { viewContext, renderBoard, renderMain, renderTools, renderUnderboard } from './components'; import { renderControls } from './controls'; +import { render as trainingView } from './roundTraining'; let resizeCache: { columns: number; diff --git a/ui/analyse/src/view/nvuiView.ts b/ui/analyse/src/view/nvuiView.ts index 39b64da53c2..d83ac3753cd 100644 --- a/ui/analyse/src/view/nvuiView.ts +++ b/ui/analyse/src/view/nvuiView.ts @@ -1,10 +1,17 @@ -import { type VNode, type LooseVNodes, type VNodeChildren, hl, bind, noTrans, enter } from 'lib/view'; +import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { COLORS } from 'chessops'; +import { lichessRules } from 'chessops/compat'; +import { parseFen } from 'chessops/fen'; +import { makeSan } from 'chessops/san'; +import { charToRole, opposite, parseUci } from 'chessops/util'; +import { setupPosition } from 'chessops/variant'; + import { defined } from 'lib'; -import { text as xhrText } from 'lib/xhr'; -import type AnalyseCtrl from '../ctrl'; -import { makeConfig as makeCgConfig } from '../ground'; -import type { AnalyseData } from '../interfaces'; +import { throttle } from 'lib/async'; +import { view as cevalView, renderEval } from 'lib/ceval'; +import { renderChat } from 'lib/chat/renderChat'; import type { Player } from 'lib/game'; +import { plyToTurn } from 'lib/game/chess'; import { renderSan, renderPieces, @@ -25,34 +32,29 @@ import { pocketsStr, leaveSquareHandler, } from 'lib/nvui/chess'; +import { commands, boardCommands, addBreaks } from 'lib/nvui/command'; +import { scanDirectionsHandler } from 'lib/nvui/directionScan'; import { liveText } from 'lib/nvui/notify'; import { renderSetting } from 'lib/nvui/setting'; -import { commands, boardCommands, addBreaks } from 'lib/nvui/command'; -import explorerView from '../explorer/explorerView'; -import { ops, path as treePath } from 'lib/tree/tree'; -import { view as cevalView, renderEval } from 'lib/ceval'; -import { next, prev } from '../control'; -import { lichessRules } from 'chessops/compat'; -import { makeSan } from 'chessops/san'; -import { charToRole, opposite, parseUci } from 'chessops/util'; -import { parseFen } from 'chessops/fen'; -import { setupPosition } from 'chessops/variant'; -import { plyToTurn } from 'lib/game/chess'; -import { Chessground as makeChessground } from '@lichess-org/chessground'; import { pubsub } from 'lib/pubsub'; -import { renderResult, viewContext, type RelayViewContext } from '../view/components'; -import { view as chapterNewFormView } from '../study/chapterNewForm'; -import { view as chapterEditFormView } from '../study/chapterEditForm'; -import renderClocks from '../view/clocks'; -import { renderChat } from 'lib/chat/renderChat'; -import { throttle } from 'lib/async'; +import { ops, path as treePath } from 'lib/tree/tree'; +import type { ClientEval, PvData } from 'lib/tree/types'; +import { type VNode, type LooseVNodes, type VNodeChildren, hl, bind, noTrans, enter } from 'lib/view'; +import { text as xhrText } from 'lib/xhr'; + +import type { AnalyseNvuiContext } from '../analyse.nvui'; +import { next, prev } from '../control'; +import type AnalyseCtrl from '../ctrl'; +import explorerView from '../explorer/explorerView'; +import { makeConfig as makeCgConfig } from '../ground'; +import type { AnalyseData } from '../interfaces'; import { renderRetro } from '../retrospect/nvuiRetroView'; +import { view as chapterEditFormView } from '../study/chapterEditForm'; +import { view as chapterNewFormView } from '../study/chapterNewForm'; import { playersView } from '../study/relay/relayPlayers'; import { showInfo as tourOverview } from '../study/relay/relayTourView'; -import type { AnalyseNvuiContext } from '../analyse.nvui'; -import { scanDirectionsHandler } from 'lib/nvui/directionScan'; -import type { ClientEval, PvData } from 'lib/tree/types'; -import { COLORS } from 'chessops'; +import renderClocks from '../view/clocks'; +import { renderResult, viewContext, type RelayViewContext } from '../view/components'; const throttled = (sound: string) => throttle(100, () => site.sound.play(sound)); const selectSound = throttled('select'); diff --git a/ui/analyse/src/view/roundTraining.ts b/ui/analyse/src/view/roundTraining.ts index 816952c90fa..82c25c2e254 100644 --- a/ui/analyse/src/view/roundTraining.ts +++ b/ui/analyse/src/view/roundTraining.ts @@ -1,11 +1,13 @@ import { h, thunk, type VNode } from 'snabbdom'; -import type AnalyseCtrl from '../ctrl'; -import { findTag } from '../study/studyChapters'; + import { getPlayer } from 'lib/game'; import * as licon from 'lib/licon'; import { bind, dataIcon } from 'lib/view'; import { ratingDiff } from 'lib/view/userLink'; +import type AnalyseCtrl from '../ctrl'; +import { findTag } from '../study/studyChapters'; + type AdviceKind = 'inaccuracy' | 'mistake' | 'blunder'; interface Advice { diff --git a/ui/analyse/src/view/util.ts b/ui/analyse/src/view/util.ts index 535957da9c9..3a16a1861a3 100644 --- a/ui/analyse/src/view/util.ts +++ b/ui/analyse/src/view/util.ts @@ -1,5 +1,3 @@ -import type { TreeNode } from 'lib/tree/types'; -import { fixCrazySan, plyToTurn } from 'lib/game/chess'; import { attributesModule, classModule, @@ -10,6 +8,9 @@ import { type VNodeData, } from 'snabbdom'; +import { fixCrazySan, plyToTurn } from 'lib/game/chess'; +import type { TreeNode } from 'lib/tree/types'; + export const patch = init([classModule, attributesModule, propsModule, eventListenersModule]); export const emptyRedButton = 'button.button.button-red.button-empty'; diff --git a/ui/analyse/src/wiki.ts b/ui/analyse/src/wiki.ts index 2da1a55fe43..89025621842 100644 --- a/ui/analyse/src/wiki.ts +++ b/ui/analyse/src/wiki.ts @@ -1,6 +1,6 @@ import { debounce } from 'lib/async'; -import type { TreeNode } from 'lib/tree/types'; import { storedBooleanPropWithEffect } from 'lib/storage'; +import type { TreeNode } from 'lib/tree/types'; import { enter } from 'lib/view'; import { wikiBooksUrl, apiArgs, transformWikiHtml } from 'lib/wikiBooks'; diff --git a/ui/analyse/tests/boardAnalysis.test.ts b/ui/analyse/tests/boardAnalysis.test.ts index e9f9668be16..d4f4924fc1a 100644 --- a/ui/analyse/tests/boardAnalysis.test.ts +++ b/ui/analyse/tests/boardAnalysis.test.ts @@ -1,7 +1,8 @@ -import { test } from 'node:test'; -import assert from 'node:assert/strict'; import { parseFen } from 'chessops/fen'; import { makeSquare } from 'chessops/util'; +import assert from 'node:assert/strict'; +import { test } from 'node:test'; + import { detectPins, detectUndefended, detectCheckable } from '../src/motif/boardAnalysis'; function runAnalysis(fen: string): string[] { diff --git a/ui/analyse/tests/deepLink.test.ts b/ui/analyse/tests/deepLink.test.ts index c9ac4376c9c..9600a07dd8b 100644 --- a/ui/analyse/tests/deepLink.test.ts +++ b/ui/analyse/tests/deepLink.test.ts @@ -1,5 +1,6 @@ -import { test } from 'node:test'; import assert from 'node:assert/strict'; +import { test } from 'node:test'; + import { broadcasterDeepLink } from '../src/study/relay/deepLink'; test('creates deep link from URL', () => { diff --git a/ui/bits/src/bits.captcha.ts b/ui/bits/src/bits.captcha.ts index e446cc5a4df..67deceb56f0 100644 --- a/ui/bits/src/bits.captcha.ts +++ b/ui/bits/src/bits.captcha.ts @@ -1,5 +1,5 @@ -import * as xhr from 'lib/xhr'; import * as domData from 'lib/data'; +import * as xhr from 'lib/xhr'; function init() { let failed = false; diff --git a/ui/bits/src/bits.challengePage.ts b/ui/bits/src/bits.challengePage.ts index 21e59abd26c..2d15fb10238 100644 --- a/ui/bits/src/bits.challengePage.ts +++ b/ui/bits/src/bits.challengePage.ts @@ -1,8 +1,8 @@ -import * as xhr from 'lib/xhr'; -import { wsConnect, wsSend } from 'lib/socket'; -import { userComplete } from 'lib/view/userComplete'; import { isTouchDevice, isIos } from 'lib/device'; import { pubsub } from 'lib/pubsub'; +import { wsConnect, wsSend } from 'lib/socket'; +import { userComplete } from 'lib/view/userComplete'; +import * as xhr from 'lib/xhr'; interface ChallengeOpts { xhrUrl: string; diff --git a/ui/bits/src/bits.checkout.ts b/ui/bits/src/bits.checkout.ts index cca08f8ce49..86af833f599 100644 --- a/ui/bits/src/bits.checkout.ts +++ b/ui/bits/src/bits.checkout.ts @@ -1,8 +1,9 @@ -import * as xhr from 'lib/xhr'; -import { spinnerHtml, prompt } from 'lib/view'; -import { currencyFormat, roundToCurrency } from 'lib/i18n'; -import { contactEmail } from './bits'; import { myUserId } from 'lib'; +import { currencyFormat, roundToCurrency } from 'lib/i18n'; +import { spinnerHtml, prompt } from 'lib/view'; +import * as xhr from 'lib/xhr'; + +import { contactEmail } from './bits'; export interface Pricing { currency: string; diff --git a/ui/bits/src/bits.clas.ts b/ui/bits/src/bits.clas.ts index 3fac6016597..3b3797d134a 100644 --- a/ui/bits/src/bits.clas.ts +++ b/ui/bits/src/bits.clas.ts @@ -1,9 +1,9 @@ -import { sortTable, extendTablesortNumber } from 'lib/tablesort'; -import * as xhr from 'lib/xhr'; import { Textcomplete } from '@textcomplete/core'; import { TextareaEditor } from '@textcomplete/textarea'; +import { sortTable, extendTablesortNumber } from 'lib/tablesort'; import type { UserCompleteResult } from 'lib/view/userComplete'; +import * as xhr from 'lib/xhr'; site.load.then(() => { $('table.sortable').each(function (this: HTMLTableElement) { diff --git a/ui/bits/src/bits.cms.ts b/ui/bits/src/bits.cms.ts index 02281f8f828..5ae00175836 100644 --- a/ui/bits/src/bits.cms.ts +++ b/ui/bits/src/bits.cms.ts @@ -1,5 +1,6 @@ import { throttle } from 'lib/async'; import { sortTable } from 'lib/tablesort'; + import { makeToastEditor, getSanitizedMarkdown } from './toastEditor'; site.load.then(() => { diff --git a/ui/bits/src/bits.coachForm.ts b/ui/bits/src/bits.coachForm.ts index b403477f321..eeb48135898 100644 --- a/ui/bits/src/bits.coachForm.ts +++ b/ui/bits/src/bits.coachForm.ts @@ -1,10 +1,12 @@ -import { debounce } from 'lib/async'; -import * as xhr from 'lib/xhr'; -import { isSafari } from 'lib/device'; -import { notNull } from 'lib'; import Tagify from '@yaireo/tagify'; -import { wireCropDialog } from './crop'; + +import { notNull } from 'lib'; +import { debounce } from 'lib/async'; +import { isSafari } from 'lib/device'; import { spinnerHtml } from 'lib/view'; +import * as xhr from 'lib/xhr'; + +import { wireCropDialog } from './crop'; if (isSafari()) wireCropDialog(); // preload diff --git a/ui/bits/src/bits.cropDialog.ts b/ui/bits/src/bits.cropDialog.ts index b4c0bc8a933..17add6f9f21 100644 --- a/ui/bits/src/bits.cropDialog.ts +++ b/ui/bits/src/bits.cropDialog.ts @@ -1,6 +1,8 @@ +import Cropper from 'cropperjs'; + import { defined } from 'lib'; import { domDialog, spinnerHtml } from 'lib/view'; -import Cropper from 'cropperjs'; + import { supported, mimeAccept } from './crop'; export interface CropOpts { diff --git a/ui/bits/src/bits.devMode.ts b/ui/bits/src/bits.devMode.ts index a73a4bbe467..d5661e35494 100644 --- a/ui/bits/src/bits.devMode.ts +++ b/ui/bits/src/bits.devMode.ts @@ -1,5 +1,5 @@ -import { initMiniBoard } from 'lib/view'; import { frag } from 'lib'; +import { initMiniBoard } from 'lib/view'; export function initModule(): void { $('main.lobby').each(function (this: HTMLElement) { diff --git a/ui/bits/src/bits.diagnosticDialog.ts b/ui/bits/src/bits.diagnosticDialog.ts index 8b13843a1a2..bc8770b30fe 100644 --- a/ui/bits/src/bits.diagnosticDialog.ts +++ b/ui/bits/src/bits.diagnosticDialog.ts @@ -1,9 +1,9 @@ -import { isTouchDevice } from 'lib/device'; -import { domDialog } from 'lib/view'; -import * as licon from 'lib/licon'; import { escapeHtml, myUserId } from 'lib'; -import { storage } from 'lib/storage'; +import { isTouchDevice } from 'lib/device'; +import * as licon from 'lib/licon'; import { log } from 'lib/permalog'; +import { storage } from 'lib/storage'; +import { domDialog } from 'lib/view'; interface DiagnosticOpts { text: string; diff --git a/ui/bits/src/bits.dropdownOverflow.ts b/ui/bits/src/bits.dropdownOverflow.ts index 3afc3eb8037..724693a1f76 100644 --- a/ui/bits/src/bits.dropdownOverflow.ts +++ b/ui/bits/src/bits.dropdownOverflow.ts @@ -1,6 +1,6 @@ import { frag } from 'lib'; -import { json as xhrJson } from 'lib/xhr'; import { isTouchDevice } from 'lib/device'; +import { json as xhrJson } from 'lib/xhr'; type HttpMethod = 'GET' | 'POST'; diff --git a/ui/bits/src/bits.flatpickr.ts b/ui/bits/src/bits.flatpickr.ts index d268ca6f59e..ec0dc7e13a5 100644 --- a/ui/bits/src/bits.flatpickr.ts +++ b/ui/bits/src/bits.flatpickr.ts @@ -1,7 +1,8 @@ import flatpickr from 'flatpickr'; -import { use24h } from 'lib/i18n'; import type { Options } from 'flatpickr/dist/types/options'; +import { use24h } from 'lib/i18n'; + site.load.then(() => { $('.flatpickr').each(function (this: HTMLInputElement) { const minDate = this.dataset['minDate']; diff --git a/ui/bits/src/bits.forum.ts b/ui/bits/src/bits.forum.ts index 0aa188247ba..79a8e50958c 100644 --- a/ui/bits/src/bits.forum.ts +++ b/ui/bits/src/bits.forum.ts @@ -1,8 +1,10 @@ -import * as xhr from 'lib/xhr'; -import { domDialog } from 'lib/view'; import { Textcomplete } from '@textcomplete/core'; import { TextareaEditor } from '@textcomplete/textarea'; + import { tempStorage } from 'lib/storage'; +import { domDialog } from 'lib/view'; +import * as xhr from 'lib/xhr'; + import { setMode } from './markdownTextarea'; site.load.then(() => { diff --git a/ui/bits/src/bits.infiniteScroll.ts b/ui/bits/src/bits.infiniteScroll.ts index b2ee1c82bf7..2e2ccab7673 100644 --- a/ui/bits/src/bits.infiniteScroll.ts +++ b/ui/bits/src/bits.infiniteScroll.ts @@ -1,6 +1,6 @@ -import * as xhr from 'lib/xhr'; -import { spinnerHtml } from 'lib/view'; import { pubsub } from 'lib/pubsub'; +import { spinnerHtml } from 'lib/view'; +import * as xhr from 'lib/xhr'; export function initModule(selector: string = '.infinite-scroll'): void { $(selector).each(function (this: HTMLElement) { diff --git a/ui/bits/src/bits.login.ts b/ui/bits/src/bits.login.ts index a111622ef25..32a21662c1e 100644 --- a/ui/bits/src/bits.login.ts +++ b/ui/bits/src/bits.login.ts @@ -1,7 +1,7 @@ -import * as xhr from 'lib/xhr'; import { debounce } from 'lib/async'; -import { addPasswordVisibilityToggleListener, spinnerHtml, alert } from 'lib/view'; import { storedJsonProp } from 'lib/storage'; +import { addPasswordVisibilityToggleListener, spinnerHtml, alert } from 'lib/view'; +import * as xhr from 'lib/xhr'; export function initModule(mode: 'login' | 'signup' | 'reset'): void { mode === 'login' ? loginStart() : mode === 'signup' ? signupStart() : resetStart(); diff --git a/ui/bits/src/bits.lpv.ts b/ui/bits/src/bits.lpv.ts index eda911bf8ea..40b5a99f08b 100644 --- a/ui/bits/src/bits.lpv.ts +++ b/ui/bits/src/bits.lpv.ts @@ -1,6 +1,7 @@ import Lpv from '@lichess-org/pgn-viewer'; -import type PgnViewer from '@lichess-org/pgn-viewer/pgnViewer'; import type { Opts as LpvOpts } from '@lichess-org/pgn-viewer/interfaces'; +import type PgnViewer from '@lichess-org/pgn-viewer/pgnViewer'; + import { text as xhrText } from 'lib/xhr'; export default async function (opts?: { el: HTMLElement; url: string; lpvOpts: LpvOpts }): Promise { diff --git a/ui/bits/src/bits.markdownTextarea.ts b/ui/bits/src/bits.markdownTextarea.ts index de758bbd500..6dc6b2ff494 100644 --- a/ui/bits/src/bits.markdownTextarea.ts +++ b/ui/bits/src/bits.markdownTextarea.ts @@ -1,8 +1,9 @@ +import { marked } from 'marked'; + +import { frag } from 'lib'; import { alert, info, spinnerHtml } from 'lib/view'; import { wireMarkdownImgResizers, naturalSize, markdownPicfitRegex } from 'lib/view/markdownImgResizer'; -import { marked } from 'marked'; import { json as xhrJson } from 'lib/xhr'; -import { frag } from 'lib'; // also see markdownTextarea.ts diff --git a/ui/bits/src/bits.plan.ts b/ui/bits/src/bits.plan.ts index baf263e364e..f8dd84a92ae 100644 --- a/ui/bits/src/bits.plan.ts +++ b/ui/bits/src/bits.plan.ts @@ -1,6 +1,6 @@ -import * as xhr from 'lib/xhr'; -import { alert } from 'lib/view'; import { log } from 'lib/permalog'; +import { alert } from 'lib/view'; +import * as xhr from 'lib/xhr'; const showError = (error: string) => alert(error); diff --git a/ui/bits/src/bits.polyglot.ts b/ui/bits/src/bits.polyglot.ts index 14347d37e60..1b96a0a3c1d 100644 --- a/ui/bits/src/bits.polyglot.ts +++ b/ui/bits/src/bits.polyglot.ts @@ -1,7 +1,9 @@ +import type { Board } from 'chessops'; import * as co from 'chessops'; -import { hashBoard, hashChess } from 'lib/game/hash'; -import { deepFreeze } from 'lib/algo'; import { normalizeMove } from 'chessops/chess'; + +import { deepFreeze } from 'lib/algo'; +import { hashBoard, hashChess } from 'lib/game/hash'; import type { OpeningMove, OpeningBook, @@ -10,7 +12,6 @@ import type { PolyglotResult, PolyglotOpts, } from 'lib/game/polyglot'; -import type { Board } from 'chessops'; export async function initModule(o: PolyglotOpts): Promise bigint)> { if (!o) return hashBoard; diff --git a/ui/bits/src/bits.publicChats.ts b/ui/bits/src/bits.publicChats.ts index 85e7c169094..dbeec69edb6 100644 --- a/ui/bits/src/bits.publicChats.ts +++ b/ui/bits/src/bits.publicChats.ts @@ -1,5 +1,5 @@ -import { text, form } from 'lib/xhr'; import { domDialog } from 'lib/view'; +import { text, form } from 'lib/xhr'; site.load.then(() => { let autoRefreshEnabled = true; diff --git a/ui/bits/src/bits.streamerEdit.ts b/ui/bits/src/bits.streamerEdit.ts index a72e783ae4b..a2e9d228e55 100644 --- a/ui/bits/src/bits.streamerEdit.ts +++ b/ui/bits/src/bits.streamerEdit.ts @@ -1,6 +1,7 @@ -import { wireCropDialog } from './crop'; -import { prompt, choose, alert } from 'lib/view'; import { scopedQuery, frag } from 'lib'; +import { prompt, choose, alert } from 'lib/view'; + +import { wireCropDialog } from './crop'; type Platform = 'youtube' | 'twitch'; type MaybeEl = HTMLElement | null; diff --git a/ui/bits/src/bits.team.ts b/ui/bits/src/bits.team.ts index 3e9ebeb1d65..9380abfaa31 100644 --- a/ui/bits/src/bits.team.ts +++ b/ui/bits/src/bits.team.ts @@ -1,8 +1,9 @@ -import * as xhr from 'lib/xhr'; -import flairPickerLoader from './flairPicker'; -import { wsConnect } from 'lib/socket'; import standaloneChat from 'lib/chat/standalone'; +import { wsConnect } from 'lib/socket'; import { prompt } from 'lib/view'; +import * as xhr from 'lib/xhr'; + +import flairPickerLoader from './flairPicker'; interface TeamOpts { id: string; diff --git a/ui/bits/src/bits.teamBattleForm.ts b/ui/bits/src/bits.teamBattleForm.ts index 4177ab3b7eb..3228619d8d9 100644 --- a/ui/bits/src/bits.teamBattleForm.ts +++ b/ui/bits/src/bits.teamBattleForm.ts @@ -1,7 +1,8 @@ -import * as xhr from 'lib/xhr'; import { Textcomplete } from '@textcomplete/core'; import { TextareaEditor } from '@textcomplete/textarea'; +import * as xhr from 'lib/xhr'; + interface Team { id: string; name: string; diff --git a/ui/bits/src/bits.tourForm.ts b/ui/bits/src/bits.tourForm.ts index 7480712f546..a8c10dd3659 100644 --- a/ui/bits/src/bits.tourForm.ts +++ b/ui/bits/src/bits.tourForm.ts @@ -1,4 +1,5 @@ import flatpickr from 'flatpickr'; + import { use24h } from 'lib/i18n'; site.load.then(() => { diff --git a/ui/bits/src/bits.ts b/ui/bits/src/bits.ts index f9566aca985..83f706e2158 100644 --- a/ui/bits/src/bits.ts +++ b/ui/bits/src/bits.ts @@ -1,7 +1,8 @@ -import { text, formToXhr } from 'lib/xhr'; -import flairPickerLoader from './flairPicker'; import { spinnerHtml } from 'lib/view'; +import { text, formToXhr } from 'lib/xhr'; + import { wireCropDialog } from './crop'; +import flairPickerLoader from './flairPicker'; // avoid node_modules and pay attention to imports here. we don't want to force people // to download the entire toastui editor library just to do some light form processing. diff --git a/ui/bits/src/bits.tvGames.ts b/ui/bits/src/bits.tvGames.ts index 266e93206f8..23e4c86141a 100644 --- a/ui/bits/src/bits.tvGames.ts +++ b/ui/bits/src/bits.tvGames.ts @@ -1,6 +1,6 @@ -import * as xhr from 'lib/xhr'; -import { pubsub } from 'lib/pubsub'; import { api } from 'lib/api'; +import { pubsub } from 'lib/pubsub'; +import * as xhr from 'lib/xhr'; interface ReplacementResponse { id: string; diff --git a/ui/bits/src/bits.ublog.ts b/ui/bits/src/bits.ublog.ts index e5ab20ec767..8c546983c7c 100644 --- a/ui/bits/src/bits.ublog.ts +++ b/ui/bits/src/bits.ublog.ts @@ -1,7 +1,7 @@ -import * as xhr from 'lib/xhr'; -import { alert, prompt, domDialog, spinnerHtml } from 'lib/view'; -import { throttlePromiseDelay } from 'lib/async'; import { escapeHtml } from 'lib'; +import { throttlePromiseDelay } from 'lib/async'; +import { alert, prompt, domDialog, spinnerHtml } from 'lib/view'; +import * as xhr from 'lib/xhr'; site.load.then(() => { $('.flash').addClass('fade'); diff --git a/ui/bits/src/bits.ublogForm.ts b/ui/bits/src/bits.ublogForm.ts index fa8998b0465..70b7eec0c54 100644 --- a/ui/bits/src/bits.ublogForm.ts +++ b/ui/bits/src/bits.ublogForm.ts @@ -1,5 +1,7 @@ -import { throttle } from 'lib/async'; import Tagify from '@yaireo/tagify'; + +import { throttle } from 'lib/async'; + import { wireCropDialog } from './crop'; import { makeToastEditor, getSanitizedMarkdown } from './toastEditor'; diff --git a/ui/bits/src/bits.voiceChat.ts b/ui/bits/src/bits.voiceChat.ts index 7c62323aba3..95a1fd503ba 100644 --- a/ui/bits/src/bits.voiceChat.ts +++ b/ui/bits/src/bits.voiceChat.ts @@ -1,8 +1,9 @@ -import { hl, alert } from 'lib/view'; -import * as licon from 'lib/licon'; import Peer from 'peerjs'; -import { pubsub } from 'lib/pubsub'; + import type { VoiceChat } from 'lib/chat/interfaces'; +import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { hl, alert } from 'lib/view'; type State = | 'off' diff --git a/ui/bits/src/crop.ts b/ui/bits/src/crop.ts index 00359dadec6..aa017ea8221 100644 --- a/ui/bits/src/crop.ts +++ b/ui/bits/src/crop.ts @@ -1,4 +1,5 @@ import { isSafari, isFirefox } from 'lib/device'; + import { type CropOpts } from './bits.cropDialog'; export { type CropOpts } from './bits.cropDialog'; diff --git a/ui/bits/src/toastEditor.ts b/ui/bits/src/toastEditor.ts index b39013cf723..3d63c4b7180 100644 --- a/ui/bits/src/toastEditor.ts +++ b/ui/bits/src/toastEditor.ts @@ -1,11 +1,12 @@ -import type { EditorView as EditorViewType } from 'prosemirror-view'; +import { Editor } from '@toast-ui/editor'; import type { Node as NodeType, Schema as SchemaType } from 'prosemirror-model'; import type { EditorState as EditorStateType } from 'prosemirror-state'; -import { json as xhrJson } from 'lib/xhr'; -import { Editor } from '@toast-ui/editor'; +import type { EditorView as EditorViewType } from 'prosemirror-view'; + import { currentTheme } from 'lib/device'; -import { wireMarkdownImgResizers, wrapImg, naturalSize } from 'lib/view/markdownImgResizer'; import { enter } from 'lib/view'; +import { wireMarkdownImgResizers, wrapImg, naturalSize } from 'lib/view/markdownImgResizer'; +import { json as xhrJson } from 'lib/xhr'; export function makeToastEditor(el: HTMLTextAreaElement, text: string = '', height: string = '60vh'): Editor { const rewire = () => diff --git a/ui/bits/tests/youtubeLinkProcessor.test.ts b/ui/bits/tests/youtubeLinkProcessor.test.ts index e29d47c9ce1..024749467d3 100644 --- a/ui/bits/tests/youtubeLinkProcessor.test.ts +++ b/ui/bits/tests/youtubeLinkProcessor.test.ts @@ -1,5 +1,6 @@ -import { describe, test } from 'node:test'; import assert from 'node:assert/strict'; +import { describe, test } from 'node:test'; + import { embedYoutubeUrl, parseYoutubeUrl } from '../src/youtubeLinkProcessor.ts'; describe('parseYoutubeUrl - realistic URLs & edge cases', () => { diff --git a/ui/botDev/src/analyse.ts b/ui/botDev/src/analyse.ts index b6dc5aca3f2..7a149816dae 100644 --- a/ui/botDev/src/analyse.ts +++ b/ui/botDev/src/analyse.ts @@ -1,7 +1,9 @@ -import { type GameCtrl } from './gameCtrl'; import * as co from 'chessops'; + import { escapeHtml, frag } from 'lib'; + import { env } from './devEnv'; +import { type GameCtrl } from './gameCtrl'; export function analyse(gameCtrl: GameCtrl): void { const local = gameCtrl.live; diff --git a/ui/botDev/src/assetDialog.ts b/ui/botDev/src/assetDialog.ts index 0e21bc658b7..e79f1ec4b10 100644 --- a/ui/botDev/src/assetDialog.ts +++ b/ui/botDev/src/assetDialog.ts @@ -1,9 +1,11 @@ -import { domDialog, type Dialog, alert, confirm } from 'lib/view'; +import { wireCropDialog } from 'bits/crop'; + import { frag } from 'lib'; import * as licon from 'lib/licon'; -import { renderRemoveButton } from './devUtil'; -import { wireCropDialog } from 'bits/crop'; +import { domDialog, type Dialog, alert, confirm } from 'lib/view'; + import { env } from './devEnv'; +import { renderRemoveButton } from './devUtil'; export type AssetType = 'image' | 'book' | 'sound'; diff --git a/ui/botDev/src/booksPane.ts b/ui/botDev/src/booksPane.ts index 8bb501476e8..81908c94c91 100644 --- a/ui/botDev/src/booksPane.ts +++ b/ui/botDev/src/booksPane.ts @@ -1,12 +1,14 @@ -import { Pane, RangeSetting } from './pane'; -import * as licon from 'lib/licon'; -import { frag } from 'lib'; -import type { PaneArgs, BooksInfo, RangeInfo } from './devTypes'; -import type { Book } from 'lib/bot/types'; -import { renderRemoveButton } from './devUtil'; -import { env } from './devEnv'; import { opposite } from 'chessops'; +import { frag } from 'lib'; +import type { Book } from 'lib/bot/types'; +import * as licon from 'lib/licon'; + +import { env } from './devEnv'; +import type { PaneArgs, BooksInfo, RangeInfo } from './devTypes'; +import { renderRemoveButton } from './devUtil'; +import { Pane, RangeSetting } from './pane'; + export class BooksPane extends Pane { info: BooksInfo; template: RangeInfo; diff --git a/ui/botDev/src/botDev.ts b/ui/botDev/src/botDev.ts index 22414f7923c..c24bcb442dc 100644 --- a/ui/botDev/src/botDev.ts +++ b/ui/botDev/src/botDev.ts @@ -1,16 +1,18 @@ +import type { RoundController } from 'round'; import { attributesModule, classModule, init } from 'snabbdom'; -import { GameCtrl } from './gameCtrl'; -import { DevCtrl } from './devCtrl'; + +import { makeZerofish } from 'lib/bot/botLoader'; +import type { LocalPlayOpts, LocalSetup } from 'lib/bot/types'; + import { DevAssets, type AssetList } from './devAssets'; -import { renderDevSide } from './devSideView'; import { DevBotCtrl } from './devBotCtrl'; -import { PushCtrl } from './pushCtrl'; +import { DevCtrl } from './devCtrl'; import { env, makeEnv } from './devEnv'; +import { renderDevSide } from './devSideView'; +import { GameCtrl } from './gameCtrl'; import { renderGameView } from './gameView'; import { LocalDb } from './localDb'; -import type { RoundController } from 'round'; -import type { LocalPlayOpts, LocalSetup } from 'lib/bot/types'; -import { makeZerofish } from 'lib/bot/botLoader'; +import { PushCtrl } from './pushCtrl'; const patch = init([classModule, attributesModule]); diff --git a/ui/botDev/src/botDev.user.ts b/ui/botDev/src/botDev.user.ts index 6ef5479f7b5..33831f9bc5e 100644 --- a/ui/botDev/src/botDev.user.ts +++ b/ui/botDev/src/botDev.user.ts @@ -1,13 +1,15 @@ -import { attributesModule, classModule, init } from 'snabbdom'; -import { showSetupDialog } from './setupDialog'; -import { GameCtrl } from './gameCtrl'; -import { LocalDb } from './localDb'; -import { DevBotCtrl } from './devBotCtrl'; -import { DevAssets } from './devAssets'; -import { env, makeEnv } from './devEnv'; -import { renderGameView } from './gameView'; -import type { LocalPlayOpts, LocalSetup } from 'lib/bot/types'; import type { RoundController } from 'round'; +import { attributesModule, classModule, init } from 'snabbdom'; + +import type { LocalPlayOpts, LocalSetup } from 'lib/bot/types'; + +import { DevAssets } from './devAssets'; +import { DevBotCtrl } from './devBotCtrl'; +import { env, makeEnv } from './devEnv'; +import { GameCtrl } from './gameCtrl'; +import { renderGameView } from './gameView'; +import { LocalDb } from './localDb'; +import { showSetupDialog } from './setupDialog'; const patch = init([classModule, attributesModule]); diff --git a/ui/botDev/src/devAssets.ts b/ui/botDev/src/devAssets.ts index faf96d255ca..7fa21fc43e8 100644 --- a/ui/botDev/src/devAssets.ts +++ b/ui/botDev/src/devAssets.ts @@ -1,11 +1,12 @@ -import { type ObjectStorage, objectStorage } from 'lib/objectStorage'; -import { makeBookFromPolyglot, makeBookFromPgn, type PgnProgress, type PgnFilter } from 'lib/game/polyglot'; -import { botAssetUrl } from 'lib/bot/botLoader'; -import { alert } from 'lib/view'; -import { zip } from 'lib/algo'; -import { env } from './devEnv'; -import { pubsub } from 'lib/pubsub'; import { myUserId } from 'lib'; +import { zip } from 'lib/algo'; +import { botAssetUrl } from 'lib/bot/botLoader'; +import { makeBookFromPolyglot, makeBookFromPgn, type PgnProgress, type PgnFilter } from 'lib/game/polyglot'; +import { type ObjectStorage, objectStorage } from 'lib/objectStorage'; +import { pubsub } from 'lib/pubsub'; +import { alert } from 'lib/view'; + +import { env } from './devEnv'; // dev asset keys are a 12 digit hex hash of the asset contents (plus the file extension for image/sound) // dev asset names are strictly cosmetic and can be renamed at any time diff --git a/ui/botDev/src/devBotCtrl.ts b/ui/botDev/src/devBotCtrl.ts index ca9bc7e0915..64339a451cc 100644 --- a/ui/botDev/src/devBotCtrl.ts +++ b/ui/botDev/src/devBotCtrl.ts @@ -1,15 +1,17 @@ import { type Zerofish } from '@lichess-org/zerofish'; -import { Bot } from 'lib/bot/bot'; -import { RateBot } from './rateBot'; -import { BotLoader, botAssetUrl } from 'lib/bot/botLoader'; -import { type ObjectStorage, objectStorage } from 'lib/objectStorage'; -import { deepFreeze } from 'lib/algo'; -import { pubsub } from 'lib/pubsub'; -import { type OpeningBook, makeBookFromPolyglot } from 'lib/game/polyglot'; -import { env } from './devEnv'; -import type { BotInfo, LocalSpeed, MoveArgs, MoveResult, MoveSource } from 'lib/bot/types'; -import type { CardData } from './handOfCards'; + import { defined } from 'lib'; +import { deepFreeze } from 'lib/algo'; +import { Bot } from 'lib/bot/bot'; +import { BotLoader, botAssetUrl } from 'lib/bot/botLoader'; +import type { BotInfo, LocalSpeed, MoveArgs, MoveResult, MoveSource } from 'lib/bot/types'; +import { type OpeningBook, makeBookFromPolyglot } from 'lib/game/polyglot'; +import { type ObjectStorage, objectStorage } from 'lib/objectStorage'; +import { pubsub } from 'lib/pubsub'; + +import { env } from './devEnv'; +import type { CardData } from './handOfCards'; +import { RateBot } from './rateBot'; const currentBotDbVersion = 3; diff --git a/ui/botDev/src/devCtrl.ts b/ui/botDev/src/devCtrl.ts index da80f6dd33b..051bd93ea5d 100644 --- a/ui/botDev/src/devCtrl.ts +++ b/ui/botDev/src/devCtrl.ts @@ -1,15 +1,16 @@ -import { RateBot, rateBotMatchup } from './rateBot'; -import type { BotInfo, LocalSpeed } from 'lib/bot/types'; -import { statusOf } from 'lib/game'; import { defined, type Prop } from 'lib'; import { shuffle } from 'lib/algo'; +import type { BotInfo, LocalSpeed } from 'lib/bot/types'; +import { statusOf } from 'lib/game'; import { type ObjectStorage, objectStorage } from 'lib/objectStorage'; -import { storedBooleanProp } from 'lib/storage'; -import type { GameStatus, GameContext } from './localGame'; -import { env } from './devEnv'; -import { pubsub } from 'lib/pubsub'; import { type PermaLog, makeLog } from 'lib/permalog'; +import { pubsub } from 'lib/pubsub'; +import { storedBooleanProp } from 'lib/storage'; + +import { env } from './devEnv'; import type { GameObserver } from './gameCtrl'; +import type { GameStatus, GameContext } from './localGame'; +import { RateBot, rateBotMatchup } from './rateBot'; export type Result = { winner?: Color; diff --git a/ui/botDev/src/devEnv.ts b/ui/botDev/src/devEnv.ts index 13698691b48..b2cfc3c6932 100644 --- a/ui/botDev/src/devEnv.ts +++ b/ui/botDev/src/devEnv.ts @@ -1,9 +1,10 @@ +import type { RoundController } from 'round'; + +import type { DevAssets } from './devAssets'; import type { DevBotCtrl } from './devBotCtrl'; import type { DevCtrl } from './devCtrl'; import type { GameCtrl } from './gameCtrl'; import type { LocalDb } from './localDb'; -import type { RoundController } from 'round'; -import type { DevAssets } from './devAssets'; import type { PushCtrl } from './pushCtrl'; export let env: DevEnv; diff --git a/ui/botDev/src/devSideView.ts b/ui/botDev/src/devSideView.ts index aa7d48df259..3998b8881fd 100644 --- a/ui/botDev/src/devSideView.ts +++ b/ui/botDev/src/devSideView.ts @@ -1,16 +1,18 @@ import * as co from 'chessops'; -import { type VNode, hl, onInsert, bind, domDialog } from 'lib/view'; + +import { definedMap } from 'lib/algo'; +import { Bot } from 'lib/bot/bot'; +import type { LocalSpeed, LocalSetup } from 'lib/bot/types'; import * as licon from 'lib/licon'; import { storedBooleanProp, storedIntProp } from 'lib/storage'; -import { EditDialog } from './editDialog'; -import { Bot } from 'lib/bot/bot'; +import { type VNode, hl, onInsert, bind, domDialog } from 'lib/view'; + +import { domIdToUid, uidToDomId } from './devBotCtrl'; +import { env } from './devEnv'; import { resultsString, playersWithResults, rangeTicks } from './devUtil'; +import { EditDialog } from './editDialog'; import { type Drop, type HandOfCards, handOfCards } from './handOfCards'; import { showSetupDialog } from './setupDialog'; -import { domIdToUid, uidToDomId } from './devBotCtrl'; -import { definedMap } from 'lib/algo'; -import type { LocalSpeed, LocalSetup } from 'lib/bot/types'; -import { env } from './devEnv'; export function renderDevSide(): VNode { return hl('div.dev-side.dev-view', [ diff --git a/ui/botDev/src/devTypes.ts b/ui/botDev/src/devTypes.ts index 606fdbeacfe..4f6ae91414f 100644 --- a/ui/botDev/src/devTypes.ts +++ b/ui/botDev/src/devTypes.ts @@ -1,8 +1,9 @@ -import type { Book, SoundEvent, Sound as NamedSound } from 'lib/bot/types'; import type { Requirement, Filter } from 'lib/bot/filter'; -import type { Pane } from './pane'; +import type { Book, SoundEvent, Sound as NamedSound } from 'lib/bot/types'; + import type { AssetType } from './devAssets'; import type { EditDialog } from './editDialog'; +import type { Pane } from './pane'; export type Sound = Omit; diff --git a/ui/botDev/src/devUtil.ts b/ui/botDev/src/devUtil.ts index 9df6573a0eb..15c8e31bf32 100644 --- a/ui/botDev/src/devUtil.ts +++ b/ui/botDev/src/devUtil.ts @@ -1,9 +1,11 @@ import * as co from 'chessops'; -import * as licon from 'lib/licon'; -import type { BotInfo } from 'lib/bot/types'; + import { frag } from 'lib'; -import type { NumberInfo, RangeInfo } from './devTypes'; +import type { BotInfo } from 'lib/bot/types'; +import * as licon from 'lib/licon'; + import type { Result } from './devCtrl'; +import type { NumberInfo, RangeInfo } from './devTypes'; type ObjectPath = { obj: any; path: { keys: string[] } | { id: string } }; diff --git a/ui/botDev/src/editDialog.ts b/ui/botDev/src/editDialog.ts index 965cb71db25..3c29204311d 100644 --- a/ui/botDev/src/editDialog.ts +++ b/ui/botDev/src/editDialog.ts @@ -1,19 +1,21 @@ -import { domIdToUid, uidToDomId, botEquals } from './devBotCtrl'; -import { handOfCards, type HandOfCards } from './handOfCards'; +import stringify from 'json-stringify-pretty-compact'; + import { frag } from 'lib'; import { deepFreeze, definedMap } from 'lib/algo'; -import { buildFromSchema, Panes } from './panes'; -import { deadStrip } from './devUtil'; -import { domDialog, type Dialog, type Action, confirm, alert } from 'lib/view'; -import type { BotInfo } from 'lib/bot/types'; import { Bot } from 'lib/bot/bot'; -import { AssetDialog, type AssetType } from './assetDialog'; -import { historyDialog } from './historyDialog'; -import { env } from './devEnv'; -import { pubsub } from 'lib/pubsub'; +import type { BotInfo } from 'lib/bot/types'; import { Janitor } from 'lib/event'; -import stringify from 'json-stringify-pretty-compact'; import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { domDialog, type Dialog, type Action, confirm, alert } from 'lib/view'; + +import { AssetDialog, type AssetType } from './assetDialog'; +import { domIdToUid, uidToDomId, botEquals } from './devBotCtrl'; +import { env } from './devEnv'; +import { deadStrip } from './devUtil'; +import { handOfCards, type HandOfCards } from './handOfCards'; +import { historyDialog } from './historyDialog'; +import { buildFromSchema, Panes } from './panes'; export class EditDialog { static default: ReadableBot = deepFreeze({ diff --git a/ui/botDev/src/filterPane.ts b/ui/botDev/src/filterPane.ts index af2e1ab2aee..cd53e1d6a3a 100644 --- a/ui/botDev/src/filterPane.ts +++ b/ui/botDev/src/filterPane.ts @@ -1,5 +1,7 @@ -import { Pane } from './pane'; import { Chart, PointElement, LinearScale, LineController, LineElement } from 'chart.js'; + +import { frag } from 'lib'; +import { clamp } from 'lib/algo'; import { addPoint, asData, @@ -10,9 +12,9 @@ import { type FilterBy, type FilterFacetKey, } from 'lib/bot/filter'; -import { frag } from 'lib'; -import { clamp } from 'lib/algo'; + import type { PaneArgs, FilterInfo } from './devTypes'; +import { Pane } from './pane'; type FacetToggle = { el: HTMLElement; input: HTMLInputElement }; diff --git a/ui/botDev/src/gameCtrl.ts b/ui/botDev/src/gameCtrl.ts index ffa5a168820..ca49c4f2b32 100644 --- a/ui/botDev/src/gameCtrl.ts +++ b/ui/botDev/src/gameCtrl.ts @@ -1,12 +1,14 @@ import * as co from 'chessops'; -import { RoundProxy } from './roundProxy'; -import { type GameContext, type GameStatus, LocalGame } from './localGame'; -import { statusOf, clockToSpeed, playable } from 'lib/game'; import type { ClockData } from 'round'; -import type { LocalPlayOpts, LocalSetup, SoundEvent, LocalSpeed } from 'lib/bot/types'; -import { env } from './devEnv'; -import { pubsub } from 'lib/pubsub'; + import { myUserId, myUsername } from 'lib'; +import type { LocalPlayOpts, LocalSetup, SoundEvent, LocalSpeed } from 'lib/bot/types'; +import { statusOf, clockToSpeed, playable } from 'lib/game'; +import { pubsub } from 'lib/pubsub'; + +import { env } from './devEnv'; +import { type GameContext, type GameStatus, LocalGame } from './localGame'; +import { RoundProxy } from './roundProxy'; export interface GameObserver { hurry: boolean; diff --git a/ui/botDev/src/historyDialog.ts b/ui/botDev/src/historyDialog.ts index 424bcb78eb7..3aab46a3113 100644 --- a/ui/botDev/src/historyDialog.ts +++ b/ui/botDev/src/historyDialog.ts @@ -1,11 +1,13 @@ -import { domDialog, type Dialog } from 'lib/view'; -import { frag, escapeHtml, myUserId } from 'lib'; -import * as licon from 'lib/licon'; -import type { EditDialog } from './editDialog'; -import { env } from './devEnv'; -import type { BotInfo } from 'lib/bot/types'; -import stringify from 'json-stringify-pretty-compact'; import diff from 'fast-diff'; +import stringify from 'json-stringify-pretty-compact'; + +import { frag, escapeHtml, myUserId } from 'lib'; +import type { BotInfo } from 'lib/bot/types'; +import * as licon from 'lib/licon'; +import { domDialog, type Dialog } from 'lib/view'; + +import { env } from './devEnv'; +import type { EditDialog } from './editDialog'; interface BotVersionInfo extends Omit { author: string; diff --git a/ui/botDev/src/localDb.ts b/ui/botDev/src/localDb.ts index 346978667d6..5d5ae43c401 100644 --- a/ui/botDev/src/localDb.ts +++ b/ui/botDev/src/localDb.ts @@ -1,8 +1,9 @@ -import { type ObjectStorage, objectStorage, range } from 'lib/objectStorage'; -import { type LocalGame, LocalGameData } from './localGame'; -import { type StatusId, clockToSpeed, status } from 'lib/game'; import { myUserId } from 'lib'; import { hasFeature } from 'lib/device'; +import { type StatusId, clockToSpeed, status } from 'lib/game'; +import { type ObjectStorage, objectStorage, range } from 'lib/objectStorage'; + +import { type LocalGame, LocalGameData } from './localGame'; export class LocalDb { store: ObjectStorage | undefined; diff --git a/ui/botDev/src/localGame.ts b/ui/botDev/src/localGame.ts index 68462de4c88..a5d0ed8d41e 100644 --- a/ui/botDev/src/localGame.ts +++ b/ui/botDev/src/localGame.ts @@ -1,9 +1,10 @@ import * as co from 'chessops'; -import { normalMove } from 'lib/game/chess'; -import { type Status, type RoundStep, statusOf } from 'lib/game'; + import { deepFreeze, randomId } from 'lib/algo'; -import { hashBoard } from 'lib/game/hash'; import type { LocalSetup } from 'lib/bot/types'; +import { type Status, type RoundStep, statusOf } from 'lib/game'; +import { normalMove } from 'lib/game/chess'; +import { hashBoard } from 'lib/game/hash'; type LocalMove = { uci: Uci; diff --git a/ui/botDev/src/pane.ts b/ui/botDev/src/pane.ts index fed9358bf75..b4a30a1acc5 100644 --- a/ui/botDev/src/pane.ts +++ b/ui/botDev/src/pane.ts @@ -1,7 +1,5 @@ -import { removeObjectProperty, setObjectProperty, maxChars } from './devUtil'; import { frag } from 'lib'; -import { getSchemaDefault, requiresOpRe } from './schema'; -import type { EditDialog } from './editDialog'; + import { env } from './devEnv'; import type { PaneArgs, @@ -15,6 +13,9 @@ import type { PropertyValue, Requirement, } from './devTypes'; +import { removeObjectProperty, setObjectProperty, maxChars } from './devUtil'; +import type { EditDialog } from './editDialog'; +import { getSchemaDefault, requiresOpRe } from './schema'; export class Pane { input?: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; diff --git a/ui/botDev/src/panes.ts b/ui/botDev/src/panes.ts index 69f333cd315..7176dab2ef4 100644 --- a/ui/botDev/src/panes.ts +++ b/ui/botDev/src/panes.ts @@ -1,12 +1,13 @@ -import { schema, infoKeys } from './schema'; -import { Pane, SelectSetting, RangeSetting, TextareaSetting, TextSetting, NumberSetting } from './pane'; -import { FilterPane } from './filterPane'; -import { SoundEventPane } from './soundEventPane'; -import { BooksPane } from './booksPane'; -import type { EditDialog } from './editDialog'; -import type { PaneInfo, InfoKey } from './devTypes'; import type { ActionListener, Action } from 'lib/view'; +import { BooksPane } from './booksPane'; +import type { PaneInfo, InfoKey } from './devTypes'; +import type { EditDialog } from './editDialog'; +import { FilterPane } from './filterPane'; +import { Pane, SelectSetting, RangeSetting, TextareaSetting, TextSetting, NumberSetting } from './pane'; +import { schema, infoKeys } from './schema'; +import { SoundEventPane } from './soundEventPane'; + export class Panes { byId: Record = {}; diff --git a/ui/botDev/src/pushCtrl.ts b/ui/botDev/src/pushCtrl.ts index afdffb98ebf..ce17f6a47fd 100644 --- a/ui/botDev/src/pushCtrl.ts +++ b/ui/botDev/src/pushCtrl.ts @@ -1,5 +1,6 @@ -import type { BotInfo } from 'lib/bot/types'; import { defined, myUserId } from 'lib'; +import type { BotInfo } from 'lib/bot/types'; + import type { AssetBlob, AssetType } from './devAssets'; import { env } from './devEnv'; diff --git a/ui/botDev/src/rateBot.ts b/ui/botDev/src/rateBot.ts index e59b4a299de..a670e18dc05 100644 --- a/ui/botDev/src/rateBot.ts +++ b/ui/botDev/src/rateBot.ts @@ -1,9 +1,11 @@ import * as co from 'chessops'; + import { clamp } from 'lib/algo'; -import { botScore } from './devUtil'; import type { BotInfo, MoveSource, MoveResult, MoveArgs, Book, Ratings } from 'lib/bot/types'; + import type { Result, Matchup, Glicko } from './devCtrl'; import { env } from './devEnv'; +import { botScore } from './devUtil'; // ratings in context of classical Computer Chess Rating Lists (CCRL) where goldfish 1.13 = 2000 // goldfish is an intentionally weakened Stockfish derivative for an approximate bridge to FIDE Elo. diff --git a/ui/botDev/src/roundProxy.ts b/ui/botDev/src/roundProxy.ts index 4ad52cd7f6a..a8cc81a4d0d 100644 --- a/ui/botDev/src/roundProxy.ts +++ b/ui/botDev/src/roundProxy.ts @@ -1,11 +1,13 @@ import * as co from 'chessops'; -import { showSetupDialog } from './setupDialog'; -import { LocalGame } from './localGame'; -import { type Player, clockToSpeed } from 'lib/game'; import type { RoundProxy as RoundProxyType, RoundData, RoundOpts } from 'round'; + +import { myUserId } from 'lib'; +import { type Player, clockToSpeed } from 'lib/game'; + import { analyse } from './analyse'; import { env } from './devEnv'; -import { myUserId } from 'lib'; +import { LocalGame } from './localGame'; +import { showSetupDialog } from './setupDialog'; export class RoundProxy implements RoundProxyType { readonly data: RoundData; diff --git a/ui/botDev/src/schema.ts b/ui/botDev/src/schema.ts index bec9d307907..22b18e4a3ca 100644 --- a/ui/botDev/src/schema.ts +++ b/ui/botDev/src/schema.ts @@ -1,8 +1,9 @@ -import type { Schema, InfoKey, PropertyValue } from './devTypes'; import { memoize } from 'lib'; +import { deepFreeze } from 'lib/algo'; import { Bot } from 'lib/bot/bot'; import type { FilterSpec } from 'lib/bot/filter'; -import { deepFreeze } from 'lib/algo'; + +import type { Schema, InfoKey, PropertyValue } from './devTypes'; // describe dialog content, define constraints, maps to Bot instance data diff --git a/ui/botDev/src/setupDialog.ts b/ui/botDev/src/setupDialog.ts index f0235034ca5..392a446442c 100644 --- a/ui/botDev/src/setupDialog.ts +++ b/ui/botDev/src/setupDialog.ts @@ -1,17 +1,19 @@ -import { handOfCards, type HandOfCards } from './handOfCards'; import * as co from 'chessops'; -import { domDialog, type Dialog } from 'lib/view'; -import { fen960 } from 'lib/game/chess'; -import { pubsub } from 'lib/pubsub'; -import { definedMap, clamp } from 'lib/algo'; -import { domIdToUid, uidToDomId } from './devBotCtrl'; -import { rangeTicks } from './devUtil'; -import type { LocalSetup } from 'lib/bot/types'; -import { env } from './devEnv'; -import * as licon from 'lib/licon'; import type { LichessEditor } from 'editor'; -import { json } from 'lib/xhr'; + +import { definedMap, clamp } from 'lib/algo'; +import type { LocalSetup } from 'lib/bot/types'; import { Janitor } from 'lib/event'; +import { fen960 } from 'lib/game/chess'; +import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { domDialog, type Dialog } from 'lib/view'; +import { json } from 'lib/xhr'; + +import { domIdToUid, uidToDomId } from './devBotCtrl'; +import { env } from './devEnv'; +import { rangeTicks } from './devUtil'; +import { handOfCards, type HandOfCards } from './handOfCards'; export function showSetupDialog(setup: LocalSetup = {}): void { pubsub.after('botdev.images.ready').then(() => new SetupDialog(setup).show()); diff --git a/ui/botDev/src/soundEventPane.ts b/ui/botDev/src/soundEventPane.ts index 78235ac5559..85b0e419329 100644 --- a/ui/botDev/src/soundEventPane.ts +++ b/ui/botDev/src/soundEventPane.ts @@ -1,10 +1,11 @@ -import { Pane } from './pane'; -import * as licon from 'lib/licon'; import { frag } from 'lib'; -import type { PaneArgs, SoundEventInfo, Template, SoundsInfo, Sound as TemplateSound } from './devTypes'; import type { Sound } from 'lib/bot/types'; -import { renderRemoveButton } from './devUtil'; +import * as licon from 'lib/licon'; + import { env } from './devEnv'; +import type { PaneArgs, SoundEventInfo, Template, SoundsInfo, Sound as TemplateSound } from './devTypes'; +import { renderRemoveButton } from './devUtil'; +import { Pane } from './pane'; export class SoundEventPane extends Pane { info: SoundEventInfo; diff --git a/ui/botPlay/src/botCtrl.ts b/ui/botPlay/src/botCtrl.ts index 6fa6866bc75..4ed97bae9f9 100644 --- a/ui/botPlay/src/botCtrl.ts +++ b/ui/botPlay/src/botCtrl.ts @@ -1,18 +1,20 @@ -import SetupCtrl from './setup/setupCtrl'; -import PlayCtrl from './play/playCtrl'; -import type { BotOpts, LocalBridge } from './interfaces'; -import { type BotInfo } from 'lib/bot/types'; -import { BotLoader } from 'lib/bot/botLoader'; -import { setupView } from './setup/view/setupView'; -import { playView } from './play/view/playView'; -import { alert } from 'lib/view'; import { opposite } from 'chessops'; -import { Game } from './game'; -import { debugCli } from './debug'; -import { pubsub } from 'lib/pubsub'; -import { loadCurrentGame, saveCurrentGame } from './storage'; + +import { BotLoader } from 'lib/bot/botLoader'; +import { type BotInfo } from 'lib/bot/types'; import type { ClockConfig } from 'lib/game/clock/clockCtrl'; +import { pubsub } from 'lib/pubsub'; import type { ColorChoice } from 'lib/setup/color'; +import { alert } from 'lib/view'; + +import { debugCli } from './debug'; +import { Game } from './game'; +import type { BotOpts, LocalBridge } from './interfaces'; +import PlayCtrl from './play/playCtrl'; +import { playView } from './play/view/playView'; +import SetupCtrl from './setup/setupCtrl'; +import { setupView } from './setup/view/setupView'; +import { loadCurrentGame, saveCurrentGame } from './storage'; export class BotCtrl { setupCtrl: SetupCtrl; diff --git a/ui/botPlay/src/botPlay.main.ts b/ui/botPlay/src/botPlay.main.ts index 395a966078f..d8b3ce3fb7c 100644 --- a/ui/botPlay/src/botPlay.main.ts +++ b/ui/botPlay/src/botPlay.main.ts @@ -1,7 +1,7 @@ import { init, classModule, attributesModule, eventListenersModule } from 'snabbdom'; -import type { BotOpts } from './interfaces'; import { BotCtrl } from './botCtrl'; +import type { BotOpts } from './interfaces'; export async function initModule(opts: BotOpts) { const element = document.querySelector('main.bot-play') as HTMLElement, diff --git a/ui/botPlay/src/chess.ts b/ui/botPlay/src/chess.ts index b82a9518065..cf3121fac9c 100644 --- a/ui/botPlay/src/chess.ts +++ b/ui/botPlay/src/chess.ts @@ -1,6 +1,6 @@ import { Chess, type Move as ChessMove } from 'chessops'; -import { makeSanAndPlay } from 'chessops/san'; import { normalizeMove } from 'chessops/chess'; +import { makeSanAndPlay } from 'chessops/san'; /* The currently displayed position, not necessarily the last one played */ export interface Board { diff --git a/ui/botPlay/src/clock.ts b/ui/botPlay/src/clock.ts index 705dba8aaf7..ce27f9d468d 100644 --- a/ui/botPlay/src/clock.ts +++ b/ui/botPlay/src/clock.ts @@ -1,6 +1,7 @@ import type { SetData as ClockState } from 'lib/game/clock/clockCtrl'; -import type { DateMillis } from './interfaces'; + import type { Game } from './game'; +import type { DateMillis } from './interfaces'; export const computeClockState = (g: Game): ClockState | undefined => { const config = g.clockConfig; diff --git a/ui/botPlay/src/game.ts b/ui/botPlay/src/game.ts index dfd541216b1..388b4365f24 100644 --- a/ui/botPlay/src/game.ts +++ b/ui/botPlay/src/game.ts @@ -1,13 +1,15 @@ import { Chess, type Move as ChessMove, opposite } from 'chessops'; +import { normalizeMove } from 'chessops/chess'; import { makeFen, parseFen } from 'chessops/fen'; import { defaultGame, parsePgn, type PgnNodeData, type Game as PgnGame } from 'chessops/pgn'; -import type { ClockConfig, SetData as ClockState } from 'lib/game/clock/clockCtrl'; -import type { BotKey, GameData, GameEnd, GameId, Move } from './interfaces'; -import type { Board } from './chess'; import { makeSan, parseSan } from 'chessops/san'; -import { normalizeMove } from 'chessops/chess'; + import { randomId } from 'lib/algo'; +import type { ClockConfig, SetData as ClockState } from 'lib/game/clock/clockCtrl'; + +import type { Board } from './chess'; import { computeClockState } from './clock'; +import type { BotKey, GameData, GameEnd, GameId, Move } from './interfaces'; export class Game { constructor(readonly data: GameData) { diff --git a/ui/botPlay/src/ground.ts b/ui/botPlay/src/ground.ts index 58e09fc3f7c..206fb8da804 100644 --- a/ui/botPlay/src/ground.ts +++ b/ui/botPlay/src/ground.ts @@ -1,14 +1,16 @@ +import { makeUci } from 'chessops'; +import { chessgroundDests, chessgroundMove } from 'chessops/compat'; +import { makeFen } from 'chessops/fen'; +import { h } from 'snabbdom'; + import resizeHandle from 'lib/chessgroundResize'; -import type PlayCtrl from './play/playCtrl'; import { ShowResizeHandle, Coords, MoveEvent } from 'lib/prefs'; import { storage } from 'lib/storage'; -import { makeFen } from 'chessops/fen'; -import { chessgroundDests, chessgroundMove } from 'chessops/compat'; -import type { Board } from './chess'; -import { h } from 'snabbdom'; import { initMiniBoard } from 'lib/view'; -import { makeUci } from 'chessops'; + +import type { Board } from './chess'; import type { Game } from './game'; +import type PlayCtrl from './play/playCtrl'; export const updateGround = (game: Game, board: Board): CgConfig => { const onLastPosition = board.onPly === game.ply(); diff --git a/ui/botPlay/src/interfaces.ts b/ui/botPlay/src/interfaces.ts index f3a69be4c0e..3813392bea4 100644 --- a/ui/botPlay/src/interfaces.ts +++ b/ui/botPlay/src/interfaces.ts @@ -1,7 +1,7 @@ import type { BotInfo, MoveSource, SoundEvent } from 'lib/bot/types'; import type { StatusName } from 'lib/game'; -import * as Prefs from 'lib/prefs'; import type { ClockConfig } from 'lib/game/clock/clockCtrl'; +import * as Prefs from 'lib/prefs'; export type DateMillis = number; // local millis since Unix epoch = Date.getTime() diff --git a/ui/botPlay/src/play/botMove.ts b/ui/botPlay/src/play/botMove.ts index 57e4418c92f..1ddaec01cef 100644 --- a/ui/botPlay/src/play/botMove.ts +++ b/ui/botPlay/src/play/botMove.ts @@ -1,10 +1,12 @@ import { type Chess, makeUci, type Move, parseUci } from 'chessops'; -import type { MoveArgs, MoveSource } from 'lib/bot/types'; -import type { Game } from '../game'; import { INITIAL_FEN } from 'chessops/fen'; import { parseSan } from 'chessops/san'; + +import type { MoveArgs, MoveSource } from 'lib/bot/types'; import { hashBoard } from 'lib/game/hash'; +import type { Game } from '../game'; + export const requestBotMove = async (source: MoveSource, game: Game): Promise => { const now = performance.now(); diff --git a/ui/botPlay/src/play/keyboard.ts b/ui/botPlay/src/play/keyboard.ts index 7b7ccc94a1e..e8fa45a3235 100644 --- a/ui/botPlay/src/play/keyboard.ts +++ b/ui/botPlay/src/play/keyboard.ts @@ -1,4 +1,5 @@ import { pubsub } from 'lib/pubsub'; + import PlayCtrl from './playCtrl'; export default function keyboard(ctrl: PlayCtrl): void { diff --git a/ui/botPlay/src/play/playCtrl.ts b/ui/botPlay/src/play/playCtrl.ts index 08cbc86c5a5..6eb6f3be864 100644 --- a/ui/botPlay/src/play/playCtrl.ts +++ b/ui/botPlay/src/play/playCtrl.ts @@ -1,17 +1,19 @@ import { opposite, parseSquare } from 'chessops'; -import type { Bot, LocalBridge, Move, Pref } from '../interfaces'; import { normalizeMove } from 'chessops/chess'; + +import { prop, toggle, type Toggle } from 'lib'; +import type { TopOrBottom } from 'lib/game'; +import { ClockCtrl, type ClockOpts } from 'lib/game/clock/clockCtrl'; +import type { WithGround } from 'lib/game/ground'; +import { PromotionCtrl } from 'lib/game/promotion'; + import type { Board } from '../chess'; +import { Game } from '../game'; +import { initialGround, updateGround } from '../ground'; +import type { Bot, LocalBridge, Move, Pref } from '../interfaces'; import { requestBotMove } from './botMove'; import keyboard from './keyboard'; -import { initialGround, updateGround } from '../ground'; -import { Game } from '../game'; -import { prop, toggle, type Toggle } from 'lib'; import { playMoveSounds } from './sound'; -import { PromotionCtrl } from 'lib/game/promotion'; -import type { WithGround } from 'lib/game/ground'; -import { ClockCtrl, type ClockOpts } from 'lib/game/clock/clockCtrl'; -import type { TopOrBottom } from 'lib/game'; export interface PlayOpts { pref: Pref; diff --git a/ui/botPlay/src/play/sound.ts b/ui/botPlay/src/play/sound.ts index 3daea74c70d..26e5c27ac94 100644 --- a/ui/botPlay/src/play/sound.ts +++ b/ui/botPlay/src/play/sound.ts @@ -1,7 +1,9 @@ import { type SoundEvent } from 'lib/bot/types'; -import PlayCtrl from './playCtrl'; + import type { Move } from '@/interfaces'; +import PlayCtrl from './playCtrl'; + export const playMoveSounds = async (ctrl: PlayCtrl, move: Move) => { const san = move.san; const sounds: SoundEvent[] = []; diff --git a/ui/botPlay/src/play/view/autoScroll.ts b/ui/botPlay/src/play/view/autoScroll.ts index a2150ffb0c8..f1cfd29cc02 100644 --- a/ui/botPlay/src/play/view/autoScroll.ts +++ b/ui/botPlay/src/play/view/autoScroll.ts @@ -1,7 +1,8 @@ import { throttle } from 'lib/async'; -import PlayCtrl from '../playCtrl'; import { displayColumns } from 'lib/device'; +import PlayCtrl from '../playCtrl'; + const scrollMax = 99999; export const autoScroll = throttle(100, (movesEl: HTMLElement, ctrl: PlayCtrl) => diff --git a/ui/botPlay/src/play/view/boardMenu.ts b/ui/botPlay/src/play/view/boardMenu.ts index d93cbb40ffa..76e068a2a60 100644 --- a/ui/botPlay/src/play/view/boardMenu.ts +++ b/ui/botPlay/src/play/view/boardMenu.ts @@ -1,5 +1,7 @@ import { h } from 'snabbdom'; + import { type LooseVNode, boardMenu as menuDropdown } from 'lib/view'; + import type PlayCtrl from '../playCtrl'; // import { toggle } from 'lib'; // import { boolPrefXhrToggle } from 'lib/view'; diff --git a/ui/botPlay/src/play/view/playView.ts b/ui/botPlay/src/play/view/playView.ts index 8699ed5e265..8b2ff0af1b8 100644 --- a/ui/botPlay/src/play/view/playView.ts +++ b/ui/botPlay/src/play/view/playView.ts @@ -1,4 +1,14 @@ +import { Chessground } from '@lichess-org/chessground'; + +import { repeater } from 'lib'; +import { type BotInfo, Bot } from 'lib/bot/bot'; +import { botAssetUrl } from 'lib/bot/botLoader'; +import { type TopOrBottom } from 'lib/game'; +import { renderClock } from 'lib/game/clock/clockView'; +import { renderMaterialDiffs } from 'lib/game/view/material'; +import { type StatusData, statusOf as viewStatus } from 'lib/game/view/status'; import * as licon from 'lib/licon'; +import { addPointerListeners } from 'lib/pointer'; import { bind, hl, @@ -9,21 +19,14 @@ import { stepwiseScroll, toggleButton as boardMenuToggleButton, } from 'lib/view'; -import { Chessground } from '@lichess-org/chessground'; -import type PlayCtrl from '../playCtrl'; -import { initialGround } from '@/ground'; -import { botAssetUrl } from 'lib/bot/botLoader'; -import { type BotInfo, Bot } from 'lib/bot/bot'; -import { autoScroll } from './autoScroll'; -import { repeater } from 'lib'; -import { addPointerListeners } from 'lib/pointer'; -import { type StatusData, statusOf as viewStatus } from 'lib/game/view/status'; -import boardMenu from './boardMenu'; -import { renderMaterialDiffs } from 'lib/game/view/material'; -import { type TopOrBottom } from 'lib/game'; -import { renderClock } from 'lib/game/clock/clockView'; import { renderBlindfoldToggle } from 'lib/view/blindfold'; +import { initialGround } from '@/ground'; + +import type PlayCtrl from '../playCtrl'; +import { autoScroll } from './autoScroll'; +import boardMenu from './boardMenu'; + export const playView = (ctrl: PlayCtrl) => hl(`main.bot-app.bot-game.unique-game-${ctrl.game.id}.bot-color--${ctrl.opts.bot.key}`, [ renderBlindfoldToggle(ctrl.blindfold), diff --git a/ui/botPlay/src/setup/setupCtrl.ts b/ui/botPlay/src/setup/setupCtrl.ts index a0dd1ada22c..e272c15d72d 100644 --- a/ui/botPlay/src/setup/setupCtrl.ts +++ b/ui/botPlay/src/setup/setupCtrl.ts @@ -1,13 +1,14 @@ -import type { Bot, BotOpts } from '../interfaces'; -import { type BotInfo } from 'lib/bot/types'; -import { Game } from '../game'; import { type Prop, prop, propWithEffect } from 'lib'; -import { type TimeControl, timeControlFromStoredValues } from 'lib/setup/timeControl'; -import { storedJsonProp } from 'lib/storage'; +import { type BotInfo } from 'lib/bot/types'; import type { ClockConfig } from 'lib/game/clock/clockCtrl'; import type { ColorChoice, ColorProp } from 'lib/setup/color'; +import { type TimeControl, timeControlFromStoredValues } from 'lib/setup/timeControl'; +import { storedJsonProp } from 'lib/storage'; import type { Dialog } from 'lib/view'; +import { Game } from '../game'; +import type { Bot, BotOpts } from '../interfaces'; + interface Settings { color: ColorChoice; clock: boolean; diff --git a/ui/botPlay/src/setup/view/setupDialog.ts b/ui/botPlay/src/setup/view/setupDialog.ts index 59b7c1a621c..66bc3db9087 100644 --- a/ui/botPlay/src/setup/view/setupDialog.ts +++ b/ui/botPlay/src/setup/view/setupDialog.ts @@ -1,10 +1,11 @@ -import { snabDialog, bind, hl } from 'lib/view'; -import type SetupCtrl from '../setupCtrl'; import { botAssetUrl } from 'lib/bot/botLoader'; -import { colorButtons } from 'lib/setup/view/color'; -import { colors } from 'lib/setup/color'; -import { timePickerAndSliders } from 'lib/setup/view/timeControl'; import { pubsub } from 'lib/pubsub'; +import { colors } from 'lib/setup/color'; +import { colorButtons } from 'lib/setup/view/color'; +import { timePickerAndSliders } from 'lib/setup/view/timeControl'; +import { snabDialog, bind, hl } from 'lib/view'; + +import type SetupCtrl from '../setupCtrl'; export const setupDialog = (ctrl: SetupCtrl) => { const bot = ctrl.selectedBot; diff --git a/ui/botPlay/src/setup/view/setupView.ts b/ui/botPlay/src/setup/view/setupView.ts index fc60636def5..faa6349a0f3 100644 --- a/ui/botPlay/src/setup/view/setupView.ts +++ b/ui/botPlay/src/setup/view/setupView.ts @@ -1,8 +1,10 @@ import { botAssetUrl } from 'lib/bot/botLoader'; import { bind, hl } from 'lib/view'; -import type SetupCtrl from '../setupCtrl'; + import { miniBoard } from '@/ground'; import { type Bot } from '@/interfaces'; + +import type SetupCtrl from '../setupCtrl'; import { setupDialog } from './setupDialog'; export const setupView = (ctrl: SetupCtrl) => diff --git a/ui/botPlay/src/storage.ts b/ui/botPlay/src/storage.ts index a4d331f5507..31846880464 100644 --- a/ui/botPlay/src/storage.ts +++ b/ui/botPlay/src/storage.ts @@ -1,4 +1,5 @@ import { storedJsonProp } from 'lib/storage'; + import { Game } from './game'; import type { GameData } from './interfaces'; diff --git a/ui/challenge/src/challenge.ts b/ui/challenge/src/challenge.ts index f253bbcecef..1eb061e03e2 100644 --- a/ui/challenge/src/challenge.ts +++ b/ui/challenge/src/challenge.ts @@ -1,8 +1,10 @@ import { init, type VNode, classModule, attributesModule } from 'snabbdom'; -import ChallengeCtrl from './ctrl'; -import { loaded, loading } from './view'; + import { json } from 'lib/xhr'; + +import ChallengeCtrl from './ctrl'; import type { ChallengeOpts, ChallengeData } from './interfaces'; +import { loaded, loading } from './view'; const patch = init([classModule, attributesModule]); diff --git a/ui/challenge/src/ctrl.ts b/ui/challenge/src/ctrl.ts index b7680a6b469..5d9283e0c80 100644 --- a/ui/challenge/src/ctrl.ts +++ b/ui/challenge/src/ctrl.ts @@ -1,5 +1,6 @@ -import { text as xhrText, form as xhrForm } from 'lib/xhr'; import { once } from 'lib/storage'; +import { text as xhrText, form as xhrForm } from 'lib/xhr'; + import type { ChallengeOpts, ChallengeData, Reasons } from './interfaces'; export default class ChallengeCtrl { diff --git a/ui/challenge/src/view.ts b/ui/challenge/src/view.ts index c1d8676ed97..70657979659 100644 --- a/ui/challenge/src/view.ts +++ b/ui/challenge/src/view.ts @@ -1,10 +1,12 @@ -import type { Challenge, ChallengeData, ChallengeDirection, ChallengeUser, TimeControl } from './interfaces'; +import { opposite } from '@lichess-org/chessground/util'; import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; import { spinnerVdom, initMiniBoard } from 'lib/view'; import { userLink } from 'lib/view/userLink'; -import { opposite } from '@lichess-org/chessground/util'; + import type ChallengeCtrl from './ctrl'; +import type { Challenge, ChallengeData, ChallengeDirection, ChallengeUser, TimeControl } from './interfaces'; export const loaded = (ctrl: ChallengeCtrl): VNode => ctrl.redirecting diff --git a/ui/chart/src/acpl.ts b/ui/chart/src/acpl.ts index c52dad225c6..c62ac5a7076 100644 --- a/ui/chart/src/acpl.ts +++ b/ui/chart/src/acpl.ts @@ -1,4 +1,3 @@ -import { winningChances } from 'lib/ceval'; import { type ChartConfiguration, type ChartDataset, @@ -11,6 +10,14 @@ import { PointElement, Tooltip, } from 'chart.js'; +import ChartDataLabels from 'chartjs-plugin-datalabels'; + +import { winningChances } from 'lib/ceval'; +import { plyToTurn } from 'lib/game/chess'; +import { pubsub } from 'lib/pubsub'; +import type { TreeNode, TreeNodeIncomplete } from 'lib/tree/types'; + +import division from './division'; import { blackFill, fontColor, @@ -23,12 +30,7 @@ import { whiteFill, axisOpts, } from './index'; -import division from './division'; import type { AcplChart, AnalyseData, Player } from './interface'; -import ChartDataLabels from 'chartjs-plugin-datalabels'; -import { pubsub } from 'lib/pubsub'; -import { plyToTurn } from 'lib/game/chess'; -import type { TreeNode, TreeNodeIncomplete } from 'lib/tree/types'; Chart.register(LineController, LinearScale, PointElement, LineElement, Tooltip, Filler, ChartDataLabels); export default async function ( diff --git a/ui/chart/src/chart.game.ts b/ui/chart/src/chart.game.ts index 9269dc3ae11..2f0d8ad1251 100644 --- a/ui/chart/src/chart.game.ts +++ b/ui/chart/src/chart.game.ts @@ -1,7 +1,7 @@ -import type { ChartGame, AcplChart } from './interface'; -import movetime from './movetime'; import acpl from './acpl'; import { gridColor, tooltipBgColor, fontFamily, maybeChart, colorSeries } from './index'; +import type { ChartGame, AcplChart } from './interface'; +import movetime from './movetime'; export { type ChartGame, type AcplChart }; diff --git a/ui/chart/src/chart.lag.ts b/ui/chart/src/chart.lag.ts index 12147e38adf..7ca4d615c49 100644 --- a/ui/chart/src/chart.lag.ts +++ b/ui/chart/src/chart.lag.ts @@ -8,10 +8,12 @@ import { Title, } from 'chart.js'; import dataLabels from 'chartjs-plugin-datalabels'; -import { fontColor, fontFamily } from './index'; + import { pubsub } from 'lib/pubsub'; import { wsSend, wsAverageLag } from 'lib/socket'; +import { fontColor, fontFamily } from './index'; + declare module 'chart.js' { // oxlint-disable-next-line no-unused-vars interface PluginOptionsByType { diff --git a/ui/chart/src/chart.ratingDistribution.ts b/ui/chart/src/chart.ratingDistribution.ts index bfb1a35d4c6..b28f70894b3 100644 --- a/ui/chart/src/chart.ratingDistribution.ts +++ b/ui/chart/src/chart.ratingDistribution.ts @@ -1,5 +1,3 @@ -import { fontFamily, gridColor, hoverBorderColor } from './index'; -import type { DistributionData } from './interface'; import { type ChartConfiguration, type ChartData, @@ -15,6 +13,9 @@ import { } from 'chart.js'; import ChartDataLabels from 'chartjs-plugin-datalabels'; +import { fontFamily, gridColor, hoverBorderColor } from './index'; +import type { DistributionData } from './interface'; + Chart.register(LineController, LinearScale, PointElement, LineElement, Tooltip, Filler, ChartDataLabels); export async function initModule(data: DistributionData): Promise { diff --git a/ui/chart/src/chart.ratingHistory.ts b/ui/chart/src/chart.ratingHistory.ts index 33f04b086dc..7eb1736fd54 100644 --- a/ui/chart/src/chart.ratingHistory.ts +++ b/ui/chart/src/chart.ratingHistory.ts @@ -1,3 +1,4 @@ +import 'chartjs-adapter-dayjs-4'; import { type ChartDataset, type Point, @@ -11,18 +12,19 @@ import { Tooltip, LineElement, } from 'chart.js'; -import type { PerfRatingHistory } from './interface'; -import { fontColor, fontFamily, gridColor, hoverBorderColor, tooltipBgColor } from './index'; -import 'chartjs-adapter-dayjs-4'; import zoomPlugin from 'chartjs-plugin-zoom'; -import noUiSlider, { type Options, PipsMode } from 'nouislider'; import dayjs from 'dayjs'; -import duration from 'dayjs/plugin/duration'; import dayOfYear from 'dayjs/plugin/dayOfYear'; +import duration from 'dayjs/plugin/duration'; import utc from 'dayjs/plugin/utc'; +import noUiSlider, { type Options, PipsMode } from 'nouislider'; + import { memoize } from 'lib'; import { pubsub } from 'lib/pubsub'; +import { fontColor, fontFamily, gridColor, hoverBorderColor, tooltipBgColor } from './index'; +import type { PerfRatingHistory } from './interface'; + interface Opts { data: PerfRatingHistory[]; singlePerfName?: string; diff --git a/ui/chart/src/chart.relayStats.ts b/ui/chart/src/chart.relayStats.ts index 908c03df109..22a19921114 100644 --- a/ui/chart/src/chart.relayStats.ts +++ b/ui/chart/src/chart.relayStats.ts @@ -1,10 +1,12 @@ -import type { RoundStats } from './interface'; -import * as chart from 'chart.js'; import 'chartjs-adapter-dayjs-4'; -import { hoverBorderColor, gridColor, tooltipBgColor, fontColor, fontFamily } from './index'; -import { memoize, notNull } from 'lib'; +import * as chart from 'chart.js'; import ChartDataLabels from 'chartjs-plugin-datalabels'; +import { memoize, notNull } from 'lib'; + +import { hoverBorderColor, gridColor, tooltipBgColor, fontColor, fontFamily } from './index'; +import type { RoundStats } from './interface'; + chart.Chart.register( chart.PointElement, chart.TimeScale, diff --git a/ui/chart/src/division.ts b/ui/chart/src/division.ts index 5c409179a30..8402d6c0d65 100644 --- a/ui/chart/src/division.ts +++ b/ui/chart/src/division.ts @@ -1,6 +1,7 @@ +import type { ChartDataset, Point } from 'chart.js'; + import { chartYMax, chartYMin } from './index'; import type { Division } from './interface'; -import type { ChartDataset, Point } from 'chart.js'; export default function (div?: Division): ChartDataset<'line'>[] { const lines: { div: string; loc: number }[] = []; diff --git a/ui/chart/src/index.ts b/ui/chart/src/index.ts index 306b875e432..13f1afcaa15 100644 --- a/ui/chart/src/index.ts +++ b/ui/chart/src/index.ts @@ -1,4 +1,5 @@ import { Chart, type ChartDataset, type ChartOptions } from 'chart.js'; + import { currentTheme } from 'lib/device'; export interface MovePoint { diff --git a/ui/chart/src/interface.ts b/ui/chart/src/interface.ts index 99dc7aa7936..f83613c1336 100644 --- a/ui/chart/src/interface.ts +++ b/ui/chart/src/interface.ts @@ -1,4 +1,5 @@ import type { Chart } from 'chart.js'; + import type { TreeNode, TreeNodeIncomplete } from 'lib/tree/types'; export interface PlyChart extends Chart<'line'> { diff --git a/ui/chart/src/movetime.ts b/ui/chart/src/movetime.ts index 2ebda4287dc..4314d622830 100644 --- a/ui/chart/src/movetime.ts +++ b/ui/chart/src/movetime.ts @@ -10,6 +10,11 @@ import { type PointStyle, Tooltip, } from 'chart.js'; +import { COLORS } from 'chessops'; + +import { pubsub } from 'lib/pubsub'; + +import division from './division'; import { type MovePoint, blackFill, @@ -24,9 +29,6 @@ import { axisOpts, } from './index'; import type { AnalyseData, Player, PlyChart } from './interface'; -import division from './division'; -import { pubsub } from 'lib/pubsub'; -import { COLORS } from 'chessops'; Chart.register(LineController, LinearScale, PointElement, LineElement, Tooltip, BarElement, BarController); diff --git a/ui/cli/src/cli.ts b/ui/cli/src/cli.ts index 189acfeeea8..b33d58c813b 100644 --- a/ui/cli/src/cli.ts +++ b/ui/cli/src/cli.ts @@ -1,7 +1,8 @@ -import debounce from 'debounce-promise'; import { load as loadDasher } from 'dasher'; -import { domDialog, alert, enter } from 'lib/view'; +import debounce from 'debounce-promise'; + import { defined, escapeHtml } from 'lib'; +import { domDialog, alert, enter } from 'lib/view'; import { complete, type CompleteOpts } from 'lib/view/complete'; import { checkDebouncedResultAgainstTerm, fetchUsers, renderUserEntry } from 'lib/view/userComplete'; diff --git a/ui/coordinateTrainer/src/chessground.ts b/ui/coordinateTrainer/src/chessground.ts index c07bc3593e2..53cc7a28e58 100644 --- a/ui/coordinateTrainer/src/chessground.ts +++ b/ui/coordinateTrainer/src/chessground.ts @@ -1,10 +1,12 @@ -import { h, type VNode } from 'snabbdom'; -import type { Elements } from '@lichess-org/chessground/types'; -import resizeHandle from 'lib/chessgroundResize'; -import type CoordinateTrainerCtrl from './ctrl'; import { Chessground as makeChessground } from '@lichess-org/chessground'; +import type { Elements } from '@lichess-org/chessground/types'; +import { h, type VNode } from 'snabbdom'; + +import resizeHandle from 'lib/chessgroundResize'; import { pubsub } from 'lib/pubsub'; +import type CoordinateTrainerCtrl from './ctrl'; + export default function (ctrl: CoordinateTrainerCtrl): VNode { return h('div.cg-wrap', { hook: { diff --git a/ui/coordinateTrainer/src/coordinateTrainer.ts b/ui/coordinateTrainer/src/coordinateTrainer.ts index ce1a21acd31..e25c08c683d 100644 --- a/ui/coordinateTrainer/src/coordinateTrainer.ts +++ b/ui/coordinateTrainer/src/coordinateTrainer.ts @@ -6,10 +6,12 @@ import { propsModule, styleModule, } from 'snabbdom'; + import menuHover from 'lib/menuHover'; -import view from './view'; -import type { CoordinateTrainerConfig } from './interfaces'; + import CoordinateTrainerCtrl from './ctrl'; +import type { CoordinateTrainerConfig } from './interfaces'; +import view from './view'; const patch = init([classModule, attributesModule, propsModule, eventListenersModule, styleModule]); diff --git a/ui/coordinateTrainer/src/ctrl.ts b/ui/coordinateTrainer/src/ctrl.ts index 190ce62a614..7d964477f5d 100644 --- a/ui/coordinateTrainer/src/ctrl.ts +++ b/ui/coordinateTrainer/src/ctrl.ts @@ -1,9 +1,15 @@ import { sparkline } from '@fnando/sparkline'; -import { text as xhrText, form as xhrForm } from 'lib/xhr'; -import { type Prop, myUserId, withEffect } from 'lib'; -import { makeVoice, type VoiceCtrl } from 'voice'; -import { storedBooleanProp, storedProp } from 'lib/storage'; import type { Api as CgApi } from '@lichess-org/chessground/api'; +import { COLORS } from 'chessops'; +import { makeVoice, type VoiceCtrl } from 'voice'; + +import { type Prop, myUserId, withEffect } from 'lib'; +import { pubsub } from 'lib/pubsub'; +import type { ColorChoice } from 'lib/setup/color'; +import { storedBooleanProp, storedProp } from 'lib/storage'; +import { toggleZenMode } from 'lib/view/zen'; +import { text as xhrText, form as xhrForm } from 'lib/xhr'; + import type { TimeControl, CoordinateTrainerConfig, @@ -12,10 +18,6 @@ import type { ModeScores, Redraw, } from './interfaces'; -import { pubsub } from 'lib/pubsub'; -import type { ColorChoice } from 'lib/setup/color'; -import { COLORS } from 'chessops'; -import { toggleZenMode } from 'lib/view/zen'; const orientationFromColorChoice = (colorChoice: ColorChoice): Color => colorChoice === 'random' ? COLORS[Math.round(Math.random())] : colorChoice; diff --git a/ui/coordinateTrainer/src/side.ts b/ui/coordinateTrainer/src/side.ts index 5929964536c..2fbf8f44afe 100644 --- a/ui/coordinateTrainer/src/side.ts +++ b/ui/coordinateTrainer/src/side.ts @@ -1,9 +1,11 @@ import { h, type VNode, type VNodes } from 'snabbdom'; + +import { colors, type ColorChoice } from 'lib/setup/color'; import { bind } from 'lib/view'; import { cmnToggleWrapProp } from 'lib/view/cmn-toggle'; + import type CoordinateTrainerCtrl from './ctrl'; import type { TimeControl, Mode } from './interfaces'; -import { colors, type ColorChoice } from 'lib/setup/color'; const timeControls: [TimeControl, string][] = [ ['untimed', '∞'], diff --git a/ui/coordinateTrainer/src/view.ts b/ui/coordinateTrainer/src/view.ts index 3a1c94c63f4..4229e4f18b3 100644 --- a/ui/coordinateTrainer/src/view.ts +++ b/ui/coordinateTrainer/src/view.ts @@ -1,6 +1,8 @@ import type { VNode, VNodeStyle } from 'snabbdom'; -import { bind, hl } from 'lib/view'; import { renderVoiceBar } from 'voice'; + +import { bind, hl } from 'lib/view'; + import chessground from './chessground'; import CoordinateTrainerCtrl, { DURATION } from './ctrl'; import type { CoordModifier } from './interfaces'; diff --git a/ui/dasher/src/background.ts b/ui/dasher/src/background.ts index 8e5abc32a38..53d6ec04b51 100644 --- a/ui/dasher/src/background.ts +++ b/ui/dasher/src/background.ts @@ -1,12 +1,14 @@ import { h, type VNode } from 'snabbdom'; -import { elementScrollBarWidthSlowGuess, header } from './util'; + import { debounce, throttlePromiseDelay } from 'lib/async'; import { prefersLightThemeQuery } from 'lib/device'; import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; import { bind } from 'lib/view'; import { text as xhrText, form as xhrForm, textRaw as xhrTextRaw } from 'lib/xhr'; + import { type DasherCtrl, PaneCtrl } from './interfaces'; -import { pubsub } from 'lib/pubsub'; +import { elementScrollBarWidthSlowGuess, header } from './util'; export interface BackgroundData { current: string; diff --git a/ui/dasher/src/board.ts b/ui/dasher/src/board.ts index d46aa12d6b9..52f9a463190 100644 --- a/ui/dasher/src/board.ts +++ b/ui/dasher/src/board.ts @@ -1,11 +1,12 @@ -import { header, moreButton } from './util'; import { hyphenToCamel, type Toggle, toggle } from 'lib'; import { debounce } from 'lib/async'; import * as licon from 'lib/licon'; -import { text as xhrText, form as xhrForm } from 'lib/xhr'; -import { bind, hl, type VNode } from 'lib/view'; -import { type DasherCtrl, type Dimension, PaneCtrl } from './interfaces'; import { pubsub } from 'lib/pubsub'; +import { bind, hl, type VNode } from 'lib/view'; +import { text as xhrText, form as xhrForm } from 'lib/xhr'; + +import { type DasherCtrl, type Dimension, PaneCtrl } from './interfaces'; +import { header, moreButton } from './util'; type Range = { min: number; max: number; step: number }; diff --git a/ui/dasher/src/ctrl.ts b/ui/dasher/src/ctrl.ts index d8568437439..7b05af66d04 100644 --- a/ui/dasher/src/ctrl.ts +++ b/ui/dasher/src/ctrl.ts @@ -1,13 +1,14 @@ -import { PingCtrl } from './ping'; -import { LangsCtrl } from './langs'; -import { SoundCtrl } from './sound'; +import { type Prop, prop } from 'lib'; +import type { MaybeVNode } from 'lib/view'; + import { BackgroundCtrl } from './background'; import { BoardCtrl } from './board'; -import { PieceCtrl } from './piece'; -import { LinksCtrl } from './links'; -import type { MaybeVNode } from 'lib/view'; import type { DasherData, Mode, PaneCtrl } from './interfaces'; -import { type Prop, prop } from 'lib'; +import { LangsCtrl } from './langs'; +import { LinksCtrl } from './links'; +import { PieceCtrl } from './piece'; +import { PingCtrl } from './ping'; +import { SoundCtrl } from './sound'; const defaultMode: Mode = 'links'; diff --git a/ui/dasher/src/dasher.ts b/ui/dasher/src/dasher.ts index eab04bd4065..2cf62e83f2d 100644 --- a/ui/dasher/src/dasher.ts +++ b/ui/dasher/src/dasher.ts @@ -1,8 +1,10 @@ -import { DasherCtrl } from './ctrl'; -import { json as xhrJson } from 'lib/xhr'; -import { spinnerVdom, spinnerHtml } from 'lib/view'; import { init as initSnabbdom, type VNode, classModule, attributesModule, h } from 'snabbdom'; +import { spinnerVdom, spinnerHtml } from 'lib/view'; +import { json as xhrJson } from 'lib/xhr'; + +import { DasherCtrl } from './ctrl'; + const patch = initSnabbdom([classModule, attributesModule]); export function load(): Promise { diff --git a/ui/dasher/src/interfaces.ts b/ui/dasher/src/interfaces.ts index 334fa40ef91..a9e1687054d 100644 --- a/ui/dasher/src/interfaces.ts +++ b/ui/dasher/src/interfaces.ts @@ -1,7 +1,8 @@ -import type { LangsData } from './langs'; +import type { VNode } from 'lib/view'; + import type { BackgroundData } from './background'; import { DasherCtrl } from './ctrl'; -import type { VNode } from 'lib/view'; +import type { LangsData } from './langs'; export { DasherCtrl }; diff --git a/ui/dasher/src/langs.ts b/ui/dasher/src/langs.ts index 79934d0027c..d693e9c98d2 100644 --- a/ui/dasher/src/langs.ts +++ b/ui/dasher/src/langs.ts @@ -1,9 +1,11 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; -import { header } from './util'; -import { PaneCtrl } from './interfaces'; import { onInsert } from 'lib/view'; +import { PaneCtrl } from './interfaces'; +import { header } from './util'; + type Code = string; type Name = string; diff --git a/ui/dasher/src/links.ts b/ui/dasher/src/links.ts index 67ee706d267..4b2a4ce9536 100644 --- a/ui/dasher/src/links.ts +++ b/ui/dasher/src/links.ts @@ -1,9 +1,10 @@ -import { type Attrs, hl, type VNode, bind } from 'lib/view'; import * as licon from 'lib/licon'; -import { type Mode, PaneCtrl } from './interfaces'; import { pubsub } from 'lib/pubsub'; +import { type Attrs, hl, type VNode, bind } from 'lib/view'; import { userLine } from 'lib/view/userLink'; +import { type Mode, PaneCtrl } from './interfaces'; + export class LinksCtrl extends PaneCtrl { render = (): VNode => { const modeCfg = this.modeCfg; diff --git a/ui/dasher/src/piece.ts b/ui/dasher/src/piece.ts index 8328ff436e9..fb79b6dfb4d 100644 --- a/ui/dasher/src/piece.ts +++ b/ui/dasher/src/piece.ts @@ -1,10 +1,12 @@ import { h, type VNode } from 'snabbdom'; -import { text as xhrText, form as xhrForm } from 'lib/xhr'; -import { header, elementScrollBarWidthSlowGuess, moreButton } from './util'; -import { bind } from 'lib/view'; -import { type DasherCtrl, type Dimension, PaneCtrl } from './interfaces'; -import { pubsub } from 'lib/pubsub'; + import { type Toggle, toggle } from 'lib'; +import { pubsub } from 'lib/pubsub'; +import { bind } from 'lib/view'; +import { text as xhrText, form as xhrForm } from 'lib/xhr'; + +import { type DasherCtrl, type Dimension, PaneCtrl } from './interfaces'; +import { header, elementScrollBarWidthSlowGuess, moreButton } from './util'; export class PieceCtrl extends PaneCtrl { featured: Record = { d2: [], d3: [] }; diff --git a/ui/dasher/src/ping.ts b/ui/dasher/src/ping.ts index 2faf591d0da..9470a2100cd 100644 --- a/ui/dasher/src/ping.ts +++ b/ui/dasher/src/ping.ts @@ -1,8 +1,10 @@ import { h, type VNode } from 'snabbdom'; + import { defined } from 'lib'; -import type { DasherCtrl } from './interfaces'; import { pubsub } from 'lib/pubsub'; +import type { DasherCtrl } from './interfaces'; + export class PingCtrl { ping: number | undefined; server: number | undefined; diff --git a/ui/dasher/src/sound.ts b/ui/dasher/src/sound.ts index 34cad2fa70d..e61a89bb8c3 100644 --- a/ui/dasher/src/sound.ts +++ b/ui/dasher/src/sound.ts @@ -1,11 +1,13 @@ -import * as licon from 'lib/licon'; -import { text as xhrText, form as xhrForm } from 'lib/xhr'; -import { throttle, throttlePromiseDelay } from 'lib/async'; import { h, type VNode } from 'snabbdom'; -import { header } from './util'; -import { bind, dataIcon, snabDialog } from 'lib/view'; -import { type DasherCtrl, PaneCtrl } from './interfaces'; + +import { throttle, throttlePromiseDelay } from 'lib/async'; import { isSafari } from 'lib/device'; +import * as licon from 'lib/licon'; +import { bind, dataIcon, snabDialog } from 'lib/view'; +import { text as xhrText, form as xhrForm } from 'lib/xhr'; + +import { type DasherCtrl, PaneCtrl } from './interfaces'; +import { header } from './util'; type Key = string; diff --git a/ui/dasher/src/util.ts b/ui/dasher/src/util.ts index 5d11e2a2ccc..43014b17b44 100644 --- a/ui/dasher/src/util.ts +++ b/ui/dasher/src/util.ts @@ -1,6 +1,6 @@ +import { memoize, type Toggle } from 'lib'; import * as licon from 'lib/licon'; import { bind, hl, type VNode } from 'lib/view'; -import { memoize, type Toggle } from 'lib'; export const header = (name: string, close: () => void): VNode => hl( diff --git a/ui/dgt/src/play.ts b/ui/dgt/src/play.ts index 4320fa09b60..54e2264c880 100644 --- a/ui/dgt/src/play.ts +++ b/ui/dgt/src/play.ts @@ -1,9 +1,9 @@ +import { defaultSetup, fen, makeUci, parseUci } from 'chessops'; import { Chess, normalizeMove, castlingSide } from 'chessops/chess'; +import { board } from 'chessops/debug'; import { INITIAL_FEN, makeFen, parseFen } from 'chessops/fen'; import { makeSan, parseSan } from 'chessops/san'; import type { NormalMove } from 'chessops/types'; -import { board } from 'chessops/debug'; -import { defaultSetup, fen, makeUci, parseUci } from 'chessops'; export default function (token: string): void { const root = document.getElementById('dgt-play-zone') as HTMLDivElement; diff --git a/ui/editor/src/chessground.ts b/ui/editor/src/chessground.ts index ea243990e58..9687389ffa4 100644 --- a/ui/editor/src/chessground.ts +++ b/ui/editor/src/chessground.ts @@ -1,12 +1,14 @@ -import { h, type VNode } from 'snabbdom'; -import resizeHandle from 'lib/chessgroundResize'; +import { Chessground as makeChessground } from '@lichess-org/chessground'; import type { MouchEvent } from '@lichess-org/chessground/types'; import { eventPosition, opposite } from '@lichess-org/chessground/util'; -import type EditorCtrl from './ctrl'; -import { storage } from 'lib/storage'; -import { Chessground as makeChessground } from '@lichess-org/chessground'; -import { pubsub } from 'lib/pubsub'; +import { h, type VNode } from 'snabbdom'; + +import resizeHandle from 'lib/chessgroundResize'; import { ShowResizeHandle } from 'lib/prefs'; +import { pubsub } from 'lib/pubsub'; +import { storage } from 'lib/storage'; + +import type EditorCtrl from './ctrl'; export default function (ctrl: EditorCtrl): VNode { return h('div.cg-wrap', { diff --git a/ui/editor/src/ctrl.ts b/ui/editor/src/ctrl.ts index 8b1af8e1894..44957bbe6e9 100644 --- a/ui/editor/src/ctrl.ts +++ b/ui/editor/src/ctrl.ts @@ -1,3 +1,18 @@ +import { type Result } from '@badrap/result'; +import type { Api as CgApi } from '@lichess-org/chessground/api'; +import { opposite } from '@lichess-org/chessground/util'; +import { parseSquare } from 'chessops'; +import { Board } from 'chessops/board'; +import { lichessRules } from 'chessops/compat'; +import { makeFen, parseFen, parseCastlingFen, INITIAL_FEN, EMPTY_FEN } from 'chessops/fen'; +import { type Setup, Material, RemainingChecks, defaultSetup } from 'chessops/setup'; +import type { Rules, Square } from 'chessops/types'; +import { Castles, defaultPosition, Position, setupPosition } from 'chessops/variant'; + +import { defined, prop, type Prop } from 'lib'; +import { prompt } from 'lib/view'; + +import { chess960CastlingSquares, chess960IdToFEN, fenToChess960Id, randomPositionId } from './chess960'; import { type EditorState, type Selected, @@ -8,19 +23,6 @@ import { type CastlingToggles, CASTLING_TOGGLES, } from './interfaces'; -import { type Result } from '@badrap/result'; -import type { Api as CgApi } from '@lichess-org/chessground/api'; -import type { Rules, Square } from 'chessops/types'; -import { Board } from 'chessops/board'; -import { type Setup, Material, RemainingChecks, defaultSetup } from 'chessops/setup'; -import { Castles, defaultPosition, Position, setupPosition } from 'chessops/variant'; -import { makeFen, parseFen, parseCastlingFen, INITIAL_FEN, EMPTY_FEN } from 'chessops/fen'; -import { lichessRules } from 'chessops/compat'; -import { defined, prop, type Prop } from 'lib'; -import { prompt } from 'lib/view'; -import { opposite } from '@lichess-org/chessground/util'; -import { parseSquare } from 'chessops'; -import { chess960CastlingSquares, chess960IdToFEN, fenToChess960Id, randomPositionId } from './chess960'; export default class EditorCtrl { options: Options; diff --git a/ui/editor/src/editor.ts b/ui/editor/src/editor.ts index db973ee9666..4c8768aaadb 100644 --- a/ui/editor/src/editor.ts +++ b/ui/editor/src/editor.ts @@ -1,8 +1,10 @@ +import { init, attributesModule, eventListenersModule, classModule, propsModule } from 'snabbdom'; + +import menuHover from 'lib/menuHover'; + import EditorCtrl from './ctrl'; import type { LichessEditor, Config } from './interfaces'; -import menuHover from 'lib/menuHover'; import view from './view'; -import { init, attributesModule, eventListenersModule, classModule, propsModule } from 'snabbdom'; const patch = init([classModule, attributesModule, propsModule, eventListenersModule]); diff --git a/ui/editor/src/view.ts b/ui/editor/src/view.ts index b84139ee335..20cda8eed53 100644 --- a/ui/editor/src/view.ts +++ b/ui/editor/src/view.ts @@ -1,18 +1,19 @@ -import { h, type VNode } from 'snabbdom'; -import * as licon from 'lib/licon'; -import { copyMeInput, dataIcon, domDialog, enter } from 'lib/view'; -import type { MouchEvent, NumberPair } from '@lichess-org/chessground/types'; import { dragNewPiece } from '@lichess-org/chessground/drag'; +import type { MouchEvent, NumberPair } from '@lichess-org/chessground/types'; import { eventPosition, opposite } from '@lichess-org/chessground/util'; import { lichessRules } from 'chessops/compat'; - import { parseFen } from 'chessops/fen'; import { parseSquare, makeSquare } from 'chessops/util'; -import type EditorCtrl from './ctrl'; -import chessground from './chessground'; -import type { Selected, CastlingToggle, EditorState, EndgamePosition, OpeningPosition } from './interfaces'; +import { h, type VNode } from 'snabbdom'; + import { fenToEpd } from 'lib/game/chess'; +import * as licon from 'lib/licon'; +import { copyMeInput, dataIcon, domDialog, enter } from 'lib/view'; + import { fenToChess960Id, isValidPositionId } from './chess960'; +import chessground from './chessground'; +import type EditorCtrl from './ctrl'; +import type { Selected, CastlingToggle, EditorState, EndgamePosition, OpeningPosition } from './interfaces'; function castleCheckBox(ctrl: EditorCtrl, id: CastlingToggle, label: string, reversed: boolean): VNode { const input = h('input', { diff --git a/ui/fide/src/fidePlayerFollow.ts b/ui/fide/src/fidePlayerFollow.ts index e28136061aa..7539749e84b 100644 --- a/ui/fide/src/fidePlayerFollow.ts +++ b/ui/fide/src/fidePlayerFollow.ts @@ -1,6 +1,6 @@ import { debounce } from 'lib/async'; -import { text } from 'lib/xhr'; import { pubsub } from 'lib/pubsub'; +import { text } from 'lib/xhr'; export function initModule(): void { fidePlayerFollow(); diff --git a/ui/fide/src/fideRatingChart.ts b/ui/fide/src/fideRatingChart.ts index 91f2b3e839d..6b865bf7867 100644 --- a/ui/fide/src/fideRatingChart.ts +++ b/ui/fide/src/fideRatingChart.ts @@ -1,5 +1,5 @@ -import * as chart from 'chart.js'; import 'chartjs-adapter-dayjs-4'; +import * as chart from 'chart.js'; import dayjs from 'dayjs'; interface FideRatingChartOpts { diff --git a/ui/insight/src/axis.ts b/ui/insight/src/axis.ts index 78535e10053..cfe9f8acbe3 100644 --- a/ui/insight/src/axis.ts +++ b/ui/insight/src/axis.ts @@ -1,6 +1,8 @@ -import type Ctrl from './ctrl'; -import type { MaybeVNode } from 'lib/view'; import { h, type VNodeData } from 'snabbdom'; + +import type { MaybeVNode } from 'lib/view'; + +import type Ctrl from './ctrl'; import type { Categ, Dimension, Metric } from './interfaces'; const selectData = (onClick: (v: { value: string }) => void, getValue: () => string): VNodeData => ({ diff --git a/ui/insight/src/boards.ts b/ui/insight/src/boards.ts index 3dae3741ac0..1187c0528f8 100644 --- a/ui/insight/src/boards.ts +++ b/ui/insight/src/boards.ts @@ -1,8 +1,10 @@ -import type Ctrl from './ctrl'; import { h, type VNodeData } from 'snabbdom'; -import type { Game } from './interfaces'; + import { initMiniBoard } from 'lib/view'; +import type Ctrl from './ctrl'; +import type { Game } from './interfaces'; + const miniGame = (game: Game) => h('a', { attrs: { key: game.id, href: `/${game.id}/${game.color}` } }, [ h('span.mini-board.is2d', { diff --git a/ui/insight/src/chart.ts b/ui/insight/src/chart.ts index 868fc21c377..e3e212be9ec 100644 --- a/ui/insight/src/chart.ts +++ b/ui/insight/src/chart.ts @@ -1,7 +1,4 @@ -import { h, type VNode } from 'snabbdom'; -import * as licon from 'lib/licon'; -import type Ctrl from './ctrl'; -import type { InsightChart, InsightData } from './interfaces'; +import { gridColor, tooltipBgColor, fontFamily, maybeChart, colorSeries } from 'chart'; import { Chart, type ChartDataset, @@ -14,12 +11,17 @@ import { Tooltip, type ChartOptions, } from 'chart.js'; -import { currentTheme } from 'lib/device'; -import { gridColor, tooltipBgColor, fontFamily, maybeChart, colorSeries } from 'chart'; import ChartDataLabels from 'chartjs-plugin-datalabels'; -import { formatNumber } from './table'; +import { h, type VNode } from 'snabbdom'; + +import { currentTheme } from 'lib/device'; +import * as licon from 'lib/licon'; import { spinnerHtml } from 'lib/view'; +import type Ctrl from './ctrl'; +import type { InsightChart, InsightData } from './interfaces'; +import { formatNumber } from './table'; + Chart.register(BarController, CategoryScale, LinearScale, BarElement, Tooltip, Legend, ChartDataLabels); Chart.defaults.font = fontFamily(); diff --git a/ui/insight/src/ctrl.ts b/ui/insight/src/ctrl.ts index b335fa2b13f..33a1d4a0499 100644 --- a/ui/insight/src/ctrl.ts +++ b/ui/insight/src/ctrl.ts @@ -1,5 +1,6 @@ import { throttlePromiseDelay } from 'lib/async'; import { json as xhrJson } from 'lib/xhr'; + import type { InsightData, Dimension, diff --git a/ui/insight/src/filters.ts b/ui/insight/src/filters.ts index 9c1009d403b..fe801292afe 100644 --- a/ui/insight/src/filters.ts +++ b/ui/insight/src/filters.ts @@ -1,4 +1,5 @@ import { h } from 'snabbdom'; + import type Ctrl from './ctrl'; import type { Dimension } from './interfaces'; diff --git a/ui/insight/src/help.ts b/ui/insight/src/help.ts index f7bcd073409..e90aa49a68d 100644 --- a/ui/insight/src/help.ts +++ b/ui/insight/src/help.ts @@ -1,4 +1,5 @@ import { h } from 'snabbdom'; + import type Ctrl from './ctrl'; export default function (ctrl: Ctrl) { diff --git a/ui/insight/src/info.ts b/ui/insight/src/info.ts index 93790492ad4..5e3822c2ac7 100644 --- a/ui/insight/src/info.ts +++ b/ui/insight/src/info.ts @@ -1,7 +1,9 @@ -import { onInsert, spinnerHtml } from 'lib/view'; -import { numberFormat } from 'lib/i18n'; -import { userLink } from 'lib/view/userLink'; import { h } from 'snabbdom'; + +import { numberFormat } from 'lib/i18n'; +import { onInsert, spinnerHtml } from 'lib/view'; +import { userLink } from 'lib/view/userLink'; + import type Ctrl from './ctrl'; import { registerFormHandler } from './insight'; diff --git a/ui/insight/src/insight.ts b/ui/insight/src/insight.ts index ed69d1903e5..78c8e18ec59 100644 --- a/ui/insight/src/insight.ts +++ b/ui/insight/src/insight.ts @@ -2,8 +2,8 @@ import { attributesModule, classModule, init } from 'snabbdom'; import Ctrl from './ctrl'; import type { Env } from './interfaces'; -import { view } from './view'; import { registerMultipleSelect } from './multipleSelect'; +import { view } from './view'; const patch = init([classModule, attributesModule]); diff --git a/ui/insight/src/multipleSelect.ts b/ui/insight/src/multipleSelect.ts index 2a338e27d4c..68488a839ea 100644 --- a/ui/insight/src/multipleSelect.ts +++ b/ui/insight/src/multipleSelect.ts @@ -1,5 +1,5 @@ -import { isTouchDevice } from 'lib/device'; import { escapeHtml } from 'lib'; +import { isTouchDevice } from 'lib/device'; export const registerMultipleSelect = () => { $.fn.multipleSelectHover = function (fnOver, fnOut) { diff --git a/ui/insight/src/presets.ts b/ui/insight/src/presets.ts index 122820c2735..bdb5c6fb280 100644 --- a/ui/insight/src/presets.ts +++ b/ui/insight/src/presets.ts @@ -1,6 +1,8 @@ +import { h } from 'snabbdom'; + import * as licon from 'lib/licon'; import { bind } from 'lib/view'; -import { h } from 'snabbdom'; + import type Ctrl from './ctrl'; import type { Preset } from './interfaces'; diff --git a/ui/insight/src/table.ts b/ui/insight/src/table.ts index be15047e5c6..9e6fe374806 100644 --- a/ui/insight/src/table.ts +++ b/ui/insight/src/table.ts @@ -1,4 +1,5 @@ import { h, type VNodeData } from 'snabbdom'; + import type Ctrl from './ctrl'; export function formatNumber(dt: string, n: number) { diff --git a/ui/insight/src/view.ts b/ui/insight/src/view.ts index 996a7c30fc8..a50f789117b 100644 --- a/ui/insight/src/view.ts +++ b/ui/insight/src/view.ts @@ -1,17 +1,19 @@ import { thunk } from 'snabbdom'; + import { debounce } from 'lib/async'; import * as licon from 'lib/licon'; +import { bind, hl } from 'lib/view'; + import axis from './axis'; -import filters from './filters'; -import presets from './presets'; +import boards from './boards'; import chart from './chart'; -import { vert } from './table'; +import type Ctrl from './ctrl'; +import filters from './filters'; import help from './help'; import { info, tutor } from './info'; -import boards from './boards'; -import type Ctrl from './ctrl'; import type { ViewTab } from './interfaces'; -import { bind, hl } from 'lib/view'; +import presets from './presets'; +import { vert } from './table'; let forceRender = false; diff --git a/ui/keyboardMove/src/exports.ts b/ui/keyboardMove/src/exports.ts index 81f8f02ef38..0a86bb25b05 100644 --- a/ui/keyboardMove/src/exports.ts +++ b/ui/keyboardMove/src/exports.ts @@ -1,12 +1,14 @@ -import type { SanToUci } from 'lib/game'; -import { type Prop, propWithEffect } from 'lib'; -import type { MoveRootCtrl, MoveUpdate } from 'lib/game/moveRootCtrl'; -import KeyboardChecker from '@/keyboardChecker'; -import { h, type VNode } from 'snabbdom'; -import { onInsert, snabDialog } from 'lib/view'; -import { promote } from 'lib/game/promotion'; import { charToRole } from 'chessops'; +import { h, type VNode } from 'snabbdom'; + +import { type Prop, propWithEffect } from 'lib'; +import type { SanToUci } from 'lib/game'; +import type { MoveRootCtrl, MoveUpdate } from 'lib/game/moveRootCtrl'; +import { promote } from 'lib/game/promotion'; import type { NodeCrazy } from 'lib/tree/types'; +import { onInsert, snabDialog } from 'lib/view'; + +import KeyboardChecker from '@/keyboardChecker'; export interface Opts { input: HTMLInputElement; diff --git a/ui/keyboardMove/src/keyboardMove.ts b/ui/keyboardMove/src/keyboardMove.ts index 4974195c19c..43558982bef 100644 --- a/ui/keyboardMove/src/keyboardMove.ts +++ b/ui/keyboardMove/src/keyboardMove.ts @@ -1,4 +1,5 @@ import { sanWriter, destsToUcis } from 'lib/game'; + import type { KeyboardMoveHandler, Opts, ArrowKey } from '@/exports'; import { type Submit, makeSubmit } from '@/keyboardSubmit'; diff --git a/ui/keyboardMove/src/keyboardSubmit.ts b/ui/keyboardMove/src/keyboardSubmit.ts index 5343d2e03b9..c9914e2b16f 100644 --- a/ui/keyboardMove/src/keyboardSubmit.ts +++ b/ui/keyboardMove/src/keyboardSubmit.ts @@ -1,5 +1,7 @@ import { files } from '@lichess-org/chessground/types'; + import { sanToUci, type SanToUci } from 'lib/game'; + import type { Opts } from '@/exports'; const keyRegex = /^[a-h][1-8]$/; diff --git a/ui/keyboardMove/tests/keyboardSubmit.test.ts b/ui/keyboardMove/tests/keyboardSubmit.test.ts index 0e89878c9f6..9316c7aefdf 100644 --- a/ui/keyboardMove/tests/keyboardSubmit.test.ts +++ b/ui/keyboardMove/tests/keyboardSubmit.test.ts @@ -1,8 +1,10 @@ -import { beforeEach, describe, test } from 'node:test'; import assert from 'node:assert/strict'; -import { type Prop, propWithEffect } from 'lib/index'; -import { makeSubmit } from '../src/keyboardSubmit.js'; +import { beforeEach, describe, test } from 'node:test'; + import { destsToUcis, sanWriter } from 'lib/game'; +import { type Prop, propWithEffect } from 'lib/index'; + +import { makeSubmit } from '../src/keyboardSubmit.js'; function spy() { const f: any = (...args: any[]) => { diff --git a/ui/learn/src/assert.ts b/ui/learn/src/assert.ts index c83410c6dfd..c005c96c78e 100644 --- a/ui/learn/src/assert.ts +++ b/ui/learn/src/assert.ts @@ -1,4 +1,5 @@ import { charToRole, type SquareName } from 'chessops'; + import type { AssertData } from './levelCtrl'; import { readKeys } from './util'; diff --git a/ui/learn/src/chess.ts b/ui/learn/src/chess.ts index cfbead65a9c..e976eef67bb 100644 --- a/ui/learn/src/chess.ts +++ b/ui/learn/src/chess.ts @@ -1,4 +1,3 @@ -import { parseFen, makeBoardFen } from 'chessops/fen'; import { parseSquare, makeSquare, @@ -8,10 +7,12 @@ import { charToRole, opposite, } from 'chessops'; -import { Antichess, type Context } from 'chessops/variant'; import { chessgroundDests } from 'chessops/compat'; -import type { CgMove } from './chessground'; +import { parseFen, makeBoardFen } from 'chessops/fen'; import { makeSan } from 'chessops/san'; +import { Antichess, type Context } from 'chessops/variant'; + +import type { CgMove } from './chessground'; import { isRole, type PromotionChar, type PromotionRole } from './util'; type LearnVariant = Chess | Antichess; diff --git a/ui/learn/src/chessground.ts b/ui/learn/src/chessground.ts index c1cc95ed7fd..7840e52cc5d 100644 --- a/ui/learn/src/chessground.ts +++ b/ui/learn/src/chessground.ts @@ -1,7 +1,9 @@ -import { h, type VNode } from 'snabbdom'; -import type { RunCtrl } from './run/runCtrl'; -import { Coords } from 'lib/prefs'; import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { h, type VNode } from 'snabbdom'; + +import { Coords } from 'lib/prefs'; + +import type { RunCtrl } from './run/runCtrl'; export interface Shape { orig: Key; diff --git a/ui/learn/src/ctrl.ts b/ui/learn/src/ctrl.ts index ab1eb7428cd..1fcdc500009 100644 --- a/ui/learn/src/ctrl.ts +++ b/ui/learn/src/ctrl.ts @@ -1,10 +1,10 @@ +import { extractHashParameters } from './hashRouting'; import type { LearnProgress, LearnOpts } from './learn'; -import { type Stage, byId as stageById } from './stage/list'; +import { RunCtrl } from './run/runCtrl'; import { gtz } from './score'; import { SideCtrl } from './sideCtrl'; +import { type Stage, byId as stageById } from './stage/list'; import { clearTimeouts } from './timeouts'; -import { extractHashParameters } from './hashRouting'; -import { RunCtrl } from './run/runCtrl'; export class LearnCtrl { data: LearnProgress = this.opts.storage.data; diff --git a/ui/learn/src/item.ts b/ui/learn/src/item.ts index 5c5204de322..630499501f5 100644 --- a/ui/learn/src/item.ts +++ b/ui/learn/src/item.ts @@ -1,4 +1,5 @@ import type { SquareName } from 'chessops'; + import { readKeys } from './util'; export interface Items { diff --git a/ui/learn/src/learn.ts b/ui/learn/src/learn.ts index 1c1ab89b75a..5b05087f5f7 100644 --- a/ui/learn/src/learn.ts +++ b/ui/learn/src/learn.ts @@ -6,12 +6,13 @@ import { propsModule, styleModule, } from 'snabbdom'; -import { LearnCtrl } from './ctrl'; -import { view } from './view'; + import { Coords } from 'lib/prefs'; import { pubsub } from 'lib/pubsub'; +import { LearnCtrl } from './ctrl'; import storage, { type Storage } from './storage'; +import { view } from './view'; const patch = init([classModule, attributesModule, propsModule, eventListenersModule, styleModule]); diff --git a/ui/learn/src/levelCtrl.ts b/ui/learn/src/levelCtrl.ts index aa09214ff10..d9bda3765d6 100644 --- a/ui/learn/src/levelCtrl.ts +++ b/ui/learn/src/levelCtrl.ts @@ -1,19 +1,21 @@ -import { type PromotionRole, arrow } from './util'; -import { type Items, ctrl as makeItems } from './item'; -import type { Level } from './stage/list'; -import { scenario as scoreScenario, pieceValue, capture, apple, getLevelBonus } from './score'; -import * as timeouts from './timeouts'; -import { failure, levelStart, levelEnd, take, move as moveSound } from './sound'; -import makeChess, { type ChessCtrl } from './chess'; -import makeScenario, { type Scenario } from './scenario'; -import { type SquareName, makeSquare, makeUci, opposite } from 'chessops'; -import type { CgMove } from './chessground'; -import { PromotionCtrl } from './promotionCtrl'; -import { type Prop, prop } from 'lib'; import type { DrawShape } from '@lichess-org/chessground/draw'; -import { makeAppleShape } from './apple'; +import { type SquareName, makeSquare, makeUci, opposite } from 'chessops'; + +import { type Prop, prop } from 'lib'; import { type WithGround } from 'lib/game/ground'; +import { makeAppleShape } from './apple'; +import makeChess, { type ChessCtrl } from './chess'; +import type { CgMove } from './chessground'; +import { type Items, ctrl as makeItems } from './item'; +import { PromotionCtrl } from './promotionCtrl'; +import makeScenario, { type Scenario } from './scenario'; +import { scenario as scoreScenario, pieceValue, capture, apple, getLevelBonus } from './score'; +import { failure, levelStart, levelEnd, take, move as moveSound } from './sound'; +import type { Level } from './stage/list'; +import * as timeouts from './timeouts'; +import { type PromotionRole, arrow } from './util'; + export interface LevelVm { score: number; completed: boolean; diff --git a/ui/learn/src/mapSideView.ts b/ui/learn/src/mapSideView.ts index 9f9f94cdfad..b2be1988e22 100644 --- a/ui/learn/src/mapSideView.ts +++ b/ui/learn/src/mapSideView.ts @@ -1,10 +1,12 @@ -import { assetUrl } from './util'; -import { categs } from './stage/list'; -import type { SideCtrl } from './sideCtrl'; import { h } from 'snabbdom'; + import { bind, confirm } from 'lib/view'; -import { BASE_LEARN_PATH, hashHref } from './hashRouting'; + import type { LearnCtrl } from './ctrl'; +import { BASE_LEARN_PATH, hashHref } from './hashRouting'; +import type { SideCtrl } from './sideCtrl'; +import { categs } from './stage/list'; +import { assetUrl } from './util'; export function mapSideView(ctrl: LearnCtrl) { if (ctrl.inStage()) return renderInStage(ctrl.sideCtrl); diff --git a/ui/learn/src/progressView.ts b/ui/learn/src/progressView.ts index ae951a2b4c4..03311b113eb 100644 --- a/ui/learn/src/progressView.ts +++ b/ui/learn/src/progressView.ts @@ -1,9 +1,11 @@ -import { getLevelRank } from './score'; -import type { Level } from './stage/list'; import { h } from 'snabbdom'; + +import * as licon from 'lib/licon'; + import { hashHref } from './hashRouting'; import type { RunCtrl } from './run/runCtrl'; -import * as licon from 'lib/licon'; +import { getLevelRank } from './score'; +import type { Level } from './stage/list'; const star = h('i', { attrs: { 'data-icon': licon.Star } }); diff --git a/ui/learn/src/promotionCtrl.ts b/ui/learn/src/promotionCtrl.ts index 9fcf8c589c7..8dfd0288b11 100644 --- a/ui/learn/src/promotionCtrl.ts +++ b/ui/learn/src/promotionCtrl.ts @@ -1,7 +1,9 @@ import type { PiecesDiff } from '@lichess-org/chessground/types'; -import type { PromotionRole } from './util'; + import { type WithGround } from 'lib/game/ground'; +import type { PromotionRole } from './util'; + type PromotionCallback = (orig: Key, dest: Key, role: PromotionRole) => void; export class PromotionCtrl { diff --git a/ui/learn/src/promotionView.ts b/ui/learn/src/promotionView.ts index 1a2a8022ede..5320d1b672e 100644 --- a/ui/learn/src/promotionView.ts +++ b/ui/learn/src/promotionView.ts @@ -1,8 +1,10 @@ +import { opposite, key2pos } from '@lichess-org/chessground/util'; +import { h } from 'snabbdom'; + +import { bind } from 'lib/view'; + import type { RunCtrl } from './run/runCtrl'; import type { PromotionRole } from './util'; -import { h } from 'snabbdom'; -import { bind } from 'lib/view'; -import { opposite, key2pos } from '@lichess-org/chessground/util'; const pieces: PromotionRole[] = ['queen', 'knight', 'rook', 'bishop']; diff --git a/ui/learn/src/run/runCtrl.ts b/ui/learn/src/run/runCtrl.ts index 4d67ee276c0..1c88891656a 100644 --- a/ui/learn/src/run/runCtrl.ts +++ b/ui/learn/src/run/runCtrl.ts @@ -1,12 +1,13 @@ -import { stageStart, stageEnd } from '../sound'; import { type Prop, prop } from 'lib'; +import type { WithGround } from 'lib/game/ground'; +import { pubsub } from 'lib/pubsub'; + +import { hashNavigate } from '../hashRouting'; import type { LearnProgress, LearnOpts } from '../learn'; +import { LevelCtrl } from '../levelCtrl'; +import { stageStart, stageEnd } from '../sound'; import { type Stage, type Level, byId as stageById } from '../stage/list'; import { clearTimeouts } from '../timeouts'; -import { LevelCtrl } from '../levelCtrl'; -import { hashNavigate } from '../hashRouting'; -import { pubsub } from 'lib/pubsub'; -import type { WithGround } from 'lib/game/ground'; export class RunCtrl { data: LearnProgress = this.opts.storage.data; diff --git a/ui/learn/src/run/runView.ts b/ui/learn/src/run/runView.ts index 997083af0b1..d0ef8e2e3d8 100644 --- a/ui/learn/src/run/runView.ts +++ b/ui/learn/src/run/runView.ts @@ -1,16 +1,18 @@ -import { withLinebreaks } from '../util'; -import chessground from '../chessground'; -import congrats from './congrats'; -import stageStarting from './stageStarting'; -import stageComplete from './stageComplete'; -import type { LevelCtrl } from '../levelCtrl'; -import type { RunCtrl } from './runCtrl'; -import { mapSideView } from '../mapSideView'; -import type { LearnCtrl } from '../ctrl'; import { h, type Classes, type VNode } from 'snabbdom'; + import { bind } from 'lib/view'; + +import chessground from '../chessground'; +import type { LearnCtrl } from '../ctrl'; +import type { LevelCtrl } from '../levelCtrl'; +import { mapSideView } from '../mapSideView'; import { makeStars, progressView } from '../progressView'; import { promotionView } from '../promotionView'; +import { withLinebreaks } from '../util'; +import congrats from './congrats'; +import type { RunCtrl } from './runCtrl'; +import stageComplete from './stageComplete'; +import stageStarting from './stageStarting'; const renderFailed = (ctrl: RunCtrl): VNode => h('div.result.failed', { hook: bind('click', ctrl.restart) }, [ diff --git a/ui/learn/src/run/stageComplete.ts b/ui/learn/src/run/stageComplete.ts index 610ed6f880a..b4529bf6a91 100644 --- a/ui/learn/src/run/stageComplete.ts +++ b/ui/learn/src/run/stageComplete.ts @@ -1,11 +1,13 @@ -import { withLinebreaks } from '../util'; -import { getStageRank } from '../score'; -import { numberSpread } from 'lib/i18n'; -import type { RunCtrl } from './runCtrl'; import { h } from 'snabbdom'; -import { bind } from 'lib/view'; -import { hashNavigate } from '../hashRouting'; + +import { numberSpread } from 'lib/i18n'; import * as licon from 'lib/licon'; +import { bind } from 'lib/view'; + +import { hashNavigate } from '../hashRouting'; +import { getStageRank } from '../score'; +import { withLinebreaks } from '../util'; +import type { RunCtrl } from './runCtrl'; function makeStars(rank: number) { const stars = []; diff --git a/ui/learn/src/run/stageStarting.ts b/ui/learn/src/run/stageStarting.ts index 38de3f7713c..5d253e7bcea 100644 --- a/ui/learn/src/run/stageStarting.ts +++ b/ui/learn/src/run/stageStarting.ts @@ -1,7 +1,9 @@ +import { h } from 'snabbdom'; + +import { bind } from 'lib/view'; + import { withLinebreaks } from '../util'; import type { RunCtrl } from './runCtrl'; -import { h } from 'snabbdom'; -import { bind } from 'lib/view'; export default function (ctrl: RunCtrl) { return h( diff --git a/ui/learn/src/scenario.ts b/ui/learn/src/scenario.ts index c198270121d..78aa21c5cfd 100644 --- a/ui/learn/src/scenario.ts +++ b/ui/learn/src/scenario.ts @@ -1,7 +1,7 @@ -import * as timeouts from './timeouts'; import type { ChessCtrl } from './chess'; -import { decomposeUci } from './util'; import type { Shape } from './chessground'; +import * as timeouts from './timeouts'; +import { decomposeUci } from './util'; export interface Scenario { isComplete(): boolean; diff --git a/ui/learn/src/sideCtrl.ts b/ui/learn/src/sideCtrl.ts index 533bb6176e7..284944b806a 100644 --- a/ui/learn/src/sideCtrl.ts +++ b/ui/learn/src/sideCtrl.ts @@ -1,8 +1,9 @@ -import { stageIdToCategId, byKey as stageByKey, list as stageList } from './stage/list'; -import * as scoring from './score'; import { type Prop, propWithEffect } from 'lib'; -import type { LearnProgress, LearnOpts } from './learn'; + import { LearnCtrl } from './ctrl'; +import type { LearnProgress, LearnOpts } from './learn'; +import * as scoring from './score'; +import { stageIdToCategId, byKey as stageByKey, list as stageList } from './stage/list'; export class SideCtrl { opts: LearnOpts; diff --git a/ui/learn/src/stage/capture.ts b/ui/learn/src/stage/capture.ts index cc32ed22ccc..fe5560caa72 100644 --- a/ui/learn/src/stage/capture.ts +++ b/ui/learn/src/stage/capture.ts @@ -1,6 +1,6 @@ +import { extinct } from '../assert'; import { arrow, assetUrl, roundSvg, toLevel } from '../util'; import type { LevelPartial, StageNoID } from './list'; -import { extinct } from '../assert'; const imgUrl = assetUrl + 'images/learn/bowman.svg'; const stage: StageNoID = { diff --git a/ui/learn/src/stage/checkmate1.ts b/ui/learn/src/stage/checkmate1.ts index 0b4599983e1..ce49b71e7ac 100644 --- a/ui/learn/src/stage/checkmate1.ts +++ b/ui/learn/src/stage/checkmate1.ts @@ -1,5 +1,5 @@ -import { arrow, assetUrl, roundSvg, toLevel } from '../util'; import { mate, not } from '../assert'; +import { arrow, assetUrl, roundSvg, toLevel } from '../util'; import type { StageNoID } from './list'; const imgUrl = assetUrl + 'images/learn/guillotine.svg'; diff --git a/ui/learn/src/stage/king.ts b/ui/learn/src/stage/king.ts index 041f4f5c26a..7a3ceae8e17 100644 --- a/ui/learn/src/stage/king.ts +++ b/ui/learn/src/stage/king.ts @@ -1,5 +1,5 @@ -import type { LevelPartial, StageNoID } from './list'; import { arrow, assetUrl, pieceImg, toLevel } from '../util'; +import type { LevelPartial, StageNoID } from './list'; const stage: StageNoID = { key: 'king', diff --git a/ui/learn/src/stage/list.ts b/ui/learn/src/stage/list.ts index fb2016196eb..7c2c6b9b73a 100644 --- a/ui/learn/src/stage/list.ts +++ b/ui/learn/src/stage/list.ts @@ -1,26 +1,27 @@ -import rook from './rook'; -import bishop from './bishop'; -import queen from './queen'; -import king from './king'; -import knight from './knight'; -import pawn from './pawn'; -import capture from './capture'; -import protection from './protection'; -import combat from './combat'; -import check1 from './check1'; -import outOfCheck from './outOfCheck'; -import checkmate1 from './checkmate1'; -import setup from './setup'; -import castling from './castling'; -import enpassant from './enpassant'; -import stalemate from './stalemate'; -import value from './value'; -import check2 from './check2'; -import type { AssertData } from '../levelCtrl'; -import type { ScenarioLevel } from '../scenario'; import type { SquareName } from 'chessops'; import type { VNode } from 'snabbdom'; + import type { Shape } from '../chessground'; +import type { AssertData } from '../levelCtrl'; +import type { ScenarioLevel } from '../scenario'; +import bishop from './bishop'; +import capture from './capture'; +import castling from './castling'; +import check1 from './check1'; +import check2 from './check2'; +import checkmate1 from './checkmate1'; +import combat from './combat'; +import enpassant from './enpassant'; +import king from './king'; +import knight from './knight'; +import outOfCheck from './outOfCheck'; +import pawn from './pawn'; +import protection from './protection'; +import queen from './queen'; +import rook from './rook'; +import setup from './setup'; +import stalemate from './stalemate'; +import value from './value'; export type Level = LevelBase & LevelDefaults; export type LevelPartial = LevelBase & Partial; diff --git a/ui/learn/src/stage/setup.ts b/ui/learn/src/stage/setup.ts index c2fdb40ca29..ae0d1644b23 100644 --- a/ui/learn/src/stage/setup.ts +++ b/ui/learn/src/stage/setup.ts @@ -1,5 +1,5 @@ -import { arrow, assetUrl, roundSvg, toLevel } from '../util'; import { and, pieceOn } from '../assert'; +import { arrow, assetUrl, roundSvg, toLevel } from '../util'; import type { StageNoID } from './list'; const imgUrl = assetUrl + 'images/learn/rally-the-troops.svg'; diff --git a/ui/learn/src/stage/stalemate.ts b/ui/learn/src/stage/stalemate.ts index 89c09d696ce..561f3f2f522 100644 --- a/ui/learn/src/stage/stalemate.ts +++ b/ui/learn/src/stage/stalemate.ts @@ -1,5 +1,5 @@ -import { arrow, assetUrl, circle, roundSvg, toLevel } from '../util'; import { scenarioComplete, scenarioFailed } from '../assert'; +import { arrow, assetUrl, circle, roundSvg, toLevel } from '../util'; import type { StageNoID } from './list'; const imgUrl = assetUrl + 'images/learn/scales.svg'; diff --git a/ui/learn/src/stage/value.ts b/ui/learn/src/stage/value.ts index 758ec2fd69a..3f3bcc30167 100644 --- a/ui/learn/src/stage/value.ts +++ b/ui/learn/src/stage/value.ts @@ -1,5 +1,5 @@ -import { arrow, assetUrl, roundSvg, toLevel } from '../util'; import { scenarioComplete, scenarioFailed } from '../assert'; +import { arrow, assetUrl, roundSvg, toLevel } from '../util'; import type { StageNoID } from './list'; const imgUrl = assetUrl + 'images/learn/sprint.svg'; diff --git a/ui/learn/src/storage.ts b/ui/learn/src/storage.ts index 8d961a90e9b..2d282f7f9df 100644 --- a/ui/learn/src/storage.ts +++ b/ui/learn/src/storage.ts @@ -1,7 +1,8 @@ +import { storage } from 'lib/storage'; import * as xhr from 'lib/xhr'; + import type { LearnProgress } from './learn'; import type { Stage } from './stage/list'; -import { storage } from 'lib/storage'; export interface Storage { data: LearnProgress; diff --git a/ui/learn/src/util.ts b/ui/learn/src/util.ts index cf7aaeb9d65..8bba22f0449 100644 --- a/ui/learn/src/util.ts +++ b/ui/learn/src/util.ts @@ -1,8 +1,9 @@ -import type { SquareName } from 'chessops'; -import type { Level, LevelPartial } from './stage/list'; -import { h } from 'snabbdom'; import type { DrawShape } from '@lichess-org/chessground/draw'; import type { BrushColor } from '@lichess-org/chessground/types'; +import type { SquareName } from 'chessops'; +import { h } from 'snabbdom'; + +import type { Level, LevelPartial } from './stage/list'; export function toLevel(l: LevelPartial, it: number): Level { if (l.fen.split(' ').length === 4) l.fen += ' 0 1'; diff --git a/ui/learn/src/view.ts b/ui/learn/src/view.ts index 06252c9c10b..b31a754622d 100644 --- a/ui/learn/src/view.ts +++ b/ui/learn/src/view.ts @@ -1,13 +1,15 @@ -import * as licon from 'lib/licon'; import { h, type VNode } from 'snabbdom'; + +import * as licon from 'lib/licon'; + import type { LearnCtrl } from './ctrl'; -import { type Stage, categs } from './stage/list'; -import type { StageProgress } from './learn'; -import * as scoring from './score'; -import { assetUrl } from './util'; -import { mapSideView } from './mapSideView'; import { hashHref } from './hashRouting'; +import type { StageProgress } from './learn'; +import { mapSideView } from './mapSideView'; import { runView } from './run/runView'; +import * as scoring from './score'; +import { type Stage, categs } from './stage/list'; +import { assetUrl } from './util'; export const view = (ctrl: LearnCtrl): VNode => (ctrl.inStage() ? runView(ctrl) : mapView(ctrl)); diff --git a/ui/lib/src/bigFileStorage.ts b/ui/lib/src/bigFileStorage.ts index fcc2736bd15..135960b1cff 100644 --- a/ui/lib/src/bigFileStorage.ts +++ b/ui/lib/src/bigFileStorage.ts @@ -1,6 +1,6 @@ -import { objectStorage } from './objectStorage'; -import { memoize } from './index'; import { randomToken } from './algo'; +import { memoize } from './index'; +import { objectStorage } from './objectStorage'; import { log } from './permalog'; // url keyed storage for very large assets diff --git a/ui/lib/src/bot/bot.ts b/ui/lib/src/bot/bot.ts index 20003261519..65a422f7eb5 100644 --- a/ui/lib/src/bot/bot.ts +++ b/ui/lib/src/bot/bot.ts @@ -1,6 +1,11 @@ +import type { SearchResult } from '@lichess-org/zerofish'; import * as co from 'chessops'; -import { zip } from '../algo'; + import { clockToSpeed } from '@/game'; + +import { zip } from '../algo'; +import type { OpeningBook } from '../game/polyglot'; +import type { BotLoader } from './botLoader'; import { type FilterFacetValue, type FilterSpec, @@ -11,10 +16,7 @@ import { filterFacetKeys, combine, } from './filter'; -import type { SearchResult } from '@lichess-org/zerofish'; -import type { OpeningBook } from '../game/polyglot'; import { movetime as getMovetime } from './movetime'; -import type { BotLoader } from './botLoader'; import type { BotInfo, FishSearch, diff --git a/ui/lib/src/bot/botLoader.ts b/ui/lib/src/bot/botLoader.ts index 9970793f7e6..96db9c981d6 100644 --- a/ui/lib/src/bot/botLoader.ts +++ b/ui/lib/src/bot/botLoader.ts @@ -1,12 +1,13 @@ -import makeZerofish, { type Zerofish } from '@lichess-org/zerofish'; -import { type OpeningBook, makeBookFromPolyglot } from '../game/polyglot'; -import { Bot } from './bot'; -import type { BotInfo, MoveSource, LocalSpeed, AssetType } from './types'; -import * as xhr from '../xhr'; -import { definedMap } from '../algo'; -import { makeLichessBook } from './lichessBook'; -import { myUserId, myUsername } from '../index'; import './filters'; +import makeZerofish, { type Zerofish } from '@lichess-org/zerofish'; + +import { definedMap } from '../algo'; +import { type OpeningBook, makeBookFromPolyglot } from '../game/polyglot'; +import { myUserId, myUsername } from '../index'; +import * as xhr from '../xhr'; +import { Bot } from './bot'; +import { makeLichessBook } from './lichessBook'; +import type { BotInfo, MoveSource, LocalSpeed, AssetType } from './types'; export { makeZerofish, type Zerofish }; diff --git a/ui/lib/src/bot/filters/aggression.ts b/ui/lib/src/bot/filters/aggression.ts index a76b19ecd6d..fa65c6a6be6 100644 --- a/ui/lib/src/bot/filters/aggression.ts +++ b/ui/lib/src/bot/filters/aggression.ts @@ -1,9 +1,11 @@ import * as co from 'chessops'; -import type { SearchMove, MoveArgs } from '../types'; -import type { FilterResult } from '../filter'; -import { Bot } from '../bot'; + import { normalMove } from '@/game'; +import { Bot } from '../bot'; +import type { FilterResult } from '../filter'; +import type { SearchMove, MoveArgs } from '../types'; + Bot.registerFilter('aggression', { info: { label: 'aggression', diff --git a/ui/lib/src/bot/filters/pawnStructure.ts b/ui/lib/src/bot/filters/pawnStructure.ts index 23974444409..857037bc976 100644 --- a/ui/lib/src/bot/filters/pawnStructure.ts +++ b/ui/lib/src/bot/filters/pawnStructure.ts @@ -1,10 +1,12 @@ import * as co from 'chessops'; -import type { SearchMove, MoveArgs } from '../types'; -import type { FilterResult } from '../filter'; -import { Bot } from '../bot'; + import { clamp } from '@/algo'; import { normalMove } from '@/game'; +import { Bot } from '../bot'; +import type { FilterResult } from '../filter'; +import type { SearchMove, MoveArgs } from '../types'; + Bot.registerFilter('pawnStructure', { score, info: { diff --git a/ui/lib/src/bot/lichessBook.ts b/ui/lib/src/bot/lichessBook.ts index f7536a31590..9860f532f75 100644 --- a/ui/lib/src/bot/lichessBook.ts +++ b/ui/lib/src/bot/lichessBook.ts @@ -1,6 +1,7 @@ -import type { OpeningBook } from '../game/polyglot'; import * as co from 'chessops'; + import { clamp } from '../algo'; +import type { OpeningBook } from '../game/polyglot'; export function makeLichessBook(): OpeningBook { // todo, timeout cancel and probably don't even bother below bullet diff --git a/ui/lib/src/bot/types.ts b/ui/lib/src/bot/types.ts index 98968a12f68..4db305750ec 100644 --- a/ui/lib/src/bot/types.ts +++ b/ui/lib/src/bot/types.ts @@ -1,5 +1,6 @@ import type { Position } from '@lichess-org/zerofish'; import type { Chess } from 'chessops'; + import type { Filters } from './filter'; export type Sound = { key: string; chance: number; delay: Seconds; mix: number }; diff --git a/ui/lib/src/ceval/ctrl.ts b/ui/lib/src/ceval/ctrl.ts index d4d857ee488..6159cd4830b 100644 --- a/ui/lib/src/ceval/ctrl.ts +++ b/ui/lib/src/ceval/ctrl.ts @@ -1,6 +1,16 @@ // no side effects allowed due to re-export by index.ts +import type { Rules } from 'chessops'; +import { lichessRules } from 'chessops/compat'; +import { parseFen } from 'chessops/fen'; +import { setupPosition } from 'chessops/variant'; + +import type { LocalEval, PvData, TreePath } from '@/tree/types'; + +import { clamp } from '../algo'; import { throttle } from '../async'; +import { prop, type Prop, type Toggle, toggle } from '../index'; +import { storedIntProp, storage } from '../storage'; import { Engines } from './engines/engines'; import { type CevalOpts, @@ -14,15 +24,7 @@ import { CevalState, } from './types'; import { sanIrreversible, showEngineError, fewerCores } from './util'; -import { setupPosition } from 'chessops/variant'; -import { parseFen } from 'chessops/fen'; -import { lichessRules } from 'chessops/compat'; import { povChances } from './winningChances'; -import { prop, type Prop, type Toggle, toggle } from '../index'; -import { clamp } from '../algo'; -import { storedIntProp, storage } from '../storage'; -import type { Rules } from 'chessops'; -import type { LocalEval, PvData, TreePath } from '@/tree/types'; export default class CevalCtrl { opts: CevalOpts; diff --git a/ui/lib/src/ceval/engines/engines.ts b/ui/lib/src/ceval/engines/engines.ts index 8b4638bc4d4..26aa02ccd58 100644 --- a/ui/lib/src/ceval/engines/engines.ts +++ b/ui/lib/src/ceval/engines/engines.ts @@ -1,14 +1,16 @@ -import type { BrowserEngineInfo, ExternalEngineInfo, EngineInfo, CevalEngine } from '../types'; +import { lichessRules } from 'chessops/compat'; + +import { isAndroid, isIos, isIPad, features as browserSupport } from '@/device'; +import { log } from '@/permalog'; +import { storedStringProp, type StoredProp } from '@/storage'; +import { xhrHeader } from '@/xhr'; + import type CevalCtrl from '../ctrl'; +import type { BrowserEngineInfo, ExternalEngineInfo, EngineInfo, CevalEngine } from '../types'; +import { ExternalEngine } from './externalEngine'; import { SimpleEngine } from './simpleEngine'; import { StockfishWebEngine } from './stockfishWebEngine'; import { ThreadedEngine } from './threadedEngine'; -import { ExternalEngine } from './externalEngine'; -import { storedStringProp, type StoredProp } from '@/storage'; -import { isAndroid, isIos, isIPad, features as browserSupport } from '@/device'; -import { xhrHeader } from '@/xhr'; -import { lichessRules } from 'chessops/compat'; -import { log } from '@/permalog'; export class Engines { private activeEngine: EngineInfo | undefined = undefined; diff --git a/ui/lib/src/ceval/engines/externalEngine.ts b/ui/lib/src/ceval/engines/externalEngine.ts index a150bd8f471..f4ad7a11c48 100644 --- a/ui/lib/src/ceval/engines/externalEngine.ts +++ b/ui/lib/src/ceval/engines/externalEngine.ts @@ -1,3 +1,7 @@ +import { randomToken } from '@/algo'; +import { throttle } from '@/async'; +import { readNdJson } from '@/xhr'; + import { type Work, type ExternalEngineInfo, @@ -5,9 +9,6 @@ import { type EngineNotifier, CevalState, } from '../types'; -import { randomToken } from '@/algo'; -import { readNdJson } from '@/xhr'; -import { throttle } from '@/async'; interface ExternalEngineOutput { time: number; diff --git a/ui/lib/src/ceval/engines/stockfishWebEngine.ts b/ui/lib/src/ceval/engines/stockfishWebEngine.ts index de5629b442c..2e25178cb12 100644 --- a/ui/lib/src/ceval/engines/stockfishWebEngine.ts +++ b/ui/lib/src/ceval/engines/stockfishWebEngine.ts @@ -1,3 +1,8 @@ +import type StockfishWeb from '@lichess-org/stockfish-web'; + +import { bigFileStorage } from '@/bigFileStorage'; + +import { Protocol } from '../protocol'; import { CevalState, type Work, @@ -5,10 +10,7 @@ import { type BrowserEngineInfo, type EngineNotifier, } from '../types'; -import { Protocol } from '../protocol'; import { sharedWasmMemory } from '../util'; -import type StockfishWeb from '@lichess-org/stockfish-web'; -import { bigFileStorage } from '@/bigFileStorage'; export class StockfishWebEngine implements CevalEngine { failed: Error; diff --git a/ui/lib/src/ceval/engines/threadedEngine.ts b/ui/lib/src/ceval/engines/threadedEngine.ts index 616fbce5985..e5fd97b24bd 100644 --- a/ui/lib/src/ceval/engines/threadedEngine.ts +++ b/ui/lib/src/ceval/engines/threadedEngine.ts @@ -1,3 +1,4 @@ +import { Cache } from '../cache'; import { Protocol } from '../protocol'; import { CevalState, @@ -7,7 +8,6 @@ import { type EngineNotifier, } from '../types'; import { sharedWasmMemory } from '../util'; -import { Cache } from '../cache'; interface WasmModule { (opts: { diff --git a/ui/lib/src/ceval/protocol.ts b/ui/lib/src/ceval/protocol.ts index a3cfd744584..0af1f92d470 100644 --- a/ui/lib/src/ceval/protocol.ts +++ b/ui/lib/src/ceval/protocol.ts @@ -1,4 +1,5 @@ import type { LocalEval } from '@/tree/types'; + import { defined } from '../index'; import type { Work } from './types'; diff --git a/ui/lib/src/ceval/types.ts b/ui/lib/src/ceval/types.ts index 4391cc21d51..ac01b234907 100644 --- a/ui/lib/src/ceval/types.ts +++ b/ui/lib/src/ceval/types.ts @@ -1,9 +1,11 @@ -import type { Prop } from '../index'; -import type { Feature } from '../device'; -import type CevalCtrl from './ctrl'; import type { VNode } from 'snabbdom'; + import type { ClientEval, LocalEval, ServerEval, TreeNode } from '@/tree/types'; +import type { Feature } from '../device'; +import type { Prop } from '../index'; +import type CevalCtrl from './ctrl'; + export type WinningChances = number; export type SearchBy = { movetime: number } | { depth: number } | { nodes: number }; export type Search = { by: SearchBy; multiPv: number; indeterminate?: boolean }; diff --git a/ui/lib/src/ceval/util.ts b/ui/lib/src/ceval/util.ts index 6d204ff57d0..053e4abee5f 100644 --- a/ui/lib/src/ceval/util.ts +++ b/ui/lib/src/ceval/util.ts @@ -1,6 +1,7 @@ // no side effects allowed due to re-export by index.ts import type { ClientEval } from '@/tree/types'; + import { isMobile } from '../device'; import { memoize, escapeHtml } from '../index'; import { domDialog } from '../view/dialog'; diff --git a/ui/lib/src/ceval/view/main.ts b/ui/lib/src/ceval/view/main.ts index f1baa39de61..28c4be374c4 100644 --- a/ui/lib/src/ceval/view/main.ts +++ b/ui/lib/src/ceval/view/main.ts @@ -1,24 +1,26 @@ // no side effects allowed due to re-export by index.ts -import { povChances } from '../winningChances'; -import * as licon from '@/licon'; -import { stepwiseScroll, type VNode, type LooseVNodes, bind, hl } from '@/view'; -import { cmnToggle } from '@/view/cmn-toggle'; -import { blurIfPrimaryClick, defined, notNull, requestIdleCallback } from '@/index'; -import { type CevalHandler, type NodeEvals, CevalState } from '../types'; +import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { uciToMove } from '@lichess-org/chessground/util'; import type { Position } from 'chessops/chess'; import { lichessRules } from 'chessops/compat'; +import { parseFen, makeBoardFen } from 'chessops/fen'; import { makeSanAndPlay } from 'chessops/san'; import { opposite, parseUci } from 'chessops/util'; -import { parseFen, makeBoardFen } from 'chessops/fen'; -import { renderEval } from '../util'; import { setupPosition } from 'chessops/variant'; -import { uciToMove } from '@lichess-org/chessground/util'; -import { renderCevalSettings } from './settings'; -import type CevalCtrl from '../ctrl'; -import { Chessground as makeChessground } from '@lichess-org/chessground'; + import { isTouchDevice } from '@/device'; +import { blurIfPrimaryClick, defined, notNull, requestIdleCallback } from '@/index'; +import * as licon from '@/licon'; import type { ClientEval, LocalEval, PvData } from '@/tree/types'; +import { stepwiseScroll, type VNode, type LooseVNodes, bind, hl } from '@/view'; +import { cmnToggle } from '@/view/cmn-toggle'; + +import type CevalCtrl from '../ctrl'; +import { type CevalHandler, type NodeEvals, CevalState } from '../types'; +import { renderEval } from '../util'; +import { povChances } from '../winningChances'; +import { renderCevalSettings } from './settings'; type EvalInfo = { knps: number; npsText: string; depthText: string }; diff --git a/ui/lib/src/ceval/view/settings.ts b/ui/lib/src/ceval/view/settings.ts index 4d5e69b216e..d373422ba60 100644 --- a/ui/lib/src/ceval/view/settings.ts +++ b/ui/lib/src/ceval/view/settings.ts @@ -1,11 +1,12 @@ -import type { CevalHandler } from '../types'; -import type CevalCtrl from '../ctrl'; -import { fewerCores } from '../util'; -import { isChrome } from '@/device'; -import { type VNode, onInsert, bind, dataIcon, hl, rangeConfig, confirm } from '@/view'; -import * as Licon from '@/licon'; -import { onClickAway } from '@/index'; import { clamp } from '@/algo'; +import { isChrome } from '@/device'; +import { onClickAway } from '@/index'; +import * as Licon from '@/licon'; +import { type VNode, onInsert, bind, dataIcon, hl, rangeConfig, confirm } from '@/view'; + +import type CevalCtrl from '../ctrl'; +import type { CevalHandler } from '../types'; +import { fewerCores } from '../util'; const allSearchTicks: number[] = [2, 4, 6, 8, 10, 12, 15, 20, 30, Number.POSITIVE_INFINITY]; diff --git a/ui/lib/src/chat/chatCtrl.ts b/ui/lib/src/chat/chatCtrl.ts index fe074455711..b98f58e952c 100644 --- a/ui/lib/src/chat/chatCtrl.ts +++ b/ui/lib/src/chat/chatCtrl.ts @@ -1,3 +1,10 @@ +import { isContained } from '@/algo'; +import { isMobile } from '@/device'; + +import { prop, type Prop } from '../index'; +import { pubsub, type PubsubEvents } from '../pubsub'; +import { storedStringProp, storedBooleanProp } from '../storage'; +import { alert } from '../view/dialogs'; import type { ChatOpts, Line, @@ -10,15 +17,9 @@ import type { VoiceChatData, ChatPlugin, } from './interfaces'; -import { type PresetCtrl, presetCtrl } from './preset'; -import { noteCtrl } from './note'; import { moderationCtrl } from './moderation'; -import { prop, type Prop } from '../index'; -import { storedStringProp, storedBooleanProp } from '../storage'; -import { pubsub, type PubsubEvents } from '../pubsub'; -import { alert } from '../view/dialogs'; -import { isContained } from '@/algo'; -import { isMobile } from '@/device'; +import { noteCtrl } from './note'; +import { type PresetCtrl, presetCtrl } from './preset'; type SubPair = { [K in keyof PubsubEvents]: [K, PubsubEvents[K]] }[keyof PubsubEvents]; diff --git a/ui/lib/src/chat/discussion.ts b/ui/lib/src/chat/discussion.ts index b6c4a7c8b83..430f3390aa0 100644 --- a/ui/lib/src/chat/discussion.ts +++ b/ui/lib/src/chat/discussion.ts @@ -1,16 +1,18 @@ -import * as licon from '../licon'; -import * as enhance from '../richText'; -import { userLink } from '../view/userLink'; -import * as spam from './spam'; -import type { Line } from './interfaces'; import { h, thunk, type VNode, type VNodeData } from 'snabbdom'; + +import { enter } from '@/view'; + +import * as licon from '../licon'; +import { pubsub } from '../pubsub'; +import * as enhance from '../richText'; +import { tempStorage } from '../storage'; +import { alert } from '../view/dialogs'; +import { userLink } from '../view/userLink'; +import type { ChatCtrl } from './chatCtrl'; +import type { Line } from './interfaces'; import { lineAction as modLineAction, flagReport } from './moderation'; import { presetView } from './preset'; -import type { ChatCtrl } from './chatCtrl'; -import { tempStorage } from '../storage'; -import { pubsub } from '../pubsub'; -import { alert } from '../view/dialogs'; -import { enter } from '@/view'; +import * as spam from './spam'; const whisperRegex = /^\/[wW](?:hisper)?\s/; const scrollState = { pinToBottom: true, lastScrollTop: 0 }; diff --git a/ui/lib/src/chat/interfaces.ts b/ui/lib/src/chat/interfaces.ts index 9f0e0767625..77dd8d16d3b 100644 --- a/ui/lib/src/chat/interfaces.ts +++ b/ui/lib/src/chat/interfaces.ts @@ -1,6 +1,6 @@ import type { VNode } from 'snabbdom'; -import type { Prop } from '@/index'; +import type { Prop } from '@/index'; import type { EnhanceOpts } from '@/richText'; export type { ChatCtrl } from './chatCtrl'; diff --git a/ui/lib/src/chat/moderation.ts b/ui/lib/src/chat/moderation.ts index 823d261a664..7492f7f7f0b 100644 --- a/ui/lib/src/chat/moderation.ts +++ b/ui/lib/src/chat/moderation.ts @@ -1,6 +1,10 @@ import { h, type VNode } from 'snabbdom'; -import * as licon from '../licon'; + import { bind, confirm } from '@/view'; + +import { numberFormat } from '../i18n'; +import * as licon from '../licon'; +import { pubsub } from '../pubsub'; import { userLink } from '../view/userLink'; import type { ModerationCtrl, @@ -9,9 +13,7 @@ import type { ModerationReason, ChatCtrl, } from './interfaces'; -import { numberFormat } from '../i18n'; import { userModInfo, flag, timeout } from './xhr'; -import { pubsub } from '../pubsub'; export function moderationCtrl(opts: ModerationOpts): ModerationCtrl { let data: ModerationData | undefined; diff --git a/ui/lib/src/chat/note.ts b/ui/lib/src/chat/note.ts index 5c709c4e390..af75b4326d7 100644 --- a/ui/lib/src/chat/note.ts +++ b/ui/lib/src/chat/note.ts @@ -1,7 +1,8 @@ import { h, type VNode } from 'snabbdom'; + +import { debounce } from '../async'; import type { NoteCtrl, NoteOpts } from './interfaces'; import * as xhr from './xhr'; -import { debounce } from '../async'; export function noteCtrl(opts: NoteOpts): NoteCtrl { let text: string | undefined = opts.text; diff --git a/ui/lib/src/chat/preset.ts b/ui/lib/src/chat/preset.ts index 7180fd8e54c..4c070791505 100644 --- a/ui/lib/src/chat/preset.ts +++ b/ui/lib/src/chat/preset.ts @@ -1,4 +1,5 @@ import { h, type VNode } from 'snabbdom'; + import { bind } from '@/view'; export interface PresetCtrl { diff --git a/ui/lib/src/chat/renderChat.ts b/ui/lib/src/chat/renderChat.ts index 9f48846f915..e68ed7c12be 100644 --- a/ui/lib/src/chat/renderChat.ts +++ b/ui/lib/src/chat/renderChat.ts @@ -1,13 +1,14 @@ -import * as licon from '../licon'; -import { type VNode, hl, bind } from '@/view'; -import { cmnToggleProp } from '@/view/cmn-toggle'; -import type { Tab, VoiceChat } from './interfaces'; -import discussionView from './discussion'; -import { noteView } from './note'; -import { moderationView } from './moderation'; import { type Hooks } from 'snabbdom'; +import { type VNode, hl, bind } from '@/view'; +import { cmnToggleProp } from '@/view/cmn-toggle'; + +import * as licon from '../licon'; import type { ChatCtrl } from './chatCtrl'; +import discussionView from './discussion'; +import type { Tab, VoiceChat } from './interfaces'; +import { moderationView } from './moderation'; +import { noteView } from './note'; export function renderChat(ctrl: ChatCtrl, hook: Hooks = {}): VNode { return hl( diff --git a/ui/lib/src/chat/spam.ts b/ui/lib/src/chat/spam.ts index 26cf60feacd..d282cb2b0fe 100644 --- a/ui/lib/src/chat/spam.ts +++ b/ui/lib/src/chat/spam.ts @@ -1,5 +1,5 @@ -import * as xhr from '../xhr'; import { storage } from '../storage'; +import * as xhr from '../xhr'; export const skip = (txt: string): boolean => (suspLink(txt) || followMe(txt)) && !isKnownSpammer(); diff --git a/ui/lib/src/chat/standalone.ts b/ui/lib/src/chat/standalone.ts index 40153f04965..4e6e5786ad7 100644 --- a/ui/lib/src/chat/standalone.ts +++ b/ui/lib/src/chat/standalone.ts @@ -1,8 +1,8 @@ import { init, attributesModule, classModule } from 'snabbdom'; -import { renderChat } from './renderChat'; -import type { ChatOpts } from './interfaces'; import { ChatCtrl } from './chatCtrl'; +import type { ChatOpts } from './interfaces'; +import { renderChat } from './renderChat'; // standalone chat app, can be instanciated outside of a snabbdom context export default function standaloneChat(data: Partial): ChatCtrl { diff --git a/ui/lib/src/chessgroundResize.ts b/ui/lib/src/chessgroundResize.ts index eed397bd341..77b9f173cdf 100644 --- a/ui/lib/src/chessgroundResize.ts +++ b/ui/lib/src/chessgroundResize.ts @@ -1,8 +1,9 @@ import type { Elements } from '@lichess-org/chessground/types'; -import * as xhr from './xhr'; + import { debounce } from './async'; import { ShowResizeHandle } from './prefs'; import { pubsub } from './pubsub'; +import * as xhr from './xhr'; type MouchEvent = Event & Partial; diff --git a/ui/lib/src/device.ts b/ui/lib/src/device.ts index 3219a140b7d..d2aa0836925 100644 --- a/ui/lib/src/device.ts +++ b/ui/lib/src/device.ts @@ -1,6 +1,6 @@ import { memoize } from './index'; -import { bind, type Hooks } from './view'; import * as licon from './licon'; +import { bind, type Hooks } from './view'; export const hookMobileMousedown = (f: (e: Event) => any): Hooks => bind('ontouchstart' in window ? 'click' : 'mousedown', f); diff --git a/ui/lib/src/game/chess.ts b/ui/lib/src/game/chess.ts index 808e556b2ce..dcad6c04f81 100644 --- a/ui/lib/src/game/chess.ts +++ b/ui/lib/src/game/chess.ts @@ -1,8 +1,9 @@ // no side effects allowed due to re-export by index.ts -import { shuffle } from '../algo'; -import { normalizeMove } from 'chessops/chess'; import { type Chess, type NormalMove, parseUci, makeUci } from 'chessops'; +import { normalizeMove } from 'chessops/chess'; + +import { shuffle } from '../algo'; export const fixCrazySan = (san: San): San => (san[0] === 'P' ? san.slice(1) : san); diff --git a/ui/lib/src/game/clock/clockCtrl.ts b/ui/lib/src/game/clock/clockCtrl.ts index c56037069fa..97bb5bfe74f 100644 --- a/ui/lib/src/game/clock/clockCtrl.ts +++ b/ui/lib/src/game/clock/clockCtrl.ts @@ -1,6 +1,7 @@ -import { updateElements, formatClockTimeVerbal } from './clockView'; import { ShowClockTenths } from '@/prefs'; +import { updateElements, formatClockTimeVerbal } from './clockView'; + export interface ClockOpts { onFlag(): void; bothPlayersHavePlayed(): boolean; diff --git a/ui/lib/src/game/clock/clockView.ts b/ui/lib/src/game/clock/clockView.ts index 7f445144b4a..07162dc9f17 100644 --- a/ui/lib/src/game/clock/clockView.ts +++ b/ui/lib/src/game/clock/clockView.ts @@ -1,7 +1,8 @@ -import type { ClockElements, ClockCtrl } from './clockCtrl'; -import { hl, type VNode, type LooseVNodes, type Hooks } from '@/view'; -import type { TopOrBottom } from '../index'; import { displayColumns } from '@/device'; +import { hl, type VNode, type LooseVNodes, type Hooks } from '@/view'; + +import type { TopOrBottom } from '../index'; +import type { ClockElements, ClockCtrl } from './clockCtrl'; export function renderClock( ctrl: ClockCtrl, diff --git a/ui/lib/src/game/glyphs.ts b/ui/lib/src/game/glyphs.ts index ff8aeb092ee..421bb8c767b 100644 --- a/ui/lib/src/game/glyphs.ts +++ b/ui/lib/src/game/glyphs.ts @@ -1,5 +1,6 @@ -import { parseUci, makeSquare, squareRank } from 'chessops/util'; import type { DrawShape } from '@lichess-org/chessground/draw'; +import { parseUci, makeSquare, squareRank } from 'chessops/util'; + import type { Glyph, TreeNode } from '@/tree/types'; // maximum number of glyphs to show for a given move diff --git a/ui/lib/src/game/material.ts b/ui/lib/src/game/material.ts index 1db877bdb29..92361fbc8ad 100644 --- a/ui/lib/src/game/material.ts +++ b/ui/lib/src/game/material.ts @@ -1,7 +1,8 @@ import { opposite } from '@lichess-org/chessground/util'; -import type { CheckCount, CheckState, MaterialDiff } from './interfaces'; import { charToRole, ROLES, type Board } from 'chessops'; +import type { CheckCount, CheckState, MaterialDiff } from './interfaces'; + export function getMaterialDiff(chess: FEN | Board): MaterialDiff { const diff: MaterialDiff = { white: { king: 0, queen: 0, rook: 0, bishop: 0, knight: 0, pawn: 0 }, diff --git a/ui/lib/src/game/promotion.ts b/ui/lib/src/game/promotion.ts index c11c0c3e513..c8a75b54516 100644 --- a/ui/lib/src/game/promotion.ts +++ b/ui/lib/src/game/promotion.ts @@ -1,9 +1,11 @@ -import { h } from 'snabbdom'; -import { AutoQueen } from '../prefs'; -import { type MaybeVNode, bind, onInsert } from '@/view'; import type { DrawShape } from '@lichess-org/chessground/draw'; -import { opposite, key2pos } from '@lichess-org/chessground/util'; import type { MoveMetadata } from '@lichess-org/chessground/types'; +import { opposite, key2pos } from '@lichess-org/chessground/util'; +import { h } from 'snabbdom'; + +import { type MaybeVNode, bind, onInsert } from '@/view'; + +import { AutoQueen } from '../prefs'; import type { WithGround } from './ground'; export type Hooks = { diff --git a/ui/lib/src/game/sanWriter.ts b/ui/lib/src/game/sanWriter.ts index 656bcf2ba64..49629d5e4a3 100644 --- a/ui/lib/src/game/sanWriter.ts +++ b/ui/lib/src/game/sanWriter.ts @@ -1,6 +1,7 @@ // no side effects allowed due to re-export by index.ts import { charToRole, makeSquare, type Square } from 'chessops'; + import { fixCrazySan } from './chess'; type AlmostSan = string; diff --git a/ui/lib/src/game/view/material.ts b/ui/lib/src/game/view/material.ts index 1864d935f1a..5fbd23ab592 100644 --- a/ui/lib/src/game/view/material.ts +++ b/ui/lib/src/game/view/material.ts @@ -1,8 +1,9 @@ -import { h, type VNode } from 'snabbdom'; -import type { CheckCount, CheckState, MaterialDiffSide } from '../interfaces'; -import { countChecks, getMaterialDiff, getScore, NO_CHECKS } from '../material'; import { opposite } from '@lichess-org/chessground/util'; import { type Board } from 'chessops'; +import { h, type VNode } from 'snabbdom'; + +import type { CheckCount, CheckState, MaterialDiffSide } from '../interfaces'; +import { countChecks, getMaterialDiff, getScore, NO_CHECKS } from '../material'; function renderMaterialDiff( material: MaterialDiffSide, diff --git a/ui/lib/src/nvui/command.ts b/ui/lib/src/nvui/command.ts index 20b94818e49..be2f4d6cf40 100644 --- a/ui/lib/src/nvui/command.ts +++ b/ui/lib/src/nvui/command.ts @@ -1,8 +1,10 @@ -import { type VNode, type VNodeChildren, h } from 'snabbdom'; -import { renderPieceKeys, renderPiecesOn, type MoveStyle } from './chess'; import type { Pieces } from '@lichess-org/chessground/types'; +import { type VNode, type VNodeChildren, h } from 'snabbdom'; + import { memoize } from '@/common'; +import { renderPieceKeys, renderPiecesOn, type MoveStyle } from './chess'; + interface Command { help: VNode | string; apply(c: string, pieces: Pieces, style: MoveStyle): string | undefined; diff --git a/ui/lib/src/nvui/directionScan.ts b/ui/lib/src/nvui/directionScan.ts index 397e4f7acd5..103ece8849b 100644 --- a/ui/lib/src/nvui/directionScan.ts +++ b/ui/lib/src/nvui/directionScan.ts @@ -1,5 +1,6 @@ import type { Pieces, Pos } from '@lichess-org/chessground/types'; import { key2pos, pos2key } from '@lichess-org/chessground/util'; + import { keyFromAttrs, type MoveStyle, renderKey, transPieceStr } from './chess'; const directions = ['top', 'topRight', 'right', 'bottomRight', 'bottom', 'bottomLeft', 'left', 'topLeft']; diff --git a/ui/lib/src/nvui/handler.ts b/ui/lib/src/nvui/handler.ts index 74cbb60d6ea..3f8d48d1339 100644 --- a/ui/lib/src/nvui/handler.ts +++ b/ui/lib/src/nvui/handler.ts @@ -1,9 +1,11 @@ import { files } from '@lichess-org/chessground/types'; -import { parseFen } from 'chessops/fen'; import { chessgroundDests, lichessRules } from 'chessops/compat'; -import { setupPosition } from 'chessops/variant'; +import { parseFen } from 'chessops/fen'; import { charToRole, opposite, parseUci } from 'chessops/util'; +import { setupPosition } from 'chessops/variant'; + import { destsToUcis, sanToUci, sanWriter } from '@/game'; + import { renderPieceStr, keyFromAttrs, isKey, pieceStr } from './render'; import type { PieceStyle, PrefixStyle } from './setting'; diff --git a/ui/lib/src/nvui/notify.ts b/ui/lib/src/nvui/notify.ts index fc3dab3840b..1b34502b9a5 100644 --- a/ui/lib/src/nvui/notify.ts +++ b/ui/lib/src/nvui/notify.ts @@ -1,6 +1,7 @@ import { h, type VNode, type VNodeData } from 'snabbdom'; -import { requestIdleCallback } from '../index'; + import { isMac } from '../device'; +import { requestIdleCallback } from '../index'; export class Notify { text = ''; diff --git a/ui/lib/src/nvui/render.ts b/ui/lib/src/nvui/render.ts index bd58de5f747..016668142de 100644 --- a/ui/lib/src/nvui/render.ts +++ b/ui/lib/src/nvui/render.ts @@ -1,11 +1,13 @@ -import { h, type VNode, type VNodeChildren } from 'snabbdom'; import { type Pieces, files } from '@lichess-org/chessground/types'; import { COLORS, RANK_NAMES, ROLES, type FileName } from 'chessops/types'; import { charToRole, roleToChar } from 'chessops/util'; +import { h, type VNode, type VNodeChildren } from 'snabbdom'; + import { plyToTurn, sanToWords } from '@/game'; -import type { MoveStyle, PieceStyle, PositionStyle, PrefixStyle, BoardStyle } from './setting'; import type { CrazyPocket, NodeCrazy, TreeComment, TreeNode, TreePath } from '@/tree/types'; +import type { MoveStyle, PieceStyle, PositionStyle, PrefixStyle, BoardStyle } from './setting'; + export const renderPieceStyle = (ch: string, pieceStyle: PieceStyle): string => pieceStyle === 'letter' ? ch.toLowerCase() diff --git a/ui/lib/src/nvui/setting.ts b/ui/lib/src/nvui/setting.ts index b125a4c5210..0bf8d62523a 100644 --- a/ui/lib/src/nvui/setting.ts +++ b/ui/lib/src/nvui/setting.ts @@ -1,4 +1,5 @@ import { h, type VNode } from 'snabbdom'; + import { type LichessStorage, storage } from '../storage'; import { renderSan, renderPieceStyle, renderPrefixStyle } from './render'; diff --git a/ui/lib/src/poolRangeStorage.ts b/ui/lib/src/poolRangeStorage.ts index 9ac6c74bc11..6229de3b0a6 100644 --- a/ui/lib/src/poolRangeStorage.ts +++ b/ui/lib/src/poolRangeStorage.ts @@ -1,5 +1,5 @@ -import { defined } from './index'; import type { GameData } from './game/interfaces'; +import { defined } from './index'; import { storage } from './storage'; const makeKey = (username: string | undefined, poolId: string) => diff --git a/ui/lib/src/pubsub.ts b/ui/lib/src/pubsub.ts index 47d373a8d0a..98d3963d52a 100644 --- a/ui/lib/src/pubsub.ts +++ b/ui/lib/src/pubsub.ts @@ -1,5 +1,6 @@ import type { Line } from '@/chat/interfaces'; import type { Data as WatchersData } from '@/view/watchers'; + import type { TreePath } from './tree/types'; export type PubsubEventKey = keyof PubsubEvents; diff --git a/ui/lib/src/puz/current.ts b/ui/lib/src/puz/current.ts index c09efa35917..8185877f7b8 100644 --- a/ui/lib/src/puz/current.ts +++ b/ui/lib/src/puz/current.ts @@ -1,5 +1,6 @@ import { Chess, opposite, parseUci, san } from 'chessops'; import { parseFen } from 'chessops/fen'; + import type { Puzzle } from './interfaces'; import { getNow } from './util'; diff --git a/ui/lib/src/puz/interfaces.ts b/ui/lib/src/puz/interfaces.ts index 886c801fc3b..fba0ad2d68e 100644 --- a/ui/lib/src/puz/interfaces.ts +++ b/ui/lib/src/puz/interfaces.ts @@ -1,8 +1,8 @@ +import type { Coords } from '../prefs'; import type { Clock } from './clock'; import type { Combo } from './combo'; import type CurrentPuzzle from './current'; import type { PuzFilters } from './filters'; -import type { Coords } from '../prefs'; export interface PuzCtrl { run: Run; diff --git a/ui/lib/src/puz/run.ts b/ui/lib/src/puz/run.ts index c40bd9b7654..ff1aeabb250 100644 --- a/ui/lib/src/puz/run.ts +++ b/ui/lib/src/puz/run.ts @@ -1,7 +1,8 @@ -import type { Run } from './interfaces'; import { opposite, uciToMove } from '@lichess-org/chessground/util'; -import { makeFen } from 'chessops/fen'; import { chessgroundDests } from 'chessops/compat'; +import { makeFen } from 'chessops/fen'; + +import type { Run } from './interfaces'; export const makeCgOpts = (run: Run, canMove: boolean, flipped: boolean): CgConfig => { const cur = run.current; diff --git a/ui/lib/src/puz/util.ts b/ui/lib/src/puz/util.ts index f0bd38af341..48771429f80 100644 --- a/ui/lib/src/puz/util.ts +++ b/ui/lib/src/puz/util.ts @@ -1,7 +1,8 @@ -import type { Puzzle } from './interfaces'; import { opposite } from 'chessops'; import { parseFen } from 'chessops/fen'; +import type { Puzzle } from './interfaces'; + export const getNow = (): number => Math.round(performance.now()); export const puzzlePov = (puzzle: Puzzle): Color => opposite(parseFen(puzzle.fen).unwrap().turn); diff --git a/ui/lib/src/puz/view/chessground.ts b/ui/lib/src/puz/view/chessground.ts index 5ec1b9ee4ac..1bbd8d507e3 100644 --- a/ui/lib/src/puz/view/chessground.ts +++ b/ui/lib/src/puz/view/chessground.ts @@ -1,8 +1,9 @@ import resizeHandle from '@/chessgroundResize'; -import type { PuzPrefs, UserMove } from '../interfaces'; import { ShowResizeHandle, Coords } from '@/prefs'; import { storage } from '@/storage'; +import type { PuzPrefs, UserMove } from '../interfaces'; + export function makeConfig(opts: CgConfig, pref: PuzPrefs, userMove: UserMove): CgConfig { return { fen: opts.fen, diff --git a/ui/lib/src/puz/view/clock.ts b/ui/lib/src/puz/view/clock.ts index cf3f65b0f91..3940b0e8619 100644 --- a/ui/lib/src/puz/view/clock.ts +++ b/ui/lib/src/puz/view/clock.ts @@ -1,7 +1,9 @@ -import { defined } from '@/index'; -import { getNow } from '../util'; import { h, type VNode } from 'snabbdom'; + +import { defined } from '@/index'; + import type { Run, TimeMod } from '../interfaces'; +import { getNow } from '../util'; type OnFlag = () => void; diff --git a/ui/lib/src/puz/view/history.ts b/ui/lib/src/puz/view/history.ts index a492bf6496e..75d06856f5c 100644 --- a/ui/lib/src/puz/view/history.ts +++ b/ui/lib/src/puz/view/history.ts @@ -1,11 +1,12 @@ -import { initMiniBoardWith, onInsert } from '@/view'; -import { uciToMove } from '@/game/chess'; -import type { PuzCtrl } from '@/puz/interfaces'; import { Chess } from 'chessops/chess'; -import { h, type VNode } from 'snabbdom'; import { parseFen, makeFen } from 'chessops/fen'; import { parseUci } from 'chessops/util'; +import { h, type VNode } from 'snabbdom'; + +import { uciToMove } from '@/game/chess'; import type { Toggle } from '@/index'; +import type { PuzCtrl } from '@/puz/interfaces'; +import { initMiniBoardWith, onInsert } from '@/view'; const slowPuzzleIds = (ctrl: PuzCtrl): Set | undefined => { if (!ctrl.filters.slow() || !ctrl.run.history.length) return undefined; diff --git a/ui/lib/src/puz/view/util.ts b/ui/lib/src/puz/view/util.ts index fd054e233ce..edb14dd0a96 100644 --- a/ui/lib/src/puz/view/util.ts +++ b/ui/lib/src/puz/view/util.ts @@ -1,4 +1,5 @@ import { h, type VNode } from 'snabbdom'; + import type { Config, Run } from '@/puz/interfaces'; import { getNow } from '@/puz/util'; diff --git a/ui/lib/src/richText.ts b/ui/lib/src/richText.ts index 0c8bff635de..78598abe199 100644 --- a/ui/lib/src/richText.ts +++ b/ui/lib/src/richText.ts @@ -3,6 +3,7 @@ // Rich Text helper functions // Refactored for https://github.com/lichess-org/lila/issues/7342 request import type { VNode, Hooks } from 'snabbdom'; + import { escapeHtml } from './index'; // from https://github.com/bryanwoods/autolink-js/blob/master/autolink.js diff --git a/ui/lib/src/setup/timeControl.ts b/ui/lib/src/setup/timeControl.ts index b374748471c..0a0d457c488 100644 --- a/ui/lib/src/setup/timeControl.ts +++ b/ui/lib/src/setup/timeControl.ts @@ -1,6 +1,7 @@ -import { propWithEffect, type Prop } from '@/index'; -import type { ClockConfig, InputValue, RealValue } from './interfaces'; import { clockToSpeed } from '@/game'; +import { propWithEffect, type Prop } from '@/index'; + +import type { ClockConfig, InputValue, RealValue } from './interfaces'; export type TimeMode = 'realTime' | 'correspondence' | 'unlimited'; diff --git a/ui/lib/src/setup/view/color.ts b/ui/lib/src/setup/view/color.ts index c9644525da9..6daf9b62250 100644 --- a/ui/lib/src/setup/view/color.ts +++ b/ui/lib/src/setup/view/color.ts @@ -1,6 +1,7 @@ import { hl, type VNode } from '@/view'; -import { option } from '../option'; + import { colors, type ColorChoice, type ColorProp } from '../color'; +import { option } from '../option'; export const blindModeColorPicker = (colorProp: ColorProp): VNode[] => [ hl('label', { attrs: { for: 'sf_color' } }, i18n.site.side), diff --git a/ui/lib/src/setup/view/timeControl.ts b/ui/lib/src/setup/view/timeControl.ts index c5b2b760a17..aa014baf1cd 100644 --- a/ui/lib/src/setup/view/timeControl.ts +++ b/ui/lib/src/setup/view/timeControl.ts @@ -1,6 +1,8 @@ import type { Prop } from '@/index'; import { hl, type VNode } from '@/view'; + import type { InputValue } from '../interfaces'; +import { option } from '../option'; import { timeModes, sliderTimes, @@ -11,7 +13,6 @@ import { type TimeControl, type TimeMode, } from '../timeControl'; -import { option } from '../option'; const showTime = (v: number) => { if (v === 1 / 4) return '¼'; diff --git a/ui/lib/src/socket.ts b/ui/lib/src/socket.ts index 51c6daa5f31..ff9021f6648 100644 --- a/ui/lib/src/socket.ts +++ b/ui/lib/src/socket.ts @@ -1,9 +1,9 @@ -import * as xhr from './xhr'; import { idleTimer } from './event'; -import { storage, once, type LichessStorage } from './storage'; -import { pubsub, type PubsubEventKey } from './pubsub'; import { defined, myUserId } from './index'; import { log } from './permalog'; +import { pubsub, type PubsubEventKey } from './pubsub'; +import { storage, once, type LichessStorage } from './storage'; +import * as xhr from './xhr'; let siteSocket: WsSocket | undefined; diff --git a/ui/lib/src/tree/node.ts b/ui/lib/src/tree/node.ts index 6e7e4cfdbf2..b56cc44acf4 100644 --- a/ui/lib/src/tree/node.ts +++ b/ui/lib/src/tree/node.ts @@ -1,10 +1,12 @@ -import { chessgroundDests, lichessRules, scalachessCharPair } from 'chessops/compat'; -import type { PositionResult, TreeNode, TreeNodeIncomplete } from './types'; import { type Position, parseUci, makeSquare } from 'chessops'; -import { memoize } from '@/common'; +import { chessgroundDests, lichessRules, scalachessCharPair } from 'chessops/compat'; import { parseFen } from 'chessops/fen'; import { setupPosition } from 'chessops/variant'; +import { memoize } from '@/common'; + +import type { PositionResult, TreeNode, TreeNodeIncomplete } from './types'; + // mutates and returns the node export const completeNode = (variant: VariantKey) => diff --git a/ui/lib/src/tree/tree.ts b/ui/lib/src/tree/tree.ts index a2e1ecd3d56..47280ee17d7 100644 --- a/ui/lib/src/tree/tree.ts +++ b/ui/lib/src/tree/tree.ts @@ -1,6 +1,6 @@ -import * as treePath from './path'; -import * as ops from './ops'; import { defined } from '../index'; +import * as ops from './ops'; +import * as treePath from './path'; import type { Clock, Glyph, Shape, TreeComment, TreeNode, TreePath } from './types'; export { treePath as path, ops }; diff --git a/ui/lib/src/tree/types.ts b/ui/lib/src/tree/types.ts index c76ded2a097..53ec79c5419 100644 --- a/ui/lib/src/tree/types.ts +++ b/ui/lib/src/tree/types.ts @@ -1,5 +1,5 @@ -import type { Outcome, Position } from 'chessops'; import type { Result } from '@badrap/result'; +import type { Outcome, Position } from 'chessops'; export type TreeNodeId = string; export type TreePath = string; diff --git a/ui/lib/src/view/blindfold.ts b/ui/lib/src/view/blindfold.ts index 02917839151..bd95998d90b 100644 --- a/ui/lib/src/view/blindfold.ts +++ b/ui/lib/src/view/blindfold.ts @@ -1,4 +1,5 @@ import type { Prop } from '@/common'; + import * as licon from '../licon'; import { bind, hl, type MaybeVNode } from './index'; diff --git a/ui/lib/src/view/boardMenu.ts b/ui/lib/src/view/boardMenu.ts index 2194f71a1e7..b328e3103c1 100644 --- a/ui/lib/src/view/boardMenu.ts +++ b/ui/lib/src/view/boardMenu.ts @@ -1,12 +1,14 @@ // no side effects allowed due to re-export by index.ts import { h } from 'snabbdom'; + import { type Toggle, blurIfPrimaryClick, myUserId, onClickAway } from '@/index'; -import { addPointerListeners } from '@/pointer'; import * as licon from '@/licon'; -import { type MaybeVNode, type MaybeVNodes, type VNode, dataIcon, onInsert } from './snabbdom'; -import { cmnToggleWrap, cmnToggleWrapProp } from '@/view/cmn-toggle'; +import { addPointerListeners } from '@/pointer'; import { pubsub } from '@/pubsub'; +import { cmnToggleWrap, cmnToggleWrapProp } from '@/view/cmn-toggle'; + +import { type MaybeVNode, type MaybeVNodes, type VNode, dataIcon, onInsert } from './snabbdom'; export const toggleButton = (toggle: Toggle, title: string): VNode => h('button.fbt.board-menu-toggle-btn', { diff --git a/ui/lib/src/view/cmn-toggle.ts b/ui/lib/src/view/cmn-toggle.ts index 7e2adb70134..a3c259dc82e 100644 --- a/ui/lib/src/view/cmn-toggle.ts +++ b/ui/lib/src/view/cmn-toggle.ts @@ -1,5 +1,7 @@ -import { defined, type Prop } from '@/common'; import { h, type VNode } from 'snabbdom'; + +import { defined, type Prop } from '@/common'; + import { bind } from './snabbdom'; interface CmnToggleBase { diff --git a/ui/lib/src/view/controls.ts b/ui/lib/src/view/controls.ts index cec31868fdb..394f899d518 100644 --- a/ui/lib/src/view/controls.ts +++ b/ui/lib/src/view/controls.ts @@ -1,10 +1,11 @@ // no side effects allowed due to re-export by index.ts import { h, type Hooks, type VNode, type Attrs } from 'snabbdom'; -import { toggle as baseToggle, type Toggle } from '@/index'; -import * as xhr from '@/xhr'; -import * as licon from '@/licon'; + import { isMac } from '@/device'; +import { toggle as baseToggle, type Toggle } from '@/index'; +import * as licon from '@/licon'; +import * as xhr from '@/xhr'; export function enter(effect: (target: E) => void) { return (e: Event): void => { diff --git a/ui/lib/src/view/dialog.ts b/ui/lib/src/view/dialog.ts index 168421e227a..013c5edbaa6 100644 --- a/ui/lib/src/view/dialog.ts +++ b/ui/lib/src/view/dialog.ts @@ -1,12 +1,13 @@ // no side effects allowed due to re-export by index.ts -import { onInsert, hl, type VNode, type Attrs, type LooseVNodes } from './snabbdom'; import { isTouchDevice } from '@/device'; -import { blurIfPrimaryClick, frag } from '@/index'; import { Janitor } from '@/event'; -import * as xhr from '@/xhr'; +import { blurIfPrimaryClick, frag } from '@/index'; import * as licon from '@/licon'; import { pubsub } from '@/pubsub'; +import * as xhr from '@/xhr'; + +import { onInsert, hl, type VNode, type Attrs, type LooseVNodes } from './snabbdom'; export interface Dialog { readonly view: HTMLElement; // your content div diff --git a/ui/lib/src/view/dialogs.ts b/ui/lib/src/view/dialogs.ts index 3d1c43733ab..d117a563e2d 100644 --- a/ui/lib/src/view/dialogs.ts +++ b/ui/lib/src/view/dialogs.ts @@ -1,7 +1,7 @@ // no side effects allowed due to re-export by index.ts -import { type Dialog, domDialog } from './dialog'; import { escapeHtml } from '../index'; +import { type Dialog, domDialog } from './dialog'; // non-blocking window.alert-alike export async function alert(msg: string): Promise { diff --git a/ui/lib/src/view/markdownImgResizer.ts b/ui/lib/src/view/markdownImgResizer.ts index 339f50cf913..2569b5263ad 100644 --- a/ui/lib/src/view/markdownImgResizer.ts +++ b/ui/lib/src/view/markdownImgResizer.ts @@ -1,5 +1,5 @@ -import { type Prop, frag } from '@/index'; import { clamp } from '@/algo'; +import { type Prop, frag } from '@/index'; import { json as xhrJson } from '@/xhr'; export type UpdateImageHook = diff --git a/ui/lib/src/view/miniBoard.ts b/ui/lib/src/view/miniBoard.ts index 7c45dceee07..f3434c301a9 100644 --- a/ui/lib/src/view/miniBoard.ts +++ b/ui/lib/src/view/miniBoard.ts @@ -1,13 +1,14 @@ // no side effects allowed due to re-export by index.ts -import { h, type VNode } from 'snabbdom'; -import * as domData from '@/data'; -import { lichessClockIsRunning, setClockWidget } from '@/game/clock/clockWidget'; -import { uciToMove, fenColor } from '@/game/chess'; import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { COLORS } from 'chessops'; +import { h, type VNode } from 'snabbdom'; + +import * as domData from '@/data'; +import { uciToMove, fenColor } from '@/game/chess'; +import { lichessClockIsRunning, setClockWidget } from '@/game/clock/clockWidget'; import { pubsub } from '@/pubsub'; import { wsSend } from '@/socket'; -import { COLORS } from 'chessops'; export const initMiniBoard = (node: HTMLElement): void => { const [fen, orientation, lm] = node.getAttribute('data-state')!.split(','); diff --git a/ui/lib/src/view/pagination.ts b/ui/lib/src/view/pagination.ts index c8fdd279f45..63a4d509d7a 100644 --- a/ui/lib/src/view/pagination.ts +++ b/ui/lib/src/view/pagination.ts @@ -1,4 +1,5 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from '../licon'; import { bind, onInsert, type MaybeVNodes } from './snabbdom'; import { userComplete, type UserCompleteOpts } from './userComplete'; diff --git a/ui/lib/src/view/userComplete.ts b/ui/lib/src/view/userComplete.ts index 4ba832aeca8..32587d70581 100644 --- a/ui/lib/src/view/userComplete.ts +++ b/ui/lib/src/view/userComplete.ts @@ -1,5 +1,7 @@ -import * as xhr from '@/xhr'; import debounce from 'debounce-promise'; + +import * as xhr from '@/xhr'; + import { complete } from './complete'; export interface UserCompleteResult { diff --git a/ui/lib/src/view/userLink.ts b/ui/lib/src/view/userLink.ts index cb68d478468..3ae66c4781b 100644 --- a/ui/lib/src/view/userLink.ts +++ b/ui/lib/src/view/userLink.ts @@ -1,4 +1,5 @@ import { type Attrs, h, type VNode, type VNodeData } from 'snabbdom'; + import { type MaybeVNodes } from './snabbdom'; export interface HasRating { diff --git a/ui/lib/src/view/util.ts b/ui/lib/src/view/util.ts index 64e019b3d7a..dcfe47054d0 100644 --- a/ui/lib/src/view/util.ts +++ b/ui/lib/src/view/util.ts @@ -1,4 +1,5 @@ import { h, type VNode, type VNodeChildren } from 'snabbdom'; + import { numberFormat } from '../i18n'; const ratio2percent = (r: number): string => Math.round(100 * r) + '%'; diff --git a/ui/lib/src/view/verticalResize.ts b/ui/lib/src/view/verticalResize.ts index e44c8d363c2..79f84b4fa17 100644 --- a/ui/lib/src/view/verticalResize.ts +++ b/ui/lib/src/view/verticalResize.ts @@ -1,8 +1,9 @@ -import { hl, type VNode } from './snabbdom'; import { clamp } from '@/algo'; -import { storedMap } from '@/storage'; -import { myUserId } from '@/index'; import { isSafari } from '@/device'; +import { myUserId } from '@/index'; +import { storedMap } from '@/storage'; + +import { hl, type VNode } from './snabbdom'; interface Opts { selector?: string; // selector for element to resize, defaults to the previous sibling diff --git a/ui/lib/tests/command.test.ts b/ui/lib/tests/command.test.ts index a126e0c8ce4..c6f676d187d 100644 --- a/ui/lib/tests/command.test.ts +++ b/ui/lib/tests/command.test.ts @@ -1,7 +1,8 @@ -import { test } from 'node:test'; -import assert from 'node:assert/strict'; -import { commands } from '../src/nvui/command'; import type { Pieces } from '@lichess-org/chessground/types'; +import assert from 'node:assert/strict'; +import { test } from 'node:test'; + +import { commands } from '../src/nvui/command'; const pieces: Pieces = new Map(); pieces.set('a1', { color: 'white', role: 'king' }); diff --git a/ui/lib/tests/device.test.ts b/ui/lib/tests/device.test.ts index 5e7f75a20cf..f6b6dc7abe4 100644 --- a/ui/lib/tests/device.test.ts +++ b/ui/lib/tests/device.test.ts @@ -1,5 +1,6 @@ -import { describe, test } from 'node:test'; import assert from 'node:assert/strict'; +import { describe, test } from 'node:test'; + import { isVersionCompatible } from '../src/device'; describe('test isVersionCompatible', () => { diff --git a/ui/lib/tests/i18n.test.ts b/ui/lib/tests/i18n.test.ts index c60d097ec99..bccfb83dbe7 100644 --- a/ui/lib/tests/i18n.test.ts +++ b/ui/lib/tests/i18n.test.ts @@ -1,5 +1,5 @@ -import { describe, test } from 'node:test'; import assert from 'node:assert/strict'; +import { describe, test } from 'node:test'; describe('roundToCurrency', async () => { const { roundToCurrency } = await import('../../lib/src/i18n'); diff --git a/ui/lib/tests/nvui.test.ts b/ui/lib/tests/nvui.test.ts index f4f0668f478..2379c35f7e5 100644 --- a/ui/lib/tests/nvui.test.ts +++ b/ui/lib/tests/nvui.test.ts @@ -1,7 +1,8 @@ -import { describe, test } from 'node:test'; -import assert from 'node:assert/strict'; -import { inputToMove } from '../src/nvui/chess'; import { Chessground } from '@lichess-org/chessground'; +import assert from 'node:assert/strict'; +import { describe, test } from 'node:test'; + +import { inputToMove } from '../src/nvui/chess'; describe('nvui move inputs', () => { test('mixed case bishop or pawn takes', async () => { diff --git a/ui/lib/tests/once.test.ts b/ui/lib/tests/once.test.ts index df6e8f2e932..079ad97464f 100644 --- a/ui/lib/tests/once.test.ts +++ b/ui/lib/tests/once.test.ts @@ -1,5 +1,6 @@ -import { describe, test, mock } from 'node:test'; import assert from 'node:assert/strict'; +import { describe, test, mock } from 'node:test'; + import { once } from '../src/storage'; describe('test once', () => { diff --git a/ui/lib/tests/pubsub.test.ts b/ui/lib/tests/pubsub.test.ts index 8c97b6820eb..1fe4d608e5c 100644 --- a/ui/lib/tests/pubsub.test.ts +++ b/ui/lib/tests/pubsub.test.ts @@ -1,4 +1,5 @@ import { describe, test } from 'node:test'; + import { pubsub as typed } from '../src/pubsub'; const pubsub = typed as any; diff --git a/ui/lib/tests/richText.test.ts b/ui/lib/tests/richText.test.ts index 1101657672d..be31ecc9d47 100644 --- a/ui/lib/tests/richText.test.ts +++ b/ui/lib/tests/richText.test.ts @@ -1,7 +1,8 @@ -import { describe, test } from 'node:test'; import assert from 'node:assert/strict'; -import { enhance, EnhanceOpts, movePattern, userPattern } from '../src/richText'; +import { describe, test } from 'node:test'; + import { each } from '../../.test/helpers.mts'; +import { enhance, EnhanceOpts, movePattern, userPattern } from '../src/richText'; describe('test regex patterns', () => { test('username mentions', () => { diff --git a/ui/lib/tests/spam.test.ts b/ui/lib/tests/spam.test.ts index c7f274dfe42..ca05b26ee16 100644 --- a/ui/lib/tests/spam.test.ts +++ b/ui/lib/tests/spam.test.ts @@ -1,5 +1,5 @@ -import { test, mock, before } from 'node:test'; import assert from 'node:assert/strict'; +import { test, mock, before } from 'node:test'; const spamUrl = new URL('../src/chat/spam.ts', import.meta.url).href; const xhrUrl = new URL('../src/xhr.ts', import.meta.url).href; diff --git a/ui/lib/tests/status.test.ts b/ui/lib/tests/status.test.ts index 0d2d71b9cb6..44d81186cdc 100644 --- a/ui/lib/tests/status.test.ts +++ b/ui/lib/tests/status.test.ts @@ -1,7 +1,8 @@ -import { describe, test } from 'node:test'; import assert from 'node:assert/strict'; -import { bishopOnColor, expandFen, insufficientMaterial } from '../src/game/view/status'; +import { describe, test } from 'node:test'; + import { each } from '../../.test/helpers.mts'; +import { bishopOnColor, expandFen, insufficientMaterial } from '../src/game/view/status'; describe('expand fen', () => { test('starting position', () => diff --git a/ui/lib/tests/timeago.test.ts b/ui/lib/tests/timeago.test.ts index 5225bcbd796..bd12fd99139 100644 --- a/ui/lib/tests/timeago.test.ts +++ b/ui/lib/tests/timeago.test.ts @@ -1,5 +1,6 @@ -import { describe, test } from 'node:test'; import assert from 'node:assert/strict'; +import { describe, test } from 'node:test'; + import { freshImport } from '../../.test/helpers.mts'; describe('test formatter', () => { diff --git a/ui/lib/tests/winningChances.test.ts b/ui/lib/tests/winningChances.test.ts index d936e0d084c..f166e972687 100644 --- a/ui/lib/tests/winningChances.test.ts +++ b/ui/lib/tests/winningChances.test.ts @@ -1,7 +1,8 @@ -import { describe } from 'node:test'; import assert from 'node:assert/strict'; -import * as winningChances from '../src/ceval/winningChances'; +import { describe } from 'node:test'; + import { each } from '../../.test/helpers.mts'; +import * as winningChances from '../src/ceval/winningChances'; type CentipawnsOrMate = number | string; diff --git a/ui/lobby/src/ctrl.ts b/ui/lobby/src/ctrl.ts index fa4b6fc5db6..56cf3469b15 100644 --- a/ui/lobby/src/ctrl.ts +++ b/ui/lobby/src/ctrl.ts @@ -1,10 +1,12 @@ import { numberFormat } from 'lib/i18n'; -import variantConfirm from './variant'; -import * as hookRepo from './hookRepo'; -import * as seekRepo from './seekRepo'; -import { make as makeStores, type Stores } from './store'; -import * as xhr from './xhr'; import * as poolRangeStorage from 'lib/poolRangeStorage'; +import { pubsub } from 'lib/pubsub'; +import { colors, type ColorChoice } from 'lib/setup/color'; +import { wsPingInterval } from 'lib/socket'; +import { storage, type LichessStorage } from 'lib/storage'; + +import Filter from './filter'; +import * as hookRepo from './hookRepo'; import type { LobbyOpts, LobbyData, @@ -18,13 +20,12 @@ import type { ForceSetupOptions, LobbyMe, } from './interfaces'; -import LobbySocket from './socket'; -import Filter from './filter'; +import * as seekRepo from './seekRepo'; import SetupController from './setupCtrl'; -import { storage, type LichessStorage } from 'lib/storage'; -import { pubsub } from 'lib/pubsub'; -import { wsPingInterval } from 'lib/socket'; -import { colors, type ColorChoice } from 'lib/setup/color'; +import LobbySocket from './socket'; +import { make as makeStores, type Stores } from './store'; +import variantConfirm from './variant'; +import * as xhr from './xhr'; export default class LobbyController { data: LobbyData; diff --git a/ui/lobby/src/filter.ts b/ui/lobby/src/filter.ts index 4c9b0de3687..9c34a092f19 100644 --- a/ui/lobby/src/filter.ts +++ b/ui/lobby/src/filter.ts @@ -1,4 +1,6 @@ -import type { Hook } from './interfaces'; +import type { LichessStorage } from 'lib/storage'; + +import type LobbyController from './ctrl'; import { type FormLines, type FormObject, @@ -7,8 +9,7 @@ import { toFormObject, makeStore, } from './form'; -import type LobbyController from './ctrl'; -import type { LichessStorage } from 'lib/storage'; +import type { Hook } from './interfaces'; interface FilterData { form: FormLines; diff --git a/ui/lobby/src/interfaces.ts b/ui/lobby/src/interfaces.ts index 0dc42e2df26..535c6da7853 100644 --- a/ui/lobby/src/interfaces.ts +++ b/ui/lobby/src/interfaces.ts @@ -1,6 +1,6 @@ +import type { ColorChoice } from 'lib/setup/color'; import type { ClockConfig } from 'lib/setup/interfaces'; import type { TimeMode } from 'lib/setup/timeControl'; -import type { ColorChoice } from 'lib/setup/color'; export type Sort = 'rating' | 'time'; export type Mode = 'list' | 'chart'; diff --git a/ui/lobby/src/lobby.ts b/ui/lobby/src/lobby.ts index 586efaf293e..ff9c0031c9a 100644 --- a/ui/lobby/src/lobby.ts +++ b/ui/lobby/src/lobby.ts @@ -1,8 +1,9 @@ -import * as xhr from 'lib/xhr'; -import main from './main'; -import type { LobbyOpts } from './interfaces'; -import { wsConnect, wsPingInterval } from 'lib/socket'; import { pubsub } from 'lib/pubsub'; +import { wsConnect, wsPingInterval } from 'lib/socket'; +import * as xhr from 'lib/xhr'; + +import type { LobbyOpts } from './interfaces'; +import main from './main'; export function initModule(opts: LobbyOpts) { opts.appElement = document.querySelector('.lobby__app') as HTMLElement; diff --git a/ui/lobby/src/main.ts b/ui/lobby/src/main.ts index 046615db86d..6c8be4c4807 100644 --- a/ui/lobby/src/main.ts +++ b/ui/lobby/src/main.ts @@ -1,9 +1,10 @@ import { init, classModule, attributesModule, eventListenersModule, propsModule } from 'snabbdom'; -import type { LobbyOpts } from './interfaces'; + import makeCtrl from './ctrl'; +import type { LobbyOpts } from './interfaces'; +import { makeCarousel } from './view/carousel'; import appView from './view/main'; import tableView from './view/table'; -import { makeCarousel } from './view/carousel'; export const patch = init([classModule, attributesModule, propsModule, eventListenersModule]); diff --git a/ui/lobby/src/setupCtrl.ts b/ui/lobby/src/setupCtrl.ts index 1349c5613cc..dbd7bdc8594 100644 --- a/ui/lobby/src/setupCtrl.ts +++ b/ui/lobby/src/setupCtrl.ts @@ -1,19 +1,21 @@ +import { INITIAL_FEN } from 'chessops/fen'; + import { type Prop, propWithEffect, toggle } from 'lib'; import { debounce } from 'lib/async'; -import * as xhr from 'lib/xhr'; -import { storedJsonProp } from 'lib/storage'; -import { alert } from 'lib/view'; -import { INITIAL_FEN } from 'chessops/fen'; -import type LobbyController from './ctrl'; -import type { ForceSetupOptions, GameMode, GameType, PoolMember, SetupStore } from './interfaces'; -import { keyToId, variants } from './options'; +import type { ColorChoice, ColorProp } from 'lib/setup/color'; import { allTimeModeKeys, timeControlFromStoredValues, timeModes, type TimeControl, } from 'lib/setup/timeControl'; -import type { ColorChoice, ColorProp } from 'lib/setup/color'; +import { storedJsonProp } from 'lib/storage'; +import { alert } from 'lib/view'; +import * as xhr from 'lib/xhr'; + +import type LobbyController from './ctrl'; +import type { ForceSetupOptions, GameMode, GameType, PoolMember, SetupStore } from './interfaces'; +import { keyToId, variants } from './options'; const getPerf = (variant: VariantKey, tc: TimeControl): Perf => variant !== 'standard' && variant !== 'fromPosition' ? variant : tc.speed(); diff --git a/ui/lobby/src/socket.ts b/ui/lobby/src/socket.ts index ae8315984cb..fe0a156bfb3 100644 --- a/ui/lobby/src/socket.ts +++ b/ui/lobby/src/socket.ts @@ -1,8 +1,9 @@ -import * as hookRepo from './hookRepo'; -import type LobbyController from './ctrl'; -import type { PoolMember, Hook } from './interfaces'; import { idleTimer } from 'lib/event'; +import type LobbyController from './ctrl'; +import * as hookRepo from './hookRepo'; +import type { PoolMember, Hook } from './interfaces'; + type Handlers = Record void>; export default class LobbySocket { diff --git a/ui/lobby/src/store.ts b/ui/lobby/src/store.ts index 366e772b957..ae5347cdfa0 100644 --- a/ui/lobby/src/store.ts +++ b/ui/lobby/src/store.ts @@ -1,6 +1,7 @@ -import type { Tab, Mode, Sort } from './interfaces'; import { storage } from 'lib/storage'; +import type { Tab, Mode, Sort } from './interfaces'; + interface Store { set(v: string): A; get(): A; diff --git a/ui/lobby/src/view/correspondence.ts b/ui/lobby/src/view/correspondence.ts index dd5d428aa57..8a14b126d43 100644 --- a/ui/lobby/src/view/correspondence.ts +++ b/ui/lobby/src/view/correspondence.ts @@ -1,9 +1,12 @@ import { h, type VNode } from 'snabbdom'; + +import perfIcons from 'lib/game/perfIcons'; import { bind, type MaybeVNodes, confirm } from 'lib/view'; -import { tds, perfNames } from './util'; + import type LobbyController from '@/ctrl'; import type { Seek } from '@/interfaces'; -import perfIcons from 'lib/game/perfIcons'; + +import { tds, perfNames } from './util'; function renderSeek(ctrl: LobbyController, seek: Seek): VNode { const klass = seek.action === 'joinSeek' ? 'join' : 'cancel'; diff --git a/ui/lobby/src/view/main.ts b/ui/lobby/src/view/main.ts index 7f9ba6d5e46..75529a09a96 100644 --- a/ui/lobby/src/view/main.ts +++ b/ui/lobby/src/view/main.ts @@ -1,11 +1,13 @@ import { h, type VNodeData } from 'snabbdom'; + import { spinnerVdom as spinner } from 'lib/view'; -import renderTabs from './tabs'; -import * as renderPools from './pools'; -import renderRealTime from './realTime/main'; + +import type LobbyController from '../ctrl'; import renderSeeks from './correspondence'; import renderPlaying from './playing'; -import type LobbyController from '../ctrl'; +import * as renderPools from './pools'; +import renderRealTime from './realTime/main'; +import renderTabs from './tabs'; export default function (ctrl: LobbyController) { let body, diff --git a/ui/lobby/src/view/playing.ts b/ui/lobby/src/view/playing.ts index ca5cf88176e..a400977c2b9 100644 --- a/ui/lobby/src/view/playing.ts +++ b/ui/lobby/src/view/playing.ts @@ -1,7 +1,8 @@ +import { timeago } from 'lib/i18n'; import { hl, onInsert, initMiniBoard } from 'lib/view'; + import type LobbyController from '@/ctrl'; import type { NowPlaying } from '@/interfaces'; -import { timeago } from 'lib/i18n'; function timer(pov: NowPlaying) { const date = Date.now() + pov.secondsLeft! * 1000; diff --git a/ui/lobby/src/view/pools.ts b/ui/lobby/src/view/pools.ts index aa232f3b432..53401016be1 100644 --- a/ui/lobby/src/view/pools.ts +++ b/ui/lobby/src/view/pools.ts @@ -1,5 +1,7 @@ import { h, type Hooks } from 'snabbdom'; + import { spinnerVdom, onInsert } from 'lib/view'; + import type LobbyController from '../ctrl'; const createHandler = (ctrl: LobbyController) => (e: Event) => { diff --git a/ui/lobby/src/view/realTime/chart.ts b/ui/lobby/src/view/realTime/chart.ts index ccacb5acb1f..efb8cb23dab 100644 --- a/ui/lobby/src/view/realTime/chart.ts +++ b/ui/lobby/src/view/realTime/chart.ts @@ -1,9 +1,11 @@ -import type LobbyController from '@/ctrl'; +import { h, type VNode } from 'snabbdom'; + +import perfIcons from 'lib/game/perfIcons'; import * as licon from 'lib/licon'; import { bind } from 'lib/view'; -import { h, type VNode } from 'snabbdom'; + +import type LobbyController from '@/ctrl'; import type { Hook } from '@/interfaces'; -import perfIcons from 'lib/game/perfIcons'; const percents = (v: number) => v + '%'; diff --git a/ui/lobby/src/view/realTime/filter.ts b/ui/lobby/src/view/realTime/filter.ts index 91717e229a3..dcdf70b8b7c 100644 --- a/ui/lobby/src/view/realTime/filter.ts +++ b/ui/lobby/src/view/realTime/filter.ts @@ -1,7 +1,9 @@ import { h } from 'snabbdom'; + import * as licon from 'lib/licon'; -import * as xhr from 'lib/xhr'; import { bind } from 'lib/view'; +import * as xhr from 'lib/xhr'; + import type LobbyController from '@/ctrl'; function initialize(ctrl: LobbyController, el: FilterNode) { diff --git a/ui/lobby/src/view/realTime/list.ts b/ui/lobby/src/view/realTime/list.ts index bde30fb25ee..d506f641cad 100644 --- a/ui/lobby/src/view/realTime/list.ts +++ b/ui/lobby/src/view/realTime/list.ts @@ -1,12 +1,15 @@ import { h } from 'snabbdom'; -import type LobbyController from '@/ctrl'; + +import perfIcons from 'lib/game/perfIcons'; import * as licon from 'lib/licon'; import { bind } from 'lib/view'; -import { tds, perfNames } from '../util'; -import perfIcons from 'lib/game/perfIcons'; + +import type LobbyController from '@/ctrl'; import * as hookRepo from '@/hookRepo'; import type { Hook } from '@/interfaces'; +import { tds, perfNames } from '../util'; + function renderHook(ctrl: LobbyController, hook: Hook) { return h( 'tr.hook.' + hook.action, diff --git a/ui/lobby/src/view/realTime/main.ts b/ui/lobby/src/view/realTime/main.ts index 5a67b31c6bc..f2d1fe3ec0e 100644 --- a/ui/lobby/src/view/realTime/main.ts +++ b/ui/lobby/src/view/realTime/main.ts @@ -1,7 +1,8 @@ -import * as list from './list'; +import type LobbyController from '@/ctrl'; + import * as chart from './chart'; import * as filterView from './filter'; -import type LobbyController from '@/ctrl'; +import * as list from './list'; export default function (ctrl: LobbyController) { let filterBody, body, nbFiltered, modeToggle, res; diff --git a/ui/lobby/src/view/setup/components/colorButtons.ts b/ui/lobby/src/view/setup/components/colorButtons.ts index 260fdbd2dc1..31a327308a2 100644 --- a/ui/lobby/src/view/setup/components/colorButtons.ts +++ b/ui/lobby/src/view/setup/components/colorButtons.ts @@ -1,6 +1,7 @@ -import { hl } from 'lib/view'; -import { variantsWhereWhiteIsBetter } from '@/options'; import { blindModeColorPicker, colorButtons as renderButtons } from 'lib/setup/view/color'; +import { hl } from 'lib/view'; + +import { variantsWhereWhiteIsBetter } from '@/options'; import type SetupController from '@/setupCtrl'; export const colorButtons = ({ gameMode, gameType, variant, color }: SetupController) => { diff --git a/ui/lobby/src/view/setup/components/fenInput.ts b/ui/lobby/src/view/setup/components/fenInput.ts index 3d01646ec82..dd2c62c2418 100644 --- a/ui/lobby/src/view/setup/components/fenInput.ts +++ b/ui/lobby/src/view/setup/components/fenInput.ts @@ -1,6 +1,8 @@ import { h } from 'snabbdom'; + import * as licon from 'lib/licon'; import { initMiniBoard } from 'lib/view'; + import type SetupController from '@/setupCtrl'; export const fenInput = (ctrl: SetupController) => { diff --git a/ui/lobby/src/view/setup/components/gameModeButtons.ts b/ui/lobby/src/view/setup/components/gameModeButtons.ts index 15b07076bc6..f09f42f7332 100644 --- a/ui/lobby/src/view/setup/components/gameModeButtons.ts +++ b/ui/lobby/src/view/setup/components/gameModeButtons.ts @@ -1,9 +1,11 @@ -import type { MaybeVNode } from 'lib/view'; import { h } from 'snabbdom'; + +import { option } from 'lib/setup/option'; +import type { MaybeVNode } from 'lib/view'; + import type LobbyController from '@/ctrl'; import type { GameMode } from '@/interfaces'; import { gameModes } from '@/options'; -import { option } from 'lib/setup/option'; export const gameModeButtons = ({ setupCtrl, me }: LobbyController): MaybeVNode => { if (!me) return null; diff --git a/ui/lobby/src/view/setup/components/levelButtons.ts b/ui/lobby/src/view/setup/components/levelButtons.ts index 367a499a84e..cf28b62e5c6 100644 --- a/ui/lobby/src/view/setup/components/levelButtons.ts +++ b/ui/lobby/src/view/setup/components/levelButtons.ts @@ -1,5 +1,7 @@ import { h } from 'snabbdom'; + import { option } from 'lib/setup/option'; + import type SetupController from '@/setupCtrl'; const levels = [1, 2, 3, 4, 5, 6, 7, 8]; diff --git a/ui/lobby/src/view/setup/components/ratingDifferenceSliders.ts b/ui/lobby/src/view/setup/components/ratingDifferenceSliders.ts index b387293daa0..02144da78fc 100644 --- a/ui/lobby/src/view/setup/components/ratingDifferenceSliders.ts +++ b/ui/lobby/src/view/setup/components/ratingDifferenceSliders.ts @@ -1,4 +1,5 @@ import { hl } from 'lib/view'; + import type LobbyController from '@/ctrl'; export const ratingDifferenceSliders = ({ setupCtrl, me, data }: LobbyController) => { diff --git a/ui/lobby/src/view/setup/components/ratingView.ts b/ui/lobby/src/view/setup/components/ratingView.ts index 7c7c7cfc151..73ebae9806c 100644 --- a/ui/lobby/src/view/setup/components/ratingView.ts +++ b/ui/lobby/src/view/setup/components/ratingView.ts @@ -1,5 +1,7 @@ -import type { MaybeVNode } from 'lib/view'; import { h } from 'snabbdom'; + +import type { MaybeVNode } from 'lib/view'; + import type LobbyController from '@/ctrl'; import { speeds, variants } from '@/options'; diff --git a/ui/lobby/src/view/setup/components/variantPicker.ts b/ui/lobby/src/view/setup/components/variantPicker.ts index a5b2a1a1353..867e259dfa5 100644 --- a/ui/lobby/src/view/setup/components/variantPicker.ts +++ b/ui/lobby/src/view/setup/components/variantPicker.ts @@ -1,6 +1,7 @@ -import { enter, hl } from 'lib/view'; -import { variants, variantsForGameType } from '@/options'; import { option } from 'lib/setup/option'; +import { enter, hl } from 'lib/view'; + +import { variants, variantsForGameType } from '@/options'; import type SetupController from '@/setupCtrl'; export const variantPicker = (setupCtrl: SetupController) => { diff --git a/ui/lobby/src/view/setup/modal.ts b/ui/lobby/src/view/setup/modal.ts index eebe8354e0b..36a3461bbfe 100644 --- a/ui/lobby/src/view/setup/modal.ts +++ b/ui/lobby/src/view/setup/modal.ts @@ -1,13 +1,15 @@ -import { hl, type VNode, type LooseVNodes, snabDialog, spinnerVdom } from 'lib/view'; -import type LobbyController from '@/ctrl'; -import { variantPicker } from './components/variantPicker'; -import { gameModeButtons } from './components/gameModeButtons'; -import { ratingDifferenceSliders } from './components/ratingDifferenceSliders'; -import { colorButtons } from './components/colorButtons'; -import { ratingView } from './components/ratingView'; -import { fenInput } from './components/fenInput'; -import { levelButtons } from './components/levelButtons'; import { timePickerAndSliders } from 'lib/setup/view/timeControl'; +import { hl, type VNode, type LooseVNodes, snabDialog, spinnerVdom } from 'lib/view'; + +import type LobbyController from '@/ctrl'; + +import { colorButtons } from './components/colorButtons'; +import { fenInput } from './components/fenInput'; +import { gameModeButtons } from './components/gameModeButtons'; +import { levelButtons } from './components/levelButtons'; +import { ratingDifferenceSliders } from './components/ratingDifferenceSliders'; +import { ratingView } from './components/ratingView'; +import { variantPicker } from './components/variantPicker'; export default function setupModal(ctrl: LobbyController): VNode[] | null { const { setupCtrl } = ctrl; diff --git a/ui/lobby/src/view/table.ts b/ui/lobby/src/view/table.ts index 501dd8fbac2..b5741087f2e 100644 --- a/ui/lobby/src/view/table.ts +++ b/ui/lobby/src/view/table.ts @@ -1,8 +1,10 @@ +import { numberFormat } from 'lib/i18n'; import { bind, onInsert, hl, thunk } from 'lib/view'; + import type LobbyController from '@/ctrl'; import type { GameType } from '@/interfaces'; + import renderSetupModal from './setup/modal'; -import { numberFormat } from 'lib/i18n'; type ButtonInfo = { gameType: GameType | 'dev' | 'bots'; label: string; disabled?: boolean; title?: string }; diff --git a/ui/lobby/src/view/tabs.ts b/ui/lobby/src/view/tabs.ts index fc933c42aca..eff980240f0 100644 --- a/ui/lobby/src/view/tabs.ts +++ b/ui/lobby/src/view/tabs.ts @@ -1,5 +1,7 @@ import { h } from 'snabbdom'; + import { bind, type MaybeVNodes } from 'lib/view'; + import type LobbyController from '@/ctrl'; import type { Tab } from '@/interfaces'; diff --git a/ui/lobby/src/view/util.ts b/ui/lobby/src/view/util.ts index 34d7508220e..6fc9d8e4a02 100644 --- a/ui/lobby/src/view/util.ts +++ b/ui/lobby/src/view/util.ts @@ -1,4 +1,5 @@ import { h } from 'snabbdom'; + import type { MaybeVNodes } from 'lib/view'; export function tds(bits: MaybeVNodes): MaybeVNodes { diff --git a/ui/lobby/src/xhr.ts b/ui/lobby/src/xhr.ts index 4e1633e7017..82fc03f54a2 100644 --- a/ui/lobby/src/xhr.ts +++ b/ui/lobby/src/xhr.ts @@ -1,5 +1,7 @@ -import { json as xhrJson, form } from 'lib/xhr'; import debounce from 'debounce-promise'; + +import { json as xhrJson, form } from 'lib/xhr'; + import type { Pool, Seek } from './interfaces'; export const seeks: () => Promise = debounce(() => xhrJson('/lobby/seeks'), 3000, { leading: true }); diff --git a/ui/mod/src/mod.activity.ts b/ui/mod/src/mod.activity.ts index da202fcd925..f84ebb03d02 100644 --- a/ui/mod/src/mod.activity.ts +++ b/ui/mod/src/mod.activity.ts @@ -1,4 +1,5 @@ import ApexCharts from 'apexcharts'; + import { currentTheme } from 'lib/device'; const light = currentTheme() === 'light'; diff --git a/ui/mod/src/mod.games.ts b/ui/mod/src/mod.games.ts index 21a88f75a96..629b312841c 100644 --- a/ui/mod/src/mod.games.ts +++ b/ui/mod/src/mod.games.ts @@ -1,8 +1,9 @@ -import { sortTable, extendTablesortNumber } from 'lib/tablesort'; import { debounce } from 'lib/async'; -import { formToXhr } from 'lib/xhr'; -import { checkBoxAll, expandCheckboxZone, shiftClickCheckboxRange } from './checkBoxes'; +import { sortTable, extendTablesortNumber } from 'lib/tablesort'; import { confirm, enter } from 'lib/view'; +import { formToXhr } from 'lib/xhr'; + +import { checkBoxAll, expandCheckboxZone, shiftClickCheckboxRange } from './checkBoxes'; site.load.then(() => { setupTable(); diff --git a/ui/mod/src/mod.inquiry.ts b/ui/mod/src/mod.inquiry.ts index 2536ccadad1..9f594e22b4e 100644 --- a/ui/mod/src/mod.inquiry.ts +++ b/ui/mod/src/mod.inquiry.ts @@ -1,9 +1,9 @@ -import { formToXhr } from 'lib/xhr'; - -import { storage } from 'lib/storage'; -import { alert } from 'lib/view'; import { highlightSearchTerm } from 'lib/highlight'; import { pubsub } from 'lib/pubsub'; +import { storage } from 'lib/storage'; +import { alert } from 'lib/view'; +import { formToXhr } from 'lib/xhr'; + import { autolinkAtoms } from './mod.autolink'; site.load.then(() => { diff --git a/ui/mod/src/mod.search.ts b/ui/mod/src/mod.search.ts index 37ca7a57e62..6cf9cf80170 100644 --- a/ui/mod/src/mod.search.ts +++ b/ui/mod/src/mod.search.ts @@ -1,7 +1,8 @@ -import { text as xhrText } from 'lib/xhr'; import { sortTable, extendTablesortNumber } from 'lib/tablesort'; -import { checkBoxAll, expandCheckboxZone, selector, shiftClickCheckboxRange } from './checkBoxes'; import { confirm } from 'lib/view'; +import { text as xhrText } from 'lib/xhr'; + +import { checkBoxAll, expandCheckboxZone, selector, shiftClickCheckboxRange } from './checkBoxes'; site.load.then(() => { $('.slist, slist-pad') diff --git a/ui/mod/src/mod.teamAdmin.ts b/ui/mod/src/mod.teamAdmin.ts index a191a543734..28866279a8a 100644 --- a/ui/mod/src/mod.teamAdmin.ts +++ b/ui/mod/src/mod.teamAdmin.ts @@ -1,7 +1,8 @@ import Tagify from '@yaireo/tagify'; import debounce from 'debounce-promise'; -import { json as xhrJson, url as xhrUrl } from 'lib/xhr'; + import { userComplete } from 'lib/view/userComplete'; +import { json as xhrJson, url as xhrUrl } from 'lib/xhr'; site.load.then(() => { $('#form3-leaders').each(function (this: HTMLInputElement) { diff --git a/ui/mod/src/mod.user.ts b/ui/mod/src/mod.user.ts index 167c4183770..bbf5c3d3ac4 100644 --- a/ui/mod/src/mod.user.ts +++ b/ui/mod/src/mod.user.ts @@ -1,11 +1,12 @@ -import { formToXhr, text as xhrText } from 'lib/xhr'; import { debounce } from 'lib/async'; -import * as licon from 'lib/licon'; -import { sortTable, extendTablesortNumber } from 'lib/tablesort'; -import { expandCheckboxZone, shiftClickCheckboxRange, selector } from './checkBoxes'; -import { spinnerHtml, confirm } from 'lib/view'; -import { pubsub } from 'lib/pubsub'; import { commonDateFormat, toDate } from 'lib/i18n'; +import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { sortTable, extendTablesortNumber } from 'lib/tablesort'; +import { spinnerHtml, confirm } from 'lib/view'; +import { formToXhr, text as xhrText } from 'lib/xhr'; + +import { expandCheckboxZone, shiftClickCheckboxRange, selector } from './checkBoxes'; import { autolinkAtoms } from './mod.autolink'; site.load.then(() => { diff --git a/ui/mod/tests/mod.autolink.test.ts b/ui/mod/tests/mod.autolink.test.ts index 366b90503b9..74e0b75fa1c 100644 --- a/ui/mod/tests/mod.autolink.test.ts +++ b/ui/mod/tests/mod.autolink.test.ts @@ -1,7 +1,7 @@ // mod.autolink.test.ts (node:test) -import { describe, test, before } from 'node:test'; import assert from 'node:assert/strict'; +import { describe, test, before } from 'node:test'; let autolink!: (s: string) => string; let hostname!: string; diff --git a/ui/msg/src/ctrl.ts b/ui/msg/src/ctrl.ts index 48ed7d4aea7..071636e6d9b 100644 --- a/ui/msg/src/ctrl.ts +++ b/ui/msg/src/ctrl.ts @@ -1,3 +1,7 @@ +import { throttle } from 'lib/async'; +import { pubsub } from 'lib/pubsub'; +import { storage, type LichessStorage } from 'lib/storage'; + import type { MsgData, Contact, @@ -10,11 +14,8 @@ import type { Pane, Redraw, } from './interfaces'; -import { throttle } from 'lib/async'; import * as network from './network'; import { scroller } from './view/scroller'; -import { storage, type LichessStorage } from 'lib/storage'; -import { pubsub } from 'lib/pubsub'; export default class MsgCtrl { data: MsgData; diff --git a/ui/msg/src/msg.ts b/ui/msg/src/msg.ts index 3c63386992f..9a058ee2f37 100644 --- a/ui/msg/src/msg.ts +++ b/ui/msg/src/msg.ts @@ -1,10 +1,9 @@ -import view from './view/main'; - import { init, classModule, attributesModule } from 'snabbdom'; +import MsgCtrl from './ctrl'; import type { MsgOpts } from './interfaces'; import { upgradeData } from './network'; -import MsgCtrl from './ctrl'; +import view from './view/main'; export function initModule(opts: MsgOpts) { const element = document.querySelector('.msg-app') as HTMLElement, diff --git a/ui/msg/src/network.ts b/ui/msg/src/network.ts index efb50a0eb89..b1031cc22dc 100644 --- a/ui/msg/src/network.ts +++ b/ui/msg/src/network.ts @@ -1,7 +1,8 @@ +import { pubsub } from 'lib/pubsub'; +import { json, form } from 'lib/xhr'; + import type MsgCtrl from './ctrl'; import type { MsgData, Contact, User, Msg, Convo, SearchResult } from './interfaces'; -import { json, form } from 'lib/xhr'; -import { pubsub } from 'lib/pubsub'; export async function loadConvo(userId: string): Promise { const d = await json(`/inbox/${userId}`); diff --git a/ui/msg/src/view/actions.ts b/ui/msg/src/view/actions.ts index 8d432ccfd1d..5f02dd289ad 100644 --- a/ui/msg/src/view/actions.ts +++ b/ui/msg/src/view/actions.ts @@ -1,8 +1,10 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; import { bind, confirm } from 'lib/view'; -import type { Convo } from '../interfaces'; + import type MsgCtrl from '../ctrl'; +import type { Convo } from '../interfaces'; export default function renderActions(ctrl: MsgCtrl, convo: Convo): VNode[] { if (convo.user.id === 'lichess') return []; diff --git a/ui/msg/src/view/contact.ts b/ui/msg/src/view/contact.ts index 329dedf22ce..60426de1364 100644 --- a/ui/msg/src/view/contact.ts +++ b/ui/msg/src/view/contact.ts @@ -1,11 +1,13 @@ import { h, type VNode } from 'snabbdom'; -import type { Contact, LastMsg, User } from '../interfaces'; -import type MsgCtrl from '../ctrl'; -import * as licon from 'lib/licon'; + import { hookMobileMousedown } from 'lib/device'; -import { fullName, userLine } from 'lib/view/userLink'; import { timeago } from 'lib/i18n'; +import * as licon from 'lib/licon'; import type { MaybeVNodes } from 'lib/view/snabbdom'; +import { fullName, userLine } from 'lib/view/userLink'; + +import type MsgCtrl from '../ctrl'; +import type { Contact, LastMsg, User } from '../interfaces'; export default function renderContact(ctrl: MsgCtrl, contact: Contact, active?: string): VNode { const user = contact.user, diff --git a/ui/msg/src/view/convo.ts b/ui/msg/src/view/convo.ts index 98198407c97..d93910321b2 100644 --- a/ui/msg/src/view/convo.ts +++ b/ui/msg/src/view/convo.ts @@ -1,12 +1,14 @@ +import { h, type VNode } from 'snabbdom'; + +import { hookMobileMousedown } from 'lib/device'; +import * as licon from 'lib/licon'; +import { userLine, userLink, userLinkData } from 'lib/view/userLink'; + import type MsgCtrl from '../ctrl'; +import type { Convo, User } from '../interfaces'; import renderActions from './actions'; import renderInteract from './interact'; import renderMsgs from './msgs'; -import type { Convo, User } from '../interfaces'; -import { h, type VNode } from 'snabbdom'; -import * as licon from 'lib/licon'; -import { hookMobileMousedown } from 'lib/device'; -import { userLine, userLink, userLinkData } from 'lib/view/userLink'; export default function renderConvo(ctrl: MsgCtrl, convo: Convo): VNode { const user = convo.user; diff --git a/ui/msg/src/view/enhance.ts b/ui/msg/src/view/enhance.ts index 4d99bbf47b8..62a85450574 100644 --- a/ui/msg/src/view/enhance.ts +++ b/ui/msg/src/view/enhance.ts @@ -1,7 +1,8 @@ -import { scroller } from './scroller'; +import { escapeHtml } from 'lib/index'; import * as licon from 'lib/licon'; import { linkRegex, linkReplace, newLineRegex, expandMentions } from 'lib/richText'; -import { escapeHtml } from 'lib/index'; + +import { scroller } from './scroller'; export { isMoreThanText } from 'lib/richText'; export const imgurRegex = /https?:\/\/(?:i\.)?imgur\.com\/(?!gallery\b)(\w{7})(?:\.jpe?g|\.png|\.gif)?/; diff --git a/ui/msg/src/view/interact.ts b/ui/msg/src/view/interact.ts index 09c27c4e1b9..974d6e403ed 100644 --- a/ui/msg/src/view/interact.ts +++ b/ui/msg/src/view/interact.ts @@ -1,9 +1,11 @@ import { h, type VNode } from 'snabbdom'; + +import { throttle } from 'lib/async'; import * as licon from 'lib/licon'; import { bindSubmit, alert } from 'lib/view'; -import type { User } from '../interfaces'; + import type MsgCtrl from '../ctrl'; -import { throttle } from 'lib/async'; +import type { User } from '../interfaces'; export default function renderInteract(ctrl: MsgCtrl, user: User): VNode { const connected = ctrl.connected(); diff --git a/ui/msg/src/view/main.ts b/ui/msg/src/view/main.ts index 407626408b9..3ffc01ab61c 100644 --- a/ui/msg/src/view/main.ts +++ b/ui/msg/src/view/main.ts @@ -1,8 +1,10 @@ import { h, type VNode } from 'snabbdom'; + import { spinnerVdom as spinner, onInsert } from 'lib/view'; + import type MsgCtrl from '../ctrl'; -import renderConvo from './convo'; import renderContact from './contact'; +import renderConvo from './convo'; import * as search from './search'; export default function (ctrl: MsgCtrl): VNode { diff --git a/ui/msg/src/view/msgs.ts b/ui/msg/src/view/msgs.ts index 00ad7eaf340..84a8998ec35 100644 --- a/ui/msg/src/view/msgs.ts +++ b/ui/msg/src/view/msgs.ts @@ -1,10 +1,12 @@ import { h, type VNode } from 'snabbdom'; + +import { alert, confirm, makeLinkPopups, bind } from 'lib/view'; import { json as xhrJson, form as xhrForm } from 'lib/xhr'; + +import type MsgCtrl from '../ctrl'; import type { Convo, Msg, Daily } from '../interfaces'; import { enhance, isMoreThanText, expandLpvs } from './enhance'; import { scroller } from './scroller'; -import type MsgCtrl from '../ctrl'; -import { alert, confirm, makeLinkPopups, bind } from 'lib/view'; export default function renderMsgs(ctrl: MsgCtrl, convo: Convo): VNode { return h('div.msg-app__convo__msgs', { hook: { insert: setupMsgs(true), postpatch: setupMsgs(false) } }, [ diff --git a/ui/msg/src/view/search.ts b/ui/msg/src/view/search.ts index 924845d576e..170e0870ab7 100644 --- a/ui/msg/src/view/search.ts +++ b/ui/msg/src/view/search.ts @@ -1,10 +1,12 @@ import { h, type VNode } from 'snabbdom'; + import { throttle } from 'lib/async'; +import { hookMobileMousedown } from 'lib/device'; +import { fullName } from 'lib/view/userLink'; + import type MsgCtrl from '../ctrl'; import type { SearchResult, User } from '../interfaces'; import renderContacts, { userIcon } from './contact'; -import { fullName } from 'lib/view/userLink'; -import { hookMobileMousedown } from 'lib/device'; export const renderInput = (ctrl: MsgCtrl): VNode => h('div.msg-app__side__search', [ diff --git a/ui/msg/tests/enhance.test.ts b/ui/msg/tests/enhance.test.ts index 463743c8d3b..4b1124174ba 100644 --- a/ui/msg/tests/enhance.test.ts +++ b/ui/msg/tests/enhance.test.ts @@ -1,7 +1,8 @@ -import { describe } from 'node:test'; import assert from 'node:assert/strict'; -import { enhance, imgurRegex } from '../src/view/enhance'; +import { describe } from 'node:test'; + import { each } from '../../.test/helpers.mts'; +import { enhance, imgurRegex } from '../src/view/enhance'; describe('test imgur matching', () => { each<[string, string]>([ diff --git a/ui/notify/src/ctrl.ts b/ui/notify/src/ctrl.ts index d823ceda8fd..f64d2b2e332 100644 --- a/ui/notify/src/ctrl.ts +++ b/ui/notify/src/ctrl.ts @@ -1,7 +1,7 @@ -import type { Ctrl, NotifyOpts, NotifyData, Redraw } from './interfaces'; - -import { json as xhrJson, url as xhrUrl, text as xhrText } from 'lib/xhr'; import { storage } from 'lib/storage'; +import { json as xhrJson, url as xhrUrl, text as xhrText } from 'lib/xhr'; + +import type { Ctrl, NotifyOpts, NotifyData, Redraw } from './interfaces'; export default function makeCtrl(opts: NotifyOpts, redraw: Redraw): Ctrl { let data: NotifyData | undefined, diff --git a/ui/notify/src/notify.ts b/ui/notify/src/notify.ts index b26bc86f1ce..b8b6cd23daa 100644 --- a/ui/notify/src/notify.ts +++ b/ui/notify/src/notify.ts @@ -1,7 +1,8 @@ import { init, classModule, attributesModule } from 'snabbdom'; + import makeCtrl from './ctrl'; -import view from './view'; import type { NotifyOpts, NotifyData, BumpUnread } from './interfaces'; +import view from './view'; const patch = init([classModule, attributesModule]); diff --git a/ui/notify/src/renderers.ts b/ui/notify/src/renderers.ts index 34391e71f1e..f3d93598e9a 100644 --- a/ui/notify/src/renderers.ts +++ b/ui/notify/src/renderers.ts @@ -1,7 +1,9 @@ import { h, type VNode } from 'snabbdom'; -import * as licon from 'lib/licon'; -import type { Notification, Renderer, Renderers } from './interfaces'; + import { timeago } from 'lib/i18n'; +import * as licon from 'lib/licon'; + +import type { Notification, Renderer, Renderers } from './interfaces'; export default function makeRenderers(): Renderers { return { diff --git a/ui/notify/src/view.ts b/ui/notify/src/view.ts index a7319c2f2c2..90fa72c9ba1 100644 --- a/ui/notify/src/view.ts +++ b/ui/notify/src/view.ts @@ -1,8 +1,9 @@ -import type { Ctrl, NotifyData, Notification } from './interfaces'; -import { hl, type VNode, type LooseVNodes, spinnerVdom as spinner } from 'lib/view'; import * as licon from 'lib/licon'; -import makeRenderers from './renderers'; import { pubsub } from 'lib/pubsub'; +import { hl, type VNode, type LooseVNodes, spinnerVdom as spinner } from 'lib/view'; + +import type { Ctrl, NotifyData, Notification } from './interfaces'; +import makeRenderers from './renderers'; const renderers = makeRenderers(); diff --git a/ui/opening/src/chart.ts b/ui/opening/src/chart.ts index 4a3f4dad67d..b410094deba 100644 --- a/ui/opening/src/chart.ts +++ b/ui/opening/src/chart.ts @@ -1,6 +1,7 @@ -import * as chart from 'chart.js'; import 'chartjs-adapter-dayjs-4'; +import * as chart from 'chart.js'; import dayjs from 'dayjs'; + import type { OpeningPage } from './interfaces'; chart.Chart.register( diff --git a/ui/opening/src/opening.ts b/ui/opening/src/opening.ts index 70eaf6028c3..c8fc7032771 100644 --- a/ui/opening/src/opening.ts +++ b/ui/opening/src/opening.ts @@ -1,11 +1,13 @@ import Lpv from '@lichess-org/pgn-viewer'; import type { Opts } from '@lichess-org/pgn-viewer/interfaces'; -import { initMiniBoards } from 'lib/view'; + import { requestIdleCallback } from 'lib'; -import type { OpeningPage } from './interfaces'; +import { initMiniBoards } from 'lib/view'; + import { renderHistoryChart } from './chart'; -import { init as searchEngine } from './search'; +import type { OpeningPage } from './interfaces'; import panels from './panels'; +import { init as searchEngine } from './search'; import renderPlaceholderWiki from './wiki'; export function initModule(data?: OpeningPage): void { diff --git a/ui/opening/src/search.ts b/ui/opening/src/search.ts index a2167b13d76..a40de5f35ae 100644 --- a/ui/opening/src/search.ts +++ b/ui/opening/src/search.ts @@ -1,6 +1,7 @@ -import { text as xhrText, url as xhrUrl } from 'lib/xhr'; import debounce from 'debounce-promise'; + import { initMiniBoards } from 'lib/view'; +import { text as xhrText, url as xhrUrl } from 'lib/xhr'; export function init(): void { const debounced = debounce((str: string) => { diff --git a/ui/opening/src/wiki.ts b/ui/opening/src/wiki.ts index d38171975fd..13040726824 100644 --- a/ui/opening/src/wiki.ts +++ b/ui/opening/src/wiki.ts @@ -1,6 +1,7 @@ -import type { OpeningPage } from './interfaces'; import { wikiBooksUrl, apiArgs, transformWikiHtml } from 'lib/wikiBooks'; +import type { OpeningPage } from './interfaces'; + export default function wikiTheory(data: OpeningPage): void { $('.opening__wiki__markup__placeholder').each(function (this: HTMLDivElement) { const wrap = $(this); diff --git a/ui/puzzle/src/autoShape.ts b/ui/puzzle/src/autoShape.ts index 36611fa0afb..8c7697c7566 100644 --- a/ui/puzzle/src/autoShape.ts +++ b/ui/puzzle/src/autoShape.ts @@ -1,11 +1,13 @@ +import type { DrawModifiers, DrawShape } from '@lichess-org/chessground/draw'; +import type { NormalMove } from 'chessops/types'; +import { opposite, parseUci, makeSquare } from 'chessops/util'; + import { winningChances } from 'lib/ceval'; import { annotationShapes } from 'lib/game/glyphs'; -import type { DrawModifiers, DrawShape } from '@lichess-org/chessground/draw'; -import { opposite, parseUci, makeSquare } from 'chessops/util'; -import type { NormalMove } from 'chessops/types'; -import type PuzzleCtrl from './ctrl'; import type { Glyph, TreeNode } from 'lib/tree/types'; +import type PuzzleCtrl from './ctrl'; + function makeAutoShapesFromUci( color: Color, uci: Uci, diff --git a/ui/puzzle/src/control.ts b/ui/puzzle/src/control.ts index 99d9b4d7619..174e37454f0 100644 --- a/ui/puzzle/src/control.ts +++ b/ui/puzzle/src/control.ts @@ -1,4 +1,5 @@ import { path as treePath } from 'lib/tree/tree'; + import type PuzzleCtrl from './ctrl'; export function canGoForward(ctrl: PuzzleCtrl): boolean { diff --git a/ui/puzzle/src/ctrl.ts b/ui/puzzle/src/ctrl.ts index bbff608e15a..4f5668043ea 100755 --- a/ui/puzzle/src/ctrl.ts +++ b/ui/puzzle/src/ctrl.ts @@ -1,10 +1,30 @@ -import * as xhr from './xhr'; -import computeAutoShapes from './autoShape'; -import keyboard from './keyboard'; -import moveTest from './moveTest'; -import PuzzleSession from './session'; -import PuzzleStreak from './streak'; +import { Result } from '@badrap/result'; +import { uciToMove } from '@lichess-org/chessground/util'; +import { Chess, normalizeMove } from 'chessops/chess'; +import { chessgroundDests } from 'chessops/compat'; +import { parseFen, makeFen } from 'chessops/fen'; +import { makeSanAndPlay } from 'chessops/san'; +import type { Role, Move, Outcome } from 'chessops/types'; +import { parseSquare, parseUci, makeSquare, makeUci, opposite } from 'chessops/util'; +import { ctrl as makeKeyboardMove, type KeyboardMove, type KeyboardMoveRootCtrl } from 'keyboardMove'; +import { makeVoiceMove, type VoiceMove } from 'voice'; + +import { prop, type Prop, propWithEffect, type Toggle, toggle, requestIdleCallback } from 'lib'; import { type Deferred, defer, throttle } from 'lib/async'; +import { CevalCtrl } from 'lib/ceval'; +import type { CevalHandler } from 'lib/ceval/types'; +import { type WithGround } from 'lib/game/ground'; +import { PromotionCtrl } from 'lib/game/promotion'; +import { pubsub } from 'lib/pubsub'; +import { type StoredProp, storedBooleanProp, storedBooleanPropWithEffect, storage } from 'lib/storage'; +import { makeTree, treeOps, treePath, type TreeWrapper } from 'lib/tree'; +import { completeNode } from 'lib/tree/node'; +import { last } from 'lib/tree/ops'; +import type { TreeNode, TreePath } from 'lib/tree/types'; +import { alert } from 'lib/view'; +import { toggleZenMode } from 'lib/view/zen'; + +import computeAutoShapes from './autoShape'; import type { PuzzleOpts, PuzzleData, @@ -14,31 +34,13 @@ import type { PuzzleRound, RoundThemes, } from './interfaces'; -import { makeTree, treeOps, treePath, type TreeWrapper } from 'lib/tree'; -import { Chess, normalizeMove } from 'chessops/chess'; -import { chessgroundDests } from 'chessops/compat'; -import { CevalCtrl } from 'lib/ceval'; -import { makeVoiceMove, type VoiceMove } from 'voice'; -import { ctrl as makeKeyboardMove, type KeyboardMove, type KeyboardMoveRootCtrl } from 'keyboardMove'; -import { prop, type Prop, propWithEffect, type Toggle, toggle, requestIdleCallback } from 'lib'; -import { makeSanAndPlay } from 'chessops/san'; -import { parseFen, makeFen } from 'chessops/fen'; -import { parseSquare, parseUci, makeSquare, makeUci, opposite } from 'chessops/util'; +import keyboard from './keyboard'; +import moveTest from './moveTest'; import { pgnToTree, mergeSolution, nextCorrectMove } from './moveTree'; -import { PromotionCtrl } from 'lib/game/promotion'; -import type { Role, Move, Outcome } from 'chessops/types'; -import { type StoredProp, storedBooleanProp, storedBooleanPropWithEffect, storage } from 'lib/storage'; import Report from './report'; -import { last } from 'lib/tree/ops'; -import { uciToMove } from '@lichess-org/chessground/util'; -import type { CevalHandler } from 'lib/ceval/types'; -import { pubsub } from 'lib/pubsub'; -import { alert } from 'lib/view'; -import { type WithGround } from 'lib/game/ground'; -import type { TreeNode, TreePath } from 'lib/tree/types'; -import { completeNode } from 'lib/tree/node'; -import { Result } from '@badrap/result'; -import { toggleZenMode } from 'lib/view/zen'; +import PuzzleSession from './session'; +import PuzzleStreak from './streak'; +import * as xhr from './xhr'; export default class PuzzleCtrl implements CevalHandler { data: PuzzleData; diff --git a/ui/puzzle/src/interfaces.ts b/ui/puzzle/src/interfaces.ts index f34799d2a78..56b20b82719 100644 --- a/ui/puzzle/src/interfaces.ts +++ b/ui/puzzle/src/interfaces.ts @@ -1,8 +1,9 @@ import type { Move } from 'chessops/types'; import type { VNode } from 'snabbdom'; -import type { Coords } from 'lib/prefs'; -import perfIcons from 'lib/game/perfIcons'; + import type { ExternalEngineInfo } from 'lib/ceval'; +import perfIcons from 'lib/game/perfIcons'; +import type { Coords } from 'lib/prefs'; import type { TreePath } from 'lib/tree/types'; export type PuzzleId = string; diff --git a/ui/puzzle/src/keyboard.ts b/ui/puzzle/src/keyboard.ts index 0546ace0b98..1f5809291cf 100644 --- a/ui/puzzle/src/keyboard.ts +++ b/ui/puzzle/src/keyboard.ts @@ -1,7 +1,8 @@ +import { pubsub } from 'lib/pubsub'; +import { snabDialog } from 'lib/view'; + import * as control from './control'; import type PuzzleCtrl from './ctrl'; -import { snabDialog } from 'lib/view'; -import { pubsub } from 'lib/pubsub'; export default (ctrl: PuzzleCtrl) => site.mousetrap diff --git a/ui/puzzle/src/moveTest.ts b/ui/puzzle/src/moveTest.ts index e573f178332..4cff32f97fe 100644 --- a/ui/puzzle/src/moveTest.ts +++ b/ui/puzzle/src/moveTest.ts @@ -1,7 +1,9 @@ import { parseUci } from 'chessops/util'; + import { path as pathOps } from 'lib/tree/tree'; -import type { MoveTest } from './interfaces'; + import type PuzzleCtrl from './ctrl'; +import type { MoveTest } from './interfaces'; type MoveTestReturn = undefined | 'fail' | 'win' | MoveTest; const altCastles = { diff --git a/ui/puzzle/src/moveTree.ts b/ui/puzzle/src/moveTree.ts index 7a288a38e86..fccd6a79a76 100644 --- a/ui/puzzle/src/moveTree.ts +++ b/ui/puzzle/src/moveTree.ts @@ -1,13 +1,15 @@ +import { Result } from '@badrap/result'; import { Chess, normalizeMove, Position } from 'chessops/chess'; import { INITIAL_FEN, makeFen, parseFen } from 'chessops/fen'; import { makeSanAndPlay, parseSan } from 'chessops/san'; -import { makeUci, parseUci } from 'chessops/util'; -import { type TreeWrapper, path as pathOps } from 'lib/tree/tree'; import { isNormal, type Move, type NormalMove } from 'chessops/types'; -import type PuzzleCtrl from './ctrl'; -import type { TreeNode, TreePath } from '../../lib/src/tree/types'; +import { makeUci, parseUci } from 'chessops/util'; + import { completeNode } from 'lib/tree/node'; -import { Result } from '@badrap/result'; +import { type TreeWrapper, path as pathOps } from 'lib/tree/tree'; + +import type { TreeNode, TreePath } from '../../lib/src/tree/types'; +import type PuzzleCtrl from './ctrl'; export function pgnToTree(pgn: San[]): TreeNode { const pos = Chess.default(); diff --git a/ui/puzzle/src/puzzle.dashboard.ts b/ui/puzzle/src/puzzle.dashboard.ts index 4da0582b2fc..830e096cedb 100644 --- a/ui/puzzle/src/puzzle.dashboard.ts +++ b/ui/puzzle/src/puzzle.dashboard.ts @@ -8,6 +8,7 @@ import { Filler, type ChartData, } from 'chart.js'; + import { currentTheme } from 'lib/device'; Chart.register(RadarController, RadialLinearScale, PointElement, LineElement, Tooltip, Filler); diff --git a/ui/puzzle/src/puzzle.nvui.ts b/ui/puzzle/src/puzzle.nvui.ts index b8249b42202..f8c14c98355 100644 --- a/ui/puzzle/src/puzzle.nvui.ts +++ b/ui/puzzle/src/puzzle.nvui.ts @@ -1,4 +1,5 @@ import { type NvuiContext, makeContext } from 'lib/nvui/chess'; + import type PuzzleCtrl from './ctrl'; import { renderNvui } from './view/nvuiView'; diff --git a/ui/puzzle/src/puzzle.ts b/ui/puzzle/src/puzzle.ts index 3178cbd8cbf..bf9d299a097 100644 --- a/ui/puzzle/src/puzzle.ts +++ b/ui/puzzle/src/puzzle.ts @@ -1,8 +1,10 @@ import { attributesModule, classModule, init } from 'snabbdom'; -import PuzzleCtrl from './ctrl'; + import menuHover from 'lib/menuHover'; -import view from './view/main'; + +import PuzzleCtrl from './ctrl'; import type { PuzzleOpts, NvuiPlugin } from './interfaces'; +import view from './view/main'; const patch = init([classModule, attributesModule]); diff --git a/ui/puzzle/src/report.ts b/ui/puzzle/src/report.ts index b6424e09b34..cb2471be5f0 100644 --- a/ui/puzzle/src/report.ts +++ b/ui/puzzle/src/report.ts @@ -1,12 +1,13 @@ -import { report as xhrReport } from './xhr'; -import type PuzzleCtrl from './ctrl'; -import type { PuzzleId, ThemeKey } from './interfaces'; import { winningChances } from 'lib/ceval'; +import { plyToTurn, pieceCount } from 'lib/game/chess'; import * as licon from 'lib/licon'; import { type StoredProp, storedIntProp } from 'lib/storage'; -import { domDialog } from 'lib/view'; -import { plyToTurn, pieceCount } from 'lib/game/chess'; import type { ClientEval, PvData, TreeNode } from 'lib/tree/types'; +import { domDialog } from 'lib/view'; + +import type PuzzleCtrl from './ctrl'; +import type { PuzzleId, ThemeKey } from './interfaces'; +import { report as xhrReport } from './xhr'; // bump when logic is changed, to distinguish cached clients from new ones const version = 11; diff --git a/ui/puzzle/src/session.ts b/ui/puzzle/src/session.ts index 0676dbb69fe..580f64d408e 100644 --- a/ui/puzzle/src/session.ts +++ b/ui/puzzle/src/session.ts @@ -1,5 +1,6 @@ import { prop } from 'lib'; import { storedJsonProp } from 'lib/storage'; + import type { ThemeKey } from './interfaces'; interface SessionRound { diff --git a/ui/puzzle/src/streak.ts b/ui/puzzle/src/streak.ts index 30da649dd25..8911cf6a8f0 100644 --- a/ui/puzzle/src/streak.ts +++ b/ui/puzzle/src/streak.ts @@ -1,5 +1,6 @@ import type { Prop } from 'lib'; import { storedJsonProp } from 'lib/storage'; + import type { PuzzleData, Puzzle, PuzzleId, PuzzleGame } from './interfaces'; interface Current { diff --git a/ui/puzzle/src/view/after.ts b/ui/puzzle/src/view/after.ts index 0dcce7f8af4..eefcd7ee953 100644 --- a/ui/puzzle/src/view/after.ts +++ b/ui/puzzle/src/view/after.ts @@ -1,5 +1,6 @@ import * as licon from 'lib/licon'; import { type VNode, type MaybeVNodes, bind, dataIcon, hl } from 'lib/view'; + import type PuzzleCtrl from '../ctrl'; const renderVote = (ctrl: PuzzleCtrl): VNode => diff --git a/ui/puzzle/src/view/boardMenu.ts b/ui/puzzle/src/view/boardMenu.ts index 799820ad165..fe0ea7819e1 100644 --- a/ui/puzzle/src/view/boardMenu.ts +++ b/ui/puzzle/src/view/boardMenu.ts @@ -1,6 +1,8 @@ import { h } from 'snabbdom'; + import { toggle } from 'lib'; import { boardMenu as menuDropdown, boolPrefXhrToggle } from 'lib/view'; + import type PuzzleCtrl from '../ctrl'; export default function (ctrl: PuzzleCtrl) { diff --git a/ui/puzzle/src/view/chessground.ts b/ui/puzzle/src/view/chessground.ts index a2f72a6603b..13a8aed2c6d 100644 --- a/ui/puzzle/src/view/chessground.ts +++ b/ui/puzzle/src/view/chessground.ts @@ -1,9 +1,11 @@ -import resizeHandle from 'lib/chessgroundResize'; -import { h, type VNode } from 'snabbdom'; -import { Coords, ShowResizeHandle } from 'lib/prefs'; -import type PuzzleCtrl from '../ctrl'; -import { storage } from 'lib/storage'; import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { h, type VNode } from 'snabbdom'; + +import resizeHandle from 'lib/chessgroundResize'; +import { Coords, ShowResizeHandle } from 'lib/prefs'; +import { storage } from 'lib/storage'; + +import type PuzzleCtrl from '../ctrl'; export default function (ctrl: PuzzleCtrl): VNode { return h('div.cg-wrap.cgv' + ctrl.cgVersion, { diff --git a/ui/puzzle/src/view/feedback.ts b/ui/puzzle/src/view/feedback.ts index eba84f26a10..90d12d1043b 100644 --- a/ui/puzzle/src/view/feedback.ts +++ b/ui/puzzle/src/view/feedback.ts @@ -1,7 +1,9 @@ -import { bind, requiresI18n, type MaybeVNode } from 'lib/view'; import { h, type VNode } from 'snabbdom'; -import afterView from './after'; + +import { bind, requiresI18n, type MaybeVNode } from 'lib/view'; + import type PuzzleCtrl from '../ctrl'; +import afterView from './after'; const viewSolution = (ctrl: PuzzleCtrl): VNode => ctrl.streak diff --git a/ui/puzzle/src/view/main.ts b/ui/puzzle/src/view/main.ts index d6127147692..05947408430 100644 --- a/ui/puzzle/src/view/main.ts +++ b/ui/puzzle/src/view/main.ts @@ -1,10 +1,13 @@ -import * as control from '../control'; -import { view as keyboardView } from '../keyboard'; -import { replay, puzzleBox, userBox, streakBox, config } from './side'; -import theme from './theme'; -import chessground from './chessground'; -import feedbackView from './feedback'; +import { render as renderKeyboardMove } from 'keyboardMove'; +import { type VNode, h } from 'snabbdom'; +import { renderVoiceBar } from 'voice'; + +import { view as cevalView } from 'lib/ceval'; +import { dispatchChessgroundResize } from 'lib/chessgroundResize'; import * as licon from 'lib/licon'; +import { addPointerListeners } from 'lib/pointer'; +import { Coords } from 'lib/prefs'; +import { storage } from 'lib/storage'; import { stepwiseScroll, toggleButton as boardMenuToggleButton, @@ -14,17 +17,16 @@ import { type MaybeVNode, } from 'lib/view'; import { renderBlindfoldToggle } from 'lib/view/blindfold'; -import { type VNode, h } from 'snabbdom'; -import { addPointerListeners } from 'lib/pointer'; -import { render as treeView } from './tree'; -import { view as cevalView } from 'lib/ceval'; -import { renderVoiceBar } from 'voice'; -import { render as renderKeyboardMove } from 'keyboardMove'; -import boardMenu from './boardMenu'; -import { Coords } from 'lib/prefs'; + +import * as control from '../control'; import type PuzzleCtrl from '../ctrl'; -import { dispatchChessgroundResize } from 'lib/chessgroundResize'; -import { storage } from 'lib/storage'; +import { view as keyboardView } from '../keyboard'; +import boardMenu from './boardMenu'; +import chessground from './chessground'; +import feedbackView from './feedback'; +import { replay, puzzleBox, userBox, streakBox, config } from './side'; +import theme from './theme'; +import { render as treeView } from './tree'; const renderAnalyse = (ctrl: PuzzleCtrl): VNode => hl('div.puzzle__moves.areplay', [treeView(ctrl)]); diff --git a/ui/puzzle/src/view/nvuiView.ts b/ui/puzzle/src/view/nvuiView.ts index c91c6ba1df8..5f6fd75fc59 100644 --- a/ui/puzzle/src/view/nvuiView.ts +++ b/ui/puzzle/src/view/nvuiView.ts @@ -1,21 +1,24 @@ +import { Chessground as makeChessground } from '@lichess-org/chessground'; +import type { Api } from '@lichess-org/chessground/api'; +import { makeSquare, opposite } from 'chessops'; import { h, type VNode } from 'snabbdom'; + +import { throttle } from 'lib/async'; +import * as nv from 'lib/nvui/chess'; +import { commands, boardCommands, addBreaks } from 'lib/nvui/command'; +import { scanDirectionsHandler } from 'lib/nvui/directionScan'; +import { renderSetting } from 'lib/nvui/setting'; +import type { TreeNode } from 'lib/tree/types'; +import { bind, onInsert, requiresI18n } from 'lib/view'; + +import { nextCorrectMove } from '@/moveTree'; + +import { next as controlNext, prev } from '../control'; +import type PuzzleCtrl from '../ctrl'; +import type { PuzzleNvuiContext } from '../puzzle.nvui'; +import { makeConfig } from '../view/chessground'; import { puzzleBox, renderDifficultyForm, userBox } from '../view/side'; import theme from '../view/theme'; -import * as nv from 'lib/nvui/chess'; -import { makeConfig } from '../view/chessground'; -import { renderSetting } from 'lib/nvui/setting'; -import type { PuzzleNvuiContext } from '../puzzle.nvui'; -import { commands, boardCommands, addBreaks } from 'lib/nvui/command'; -import { next as controlNext, prev } from '../control'; -import { bind, onInsert, requiresI18n } from 'lib/view'; -import { throttle } from 'lib/async'; -import type PuzzleCtrl from '../ctrl'; -import { Chessground as makeChessground } from '@lichess-org/chessground'; -import { makeSquare, opposite } from 'chessops'; -import { scanDirectionsHandler } from 'lib/nvui/directionScan'; -import type { Api } from '@lichess-org/chessground/api'; -import { nextCorrectMove } from '@/moveTree'; -import type { TreeNode } from 'lib/tree/types'; const throttled = (sound: string) => throttle(100, () => site.sound.play(sound)); const selectSound = throttled('select'); diff --git a/ui/puzzle/src/view/side.ts b/ui/puzzle/src/view/side.ts index d219d8dabdf..dafbfe8cfae 100644 --- a/ui/puzzle/src/view/side.ts +++ b/ui/puzzle/src/view/side.ts @@ -1,12 +1,13 @@ -import type { Puzzle, PuzzleGame, PuzzleDifficulty } from '../interfaces'; +import perfIcons from 'lib/game/perfIcons'; +import { numberFormat } from 'lib/i18n'; import * as licon from 'lib/licon'; import { type VNode, dataIcon, onInsert, type MaybeVNode, hl } from 'lib/view'; import { cmnToggleWrap } from 'lib/view/cmn-toggle'; -import { numberFormat } from 'lib/i18n'; -import perfIcons from 'lib/game/perfIcons'; import { userLink } from 'lib/view/userLink'; -import type PuzzleStreak from '../streak'; + import type PuzzleCtrl from '../ctrl'; +import type { Puzzle, PuzzleGame, PuzzleDifficulty } from '../interfaces'; +import type PuzzleStreak from '../streak'; export function puzzleBox(ctrl: PuzzleCtrl): VNode { const data = ctrl.data; diff --git a/ui/puzzle/src/view/theme.ts b/ui/puzzle/src/view/theme.ts index c2631007930..1929881faa6 100644 --- a/ui/puzzle/src/view/theme.ts +++ b/ui/puzzle/src/view/theme.ts @@ -1,8 +1,9 @@ import * as licon from 'lib/licon'; import { type VNode, type MaybeVNode, bind, dataIcon, hl, type VNodeData } from 'lib/view'; + +import type PuzzleCtrl from '../ctrl'; import type { ThemeKey, RoundThemes } from '../interfaces'; import { renderColorForm } from './side'; -import type PuzzleCtrl from '../ctrl'; const studyUrl = 'https://lichess.org/study/viiWlKjv'; diff --git a/ui/puzzle/src/view/tree.ts b/ui/puzzle/src/view/tree.ts index bf67b3a31d5..795dffa0bd4 100644 --- a/ui/puzzle/src/view/tree.ts +++ b/ui/puzzle/src/view/tree.ts @@ -1,12 +1,14 @@ import type { VNode, Classes } from 'snabbdom'; + import { defined } from 'lib'; import { throttle } from 'lib/async'; import { renderEval as normalizeEval } from 'lib/ceval'; -import { path as treePath } from 'lib/tree/tree'; -import { type MaybeVNode, type LooseVNodes, hl } from 'lib/view'; -import type PuzzleCtrl from '../ctrl'; import { plyToTurn } from 'lib/game/chess'; +import { path as treePath } from 'lib/tree/tree'; import type { TreeNode, TreePath } from 'lib/tree/types'; +import { type MaybeVNode, type LooseVNodes, hl } from 'lib/view'; + +import type PuzzleCtrl from '../ctrl'; interface Ctx { ctrl: PuzzleCtrl; diff --git a/ui/puzzle/src/xhr.ts b/ui/puzzle/src/xhr.ts index e7eee2077c5..44eb402273a 100644 --- a/ui/puzzle/src/xhr.ts +++ b/ui/puzzle/src/xhr.ts @@ -1,7 +1,8 @@ -import { json as xhrJson, form as xhrForm } from 'lib/xhr'; -import type PuzzleStreak from './streak'; import { defined } from 'lib'; +import { json as xhrJson, form as xhrForm } from 'lib/xhr'; + import type { PuzzleReplay, PuzzleResult, ThemeKey } from './interfaces'; +import type PuzzleStreak from './streak'; export const complete = ( puzzleId: string, diff --git a/ui/racer/src/boost.ts b/ui/racer/src/boost.ts index c806b7491c8..ea36e3e668d 100644 --- a/ui/racer/src/boost.ts +++ b/ui/racer/src/boost.ts @@ -1,4 +1,5 @@ import { getNow } from 'lib/puz/util'; + import type { PlayerWithScore } from './interfaces'; type Timestamp = number; diff --git a/ui/racer/src/ctrl.ts b/ui/racer/src/ctrl.ts index 1c62fd54842..6c473c1b22a 100644 --- a/ui/racer/src/ctrl.ts +++ b/ui/racer/src/ctrl.ts @@ -1,16 +1,24 @@ -import config from './config'; -import CurrentPuzzle from 'lib/puz/current'; +import { parseUci } from 'chessops/util'; + +import { type Prop, defined, prop } from 'lib'; import { throttle } from 'lib/async'; -import { Boost } from './boost'; +import { type WithGround } from 'lib/game/ground'; +import { PromotionCtrl } from 'lib/game/promotion'; +import { pubsub } from 'lib/pubsub'; import { Clock } from 'lib/puz/clock'; import { Combo } from 'lib/puz/combo'; -import { Countdown } from './countdown'; -import { getNow, puzzlePov, sound } from 'lib/puz/util'; -import { makeCgOpts } from 'lib/puz/run'; -import { parseUci } from 'chessops/util'; -import type { PuzCtrl, Run } from 'lib/puz/interfaces'; +import CurrentPuzzle from 'lib/puz/current'; import { PuzFilters } from 'lib/puz/filters'; -import { type Prop, defined, prop } from 'lib'; +import type { PuzCtrl, Run } from 'lib/puz/interfaces'; +import { makeCgOpts } from 'lib/puz/run'; +import { getNow, puzzlePov, sound } from 'lib/puz/util'; +import { wsConnect, wsSend } from 'lib/socket'; +import { storedBooleanProp } from 'lib/storage'; +import { toggleZenMode } from 'lib/view/zen'; + +import { Boost } from './boost'; +import config from './config'; +import { Countdown } from './countdown'; import type { RacerOpts, RacerData, @@ -21,12 +29,6 @@ import type { RaceStatus, Vehicle, } from './interfaces'; -import { storedBooleanProp } from 'lib/storage'; -import { PromotionCtrl } from 'lib/game/promotion'; -import { wsConnect, wsSend } from 'lib/socket'; -import { pubsub } from 'lib/pubsub'; -import { type WithGround } from 'lib/game/ground'; -import { toggleZenMode } from 'lib/view/zen'; export default class RacerCtrl implements PuzCtrl { private data: RacerData; diff --git a/ui/racer/src/racer.ts b/ui/racer/src/racer.ts index a6e47a1674f..e86670df605 100644 --- a/ui/racer/src/racer.ts +++ b/ui/racer/src/racer.ts @@ -1,5 +1,7 @@ import { attributesModule, classModule, init, type VNode } from 'snabbdom'; + import menuHover from 'lib/menuHover'; + import RacerCtrl from './ctrl'; import type { RacerOpts } from './interfaces'; diff --git a/ui/racer/src/view/board.ts b/ui/racer/src/view/board.ts index 46b8a49b1af..4583efc10a1 100644 --- a/ui/racer/src/view/board.ts +++ b/ui/racer/src/view/board.ts @@ -1,10 +1,12 @@ -import type RacerCtrl from '../ctrl'; +import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { INITIAL_BOARD_FEN } from 'chessops/fen'; +import { h, type VNode } from 'snabbdom'; + +import { pubsub } from 'lib/pubsub'; import { makeCgOpts } from 'lib/puz/run'; import { makeConfig as makeCgConfig } from 'lib/puz/view/chessground'; -import { h, type VNode } from 'snabbdom'; -import { INITIAL_BOARD_FEN } from 'chessops/fen'; -import { Chessground as makeChessground } from '@lichess-org/chessground'; -import { pubsub } from 'lib/pubsub'; + +import type RacerCtrl from '../ctrl'; export const renderBoard = (ctrl: RacerCtrl) => { const secs = ctrl.countdownSeconds(); diff --git a/ui/racer/src/view/main.ts b/ui/racer/src/view/main.ts index 33cc0267691..7871d26e306 100644 --- a/ui/racer/src/view/main.ts +++ b/ui/racer/src/view/main.ts @@ -1,13 +1,14 @@ -import config from '../config'; -import type RacerCtrl from '../ctrl'; +import * as licon from 'lib/licon'; +import { povMessage } from 'lib/puz/run'; import renderClock from 'lib/puz/view/clock'; import renderHistory from 'lib/puz/view/history'; -import * as licon from 'lib/licon'; -import { copyMeInput, type VNode, type MaybeVNodes, bind, hl } from 'lib/view'; import { playModifiers, renderCombo } from 'lib/puz/view/util'; -import { renderRace } from './race'; +import { copyMeInput, type VNode, type MaybeVNodes, bind, hl } from 'lib/view'; + +import config from '../config'; +import type RacerCtrl from '../ctrl'; import { renderBoard } from './board'; -import { povMessage } from 'lib/puz/run'; +import { renderRace } from './race'; export default function (ctrl: RacerCtrl): VNode { return hl( diff --git a/ui/racer/src/view/race.ts b/ui/racer/src/view/race.ts index 8a42513a2db..9516ffc7cc6 100644 --- a/ui/racer/src/view/race.ts +++ b/ui/racer/src/view/race.ts @@ -1,9 +1,11 @@ -import type RacerCtrl from '../ctrl'; import { h, type VNodes } from 'snabbdom'; -import type { PlayerWithScore } from '../interfaces'; -import type { Boost } from '../boost'; + import { userLink } from 'lib/view/userLink'; +import type { Boost } from '../boost'; +import type RacerCtrl from '../ctrl'; +import type { PlayerWithScore } from '../interfaces'; + // to [0,1] type RelativeScore = (score: number) => number; diff --git a/ui/recap/src/recap.ts b/ui/recap/src/recap.ts index cafc2fff6e4..d6fc2ab5933 100644 --- a/ui/recap/src/recap.ts +++ b/ui/recap/src/recap.ts @@ -1,9 +1,11 @@ import { init, classModule, attributesModule } from 'snabbdom'; -import { view, awaiter } from './view'; -import { makeSwiper } from './swiper'; -import { json } from 'lib/xhr'; + import { isMobile } from 'lib/device'; +import { json } from 'lib/xhr'; + import type { Opts } from './interfaces'; +import { makeSwiper } from './swiper'; +import { view, awaiter } from './view'; const patch = init([classModule, attributesModule]); diff --git a/ui/recap/src/slides.ts b/ui/recap/src/slides.ts index 347ba7d1358..78d329e4094 100644 --- a/ui/recap/src/slides.ts +++ b/ui/recap/src/slides.ts @@ -1,14 +1,16 @@ +import { COLORS } from 'chessops'; + +import { shuffle } from 'lib/algo'; +import perfIcons from 'lib/game/perfIcons'; +import { currencyFormat, numberFormat, percentFormat } from 'lib/i18n'; +import * as licon from 'lib/licon'; +import { onInsert, hl, type LooseVNodes, type VNode, dataIcon, spinnerVdom } from 'lib/view'; +import { fullName, userFlair, userTitle } from 'lib/view/userLink'; + import { pieceGrams, totalGames } from './constants'; import type { Counted, Opening, Recap, Sources, RecapPerf, Opts } from './interfaces'; -import { onInsert, hl, type LooseVNodes, type VNode, dataIcon, spinnerVdom } from 'lib/view'; import { loadOpeningLpv } from './ui'; -import { shuffle } from 'lib/algo'; -import { fullName, userFlair, userTitle } from 'lib/view/userLink'; import { formatDuration, perfIsSpeed, perfLabel } from './util'; -import perfIcons from 'lib/game/perfIcons'; -import * as licon from 'lib/licon'; -import { currencyFormat, numberFormat, percentFormat } from 'lib/i18n'; -import { COLORS } from 'chessops'; const confettiCanvas = (): VNode => hl('canvas#confetti', { diff --git a/ui/recap/src/swiper.ts b/ui/recap/src/swiper.ts index ea42e58c496..bd4c0c44c38 100644 --- a/ui/recap/src/swiper.ts +++ b/ui/recap/src/swiper.ts @@ -1,11 +1,13 @@ import Swiper from 'swiper'; -import type { SwiperOptions } from 'swiper/types'; import * as mod from 'swiper/modules'; -import { animateNumber } from './ui'; -import { get } from 'lib/data'; -import { formatDuration } from './util'; +import type { SwiperOptions } from 'swiper/types'; + import { defined } from 'lib'; +import { get } from 'lib/data'; + import type { Opts } from './interfaces'; +import { animateNumber } from './ui'; +import { formatDuration } from './util'; export const makeSwiper = (opts: Opts) => diff --git a/ui/recap/src/ui.ts b/ui/recap/src/ui.ts index 3102d552072..bdc36ad7d39 100644 --- a/ui/recap/src/ui.ts +++ b/ui/recap/src/ui.ts @@ -1,8 +1,10 @@ import Lpv from '@lichess-org/pgn-viewer'; -import type { Opening } from './interfaces'; + import { set } from 'lib/data'; import { numberFormat } from 'lib/i18n'; +import type { Opening } from './interfaces'; + interface AnimateNumber { duration: number; render: (n: number) => string; diff --git a/ui/recap/src/view.ts b/ui/recap/src/view.ts index dd87f10bb57..92068783ef1 100644 --- a/ui/recap/src/view.ts +++ b/ui/recap/src/view.ts @@ -1,6 +1,8 @@ -import type { Opts, Recap } from './interfaces'; import { type VNode } from 'snabbdom'; + import { hl } from 'lib/view'; + +import type { Opts, Recap } from './interfaces'; import * as slides from './slides'; export function awaiter(user: LightUser): VNode { diff --git a/ui/recap/tests/duration.test.ts b/ui/recap/tests/duration.test.ts index e0d8fbabacd..446b0c3854e 100644 --- a/ui/recap/tests/duration.test.ts +++ b/ui/recap/tests/duration.test.ts @@ -1,5 +1,6 @@ -import { test } from 'node:test'; import assert from 'node:assert/strict'; +import { test } from 'node:test'; + import { formatDuration } from '../src/util'; test('singular and plural time units', () => { diff --git a/ui/round/src/atomic.ts b/ui/round/src/atomic.ts index 6cde5f397a9..a7cb1f68548 100644 --- a/ui/round/src/atomic.ts +++ b/ui/round/src/atomic.ts @@ -1,5 +1,6 @@ -import { key2pos, pos2key } from '@lichess-org/chessground/util'; import type { PiecesDiff } from '@lichess-org/chessground/types'; +import { key2pos, pos2key } from '@lichess-org/chessground/util'; + import type RoundController from './ctrl'; export function capture(ctrl: RoundController, key: Key): void { diff --git a/ui/round/src/cevalSub.ts b/ui/round/src/cevalSub.ts index a410fb9af63..4cac952b717 100644 --- a/ui/round/src/cevalSub.ts +++ b/ui/round/src/cevalSub.ts @@ -1,9 +1,10 @@ -import { lastStep } from './util'; +import { playedTurns } from 'lib/game'; +import { storage } from 'lib/storage'; +import { text as xhrText } from 'lib/xhr'; + import type RoundController from './ctrl'; import type { ApiMove, RoundData } from './interfaces'; -import { text as xhrText } from 'lib/xhr'; -import { storage } from 'lib/storage'; -import { playedTurns } from 'lib/game'; +import { lastStep } from './util'; let found = false; diff --git a/ui/round/src/corresClock/corresClockView.ts b/ui/round/src/corresClock/corresClockView.ts index c2d9b5cf9a5..1c756bd6a04 100644 --- a/ui/round/src/corresClock/corresClockView.ts +++ b/ui/round/src/corresClock/corresClockView.ts @@ -1,8 +1,9 @@ -import { hl, type VNode } from 'lib/view'; import type { TopOrBottom } from 'lib/game'; -import type { CorresClockController } from './corresClockCtrl'; -import { moretime } from '../view/button'; import { formatClockTimeVerbal } from 'lib/game/clock/clockView'; +import { hl, type VNode } from 'lib/view'; + +import { moretime } from '../view/button'; +import type { CorresClockController } from './corresClockCtrl'; const prefixInteger = (num: number, length: number): string => (num / Math.pow(10, length)).toFixed(length).slice(2); diff --git a/ui/round/src/crazy/crazyCtrl.ts b/ui/round/src/crazy/crazyCtrl.ts index be9353d5c51..9756978e4f0 100644 --- a/ui/round/src/crazy/crazyCtrl.ts +++ b/ui/round/src/crazy/crazyCtrl.ts @@ -1,11 +1,13 @@ -import { isPlayerTurn } from 'lib/game'; import { dragNewPiece } from '@lichess-org/chessground/drag'; import { setDropMode, cancelDropMode } from '@lichess-org/chessground/drop'; -import type RoundController from '../ctrl'; import type { MouchEvent } from '@lichess-org/chessground/types'; -import type { RoundData } from '../interfaces'; -import { storage } from 'lib/storage'; + +import { isPlayerTurn } from 'lib/game'; import { pubsub } from 'lib/pubsub'; +import { storage } from 'lib/storage'; + +import type RoundController from '../ctrl'; +import type { RoundData } from '../interfaces'; export const pieceRoles: Exclude[] = ['pawn', 'knight', 'bishop', 'rook', 'queen']; diff --git a/ui/round/src/crazy/crazyView.ts b/ui/round/src/crazy/crazyView.ts index e32252fc109..91fa0bf2148 100644 --- a/ui/round/src/crazy/crazyView.ts +++ b/ui/round/src/crazy/crazyView.ts @@ -1,8 +1,10 @@ import type { MouchEvent } from '@lichess-org/chessground/types'; -import { onInsert, type LooseVNode } from 'lib/view'; import { h } from 'snabbdom'; -import type RoundController from '../ctrl'; + import type { TopOrBottom } from 'lib/game'; +import { onInsert, type LooseVNode } from 'lib/view'; + +import type RoundController from '../ctrl'; import { plyStep } from '../util'; import { crazyKeys, drag, pieceRoles } from './crazyCtrl'; diff --git a/ui/round/src/ctrl.ts b/ui/round/src/ctrl.ts index d50e1f3d1cb..15100d5e97f 100644 --- a/ui/round/src/ctrl.ts +++ b/ui/round/src/ctrl.ts @@ -1,35 +1,37 @@ /// +import { opposite, uciToMove } from '@lichess-org/chessground/util'; import * as ab from 'ab'; -import * as game from 'lib/game'; -import { game as gameRoute } from 'lib/game/router'; -import { playing } from 'lib/game/status'; -import { boardOrientation, reload as groundReload } from './ground'; -import * as licon from 'lib/licon'; -import notify from 'lib/notification'; -import { make as makeSocket, type RoundSocket } from './socket'; -import * as title from './title'; -import * as blur from './blur'; -import viewStatus from 'lib/game/view/status'; -import { ClockCtrl, type ClockOpts } from 'lib/game/clock/clockCtrl'; -import { CorresClockController } from './corresClock/corresClockCtrl'; -import MoveOn from './moveOn'; -import TransientMove from './transientMove'; -import * as atomic from './atomic'; -import * as util from './util'; -import * as xhr from './xhr'; -import { valid as crazyValid, init as crazyInit, onEnd as crazyEndHook } from './crazy/crazyCtrl'; -import type { MoveRootCtrl } from 'lib/game/moveRootCtrl'; import { ctrl as makeKeyboardMove, type KeyboardMove } from 'keyboardMove'; import { makeVoiceMove, type VoiceMove } from 'voice'; -import { userTxt } from './view/user'; -import * as cevalSub from './cevalSub'; -import { init as keyboardInit } from './keyboard'; + +import { defined, type Toggle, type Prop, toggle, requestIdleCallback, memoize } from 'lib'; +import * as game from 'lib/game'; +import { plyToTurn } from 'lib/game/chess'; +import { ClockCtrl, type ClockOpts } from 'lib/game/clock/clockCtrl'; +import type { MoveRootCtrl } from 'lib/game/moveRootCtrl'; import { PromotionCtrl, promote } from 'lib/game/promotion'; -import * as wakeLock from 'lib/wakeLock'; -import { opposite, uciToMove } from '@lichess-org/chessground/util'; +import { game as gameRoute } from 'lib/game/router'; +import { readFen, almostSanOf, speakable } from 'lib/game/sanWriter'; +import { playing } from 'lib/game/status'; +import viewStatus from 'lib/game/view/status'; +import * as licon from 'lib/licon'; +import notify from 'lib/notification'; +import * as poolRangeStorage from 'lib/poolRangeStorage'; import { Replay } from 'lib/prefs'; -import { endGameView } from './view/main'; +import { pubsub } from 'lib/pubsub'; +import { type SocketSendOpts } from 'lib/socket'; +import { storage, once, storedBooleanProp, type LichessBooleanStorage } from 'lib/storage'; +import type { NodeCrazy } from 'lib/tree/types'; +import { toggleZenMode } from 'lib/view/zen'; +import * as wakeLock from 'lib/wakeLock'; + +import * as atomic from './atomic'; +import * as blur from './blur'; +import * as cevalSub from './cevalSub'; +import { CorresClockController } from './corresClock/corresClockCtrl'; +import { valid as crazyValid, init as crazyInit, onEnd as crazyEndHook } from './crazy/crazyCtrl'; +import { boardOrientation, reload as groundReload } from './ground'; import type { Step, RoundOpts, @@ -43,16 +45,16 @@ import type { ApiEnd, EventsWithPayload, } from './interfaces'; -import { defined, type Toggle, type Prop, toggle, requestIdleCallback, memoize } from 'lib'; -import { storage, once, storedBooleanProp, type LichessBooleanStorage } from 'lib/storage'; -import * as poolRangeStorage from 'lib/poolRangeStorage'; -import { pubsub } from 'lib/pubsub'; -import { readFen, almostSanOf, speakable } from 'lib/game/sanWriter'; -import { plyToTurn } from 'lib/game/chess'; -import { type SocketSendOpts } from 'lib/socket'; -import type { NodeCrazy } from 'lib/tree/types'; +import { init as keyboardInit } from './keyboard'; +import MoveOn from './moveOn'; import Server from './server'; -import { toggleZenMode } from 'lib/view/zen'; +import { make as makeSocket, type RoundSocket } from './socket'; +import * as title from './title'; +import TransientMove from './transientMove'; +import * as util from './util'; +import { endGameView } from './view/main'; +import { userTxt } from './view/user'; +import * as xhr from './xhr'; type GoneBerserk = Partial>; diff --git a/ui/round/src/ground.ts b/ui/round/src/ground.ts index 40db1082698..94680f09edc 100644 --- a/ui/round/src/ground.ts +++ b/ui/round/src/ground.ts @@ -1,15 +1,17 @@ -import * as util from './util'; -import { onInsert } from 'lib/view'; -import resizeHandle from 'lib/chessgroundResize'; -import type RoundController from './ctrl'; -import { h, type VNode } from 'snabbdom'; -import { plyStep } from './util'; -import type { RoundData } from './interfaces'; +import { Chessground as makeChessground } from '@lichess-org/chessground'; import { uciToMove } from '@lichess-org/chessground/util'; +import { h, type VNode } from 'snabbdom'; + +import resizeHandle from 'lib/chessgroundResize'; import { ShowResizeHandle, Coords, MoveEvent } from 'lib/prefs'; import { storage } from 'lib/storage'; -import { Chessground as makeChessground } from '@lichess-org/chessground'; +import { onInsert } from 'lib/view'; + +import type RoundController from './ctrl'; +import type { RoundData } from './interfaces'; import { Premove } from './premove'; +import * as util from './util'; +import { plyStep } from './util'; export function makeConfig(ctrl: RoundController): CgConfig { const data = ctrl.data, diff --git a/ui/round/src/interfaces.ts b/ui/round/src/interfaces.ts index 9f1edf85329..ee72c0d7119 100644 --- a/ui/round/src/interfaces.ts +++ b/ui/round/src/interfaces.ts @@ -1,13 +1,15 @@ -import type { VNode } from 'lib/view'; +import type { MoveMetadata as CgMoveMetadata } from '@lichess-org/chessground/types'; + +import type { ChatOpts as BaseChatOpts, ChatCtrl, ChatPlugin } from 'lib/chat/interfaces'; import type { GameData, Status, RoundStep } from 'lib/game'; import type { ClockData } from 'lib/game/clock/clockCtrl'; -import type { CorresClockData } from './corresClock/corresClockCtrl'; -import type { ChatOpts as BaseChatOpts, ChatCtrl, ChatPlugin } from 'lib/chat/interfaces'; import * as Prefs from 'lib/prefs'; import type { EnhanceOpts } from 'lib/richText'; -import type { RoundSocket } from './socket'; -import type { MoveMetadata as CgMoveMetadata } from '@lichess-org/chessground/types'; import type { NodeCrazy } from 'lib/tree/types'; +import type { VNode } from 'lib/view'; + +import type { CorresClockData } from './corresClock/corresClockCtrl'; +import type { RoundSocket } from './socket'; export { type RoundSocket } from './socket'; export { type CorresClockData } from './corresClock/corresClockCtrl'; diff --git a/ui/round/src/keyboard.ts b/ui/round/src/keyboard.ts index 2e2d323f4f9..02159c97a7f 100644 --- a/ui/round/src/keyboard.ts +++ b/ui/round/src/keyboard.ts @@ -1,7 +1,9 @@ -import type RoundController from './ctrl'; import type { VNode } from 'snabbdom'; -import { snabDialog } from 'lib/view'; + import { pubsub } from 'lib/pubsub'; +import { snabDialog } from 'lib/view'; + +import type RoundController from './ctrl'; export const prev = (ctrl: RoundController): void => ctrl.userJump(ctrl.ply - 1); diff --git a/ui/round/src/moveOn.ts b/ui/round/src/moveOn.ts index 6ce53ca584e..7ee634ece08 100644 --- a/ui/round/src/moveOn.ts +++ b/ui/round/src/moveOn.ts @@ -1,8 +1,9 @@ import { isSwitchable, isPlayerTurn } from 'lib/game'; -import { whatsNext } from './xhr'; -import type RoundController from './ctrl'; import { storage } from 'lib/storage'; +import type RoundController from './ctrl'; +import { whatsNext } from './xhr'; + export default class MoveOn { private storage = storage.boolean(this.key); diff --git a/ui/round/src/plugins/round.tour.ts b/ui/round/src/plugins/round.tour.ts index d505fa4c8e2..26e78143373 100644 --- a/ui/round/src/plugins/round.tour.ts +++ b/ui/round/src/plugins/round.tour.ts @@ -1,6 +1,7 @@ -import type { RoundTour } from '../interfaces'; import Shepherd from 'shepherd.js'; +import type { RoundTour } from '../interfaces'; + export function initModule(): RoundTour { return { corresRematchOffline, diff --git a/ui/round/src/premove.ts b/ui/round/src/premove.ts index 747ee881877..ac0521820d3 100644 --- a/ui/round/src/premove.ts +++ b/ui/round/src/premove.ts @@ -1,5 +1,5 @@ -import * as util from '@lichess-org/chessground/util'; import * as cg from '@lichess-org/chessground/types'; +import * as util from '@lichess-org/chessground/util'; export class Premove { readonly unrestrictedPremoves: boolean; diff --git a/ui/round/src/round.nvui.ts b/ui/round/src/round.nvui.ts index 7066b7faf3d..ceacb446be7 100644 --- a/ui/round/src/round.nvui.ts +++ b/ui/round/src/round.nvui.ts @@ -1,11 +1,12 @@ -import type RoundController from './ctrl'; -import { renderNvui } from './view/nvuiView'; -import type { NvuiPlugin } from './interfaces'; +import { isTouchDevice } from 'lib/device'; import { type NvuiContext, makeContext } from 'lib/nvui/chess'; import { makeSetting, type Setting } from 'lib/nvui/setting'; import { pubsub } from 'lib/pubsub'; import { storage } from 'lib/storage'; -import { isTouchDevice } from 'lib/device'; + +import type RoundController from './ctrl'; +import type { NvuiPlugin } from './interfaces'; +import { renderNvui } from './view/nvuiView'; export type RoundNvuiContext = NvuiContext & Readonly<{ diff --git a/ui/round/src/round.ts b/ui/round/src/round.ts index ccf9110669f..81c958bef8e 100644 --- a/ui/round/src/round.ts +++ b/ui/round/src/round.ts @@ -1,19 +1,21 @@ -import type { RoundData, RoundOpts } from './interfaces'; import { attributesModule, classModule, init } from 'snabbdom'; -import menuHover from 'lib/menuHover'; -import RoundController from './ctrl'; -import { main as view } from './view/main'; -import { text as xhrText } from 'lib/xhr'; -import type MoveOn from './moveOn'; + +import { myUserId } from 'lib'; +import standaloneChat from 'lib/chat/standalone'; import type { TourPlayer } from 'lib/game'; -import { tourStandingCtrl, type TourStandingCtrl } from './tourStanding'; +import { setClockWidget } from 'lib/game/clock/clockWidget'; +import menuHover from 'lib/menuHover'; +import { pubsub } from 'lib/pubsub'; import { wsConnect, wsDestroy } from 'lib/socket'; import { storage } from 'lib/storage'; -import { setClockWidget } from 'lib/game/clock/clockWidget'; -import standaloneChat from 'lib/chat/standalone'; -import { pubsub } from 'lib/pubsub'; -import { myUserId } from 'lib'; import { alert } from 'lib/view'; +import { text as xhrText } from 'lib/xhr'; + +import RoundController from './ctrl'; +import type { RoundData, RoundOpts } from './interfaces'; +import type MoveOn from './moveOn'; +import { tourStandingCtrl, type TourStandingCtrl } from './tourStanding'; +import { main as view } from './view/main'; const patch = init([classModule, attributesModule]); diff --git a/ui/round/src/server.ts b/ui/round/src/server.ts index 6e23a8b0295..8735e1f8112 100644 --- a/ui/round/src/server.ts +++ b/ui/round/src/server.ts @@ -1,7 +1,8 @@ -import { pubsub } from 'lib/pubsub'; -import * as xhr from './xhr'; import { isPlayerPlaying, isPlayerTurn } from 'lib/game'; +import { pubsub } from 'lib/pubsub'; + import type { RoundData } from './interfaces'; +import * as xhr from './xhr'; export default class Server { scheduledCheck: Timeout | undefined; diff --git a/ui/round/src/socket.ts b/ui/round/src/socket.ts index 0acef132946..000a27b548f 100644 --- a/ui/round/src/socket.ts +++ b/ui/round/src/socket.ts @@ -1,13 +1,15 @@ -import { type Simul, setOnGame, isPlayerTurn } from 'lib/game'; -import { throttle } from 'lib/async'; -import { reload as xhrReload } from './xhr'; -import type RoundController from './ctrl'; +import { COLORS } from 'chessops'; + import { defined } from 'lib'; -import { domDialog } from 'lib/view'; +import { throttle } from 'lib/async'; +import { type Simul, setOnGame, isPlayerTurn } from 'lib/game'; import { pubsub } from 'lib/pubsub'; import { wsSign, wsVersion } from 'lib/socket'; +import { domDialog } from 'lib/view'; + +import type RoundController from './ctrl'; import type { RoundSocketSend, EventsWithoutPayload } from './interfaces'; -import { COLORS } from 'chessops'; +import { reload as xhrReload } from './xhr'; export interface RoundSocket { send: RoundSocketSend; diff --git a/ui/round/src/title.ts b/ui/round/src/title.ts index 4aab3c00caa..25550f6b952 100644 --- a/ui/round/src/title.ts +++ b/ui/round/src/title.ts @@ -1,6 +1,7 @@ -import type RoundController from './ctrl'; import { aborted, finished, isPlayerTurn } from 'lib/game'; +import type RoundController from './ctrl'; + const initialTitle = document.title; let curFaviconIdx = 0; diff --git a/ui/round/src/tourStanding.ts b/ui/round/src/tourStanding.ts index 4f02efd1d41..bf6f169e403 100644 --- a/ui/round/src/tourStanding.ts +++ b/ui/round/src/tourStanding.ts @@ -1,8 +1,9 @@ import { h, type VNode } from 'snabbdom'; -import * as licon from 'lib/licon'; -import { dataIcon, onInsert } from 'lib/view'; + import type { ChatPlugin } from 'lib/chat/interfaces'; import type { Team, TourPlayer } from 'lib/game'; +import * as licon from 'lib/licon'; +import { dataIcon, onInsert } from 'lib/view'; export interface TourStandingCtrl extends ChatPlugin { set(players: TourPlayer[]): void; diff --git a/ui/round/src/transientMove.ts b/ui/round/src/transientMove.ts index 105373d6658..f4a230c6d49 100644 --- a/ui/round/src/transientMove.ts +++ b/ui/round/src/transientMove.ts @@ -1,6 +1,7 @@ -import type { RoundSocket } from './socket'; import { text as xhrText } from 'lib/xhr'; +import type { RoundSocket } from './socket'; + /* Tracks moves that were played on the board, * sent to the server, possibly acked, * but without a move response from the server yet. diff --git a/ui/round/src/util.ts b/ui/round/src/util.ts index eb8f267dd2a..3241d094d95 100644 --- a/ui/round/src/util.ts +++ b/ui/round/src/util.ts @@ -1,4 +1,5 @@ import type { VNodeData } from 'snabbdom'; + import type { EncodedDests, RoundData, Step } from './interfaces'; export const justIcon = (icon: string): VNodeData => ({ diff --git a/ui/round/src/view/boardMenu.ts b/ui/round/src/view/boardMenu.ts index 9e0453167e9..457ecf16007 100644 --- a/ui/round/src/view/boardMenu.ts +++ b/ui/round/src/view/boardMenu.ts @@ -1,9 +1,10 @@ -import { hl, type LooseVNode, boardMenu as menuDropdown, boolPrefXhrToggle } from 'lib/view'; -import { cmnToggleWrap } from 'lib/view/cmn-toggle'; -import type RoundController from '../ctrl'; import { toggle } from 'lib'; import { displayColumns, isTouchDevice } from 'lib/device'; import { storage } from 'lib/storage'; +import { hl, type LooseVNode, boardMenu as menuDropdown, boolPrefXhrToggle } from 'lib/view'; +import { cmnToggleWrap } from 'lib/view/cmn-toggle'; + +import type RoundController from '../ctrl'; export default function (ctrl: RoundController): LooseVNode { return menuDropdown(ctrl.redraw, ctrl.menu, menu => { diff --git a/ui/round/src/view/button.ts b/ui/round/src/view/button.ts index 26188fb37ab..f81ee6b664e 100644 --- a/ui/round/src/view/button.ts +++ b/ui/round/src/view/button.ts @@ -1,13 +1,15 @@ import type { VNode, Hooks } from 'snabbdom'; -import * as licon from 'lib/licon'; -import { spinnerVdom as spinner, type LooseVNodes, type LooseVNode, hl, bind, onInsert } from 'lib/view'; -import { justIcon } from '../util'; + import { finished, aborted, replayable, rematchable, moretimeable, type PlayerUser } from 'lib/game'; -import { game as gameRoute } from 'lib/game/router'; -import type { EventsWithoutPayload, RoundData } from '../interfaces'; import type { ClockData } from 'lib/game/clock/clockCtrl'; -import type RoundController from '../ctrl'; +import { game as gameRoute } from 'lib/game/router'; +import * as licon from 'lib/licon'; import { pubsub } from 'lib/pubsub'; +import { spinnerVdom as spinner, type LooseVNodes, type LooseVNode, hl, bind, onInsert } from 'lib/view'; + +import type RoundController from '../ctrl'; +import type { EventsWithoutPayload, RoundData } from '../interfaces'; +import { justIcon } from '../util'; export interface ButtonState { enabled: boolean; diff --git a/ui/round/src/view/clock.ts b/ui/round/src/view/clock.ts index a473a90001a..d29c0a223c3 100644 --- a/ui/round/src/view/clock.ts +++ b/ui/round/src/view/clock.ts @@ -1,9 +1,3 @@ -import { type LooseVNode, hl, bind } from 'lib/view'; -import * as licon from 'lib/licon'; -import { renderClock } from 'lib/game/clock/clockView'; -import RoundController from '../ctrl'; -import renderCorresClock from '../corresClock/corresClockView'; -import { moretime } from './button'; import { aborted, berserkableBy, @@ -13,7 +7,14 @@ import { type TopOrBottom, type TournamentRanks, } from 'lib/game'; +import { renderClock } from 'lib/game/clock/clockView'; +import * as licon from 'lib/licon'; +import { type LooseVNode, hl, bind } from 'lib/view'; + +import renderCorresClock from '../corresClock/corresClockView'; +import RoundController from '../ctrl'; import { justIcon } from '../util'; +import { moretime } from './button'; export const anyClockView = (ctrl: RoundController, position: TopOrBottom): LooseVNode => { const player = ctrl.playerAt(position); diff --git a/ui/round/src/view/expiration.ts b/ui/round/src/view/expiration.ts index b0d75b29bcc..f7cc5e9aaec 100644 --- a/ui/round/src/view/expiration.ts +++ b/ui/round/src/view/expiration.ts @@ -1,8 +1,10 @@ import { h } from 'snabbdom'; -import type RoundController from '../ctrl'; + import { isPlayerTurn, playable } from 'lib/game'; import type { MaybeVNode } from 'lib/view'; +import type RoundController from '../ctrl'; + let rang = false; export default function (ctrl: RoundController): MaybeVNode { diff --git a/ui/round/src/view/main.ts b/ui/round/src/view/main.ts index ee47dc430a3..79c913e552b 100644 --- a/ui/round/src/view/main.ts +++ b/ui/round/src/view/main.ts @@ -1,16 +1,18 @@ -import { next, prev, view } from '../keyboard'; -import crazyView from '../crazy/crazyView'; -import type RoundController from '../ctrl'; +import { render as renderKeyboardMove } from 'keyboardMove'; +import { renderVoiceBar } from 'voice'; + +import { displayColumns, isTouchDevice } from 'lib/device'; +import { playable } from 'lib/game'; +import { renderMaterialDiffs } from 'lib/game/view/material'; +import { storage } from 'lib/storage'; import { stepwiseScroll, type VNode, hl, bind } from 'lib/view'; import { renderBlindfoldToggle } from 'lib/view/blindfold'; -import { render as renderKeyboardMove } from 'keyboardMove'; + +import crazyView from '../crazy/crazyView'; +import type RoundController from '../ctrl'; import { render as renderGround } from '../ground'; +import { next, prev, view } from '../keyboard'; import { renderTable } from './table'; -import { renderMaterialDiffs } from 'lib/game/view/material'; -import { renderVoiceBar } from 'voice'; -import { playable } from 'lib/game'; -import { storage } from 'lib/storage'; -import { displayColumns, isTouchDevice } from 'lib/device'; export function main(ctrl: RoundController): VNode { const d = ctrl.data, diff --git a/ui/round/src/view/nvuiView.ts b/ui/round/src/view/nvuiView.ts index 0270e3c265b..a606d468be8 100644 --- a/ui/round/src/view/nvuiView.ts +++ b/ui/round/src/view/nvuiView.ts @@ -1,22 +1,24 @@ -import type { RoundNvuiContext } from '../round.nvui'; -import type RoundController from '../ctrl'; -import { type LooseVNodes, type VNode, bind, hl, noTrans, onInsert } from 'lib/view'; -import { renderClock } from 'lib/game/clock/clockView'; -import { type Player, type TopOrBottom, playable } from 'lib/game'; -import { renderTableWatch, renderTablePlay, renderTableEnd } from './table'; -import { scanDirectionsHandler } from 'lib/nvui/directionScan'; -import { commands, boardCommands } from 'lib/nvui/command'; -import { plyToTurn } from 'lib/game/chess'; -import { renderSetting } from 'lib/nvui/setting'; -import * as nv from 'lib/nvui/chess'; import { Chessground as makeChessground } from '@lichess-org/chessground'; -import { makeConfig as makeCgConfig } from '../ground'; +import { COLORS, opposite } from 'chessops'; + +import { type Player, type TopOrBottom, playable } from 'lib/game'; +import { plyToTurn } from 'lib/game/chess'; +import { renderClock } from 'lib/game/clock/clockView'; +import * as nv from 'lib/nvui/chess'; +import { commands, boardCommands } from 'lib/nvui/command'; +import { scanDirectionsHandler } from 'lib/nvui/directionScan'; +import { renderSetting } from 'lib/nvui/setting'; +import { type LooseVNodes, type VNode, bind, hl, noTrans, onInsert } from 'lib/view'; + import renderCorresClock from '../corresClock/corresClockView'; -import { renderResult } from './replay'; -import { plyStep } from '../util'; +import type RoundController from '../ctrl'; +import { makeConfig as makeCgConfig } from '../ground'; import type { Step } from '../interfaces'; import { next, prev } from '../keyboard'; -import { COLORS, opposite } from 'chessops'; +import type { RoundNvuiContext } from '../round.nvui'; +import { plyStep } from '../util'; +import { renderResult } from './replay'; +import { renderTableWatch, renderTablePlay, renderTableEnd } from './table'; const selectSound = () => site.sound.play('select'); const borderSound = () => site.sound.play('outOfBound'); diff --git a/ui/round/src/view/replay.ts b/ui/round/src/view/replay.ts index 47b753a3c71..efecbcb8a7e 100644 --- a/ui/round/src/view/replay.ts +++ b/ui/round/src/view/replay.ts @@ -1,12 +1,11 @@ -import * as licon from 'lib/licon'; -import { finished, aborted, userAnalysable, playable } from 'lib/game'; -import * as util from '../util'; -import { displayColumns } from 'lib/device'; -import type RoundController from '../ctrl'; +import { blurIfPrimaryClick, repeater } from 'lib'; import { throttle } from 'lib/async'; -import viewStatus from 'lib/game/view/status'; +import { displayColumns } from 'lib/device'; +import { finished, aborted, userAnalysable, playable } from 'lib/game'; import { game as gameRoute } from 'lib/game/router'; -import type { Step } from '../interfaces'; +import viewStatus from 'lib/game/view/status'; +import * as licon from 'lib/licon'; +import { addPointerListeners } from 'lib/pointer'; import { toggleButton as boardMenuToggleButton, type VNode, @@ -15,9 +14,11 @@ import { hl, onInsert, } from 'lib/view'; + +import type RoundController from '../ctrl'; +import type { Step } from '../interfaces'; +import * as util from '../util'; import boardMenu from './boardMenu'; -import { blurIfPrimaryClick, repeater } from 'lib'; -import { addPointerListeners } from 'lib/pointer'; const scrollMax = 99999, moveTag = 'kwdb', diff --git a/ui/round/src/view/table.ts b/ui/round/src/view/table.ts index 0f0638bf0eb..42987e7d479 100644 --- a/ui/round/src/view/table.ts +++ b/ui/round/src/view/table.ts @@ -1,12 +1,13 @@ -import * as licon from 'lib/licon'; import { abortable, playable, drawableSwiss, resignable, takebackable, type TopOrBottom } from 'lib/game'; -import { render as renderReplay, analysisButton } from './replay'; -import renderExpiration from './expiration'; -import { userHtml } from './user'; -import * as button from './button'; -import type RoundController from '../ctrl'; +import * as licon from 'lib/licon'; import { type LooseVNodes, hl, bind, toggleButton as boardMenuToggleButton } from 'lib/view'; + +import type RoundController from '../ctrl'; +import * as button from './button'; import { anyClockView } from './clock'; +import renderExpiration from './expiration'; +import { render as renderReplay, analysisButton } from './replay'; +import { userHtml } from './user'; function renderPlayer(ctrl: RoundController, position: TopOrBottom) { if (ctrl.nvui) return undefined; diff --git a/ui/round/src/view/user.ts b/ui/round/src/view/user.ts index 2a19b5f6d07..861c494b6aa 100644 --- a/ui/round/src/view/user.ts +++ b/ui/round/src/view/user.ts @@ -1,10 +1,11 @@ -import { hl, type VNode } from 'lib/view'; -import * as licon from 'lib/licon'; -import type { Player, TopOrBottom } from 'lib/game'; -import type RoundController from '../ctrl'; -import { ratingDiff, userLink } from 'lib/view/userLink'; -import { wsAverageLag } from 'lib/socket'; import { defined } from 'lib'; +import type { Player, TopOrBottom } from 'lib/game'; +import * as licon from 'lib/licon'; +import { wsAverageLag } from 'lib/socket'; +import { hl, type VNode } from 'lib/view'; +import { ratingDiff, userLink } from 'lib/view/userLink'; + +import type RoundController from '../ctrl'; export function userHtml(ctrl: RoundController, player: Player, position: TopOrBottom): VNode { const d = ctrl.data, diff --git a/ui/round/src/xhr.ts b/ui/round/src/xhr.ts index c717ace43ba..d8a89eb3bbf 100644 --- a/ui/round/src/xhr.ts +++ b/ui/round/src/xhr.ts @@ -1,5 +1,6 @@ -import type RoundController from './ctrl'; import { text, json, form } from 'lib/xhr'; + +import type RoundController from './ctrl'; import type { RoundData } from './interfaces'; export const reload = (d: RoundData): Promise => { diff --git a/ui/round/tests/premove.test.ts b/ui/round/tests/premove.test.ts index d31d986e8e4..b309dd47b29 100644 --- a/ui/round/tests/premove.test.ts +++ b/ui/round/tests/premove.test.ts @@ -1,11 +1,11 @@ -import { describe, test } from 'node:test'; -import assert from 'node:assert/strict'; - -import { premove } from '@lichess-org/chessground/premove'; -import * as cg from '@lichess-org/chessground/types'; -import { defaults, type HeadlessState } from '@lichess-org/chessground/state'; import * as fen from '@lichess-org/chessground/fen'; +import { premove } from '@lichess-org/chessground/premove'; +import { defaults, type HeadlessState } from '@lichess-org/chessground/state'; +import * as cg from '@lichess-org/chessground/types'; import * as util from '@lichess-org/chessground/util'; +import assert from 'node:assert/strict'; +import { describe, test } from 'node:test'; + import { Premove } from '../src/premove'; const diagonallyOpposite = (square: cg.Key): cg.Key => diff --git a/ui/round/types/ab.d.ts b/ui/round/types/ab.d.ts index 23257abe084..23edc063f28 100644 --- a/ui/round/types/ab.d.ts +++ b/ui/round/types/ab.d.ts @@ -1,5 +1,6 @@ declare module 'ab' { import { MoveMetadata } from '@lichess-org/chessground/types'; + import { Pubsub } from 'lib/pubsub'; function init(round: unknown): void; function move(round: unknown, meta: MoveMetadata, emit: Pubsub['emit']): void; diff --git a/ui/simul/src/ctrl.ts b/ui/simul/src/ctrl.ts index af1cc46166f..2e257921389 100644 --- a/ui/simul/src/ctrl.ts +++ b/ui/simul/src/ctrl.ts @@ -1,8 +1,9 @@ +import { idleTimer } from 'lib/event'; +import { storage } from 'lib/storage'; + +import type { SimulData, SimulOpts } from './interfaces'; import { makeSocket, type SimulSocket } from './socket'; import xhr from './xhr'; -import type { SimulData, SimulOpts } from './interfaces'; -import { storage } from 'lib/storage'; -import { idleTimer } from 'lib/event'; export default class SimulCtrl { data: SimulData; diff --git a/ui/simul/src/simul.home.ts b/ui/simul/src/simul.home.ts index 6f0d167ec4c..7b86ef88898 100644 --- a/ui/simul/src/simul.home.ts +++ b/ui/simul/src/simul.home.ts @@ -1,5 +1,5 @@ -import { wsConnect } from 'lib/socket'; import { pubsub } from 'lib/pubsub'; +import { wsConnect } from 'lib/socket'; site.load.then(() => { wsConnect(`/socket/v5`, false, { params: { flag: 'simul' } }); diff --git a/ui/simul/src/simul.ts b/ui/simul/src/simul.ts index f1414faa375..8111640983e 100644 --- a/ui/simul/src/simul.ts +++ b/ui/simul/src/simul.ts @@ -1,8 +1,10 @@ import { init, type VNode, classModule, attributesModule } from 'snabbdom'; -import type { SimulOpts } from './interfaces'; -import SimulCtrl from './ctrl'; + import { wsConnect } from 'lib/socket'; +import SimulCtrl from './ctrl'; +import type { SimulOpts } from './interfaces'; + const patch = init([classModule, attributesModule]); import view from './view/main'; diff --git a/ui/simul/src/view/created.ts b/ui/simul/src/view/created.ts index 78e02b400fb..365d6a982b8 100644 --- a/ui/simul/src/view/created.ts +++ b/ui/simul/src/view/created.ts @@ -1,6 +1,8 @@ import type { VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; import { domDialog, confirm, bind, hl } from 'lib/view'; + import type SimulCtrl from '../ctrl'; import type { Applicant } from '../interfaces'; import xhr from '../xhr'; diff --git a/ui/simul/src/view/main.ts b/ui/simul/src/view/main.ts index 342f1c80b85..45d3925b60b 100644 --- a/ui/simul/src/view/main.ts +++ b/ui/simul/src/view/main.ts @@ -1,12 +1,13 @@ -import { onInsert, hl, initMiniGames } from 'lib/view'; -import type SimulCtrl from '../ctrl'; -import { title } from './util'; -import created from './created'; -import { richHTML } from 'lib/richText'; -import results from './results'; -import pairings from './pairings'; -import { watchers } from 'lib/view/watchers'; import standaloneChat from 'lib/chat/standalone'; +import { richHTML } from 'lib/richText'; +import { onInsert, hl, initMiniGames } from 'lib/view'; +import { watchers } from 'lib/view/watchers'; + +import type SimulCtrl from '../ctrl'; +import created from './created'; +import pairings from './pairings'; +import results from './results'; +import { title } from './util'; export default function (ctrl: SimulCtrl) { const handler = ctrl.data.isRunning ? started : ctrl.data.isFinished ? finished : created(showText); diff --git a/ui/simul/src/view/pairings.ts b/ui/simul/src/view/pairings.ts index 14fd0f48fa1..ab95b46c64e 100644 --- a/ui/simul/src/view/pairings.ts +++ b/ui/simul/src/view/pairings.ts @@ -1,9 +1,11 @@ +import { opposite } from '@lichess-org/chessground/util'; import { h } from 'snabbdom'; + import { onInsert, renderClock } from 'lib/view'; +import { userFlair } from 'lib/view/userLink'; + import type SimulCtrl from '../ctrl'; import type { Pairing } from '../interfaces'; -import { opposite } from '@lichess-org/chessground/util'; -import { userFlair } from 'lib/view/userLink'; export default function (ctrl: SimulCtrl) { return h('div.game-list.now-playing.box__pad', ctrl.data.pairings.map(miniPairing(ctrl))); diff --git a/ui/simul/src/view/results.ts b/ui/simul/src/view/results.ts index 53ce63baf68..b781d5f093b 100644 --- a/ui/simul/src/view/results.ts +++ b/ui/simul/src/view/results.ts @@ -1,8 +1,10 @@ -import { h } from 'snabbdom'; -import { status } from 'lib/game'; -import type { Pairing } from '../interfaces'; import { opposite } from '@lichess-org/chessground/util'; +import { h } from 'snabbdom'; + +import { status } from 'lib/game'; + import type SimulCtrl from '../ctrl'; +import type { Pairing } from '../interfaces'; export default function (ctrl: SimulCtrl) { return h('div.results', [ diff --git a/ui/simul/src/view/util.ts b/ui/simul/src/view/util.ts index f0c5839ac59..7e30f3e34e0 100644 --- a/ui/simul/src/view/util.ts +++ b/ui/simul/src/view/util.ts @@ -1,9 +1,10 @@ import { h } from 'snabbdom'; -import type { Player } from '../interfaces'; -import type SimulCtrl from '../ctrl'; import { fullName, userLine, userRating } from 'lib/view/userLink'; +import type SimulCtrl from '../ctrl'; +import type { Player } from '../interfaces'; + export function player(p: Player, ctrl: SimulCtrl) { return h( 'a.ulpt.user-link.' + (p.online || ctrl.data.host.id !== p.id ? 'online' : 'offline'), diff --git a/ui/site/src/asset.ts b/ui/site/src/asset.ts index 2a3dda8aa5a..d1ed510f1c5 100644 --- a/ui/site/src/asset.ts +++ b/ui/site/src/asset.ts @@ -1,7 +1,8 @@ -import { script as xhrScript } from 'lib/xhr'; -import { memoize } from 'lib'; import { COLORS } from 'chessops'; +import { memoize } from 'lib'; +import { script as xhrScript } from 'lib/xhr'; + export const baseUrl = memoize(() => document.body.getAttribute('data-asset-url') || ''); const assetVersion = memoize(() => document.body.getAttribute('data-asset-version')); diff --git a/ui/site/src/boot.ts b/ui/site/src/boot.ts index a5ff040c3cb..4009179e887 100644 --- a/ui/site/src/boot.ts +++ b/ui/site/src/boot.ts @@ -1,4 +1,10 @@ +import { scrollToInnerSelector, requestIdleCallback } from 'lib'; +import { dispatchChessgroundResize } from 'lib/chessgroundResize'; +import { isIos, isWebkit, prefersLightThemeQuery } from 'lib/device'; import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { eventuallySetupDefaultConnection } from 'lib/socket'; +import { once } from 'lib/storage'; import { initMiniBoards, initMiniGames, @@ -7,21 +13,16 @@ import { toggleBoxInit, alert, } from 'lib/view'; +import { watchers } from 'lib/view/watchers'; import { text as xhrText } from 'lib/xhr'; + import { display as announceDisplay } from './announce'; +import { addDomHandlers } from './domHandlers'; import OnlineFriends from './friends'; import powertip from './powertip'; -import serviceWorker from './serviceWorker'; -import { watchers } from 'lib/view/watchers'; -import { isIos, isWebkit, prefersLightThemeQuery } from 'lib/device'; -import { scrollToInnerSelector, requestIdleCallback } from 'lib'; -import { dispatchChessgroundResize } from 'lib/chessgroundResize'; -import { addDomHandlers } from './domHandlers'; import { updateTimeAgo, renderTimeAgo, renderLocalizedTimestamps } from './renderTimeAgo'; -import { pubsub } from 'lib/pubsub'; -import { once } from 'lib/storage'; +import serviceWorker from './serviceWorker'; import { addExceptionListeners } from './unhandledError'; -import { eventuallySetupDefaultConnection } from 'lib/socket'; export function boot() { addExceptionListeners(); diff --git a/ui/site/src/domHandlers.ts b/ui/site/src/domHandlers.ts index c678b0bfbef..1c1b8356242 100644 --- a/ui/site/src/domHandlers.ts +++ b/ui/site/src/domHandlers.ts @@ -1,9 +1,10 @@ import * as licon from 'lib/licon'; -import { writeTextClipboard, text as xhrText } from 'lib/xhr'; -import topBar from './topBar'; -import { userComplete } from 'lib/view/userComplete'; -import { confirm } from 'lib/view'; import menuKeyboardInteractions from 'lib/menuKeyboardInteractions'; +import { confirm } from 'lib/view'; +import { userComplete } from 'lib/view/userComplete'; +import { writeTextClipboard, text as xhrText } from 'lib/xhr'; + +import topBar from './topBar'; export function addWindowHandlers() { let animFrame: number; diff --git a/ui/site/src/friends.ts b/ui/site/src/friends.ts index a759f43111a..436936d855a 100644 --- a/ui/site/src/friends.ts +++ b/ui/site/src/friends.ts @@ -1,5 +1,5 @@ -import * as licon from 'lib/licon'; import { api as lichess } from 'lib/api'; +import * as licon from 'lib/licon'; type TitleName = string; diff --git a/ui/site/src/powertip.ts b/ui/site/src/powertip.ts index 896342c762e..a17b82f1a56 100644 --- a/ui/site/src/powertip.ts +++ b/ui/site/src/powertip.ts @@ -1,8 +1,8 @@ -import * as licon from 'lib/licon'; -import { text as xhrText } from 'lib/xhr'; import { requestIdleCallback } from 'lib'; -import { spinnerHtml } from 'lib/view'; +import * as licon from 'lib/licon'; import { pubsub } from 'lib/pubsub'; +import { spinnerHtml } from 'lib/view'; +import { text as xhrText } from 'lib/xhr'; // Thanks Steven Benner! - adapted from https://github.com/stevenbenner/jquery-powertip diff --git a/ui/site/src/serviceWorker.ts b/ui/site/src/serviceWorker.ts index 693612f3e3d..27e9e88f91a 100644 --- a/ui/site/src/serviceWorker.ts +++ b/ui/site/src/serviceWorker.ts @@ -1,7 +1,8 @@ -import { url as assetUrl, jsModule } from './asset'; import { log } from 'lib/permalog'; import { storage } from 'lib/storage'; +import { url as assetUrl, jsModule } from './asset'; + export default async function () { if (!('serviceWorker' in navigator && 'Notification' in window && 'PushManager' in window)) return; const workerUrl = new URL(assetUrl(jsModule('serviceWorker'), { pathOnly: true }), self.location.href); diff --git a/ui/site/src/site.puzzleEmbed.ts b/ui/site/src/site.puzzleEmbed.ts index b525c7b1498..b58c438f8b8 100644 --- a/ui/site/src/site.puzzleEmbed.ts +++ b/ui/site/src/site.puzzleEmbed.ts @@ -1,4 +1,5 @@ import { uciToMove } from '@lichess-org/chessground/util'; + import { embedChessground } from './asset'; // https://lichess.org/training/frame diff --git a/ui/site/src/site.ts b/ui/site/src/site.ts index 73016c20105..da52ca987cd 100644 --- a/ui/site/src/site.ts +++ b/ui/site/src/site.ts @@ -1,15 +1,16 @@ -import { boot } from './boot'; -import Mousetrap from './mousetrap'; import { randomToken } from 'lib/algo'; -import powertip from './powertip'; -import * as assets from './asset'; -import { unload, redirect, reload } from './reload'; -import { display as announceDisplay } from './announce'; -import { displayLocale } from 'lib/i18n'; -import sound from './sound'; import { api } from 'lib/api'; -import { loadPolyfills } from './polyfill'; +import { displayLocale } from 'lib/i18n'; + +import { display as announceDisplay } from './announce'; +import * as assets from './asset'; +import { boot } from './boot'; import { addWindowHandlers } from './domHandlers'; +import Mousetrap from './mousetrap'; +import { loadPolyfills } from './polyfill'; +import powertip from './powertip'; +import { unload, redirect, reload } from './reload'; +import sound from './sound'; const site = window.site; // site.load is initialized in site.inline.ts (body script) diff --git a/ui/site/src/site.tvEmbed.ts b/ui/site/src/site.tvEmbed.ts index 81f99454d71..2f0f08a650e 100644 --- a/ui/site/src/site.tvEmbed.ts +++ b/ui/site/src/site.tvEmbed.ts @@ -1,4 +1,5 @@ import { initMiniGame, updateMiniGame } from 'lib/view'; + import { embedChessground } from './asset'; function resize() { diff --git a/ui/site/src/sound.ts b/ui/site/src/sound.ts index 5ce15c7761e..5bde32793e3 100644 --- a/ui/site/src/sound.ts +++ b/ui/site/src/sound.ts @@ -1,8 +1,8 @@ -import { storage } from 'lib/storage'; -import { isIos } from 'lib/device'; -import { throttle } from 'lib/async'; import { defined } from 'lib'; +import { throttle } from 'lib/async'; +import { isIos } from 'lib/device'; import { speakable } from 'lib/game/sanWriter'; +import { storage } from 'lib/storage'; type Name = string; type Path = string; diff --git a/ui/site/src/topBar.ts b/ui/site/src/topBar.ts index bd5ef4f6625..0aaaa5e1ab0 100644 --- a/ui/site/src/topBar.ts +++ b/ui/site/src/topBar.ts @@ -1,10 +1,11 @@ -import { loadCssPath, loadEsm } from './asset'; import { memoize } from 'lib'; -import { spinnerHtml } from 'lib/view'; import { clamp } from 'lib/algo'; +import { isTouchDevice } from 'lib/device'; import { pubsub } from 'lib/pubsub'; import { wsSend } from 'lib/socket'; -import { isTouchDevice } from 'lib/device'; +import { spinnerHtml } from 'lib/view'; + +import { loadCssPath, loadEsm } from './asset'; export default function () { const top = document.getElementById('top')!; diff --git a/ui/site/src/unhandledError.ts b/ui/site/src/unhandledError.ts index 6bb6bf99b5d..6a9d050d39c 100644 --- a/ui/site/src/unhandledError.ts +++ b/ui/site/src/unhandledError.ts @@ -1,6 +1,6 @@ +import { escapeHtml } from 'lib'; import { log } from 'lib/permalog'; import { domDialog } from 'lib/view'; -import { escapeHtml } from 'lib'; function terseHref(): string { return window.location.href.replace(/^(https:\/\/)?(?:lichess|lichess1)\.org\//, '/'); diff --git a/ui/storm/src/ctrl.ts b/ui/storm/src/ctrl.ts index a9f2e0efc99..de6e0c77f2b 100644 --- a/ui/storm/src/ctrl.ts +++ b/ui/storm/src/ctrl.ts @@ -1,23 +1,25 @@ -import * as xhr from './xhr'; -import config from './config'; -import CurrentPuzzle from 'lib/puz/current'; -import sign from 'lib/puz/sign'; import type { Api as CgApi } from '@lichess-org/chessground/api'; +import { parseUci } from 'chessops/util'; + +import { prop, type Prop } from 'lib'; +import type { WithGround } from 'lib/game/ground'; +import { PromotionCtrl } from 'lib/game/promotion'; +import { pubsub } from 'lib/pubsub'; import { Clock } from 'lib/puz/clock'; import { Combo } from 'lib/puz/combo'; -import { getNow, puzzlePov, sound } from 'lib/puz/util'; -import { makeCgOpts } from 'lib/puz/run'; -import { parseUci } from 'chessops/util'; -import { PromotionCtrl } from 'lib/game/promotion'; -import { prop, type Prop } from 'lib'; -import type { PuzCtrl, Run } from 'lib/puz/interfaces'; +import CurrentPuzzle from 'lib/puz/current'; import { PuzFilters } from 'lib/puz/filters'; -import type { StormOpts, StormVm, StormRecap, StormPrefs, StormData } from './interfaces'; +import type { PuzCtrl, Run } from 'lib/puz/interfaces'; +import { makeCgOpts } from 'lib/puz/run'; +import sign from 'lib/puz/sign'; +import { getNow, puzzlePov, sound } from 'lib/puz/util'; import { storage } from 'lib/storage'; -import { pubsub } from 'lib/pubsub'; -import type { WithGround } from 'lib/game/ground'; import { toggleZenMode } from 'lib/view/zen'; +import config from './config'; +import type { StormOpts, StormVm, StormRecap, StormPrefs, StormData } from './interfaces'; +import * as xhr from './xhr'; + export default class StormCtrl implements PuzCtrl { private data: StormData; private redraw: () => void; diff --git a/ui/storm/src/storm.ts b/ui/storm/src/storm.ts index ecafdf0bbe2..2c4eb9eda86 100644 --- a/ui/storm/src/storm.ts +++ b/ui/storm/src/storm.ts @@ -1,5 +1,7 @@ import { attributesModule, classModule, init, type VNode } from 'snabbdom'; + import menuHover from 'lib/menuHover'; + import StormCtrl from './ctrl'; import type { StormOpts } from './interfaces'; diff --git a/ui/storm/src/view/end.ts b/ui/storm/src/view/end.ts index b135031f6b4..f1fc37e97f4 100644 --- a/ui/storm/src/view/end.ts +++ b/ui/storm/src/view/end.ts @@ -1,9 +1,10 @@ -import type StormCtrl from '../ctrl'; +import { numberSpread } from 'lib/i18n'; import { getNow } from 'lib/puz/util'; import renderHistory from 'lib/puz/view/history'; -import { numberSpread } from 'lib/i18n'; import { onInsert, type LooseVNodes, hl } from 'lib/view'; +import type StormCtrl from '../ctrl'; + const renderEnd = (ctrl: StormCtrl): LooseVNodes => [renderSummary(ctrl), renderHistory(ctrl)]; const newHighI18n = { diff --git a/ui/storm/src/view/main.ts b/ui/storm/src/view/main.ts index 438334f0b4d..d6dd77b485d 100644 --- a/ui/storm/src/view/main.ts +++ b/ui/storm/src/view/main.ts @@ -1,16 +1,18 @@ -import config from '../config'; -import renderClock from 'lib/puz/view/clock'; -import renderEnd from './end'; -import type StormCtrl from '../ctrl'; -import type { VNode } from 'snabbdom'; -import { makeCgOpts, povMessage } from 'lib/puz/run'; -import { makeConfig as makeCgConfig } from 'lib/puz/view/chessground'; -import { getNow } from 'lib/puz/util'; -import { playModifiers, renderCombo } from 'lib/puz/view/util'; -import * as licon from 'lib/licon'; -import { onInsert, hl } from 'lib/view'; import { Chessground as makeChessground } from '@lichess-org/chessground'; +import type { VNode } from 'snabbdom'; + +import * as licon from 'lib/licon'; import { pubsub } from 'lib/pubsub'; +import { makeCgOpts, povMessage } from 'lib/puz/run'; +import { getNow } from 'lib/puz/util'; +import { makeConfig as makeCgConfig } from 'lib/puz/view/chessground'; +import renderClock from 'lib/puz/view/clock'; +import { playModifiers, renderCombo } from 'lib/puz/view/util'; +import { onInsert, hl } from 'lib/view'; + +import config from '../config'; +import type StormCtrl from '../ctrl'; +import renderEnd from './end'; export default function (ctrl: StormCtrl): VNode { if (ctrl.vm.dupTab) return renderReload(i18n.storm.thisRunWasOpenedInAnotherTab); diff --git a/ui/storm/src/xhr.ts b/ui/storm/src/xhr.ts index d328c33ca44..c2794151a3c 100644 --- a/ui/storm/src/xhr.ts +++ b/ui/storm/src/xhr.ts @@ -1,4 +1,5 @@ import { json as xhrJson, form as xhrForm } from 'lib/xhr'; + import type { RunResponse, StormRecap } from './interfaces'; export function record(run: StormRecap): Promise { diff --git a/ui/swiss/src/ctrl.ts b/ui/swiss/src/ctrl.ts index c0270fdfd17..b0588a4012f 100644 --- a/ui/swiss/src/ctrl.ts +++ b/ui/swiss/src/ctrl.ts @@ -1,9 +1,10 @@ +import { throttlePromiseDelay } from 'lib/async'; +import { redirectFirst } from 'lib/tournament'; +import { maxPerPage, myPage, pagerData } from 'lib/view/pagination'; + +import type { SwissData, SwissOpts, Pages, Standing, Player } from './interfaces'; import { makeSocket, type SwissSocket } from './socket'; import xhr from './xhr'; -import { throttlePromiseDelay } from 'lib/async'; -import type { SwissData, SwissOpts, Pages, Standing, Player } from './interfaces'; -import { maxPerPage, myPage, pagerData } from 'lib/view/pagination'; -import { redirectFirst } from 'lib/tournament'; export default class SwissCtrl { data: SwissData; diff --git a/ui/swiss/src/socket.ts b/ui/swiss/src/socket.ts index a6c161dde46..fb4047632e3 100644 --- a/ui/swiss/src/socket.ts +++ b/ui/swiss/src/socket.ts @@ -1,6 +1,7 @@ -import type SwissCtrl from './ctrl'; import { redirectFirst } from 'lib/tournament'; +import type SwissCtrl from './ctrl'; + export interface SwissSocket { send: SocketSend; receive(tpe: string, data: any): void; diff --git a/ui/swiss/src/swiss.ts b/ui/swiss/src/swiss.ts index a2d23acff0b..7ca83998bba 100644 --- a/ui/swiss/src/swiss.ts +++ b/ui/swiss/src/swiss.ts @@ -1,8 +1,10 @@ import { init, type VNode, classModule, attributesModule } from 'snabbdom'; -import type { SwissOpts } from './interfaces'; -import SwissCtrl from './ctrl'; + import { wsConnect } from 'lib/socket'; +import SwissCtrl from './ctrl'; +import type { SwissOpts } from './interfaces'; + const patch = init([classModule, attributesModule]); import view from './view/main'; diff --git a/ui/swiss/src/view/boards.ts b/ui/swiss/src/view/boards.ts index e198f39a5de..ad2d4df6705 100644 --- a/ui/swiss/src/view/boards.ts +++ b/ui/swiss/src/view/boards.ts @@ -1,7 +1,9 @@ -import type { Board, SwissOpts } from '../interfaces'; -import { renderClock } from 'lib/view'; -import { h, type VNode } from 'snabbdom'; import { opposite } from '@lichess-org/chessground/util'; +import { h, type VNode } from 'snabbdom'; + +import { renderClock } from 'lib/view'; + +import type { Board, SwissOpts } from '../interfaces'; import { player as renderPlayer } from './util'; export function many(boards: Board[], opts: SwissOpts): VNode { diff --git a/ui/swiss/src/view/header.ts b/ui/swiss/src/view/header.ts index b59e9108081..e04da3ded8e 100644 --- a/ui/swiss/src/view/header.ts +++ b/ui/swiss/src/view/header.ts @@ -1,8 +1,10 @@ import { h, type Hooks, type VNode } from 'snabbdom'; + +import { setClockWidget } from 'lib/game/clock/clockWidget'; import * as licon from 'lib/licon'; import { dataIcon, onInsert } from 'lib/view'; + import type SwissCtrl from '../ctrl'; -import { setClockWidget } from 'lib/game/clock/clockWidget'; const startClock = (time: number): Hooks => ({ insert: (vnode: VNode) => setClockWidget(vnode.elm as HTMLElement, { time }), diff --git a/ui/swiss/src/view/main.ts b/ui/swiss/src/view/main.ts index 54f1d3e1185..20df9ba913d 100644 --- a/ui/swiss/src/view/main.ts +++ b/ui/swiss/src/view/main.ts @@ -1,4 +1,9 @@ +import flatpickr from 'flatpickr'; + +import standaloneChat from 'lib/chat/standalone'; +import { use24h } from 'lib/i18n'; import * as licon from 'lib/licon'; +import { once } from 'lib/storage'; import { spinnerVdom, initMiniGames, @@ -10,20 +15,17 @@ import { type LooseVNodes, hl, } from 'lib/view'; +import { renderPager, searchButton, searchInput } from 'lib/view/pagination'; import { numberRow } from 'lib/view/util'; +import { watchers } from 'lib/view/watchers'; + import type SwissCtrl from '../ctrl'; import type { SwissData } from '../interfaces'; -import header from './header'; -import standing from './standing'; import * as boards from './boards'; -import podium from './podium'; +import header from './header'; import playerInfo from './playerInfo'; -import flatpickr from 'flatpickr'; -import { use24h } from 'lib/i18n'; -import { once } from 'lib/storage'; -import { watchers } from 'lib/view/watchers'; -import standaloneChat from 'lib/chat/standalone'; -import { renderPager, searchButton, searchInput } from 'lib/view/pagination'; +import podium from './podium'; +import standing from './standing'; export default function (ctrl: SwissCtrl) { const d = ctrl.data; diff --git a/ui/swiss/src/view/playerInfo.ts b/ui/swiss/src/view/playerInfo.ts index 0ef03fb4966..26b96edbed8 100644 --- a/ui/swiss/src/view/playerInfo.ts +++ b/ui/swiss/src/view/playerInfo.ts @@ -1,12 +1,14 @@ import type { VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; import { spinnerVdom, bind, dataIcon, hl } from 'lib/view'; +import { fullName } from 'lib/view/userLink'; import { numberRow } from 'lib/view/util'; -import { player as renderPlayer } from './util'; + +import type SwissCtrl from '../ctrl'; import type { Pairing } from '../interfaces'; import { isOutcome } from '../util'; -import type SwissCtrl from '../ctrl'; -import { fullName } from 'lib/view/userLink'; +import { player as renderPlayer } from './util'; export default function (ctrl: SwissCtrl): VNode | undefined { if (!ctrl.playerInfoId) return; diff --git a/ui/swiss/src/view/podium.ts b/ui/swiss/src/view/podium.ts index 97bb579f958..3fc441b99e0 100644 --- a/ui/swiss/src/view/podium.ts +++ b/ui/swiss/src/view/podium.ts @@ -1,8 +1,10 @@ import { h, type VNode } from 'snabbdom'; + +import { defined } from 'lib'; +import { userLink } from 'lib/view/userLink'; + import type SwissCtrl from '../ctrl'; import type { PodiumPlayer } from '../interfaces'; -import { userLink } from 'lib/view/userLink'; -import { defined } from 'lib'; const podiumStats = (p: PodiumPlayer, ctrl: SwissCtrl): VNode => h('table.stats', [ diff --git a/ui/swiss/src/view/standing.ts b/ui/swiss/src/view/standing.ts index 9e327c3eac7..7ad06ee94df 100644 --- a/ui/swiss/src/view/standing.ts +++ b/ui/swiss/src/view/standing.ts @@ -1,9 +1,11 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; import { bind, type MaybeVNodes, onInsert } from 'lib/view'; + import type SwissCtrl from '../ctrl'; -import { player as renderPlayer } from './util'; import type { Player } from '../interfaces'; +import { player as renderPlayer } from './util'; function playerTr(ctrl: SwissCtrl, player: Player) { const userId = player.user.id; diff --git a/ui/swiss/src/view/util.ts b/ui/swiss/src/view/util.ts index 7c64f31ed8d..37848fa115a 100644 --- a/ui/swiss/src/view/util.ts +++ b/ui/swiss/src/view/util.ts @@ -1,7 +1,9 @@ import { h } from 'snabbdom'; -import type { BasePlayer } from '../interfaces'; + import { fullName, userLine, userRating } from 'lib/view/userLink'; +import type { BasePlayer } from '../interfaces'; + export function player(p: BasePlayer, asLink: boolean, withRating: boolean) { return h( 'a.ulpt.user-link.online' + (((p.user.title || '') + p.user.name).length > 15 ? '.long' : ''), diff --git a/ui/swiss/src/xhr.ts b/ui/swiss/src/xhr.ts index 5ee64f6150d..21512c094ed 100644 --- a/ui/swiss/src/xhr.ts +++ b/ui/swiss/src/xhr.ts @@ -1,8 +1,9 @@ import { throttlePromiseDelay } from 'lib/async'; import { json, form } from 'lib/xhr'; + import type SwissCtrl from './ctrl'; -import { isOutcome } from './util'; import type { Sheet } from './interfaces'; +import { isOutcome } from './util'; // when the tournament no longer exists const onFail = () => site.reload(); diff --git a/ui/tournament/src/ctrl.ts b/ui/tournament/src/ctrl.ts index 91bd9ab52ec..97808121f8f 100644 --- a/ui/tournament/src/ctrl.ts +++ b/ui/tournament/src/ctrl.ts @@ -1,6 +1,10 @@ -import { type TournamentSocket, makeSocket } from './socket'; -import * as xhr from './xhr'; -import * as sound from './sound'; +import type { Prop } from 'lib'; +import { pubsub } from 'lib/pubsub'; +import { storedMapAsProp } from 'lib/storage'; +import { redirectFirst } from 'lib/tournament'; +import { alerts, prompt } from 'lib/view'; +import { maxPerPage, myPage, pagerData } from 'lib/view/pagination'; + import type { TournamentData, TournamentOpts, @@ -10,12 +14,9 @@ import type { Standing, Player, } from './interfaces'; -import { storedMapAsProp } from 'lib/storage'; -import { pubsub } from 'lib/pubsub'; -import { alerts, prompt } from 'lib/view'; -import type { Prop } from 'lib'; -import { maxPerPage, myPage, pagerData } from 'lib/view/pagination'; -import { redirectFirst } from 'lib/tournament'; +import { type TournamentSocket, makeSocket } from './socket'; +import * as sound from './sound'; +import * as xhr from './xhr'; interface CtrlTeamInfo { requested?: string; diff --git a/ui/tournament/src/socket.ts b/ui/tournament/src/socket.ts index 16f43bd8513..faf1233b609 100644 --- a/ui/tournament/src/socket.ts +++ b/ui/tournament/src/socket.ts @@ -1,6 +1,7 @@ -import type TournamentController from './ctrl'; import { redirectFirst } from 'lib/tournament'; +import type TournamentController from './ctrl'; + export interface TournamentSocket { send: SocketSend; receive(type: string, data: any): void; diff --git a/ui/tournament/src/sound.ts b/ui/tournament/src/sound.ts index 4fd0bda8bdd..8ca77dd17be 100644 --- a/ui/tournament/src/sound.ts +++ b/ui/tournament/src/sound.ts @@ -1,7 +1,8 @@ import notify from 'lib/notification'; -import type { TournamentData } from './interfaces'; import { once } from 'lib/storage'; +import type { TournamentData } from './interfaces'; + let countDownTimeout: number | undefined; function doCountDown(targetTime: number) { diff --git a/ui/tournament/src/tournament.calendar.ts b/ui/tournament/src/tournament.calendar.ts index e5012a4c671..610e9770a9c 100644 --- a/ui/tournament/src/tournament.calendar.ts +++ b/ui/tournament/src/tournament.calendar.ts @@ -1,7 +1,7 @@ -import view from './view/calendarView'; - import { init, type VNode, classModule, attributesModule } from 'snabbdom'; + import type { Tournament } from './interfaces'; +import view from './view/calendarView'; const patch = init([classModule, attributesModule]); diff --git a/ui/tournament/src/tournament.schedule.ts b/ui/tournament/src/tournament.schedule.ts index dbf080bbe67..053432b0881 100644 --- a/ui/tournament/src/tournament.schedule.ts +++ b/ui/tournament/src/tournament.schedule.ts @@ -1,9 +1,10 @@ -import view from './view/scheduleView'; - import { init, type VNode, classModule, attributesModule } from 'snabbdom'; -import type { Tournament } from './interfaces'; -import { wsConnect } from 'lib/socket'; + import { pubsub } from 'lib/pubsub'; +import { wsConnect } from 'lib/socket'; + +import type { Tournament } from './interfaces'; +import view from './view/scheduleView'; const patch = init([classModule, attributesModule]); diff --git a/ui/tournament/src/tournament.ts b/ui/tournament/src/tournament.ts index 0f4644a8d8d..595cb1db907 100644 --- a/ui/tournament/src/tournament.ts +++ b/ui/tournament/src/tournament.ts @@ -1,7 +1,9 @@ import { init, classModule, attributesModule } from 'snabbdom'; -import type { TournamentOpts } from './interfaces'; + import { wsConnect } from 'lib/socket'; +import type { TournamentOpts } from './interfaces'; + const patch = init([classModule, attributesModule]); import makeCtrl from './ctrl'; diff --git a/ui/tournament/src/view/arena.ts b/ui/tournament/src/view/arena.ts index 841fae2d100..f86cea0f1a3 100644 --- a/ui/tournament/src/view/arena.ts +++ b/ui/tournament/src/view/arena.ts @@ -1,15 +1,17 @@ import { h, type VNode } from 'snabbdom'; + +import { defined } from 'lib'; import * as licon from 'lib/licon'; import { bind, dataIcon, type MaybeVNodes } from 'lib/view'; -import { numberRow } from 'lib/view/util'; -import type TournamentController from '../ctrl'; -import { player as renderPlayer } from './util'; -import { teamName } from './battle'; -import type { PodiumPlayer, StandingPlayer } from '../interfaces'; -import { joinWithdraw } from './button'; -import { userLink } from 'lib/view/userLink'; -import { defined } from 'lib'; import { renderPager, searchButton, searchInput } from 'lib/view/pagination'; +import { userLink } from 'lib/view/userLink'; +import { numberRow } from 'lib/view/util'; + +import type TournamentController from '../ctrl'; +import type { PodiumPlayer, StandingPlayer } from '../interfaces'; +import { teamName } from './battle'; +import { joinWithdraw } from './button'; +import { player as renderPlayer } from './util'; const renderScoreString = (scoreString: string, streakable: boolean) => { const values = scoreString.split('').map(s => parseInt(s)); diff --git a/ui/tournament/src/view/battle.ts b/ui/tournament/src/view/battle.ts index 60e1dd7623d..b9b073f5c82 100644 --- a/ui/tournament/src/view/battle.ts +++ b/ui/tournament/src/view/battle.ts @@ -1,8 +1,10 @@ -import type TournamentController from '../ctrl'; +import { h, type VNode } from 'snabbdom'; + import { shuffle } from 'lib/algo'; import { bind, type MaybeVNode, snabDialog } from 'lib/view'; import { fullName, userFlair } from 'lib/view/userLink'; -import { h, type VNode } from 'snabbdom'; + +import type TournamentController from '../ctrl'; import type { TeamBattle, RankedTeam, LightTeam } from '../interfaces'; export function joinWithTeamSelector(ctrl: TournamentController) { diff --git a/ui/tournament/src/view/button.ts b/ui/tournament/src/view/button.ts index 9ec2d5fe7ac..af57d82b743 100644 --- a/ui/tournament/src/view/button.ts +++ b/ui/tournament/src/view/button.ts @@ -1,6 +1,8 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; import { spinnerVdom, bind, dataIcon } from 'lib/view'; + import type TournamentController from '../ctrl'; function orJoinSpinner(ctrl: TournamentController, f: () => VNode): VNode { diff --git a/ui/tournament/src/view/calendarView.ts b/ui/tournament/src/view/calendarView.ts index 5293c747dbb..6c27c580660 100644 --- a/ui/tournament/src/view/calendarView.ts +++ b/ui/tournament/src/view/calendarView.ts @@ -1,14 +1,16 @@ -import { type Classes, h, type VNode } from 'snabbdom'; -import eachDayOfInterval from 'date-fns/eachDayOfInterval'; import addDays from 'date-fns/addDays'; +import areIntervalsOverlapping from 'date-fns/areIntervalsOverlapping'; +import eachDayOfInterval from 'date-fns/eachDayOfInterval'; +import format from 'date-fns/format'; import getHours from 'date-fns/getHours'; import getMinutes from 'date-fns/getMinutes'; -import areIntervalsOverlapping from 'date-fns/areIntervalsOverlapping'; -import format from 'date-fns/format'; +import { type Classes, h, type VNode } from 'snabbdom'; + +import perfIcons from 'lib/game/perfIcons'; +import * as licon from 'lib/licon'; + import type { Tournament } from '../interfaces'; import type { Ctrl, Lanes } from '../tournament.calendar'; -import * as licon from 'lib/licon'; -import perfIcons from 'lib/game/perfIcons'; function tournamentClass(tour: Tournament, day: Date): Classes { const classes = { diff --git a/ui/tournament/src/view/created.ts b/ui/tournament/src/view/created.ts index beb7d25d8d1..c1d3b1de8d0 100644 --- a/ui/tournament/src/view/created.ts +++ b/ui/tournament/src/view/created.ts @@ -1,10 +1,12 @@ import { h, type VNode } from 'snabbdom'; + import { type MaybeVNodes, onInsert } from 'lib/view'; + import type TournamentController from '../ctrl'; import { controls, standing } from './arena'; import { teamStanding } from './battle'; -import teamInfo from './teamInfo'; import header from './header'; +import teamInfo from './teamInfo'; export const name = 'created'; diff --git a/ui/tournament/src/view/finished.ts b/ui/tournament/src/view/finished.ts index c977abcdbb1..f39380a5c58 100644 --- a/ui/tournament/src/view/finished.ts +++ b/ui/tournament/src/view/finished.ts @@ -1,5 +1,10 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; +import { once } from 'lib/storage'; +import { type MaybeVNodes } from 'lib/view'; +import { numberRow } from 'lib/view/util'; + import type TournamentController from '../ctrl'; import type { TournamentData } from '../interfaces'; import { controls, standing, podium } from './arena'; @@ -7,9 +12,6 @@ import { teamStanding } from './battle'; import header from './header'; import playerInfo from './playerInfo'; import teamInfo from './teamInfo'; -import { numberRow } from 'lib/view/util'; -import { type MaybeVNodes } from 'lib/view'; -import { once } from 'lib/storage'; function confetti(data: TournamentData): VNode | undefined { if (data.me && data.isRecentlyFinished && once('tournament.end.canvas.' + data.id)) diff --git a/ui/tournament/src/view/header.ts b/ui/tournament/src/view/header.ts index d4c7b27c5d0..8d28e8a4d31 100644 --- a/ui/tournament/src/view/header.ts +++ b/ui/tournament/src/view/header.ts @@ -1,12 +1,14 @@ import { h, type Hooks, type VNode } from 'snabbdom'; + +import { setClockWidget } from 'lib/game/clock/clockWidget'; +import perfIcons from 'lib/game/perfIcons'; import * as licon from 'lib/licon'; import { dataIcon } from 'lib/view'; -import type TournamentController from '../ctrl'; -import perfIcons from 'lib/game/perfIcons'; -import type { TournamentData } from '../interfaces'; -import { setClockWidget } from 'lib/game/clock/clockWidget'; import { userTitle } from 'lib/view/userLink'; +import type TournamentController from '../ctrl'; +import type { TournamentData } from '../interfaces'; + const startClock = (time: number): Hooks => ({ insert: vnode => setClockWidget(vnode.elm as HTMLElement, { time }), }); diff --git a/ui/tournament/src/view/main.ts b/ui/tournament/src/view/main.ts index abc1e2b43c2..9277bb69a96 100644 --- a/ui/tournament/src/view/main.ts +++ b/ui/tournament/src/view/main.ts @@ -1,12 +1,14 @@ import { h, type VNode } from 'snabbdom'; -import { onInsert, type MaybeVNodes } from 'lib/view'; -import * as created from './created'; -import * as started from './started'; -import * as finished from './finished'; -import { joinWithTeamSelector } from './battle'; -import type TournamentController from '../ctrl'; -import { watchers } from 'lib/view/watchers'; + import standaloneChat from 'lib/chat/standalone'; +import { onInsert, type MaybeVNodes } from 'lib/view'; +import { watchers } from 'lib/view/watchers'; + +import type TournamentController from '../ctrl'; +import { joinWithTeamSelector } from './battle'; +import * as created from './created'; +import * as finished from './finished'; +import * as started from './started'; export default function (ctrl: TournamentController) { let handler: { diff --git a/ui/tournament/src/view/playerInfo.ts b/ui/tournament/src/view/playerInfo.ts index 8f9cf8d5892..be72939ea41 100644 --- a/ui/tournament/src/view/playerInfo.ts +++ b/ui/tournament/src/view/playerInfo.ts @@ -1,12 +1,13 @@ +import { status } from 'lib/game'; import * as licon from 'lib/licon'; import { spinnerVdom as spinner, type VNode, bind, dataIcon, hl } from 'lib/view'; -import { player as renderPlayer } from './util'; import { fullName } from 'lib/view/userLink'; import { numberRow } from 'lib/view/util'; -import { teamName } from './battle'; -import { status } from 'lib/game'; + import type TournamentController from '../ctrl'; import type { Player } from '../interfaces'; +import { teamName } from './battle'; +import { player as renderPlayer } from './util'; const playerTitle = (player: Player, tourId: string) => hl('h2', [ diff --git a/ui/tournament/src/view/scheduleView.ts b/ui/tournament/src/view/scheduleView.ts index fe333f5de31..5e6ad46b6fb 100644 --- a/ui/tournament/src/view/scheduleView.ts +++ b/ui/tournament/src/view/scheduleView.ts @@ -1,9 +1,11 @@ +import dragscroll from 'dragscroll'; import { type Classes, h, type VNode } from 'snabbdom'; -import * as licon from 'lib/licon'; + import perfIcons from 'lib/game/perfIcons'; +import * as licon from 'lib/licon'; + import type { Tournament, Clock } from '../interfaces'; import type { Ctrl, Lane } from '../tournament.schedule'; -import dragscroll from 'dragscroll'; const scale = 8; let now: number, startTime: number, stopTime: number; diff --git a/ui/tournament/src/view/started.ts b/ui/tournament/src/view/started.ts index 07ae452e6a3..8e98b10496f 100644 --- a/ui/tournament/src/view/started.ts +++ b/ui/tournament/src/view/started.ts @@ -1,12 +1,14 @@ import { h, type VNode } from 'snabbdom'; + +import type { MaybeVNodes } from 'lib/view'; + +import type TournamentController from '../ctrl'; import { controls, standing } from './arena'; import { teamStanding } from './battle'; import header from './header'; -import tourTable from './table'; import playerInfo from './playerInfo'; +import tourTable from './table'; import teamInfo from './teamInfo'; -import type TournamentController from '../ctrl'; -import type { MaybeVNodes } from 'lib/view'; function joinTheGame(gameId: string) { return h('a.tour__ur-playing.button.is.is-after', { attrs: { href: '/' + gameId } }, [ diff --git a/ui/tournament/src/view/table.ts b/ui/tournament/src/view/table.ts index a635c39a5a3..70520617630 100644 --- a/ui/tournament/src/view/table.ts +++ b/ui/tournament/src/view/table.ts @@ -1,10 +1,12 @@ import { opposite } from '@lichess-org/chessground/util'; + import * as licon from 'lib/licon'; import { type VNode, bind, onInsert, hl, initMiniGames } from 'lib/view'; -import { player as renderPlayer } from './util'; + +import type TournamentController from '../ctrl'; import type { Duel, DuelPlayer, FeaturedGame, TournamentOpts } from '../interfaces'; import { teamName } from './battle'; -import type TournamentController from '../ctrl'; +import { player as renderPlayer } from './util'; function featuredPlayer(game: FeaturedGame, color: Color, opts: TournamentOpts) { const player = game[color]; diff --git a/ui/tournament/src/view/teamInfo.ts b/ui/tournament/src/view/teamInfo.ts index 9d16711b114..7dc01050977 100644 --- a/ui/tournament/src/view/teamInfo.ts +++ b/ui/tournament/src/view/teamInfo.ts @@ -1,10 +1,12 @@ import { h, type VNode } from 'snabbdom'; + import * as licon from 'lib/licon'; import { spinnerVdom, bind, dataIcon } from 'lib/view'; import { numberRow } from 'lib/view/util'; + import type TournamentController from '../ctrl'; -import { player as renderPlayer } from './util'; import { teamName } from './battle'; +import { player as renderPlayer } from './util'; export default function (ctrl: TournamentController): VNode | undefined { const battle = ctrl.data.teamBattle, diff --git a/ui/tournament/src/view/util.ts b/ui/tournament/src/view/util.ts index c3b11b4b5d6..6d9803b9713 100644 --- a/ui/tournament/src/view/util.ts +++ b/ui/tournament/src/view/util.ts @@ -1,7 +1,9 @@ import { h } from 'snabbdom'; + import * as licon from 'lib/licon'; import { dataIcon } from 'lib/view'; import { fullName, userLine, userRating } from 'lib/view/userLink'; + import type { SimplePlayer } from '../interfaces'; export const player = ( diff --git a/ui/tournament/src/xhr.ts b/ui/tournament/src/xhr.ts index 41102269f15..93796c5de8f 100644 --- a/ui/tournament/src/xhr.ts +++ b/ui/tournament/src/xhr.ts @@ -1,7 +1,8 @@ import { finallyDelay, throttlePromiseDelay } from 'lib/async'; -import * as xhr from 'lib/xhr'; -import type TournamentController from './ctrl'; import { alert } from 'lib/view'; +import * as xhr from 'lib/xhr'; + +import type TournamentController from './ctrl'; // when the tournament no longer exists // randomly delay reloads in case of massive tournament to avoid ddos diff --git a/ui/user/src/user.account.ts b/ui/user/src/user.account.ts index 78fbc64194f..e781e230a17 100644 --- a/ui/user/src/user.account.ts +++ b/ui/user/src/user.account.ts @@ -1,8 +1,9 @@ +import flairPickerLoader from 'bits/flairPicker'; + import * as licon from 'lib/licon'; -import * as xhr from 'lib/xhr'; import { storage } from 'lib/storage'; import { addPasswordVisibilityToggleListener, confirm } from 'lib/view'; -import flairPickerLoader from 'bits/flairPicker'; +import * as xhr from 'lib/xhr'; site.load.then(() => { $('.emoji-details').each(function (this: HTMLElement) { diff --git a/ui/user/src/user.ts b/ui/user/src/user.ts index 8355d0a12ac..0f5855f0f00 100644 --- a/ui/user/src/user.ts +++ b/ui/user/src/user.ts @@ -1,8 +1,8 @@ -import * as xhr from 'lib/xhr'; -import * as licon from 'lib/licon'; -import { alert, makeLinkPopups } from 'lib/view'; -import { pubsub } from 'lib/pubsub'; import { myUserId } from 'lib'; +import * as licon from 'lib/licon'; +import { pubsub } from 'lib/pubsub'; +import { alert, makeLinkPopups } from 'lib/view'; +import * as xhr from 'lib/xhr'; const gamesAngle = document.querySelector('.games'); if (gamesAngle) gamesAngle.style.visibility = 'hidden'; // FOUC diff --git a/ui/voice/makeGrammar.mts b/ui/voice/makeGrammar.mts index 2de5e2f902a..259db6b8b4a 100644 --- a/ui/voice/makeGrammar.mts +++ b/ui/voice/makeGrammar.mts @@ -1,7 +1,8 @@ -import * as ps from 'node:process'; import * as fs from 'node:fs'; +import * as ps from 'node:process'; import { Readable } from 'node:stream'; import { finished } from 'node:stream/promises'; + import { findTransforms } from './src/util'; let builder: Builder; diff --git a/ui/voice/src/interfaces.ts b/ui/voice/src/interfaces.ts index b379c4d3c8b..5714a863d57 100644 --- a/ui/voice/src/interfaces.ts +++ b/ui/voice/src/interfaces.ts @@ -1,6 +1,7 @@ -import type { Prop, Toggle } from 'lib'; import type { VNode } from 'snabbdom'; +import type { Prop, Toggle } from 'lib'; + export type MsgType = 'full' | 'partial' | 'status' | 'error' | 'stop' | 'start'; export type Listener = (msgText: string, msgType: MsgType) => void; diff --git a/ui/voice/src/mic.ts b/ui/voice/src/mic.ts index 4f5c6e38385..fa595ecdc15 100644 --- a/ui/voice/src/mic.ts +++ b/ui/voice/src/mic.ts @@ -1,7 +1,8 @@ import { objectStorage } from 'lib/objectStorage'; -import { Switch, type Selectable } from './switch'; import { storedStringProp } from 'lib/storage'; + import type { VoskModule, Listener, Microphone, MsgType } from './interfaces'; +import { Switch, type Selectable } from './switch'; export class Mic implements Microphone { recId = 'default'; diff --git a/ui/voice/src/move/interfaces.ts b/ui/voice/src/move/interfaces.ts index 043bd19b90d..9ccd7747d74 100644 --- a/ui/voice/src/move/interfaces.ts +++ b/ui/voice/src/move/interfaces.ts @@ -1,5 +1,6 @@ -import type { PromotionCtrl } from 'lib/game/promotion'; import type { MoveUpdate } from 'lib/game/moveRootCtrl'; +import type { PromotionCtrl } from 'lib/game/promotion'; + import type { VoiceModule } from '../interfaces'; export interface VoiceMove extends VoiceModule { diff --git a/ui/voice/src/move/view.ts b/ui/voice/src/move/view.ts index 9bcb8150102..4ee09650b81 100644 --- a/ui/voice/src/move/view.ts +++ b/ui/voice/src/move/view.ts @@ -1,4 +1,5 @@ import { h, type VNode } from 'snabbdom'; + import type { Prop } from 'lib'; import { bind, rangeConfig } from 'lib/view'; diff --git a/ui/voice/src/move/voice.move.ts b/ui/voice/src/move/voice.move.ts index d681cc4d019..ee5ae7754c2 100644 --- a/ui/voice/src/move/voice.move.ts +++ b/ui/voice/src/move/voice.move.ts @@ -1,13 +1,12 @@ -import { jsonSimple } from 'lib/xhr'; -import { storedIntProp, storedBooleanPropWithEffect, storedIntPropWithEffect } from 'lib/storage'; -import * as licon from 'lib/licon'; -import { readFen, destsToUcis, square, type Board } from 'lib/game'; import { charToRole } from 'chessops'; -import { type PromotionCtrl, promote } from 'lib/game/promotion'; + +import { readFen, destsToUcis, square, type Board } from 'lib/game'; import type { MoveRootCtrl, MoveUpdate } from 'lib/game/moveRootCtrl'; -import type { VoiceMove, VoiceCtrl, Entry, Match } from '../voice'; -import { coloredArrows, numberedArrows, brushes } from './arrows'; -import { settingNodes } from './view'; +import { type PromotionCtrl, promote } from 'lib/game/promotion'; +import * as licon from 'lib/licon'; +import { storedIntProp, storedBooleanPropWithEffect, storedIntPropWithEffect } from 'lib/storage'; +import { jsonSimple } from 'lib/xhr'; + import type { MsgType } from '../interfaces'; import { spread, @@ -24,6 +23,9 @@ import { type Transform, type SparseMap, } from '../util'; +import type { VoiceMove, VoiceCtrl, Entry, Match } from '../voice'; +import { coloredArrows, numberedArrows, brushes } from './arrows'; +import { settingNodes } from './view'; export function initModule({ root, diff --git a/ui/voice/src/util.ts b/ui/voice/src/util.ts index 274f49de367..b2199f33ad8 100644 --- a/ui/voice/src/util.ts +++ b/ui/voice/src/util.ts @@ -1,6 +1,7 @@ -import { squareDist, type Board } from 'lib/game'; import { charToRole } from 'chessops'; +import { squareDist, type Board } from 'lib/game'; + const mode = { del: true, sub: 2 }; export function findTransforms( diff --git a/ui/voice/src/view.ts b/ui/voice/src/view.ts index e7999e16158..14a5e51fb15 100644 --- a/ui/voice/src/view.ts +++ b/ui/voice/src/view.ts @@ -1,8 +1,9 @@ +import { onClickAway } from 'lib'; import * as licon from 'lib/licon'; import { onInsert, bind, hl, type VNode, snabDialog, type Dialog } from 'lib/view'; import { cmnToggleProp } from 'lib/view/cmn-toggle'; import { jsonSimple } from 'lib/xhr'; -import { onClickAway } from 'lib'; + import type { Entry, VoiceCtrl, MsgType } from './interfaces'; import { supportedLangs } from './voice'; diff --git a/ui/voice/src/voice.ts b/ui/voice/src/voice.ts index c7ffbaf80ee..03bae416222 100644 --- a/ui/voice/src/voice.ts +++ b/ui/voice/src/voice.ts @@ -1,9 +1,5 @@ import { propWithEffect, toggle as commonToggle } from 'lib'; import type { MoveRootCtrl, MoveUpdate } from 'lib/game/moveRootCtrl'; -import type { VoiceCtrl, VoiceModule } from './interfaces'; -import type { VoiceMove } from './move/interfaces'; -import { Mic } from './mic'; -import { flash } from './view'; import { once, storedBooleanProp, @@ -11,6 +7,11 @@ import { storedBooleanPropWithEffect, } from 'lib/storage'; +import type { VoiceCtrl, VoiceModule } from './interfaces'; +import { Mic } from './mic'; +import type { VoiceMove } from './move/interfaces'; +import { flash } from './view'; + export * from './interfaces'; export * from './move/interfaces'; export { renderVoiceBar } from './view'; diff --git a/ui/voice/src/voice.vosk.ts b/ui/voice/src/voice.vosk.ts index 41aa8dd6b43..5a9dd782c2e 100644 --- a/ui/voice/src/voice.vosk.ts +++ b/ui/voice/src/voice.vosk.ts @@ -5,6 +5,7 @@ import { type ServerMessagePartialResult, createVoskClient, } from '@lichess-org/vosk-browser'; + import type { RecognizerOpts, VoskModule } from './interfaces'; import { type Selectable, Switch } from './switch';