Skip to content

Commit 281a685

Browse files
authored
Merge branch 'main' into 09-28-feat_fontless_ability_to_remove_google_font_for_old_browser
2 parents e4cade4 + d66809d commit 281a685

30 files changed

+1329
-3584
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: release-preview
1+
name: release
22

33
on:
44
push:
@@ -8,19 +8,21 @@ on:
88
types: [opened, synchronize, labeled]
99

1010
jobs:
11-
release-preview:
11+
pkg-pr-new:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v5
15-
with:
16-
fetch-depth: 0
17-
14+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1815
- run: corepack enable
19-
- uses: actions/setup-node@v5
16+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2017
with:
2118
node-version: lts/*
2219
cache: pnpm
2320

24-
- run: pnpm install
25-
- run: pnpm build
26-
- run: pnpm dlx pkg-pr-new publish --compact packages/fontless packages/fontaine
21+
- name: 📦 install dependencies
22+
run: pnpm install
23+
24+
- name: 🛠 build project
25+
run: pnpm build
26+
27+
- name: 📦 publish nightly release
28+
run: pnpm pkg-pr-new publish --compact packages/fontless packages/fontaine

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
"changelogithub": "13.16.0",
2626
"eslint": "9.36.0",
2727
"installed-check": "9.3.0",
28-
"knip": "5.64.0",
29-
"lint-staged": "16.2.0",
28+
"knip": "5.64.1",
29+
"lint-staged": "16.2.3",
30+
"pkg-pr-new": "0.0.60",
3031
"simple-git-hooks": "2.13.1",
3132
"typescript": "5.9.2"
3233
},

packages/fontaine/build.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import fs from 'node:fs'
2+
import { defineBuildConfig } from 'unbuild'
3+
4+
export default defineBuildConfig({
5+
hooks: {
6+
'build:done': async function () {
7+
const { entireMetricsCollection } = await import('@capsizecss/metrics/entireMetricsCollection')
8+
const output = `export const entireMetricsCollection = ${JSON.stringify(entireMetricsCollection)}`
9+
fs.writeFileSync('dist/capsize-font-metrics.mjs', output)
10+
},
11+
},
12+
})

packages/fontaine/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"performance"
2222
],
2323
"sideEffects": false,
24+
"imports": {
25+
"#capsize-font-metrics": "./dist/capsize-font-metrics.mjs"
26+
},
2427
"exports": {
2528
".": {
2629
"import": "./dist/index.mjs",
@@ -47,7 +50,6 @@
4750
"test": "vitest run"
4851
},
4952
"dependencies": {
50-
"@capsizecss/metrics": "^3.5.0",
5153
"@capsizecss/unpack": "^3.0.0",
5254
"css-tree": "^3.1.0",
5355
"magic-regexp": "^0.10.0",
@@ -57,8 +59,9 @@
5759
"unplugin": "^2.3.10"
5860
},
5961
"devDependencies": {
62+
"@capsizecss/metrics": "3.5.0",
6063
"@types/css-tree": "2.3.10",
61-
"@types/node": "22.18.6",
64+
"@types/node": "22.18.7",
6265
"@types/serve-handler": "6.1.4",
6366
"@vitest/coverage-v8": "3.2.4",
6467
"eslint": "9.36.0",

packages/fontaine/src/metrics.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Font } from '@capsizecss/unpack'
22
import type { FontFaceMetrics } from './css'
33

44
import { fileURLToPath } from 'node:url'
5-
import { fontFamilyToCamelCase } from '@capsizecss/metrics'
65
import { fromFile, fromUrl } from '@capsizecss/unpack'
76
import { parseURL } from 'ufo'
87

@@ -34,7 +33,7 @@ export async function getMetricsForFamily(family: string) {
3433

3534
try {
3635
const name = fontFamilyToCamelCase(family)
37-
const { entireMetricsCollection } = await import('@capsizecss/metrics/entireMetricsCollection')
36+
const { entireMetricsCollection } = await import('#capsize-font-metrics') as any as typeof import('@capsizecss/metrics/entireMetricsCollection')
3837
const metrics = entireMetricsCollection[name as keyof typeof entireMetricsCollection]
3938

4039
/* v8 ignore next 4 */
@@ -92,3 +91,16 @@ export async function readMetrics(_source: URL | string) {
9291
metricCache[source] = filteredMetrics
9392
return filteredMetrics
9493
}
94+
95+
// inline `@capsizecss/metrics`
96+
// https://github.com/seek-oss/capsize/blob/66344699ff7759a661a78d0629375714c6f308b0/packages/metrics/src/index.ts
97+
function fontFamilyToCamelCase(str: string) {
98+
return str
99+
.split(/[\s|-]/)
100+
.filter(Boolean)
101+
.map(
102+
(s, i) =>
103+
`${s.charAt(0)[i > 0 ? 'toUpperCase' : 'toLowerCase']()}${s.slice(1)}`,
104+
)
105+
.join('')
106+
}

packages/fontless/examples/remix-app/.gitignore renamed to packages/fontless/examples/react-router-app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22

33
/.cache
44
/build
5+
/.react-router
56
.env

packages/fontless/examples/remix-app/app/routes/styles/styles.css renamed to packages/fontless/examples/react-router-app/app/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
:root {
2+
color: rgba(255, 255, 255, 0.87);
3+
background-color: #242424;
4+
}
5+
16
p {
27
font-size: x-large;
38
}

packages/fontless/examples/remix-app/app/root.tsx renamed to packages/fontless/examples/react-router-app/app/root.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'
1+
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'
22

33
import './index.css'
44

@@ -9,6 +9,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
99
<meta charSet="utf-8" />
1010
<meta name="viewport" content="width=device-width, initial-scale=1" />
1111
<Meta />
12+
<Links />
1213
</head>
1314
<body>
1415
{children}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { RouteConfig } from '@react-router/dev/routes'
2+
import { index } from '@react-router/dev/routes'
3+
4+
export default [
5+
index('routes/_index.tsx'),
6+
] satisfies RouteConfig

0 commit comments

Comments
 (0)