Skip to content

Commit 94f1d7b

Browse files
committed
fix(cards): migrate Takumi renderer to v2
1 parent daab023 commit 94f1d7b

5 files changed

Lines changed: 99 additions & 81 deletions

File tree

.changeset/wise-cards-shine.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"skycrypt-frontend": patch
3+
---
4+
5+
Restore generated card fonts and keyed images under Takumi v2.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"@sentry/sveltekit": "^10.58.0",
129129
"culori": "^4.0.2",
130130
"simple-git-hooks": "^2.13.1",
131-
"takumi-js": "^1.8.5"
131+
"takumi-js": "^2.0.2"
132132
},
133133
"engines": {
134134
"node": "^24",

pnpm-lock.yaml

Lines changed: 79 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/components/cards/default/Base.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
...settings
3131
});
3232
33-
// The persistent image is referenced via background-image CSS rather than
33+
// The per-render keyed image is referenced via background-image CSS rather than
3434
// an absolutely-positioned <img>: takumi-js 1.1.x reworked inline-formatting-
3535
// context detection (commit adc48da, "Treat absolute/floated children as
3636
// out-of-flow"), which left the previous <img class="absolute inset-0">

src/routes/stats/[ign]/[[profile]]/card/+server.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ import type { RequestHandler } from "./$types";
1414

1515
const { PUBLIC_ORIGIN: baseUrl } = env;
1616

17-
const { fonts, persistentImages } = await initializeAssets();
17+
const { fonts, images } = await initializeAssets();
1818

19-
const renderer = new Renderer({
20-
fonts,
21-
persistentImages
22-
});
19+
const renderer = new Renderer();
2320

2421
export const GET: RequestHandler = async ({ params, request, url }) => {
2522
const { ign, profile } = params;
@@ -73,15 +70,13 @@ export const GET: RequestHandler = async ({ params, request, url }) => {
7370
},
7471
stylesheets: [appStyles],
7572
emoji: "twemoji",
73+
fonts,
74+
images,
7675
renderer
7776
});
7877

79-
const response = new Response(await imageResponse.arrayBuffer(), {
80-
status: imageResponse.status,
81-
statusText: imageResponse.statusText,
82-
headers: imageResponse.headers
83-
});
84-
return response;
78+
await imageResponse.ready;
79+
return imageResponse;
8580
} catch (error) {
8681
console.error("Error generating image:", error);
8782
try {
@@ -98,13 +93,13 @@ export const GET: RequestHandler = async ({ params, request, url }) => {
9893
},
9994
stylesheets: [appStyles],
10095
emoji: "twemoji",
96+
fonts,
97+
images,
10198
renderer
10299
});
103100

104-
return new Response(await errorResponse.arrayBuffer(), {
105-
status: 200,
106-
headers: errorResponse.headers
107-
});
101+
await errorResponse.ready;
102+
return errorResponse;
108103
} catch (error) {
109104
console.error("Error generating error image:", error);
110105
return new Response("Internal Server Error", { status: 500 });
@@ -113,7 +108,7 @@ export const GET: RequestHandler = async ({ params, request, url }) => {
113108
};
114109

115110
async function initializeAssets() {
116-
if (building) return { fonts: [], persistentImages: [] };
111+
if (building) return { fonts: [], images: [] };
117112
const [
118113
// prettier-ignore
119114
montserratNormalBuffer,
@@ -139,7 +134,7 @@ async function initializeAssets() {
139134
}
140135
];
141136

142-
const persistentImages: ImageSource[] = [
137+
const images: ImageSource[] = [
143138
{
144139
src: "skycrypt-logo",
145140
data: skycryptLogo
@@ -150,5 +145,5 @@ async function initializeAssets() {
150145
}
151146
];
152147

153-
return { fonts, persistentImages };
148+
return { fonts, images };
154149
}

0 commit comments

Comments
 (0)