Skip to content

Commit

Permalink
⬆️ update prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Platane committed Feb 20, 2025
1 parent 79c2523 commit ace186c
Showing 41 changed files with 94 additions and 94 deletions.
4 changes: 2 additions & 2 deletions bun.lock
Original file line number Diff line number Diff line change
@@ -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=="],

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Original file line number Diff line number Diff line change
@@ -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 },
);
18 changes: 9 additions & 9 deletions packages/action/__tests__/outputsOptions.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
})
}),
);
6 changes: 3 additions & 3 deletions packages/action/generateContributionSnake.ts
Original file line number Diff line number Diff line change
@@ -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,
);
}
}
})
}),
);
};
2 changes: 1 addition & 1 deletion packages/action/index.ts
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion packages/demo/canvas.ts
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion packages/demo/demo.getBestTunnel.ts
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ const tunnels = ones.map(({ x, y }) => ({
x,
y,
3 as Color,
getSnakeLength(snake)
getSnakeLength(snake),
),
}));

2 changes: 1 addition & 1 deletion packages/demo/demo.getPathToPose.ts
Original file line number Diff line number Diff line change
@@ -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)!];
8 changes: 4 additions & 4 deletions packages/demo/demo.interactive.ts
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ const createViewer = ({
: "") +
`<a href="${svgLink.href}" download="github-user-contribution.svg">` +
svgString +
"<a/>"
"<a/>",
);
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<WorkerAPI>(worker);
2 changes: 1 addition & 1 deletion packages/demo/menu.ts
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 4 additions & 4 deletions packages/demo/springUtils.ts
Original file line number Diff line number Diff line change
@@ -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;

8 changes: 4 additions & 4 deletions packages/demo/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -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],
2 changes: 1 addition & 1 deletion packages/demo/worker-utils.ts
Original file line number Diff line number Diff line change
@@ -54,6 +54,6 @@ export const createRpcClient = <API_ extends API>(worker: Worker) => {
worker.addEventListener("terminate", onTerminate);
worker.postMessage({ symbol, key, methodName, args });
}),
}
},
);
};
4 changes: 2 additions & 2 deletions packages/draw/drawCircleStack.ts
Original file line number Diff line number Diff line change
@@ -59,15 +59,15 @@ 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];

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
4 changes: 2 additions & 2 deletions packages/draw/drawGrid.ts
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 4 additions & 4 deletions packages/draw/drawSnake.ts
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 3 additions & 3 deletions packages/draw/drawWorld.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ export const drawStack = (
stack: Color[],
max: number,
width: number,
o: { colorDots: Record<Color, string> }
o: { colorDots: Record<Color, string> },
) => {
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();

2 changes: 1 addition & 1 deletion packages/draw/pathRoundedRect.ts
Original file line number Diff line number Diff line change
@@ -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);
Loading
Oops, something went wrong.

0 comments on commit ace186c

Please sign in to comment.