Skip to content

Commit

Permalink
πŸ› Fix png endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wei committed Apr 11, 2024
1 parent 3760dcc commit ca40cc2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions common/renderPNG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import resvgWasm from '../public/resvg_bg.wasm?module'
import renderCardSVG from './renderSVG'
import QueryType from './types/queryType'

const initResvgWasm = resvg.initWasm(resvgWasm)
let resvgInitialized = false

const renderCardPNG = async (query: QueryType) => {
const [svg] = await Promise.all([renderCardSVG(query), initResvgWasm])

async function initResvg() {
if (!resvgInitialized) {
await resvg.initWasm(resvgWasm)
resvgInitialized = true
}
}

const [svg] = await Promise.all([renderCardSVG(query), initResvg()])

const resvgJS = new resvg.Resvg(svg, {
fitTo: {
Expand Down

0 comments on commit ca40cc2

Please sign in to comment.