hashquiz 1.0.0-beta.5 → 1.0.0-beta.6

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 CHANGED
@@ -61,6 +61,23 @@ can add `llms.txt` or `sitemap.xml`, or replace `og.png` and `robots.txt`. The `
61
61
  `robots.txt` appears only when `public/` holds a `sitemap.xml` and `HASHQUIZ_SITE_URL` is set.
62
62
  Background: [SEO audit](https://github.com/WhiteWoodTech/hashquiz/blob/develop/docs/SEO_AUDIT.md).
63
63
 
64
+ ### Theme
65
+
66
+ A `public/theme.css` restyles the site without forking the engine: `build` (and `dev` from the package) links it
67
+ last in the player and host pages, so a `:root` block there overrides the `--hq-*` tokens (colors, fonts, radii,
68
+ offset shadows, particles). Replace `favicon.svg` (and `favicon-32.png`, `apple-touch-icon.png`) the same way.
69
+ Token list: [design system](https://github.com/WhiteWoodTech/hashquiz/blob/develop/docs/DESIGN_SYSTEM.md#deck-repository-theme).
70
+
71
+ ```css
72
+ /* public/theme.css */
73
+ @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');
74
+ :root {
75
+ --hq-bg: #1a1e1f;
76
+ --hq-accent: #5c7063;
77
+ --hq-font-display: 'Roboto', system-ui, sans-serif;
78
+ }
79
+ ```
80
+
64
81
  The `VITE_*` names (`VITE_TRANSPORT`, …) are accepted too. The prebuilt apps carry no
65
82
  settings of their own: whatever `hashquiz-config.js` says (including `local` and `browser`) is what they use.
66
83
 
package/bin/hashquiz.js CHANGED
@@ -5273,6 +5273,16 @@ function repoDecksDir(repoRoot) {
5273
5273
  return existsSync2(local) ? local : resolve3(repoRoot, "tests/fixtures");
5274
5274
  }
5275
5275
 
5276
+ // packages/server/src/theme.ts
5277
+ var THEME_FILE = "theme.css";
5278
+ var THEME_LINK = `<link rel="stylesheet" href="/${THEME_FILE}">`;
5279
+ function linkTheme(html) {
5280
+ if (html.includes(THEME_LINK))
5281
+ return html;
5282
+ return html.replace("</head>", ` ${THEME_LINK}
5283
+ </head>`);
5284
+ }
5285
+
5276
5286
  // packages/server/src/dev.ts
5277
5287
  function resolveDevTarget(arg, opts) {
5278
5288
  const target = resolve4(arg);
@@ -5307,8 +5317,12 @@ function devCommand(arg, port, decksFlag) {
5307
5317
  console.error("Prebuilt web apps not found: reinstall the hashquiz package.");
5308
5318
  process.exit(1);
5309
5319
  }
5310
- serveStatic(web, 3031, "/host/", decksDir);
5311
- serveStatic(web, 3032, "/", decksDir);
5320
+ const publicDir = resolve4("public");
5321
+ const pub = existsSync3(publicDir) && statSync2(publicDir).isDirectory() ? publicDir : null;
5322
+ serveStatic(web, 3031, "/host/", decksDir, pub);
5323
+ serveStatic(web, 3032, "/", decksDir, pub);
5324
+ if (pub && existsSync3(join2(pub, THEME_FILE)))
5325
+ console.log(` Theme: ${join2(pub, THEME_FILE)}`);
5312
5326
  console.log(` Host app: http://localhost:3031/host/
5313
5327
  Player app: http://localhost:3032/
5314
5328
  `);
@@ -5326,7 +5340,7 @@ function devCommand(arg, port, decksFlag) {
5326
5340
  `);
5327
5341
  });
5328
5342
  }
5329
- function serveStatic(root, port, home, decksDir) {
5343
+ function serveStatic(root, port, home, decksDir, publicDir) {
5330
5344
  const config = renderConfigScript({ transport: "local", soloScoring: "browser" });
5331
5345
  Bun.serve({
5332
5346
  port,
@@ -5341,13 +5355,19 @@ function serveStatic(root, port, home, decksDir) {
5341
5355
  }
5342
5356
  if (pathname === "/" && home !== "/")
5343
5357
  return Response.redirect(home, 302);
5344
- const file = resolve4(join2(root, decodeURIComponent(pathname)));
5345
- if (!file.startsWith(root))
5346
- return new Response("Not found", { status: 404 });
5347
- if (existsSync3(file) && statSync2(file).isFile())
5348
- return new Response(Bun.file(file));
5349
- const index = pathname.startsWith("/host") ? join2(root, "host/index.html") : join2(root, "index.html");
5350
- return new Response(Bun.file(index));
5358
+ const themed = publicDir !== null && existsSync3(join2(publicDir, THEME_FILE));
5359
+ const page = async (path) => new Response(themed ? linkTheme(await Bun.file(path).text()) : Bun.file(path), { headers: { "Content-Type": "text/html; charset=utf-8" } });
5360
+ for (const base of publicDir ? [publicDir, root] : [root]) {
5361
+ const file = resolve4(join2(base, decodeURIComponent(pathname)));
5362
+ if (!file.startsWith(base))
5363
+ return new Response("Not found", { status: 404 });
5364
+ if (existsSync3(file) && statSync2(file).isFile())
5365
+ return file.endsWith(".html") ? page(file) : new Response(Bun.file(file));
5366
+ const dirIndex = join2(file, "index.html");
5367
+ if (base === root && existsSync3(dirIndex))
5368
+ return page(dirIndex);
5369
+ }
5370
+ return page(pathname.startsWith("/host") ? join2(root, "host/index.html") : join2(root, "index.html"));
5351
5371
  }
5352
5372
  });
5353
5373
  }
@@ -5446,7 +5466,12 @@ function buildSite({ decksDir, outDir, publicDir, env = process.env }) {
5446
5466
  if (hasPublic)
5447
5467
  cpSync(publicAbs, out, { recursive: true });
5448
5468
  const playerHtml = resolve5(out, "index.html");
5449
- writeFileSync(playerHtml, applySeo(readFileSync3(playerHtml, "utf-8"), seo));
5469
+ const themed = hasPublic && existsSync4(resolve5(publicAbs, THEME_FILE));
5470
+ const page = (html) => themed ? linkTheme(html) : html;
5471
+ writeFileSync(playerHtml, page(applySeo(readFileSync3(playerHtml, "utf-8"), seo)));
5472
+ const hostHtml = resolve5(out, "host/index.html");
5473
+ if (themed)
5474
+ writeFileSync(hostHtml, page(readFileSync3(hostHtml, "utf-8")));
5450
5475
  const manifest = JSON.stringify(decks);
5451
5476
  writeFileSync(resolve5(out, "host/decks.json"), manifest);
5452
5477
  writeFileSync(resolve5(out, "decks.json"), manifest);
@@ -5666,7 +5691,8 @@ function printUsage() {
5666
5691
  --out <dir> Output folder for build (default: dist)
5667
5692
  --public <dir> Files copied to the site root by build, e.g.
5668
5693
  robots.txt, llms.txt, og.png (default: ./public
5669
- when it exists)
5694
+ when it exists). A theme.css there overrides the
5695
+ --hq-* design tokens (build and dev).
5670
5696
  `);
5671
5697
  }
5672
5698
  if (!command || command === "--help" || command === "-h") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hashquiz",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.6",
4
4
  "description": "Real-time multiplayer quiz from Markdown decks: CLI and prebuilt host/player apps",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",