diff --git a/modules/local/src/main/LocalRepo.scala b/modules/local/src/main/LocalRepo.scala index 314622ea2ee9f..bd7bcc7305115 100644 --- a/modules/local/src/main/LocalRepo.scala +++ b/modules/local/src/main/LocalRepo.scala @@ -2,7 +2,7 @@ package lila.local import reactivemongo.api.Cursor import reactivemongo.api.bson.* -import lila.common.Json.opaqueFormat +import lila.common.Json.given import lila.db.JSON import play.api.libs.json.* diff --git a/ui/.build/src/esbuild.ts b/ui/.build/src/esbuild.ts index e02a03d5944fe..3fdc2dfb59478 100644 --- a/ui/.build/src/esbuild.ts +++ b/ui/.build/src/esbuild.ts @@ -54,6 +54,17 @@ export async function stopEsbuildWatch(): Promise { } const plugins = [ + // { + // name: '_html', // experimental + // setup(build: es.PluginBuild) { + // build.onLoad({ filter: /\.ts$/ }, async (args: es.OnLoadArgs) => ({ + // loader: 'ts', + // contents: (await fs.promises.readFile(args.path, 'utf8')).replace(/_html`([\s\S]*?)`/g, (_, s) => + // env.prod ? `\`${s.replace(/\s+/g, ' ').replaceAll('> <', '><').trim()}\`` : `\`${s}\``, + // ), + // })); + // }, + // }, { name: 'onBundleDone', setup(build: es.PluginBuild) { diff --git a/ui/.build/src/parse.ts b/ui/.build/src/parse.ts index 60d47562d6c27..604d7fe8c19c3 100644 --- a/ui/.build/src/parse.ts +++ b/ui/.build/src/parse.ts @@ -50,16 +50,20 @@ export async function globArrays(globs: string[] | undefined, opts: fg.Options = } export async function folderSize(folder: string): Promise { - let totalSize = 0; + async function getSize(dir: string): Promise { + const entries = await fs.promises.readdir(dir, { withFileTypes: true }); - async function getSize(dir: string) { - for (const file of await fs.promises.readdir(dir, { withFileTypes: true })) { - if (file.isDirectory()) await getSize(path.join(dir, file.name)); - else if (file.isFile()) totalSize += (await fs.promises.stat(path.join(dir, file.name))).size; - } + const sizes = await Promise.all( + entries.map(async entry => { + const fullPath = path.join(dir, entry.name); + if (entry.isDirectory()) return getSize(fullPath); + if (entry.isFile()) return (await fs.promises.stat(fullPath)).size; + return 0; + }), + ); + return sizes.reduce((acc: number, size: number) => acc + size, 0); } - await getSize(folder); - return totalSize; + return getSize(folder); } export async function readable(file: string): Promise { diff --git a/ui/.build/src/tsc.ts b/ui/.build/src/tsc.ts index 8955489280fc8..39d98f7bdb8a9 100644 --- a/ui/.build/src/tsc.ts +++ b/ui/.build/src/tsc.ts @@ -112,7 +112,6 @@ async function splitConfig(cfgPath: string): Promise { co.lib = co.lib?.map((lib: string) => (lib.startsWith('lib.') ? lib.split('.')[1] : lib)); co.incremental = true; - config.compilerOptions = co; config.size = await folderSize(path.join(root, 'src')); config.include = config.include?.map((glob: string) => diff --git a/ui/@types/lichess/index.d.ts b/ui/@types/lichess/index.d.ts index 7c577d8f3be89..c2e8f841a70e0 100644 --- a/ui/@types/lichess/index.d.ts +++ b/ui/@types/lichess/index.d.ts @@ -296,3 +296,4 @@ declare const site: Site; declare const fipr: Fipr; declare const i18n: I18n; declare module 'tablesort'; +declare const _html: (s: TemplateStringsArray, ...k: any) => string; // file://./../../.build/src/esbuild.ts diff --git a/ui/bits/src/bits.polyglot.ts b/ui/bits/src/bits.polyglot.ts index 6a007b0b83a92..e49cd1f950551 100644 --- a/ui/bits/src/bits.polyglot.ts +++ b/ui/bits/src/bits.polyglot.ts @@ -46,7 +46,6 @@ async function makeBookPgn( if (filter && !filter(game)) continue; traverseTree(co.pgn.startingPosition(game.headers).unwrap(), game.moves, maxPly); } - // calc weights and collapse secondary maps into arrays for less memory overhead const posMap = new Map(); for (const [hash, map] of bigMap) { const moves = Array.from(map, ([uci, weight]) => ({ uci, weight })); @@ -127,16 +126,16 @@ async function* pgnFromBlob(blob: Blob, chunkSize: number, progress?: PgnProgres const textChunk = await chunk.text(); const crlfLast = textChunk.lastIndexOf('\r\n\r\n['); const lfLast = textChunk.lastIndexOf('\n\n['); - const gamesThisChunk = + const wholePgnsChunk = offset + chunk.size === totalSize || Math.max(crlfLast, lfLast) === -1 ? textChunk : textChunk.slice(0, Math.max(lfLast + 2, crlfLast + 4)); - const games = co.pgn.parsePgn(residual + gamesThisChunk).filter(game => { + const games = co.pgn.parsePgn(residual + wholePgnsChunk).filter(game => { const tag = game.headers.get('Variant'); return !tag || tag.toLowerCase() === 'standard'; }); for (const game of games) yield game; - residual = textChunk.slice(gamesThisChunk.length); + residual = textChunk.slice(wholePgnsChunk.length); offset += chunkSize; } }