spark-html-font 0.1.3 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/package.json +3 -3
- package/src/index.js +7 -2
package/README.md
CHANGED
|
@@ -79,11 +79,12 @@ Top-level: `fallback` — generic families appended to every var stack
|
|
|
79
79
|
## The Spark family
|
|
80
80
|
|
|
81
81
|
Small, single-purpose packages that share one philosophy: no compiler, no
|
|
82
|
-
virtual DOM, no build step required
|
|
82
|
+
virtual DOM, no build step required — built for humans who love hand-writing
|
|
83
|
+
their web apps. Add only what you use.
|
|
83
84
|
|
|
84
85
|
| Package | What it does |
|
|
85
86
|
|---|---|
|
|
86
|
-
| [`spark-html`](https://www.npmjs.com/package/spark-html) | The runtime — components, reactivity, stores, forms, scoped styles.
|
|
87
|
+
| [`spark-html`](https://www.npmjs.com/package/spark-html) | The runtime — components, reactivity, stores, forms, scoped styles. ~14.4 kB gzip, 0 deps. |
|
|
87
88
|
| [`spark-html-bun`](https://www.npmjs.com/package/spark-html-bun) | Dev server, bundler & preview on Bun — scoped HMR, no-build dev, post-build pipeline. |
|
|
88
89
|
| [`spark-html-router`](https://www.npmjs.com/package/spark-html-router) | `<template route>` routing — nested routes/layouts, `route.query`, active links. |
|
|
89
90
|
| [`spark-html-theme`](https://www.npmjs.com/package/spark-html-theme) | Dark/light/system theming in one line — persisted, no flash. |
|
|
@@ -94,6 +95,7 @@ virtual DOM, no build step required. Add only what you use.
|
|
|
94
95
|
| [`spark-html-persist`](https://www.npmjs.com/package/spark-html-persist) | Persist stores to localStorage/sessionStorage in one line. |
|
|
95
96
|
| [`spark-html-websocket`](https://www.npmjs.com/package/spark-html-websocket) | A WebSocket as a reactive store — auto-reconnect, JSON, `send()`. |
|
|
96
97
|
| [`spark-prerender`](https://www.npmjs.com/package/spark-prerender) | Build-time SEO prerender + sitemap/robots — no SSR server. |
|
|
98
|
+
| [`spark-ssr`](https://www.npmjs.com/package/spark-ssr) | Full-stack SSR on Bun — the template is the backend: inferred DB, REST CRUD, auth, live updates. Precompiled + response-cached: fast by default. |
|
|
97
99
|
| [`spark-html-image`](https://www.npmjs.com/package/spark-html-image) | Build-time image optimization — webp/avif + responsive `srcset`, zero config. |
|
|
98
100
|
| [`spark-html-font`](https://www.npmjs.com/package/spark-html-font) | Font loading optimizer — preload + size-adjusted fallbacks, no FOUT. |
|
|
99
101
|
| [`spark-html-manifest`](https://www.npmjs.com/package/spark-html-manifest) | PWA manifest + icons + head tags (and optional service worker) from one config. |
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spark-html-font",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
4
|
"description": "Font loading optimizer for spark-html sites — @font-face + preload + size-adjusted fallbacks in one config, no FOUT, no layout shift. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
8
|
-
"homepage": "https://wilkinnovo.github.io/spark",
|
|
8
|
+
"homepage": "https://wilkinnovo.github.io/spark-html",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./src/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/wilkinnovo/spark.git",
|
|
26
|
+
"url": "git+https://github.com/wilkinnovo/spark-html.git",
|
|
27
27
|
"directory": "packages/spark-html-font"
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
package/src/index.js
CHANGED
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
* Zero dependencies; pure string generation plus a little DOM.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
// Approximate
|
|
28
|
+
// Approximate size-adjusted fallback metrics (fontaine-style) for popular
|
|
29
29
|
// families. Percentages; good enough to keep the swap from moving the page.
|
|
30
|
+
// Sans families adjust from Arial; mono families carry their own local basis
|
|
31
|
+
// (`from`) — Courier New is the metric-compatible mono every OS ships.
|
|
30
32
|
// Override per font with `metrics: { sizeAdjust, ascent, descent, lineGap }`.
|
|
31
33
|
const METRICS = {
|
|
32
34
|
'inter': { sizeAdjust: 107.4, ascent: 90.2, descent: 22.5, lineGap: 0 },
|
|
@@ -37,6 +39,9 @@ const METRICS = {
|
|
|
37
39
|
'poppins': { sizeAdjust: 112.2, ascent: 93.8, descent: 31.3, lineGap: 0 },
|
|
38
40
|
'nunito': { sizeAdjust: 101.9, ascent: 99.4, descent: 34.7, lineGap: 0 },
|
|
39
41
|
'source sans pro': { sizeAdjust: 94.1, ascent: 104.6, descent: 29.0, lineGap: 0 },
|
|
42
|
+
'jetbrains mono': { sizeAdjust: 100, ascent: 102, descent: 24.5, lineGap: 0, from: 'Courier New' },
|
|
43
|
+
'roboto mono': { sizeAdjust: 100, ascent: 104.8, descent: 27.1, lineGap: 0, from: 'Courier New' },
|
|
44
|
+
'source code pro': { sizeAdjust: 100, ascent: 98.4, descent: 27.3, lineGap: 0, from: 'Courier New' },
|
|
40
45
|
};
|
|
41
46
|
|
|
42
47
|
const slug = (family) => family.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
@@ -87,7 +92,7 @@ export function fontCss(config = {}) {
|
|
|
87
92
|
const m = font.metrics || METRICS[fam.toLowerCase()];
|
|
88
93
|
const stack = [`"${fam}"`];
|
|
89
94
|
if (m && font.adjust !== false) {
|
|
90
|
-
const local = font.adjustFrom || 'Arial';
|
|
95
|
+
const local = font.adjustFrom || m.from || 'Arial';
|
|
91
96
|
rules.push(
|
|
92
97
|
`@font-face { font-family: "${fam} Fallback"; src: local("${local}");` +
|
|
93
98
|
` size-adjust: ${m.sizeAdjust}%; ascent-override: ${m.ascent}%;` +
|