Skip to content

Commit

Permalink
feat(deps): upgrade to latest Capsize packages (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto authored Feb 23, 2024
1 parent 65410d6 commit f8d28c2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
cache: "pnpm"

- name: 📦 Install dependencies
Expand All @@ -34,7 +34,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
cache: "pnpm"

- name: 📦 Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"test": "vitest run"
},
"dependencies": {
"@capsizecss/metrics": "^1.2.0",
"@capsizecss/unpack": "^1.0.0",
"@capsizecss/metrics": "^2.0.0",
"@capsizecss/unpack": "^2.0.0",
"magic-regexp": "^0.7.0",
"magic-string": "^0.30.5",
"pathe": "^1.1.1",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fileURLToPath } from 'node:url'
import { fromFile, fromUrl, Font } from '@capsizecss/unpack'
// @ts-expect-error TODO: fix upstream typings
import { fontFamilyToCamelCase } from '@capsizecss/metrics'
import { parseURL } from 'ufo'
import { FontFaceMetrics, withoutQuotes } from './css'
Expand Down Expand Up @@ -31,9 +30,8 @@ export async function getMetricsForFamily(family: string) {

try {
const name = fontFamilyToCamelCase(family)
// @ts-expect-error TODO: fix upstream typings
const { entireMetricsCollection } = await import(
'@capsizecss/metrics/entireMetricsCollection/dist/capsizecss-metrics-entireMetricsCollection.cjs.js'
'@capsizecss/metrics/entireMetricsCollection'
)
const metrics =
entireMetricsCollection[name as keyof typeof entireMetricsCollection]
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('fontaine', () => {
// @ts-expect-error there must be a file or we _want_ a test failure
const css = await readFile(join(assetsDir, cssFile), 'utf-8')
expect(css.replace(/\.[\w]+\.woff2/g, '.woff2')).toMatchInlineSnapshot(`
"@font-face{font-family:Poppins variant fallback;src:local("Segoe UI");size-adjust:113.4764%;ascent-override:92.5303%;descent-override:30.8434%;line-gap-override:8.8124%}@font-face{font-family:Poppins variant fallback;src:local("Arial");size-adjust:113.7274%;ascent-override:92.326%;descent-override:30.7753%;line-gap-override:8.793%}@font-face{font-family:Poppins variant;font-display:swap;src:url(/assets/font-CTKNfV9P.ttf) format("truetype")}@font-face{font-family:Roboto fallback;src:local("Segoe UI");size-adjust:99.8896%;ascent-override:92.8759%;descent-override:24.441%;line-gap-override:0%}@font-face{font-family:Roboto fallback;src:local("Arial");size-adjust:100.1106%;ascent-override:92.6709%;descent-override:24.3871%;line-gap-override:0%}@font-face{font-family:Roboto;font-display:swap;src:url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu72xKKTU1Kvnz.woff2) format("woff2")}@font-face{font-family:Inter fallback;src:local("Segoe UI");size-adjust:107.1644%;ascent-override:90.3985%;descent-override:22.5334%;line-gap-override:0%}@font-face{font-family:Inter fallback;src:local("Arial");size-adjust:107.4014%;ascent-override:90.199%;descent-override:22.4836%;line-gap-override:0%}@font-face{font-family:Inter;font-display:swap;src:url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format("woff2")}:root{--someFont: "Poppins variant", "Poppins variant fallback"}h1{font-family:Poppins variant,Poppins variant fallback,sans-serif}.roboto{font-family:Roboto,Roboto fallback,Arial,Helvetica,sans-serif}p{font-family:Poppins variant,Poppins variant fallback}div{font-family:var(--someFont)}.inter{font-family:Inter,Inter fallback}
"@font-face{font-family:Poppins variant fallback;src:local("Segoe UI");size-adjust:114.4346%;ascent-override:91.7554%;descent-override:30.5851%;line-gap-override:8.7386%}@font-face{font-family:Poppins variant fallback;src:local("Arial");size-adjust:113.8478%;ascent-override:92.2284%;descent-override:30.7428%;line-gap-override:8.7837%}@font-face{font-family:Poppins variant;font-display:swap;src:url(/assets/font-CTKNfV9P.ttf) format("truetype")}@font-face{font-family:Roboto fallback;src:local("Segoe UI");size-adjust:101.4433%;ascent-override:91.4535%;descent-override:24.0667%;line-gap-override:0%}@font-face{font-family:Roboto fallback;src:local("Arial");size-adjust:100.9231%;ascent-override:91.9249%;descent-override:24.1908%;line-gap-override:0%}@font-face{font-family:Roboto;font-display:swap;src:url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu72xKKTU1Kvnz.woff2) format("woff2")}@font-face{font-family:Inter fallback;src:local("Segoe UI");size-adjust:108.1912%;ascent-override:89.5406%;descent-override:22.3195%;line-gap-override:0%}@font-face{font-family:Inter fallback;src:local("Arial");size-adjust:107.6364%;ascent-override:90.0021%;descent-override:22.4345%;line-gap-override:0%}@font-face{font-family:Inter;font-display:swap;src:url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2) format("woff2")}:root{--someFont: "Poppins variant", "Poppins variant fallback"}h1{font-family:Poppins variant,Poppins variant fallback,sans-serif}.roboto{font-family:Roboto,Roboto fallback,Arial,Helvetica,sans-serif}p{font-family:Poppins variant,Poppins variant fallback}div{font-family:var(--someFont)}.inter{font-family:Inter,Inter fallback}
"
`)
})
Expand Down
18 changes: 9 additions & 9 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('getMetricsForFamily', () => {
"descent": -546,
"lineGap": 0,
"unitsPerEm": 2000,
"xWidthAvg": 936,
"xWidthAvg": 1056,
}
`)
// Test cache
Expand All @@ -69,9 +69,9 @@ describe('getMetricsForFamily', () => {
"@font-face {
font-family: "Merriweather Sans fallback";
src: local("Arial");
size-adjust: 106.0248%;
ascent-override: 92.8085%;
descent-override: 25.7487%;
size-adjust: 110.9071%;
ascent-override: 88.7229%;
descent-override: 24.6152%;
line-gap-override: 0%;
}
"
Expand Down Expand Up @@ -103,9 +103,9 @@ describe('getMetricsForFamily', () => {
"@font-face {
font-family: "IBM Plex Mono fallback";
src: local("Arial");
size-adjust: 135.9292%;
ascent-override: 75.4069%;
descent-override: 20.2311%;
size-adjust: 126.0308%;
ascent-override: 81.3293%;
descent-override: 21.8201%;
line-gap-override: 0%;
}
"
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('readMetrics', () => {
"descent": -350,
"lineGap": 100,
"unitsPerEm": 1000,
"xWidthAvg": 502,
"xWidthAvg": 542,
}
`)
})
Expand All @@ -153,7 +153,7 @@ describe('readMetrics', () => {
"descent": -350,
"lineGap": 100,
"unitsPerEm": 1000,
"xWidthAvg": 502,
"xWidthAvg": 542,
}
`)
server.close()
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"target": "ESNext",
"module": "ESNext",
"strict": true,
"moduleResolution": "Node",
"moduleResolution": "Bundler",
"esModuleInterop": true
}
}

0 comments on commit f8d28c2

Please sign in to comment.