Files
meshcore-analyzer/scripts/instrument-frontend.sh
T
Kpa-clawbot eae1b915ca feat: load Aldrich webfont for #1137 logo SVG (#1138)
Adds Aldrich webfont so the merged #1137 logo renders in the intended
typeface.

## Problem
The inline SVG logo merged in #1137 declares `font-family="Aldrich,
monospace"` in `public/index.html` and `public/home.js`, but the page
never loaded the Aldrich font face. Browsers silently fell back to
monospace.

## Fix
Self-hosted webfont:
- `public/fonts/aldrich-regular.woff2` — Regular 400, ~16KB, downloaded
from Google Fonts (latin subset). Self-hosted to avoid third-party CDN
dependency, privacy concern, and FOUT delay.
- `@font-face` declaration added at the top of `public/style.css` with
`font-display: swap`.

Aldrich only ships in 400; the SVG `font-weight="700"` on the wordmark
synthesizes bold (matches the design intent of #1137).

## TDD
- Red commit: E2E test asserting `document.fonts.check('1em Aldrich')`
is true and the navbar SVG `<text>` `font-family` contains "Aldrich".
Without the font face declaration, both assertions fail on an assertion
(not a build error).
- Green commit: adds the woff2 + `@font-face` rule, both assertions
pass.

## Files
- `public/fonts/aldrich-regular.woff2` (new, 16460 bytes)
- `public/style.css` — `@font-face` rule
- `test-e2e-playwright.js` — new test

---------

Co-authored-by: openclaw-bot <bot@openclaw.local>
2026-05-06 21:24:57 -07:00

38 lines
1.9 KiB
Bash

#!/bin/sh
# Instrument frontend JS for coverage tracking
rm -rf public-instrumented
npx nyc instrument public/ public-instrumented/ --compact=false
# Copy non-JS files (CSS, HTML, images) as-is
cp public/*.css public-instrumented/ 2>/dev/null
cp public/*.html public-instrumented/ 2>/dev/null
cp public/*.svg public-instrumented/ 2>/dev/null
cp public/*.png public-instrumented/ 2>/dev/null
# Copy nested asset directories (e.g. public/img/*.svg used by the new
# CoreScope logo + hero). nyc instrument skips non-JS subdirs entirely,
# so without this the SPA fallback would serve index.html for
# `/img/corescope-logo.svg`, breaking the navbar logo + the
# logo-rebrand E2E (the content-type assertion catches this cleanly).
if [ -d public/img ]; then
mkdir -p public-instrumented/img
cp -r public/img/. public-instrumented/img/
fi
# Copy webfonts (e.g. public/fonts/aldrich-regular.woff2 used by the
# navbar logo SVG @font-face, #1137 follow-up). Same SPA-fallback gotcha
# as /img — without this, GET /fonts/aldrich-regular.woff2 returns
# index.html and the @font-face download fails silently, so the logo
# falls back to monospace and the Aldrich E2E assertion fails.
if [ -d public/fonts ]; then
mkdir -p public-instrumented/fonts
cp -r public/fonts/. public-instrumented/fonts/
fi
# Copy vendored libraries unmodified — `nyc instrument` skips subdirectories
# without a package.json, so vendor/qrcode.js, vendor/jsqr.min.js, etc. are
# never emitted into public-instrumented/. Without them the SPA fallback
# returns index.html for `<script src="vendor/qrcode.js">`, producing
# "Unexpected token '<'" pageerrors and a missing `qrcode` global —
# which makes the QR Generate path hit the "[QR library not loaded]"
# fallback in channel-qr.js (issue #1087 bug 1 manifests in CI only).
mkdir -p public-instrumented/vendor
cp public/vendor/* public-instrumented/vendor/ 2>/dev/null
echo "Frontend instrumented successfully"