Skip to content

Commit 4829516

Browse files
authored
⬆️ Upgrade satori to 0.18.3 (#769)
1 parent 507ed9f commit 4829516

5 files changed

Lines changed: 26 additions & 41 deletions

File tree

.changeset/upgrade-satori.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"socialify": patch
3+
---
4+
5+
Upgrade satori from 0.15.2 to 0.18.3
6+
7+
- Simplified renderSVG.tsx by removing manual yoga-wasm-web initialization (satori now bundles WASM internally)
8+
- Removed yoga-wasm-web dependency
9+
- Updated postinstall script to no longer copy yoga.wasm

common/renderSVG.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
1-
// @ts-ignore
2-
import satori, { init as initSatori } from 'satori/wasm'
3-
// @ts-ignore
4-
import initYoga from 'yoga-wasm-web'
1+
import satori from 'satori'
52

63
import { autoThemeCss } from '@/common/helpers'
74
import { getCardConfig, getFonts, loadDynamicAsset } from '@/common/renderCard'
85
import { Theme } from '@/common/types/configType'
96
import type QueryType from '@/common/types/queryType'
107
import Card from '@/src/components/preview/card'
11-
// @ts-ignore: Not a typical module, using import alias will cause an error.
12-
import yogaWasm from '../public/yoga.wasm?module'
13-
14-
// Module-level WASM initialization - cached across warm FaaS invocations
15-
let yogaInitPromise: Promise<void> | null = null
16-
17-
const initYogaWasm = async () => {
18-
if (!yogaInitPromise) {
19-
yogaInitPromise = (async () => {
20-
const yoga = await initYoga(yogaWasm)
21-
initSatori(yoga)
22-
})()
23-
}
24-
return yogaInitPromise
25-
}
268

279
const renderCardSVG = async (query: QueryType) => {
28-
await initYogaWasm()
29-
3010
const config = await getCardConfig(query)
3111

3212
if (config.theme === Theme.auto) {

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"ncu": "npx npm-check-updates -u",
3030
"verify": "pnpm lint && pnpm test:unit && pnpm build",
3131
"playwright:install": "pnpm playwright install --with-deps chromium",
32-
"postinstall": "mkdir -p ./public && cp ./node_modules/yoga-wasm-web/dist/yoga.wasm ./public/yoga.wasm && cp ./node_modules/@resvg/resvg-wasm/index_bg.wasm ./public/resvg_bg.wasm",
32+
"postinstall": "mkdir -p ./public && cp ./node_modules/@resvg/resvg-wasm/index_bg.wasm ./public/resvg_bg.wasm",
3333
"prepare": "is-ci || husky"
3434
},
3535
"engines": {
@@ -49,11 +49,10 @@
4949
"react-dom": "19.2.3",
5050
"react-hot-toast": "^2.6.0",
5151
"react-icons": "^5.5.0",
52-
"satori": "^0.15.2",
52+
"satori": "^0.18.3",
5353
"server-only": "^0.0.1",
5454
"simple-icons": "^16.3.0",
55-
"use-debounce": "^10.0.6",
56-
"yoga-wasm-web": "^0.3.3"
55+
"use-debounce": "^10.0.6"
5756
},
5857
"devDependencies": {
5958
"@biomejs/biome": "^2.3.10",

pnpm-lock.yaml

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

public/yoga.wasm

-86.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)