hashquiz 1.0.0-beta.4 → 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.
Files changed (36) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +31 -0
  3. package/bin/hashquiz.js +138 -30
  4. package/package.json +1 -1
  5. package/web/assets/{SoloCatalog-CkqJ5Tx_.js → SoloCatalog-DTBlhnsB.js} +1 -1
  6. package/web/assets/SoloEndView-Bn5FrTy9.css +1 -0
  7. package/web/assets/SoloEndView-BnFyJZ3B.js +1 -0
  8. package/web/assets/SoloIntroView-ojLTuZHH.js +1 -0
  9. package/web/assets/SoloIntroView-tHv4f8e_.css +1 -0
  10. package/web/assets/SoloLeaderboard-eVHseNB2.js +1 -0
  11. package/web/assets/SoloQuestionView-Cf0mhxPN.css +1 -0
  12. package/web/assets/{SoloQuestionView-7ZBgZtDL.js → SoloQuestionView-Cmf4MYWt.js} +11 -11
  13. package/web/assets/{decks-DUUEsbbr.js → decks-CILP6Nug.js} +2 -2
  14. package/web/assets/{decks-i0k875Ku.js → decks-DyA4U4Wi.js} +1 -1
  15. package/web/assets/{deps-B9JMgire.js → deps-Rtqf7cy6.js} +1 -1
  16. package/web/assets/index-DX4WkM4r.js +32 -0
  17. package/web/assets/index-D_fGdCHX.css +1 -0
  18. package/web/assets/solo-YNcyK1fh.js +1 -0
  19. package/web/host/assets/{index-CuMMk6nf.js → index-3b7YwlZc.js} +5 -5
  20. package/web/host/assets/index-DlZpwtSf.css +1 -0
  21. package/web/host/index.html +6 -2
  22. package/web/icon-192.png +0 -0
  23. package/web/icon-512.png +0 -0
  24. package/web/index.html +17 -3
  25. package/web/manifest.webmanifest +15 -0
  26. package/web/og.png +0 -0
  27. package/web/robots.txt +3 -0
  28. package/web/assets/SoloEndView-D4O71skZ.js +0 -1
  29. package/web/assets/SoloEndView-DiG29AY1.css +0 -1
  30. package/web/assets/SoloIntroView-BZVJulM4.css +0 -1
  31. package/web/assets/SoloIntroView-BffbrN2m.js +0 -1
  32. package/web/assets/SoloLeaderboard-yKT1v7Ii.js +0 -1
  33. package/web/assets/SoloQuestionView-D4uFu3tV.css +0 -1
  34. package/web/assets/index-B3S7raZa.js +0 -32
  35. package/web/assets/index-mrY1X_tz.css +0 -1
  36. package/web/host/assets/index-CtXpIwsc.css +0 -1
package/LICENSE.md CHANGED
@@ -9,7 +9,7 @@ See [`docs/LICENSING.md`](docs/LICENSING.md) for a plain-language FAQ.
9
9
  | Tier | License | Applies to |
10
10
  |------|---------|------------|
11
11
  | Format & tooling | [MIT](packages/parser/LICENSE) | `packages/parser/` (the `.hashquiz.md` format), `.claude/plugins/hashquiz/` (Claude skills and commands), and any future MCP server package marked MIT |
12
- | Product | **HashQuiz Sustainable Use License** (below) | Everything else, unless stated otherwise: `packages/core`, `packages/server`, `packages/transport-*`, `packages/ui`, `packages/theme-default`, `apps/host`, `apps/player`, `decks/`, `examples/` |
12
+ | Product | **HashQuiz Sustainable Use License** (below) | Everything else, unless stated otherwise: `packages/core`, `packages/server`, `packages/transport-*`, `packages/ui`, `packages/theme-default`, `apps/host`, `apps/player`, `decks/`, `tests/` |
13
13
  | Pro / Enterprise | [HashQuiz Enterprise License](LICENSE_EE.md) | `packages/ee/`, and any file whose name contains `.ee.` or whose path contains a `.ee` directory |
14
14
 
15
15
  When a directory contains its own `LICENSE` file, that file takes precedence for its contents.
package/README.md CHANGED
@@ -31,6 +31,7 @@ hashquiz check decks/my-deck/index.hashquiz.md # validate one deck
31
31
  hashquiz dev decks/my-deck/index.hashquiz.md # local game: host :3031/host/, players :3032
32
32
  hashquiz dev decks # same, a folder: solo decks folder, room deck = first deck by id
33
33
  hashquiz build decks --out dist # static site with every deck under decks/
34
+ hashquiz build decks --public public # same, with extra files copied to the site root
34
35
  hashquiz supabase deploy --project <ref> # solo backend on a Supabase project
35
36
  ```
36
37
 
@@ -46,6 +47,36 @@ from the environment:
46
47
  | `HASHQUIZ_SUPABASE_ANON_KEY` | Supabase anon public key |
47
48
  | `HASHQUIZ_SOLO_SCORING` | Solo run scoring: `browser` (default) or `edge` |
48
49
  | `HASHQUIZ_PLAYER_URL` | Optional player URL for the host's solo links (default: same origin) |
50
+ | `HASHQUIZ_SITE_URL` | Public URL of the site (e.g. `https://hashquiz.ai`): canonical, `og:url`, absolute `og:image`, sitemap line of `robots.txt` |
51
+ | `HASHQUIZ_LANG` | `<html lang>` of the player page, e.g. `fr` (default `en`) |
52
+ | `HASHQUIZ_INDEXABLE` | `true` lets search engines index the player page (default: `noindex`). The host is always `noindex` |
53
+
54
+ ### Search engines and link previews
55
+
56
+ The player page ships a description, Open Graph tags and a 1200×630 `og.png`, a web app manifest and its icons.
57
+ `build` also writes a `robots.txt` that keeps `/host` out of search engines.
58
+
59
+ Files in `public/` (or the folder given with `--public`) are copied to the site root last, so a decks repository
60
+ can add `llms.txt` or `sitemap.xml`, or replace `og.png` and `robots.txt`. The `Sitemap:` line of the generated
61
+ `robots.txt` appears only when `public/` holds a `sitemap.xml` and `HASHQUIZ_SITE_URL` is set.
62
+ Background: [SEO audit](https://github.com/WhiteWoodTech/hashquiz/blob/develop/docs/SEO_AUDIT.md).
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
+ ```
49
80
 
50
81
  The `VITE_*` names (`VITE_TRANSPORT`, …) are accepted too. The prebuilt apps carry no
51
82
  settings of their own: whatever `hashquiz-config.js` says (including `local` and `browser`) is what they use.
package/bin/hashquiz.js CHANGED
@@ -3672,6 +3672,11 @@ function validateQuiz(quiz) {
3672
3672
  }
3673
3673
  return { valid: errors.length === 0, errors };
3674
3674
  }
3675
+ // packages/core/src/quiz-format.ts
3676
+ function quizFormat(meta, poolSize) {
3677
+ const randomDraw = meta.maxQuestions !== undefined || meta.maxTimeSec !== undefined || meta.targetDifficulty !== undefined;
3678
+ return { poolSize, randomDraw, oneShoot: meta.oneShoot ?? true };
3679
+ }
3675
3680
  // packages/core/src/events.ts
3676
3681
  var GameEvents = {
3677
3682
  playerJoined: (player) => ({ type: "player_joined", player }),
@@ -4697,7 +4702,15 @@ function buildQuizInfo(quiz) {
4697
4702
  hard: 100 - easyPct - mediumPct
4698
4703
  };
4699
4704
  }
4700
- return { title, description, tags, totalQuestions: totalN, targetDifficulty, difficultyDistribution: dist };
4705
+ return {
4706
+ title,
4707
+ description,
4708
+ tags,
4709
+ totalQuestions: totalN,
4710
+ targetDifficulty,
4711
+ difficultyDistribution: dist,
4712
+ ...quizFormat(quiz.meta, all.length)
4713
+ };
4701
4714
  }
4702
4715
 
4703
4716
  class HashQuizServer {
@@ -5230,7 +5243,7 @@ class HashQuizServer {
5230
5243
  }
5231
5244
 
5232
5245
  // packages/server/src/dev.ts
5233
- import { existsSync as existsSync2, statSync as statSync2, watch } from "fs";
5246
+ import { existsSync as existsSync3, statSync as statSync2, watch } from "fs";
5234
5247
  import { dirname as dirname2, join as join2, resolve as resolve4 } from "path";
5235
5248
  import { spawn } from "child_process";
5236
5249
 
@@ -5251,15 +5264,29 @@ function findMonorepoRoot() {
5251
5264
  }
5252
5265
 
5253
5266
  // packages/server/src/vite-plugin.ts
5267
+ import { existsSync as existsSync2 } from "fs";
5254
5268
  import { resolve as resolve3 } from "path";
5255
5269
  function repoDecksDir(repoRoot) {
5256
- return resolve3(repoRoot, process.env.HASHQUIZ_DECKS_DIR ?? "examples");
5270
+ if (process.env.HASHQUIZ_DECKS_DIR)
5271
+ return resolve3(repoRoot, process.env.HASHQUIZ_DECKS_DIR);
5272
+ const local = resolve3(repoRoot, "decks");
5273
+ return existsSync2(local) ? local : resolve3(repoRoot, "tests/fixtures");
5274
+ }
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>`);
5257
5284
  }
5258
5285
 
5259
5286
  // packages/server/src/dev.ts
5260
5287
  function resolveDevTarget(arg, opts) {
5261
5288
  const target = resolve4(arg);
5262
- if (!existsSync2(target))
5289
+ if (!existsSync3(target))
5263
5290
  throw new Error(`${arg} not found`);
5264
5291
  if (statSync2(target).isDirectory()) {
5265
5292
  const first = collectDecks(target)[0];
@@ -5290,8 +5317,12 @@ function devCommand(arg, port, decksFlag) {
5290
5317
  console.error("Prebuilt web apps not found: reinstall the hashquiz package.");
5291
5318
  process.exit(1);
5292
5319
  }
5293
- serveStatic(web, 3031, "/host/", decksDir);
5294
- 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)}`);
5295
5326
  console.log(` Host app: http://localhost:3031/host/
5296
5327
  Player app: http://localhost:3032/
5297
5328
  `);
@@ -5309,7 +5340,7 @@ function devCommand(arg, port, decksFlag) {
5309
5340
  `);
5310
5341
  });
5311
5342
  }
5312
- function serveStatic(root, port, home, decksDir) {
5343
+ function serveStatic(root, port, home, decksDir, publicDir) {
5313
5344
  const config = renderConfigScript({ transport: "local", soloScoring: "browser" });
5314
5345
  Bun.serve({
5315
5346
  port,
@@ -5324,23 +5355,82 @@ function serveStatic(root, port, home, decksDir) {
5324
5355
  }
5325
5356
  if (pathname === "/" && home !== "/")
5326
5357
  return Response.redirect(home, 302);
5327
- const file = resolve4(join2(root, decodeURIComponent(pathname)));
5328
- if (!file.startsWith(root))
5329
- return new Response("Not found", { status: 404 });
5330
- if (existsSync2(file) && statSync2(file).isFile())
5331
- return new Response(Bun.file(file));
5332
- const index = pathname.startsWith("/host") ? join2(root, "host/index.html") : join2(root, "index.html");
5333
- 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"));
5334
5371
  }
5335
5372
  });
5336
5373
  }
5337
5374
 
5338
5375
  // packages/server/src/build.ts
5339
- import { cpSync, existsSync as existsSync3, mkdirSync as mkdirSync2, rmSync, writeFileSync } from "fs";
5376
+ import { cpSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, statSync as statSync3, writeFileSync } from "fs";
5340
5377
  import { resolve as resolve5 } from "path";
5341
- function buildSite({ decksDir, outDir, env = process.env }) {
5378
+
5379
+ // packages/server/src/seo.ts
5380
+ var TRUE = new Set(["1", "true", "yes"]);
5381
+ function seoFromEnv(env) {
5382
+ const settings = { indexable: TRUE.has((env.HASHQUIZ_INDEXABLE ?? "").trim().toLowerCase()) };
5383
+ const rawUrl = env.HASHQUIZ_SITE_URL?.trim();
5384
+ if (rawUrl) {
5385
+ let url;
5386
+ try {
5387
+ url = new URL(rawUrl);
5388
+ } catch {
5389
+ throw new Error(`HASHQUIZ_SITE_URL is not a URL: ${rawUrl}`);
5390
+ }
5391
+ if (url.protocol !== "https:" && url.protocol !== "http:")
5392
+ throw new Error(`HASHQUIZ_SITE_URL must be http(s): ${rawUrl}`);
5393
+ settings.siteUrl = `${url.origin}${url.pathname}`.replace(/\/+$/, "");
5394
+ }
5395
+ const lang = env.HASHQUIZ_LANG?.trim();
5396
+ if (lang) {
5397
+ if (!/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$/.test(lang))
5398
+ throw new Error(`HASHQUIZ_LANG is not a language tag: ${lang}`);
5399
+ settings.lang = lang;
5400
+ }
5401
+ return settings;
5402
+ }
5403
+ var escapeAttr = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
5404
+ function applySeo(html, settings) {
5405
+ let out = html;
5406
+ if (settings.lang)
5407
+ out = out.replace(/<html lang="[^"]*">/, `<html lang="${escapeAttr(settings.lang)}">`);
5408
+ if (settings.indexable)
5409
+ out = out.replace(/[ \t]*<meta name="robots" content="noindex">\n?/, "");
5410
+ if (settings.siteUrl) {
5411
+ const home = `${settings.siteUrl}/`;
5412
+ out = out.replace(/(<meta property="og:image" content=")\/([^"]*)"/, (_m, start, path) => `${start}${escapeAttr(settings.siteUrl)}/${path}"`).replace(/<!-- hashquiz:head[^>]*-->/, `<link rel="canonical" href="${escapeAttr(home)}">
5413
+ <meta property="og:url" content="${escapeAttr(home)}">`);
5414
+ }
5415
+ return out;
5416
+ }
5417
+ function renderRobots(settings, hasSitemap) {
5418
+ const lines = ["# Written by `hashquiz build`. Ship your own public/robots.txt to replace it.", "User-agent: *", "Disallow: /host", ""];
5419
+ if (hasSitemap && settings.siteUrl)
5420
+ lines.push(`Sitemap: ${settings.siteUrl}/sitemap.xml`, "");
5421
+ return lines.join(`
5422
+ `);
5423
+ }
5424
+
5425
+ // packages/server/src/build.ts
5426
+ function buildSite({ decksDir, outDir, publicDir, env = process.env }) {
5427
+ const seo = seoFromEnv(env);
5428
+ const publicAbs = publicDir !== undefined ? resolve5(publicDir) : resolve5("public");
5429
+ if (publicDir !== undefined && !(existsSync4(publicAbs) && statSync3(publicAbs).isDirectory())) {
5430
+ throw new Error(`Public folder not found: ${publicDir}`);
5431
+ }
5342
5432
  const decksAbs = resolve5(decksDir);
5343
- if (!existsSync3(decksAbs))
5433
+ if (!existsSync4(decksAbs))
5344
5434
  throw new Error(`Decks folder not found: ${decksDir}`);
5345
5435
  const decks = collectDecks(decksAbs);
5346
5436
  if (decks.length === 0)
@@ -5370,6 +5460,18 @@ function buildSite({ decksDir, outDir, env = process.env }) {
5370
5460
  rmSync(out, { recursive: true, force: true });
5371
5461
  mkdirSync2(out, { recursive: true });
5372
5462
  cpSync(web, out, { recursive: true });
5463
+ const hasPublic = existsSync4(publicAbs) && statSync3(publicAbs).isDirectory();
5464
+ const hasSitemap = hasPublic && existsSync4(resolve5(publicAbs, "sitemap.xml"));
5465
+ writeFileSync(resolve5(out, "robots.txt"), renderRobots(seo, hasSitemap));
5466
+ if (hasPublic)
5467
+ cpSync(publicAbs, out, { recursive: true });
5468
+ const playerHtml = resolve5(out, "index.html");
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")));
5373
5475
  const manifest = JSON.stringify(decks);
5374
5476
  writeFileSync(resolve5(out, "host/decks.json"), manifest);
5375
5477
  writeFileSync(resolve5(out, "decks.json"), manifest);
@@ -5378,7 +5480,7 @@ function buildSite({ decksDir, outDir, env = process.env }) {
5378
5480
  }
5379
5481
 
5380
5482
  // packages/backend-supabase/src/cli/edge-bundle.ts
5381
- import { existsSync as existsSync4 } from "fs";
5483
+ import { existsSync as existsSync5 } from "fs";
5382
5484
  import { mkdir } from "fs/promises";
5383
5485
  import { dirname as dirname3, join as join3 } from "path";
5384
5486
  var EDGE_CORE_FILE = "functions/_shared/solo-core.js";
@@ -5386,7 +5488,7 @@ var EDGE_CORE_BANNER = `import { Buffer } from "node:buffer";
5386
5488
  `;
5387
5489
  function edgeCoreEntry() {
5388
5490
  const entry = join3(import.meta.dir, "../edge/solo-core.ts");
5389
- return existsSync4(entry) ? entry : null;
5491
+ return existsSync5(entry) ? entry : null;
5390
5492
  }
5391
5493
  async function bundleEdgeCore(outFile) {
5392
5494
  const entry = edgeCoreEntry();
@@ -5406,7 +5508,7 @@ function stripModulePathComments(code) {
5406
5508
  }
5407
5509
  if (false) {}
5408
5510
  // packages/backend-supabase/src/cli/deploy.ts
5409
- import { existsSync as existsSync5, statSync as statSync3 } from "fs";
5511
+ import { existsSync as existsSync6, statSync as statSync4 } from "fs";
5410
5512
  import { cp, mkdtemp, rm } from "fs/promises";
5411
5513
  import { tmpdir } from "os";
5412
5514
  import { basename, join as join4, resolve as resolve6 } from "path";
@@ -5424,7 +5526,7 @@ function supabaseDeploySteps(o) {
5424
5526
  ];
5425
5527
  }
5426
5528
  function isProject(dir) {
5427
- return existsSync5(join4(dir, "config.toml"));
5529
+ return existsSync6(join4(dir, "config.toml"));
5428
5530
  }
5429
5531
  function findSupabaseDir() {
5430
5532
  const here = import.meta.dirname;
@@ -5436,17 +5538,17 @@ function findSupabaseDir() {
5436
5538
  }
5437
5539
  async function copySupabaseProject(src, destSupabaseDir, edgeCore) {
5438
5540
  const coreFile = resolve6(src, EDGE_CORE_FILE);
5439
- if (edgeCore === "copy" && !existsSync5(coreFile)) {
5541
+ if (edgeCore === "copy" && !existsSync6(coreFile)) {
5440
5542
  throw new Error(`supabase: ${EDGE_CORE_FILE} missing in ${src} (run \`bun run build:edge\`)`);
5441
5543
  }
5442
5544
  await cp(join4(src, "config.toml"), join4(destSupabaseDir, "config.toml"));
5443
5545
  for (const dir of ["migrations", "functions"]) {
5444
- if (!existsSync5(join4(src, dir)))
5546
+ if (!existsSync6(join4(src, dir)))
5445
5547
  continue;
5446
5548
  await cp(join4(src, dir), join4(destSupabaseDir, dir), {
5447
5549
  recursive: true,
5448
5550
  filter: (p) => {
5449
- if (basename(p).startsWith(".env") && !statSync3(p).isDirectory())
5551
+ if (basename(p).startsWith(".env") && !statSync4(p).isDirectory())
5450
5552
  return false;
5451
5553
  return edgeCore === "copy" || resolve6(p) !== coreFile;
5452
5554
  }
@@ -5552,7 +5654,7 @@ async function supabaseCommand(args, env, run = defaultRunner, log = console.log
5552
5654
  return 1;
5553
5655
  }
5554
5656
  // packages/server/src/cli.ts
5555
- import { readFileSync as readFileSync3 } from "fs";
5657
+ import { readFileSync as readFileSync4 } from "fs";
5556
5658
  import { resolve as resolve7 } from "path";
5557
5659
  var [, , command, arg, ...flags] = process.argv;
5558
5660
  function printUsage() {
@@ -5570,7 +5672,9 @@ function printUsage() {
5570
5672
  folder (default: decks). Reads HASHQUIZ_TRANSPORT,
5571
5673
  HASHQUIZ_SUPABASE_URL, HASHQUIZ_SUPABASE_ANON_KEY,
5572
5674
  HASHQUIZ_SOLO_SCORING, HASHQUIZ_PLAYER_URL
5573
- (or their VITE_* names) from the environment.
5675
+ (or their VITE_* names) from the environment, and
5676
+ HASHQUIZ_SITE_URL, HASHQUIZ_LANG,
5677
+ HASHQUIZ_INDEXABLE for search engines.
5574
5678
  supabase deploy --project <ref> [--site-url <url>] [--dry-run]
5575
5679
  Deploy the solo backend to a Supabase project:
5576
5680
  migrations, the solo-submit Edge Function and its
@@ -5582,9 +5686,13 @@ function printUsage() {
5582
5686
  Options:
5583
5687
  --port <number> Port to listen on (default: 3030)
5584
5688
  --decks <dir> Decks folder for dev with a file (default: the
5585
- repo's examples/ from the sources, else the
5586
- file's folder)
5689
+ repo's decks/ or tests/fixtures/ from the
5690
+ sources, else the file's folder)
5587
5691
  --out <dir> Output folder for build (default: dist)
5692
+ --public <dir> Files copied to the site root by build, e.g.
5693
+ robots.txt, llms.txt, og.png (default: ./public
5694
+ when it exists). A theme.css there overrides the
5695
+ --hq-* design tokens (build and dev).
5588
5696
  `);
5589
5697
  }
5590
5698
  if (!command || command === "--help" || command === "-h") {
@@ -5614,7 +5722,7 @@ if (command === "dev") {
5614
5722
  const decksDir = positional ?? "decks";
5615
5723
  const outDir = flag("--out") ?? "dist";
5616
5724
  try {
5617
- const count = buildSite({ decksDir, outDir });
5725
+ const count = buildSite({ decksDir, outDir, publicDir: flag("--public") });
5618
5726
  console.log(`\u2713 Built ${count} deck(s) from ${decksDir} into ${outDir}`);
5619
5727
  } catch (e) {
5620
5728
  console.error(`\u2717 ${e instanceof Error ? e.message : String(e)}`);
@@ -5629,7 +5737,7 @@ if (command === "dev") {
5629
5737
  process.exit(1);
5630
5738
  }
5631
5739
  try {
5632
- const content = readFileSync3(resolve7(arg), "utf-8");
5740
+ const content = readFileSync4(resolve7(arg), "utf-8");
5633
5741
  const quiz = parseQuizFile(content);
5634
5742
  const result = validateQuiz(quiz);
5635
5743
  if (result.valid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hashquiz",
3
- "version": "1.0.0-beta.4",
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",
@@ -1 +1 @@
1
- import{C as e,E as t,N as n,O as r,P as i,b as a,g as o,k as s,o as c,t as l,u,v as d,w as f,x as p}from"./index-B3S7raZa.js";import{t as m}from"./decks-DUUEsbbr.js";import{n as h}from"./decks-i0k875Ku.js";var g={key:0,class:`solo-catalog`,"aria-labelledby":`solo-catalog-title`},_={class:`solo-catalog__list`},v=[`href`,`aria-label`],y=u(f({__name:`SoloCatalog`,setup(u){let f=n([]);return t(async()=>{try{f.value=(await h()).map(e=>({id:e.id,info:m(e)}))}catch(e){console.error(`Solo quizzes unavailable:`,e)}}),(t,n)=>f.value.length?(r(),p(`section`,g,[n[0]||=d(`h2`,{id:`solo-catalog-title`,class:`solo-catalog__title`},`Ou jouez en solo`,-1),d(`ul`,_,[(r(!0),p(o,null,s(f.value,t=>(r(),p(`li`,{key:t.id},[d(`a`,{class:`solo-catalog__card`,href:i(l)(t.id),"aria-label":`Jouer en solo : ${t.info.title}`},[e(i(c),{"quiz-info":t.info,compact:``},null,8,[`quiz-info`])],8,v)]))),128))])])):a(``,!0)}}),[[`__scopeId`,`data-v-09d9ea2c`]]);export{y as default};
1
+ import{C as e,E as t,N as n,O as r,P as i,b as a,g as o,k as s,o as c,t as l,u,v as d,w as f,x as p}from"./index-DX4WkM4r.js";import{t as m}from"./decks-CILP6Nug.js";import{n as h}from"./decks-DyA4U4Wi.js";var g={key:0,class:`solo-catalog`,"aria-labelledby":`solo-catalog-title`},_={class:`solo-catalog__list`},v=[`href`,`aria-label`],y=u(f({__name:`SoloCatalog`,setup(u){let f=n([]);return t(async()=>{try{f.value=(await h()).map(e=>({id:e.id,info:m(e)}))}catch(e){console.error(`Solo quizzes unavailable:`,e)}}),(t,n)=>f.value.length?(r(),p(`section`,g,[n[0]||=d(`h2`,{id:`solo-catalog-title`,class:`solo-catalog__title`},`Ou jouez en solo`,-1),d(`ul`,_,[(r(!0),p(o,null,s(f.value,t=>(r(),p(`li`,{key:t.id},[d(`a`,{class:`solo-catalog__card`,href:i(l)(t.id),"aria-label":`Jouer en solo : ${t.info.title}`},[e(i(c),{"quiz-info":t.info,compact:``},null,8,[`quiz-info`])],8,v)]))),128))])])):a(``,!0)}}),[[`__scopeId`,`data-v-09d9ea2c`]]);export{y as default};
@@ -0,0 +1 @@
1
+ .lead[data-v-198afc42]{background:var(--hq-surface);border:1px solid var(--hq-border);border-radius:var(--hq-radius);width:100%;padding:1rem}.lead__form[data-v-198afc42]{flex-direction:column;gap:.6rem;display:flex}.lead__title[data-v-198afc42]{margin:0 0 .25rem;font-size:1.05rem}.lead__consent[data-v-198afc42]{color:var(--hq-text-muted);cursor:pointer;align-items:flex-start;gap:.6rem;font-size:.9rem;display:flex}.lead__consent input[data-v-198afc42]{accent-color:var(--hq-accent);flex-shrink:0;width:1.1rem;height:1.1rem;margin-top:.2rem}.lead__error[data-v-198afc42]{color:var(--hq-wrong);margin:0;font-size:.9rem}.lead__thanks[data-v-198afc42]{text-align:center;color:var(--hq-correct);margin:0;font-weight:600}.solo-end[data-v-c555ea86]{flex-direction:column;align-items:center;gap:1.25rem;padding-top:1rem;display:flex}.solo-end__summary[data-v-c555ea86]{text-align:center}.solo-end__name[data-v-c555ea86]{margin:0 0 .25rem;font-size:1.3rem;font-weight:700}.solo-end__score[data-v-c555ea86]{font-family:var(--hq-font-pixel);color:var(--hq-figure);margin:0;font-size:2rem;font-weight:700}.solo-end__meta[data-v-c555ea86]{color:var(--hq-text-muted);font-variant-numeric:tabular-nums;margin:.35rem 0 0}.solo-end__rank[data-v-c555ea86]{margin:.5rem 0 0;font-size:1.15rem;font-weight:700}.solo-end__actions[data-v-c555ea86]{gap:.75rem;width:100%;display:flex}.solo-end__actions .solo-btn[data-v-c555ea86]{text-align:center;flex:1 1 0;text-decoration:none;display:block}.solo-end__share-note[data-v-c555ea86]{color:var(--hq-text-muted);margin:-.5rem 0 0;font-size:.85rem}.solo-end__status[data-v-c555ea86]{color:var(--hq-text-muted);margin:0;font-size:.9rem}.solo-end__status[data-v-c555ea86]:empty{display:none}.solo-end__retry[data-v-c555ea86]{color:var(--hq-wrong);cursor:pointer;background:0 0;border:none;padding:.25rem;font-family:inherit;text-decoration:underline}
@@ -0,0 +1 @@
1
+ import{C as e,L as t,M as n,O as r,P as i,S as a,_ as o,b as s,g as c,h as l,j as u,m as d,n as f,p,t as m,u as h,v as g,w as _,x as v}from"./index-DX4WkM4r.js";import{n as y,t as b}from"./solo-YNcyK1fh.js";import{t as x}from"./SoloLeaderboard-eVHseNB2.js";import{t as S}from"./solo-backend-DxFnwiPI.js";function C(e,t){return`${t.origin}${t.pathname}${m(e)}`}function w(e){let t=e.rank===null?``:` (${y(e.rank)} au classement)`;return`J'ai fait ${e.score.toLocaleString(`fr-FR`)} pts sur le quiz « ${e.title} »${t}. À toi de jouer !`}async function T(e,t){if(t.share)try{return await t.share(e),`shared`}catch(e){if(e?.name===`AbortError`)return`cancelled`}if(!t.clipboard)return`failed`;try{return await t.clipboard.writeText(`${e.text} ${e.url}`),`copied`}catch{return`failed`}}var E={class:`lead`,"aria-labelledby":`lead-title`},D={key:0,class:`lead__thanks`,role:`status`},O=[`aria-invalid`],k={class:`lead__consent`},A=[`disabled`],j={key:0,class:`lead__error`,role:`status`},M=h(_({__name:`LeadForm`,setup(e){let t=f(),i=n(``),a=n(!1),c=n(`idle`),m=o(()=>S.test(i.value.trim())),h=o(()=>m.value&&a.value&&c.value!==`sending`);async function _(){if(!h.value)return;c.value=`sending`;let e=await t.submitLead(i.value);c.value=e.ok?`done`:`error`}return(e,t)=>(r(),v(`section`,E,[c.value===`done`?(r(),v(`p`,D,`Merci, on vous tient au courant de HashQuiz !`)):(r(),v(`form`,{key:1,class:`lead__form`,novalidate:``,onSubmit:l(_,[`prevent`])},[t[3]||=g(`h3`,{id:`lead-title`,class:`lead__title`},`HashQuiz arrive bientôt`,-1),t[4]||=g(`label`,{class:`solo-label`,for:`lead-email`},`Email`,-1),u(g(`input`,{id:`lead-email`,"onUpdate:modelValue":t[0]||=e=>i.value=e,class:`solo-input`,type:`email`,autocomplete:`email`,inputmode:`email`,required:``,"aria-invalid":i.value!==``&&!m.value},null,8,O),[[d,i.value]]),g(`label`,k,[u(g(`input`,{"onUpdate:modelValue":t[1]||=e=>a.value=e,type:`checkbox`,required:``},null,512),[[p,a.value]]),t[2]||=g(`span`,null,`J'accepte d'être recontacté·e au sujet de HashQuiz`,-1)]),g(`button`,{class:`solo-btn solo-btn--ghost hq-press`,type:`submit`,disabled:!h.value},`Tenir au courant`,8,A),c.value===`error`?(r(),v(`p`,j,`Oups, réessayez.`)):s(``,!0)],32))]))}}),[[`__scopeId`,`data-v-198afc42`]]),N={class:`solo-end`},P={class:`solo-end__summary`},F={class:`solo-end__name`},I={class:`solo-end__score`},L={class:`solo-end__meta`},R={key:0,class:`solo-end__rank`},z={class:`solo-end__status`,role:`status`},B={class:`solo-end__actions`},V=[`href`],H={key:0,class:`solo-end__share-note`,role:`status`},U=h(_({__name:`SoloEndView`,setup(o){let l=f(),u={copied:`Lien copié !`,failed:`Partage indisponible sur ce navigateur.`},d=n(``);async function p(){let e=l.deck;if(!e)return;let t=e.quiz.meta.title||e.name,n=await T({title:t,text:w({title:t,score:l.score,rank:l.myRank}),url:C(e.id,location)},navigator);d.value=n===`copied`||n===`failed`?u[n]:``}return(n,o)=>(r(),v(`div`,N,[g(`div`,P,[g(`p`,F,t(i(l).pseudo),1),g(`p`,I,t(i(l).score.toLocaleString(`fr-FR`))+` pts`,1),g(`p`,L,t(i(l).correctCount)+`/`+t(i(l).total)+` bonnes réponses · `+t(i(b)(i(l).totalTimeMs)),1),i(l).myRank===null?s(``,!0):(r(),v(`p`,R,[a(` #`+t(i(l).myRank),1),i(l).runCount===null?s(``,!0):(r(),v(c,{key:0},[a(` sur `+t(i(l).runCount),1)],64))]))]),g(`div`,z,[i(l).submitState===`saving`?(r(),v(c,{key:0},[a(`Enregistrement du score…`)],64)):i(l).submitState===`error`?(r(),v(`button`,{key:1,class:`solo-end__retry`,onClick:o[0]||=e=>i(l).retrySubmit()},` Score non enregistré — réessayer `)):i(l).submitState===`stale`?(r(),v(c,{key:2},[a(` Score non enregistré : ce quiz a été mis à jour. Rejouez pour utiliser la nouvelle version. `)],64)):s(``,!0)]),g(`div`,B,[g(`button`,{class:`solo-btn hq-press`,onClick:o[1]||=e=>i(l).playAgain()},`Rejouer`),g(`a`,{class:`solo-btn solo-btn--ghost hq-press`,href:i(`#/`)},`Menu`,8,V),g(`button`,{class:`solo-btn solo-btn--ghost hq-press`,onClick:p},`Partager`)]),d.value?(r(),v(`p`,H,t(d.value),1)):s(``,!0),e(x,{live:i(l).liveOthers,rows:i(l).board},null,8,[`live`,`rows`]),e(M)]))}}),[[`__scopeId`,`data-v-c555ea86`]]);export{U as default};
@@ -0,0 +1 @@
1
+ import{C as e,M as t,O as n,P as r,_ as i,g as a,h as o,j as s,m as c,n as l,o as u,u as d,v as f,w as p,x as m}from"./index-DX4WkM4r.js";import{t as h}from"./decks-CILP6Nug.js";import{t as g}from"./SoloLeaderboard-eVHseNB2.js";import"./solo-YNcyK1fh.js";var _={class:`solo-intro`},v={key:0,class:`solo-intro__unavailable`,role:`status`},y={key:1,class:`solo-intro__unavailable`,role:`status`},b=[`maxlength`],x=[`disabled`],S=d(p({__name:`SoloIntroView`,setup(d){let p=l(),S=t(p.pseudo),C=i(()=>p.deck?h(p.deck):null);return(t,i)=>(n(),m(`div`,_,[r(p).phase===`loading`?(n(),m(`p`,v,`Chargement du quiz…`)):r(p).phase===`unavailable`||!r(p).deck?(n(),m(`p`,y,` Ce quiz n'est pas disponible en solo. `)):(n(),m(a,{key:2},[e(r(u),{"quiz-info":C.value,"play-count":r(p).runCount??void 0,compact:``},null,8,[`quiz-info`,`play-count`]),f(`form`,{class:`solo-intro__form`,onSubmit:i[1]||=o(e=>r(p).start(S.value),[`prevent`])},[i[2]||=f(`label`,{class:`solo-label`,for:`solo-pseudo`},`Votre pseudo`,-1),s(f(`input`,{id:`solo-pseudo`,"onUpdate:modelValue":i[0]||=e=>S.value=e,class:`solo-input`,autocomplete:`nickname`,required:``,maxlength:r(24)},null,8,b),[[c,S.value]]),f(`button`,{class:`solo-btn hq-press`,type:`submit`,disabled:!S.value.trim()},`Commencer`,8,x)],32),e(g,{live:r(p).liveOthers,rows:r(p).board},null,8,[`live`,`rows`])],64))]))}}),[[`__scopeId`,`data-v-67931efa`]]);export{S as default};
@@ -0,0 +1 @@
1
+ .solo-intro[data-v-67931efa]{flex-direction:column;gap:1.25rem;padding-top:1rem;display:flex}.solo-intro__form[data-v-67931efa]{flex-direction:column;gap:.6rem;display:flex}.solo-intro__unavailable[data-v-67931efa]{text-align:center;color:var(--hq-text-muted);padding-top:3rem;font-size:1.1rem}
@@ -0,0 +1 @@
1
+ import{F as e,L as t,O as n,P as r,S as i,b as a,g as o,k as s,u as c,v as l,w as u,x as d}from"./index-DX4WkM4r.js";import{t as f}from"./solo-YNcyK1fh.js";var p={class:`solo-board`,"aria-labelledby":`solo-board-title`},m={key:0,class:`solo-board__list`},h={class:`solo-board__name`},g={class:`solo-board__meta`},_={class:`solo-board__score`},v=[`aria-current`],y={class:`solo-board__rank`},b={class:`solo-board__name`},x={key:0,class:`hq-sr-only`},S={class:`solo-board__meta`},C={class:`solo-board__score`},w={key:1,class:`solo-board__empty`},T=c(u({__name:`SoloLeaderboard`,props:{live:{},rows:{}},setup(c){return(u,T)=>(n(),d(`section`,p,[T[2]||=l(`h3`,{id:`solo-board-title`,class:`solo-board__title hq-label`},`Classement`,-1),c.live.length||c.rows.length?(n(),d(`ol`,m,[(n(!0),d(o,null,s(c.live,e=>(n(),d(`li`,{key:`live-`+e.key,class:`solo-board__row solo-board__row--live`},[T[1]||=l(`span`,{class:`solo-board__rank solo-board__dot`,"aria-hidden":`true`},null,-1),l(`span`,h,t(e.pseudo),1),l(`span`,g,[T[0]||=l(`span`,{class:`solo-board__badge`},`en cours`,-1),i(` · Q`+t(Math.min(e.index+1,e.total))+`/`+t(e.total),1)]),l(`span`,_,t(e.score),1)]))),128)),(n(!0),d(o,null,s(c.rows,o=>(n(),d(`li`,{key:o.id,class:e([`solo-board__row`,{"solo-board__row--mine":o.mine,"solo-board__row--gap":o.mine&&o.rank>c.rows.length}]),"aria-current":o.mine?`true`:void 0},[l(`span`,y,t(o.rank),1),l(`span`,b,[i(t(o.pseudo),1),o.mine?(n(),d(`span`,x,` (vous)`)):a(``,!0)]),l(`span`,S,t(r(f)(o.totalTimeMs)),1),l(`span`,C,t(o.score),1)],10,v))),128))])):(n(),d(`p`,w,`Aucun score pour l'instant. Soyez le premier !`))]))}}),[[`__scopeId`,`data-v-bddd0413`]]);export{T as t};
@@ -0,0 +1 @@
1
+ .solo-q[data-v-79a7b626]{flex-direction:column;align-items:center;gap:.75rem;padding-top:.5rem;display:flex}.solo-q__progress[data-v-79a7b626]{align-items:center;gap:.6rem;width:100%;display:flex}.solo-q__progress-label[data-v-79a7b626]{color:var(--hq-text-muted);min-width:2rem;font-size:.8rem}.solo-q__progress-label[data-v-79a7b626]:last-child{text-align:right}.solo-q__track[data-v-79a7b626]{background:var(--hq-border);border-radius:var(--hq-radius-sm);flex:1;height:6px;overflow:hidden}.solo-q__fill[data-v-79a7b626]{background:var(--hq-progress);height:100%;transition:width .3s}.solo-q__timer[data-v-79a7b626]{margin:.5rem 0}.solo-q__text[data-v-79a7b626]{text-align:center;margin:.5rem 0;font-size:1.25rem;line-height:1.4}.solo-q__grid[data-v-79a7b626]{grid-template-columns:1fr 1fr;gap:.65rem;width:100%;display:grid}@media (width<=640px){.solo-q__grid[data-v-79a7b626]{grid-template-columns:1fr}}.solo-q__result[data-v-79a7b626]{text-align:center;flex-direction:column;align-items:center;gap:.15rem;width:100%;padding:.25rem .75rem .5rem;animation:.35s cubic-bezier(.34,1.56,.64,1) solo-pop-79a7b626;display:flex}.solo-q__result .solo-q__fx[data-v-79a7b626]{height:88px}.solo-q__delta[data-v-79a7b626]{font-size:1.15rem;font-weight:700}.solo-q__result--correct .solo-q__delta[data-v-79a7b626]{color:var(--hq-correct)}.solo-q__result--wrong .solo-q__delta[data-v-79a7b626]{color:var(--hq-text-muted)}.solo-q__score[data-v-79a7b626]{font-family:var(--hq-font-pixel);font-size:1.6rem;font-weight:700;line-height:1.1}.solo-q__score small[data-v-79a7b626]{color:var(--hq-text-muted);font-size:.8rem;font-weight:500}.solo-q__rank[data-v-79a7b626]{font-family:var(--hq-font-pixel);color:var(--hq-figure);font-size:1.15rem}.solo-q__rank small[data-v-79a7b626]{font-family:var(--hq-font-display);color:var(--hq-text-muted);font-size:.8rem}.solo-q__info[data-v-79a7b626]{color:var(--hq-text-muted);font-size:.8rem}@keyframes solo-pop-79a7b626{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@media (prefers-reduced-motion:reduce){.solo-q__result[data-v-79a7b626]{animation:none}}.solo-q__explanation[data-v-79a7b626]{background:var(--hq-surface);border:1px solid var(--hq-border);border-radius:var(--hq-radius);width:100%;color:var(--hq-text-muted);margin:0;padding:.75rem 1rem;line-height:1.5}.solo-q__explanation[data-v-79a7b626] p{margin:0 0 .5rem}.solo-q__explanation[data-v-79a7b626] p:last-child{margin:0}.solo-q__explanation[data-v-79a7b626] code{background:var(--hq-surface-2);border:1px solid var(--hq-border);border-radius:var(--hq-radius-sm);padding:.1rem .35rem;font-size:.9em}.solo-q__explanation[data-v-79a7b626] strong{color:var(--hq-text)}.solo-q__explanation[data-v-79a7b626] ul,.solo-q__explanation[data-v-79a7b626] ol{margin:.25rem 0;padding-left:1.25rem}.solo-q__live[data-v-79a7b626]{width:100%}.solo-q__live-title[data-v-79a7b626]{color:var(--hq-text-muted);margin:0 0 .35rem;font-size:.75rem}.solo-q__live ul[data-v-79a7b626]{flex-direction:column;gap:.25rem;margin:0;padding:0;list-style:none;display:flex}.solo-q__live li[data-v-79a7b626]{justify-content:space-between;gap:.5rem;font-size:.85rem;display:flex}.solo-q__live-name[data-v-79a7b626]{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.solo-q__live-meta[data-v-79a7b626]{color:var(--hq-text-muted);font-variant-numeric:tabular-nums;flex-shrink:0}