chore: add biome for linting/formatting

This commit is contained in:
Marc Emmanuel 2026-01-25 23:05:37 +01:00
parent 6797baf7fe
commit 39ab98a95c
29 changed files with 1929 additions and 754 deletions

View file

@ -1,13 +1,22 @@
import "./polyfills";
import { rn, lim, minmax, normalize, lerp } from "./numberUtils";
import { lerp, lim, minmax, normalize, rn } from "./numberUtils";
window.rn = rn;
window.lim = lim;
window.minmax = minmax;
window.normalize = normalize;
window.lerp = lerp as typeof window.lerp;
import { isVowel, trimVowels, getAdjective, nth, abbreviate, list } from "./languageUtils";
import {
abbreviate,
getAdjective,
isVowel,
list,
nth,
trimVowels,
} from "./languageUtils";
window.vowel = isVowel;
window.trimVowels = trimVowels;
window.getAdjective = getAdjective;
@ -15,7 +24,15 @@ window.nth = nth;
window.abbreviate = abbreviate;
window.list = list;
import { last, unique, deepCopy, getTypedArray, createTypedArray, TYPED_ARRAY_MAX_VALUES } from "./arrayUtils";
import {
createTypedArray,
deepCopy,
getTypedArray,
last,
TYPED_ARRAY_MAX_VALUES,
unique,
} from "./arrayUtils";
window.last = last;
window.unique = unique;
window.deepCopy = deepCopy;
@ -26,7 +43,19 @@ window.UINT8_MAX = TYPED_ARRAY_MAX_VALUES.UINT8_MAX;
window.UINT16_MAX = TYPED_ARRAY_MAX_VALUES.UINT16_MAX;
window.UINT32_MAX = TYPED_ARRAY_MAX_VALUES.UINT32_MAX;
import { rand, P, each, gauss, Pint, biased, generateSeed, getNumberInRange, ra, rw } from "./probabilityUtils";
import {
biased,
each,
gauss,
generateSeed,
getNumberInRange,
P,
Pint,
ra,
rand,
rw,
} from "./probabilityUtils";
window.rand = rand;
window.P = P;
window.each = each;
@ -38,12 +67,23 @@ window.biased = biased;
window.getNumberInRange = getNumberInRange;
window.generateSeed = generateSeed;
import { convertTemperature, si, getIntegerFromSI } from "./unitUtils";
window.convertTemperature = (temp:number, scale: any = (window as any).temperatureScale.value || "°C") => convertTemperature(temp, scale);
import { convertTemperature, getIntegerFromSI, si } from "./unitUtils";
window.convertTemperature = (
temp: number,
scale: any = (window as any).temperatureScale.value || "°C",
) => convertTemperature(temp, scale);
window.si = si;
window.getInteger = getIntegerFromSI;
import { toHEX, getColors, getRandomColor, getMixedColor, C_12 } from "./colorUtils";
import {
C_12,
getColors,
getMixedColor,
getRandomColor,
toHEX,
} from "./colorUtils";
window.toHEX = toHEX;
window.getColors = getColors;
window.getRandomColor = getRandomColor;
@ -51,21 +91,41 @@ window.getMixedColor = getMixedColor;
window.C_12 = C_12;
import { getComposedPath, getNextId } from "./nodeUtils";
window.getComposedPath = getComposedPath;
window.getNextId = getNextId;
import { rollups, distanceSquared } from "./functionUtils";
import { distanceSquared, rollups } from "./functionUtils";
window.rollups = rollups;
window.dist2 = distanceSquared;
import { getIsolines, getPolesOfInaccessibility, connectVertices, findPath, getVertexPath } from "./pathUtils";
import {
connectVertices,
findPath,
getIsolines,
getPolesOfInaccessibility,
getVertexPath,
} from "./pathUtils";
window.getIsolines = getIsolines;
window.getPolesOfInaccessibility = getPolesOfInaccessibility;
window.connectVertices = connectVertices;
window.findPath = (start, end, getCost) => findPath(start, end, getCost, (window as any).pack);
window.getVertexPath = (cellsArray) => getVertexPath(cellsArray, (window as any).pack);
window.findPath = (start, end, getCost) =>
findPath(start, end, getCost, (window as any).pack);
window.getVertexPath = (cellsArray) =>
getVertexPath(cellsArray, (window as any).pack);
import {
capitalize,
isValidJSON,
parseTransform,
round,
safeParseJSON,
sanitizeId,
splitInTwo,
} from "./stringUtils";
import { round, capitalize, splitInTwo, parseTransform, isValidJSON, safeParseJSON, sanitizeId } from "./stringUtils";
window.round = round;
window.capitalize = capitalize;
window.splitInTwo = splitInTwo;
@ -76,6 +136,7 @@ JSON.isValid = isValidJSON;
JSON.safeParse = safeParseJSON;
import { byId } from "./shorthands";
window.byId = byId;
Node.prototype.on = function (name, fn, options) {
this.addEventListener(name, fn, options);
@ -87,27 +148,63 @@ Node.prototype.off = function (name, fn) {
};
declare global {
interface JSON {
isValid: (str: string) => boolean;
safeParse: (str: string) => any;
}
interface Node {
on: (name: string, fn: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => Node;
on: (
name: string,
fn: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
) => Node;
off: (name: string, fn: EventListenerOrEventListenerObject) => Node;
}
}
import { shouldRegenerateGrid, generateGrid, findGridAll, findGridCell, findClosestCell, calculateVoronoi, findAllCellsInRadius, getPackPolygon, getGridPolygon, poissonDiscSampler, isLand, isWater, findAllInQuadtree, drawHeights } from "./graphUtils";
window.shouldRegenerateGrid = (grid: any, expectedSeed: number) => shouldRegenerateGrid(grid, expectedSeed, (window as any).graphWidth, (window as any).graphHeight);
window.generateGrid = () => generateGrid((window as any).seed, (window as any).graphWidth, (window as any).graphHeight);
window.findGridAll = (x: number, y: number, radius: number) => findGridAll(x, y, radius, (window as any).grid);
window.findGridCell = (x: number, y: number) => findGridCell(x, y, (window as any).grid);
window.findCell = (x: number, y: number, radius?: number) => findClosestCell(x, y, radius, (window as any).pack);
window.findAll = (x: number, y: number, radius: number) => findAllCellsInRadius(x, y, radius, (window as any).pack);
window.getPackPolygon = (cellIndex: number) => getPackPolygon(cellIndex, (window as any).pack);
window.getGridPolygon = (cellIndex: number) => getGridPolygon(cellIndex, (window as any).grid);
import {
calculateVoronoi,
drawHeights,
findAllCellsInRadius,
findAllInQuadtree,
findClosestCell,
findGridAll,
findGridCell,
generateGrid,
getGridPolygon,
getPackPolygon,
isLand,
isWater,
poissonDiscSampler,
shouldRegenerateGrid,
} from "./graphUtils";
window.shouldRegenerateGrid = (grid: any, expectedSeed: number) =>
shouldRegenerateGrid(
grid,
expectedSeed,
(window as any).graphWidth,
(window as any).graphHeight,
);
window.generateGrid = () =>
generateGrid(
(window as any).seed,
(window as any).graphWidth,
(window as any).graphHeight,
);
window.findGridAll = (x: number, y: number, radius: number) =>
findGridAll(x, y, radius, (window as any).grid);
window.findGridCell = (x: number, y: number) =>
findGridCell(x, y, (window as any).grid);
window.findCell = (x: number, y: number, radius?: number) =>
findClosestCell(x, y, radius, (window as any).pack);
window.findAll = (x: number, y: number, radius: number) =>
findAllCellsInRadius(x, y, radius, (window as any).pack);
window.getPackPolygon = (cellIndex: number) =>
getPackPolygon(cellIndex, (window as any).pack);
window.getGridPolygon = (cellIndex: number) =>
getGridPolygon(cellIndex, (window as any).grid);
window.calculateVoronoi = calculateVoronoi;
window.poissonDiscSampler = poissonDiscSampler;
window.findAllInQuadtree = findAllInQuadtree;
@ -115,8 +212,31 @@ window.drawHeights = drawHeights;
window.isLand = (i: number) => isLand(i, (window as any).pack);
window.isWater = (i: number) => isWater(i, (window as any).pack);
import { clipPoly, getSegmentId, debounce, throttle, parseError, getBase64, openURL, wiki, link, isCtrlClick, generateDate, getLongitude, getLatitude, getCoordinates, initializePrompt } from "./commonUtils";
window.clipPoly = (points: [number, number][], secure?: number) => clipPoly(points, (window as any).graphWidth, (window as any).graphHeight, secure);
import {
clipPoly,
debounce,
generateDate,
getBase64,
getCoordinates,
getLatitude,
getLongitude,
getSegmentId,
initializePrompt,
isCtrlClick,
link,
openURL,
parseError,
throttle,
wiki,
} from "./commonUtils";
window.clipPoly = (points: [number, number][], secure?: number) =>
clipPoly(
points,
(window as any).graphWidth,
(window as any).graphHeight,
secure,
);
window.getSegmentId = getSegmentId;
window.debounce = debounce;
window.throttle = throttle;
@ -127,25 +247,54 @@ window.wiki = wiki;
window.link = link;
window.isCtrlClick = isCtrlClick;
window.generateDate = generateDate;
window.getLongitude = (x: number, decimals?: number) => getLongitude(x, (window as any).mapCoordinates, (window as any).graphWidth, decimals);
window.getLatitude = (y: number, decimals?: number) => getLatitude(y, (window as any).mapCoordinates, (window as any).graphHeight, decimals);
window.getCoordinates = (x: number, y: number, decimals?: number) => getCoordinates(x, y, (window as any).mapCoordinates, (window as any).graphWidth, (window as any).graphHeight, decimals);
window.getLongitude = (x: number, decimals?: number) =>
getLongitude(
x,
(window as any).mapCoordinates,
(window as any).graphWidth,
decimals,
);
window.getLatitude = (y: number, decimals?: number) =>
getLatitude(
y,
(window as any).mapCoordinates,
(window as any).graphHeight,
decimals,
);
window.getCoordinates = (x: number, y: number, decimals?: number) =>
getCoordinates(
x,
y,
(window as any).mapCoordinates,
(window as any).graphWidth,
(window as any).graphHeight,
decimals,
);
// Initialize prompt when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializePrompt);
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initializePrompt);
} else {
initializePrompt();
}
import { drawCellsValue, drawPolygons, drawRouteConnections, drawPoint, drawPath } from "./debugUtils";
window.drawCellsValue = (data:any[]) => drawCellsValue(data, (window as any).pack);
window.drawPolygons = (data: any[]) => drawPolygons(data, (window as any).terrs, (window as any).grid);
window.drawRouteConnections = () => drawRouteConnections((window as any).packedGraph);
import {
drawCellsValue,
drawPath,
drawPoint,
drawPolygons,
drawRouteConnections,
} from "./debugUtils";
window.drawCellsValue = (data: any[]) =>
drawCellsValue(data, (window as any).pack);
window.drawPolygons = (data: any[]) =>
drawPolygons(data, (window as any).terrs, (window as any).grid);
window.drawRouteConnections = () =>
drawRouteConnections((window as any).packedGraph);
window.drawPoint = drawPoint;
window.drawPath = drawPath;
export {
rn,
lim,
@ -232,5 +381,5 @@ export {
drawPolygons,
drawRouteConnections,
drawPoint,
drawPath
}
drawPath,
};