fix(theme): remove webfontloader Public Sans path (AD-2.5-T1 completion)

P2 reverted CSS font-family to Inter but missed the JS font-loading
path: src/plugins/webfontloader.ts loaded Public Sans from Google
Fonts via WebFont.load(). The wf-publicsans-n4-active class on <html>
(found during P5 manual smoke) proved Public Sans was still loaded at
runtime, plus an external Google Fonts CDN request — both contrary to
AD-2.5-T1 (local @fontsource/inter, no CDN).

Audit context: the plugin was auto-registered via the Vuexy
registerPlugins() glob (src/@core/utils/plugins.ts walks
plugins/*.{ts,js}). No explicit import / call site to delete — file
removal is enough. The plugin only ever loaded Public Sans (no other
families), so full deletion is correct.

Changes:
- Removed src/plugins/webfontloader.ts (auto-registration falls away
  with the file itself; no manual unregister needed).
- Removed webfontloader (1.6.28) + @types/webfontloader (1.6.38) from
  package.json / pnpm-lock.yaml.
- Strengthened tests/unit/styles/typography.spec.ts with a new
  describe block that scans every src/plugins/*.ts for: any
  webfontloader reference, any WebFont.load call, any "Public Sans"
  spelling, any fonts.googleapis.com URL. Plus a regression-lock
  spec asserting webfontloader.ts itself stays deleted.

Suite delta: 552 → 554 (+2 new JS-path specs). vue-tsc clean.
Scoped ESLint clean (0 errors).

Manual smoke pending (Bert): hard-reload /v2/dashboard, confirm
- wf-publicsans-* and wf-active classes are gone from <html>
- computed font-family on body text starts with "Inter"
- Network tab has no fonts.googleapis.com request

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-20 22:25:28 +02:00
parent 30be9aa331
commit 641ca5131d
4 changed files with 40 additions and 38 deletions

View File

@@ -73,7 +73,6 @@
"vue3-perfect-scrollbar": "2.0.0",
"vuedraggable": "^4.1.0",
"vuetify": "3.10.8",
"webfontloader": "1.6.28",
"zod": "3"
},
"devDependencies": {
@@ -116,7 +115,6 @@
"@types/mapbox-gl": "3.4.1",
"@types/node": "24.9.2",
"@types/qrcode": "^1.5.6",
"@types/webfontloader": "1.6.38",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"@vitejs/plugin-vue": "6.0.1",

View File

@@ -162,9 +162,6 @@ importers:
vuetify:
specifier: 3.10.8
version: 3.10.8(typescript@5.9.3)(vite-plugin-vuetify@2.1.2)(vue@3.5.22(typescript@5.9.3))
webfontloader:
specifier: 1.6.28
version: 1.6.28
zod:
specifier: '3'
version: 3.25.76
@@ -286,9 +283,6 @@ importers:
'@types/qrcode':
specifier: ^1.5.6
version: 1.5.6
'@types/webfontloader':
specifier: 1.6.38
version: 1.6.38
'@typescript-eslint/eslint-plugin':
specifier: 7.18.0
version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.9.3))(eslint@8.57.1)(typescript@5.9.3)
@@ -2262,9 +2256,6 @@ packages:
'@types/web-bluetooth@0.0.20':
resolution: {integrity: sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==}
'@types/webfontloader@1.6.38':
resolution: {integrity: sha512-kUaF72Fv202suFx6yBrwXqeVRMx7hGtJTesyESZgn9sEPCUeDXm2p0SiyS1MTqW74nQP4p7JyrOCwZ7pNFns4w==}
'@types/whatwg-mimetype@3.0.2':
resolution: {integrity: sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==}
@@ -6416,9 +6407,6 @@ packages:
resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}
engines: {node: '>=18'}
webfontloader@1.6.28:
resolution: {integrity: sha512-Egb0oFEga6f+nSgasH3E0M405Pzn6y3/9tOVanv/DLfa1YBIgcv90L18YyWnvXkRbIM17v5Kv6IT2N6g1x5tvQ==}
webidl-conversions@8.0.1:
resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}
engines: {node: '>=20'}
@@ -8348,8 +8336,6 @@ snapshots:
'@types/web-bluetooth@0.0.20': {}
'@types/webfontloader@1.6.38': {}
'@types/whatwg-mimetype@3.0.2': {}
'@types/ws@8.18.1':
@@ -13207,8 +13193,6 @@ snapshots:
dependencies:
xml-name-validator: 5.0.0
webfontloader@1.6.28: {}
webidl-conversions@8.0.1: {}
webpack-virtual-modules@0.6.2: {}

View File

@@ -1,19 +0,0 @@
/**
* plugins/webfontloader.js
*
* webfontloader documentation: https://github.com/typekit/webfontloader
*/
export async function loadFonts() {
const webFontLoader = await import(/* webpackChunkName: "webfontloader" */'webfontloader')
webFontLoader.load({
google: {
families: ['Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap'],
},
})
}
export default function () {
loadFonts()
}

View File

@@ -16,7 +16,7 @@
* If either file is moved, update the path constants below.
*/
import { readFileSync } from 'node:fs'
import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
@@ -30,9 +30,24 @@ const VUEXY_VARIABLES_PATH = resolve(
'../../../src/@core/scss/template/libs/vuetify/_variables.scss',
)
const PLUGINS_DIR = resolve(__dirname, '../../../src/plugins')
const tailwindCss = readFileSync(TAILWIND_CSS_PATH, 'utf-8')
const vuexyVariables = readFileSync(VUEXY_VARIABLES_PATH, 'utf-8')
/**
* All TypeScript plugin files under `apps/app/src/plugins/`, flat-only (the
* `registerPlugins` glob also picks up `plugins/*\/index.ts`, but those
* sub-plugins are folder-namespaced and unlikely to load fonts — flat
* coverage matches where webfontloader.ts lived and where any future
* font-loading regression would most likely surface).
*/
const pluginFiles: Array<{ path: string; content: string }> = existsSync(PLUGINS_DIR)
? readdirSync(PLUGINS_DIR)
.filter(f => f.endsWith('.ts'))
.map(f => ({ path: f, content: readFileSync(resolve(PLUGINS_DIR, f), 'utf-8') }))
: []
/**
* Pulls every `font-family: …;` or `--<name>font<name>: …;` declaration
* from a CSS source. Skips `var(...)` indirections — those are pointers
@@ -91,3 +106,27 @@ describe('Typography regression lock (AD-2.5-T1)', () => {
expect(vuexyVariables).not.toMatch(/public-sans/i)
})
})
/**
* AD-2.5-T1 completion (P2-followup): the JS font-loading path.
*
* P2 inspected CSS only and missed `src/plugins/webfontloader.ts`, which
* loaded Public Sans from the Google Fonts CDN via WebFont.load(). This
* block locks the JS path so the same drift cannot recur: no plugin may
* load fonts via webfontloader, the Google Fonts CDN, or reference
* Public Sans by any spelling.
*/
describe('Typography regression lock — JS font-loading path (AD-2.5-T1 completion)', () => {
it('no plugin loads fonts via webfontloader / Google Fonts CDN / Public Sans', () => {
for (const { path, content } of pluginFiles) {
expect(content, `${path} references webfontloader`).not.toMatch(/webfontloader/i)
expect(content, `${path} calls WebFont.load`).not.toMatch(/WebFont\.load/)
expect(content, `${path} references Public Sans`).not.toMatch(/Public.?Sans/i)
expect(content, `${path} references fonts.googleapis.com`).not.toMatch(/fonts\.googleapis\.com/)
}
})
it('webfontloader.ts plugin no longer exists', () => {
expect(existsSync(resolve(PLUGINS_DIR, 'webfontloader.ts'))).toBe(false)
})
})