diff --git a/bun.lock b/bun.lock
index db74dcd..db3d7e7 100644
--- a/bun.lock
+++ b/bun.lock
@@ -5,7 +5,7 @@
"name": "snk",
"devDependencies": {
"@types/bun": "1.2.2",
- "prettier": "2.8.8",
+ "prettier": "3.5.1",
"typescript": "5.7.3",
},
},
@@ -1001,7 +1001,7 @@
"prepend-http": ["prepend-http@1.0.4", "", {}, "sha512-PhmXi5XmoyKw1Un4E+opM2KcsJInDvKyuOumcjjw3waw86ZNjHwVUOOWLc4bCzLdcKNaWBH9e99sbWzDQsVaYg=="],
- "prettier": ["prettier@2.8.8", "", { "bin": { "prettier": "bin-prettier.js" } }, "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q=="],
+ "prettier": ["prettier@3.5.1", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw=="],
"pretty-error": ["pretty-error@4.0.0", "", { "dependencies": { "lodash": "^4.17.20", "renderkid": "^3.0.0" } }, "sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw=="],
diff --git a/package.json b/package.json
index d490bbf..214f05f 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
"repository": "github:platane/snk",
"devDependencies": {
"@types/bun": "1.2.2",
- "prettier": "2.8.8",
+ "prettier": "3.5.1",
"typescript": "5.7.3"
},
"workspaces": [
diff --git a/packages/action/__tests__/generateContributionSnake.spec.ts b/packages/action/__tests__/generateContributionSnake.spec.ts
index fbcfea8..6b7f115 100644
--- a/packages/action/__tests__/generateContributionSnake.spec.ts
+++ b/packages/action/__tests__/generateContributionSnake.spec.ts
@@ -41,5 +41,5 @@ it(
fs.writeFileSync(outputs[1]!.filename, results[1]!);
fs.writeFileSync(outputs[2]!.filename, results[2]!);
}),
- { timeout: 2 * 60 * 1000 }
+ { timeout: 2 * 60 * 1000 },
);
diff --git a/packages/action/__tests__/outputsOptions.spec.ts b/packages/action/__tests__/outputsOptions.spec.ts
index a297fd7..6cb9be0 100644
--- a/packages/action/__tests__/outputsOptions.spec.ts
+++ b/packages/action/__tests__/outputsOptions.spec.ts
@@ -3,42 +3,42 @@ import { it, expect } from "bun:test";
it("should parse options as json", () => {
expect(
- parseEntry(`/out.svg {"color_snake":"yellow"}`)?.drawOptions
+ parseEntry(`/out.svg {"color_snake":"yellow"}`)?.drawOptions,
).toHaveProperty("colorSnake", "yellow");
expect(
- parseEntry(`/out.svg?{"color_snake":"yellow"}`)?.drawOptions
+ parseEntry(`/out.svg?{"color_snake":"yellow"}`)?.drawOptions,
).toHaveProperty("colorSnake", "yellow");
expect(
parseEntry(`/out.svg?{"color_dots":["#000","#111","#222","#333","#444"]}`)
- ?.drawOptions.colorDots
+ ?.drawOptions.colorDots,
).toEqual(["#000", "#111", "#222", "#333", "#444"]);
});
it("should parse options as searchparams", () => {
expect(parseEntry(`/out.svg?color_snake=yellow`)?.drawOptions).toHaveProperty(
"colorSnake",
- "yellow"
+ "yellow",
);
expect(
parseEntry(`/out.svg?color_dots=#000,#111,#222,#333,#444`)?.drawOptions
- .colorDots
+ .colorDots,
).toEqual(["#000", "#111", "#222", "#333", "#444"]);
});
it("should parse filename", () => {
expect(parseEntry(`/a/b/c.svg?{"color_snake":"yellow"}`)).toHaveProperty(
"filename",
- "/a/b/c.svg"
+ "/a/b/c.svg",
);
expect(
- parseEntry(`/a/b/out.svg?.gif.svg?{"color_snake":"yellow"}`)
+ parseEntry(`/a/b/out.svg?.gif.svg?{"color_snake":"yellow"}`),
).toHaveProperty("filename", "/a/b/out.svg?.gif.svg");
expect(
- parseEntry(`/a/b/{[-1].svg?.gif.svg?{"color_snake":"yellow"}`)
+ parseEntry(`/a/b/{[-1].svg?.gif.svg?{"color_snake":"yellow"}`),
).toHaveProperty("filename", "/a/b/{[-1].svg?.gif.svg");
});
@@ -57,5 +57,5 @@ it("should parse filename", () => {
].forEach((entry) =>
it(`should parse ${entry}`, () => {
expect(parseEntry(entry)).toMatchSnapshot();
- })
+ }),
);
diff --git a/packages/action/generateContributionSnake.ts b/packages/action/generateContributionSnake.ts
index 8f9df30..b61455d 100644
--- a/packages/action/generateContributionSnake.ts
+++ b/packages/action/generateContributionSnake.ts
@@ -13,7 +13,7 @@ export const generateContributionSnake = async (
drawOptions: DrawOptions;
animationOptions: AnimationOptions;
} | null)[],
- options: { githubToken: string }
+ options: { githubToken: string },
) => {
console.log("🎣 fetching github user contribution");
const cells = await getGithubUserContribution(userName, options);
@@ -43,10 +43,10 @@ export const generateContributionSnake = async (
cells,
chain,
drawOptions,
- animationOptions
+ animationOptions,
);
}
}
- })
+ }),
);
};
diff --git a/packages/action/index.ts b/packages/action/index.ts
index d45d209..b67d7a0 100644
--- a/packages/action/index.ts
+++ b/packages/action/index.ts
@@ -10,7 +10,7 @@ import { parseOutputsOption } from "./outputsOptions";
core.getMultilineInput("outputs") ?? [
core.getInput("gif_out_path"),
core.getInput("svg_out_path"),
- ]
+ ],
);
const githubToken =
process.env.GITHUB_TOKEN ?? core.getInput("github_token");
diff --git a/packages/demo/canvas.ts b/packages/demo/canvas.ts
index c6f2f8f..882c49e 100644
--- a/packages/demo/canvas.ts
+++ b/packages/demo/canvas.ts
@@ -76,7 +76,7 @@ export const createCanvas = ({
snake0: Snake,
snake1: Snake,
stack: Color[],
- k: number
+ k: number,
) => {
ctx.clearRect(0, 0, 9999, 9999);
drawLerpWorld(ctx, grid, null, snake0, snake1, stack, k, drawOptions);
diff --git a/packages/demo/demo.getBestTunnel.ts b/packages/demo/demo.getBestTunnel.ts
index a32f7e4..3ca0b2b 100644
--- a/packages/demo/demo.getBestTunnel.ts
+++ b/packages/demo/demo.getBestTunnel.ts
@@ -26,7 +26,7 @@ const tunnels = ones.map(({ x, y }) => ({
x,
y,
3 as Color,
- getSnakeLength(snake)
+ getSnakeLength(snake),
),
}));
diff --git a/packages/demo/demo.getPathToPose.ts b/packages/demo/demo.getPathToPose.ts
index a7246ed..014dd66 100644
--- a/packages/demo/demo.getPathToPose.ts
+++ b/packages/demo/demo.getPathToPose.ts
@@ -8,7 +8,7 @@ const { canvas, ctx, draw, highlightCell } = createCanvas(grid);
canvas.style.pointerEvents = "auto";
const target = createSnakeFromCells(
- snakeToCells(snake).map((p) => ({ ...p, x: p.x - 1 }))
+ snakeToCells(snake).map((p) => ({ ...p, x: p.x - 1 })),
);
let chain = [snake, ...getPathToPose(snake, target)!];
diff --git a/packages/demo/demo.interactive.ts b/packages/demo/demo.interactive.ts
index d79f2e2..16af144 100644
--- a/packages/demo/demo.interactive.ts
+++ b/packages/demo/demo.interactive.ts
@@ -253,7 +253,7 @@ const createViewer = ({
: "") +
`` +
svgString +
- ""
+ "",
);
e.preventDefault();
});
@@ -277,7 +277,7 @@ const createViewer = ({
const onSubmit = async (userName: string) => {
const res = await fetch(
- process.env.GITHUB_USER_CONTRIBUTION_API_ENDPOINT + userName
+ process.env.GITHUB_USER_CONTRIBUTION_API_ENDPOINT + userName,
);
const cells = (await res.json()) as Res;
@@ -294,8 +294,8 @@ const worker = new Worker(
new URL(
"./demo.interactive.worker.ts",
// @ts-ignore
- import.meta.url
- )
+ import.meta.url,
+ ),
);
const { getChain } = createRpcClient(worker);
diff --git a/packages/demo/menu.ts b/packages/demo/menu.ts
index b22f41c..ac187cd 100644
--- a/packages/demo/menu.ts
+++ b/packages/demo/menu.ts
@@ -25,7 +25,7 @@ const onChange = () => {
const url = new URL(
config.demo + ".html?" + search,
- window.location.href
+ window.location.href,
).toString();
window.location.href = url;
diff --git a/packages/demo/springUtils.ts b/packages/demo/springUtils.ts
index 44b4107..10bc2f7 100644
--- a/packages/demo/springUtils.ts
+++ b/packages/demo/springUtils.ts
@@ -15,7 +15,7 @@ const stepSpringOne = (
maxVelocity = Infinity,
}: { tension: number; friction: number; maxVelocity?: number },
target: number,
- dt = 1 / 60
+ dt = 1 / 60,
) => {
const a = -tension * (s.x - target) - friction * s.v;
@@ -31,13 +31,13 @@ const stepSpringOne = (
export const isStable = (
s: { x: number; v: number },
target: number,
- dt = 1 / 60
+ dt = 1 / 60,
) => Math.abs(s.x - target) < epsilon && Math.abs(s.v * dt) < epsilon;
export const isStableAndBound = (
s: { x: number; v: number },
target: number,
- dt?: number
+ dt?: number,
) => {
const stable = isStable(s, target, dt);
if (stable) {
@@ -51,7 +51,7 @@ export const stepSpring = (
s: { x: number; v: number },
params: { tension: number; friction: number; maxVelocity?: number },
target: number,
- dt = 1 / 60
+ dt = 1 / 60,
) => {
const interval = 1 / 60;
diff --git a/packages/demo/webpack.config.ts b/packages/demo/webpack.config.ts
index eeef050..b495371 100644
--- a/packages/demo/webpack.config.ts
+++ b/packages/demo/webpack.config.ts
@@ -18,13 +18,13 @@ const webpackDevServerConfiguration: WebpackDevServerConfiguration = {
...ms,
(async (req, res, next) => {
const userName = req.url.match(
- /\/api\/github-user-contribution\/(\w+)/
+ /\/api\/github-user-contribution\/(\w+)/,
)?.[1];
if (userName)
res.send(
await getGithubUserContribution(userName, {
githubToken: process.env.GITHUB_TOKEN!,
- })
+ }),
);
else next();
}) as ExpressRequestHandler,
@@ -34,7 +34,7 @@ const webpackDevServerConfiguration: WebpackDevServerConfiguration = {
const webpackConfiguration: WebpackConfiguration = {
mode: "development",
entry: Object.fromEntries(
- demos.map((demo: string) => [demo, `./demo.${demo}`])
+ demos.map((demo: string) => [demo, `./demo.${demo}`]),
),
target: ["web", "es2019"],
resolve: { extensions: [".ts", ".js"] },
@@ -65,7 +65,7 @@ const webpackConfiguration: WebpackConfiguration = {
title: "snk - " + demo,
filename: `${demo}.html`,
chunks: [demo],
- })
+ }),
),
new HtmlWebpackPlugin({
title: "snk - " + demos[0],
diff --git a/packages/demo/worker-utils.ts b/packages/demo/worker-utils.ts
index ecd81e7..be45c71 100644
--- a/packages/demo/worker-utils.ts
+++ b/packages/demo/worker-utils.ts
@@ -54,6 +54,6 @@ export const createRpcClient = (worker: Worker) => {
worker.addEventListener("terminate", onTerminate);
worker.postMessage({ symbol, key, methodName, args });
}),
- }
+ },
);
};
diff --git a/packages/draw/drawCircleStack.ts b/packages/draw/drawCircleStack.ts
index 3bd1f45..2bf6e9e 100644
--- a/packages/draw/drawCircleStack.ts
+++ b/packages/draw/drawCircleStack.ts
@@ -59,7 +59,7 @@ export const getCircleSize = (n: number) => {
export const drawCircleStack = (
ctx: CanvasRenderingContext2D,
stack: Color[],
- o: Options
+ o: Options,
) => {
for (let i = stack.length; i--; ) {
const { x, y } = cellPath[i];
@@ -67,7 +67,7 @@ export const drawCircleStack = (
ctx.save();
ctx.translate(
x * o.sizeCell + (o.sizeCell - o.sizeDot) / 2,
- y * o.sizeCell + (o.sizeCell - o.sizeDot) / 2
+ y * o.sizeCell + (o.sizeCell - o.sizeDot) / 2,
);
//@ts-ignore
diff --git a/packages/draw/drawGrid.ts b/packages/draw/drawGrid.ts
index be31e6c..d9adea9 100644
--- a/packages/draw/drawGrid.ts
+++ b/packages/draw/drawGrid.ts
@@ -16,7 +16,7 @@ export const drawGrid = (
ctx: CanvasRenderingContext2D,
grid: Grid,
cells: Point[] | null,
- o: Options
+ o: Options,
) => {
for (let x = grid.width; x--; )
for (let y = grid.height; y--; ) {
@@ -27,7 +27,7 @@ export const drawGrid = (
ctx.save();
ctx.translate(
x * o.sizeCell + (o.sizeCell - o.sizeDot) / 2,
- y * o.sizeCell + (o.sizeCell - o.sizeDot) / 2
+ y * o.sizeCell + (o.sizeCell - o.sizeDot) / 2,
);
ctx.fillStyle = color;
diff --git a/packages/draw/drawSnake.ts b/packages/draw/drawSnake.ts
index 7c25142..35acf81 100644
--- a/packages/draw/drawSnake.ts
+++ b/packages/draw/drawSnake.ts
@@ -10,7 +10,7 @@ type Options = {
export const drawSnake = (
ctx: CanvasRenderingContext2D,
snake: Snake,
- o: Options
+ o: Options,
) => {
const cells = snakeToCells(snake);
@@ -25,7 +25,7 @@ export const drawSnake = (
ctx,
o.sizeCell - u * 2,
o.sizeCell - u * 2,
- (o.sizeCell - u * 2) * 0.25
+ (o.sizeCell - u * 2) * 0.25,
);
ctx.fill();
ctx.restore();
@@ -40,7 +40,7 @@ export const drawSnakeLerp = (
snake0: Snake,
snake1: Snake,
k: number,
- o: Options
+ o: Options,
) => {
const m = 0.8;
const n = snake0.length / 2;
@@ -61,7 +61,7 @@ export const drawSnakeLerp = (
ctx,
o.sizeCell - u * 2,
o.sizeCell - u * 2,
- (o.sizeCell - u * 2) * 0.25
+ (o.sizeCell - u * 2) * 0.25,
);
ctx.fill();
ctx.restore();
diff --git a/packages/draw/drawWorld.ts b/packages/draw/drawWorld.ts
index 154782f..3d041a3 100644
--- a/packages/draw/drawWorld.ts
+++ b/packages/draw/drawWorld.ts
@@ -19,7 +19,7 @@ export const drawStack = (
stack: Color[],
max: number,
width: number,
- o: { colorDots: Record }
+ o: { colorDots: Record },
) => {
ctx.save();
@@ -39,7 +39,7 @@ export const drawWorld = (
cells: Point[] | null,
snake: Snake,
stack: Color[],
- o: Options
+ o: Options,
) => {
ctx.save();
@@ -73,7 +73,7 @@ export const drawLerpWorld = (
snake1: Snake,
stack: Color[],
k: number,
- o: Options
+ o: Options,
) => {
ctx.save();
diff --git a/packages/draw/pathRoundedRect.ts b/packages/draw/pathRoundedRect.ts
index b646ea8..192b3b0 100644
--- a/packages/draw/pathRoundedRect.ts
+++ b/packages/draw/pathRoundedRect.ts
@@ -2,7 +2,7 @@ export const pathRoundedRect = (
ctx: CanvasRenderingContext2D,
width: number,
height: number,
- borderRadius: number
+ borderRadius: number,
) => {
ctx.moveTo(borderRadius, 0);
ctx.arcTo(width, 0, width, height, borderRadius);
diff --git a/packages/gif-creator/__tests__/benchmark.ts b/packages/gif-creator/__tests__/benchmark.ts
index 3918b75..d580761 100644
--- a/packages/gif-creator/__tests__/benchmark.ts
+++ b/packages/gif-creator/__tests__/benchmark.ts
@@ -8,7 +8,7 @@ import { getPathToPose } from "@snk/solver/getPathToPose";
import type { Options as DrawOptions } from "@snk/draw/drawWorld";
let snake = createSnakeFromCells(
- Array.from({ length: 4 }, (_, i) => ({ x: i, y: -1 }))
+ Array.from({ length: 4 }, (_, i) => ({ x: i, y: -1 })),
);
// const chain = [snake];
@@ -55,7 +55,7 @@ const animationOptions: AnimationOptions = { frameDuration: 100, step: 1 };
null,
chainL,
drawOptions,
- animationOptions
+ animationOptions,
);
stats.push(performance.now() - s);
}
@@ -73,12 +73,12 @@ const animationOptions: AnimationOptions = { frameDuration: 100, step: 1 };
})}ms`,
"",
].join("\n"),
- stats
+ stats,
);
fs.writeFileSync(
`__tests__/__snapshots__/benchmark-output-${length}.gif`,
- buffer!
+ buffer!,
);
}
})();
diff --git a/packages/gif-creator/__tests__/createGif.spec.ts b/packages/gif-creator/__tests__/createGif.spec.ts
index 822ed1c..51d25cd 100644
--- a/packages/gif-creator/__tests__/createGif.spec.ts
+++ b/packages/gif-creator/__tests__/createGif.spec.ts
@@ -46,14 +46,14 @@ for (const key of [
null,
chain,
drawOptions,
- animationOptions
+ animationOptions,
);
expect(gif).toBeDefined();
fs.writeFileSync(path.resolve(dir, key + ".gif"), gif);
},
- { timeout: 20 * 1000 }
+ { timeout: 20 * 1000 },
);
it(
@@ -61,7 +61,7 @@ it(
async () => {
const grid = grids.smallFull;
let snk = createSnakeFromCells(
- Array.from({ length: 6 }, (_, i) => ({ x: i, y: -1 }))
+ Array.from({ length: 6 }, (_, i) => ({ x: i, y: -1 })),
);
const chain = [snk];
@@ -80,12 +80,12 @@ it(
null,
chain,
drawOptions,
- animationOptions
+ animationOptions,
);
expect(gif).toBeDefined();
fs.writeFileSync(path.resolve(dir, "swipper.gif"), gif);
},
- { timeout: 20 * 1000 }
+ { timeout: 20 * 1000 },
);
diff --git a/packages/gif-creator/index.ts b/packages/gif-creator/index.ts
index f73e17c..0b42c95 100644
--- a/packages/gif-creator/index.ts
+++ b/packages/gif-creator/index.ts
@@ -17,7 +17,7 @@ import gifsicle from "gifsicle";
import GIFEncoder from "gif-encoder-2";
const withTmpDir = async (
- handler: (dir: string) => Promise
+ handler: (dir: string) => Promise,
): Promise => {
const { name: dir, removeCallback: cleanUp } = tmp.dirSync({
unsafeCleanup: true,
@@ -37,7 +37,7 @@ export const createGif = async (
cells: Point[] | null,
chain: Snake[],
drawOptions: DrawOptions,
- animationOptions: AnimationOptions
+ animationOptions: AnimationOptions,
) =>
withTmpDir(async (dir) => {
const { width, height } = getCanvasWorldSize(grid0, drawOptions);
@@ -70,7 +70,7 @@ export const createGif = async (
snake1,
stack,
k / animationOptions.step,
- drawOptions
+ drawOptions,
);
encoder.addFrame(ctx);
@@ -92,7 +92,7 @@ export const createGif = async (
"--colors=18",
outFileName,
["--output", optimizedFileName],
- ].flat()
+ ].flat(),
);
return new Uint8Array(fs.readFileSync(optimizedFileName));
diff --git a/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts b/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts
index 42de982..9a6f14e 100644
--- a/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts
+++ b/packages/github-user-contribution-service/api/github-user-contribution/[userName].ts
@@ -13,7 +13,7 @@ export default async (req: VercelRequest, res: VercelResponse) => {
];
const allowedOrigin = allowedOrigins.find(
- (o) => o === req.headers.origin
+ (o) => o === req.headers.origin,
);
if (allowedOrigin)
res.setHeader("Access-Control-Allow-Origin", allowedOrigin);
@@ -23,7 +23,7 @@ export default async (req: VercelRequest, res: VercelResponse) => {
res.json(
await getGithubUserContribution(userName as string, {
githubToken: process.env.GITHUB_TOKEN!,
- })
+ }),
);
} catch (err) {
console.error(err);
diff --git a/packages/github-user-contribution/index.ts b/packages/github-user-contribution/index.ts
index da887d5..6c32411 100644
--- a/packages/github-user-contribution/index.ts
+++ b/packages/github-user-contribution/index.ts
@@ -16,7 +16,7 @@
*/
export const getGithubUserContribution = async (
userName: string,
- o: { githubToken: string }
+ o: { githubToken: string },
) => {
const query = /* GraphQL */ `
query ($login: String!) {
@@ -69,7 +69,7 @@ export const getGithubUserContribution = async (
(d.contributionLevel === "SECOND_QUARTILE" && 2) ||
(d.contributionLevel === "FIRST_QUARTILE" && 1) ||
0,
- }))
+ })),
);
};
diff --git a/packages/solver/__tests__/getBestRoute-fuzz.spec.ts b/packages/solver/__tests__/getBestRoute-fuzz.spec.ts
index eb0499b..6e5bfc0 100644
--- a/packages/solver/__tests__/getBestRoute-fuzz.spec.ts
+++ b/packages/solver/__tests__/getBestRoute-fuzz.spec.ts
@@ -17,7 +17,7 @@ for (const { width, height, snake } of [
{ width: 5, height: 5, snake: snake4 },
])
it(`should find solution for ${n} ${width}x${height} generated grids for ${getSnakeLength(
- snake
+ snake,
)} length snake`, () => {
const results = Array.from({ length: n }, (_, seed) => {
const grid = createFromSeed(seed, width, height);
diff --git a/packages/solver/clearCleanColoredLayer.ts b/packages/solver/clearCleanColoredLayer.ts
index 533e156..b59313d 100644
--- a/packages/solver/clearCleanColoredLayer.ts
+++ b/packages/solver/clearCleanColoredLayer.ts
@@ -24,7 +24,7 @@ export const clearCleanColoredLayer = (
grid: Grid,
outside: Outside,
snake0: Snake,
- color: Color
+ color: Color,
) => {
const snakeN = getSnakeLength(snake0);
@@ -55,7 +55,7 @@ const getPathToNextPoint = (
grid: Grid,
snake0: Snake,
color: Color,
- points: Point[]
+ points: Point[],
) => {
const closeList: Snake[] = [];
const openList: M[] = [{ snake: snake0 } as any];
@@ -96,7 +96,7 @@ export const getTunnellablePoints = (
grid: Grid,
outside: Outside,
snakeN: number,
- color: Color
+ color: Color,
) => {
const points: Point[] = [];
diff --git a/packages/solver/clearResidualColoredLayer.ts b/packages/solver/clearResidualColoredLayer.ts
index e898521..a80c310 100644
--- a/packages/solver/clearResidualColoredLayer.ts
+++ b/packages/solver/clearResidualColoredLayer.ts
@@ -20,7 +20,7 @@ export const clearResidualColoredLayer = (
grid: Grid,
outside: Outside,
snake0: Snake,
- color: Color
+ color: Color,
) => {
const snakeN = getSnakeLength(snake0);
@@ -99,7 +99,7 @@ export const getTunnellablePoints = (
grid: Grid,
outside: Outside,
snakeN: number,
- color: Color
+ color: Color,
) => {
const points: T[] = [];
diff --git a/packages/solver/getBestRoute.ts b/packages/solver/getBestRoute.ts
index 548edd0..b2fd3fb 100644
--- a/packages/solver/getBestRoute.ts
+++ b/packages/solver/getBestRoute.ts
@@ -13,7 +13,7 @@ export const getBestRoute = (grid0: Grid, snake0: Snake) => {
for (const color of extractColors(grid)) {
if (color > 1)
chain.unshift(
- ...clearResidualColoredLayer(grid, outside, chain[0], color)
+ ...clearResidualColoredLayer(grid, outside, chain[0], color),
);
chain.unshift(...clearCleanColoredLayer(grid, outside, chain[0], color));
}
diff --git a/packages/solver/getBestTunnel.ts b/packages/solver/getBestTunnel.ts
index f26e51d..84eeddf 100644
--- a/packages/solver/getBestTunnel.ts
+++ b/packages/solver/getBestTunnel.ts
@@ -37,7 +37,7 @@ const getSnakeEscapePath = (
grid: Grid,
outside: Outside,
snake0: Snake,
- color: Color
+ color: Color,
) => {
const openList: M[] = [{ snake: snake0, w: 0 } as any];
const closeList: Snake[] = [];
@@ -79,7 +79,7 @@ export const getBestTunnel = (
x: number,
y: number,
color: Color,
- snakeN: number
+ snakeN: number,
) => {
const c = { x, y };
const snake0 = createSnakeFromCells(Array.from({ length: snakeN }, () => c));
diff --git a/packages/solver/outside.ts b/packages/solver/outside.ts
index 0cf7cf5..5318ec0 100644
--- a/packages/solver/outside.ts
+++ b/packages/solver/outside.ts
@@ -24,7 +24,7 @@ export const createOutside = (grid: Grid, color: Color = 0 as Color) => {
export const fillOutside = (
outside: Outside,
grid: Grid,
- color: Color = 0 as Color
+ color: Color = 0 as Color,
) => {
let changed = true;
while (changed) {
diff --git a/packages/solver/tunnel.ts b/packages/solver/tunnel.ts
index 2871deb..4c24ea1 100644
--- a/packages/solver/tunnel.ts
+++ b/packages/solver/tunnel.ts
@@ -27,7 +27,7 @@ export const getTunnelPath = (snake0: Snake, tunnel: Point[]) => {
export const updateTunnel = (
grid: Grid,
tunnel: Point[],
- toDelete: Point[]
+ toDelete: Point[],
) => {
while (tunnel.length) {
const { x, y } = tunnel[0];
diff --git a/packages/svg-creator/__tests__/createSvg.spec.ts b/packages/svg-creator/__tests__/createSvg.spec.ts
index 4dc3a41..010ff69 100644
--- a/packages/svg-creator/__tests__/createSvg.spec.ts
+++ b/packages/svg-creator/__tests__/createSvg.spec.ts
@@ -38,7 +38,7 @@ for (const [key, grid] of Object.entries(grids))
null,
chain,
drawOptions,
- animationOptions
+ animationOptions,
);
expect(svg).toBeDefined();
diff --git a/packages/svg-creator/__tests__/minifyCss.spec.ts b/packages/svg-creator/__tests__/minifyCss.spec.ts
index 41cdb1f..f63a3f7 100644
--- a/packages/svg-creator/__tests__/minifyCss.spec.ts
+++ b/packages/svg-creator/__tests__/minifyCss.spec.ts
@@ -8,7 +8,7 @@ it("should minify css", () => {
color : red ;
}
- `)
+ `),
).toBe(".c{color:red}");
expect(
@@ -22,6 +22,6 @@ it("should minify css", () => {
animation: linear 10;
}
- `)
+ `),
).toBe(".c{top:0;color:red}#{animation:linear 10}");
});
diff --git a/packages/svg-creator/css-utils.ts b/packages/svg-creator/css-utils.ts
index 4bd4d73..b687b57 100644
--- a/packages/svg-creator/css-utils.ts
+++ b/packages/svg-creator/css-utils.ts
@@ -16,7 +16,7 @@ const mergeKeyFrames = (keyframes: { t: number; style: string }[]) => {
*/
export const createAnimation = (
name: string,
- keyframes: { t: number; style: string }[]
+ keyframes: { t: number; style: string }[],
) =>
`@keyframes ${name}{` +
mergeKeyFrames(keyframes)
diff --git a/packages/svg-creator/grid.ts b/packages/svg-creator/grid.ts
index 7d89417..96bf932 100644
--- a/packages/svg-creator/grid.ts
+++ b/packages/svg-creator/grid.ts
@@ -15,7 +15,7 @@ export type Options = {
export const createGrid = (
cells: (Point & { t: number | null; color: Color | Empty })[],
{ sizeDotBorderRadius, sizeDot, sizeCell }: Options,
- duration: number
+ duration: number,
) => {
const svgElements: string[] = [];
const styles = [
@@ -48,7 +48,7 @@ export const createGrid = (
`.c.${id}{
fill: var(--c${color});
animation-name: ${animationName}
- }`
+ }`,
);
}
@@ -59,7 +59,7 @@ export const createGrid = (
y: y * sizeCell + m,
rx: sizeDotBorderRadius,
ry: sizeDotBorderRadius,
- })
+ }),
);
}
diff --git a/packages/svg-creator/index.ts b/packages/svg-creator/index.ts
index edf347c..0aa07bf 100644
--- a/packages/svg-creator/index.ts
+++ b/packages/svg-creator/index.ts
@@ -34,13 +34,13 @@ export type DrawOptions = {
const getCellsFromGrid = ({ width, height }: Grid) =>
Array.from({ length: width }, (_, x) =>
- Array.from({ length: height }, (_, y) => ({ x, y }))
+ Array.from({ length: height }, (_, y) => ({ x, y })),
).flat();
const createLivingCells = (
grid0: Grid,
chain: Snake[],
- cells: Point[] | null
+ cells: Point[] | null,
) => {
const livingCells: (Point & {
t: number | null;
@@ -73,7 +73,7 @@ export const createSvg = (
cells: Point[] | null,
chain: Snake[],
drawOptions: DrawOptions,
- animationOptions: Pick
+ animationOptions: Pick,
) => {
const width = (grid.width + 2) * drawOptions.sizeCell;
const height = (grid.height + 5) * drawOptions.sizeCell;
@@ -89,7 +89,7 @@ export const createSvg = (
drawOptions,
grid.width * drawOptions.sizeCell,
(grid.height + 2) * drawOptions.sizeCell,
- duration
+ duration,
),
createSnake(chain, drawOptions, duration),
];
diff --git a/packages/svg-creator/snake.ts b/packages/svg-creator/snake.ts
index 5514adf..a32c974 100644
--- a/packages/svg-creator/snake.ts
+++ b/packages/svg-creator/snake.ts
@@ -15,7 +15,7 @@ const lerp = (k: number, a: number, b: number) => (1 - k) * a + k * b;
export const createSnake = (
chain: Snake[],
{ sizeCell, sizeDot }: Options,
- duration: number
+ duration: number,
) => {
const snakeN = chain[0] ? getSnakeLength(chain[0]) : 0;
@@ -64,7 +64,7 @@ export const createSnake = (
const animationName = id;
const keyframes = removeInterpolatedPositions(
- positions.map((tr, i, { length }) => ({ ...tr, t: i / length }))
+ positions.map((tr, i, { length }) => ({ ...tr, t: i / length })),
).map(({ t, ...p }) => ({ t, style: transform(p) }));
return [
diff --git a/packages/svg-creator/stack.ts b/packages/svg-creator/stack.ts
index 556fdac..58b9a9f 100644
--- a/packages/svg-creator/stack.ts
+++ b/packages/svg-creator/stack.ts
@@ -11,7 +11,7 @@ export const createStack = (
{ sizeDot }: Options,
width: number,
y: number,
- duration: number
+ duration: number,
) => {
const svgElements: string[] = [];
const styles = [
@@ -51,7 +51,7 @@ export const createStack = (
width: (ts.length * m + 0.6).toFixed(1),
x,
y,
- })
+ }),
);
styles.push(
@@ -68,7 +68,7 @@ export const createStack = (
].map(({ scale, t }) => ({
t,
style: `transform:scale(${scale.toFixed(3)},1)`,
- }))
+ })),
),
`.u.${id} {
@@ -76,7 +76,7 @@ export const createStack = (
animation-name: ${animationName};
transform-origin: ${x}px 0
}
- `
+ `,
);
}
diff --git a/packages/types/__tests__/snake.spec.ts b/packages/types/__tests__/snake.spec.ts
index 00f5a99..09ff926 100644
--- a/packages/types/__tests__/snake.spec.ts
+++ b/packages/types/__tests__/snake.spec.ts
@@ -30,7 +30,7 @@ it("should return next snake", () => {
];
expect(snakeToCells(nextSnake(createSnakeFromCells(snk0), 1, 0))).toEqual(
- snk1
+ snk1,
);
});
diff --git a/packages/types/grid.ts b/packages/types/grid.ts
index 4b041d5..1cd5a11 100644
--- a/packages/types/grid.ts
+++ b/packages/types/grid.ts
@@ -30,7 +30,7 @@ export const setColor = (
grid: Grid,
x: number,
y: number,
- color: Color | Empty
+ color: Color | Empty,
) => {
grid.data[getIndex(grid, x, y)] = color || 0;
};
diff --git a/packages/types/randomlyFillGrid.ts b/packages/types/randomlyFillGrid.ts
index 3daf811..339581b 100644
--- a/packages/types/randomlyFillGrid.ts
+++ b/packages/types/randomlyFillGrid.ts
@@ -9,7 +9,7 @@ export const randomlyFillGrid = (
colors = [1, 2, 3] as Color[],
emptyP = 2,
}: { colors?: Color[]; emptyP?: number } = {},
- rand = defaultRand
+ rand = defaultRand,
) => {
for (let x = grid.width; x--; )
for (let y = grid.height; y--; ) {