revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s

revert style: clean up code with prettier and eslint
This commit is contained in:
remco committed 2026-07-12 21:02:03 +02:00
1 parent 27de078f54
commit e85e4d74ea
378 files changed
+20710 -22428

No files matched your search

+41 -41
View File
@@ -1,81 +1,81 @@
import { resolveGamedataFile } from "@/lib/services/import/core/asset-paths";
import { resolveGamedataFile } from '@/lib/services/import/core/asset-paths'
import {
readGamedataJson,
withGamedataLock,
writeGamedataJsonAtomic,
} from "@/lib/services/import/core/gamedata-json";
import { siteSettings } from "@/lib/services/site-settings";
} from '@/lib/services/import/core/gamedata-json'
import { siteSettings } from '@/lib/services/site-settings'
interface FdSet {
id: number;
[k: string]: unknown;
id: number
[k: string]: unknown
}
interface FdSetType {
type: string;
paletteId: number;
sets: FdSet[];
[k: string]: unknown;
type: string
paletteId: number
sets: FdSet[]
[k: string]: unknown
}
interface FdPalette {
id: number;
colors: unknown[];
id: number
colors: unknown[]
}
interface FigureDataFile {
palettes: FdPalette[];
setTypes: FdSetType[];
palettes: FdPalette[]
setTypes: FdSetType[]
}
let pathOverride: string | null = null;
let pathOverride: string | null = null
export function __setFigureDataPathForTests(p: string | null): void {
pathOverride = p;
pathOverride = p
}
export async function getFigureDataPath(): Promise<string> {
if (pathOverride) return pathOverride;
const url = await siteSettings.get("figuredata_url", "/nitro-assets/gamedata/FigureData.json");
return resolveGamedataFile(url ?? "/nitro-assets/gamedata/FigureData.json", "FigureData.json");
if (pathOverride) return pathOverride
const url = await siteSettings.get('figuredata_url', '/nitro-assets/gamedata/FigureData.json')
return resolveGamedataFile(url ?? '/nitro-assets/gamedata/FigureData.json', 'FigureData.json')
}
export async function readFigureData(): Promise<FigureDataFile> {
const data = await readGamedataJson<Partial<FigureDataFile>>(await getFigureDataPath());
return { palettes: data.palettes ?? [], setTypes: data.setTypes ?? [] };
const data = await readGamedataJson<Partial<FigureDataFile>>(await getFigureDataPath())
return { palettes: data.palettes ?? [], setTypes: data.setTypes ?? [] }
}
export async function listLocalSetIds(setType: string): Promise<Set<number>> {
const fd = await readFigureData();
const st = fd.setTypes.find((s) => s.type === setType);
return new Set((st?.sets ?? []).map((s) => s.id));
const fd = await readFigureData()
const st = fd.setTypes.find((s) => s.type === setType)
return new Set((st?.sets ?? []).map((s) => s.id))
}
export async function mergeSet(setType: string, paletteId: number, set: FdSet): Promise<void> {
const file = await getFigureDataPath();
const file = await getFigureDataPath()
await withGamedataLock(file, async () => {
const fd = await readGamedataJson<FigureDataFile>(file);
fd.setTypes ??= [];
let st = fd.setTypes.find((s) => s.type === setType);
const fd = await readGamedataJson<FigureDataFile>(file)
fd.setTypes ??= []
let st = fd.setTypes.find((s) => s.type === setType)
if (!st) {
st = { type: setType, paletteId, sets: [] };
fd.setTypes.push(st);
st = { type: setType, paletteId, sets: [] }
fd.setTypes.push(st)
}
st.sets ??= [];
const idx = st.sets.findIndex((s) => s.id === set.id);
st.sets ??= []
const idx = st.sets.findIndex((s) => s.id === set.id)
if (idx >= 0) {
st.sets[idx] = set;
st.sets[idx] = set
} else {
st.sets.push(set);
st.sets.push(set)
}
await writeGamedataJsonAtomic(file, fd);
});
await writeGamedataJsonAtomic(file, fd)
})
}
export async function mergePalette(palette: FdPalette): Promise<void> {
const file = await getFigureDataPath();
const file = await getFigureDataPath()
await withGamedataLock(file, async () => {
const fd = await readGamedataJson<FigureDataFile>(file);
fd.palettes ??= [];
const fd = await readGamedataJson<FigureDataFile>(file)
fd.palettes ??= []
if (!fd.palettes.some((p) => p.id === palette.id)) {
fd.palettes.push(palette);
await writeGamedataJsonAtomic(file, fd);
fd.palettes.push(palette)
await writeGamedataJsonAtomic(file, fd)
}
});
})
}