Skip to content

Commit c815a5d

Browse files
committed
fix: experimentally swap napi-rs/canvas to canvas
This is an EXPERIMENTAL pull request to see if swapping the libs would fix the issue where badges text is not measured correctly. Continuation of npmx-dev#1584
1 parent c52d259 commit c815a5d

File tree

4 files changed

+17
-129
lines changed

4 files changed

+17
-129
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"@iconify-json/vscode-icons": "1.2.43",
6262
"@intlify/shared": "11.2.8",
6363
"@lunariajs/core": "https://pkg.pr.new/lunariajs/lunaria/@lunariajs/core@904b935",
64-
"@napi-rs/canvas": "0.1.94",
6564
"@nuxt/a11y": "1.0.0-alpha.1",
6665
"@nuxt/fonts": "0.14.0",
6766
"@nuxt/scripts": "0.13.2",
@@ -83,6 +82,7 @@
8382
"@vueuse/router": "^14.2.1",
8483
"@vueuse/shared": "14.2.1",
8584
"algoliasearch": "5.49.0",
85+
"canvas": "^3.2.1",
8686
"defu": "6.1.4",
8787
"fast-npm-meta": "1.2.1",
8888
"focus-trap": "^8.0.0",

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ignoredBuiltDependencies:
1717
onlyBuiltDependencies:
1818
- '@resvg/resvg-js'
1919
- better-sqlite3
20+
- canvas
2021
- sharp@0.34.5
2122
- simple-git-hooks@2.13.1
2223

server/api/registry/badge/[type]/[...pkg].get.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as v from 'valibot'
2-
import { createCanvas, type SKRSContext2D } from '@napi-rs/canvas'
2+
import { createCanvas, type CanvasRenderingContext2D } from 'canvas'
33
import { hash } from 'ohash'
44
import { createError, getRouterParam, getQuery, setHeader } from 'h3'
55
import { PackageRouteParamsSchema } from '#shared/schemas/package'
@@ -45,9 +45,9 @@ const SHIELDS_LABEL_PADDING_X = 5
4545
const BADGE_FONT_SHORTHAND = 'normal normal 400 11px Geist, system-ui, -apple-system, sans-serif'
4646
const SHIELDS_FONT_SHORTHAND = 'normal normal 400 11px Verdana, Geneva, DejaVu Sans, sans-serif'
4747

48-
let cachedCanvasContext: SKRSContext2D | null | undefined
48+
let cachedCanvasContext: CanvasRenderingContext2D | null | undefined
4949

50-
function getCanvasContext(): SKRSContext2D | null {
50+
function getCanvasContext(): CanvasRenderingContext2D | null {
5151
if (cachedCanvasContext !== undefined) {
5252
return cachedCanvasContext
5353
}

0 commit comments

Comments
 (0)