mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Chart fonts: self-hosted roster + document.fonts.load render gate
This commit is contained in:
+35
-4
@@ -56,13 +56,44 @@ export default defineConfig({
|
||||
],
|
||||
},
|
||||
workbox: {
|
||||
// Workbox's default globPatterns omit woff2; add it so the self-hosted
|
||||
// Plex fonts are precached too (offline is a core requirement — without
|
||||
// this the first offline load silently falls back to system fonts).
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
||||
// Precache the app, plus the font woff2 the offline-first UI and the
|
||||
// common chart path need:
|
||||
// - the bare `latin` subset of every family (`*-latin-[0-9]*` — the
|
||||
// weight digit excludes `latin-ext`), the common chart case;
|
||||
// - every subset of the UI fonts (IBM Plex Sans + Mono) — these are
|
||||
// capability: the chrome must render any script (incl. latin-ext,
|
||||
// Cyrillic, Greek) offline. The Sans brace-list names the subsets so
|
||||
// it matches the UI Sans but not `ibm-plex-sans-condensed-*`, a roster
|
||||
// chart font that stays latin-only like the rest.
|
||||
// Every other subset (the roster's latin-ext and non-latin scripts) is
|
||||
// decoration with per-glyph fallback: left out of the precache and
|
||||
// runtime-cached on first use below, so the install stays small while the
|
||||
// roster still works offline once a script has been seen. (Default
|
||||
// globPatterns omit woff2 entirely — without this the first offline load
|
||||
// silently falls back to system fonts.)
|
||||
globPatterns: [
|
||||
'**/*.{js,css,html,ico,png,svg}',
|
||||
'**/*-latin-[0-9]*.woff2',
|
||||
'**/ibm-plex-sans-{latin,latin-ext,cyrillic,cyrillic-ext,greek,greek-ext,vietnamese}-*.woff2',
|
||||
'**/ibm-plex-mono-*.woff2',
|
||||
],
|
||||
// Monaco and Vega vendor chunks exceed Workbox's 2 MiB default; raise the
|
||||
// ceiling so the whole app (offline is a core requirement) is precached.
|
||||
maximumFileSizeToCacheInBytes: 6 * 1024 * 1024,
|
||||
runtimeCaching: [
|
||||
{
|
||||
// Chart-roster non-latin font subsets: not precached, so fetch on
|
||||
// demand and keep them offline-after-first-use. Precached woff2
|
||||
// (latin + Plex) are served from the precache and never reach here.
|
||||
urlPattern: /\.woff2$/,
|
||||
handler: 'CacheFirst',
|
||||
options: {
|
||||
cacheName: 'chart-font-subsets',
|
||||
expiration: { maxEntries: 120, maxAgeSeconds: 60 * 60 * 24 * 365 },
|
||||
cacheableResponse: { statuses: [0, 200] },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user