hashquiz 1.0.0-beta.3 → 1.0.0-beta.5
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/LICENSE.md +7 -7
- package/README.md +22 -8
- package/bin/hashquiz.js +135 -53
- package/package.json +1 -1
- package/supabase/config.toml +1 -1
- package/supabase/functions/_shared/solo-core.js +1 -1
- package/supabase/migrations/20261126090000_solo_live.sql +2 -2
- package/web/apple-touch-icon.png +0 -0
- package/web/assets/SoloCatalog-C2yyeNv7.css +1 -0
- package/web/assets/{SoloCatalog-RmTIEBht.js → SoloCatalog-DTBlhnsB.js} +1 -1
- package/web/assets/SoloEndView-Bn5FrTy9.css +1 -0
- package/web/assets/SoloEndView-BnFyJZ3B.js +1 -0
- package/web/assets/SoloIntroView-ojLTuZHH.js +1 -0
- package/web/assets/SoloIntroView-tHv4f8e_.css +1 -0
- package/web/assets/SoloLeaderboard-CZv7b2Vs.css +1 -0
- package/web/assets/SoloLeaderboard-eVHseNB2.js +1 -0
- package/web/assets/SoloQuestionView-Cf0mhxPN.css +1 -0
- package/web/assets/{SoloQuestionView-BdhWlUbp.js → SoloQuestionView-Cmf4MYWt.js} +11 -11
- package/web/assets/{decks-csTABOt9.js → decks-CILP6Nug.js} +2 -2
- package/web/assets/{decks-BZDX98pq.js → decks-DyA4U4Wi.js} +1 -1
- package/web/assets/{deps-BfbCwAyG.js → deps-Rtqf7cy6.js} +1 -1
- package/web/assets/index-DX4WkM4r.js +32 -0
- package/web/assets/index-D_fGdCHX.css +1 -0
- package/web/assets/solo-8S92cge3.css +1 -0
- package/web/assets/solo-YNcyK1fh.js +1 -0
- package/web/favicon-32.png +0 -0
- package/web/favicon.svg +8 -0
- package/web/host/apple-touch-icon.png +0 -0
- package/web/host/assets/{index-DZ-XwveM.js → index-3b7YwlZc.js} +5 -5
- package/web/host/assets/index-DlZpwtSf.css +1 -0
- package/web/host/favicon-32.png +0 -0
- package/web/host/favicon.svg +8 -0
- package/web/host/index.html +12 -5
- package/web/icon-192.png +0 -0
- package/web/icon-512.png +0 -0
- package/web/index.html +22 -5
- package/web/manifest.webmanifest +15 -0
- package/web/og.png +0 -0
- package/web/robots.txt +3 -0
- package/web/assets/SoloCatalog-Ch3PpTKe.css +0 -1
- package/web/assets/SoloEndView-ByZ9j8Gt.css +0 -1
- package/web/assets/SoloEndView-x2DfmujZ.js +0 -1
- package/web/assets/SoloIntroView-BW3bvLD4.js +0 -1
- package/web/assets/SoloIntroView-C9DwHzgy.css +0 -1
- package/web/assets/SoloLeaderboard--dTz2ifg.css +0 -1
- package/web/assets/SoloLeaderboard-Dvy2DCHn.js +0 -1
- package/web/assets/SoloQuestionView-DaTryQhm.css +0 -1
- package/web/assets/index-BknIaGEG.css +0 -1
- package/web/assets/index-CwQWfifA.js +0 -32
- package/web/assets/solo-IysrS7Ez.css +0 -1
- package/web/host/assets/index-DtJ46Si7.css +0 -1
package/LICENSE.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# HashQuiz licensing
|
|
2
2
|
|
|
3
3
|
> **DRAFT — not yet reviewed by a lawyer.** The texts below describe the intended licensing model.
|
|
4
4
|
> They must be reviewed before the repository is made public.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
HashQuiz is **fair-code open-core**. The repository contains code under three licenses.
|
|
7
7
|
See [`docs/LICENSING.md`](docs/LICENSING.md) for a plain-language FAQ.
|
|
8
8
|
|
|
9
9
|
| Tier | License | Applies to |
|
|
10
10
|
|------|---------|------------|
|
|
11
|
-
| Format & tooling | [MIT](packages/parser/LICENSE) | `packages/parser/` (the `.
|
|
12
|
-
| Product | **
|
|
13
|
-
| Pro / Enterprise | [
|
|
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/`, `tests/` |
|
|
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.
|
|
16
16
|
|
|
17
|
-
Versions of
|
|
17
|
+
Versions of HashQuiz released before this change (up to and including v2.0.0) remain available under the MIT license.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## HashQuiz Sustainable Use License
|
|
22
22
|
|
|
23
23
|
Version 1.0 (draft)
|
|
24
24
|
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ bun add -d hashquiz@beta # prereleases until 1.0.0
|
|
|
17
17
|
```text
|
|
18
18
|
decks/
|
|
19
19
|
my-deck/
|
|
20
|
-
index.
|
|
20
|
+
index.hashquiz.md
|
|
21
21
|
package.json
|
|
22
22
|
vercel.json
|
|
23
23
|
```
|
|
@@ -27,16 +27,17 @@ Format reference: [deck format](https://github.com/WhiteWoodTech/hashquiz/blob/d
|
|
|
27
27
|
## Commands
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
hashquiz check decks/my-deck/index.
|
|
31
|
-
hashquiz dev decks/my-deck/index.
|
|
30
|
+
hashquiz check decks/my-deck/index.hashquiz.md # validate one deck
|
|
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
|
|
|
37
|
-
`build` validates every `*.
|
|
38
|
+
`build` validates every `*.hashquiz.md` under the folder, copies the apps and
|
|
38
39
|
writes `host/decks.json` (host deck list), the same `decks.json` at the root
|
|
39
|
-
(player solo decks) and `
|
|
40
|
+
(player solo decks) and `hashquiz-config.js`. It reads the deployment settings
|
|
40
41
|
from the environment:
|
|
41
42
|
|
|
42
43
|
| Variable | Value |
|
|
@@ -46,9 +47,22 @@ 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` |
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
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
|
+
The `VITE_*` names (`VITE_TRANSPORT`, …) are accepted too. The prebuilt apps carry no
|
|
65
|
+
settings of their own: whatever `hashquiz-config.js` says (including `local` and `browser`) is what they use.
|
|
52
66
|
|
|
53
67
|
Decks with `solo: true` in their frontmatter can also be played alone from
|
|
54
68
|
the player app. `hashquiz dev` serves solo on its own (port 3030): runs are stored in `.hashquiz/solo.db` of
|
|
@@ -68,7 +82,7 @@ prebuilt core). After `hashquiz build`, deploy it with:
|
|
|
68
82
|
HASHQUIZ_SITE_URL=https://<domain> hashquiz supabase deploy --project <project-ref> [--dry-run]
|
|
69
83
|
```
|
|
70
84
|
|
|
71
|
-
It stages the project in a temp folder and runs `supabase link`, `supabase db push`,
|
|
85
|
+
It stages the project in a temp folder and runs `supabase link`, `supabase db push --remote`,
|
|
72
86
|
`supabase functions deploy solo-submit` and `supabase secrets set HASHQUIZ_SITE_URL=…`, stopping at the first
|
|
73
87
|
failure. The function reads `<HASHQUIZ_SITE_URL>/decks.json` at runtime, so deck changes need no redeploy.
|
|
74
88
|
`--site-url <url>` overrides `HASHQUIZ_SITE_URL` (an http(s) URL). It needs the
|
package/bin/hashquiz.js
CHANGED
|
@@ -3516,7 +3516,7 @@ function splitBlocks(content) {
|
|
|
3516
3516
|
const metaBlock = pieces[0];
|
|
3517
3517
|
const rest = pieces.slice(1);
|
|
3518
3518
|
if (rest.length % 2 !== 0) {
|
|
3519
|
-
throw new Error(`Malformed .
|
|
3519
|
+
throw new Error(`Malformed .hashquiz.md file: expected an even number of blocks after the meta section, got ${rest.length}`);
|
|
3520
3520
|
}
|
|
3521
3521
|
const questionBlocks = [];
|
|
3522
3522
|
for (let i = 0;i < rest.length; i += 2) {
|
|
@@ -3666,12 +3666,17 @@ function validateQuiz(quiz) {
|
|
|
3666
3666
|
errors.push({
|
|
3667
3667
|
questionIndex: i,
|
|
3668
3668
|
field: "choices",
|
|
3669
|
-
message: `Question ${i + 1} has ${q.choices.length} choices;
|
|
3669
|
+
message: `Question ${i + 1} has ${q.choices.length} choices; HashQuiz supports at most 4`
|
|
3670
3670
|
});
|
|
3671
3671
|
}
|
|
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 }),
|
|
@@ -3987,8 +3992,8 @@ class GameEngine {
|
|
|
3987
3992
|
}
|
|
3988
3993
|
// packages/core/src/runtime-config.ts
|
|
3989
3994
|
function configFromEnv(env) {
|
|
3990
|
-
const pick = (name) => env[`HASHQUIZ_${name}`] || env[`
|
|
3991
|
-
const grace = pick("GRACE_MS")
|
|
3995
|
+
const pick = (name) => env[`HASHQUIZ_${name}`] || env[`VITE_${name}`] || undefined;
|
|
3996
|
+
const grace = pick("GRACE_MS");
|
|
3992
3997
|
const n = grace !== undefined ? Number(grace) : NaN;
|
|
3993
3998
|
return {
|
|
3994
3999
|
transport: pick("TRANSPORT") === "supabase" ? "supabase" : "local",
|
|
@@ -4000,7 +4005,7 @@ function configFromEnv(env) {
|
|
|
4000
4005
|
};
|
|
4001
4006
|
}
|
|
4002
4007
|
function renderConfigScript(config) {
|
|
4003
|
-
return `window.
|
|
4008
|
+
return `window.__HASHQUIZ_CONFIG__ = ${JSON.stringify(config)};
|
|
4004
4009
|
`;
|
|
4005
4010
|
}
|
|
4006
4011
|
// packages/core/src/solo-verify.ts
|
|
@@ -4602,7 +4607,7 @@ function collectDecks(dir) {
|
|
|
4602
4607
|
const p = join(d, name);
|
|
4603
4608
|
if (statSync(p).isDirectory())
|
|
4604
4609
|
walk(p);
|
|
4605
|
-
else if (name.endsWith(".
|
|
4610
|
+
else if (name.endsWith(".hashquiz.md")) {
|
|
4606
4611
|
out.push({ id: relative(dir, p).split(sep).join("/"), content: readFileSync(p, "utf-8") });
|
|
4607
4612
|
}
|
|
4608
4613
|
}
|
|
@@ -4645,7 +4650,7 @@ var DEFAULT_GRACE_MS = 60000;
|
|
|
4645
4650
|
function resolveGraceMs(opt) {
|
|
4646
4651
|
if (typeof opt === "number" && Number.isFinite(opt) && opt >= 0)
|
|
4647
4652
|
return opt;
|
|
4648
|
-
const raw = process.env["
|
|
4653
|
+
const raw = process.env["HASHQUIZ_GRACE_MS"];
|
|
4649
4654
|
if (raw) {
|
|
4650
4655
|
const n = Number(raw);
|
|
4651
4656
|
if (Number.isFinite(n) && n >= 0)
|
|
@@ -4697,10 +4702,18 @@ function buildQuizInfo(quiz) {
|
|
|
4697
4702
|
hard: 100 - easyPct - mediumPct
|
|
4698
4703
|
};
|
|
4699
4704
|
}
|
|
4700
|
-
return {
|
|
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
|
-
class
|
|
4716
|
+
class HashQuizServer {
|
|
4704
4717
|
engine;
|
|
4705
4718
|
transport;
|
|
4706
4719
|
joinCode;
|
|
@@ -4928,7 +4941,7 @@ class QuizvServer {
|
|
|
4928
4941
|
const localIP = getLocalIP();
|
|
4929
4942
|
const playerURL = `http://${localIP}:${this.port}/play`;
|
|
4930
4943
|
console.log(`
|
|
4931
|
-
|
|
4944
|
+
HashQuiz Dev Server
|
|
4932
4945
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
4933
4946
|
Host: http://localhost:${this.port}
|
|
4934
4947
|
Players: ${playerURL}
|
|
@@ -4950,7 +4963,7 @@ class QuizvServer {
|
|
|
4950
4963
|
<html lang="en">
|
|
4951
4964
|
<head>
|
|
4952
4965
|
<meta charset="UTF-8">
|
|
4953
|
-
<title>
|
|
4966
|
+
<title>HashQuiz Host \u2014 ${this.joinCode}</title>
|
|
4954
4967
|
<style>
|
|
4955
4968
|
body { font-family: system-ui; background: #0a0a0f; color: #fff; padding: 2rem; }
|
|
4956
4969
|
button { background: #7c3aed; color: #fff; border: none; padding: 0.75rem 1.5rem;
|
|
@@ -4967,7 +4980,7 @@ class QuizvServer {
|
|
|
4967
4980
|
</style>
|
|
4968
4981
|
</head>
|
|
4969
4982
|
<body>
|
|
4970
|
-
<h1>
|
|
4983
|
+
<h1>HashQuiz Host Control</h1>
|
|
4971
4984
|
<p id="ws-status">Connecting...</p>
|
|
4972
4985
|
<div id="status">
|
|
4973
4986
|
<p>Join code: <strong>${this.joinCode}</strong></p>
|
|
@@ -5070,7 +5083,7 @@ class QuizvServer {
|
|
|
5070
5083
|
<head>
|
|
5071
5084
|
<meta charset="UTF-8">
|
|
5072
5085
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5073
|
-
<title>
|
|
5086
|
+
<title>HashQuiz Player</title>
|
|
5074
5087
|
<style>
|
|
5075
5088
|
body { font-family: system-ui; background: #0a0a0f; color: #fff; padding: 1rem;
|
|
5076
5089
|
max-width: 480px; margin: 0 auto; }
|
|
@@ -5087,7 +5100,7 @@ class QuizvServer {
|
|
|
5087
5100
|
</head>
|
|
5088
5101
|
<body>
|
|
5089
5102
|
<div id="join-screen">
|
|
5090
|
-
<h1>Join
|
|
5103
|
+
<h1>Join HashQuiz</h1>
|
|
5091
5104
|
<input id="code" placeholder="Join code (e.g. ABC123)" style="text-transform:uppercase;letter-spacing:0.15em" />
|
|
5092
5105
|
<input id="pseudo" placeholder="Your name" />
|
|
5093
5106
|
<input id="email" type="email" placeholder="Email (optional)" />
|
|
@@ -5230,7 +5243,7 @@ class QuizvServer {
|
|
|
5230
5243
|
}
|
|
5231
5244
|
|
|
5232
5245
|
// packages/server/src/dev.ts
|
|
5233
|
-
import { existsSync as
|
|
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,20 +5264,24 @@ 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
|
-
|
|
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");
|
|
5257
5274
|
}
|
|
5258
5275
|
|
|
5259
5276
|
// packages/server/src/dev.ts
|
|
5260
5277
|
function resolveDevTarget(arg, opts) {
|
|
5261
5278
|
const target = resolve4(arg);
|
|
5262
|
-
if (!
|
|
5279
|
+
if (!existsSync3(target))
|
|
5263
5280
|
throw new Error(`${arg} not found`);
|
|
5264
5281
|
if (statSync2(target).isDirectory()) {
|
|
5265
5282
|
const first = collectDecks(target)[0];
|
|
5266
5283
|
if (!first)
|
|
5267
|
-
throw new Error(`no .
|
|
5284
|
+
throw new Error(`no .hashquiz.md deck in ${arg}`);
|
|
5268
5285
|
return { quizFile: join2(target, first.id), decksDir: target };
|
|
5269
5286
|
}
|
|
5270
5287
|
const decksDir = opts.decksFlag ? resolve4(opts.decksFlag) : opts.repoRoot ? repoDecksDir(opts.repoRoot) : dirname2(target);
|
|
@@ -5273,14 +5290,14 @@ function resolveDevTarget(arg, opts) {
|
|
|
5273
5290
|
function devCommand(arg, port, decksFlag) {
|
|
5274
5291
|
const repo = findMonorepoRoot();
|
|
5275
5292
|
const { quizFile: absPath, decksDir } = resolveDevTarget(arg, { decksFlag, repoRoot: repo });
|
|
5276
|
-
const server = new
|
|
5293
|
+
const server = new HashQuizServer({ quizFile: absPath, port, decksDir });
|
|
5277
5294
|
server.start();
|
|
5278
5295
|
console.log(` Room deck: ${absPath}
|
|
5279
5296
|
Decks: ${decksDir}
|
|
5280
5297
|
`);
|
|
5281
5298
|
const children = [];
|
|
5282
5299
|
if (repo) {
|
|
5283
|
-
const env = { ...process.env,
|
|
5300
|
+
const env = { ...process.env, HASHQUIZ_DECKS_DIR: decksDir };
|
|
5284
5301
|
for (const app of ["apps/host", "apps/player"]) {
|
|
5285
5302
|
children.push(spawn("bun", ["run", "dev"], { cwd: resolve4(repo, app), stdio: "inherit", shell: false, env }));
|
|
5286
5303
|
}
|
|
@@ -5316,7 +5333,7 @@ function serveStatic(root, port, home, decksDir) {
|
|
|
5316
5333
|
hostname: "0.0.0.0",
|
|
5317
5334
|
fetch(req) {
|
|
5318
5335
|
const { pathname } = new URL(req.url);
|
|
5319
|
-
if (pathname === "/
|
|
5336
|
+
if (pathname === "/hashquiz-config.js") {
|
|
5320
5337
|
return new Response(config, { headers: { "Content-Type": "text/javascript" } });
|
|
5321
5338
|
}
|
|
5322
5339
|
if (pathname === "/decks.json" || pathname === "/host/decks.json") {
|
|
@@ -5327,7 +5344,7 @@ function serveStatic(root, port, home, decksDir) {
|
|
|
5327
5344
|
const file = resolve4(join2(root, decodeURIComponent(pathname)));
|
|
5328
5345
|
if (!file.startsWith(root))
|
|
5329
5346
|
return new Response("Not found", { status: 404 });
|
|
5330
|
-
if (
|
|
5347
|
+
if (existsSync3(file) && statSync2(file).isFile())
|
|
5331
5348
|
return new Response(Bun.file(file));
|
|
5332
5349
|
const index = pathname.startsWith("/host") ? join2(root, "host/index.html") : join2(root, "index.html");
|
|
5333
5350
|
return new Response(Bun.file(index));
|
|
@@ -5336,15 +5353,68 @@ function serveStatic(root, port, home, decksDir) {
|
|
|
5336
5353
|
}
|
|
5337
5354
|
|
|
5338
5355
|
// packages/server/src/build.ts
|
|
5339
|
-
import { cpSync, existsSync as
|
|
5356
|
+
import { cpSync, existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, statSync as statSync3, writeFileSync } from "fs";
|
|
5340
5357
|
import { resolve as resolve5 } from "path";
|
|
5341
|
-
|
|
5358
|
+
|
|
5359
|
+
// packages/server/src/seo.ts
|
|
5360
|
+
var TRUE = new Set(["1", "true", "yes"]);
|
|
5361
|
+
function seoFromEnv(env) {
|
|
5362
|
+
const settings = { indexable: TRUE.has((env.HASHQUIZ_INDEXABLE ?? "").trim().toLowerCase()) };
|
|
5363
|
+
const rawUrl = env.HASHQUIZ_SITE_URL?.trim();
|
|
5364
|
+
if (rawUrl) {
|
|
5365
|
+
let url;
|
|
5366
|
+
try {
|
|
5367
|
+
url = new URL(rawUrl);
|
|
5368
|
+
} catch {
|
|
5369
|
+
throw new Error(`HASHQUIZ_SITE_URL is not a URL: ${rawUrl}`);
|
|
5370
|
+
}
|
|
5371
|
+
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
5372
|
+
throw new Error(`HASHQUIZ_SITE_URL must be http(s): ${rawUrl}`);
|
|
5373
|
+
settings.siteUrl = `${url.origin}${url.pathname}`.replace(/\/+$/, "");
|
|
5374
|
+
}
|
|
5375
|
+
const lang = env.HASHQUIZ_LANG?.trim();
|
|
5376
|
+
if (lang) {
|
|
5377
|
+
if (!/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$/.test(lang))
|
|
5378
|
+
throw new Error(`HASHQUIZ_LANG is not a language tag: ${lang}`);
|
|
5379
|
+
settings.lang = lang;
|
|
5380
|
+
}
|
|
5381
|
+
return settings;
|
|
5382
|
+
}
|
|
5383
|
+
var escapeAttr = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
5384
|
+
function applySeo(html, settings) {
|
|
5385
|
+
let out = html;
|
|
5386
|
+
if (settings.lang)
|
|
5387
|
+
out = out.replace(/<html lang="[^"]*">/, `<html lang="${escapeAttr(settings.lang)}">`);
|
|
5388
|
+
if (settings.indexable)
|
|
5389
|
+
out = out.replace(/[ \t]*<meta name="robots" content="noindex">\n?/, "");
|
|
5390
|
+
if (settings.siteUrl) {
|
|
5391
|
+
const home = `${settings.siteUrl}/`;
|
|
5392
|
+
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)}">
|
|
5393
|
+
<meta property="og:url" content="${escapeAttr(home)}">`);
|
|
5394
|
+
}
|
|
5395
|
+
return out;
|
|
5396
|
+
}
|
|
5397
|
+
function renderRobots(settings, hasSitemap) {
|
|
5398
|
+
const lines = ["# Written by `hashquiz build`. Ship your own public/robots.txt to replace it.", "User-agent: *", "Disallow: /host", ""];
|
|
5399
|
+
if (hasSitemap && settings.siteUrl)
|
|
5400
|
+
lines.push(`Sitemap: ${settings.siteUrl}/sitemap.xml`, "");
|
|
5401
|
+
return lines.join(`
|
|
5402
|
+
`);
|
|
5403
|
+
}
|
|
5404
|
+
|
|
5405
|
+
// packages/server/src/build.ts
|
|
5406
|
+
function buildSite({ decksDir, outDir, publicDir, env = process.env }) {
|
|
5407
|
+
const seo = seoFromEnv(env);
|
|
5408
|
+
const publicAbs = publicDir !== undefined ? resolve5(publicDir) : resolve5("public");
|
|
5409
|
+
if (publicDir !== undefined && !(existsSync4(publicAbs) && statSync3(publicAbs).isDirectory())) {
|
|
5410
|
+
throw new Error(`Public folder not found: ${publicDir}`);
|
|
5411
|
+
}
|
|
5342
5412
|
const decksAbs = resolve5(decksDir);
|
|
5343
|
-
if (!
|
|
5413
|
+
if (!existsSync4(decksAbs))
|
|
5344
5414
|
throw new Error(`Decks folder not found: ${decksDir}`);
|
|
5345
5415
|
const decks = collectDecks(decksAbs);
|
|
5346
5416
|
if (decks.length === 0)
|
|
5347
|
-
throw new Error(`No .
|
|
5417
|
+
throw new Error(`No .hashquiz.md file found in ${decksDir}`);
|
|
5348
5418
|
const problems = [];
|
|
5349
5419
|
for (const { id, content } of decks) {
|
|
5350
5420
|
try {
|
|
@@ -5363,22 +5433,29 @@ function buildSite({ decksDir, outDir, env = process.env }) {
|
|
|
5363
5433
|
`)}`);
|
|
5364
5434
|
const web = findWebDist();
|
|
5365
5435
|
if (!web)
|
|
5366
|
-
throw new Error("Prebuilt web apps not found (in the
|
|
5436
|
+
throw new Error("Prebuilt web apps not found (in the hashquiz repo, run `bun run build:web` first)");
|
|
5367
5437
|
const out = resolve5(outDir);
|
|
5368
5438
|
if (out === decksAbs)
|
|
5369
5439
|
throw new Error("--out must differ from the decks folder");
|
|
5370
5440
|
rmSync(out, { recursive: true, force: true });
|
|
5371
5441
|
mkdirSync2(out, { recursive: true });
|
|
5372
5442
|
cpSync(web, out, { recursive: true });
|
|
5443
|
+
const hasPublic = existsSync4(publicAbs) && statSync3(publicAbs).isDirectory();
|
|
5444
|
+
const hasSitemap = hasPublic && existsSync4(resolve5(publicAbs, "sitemap.xml"));
|
|
5445
|
+
writeFileSync(resolve5(out, "robots.txt"), renderRobots(seo, hasSitemap));
|
|
5446
|
+
if (hasPublic)
|
|
5447
|
+
cpSync(publicAbs, out, { recursive: true });
|
|
5448
|
+
const playerHtml = resolve5(out, "index.html");
|
|
5449
|
+
writeFileSync(playerHtml, applySeo(readFileSync3(playerHtml, "utf-8"), seo));
|
|
5373
5450
|
const manifest = JSON.stringify(decks);
|
|
5374
5451
|
writeFileSync(resolve5(out, "host/decks.json"), manifest);
|
|
5375
5452
|
writeFileSync(resolve5(out, "decks.json"), manifest);
|
|
5376
|
-
writeFileSync(resolve5(out, "
|
|
5453
|
+
writeFileSync(resolve5(out, "hashquiz-config.js"), renderConfigScript(configFromEnv(env)));
|
|
5377
5454
|
return decks.length;
|
|
5378
5455
|
}
|
|
5379
5456
|
|
|
5380
5457
|
// packages/backend-supabase/src/cli/edge-bundle.ts
|
|
5381
|
-
import { existsSync as
|
|
5458
|
+
import { existsSync as existsSync5 } from "fs";
|
|
5382
5459
|
import { mkdir } from "fs/promises";
|
|
5383
5460
|
import { dirname as dirname3, join as join3 } from "path";
|
|
5384
5461
|
var EDGE_CORE_FILE = "functions/_shared/solo-core.js";
|
|
@@ -5386,7 +5463,7 @@ var EDGE_CORE_BANNER = `import { Buffer } from "node:buffer";
|
|
|
5386
5463
|
`;
|
|
5387
5464
|
function edgeCoreEntry() {
|
|
5388
5465
|
const entry = join3(import.meta.dir, "../edge/solo-core.ts");
|
|
5389
|
-
return
|
|
5466
|
+
return existsSync5(entry) ? entry : null;
|
|
5390
5467
|
}
|
|
5391
5468
|
async function bundleEdgeCore(outFile) {
|
|
5392
5469
|
const entry = edgeCoreEntry();
|
|
@@ -5406,7 +5483,7 @@ function stripModulePathComments(code) {
|
|
|
5406
5483
|
}
|
|
5407
5484
|
if (false) {}
|
|
5408
5485
|
// packages/backend-supabase/src/cli/deploy.ts
|
|
5409
|
-
import { existsSync as
|
|
5486
|
+
import { existsSync as existsSync6, statSync as statSync4 } from "fs";
|
|
5410
5487
|
import { cp, mkdtemp, rm } from "fs/promises";
|
|
5411
5488
|
import { tmpdir } from "os";
|
|
5412
5489
|
import { basename, join as join4, resolve as resolve6 } from "path";
|
|
@@ -5414,17 +5491,17 @@ var USAGE = "Usage: hashquiz supabase deploy --project <ref> [--site-url <url>]
|
|
|
5414
5491
|
var SECRET_ENV = ["SUPABASE_ACCESS_TOKEN", "SUPABASE_DB_PASSWORD"];
|
|
5415
5492
|
function supabaseDeploySteps(o) {
|
|
5416
5493
|
const bin = o.supabaseBin ?? "supabase";
|
|
5417
|
-
const ref = ["--project-ref", o.projectRef];
|
|
5418
5494
|
const wd = ["--workdir", o.workdir];
|
|
5495
|
+
const remote = `--remote=${o.projectRef}`;
|
|
5419
5496
|
return [
|
|
5420
|
-
{ label: "link project", argv: [bin, "link",
|
|
5421
|
-
{ label: "push migrations", argv: [bin, "db", "push", ...wd, "--yes"] },
|
|
5422
|
-
{ label: "deploy solo-submit", argv: [bin, "functions", "deploy", "solo-submit",
|
|
5423
|
-
{ label: "set HASHQUIZ_SITE_URL", argv: [bin, "secrets", "set", `HASHQUIZ_SITE_URL=${o.siteUrl}`,
|
|
5497
|
+
{ label: "link project", argv: [bin, "link", "--project-ref", o.projectRef, ...wd] },
|
|
5498
|
+
{ label: "push migrations", argv: [bin, "db", "push", remote, ...wd, "--yes"] },
|
|
5499
|
+
{ label: "deploy solo-submit", argv: [bin, "functions", "deploy", "solo-submit", remote, ...wd] },
|
|
5500
|
+
{ label: "set HASHQUIZ_SITE_URL", argv: [bin, "secrets", "set", `HASHQUIZ_SITE_URL=${o.siteUrl}`, remote, ...wd] }
|
|
5424
5501
|
];
|
|
5425
5502
|
}
|
|
5426
5503
|
function isProject(dir) {
|
|
5427
|
-
return
|
|
5504
|
+
return existsSync6(join4(dir, "config.toml"));
|
|
5428
5505
|
}
|
|
5429
5506
|
function findSupabaseDir() {
|
|
5430
5507
|
const here = import.meta.dirname;
|
|
@@ -5436,17 +5513,17 @@ function findSupabaseDir() {
|
|
|
5436
5513
|
}
|
|
5437
5514
|
async function copySupabaseProject(src, destSupabaseDir, edgeCore) {
|
|
5438
5515
|
const coreFile = resolve6(src, EDGE_CORE_FILE);
|
|
5439
|
-
if (edgeCore === "copy" && !
|
|
5516
|
+
if (edgeCore === "copy" && !existsSync6(coreFile)) {
|
|
5440
5517
|
throw new Error(`supabase: ${EDGE_CORE_FILE} missing in ${src} (run \`bun run build:edge\`)`);
|
|
5441
5518
|
}
|
|
5442
5519
|
await cp(join4(src, "config.toml"), join4(destSupabaseDir, "config.toml"));
|
|
5443
5520
|
for (const dir of ["migrations", "functions"]) {
|
|
5444
|
-
if (!
|
|
5521
|
+
if (!existsSync6(join4(src, dir)))
|
|
5445
5522
|
continue;
|
|
5446
5523
|
await cp(join4(src, dir), join4(destSupabaseDir, dir), {
|
|
5447
5524
|
recursive: true,
|
|
5448
5525
|
filter: (p) => {
|
|
5449
|
-
if (basename(p).startsWith(".env") && !
|
|
5526
|
+
if (basename(p).startsWith(".env") && !statSync4(p).isDirectory())
|
|
5450
5527
|
return false;
|
|
5451
5528
|
return edgeCore === "copy" || resolve6(p) !== coreFile;
|
|
5452
5529
|
}
|
|
@@ -5552,25 +5629,27 @@ async function supabaseCommand(args, env, run = defaultRunner, log = console.log
|
|
|
5552
5629
|
return 1;
|
|
5553
5630
|
}
|
|
5554
5631
|
// packages/server/src/cli.ts
|
|
5555
|
-
import { readFileSync as
|
|
5632
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
5556
5633
|
import { resolve as resolve7 } from "path";
|
|
5557
5634
|
var [, , command, arg, ...flags] = process.argv;
|
|
5558
5635
|
function printUsage() {
|
|
5559
5636
|
console.log(`
|
|
5560
|
-
hashquiz <command> [options] (
|
|
5637
|
+
hashquiz <command> [options] (hashquiz from the sources)
|
|
5561
5638
|
|
|
5562
5639
|
Commands:
|
|
5563
|
-
dev <quiz.
|
|
5640
|
+
dev <quiz.hashquiz.md | decks-dir> [--decks <dir>]
|
|
5564
5641
|
Start the local dev stack. A file is the room
|
|
5565
5642
|
deck; a folder is the decks folder (room deck =
|
|
5566
5643
|
its first deck by id). Solo runs are stored in
|
|
5567
5644
|
.hashquiz/solo.db.
|
|
5568
|
-
check <quiz.
|
|
5645
|
+
check <quiz.hashquiz.md> Validate quiz file format
|
|
5569
5646
|
build [decks-dir] Build the static site (host + player) for a decks
|
|
5570
5647
|
folder (default: decks). Reads HASHQUIZ_TRANSPORT,
|
|
5571
5648
|
HASHQUIZ_SUPABASE_URL, HASHQUIZ_SUPABASE_ANON_KEY,
|
|
5572
5649
|
HASHQUIZ_SOLO_SCORING, HASHQUIZ_PLAYER_URL
|
|
5573
|
-
(or their
|
|
5650
|
+
(or their VITE_* names) from the environment, and
|
|
5651
|
+
HASHQUIZ_SITE_URL, HASHQUIZ_LANG,
|
|
5652
|
+
HASHQUIZ_INDEXABLE for search engines.
|
|
5574
5653
|
supabase deploy --project <ref> [--site-url <url>] [--dry-run]
|
|
5575
5654
|
Deploy the solo backend to a Supabase project:
|
|
5576
5655
|
migrations, the solo-submit Edge Function and its
|
|
@@ -5582,9 +5661,12 @@ function printUsage() {
|
|
|
5582
5661
|
Options:
|
|
5583
5662
|
--port <number> Port to listen on (default: 3030)
|
|
5584
5663
|
--decks <dir> Decks folder for dev with a file (default: the
|
|
5585
|
-
repo's
|
|
5586
|
-
file's folder)
|
|
5664
|
+
repo's decks/ or tests/fixtures/ from the
|
|
5665
|
+
sources, else the file's folder)
|
|
5587
5666
|
--out <dir> Output folder for build (default: dist)
|
|
5667
|
+
--public <dir> Files copied to the site root by build, e.g.
|
|
5668
|
+
robots.txt, llms.txt, og.png (default: ./public
|
|
5669
|
+
when it exists)
|
|
5588
5670
|
`);
|
|
5589
5671
|
}
|
|
5590
5672
|
if (!command || command === "--help" || command === "-h") {
|
|
@@ -5600,8 +5682,8 @@ var port = parseInt(flag("--port") ?? "3030");
|
|
|
5600
5682
|
var positional = args.find((a, i) => !a.startsWith("--") && !(i > 0 && args[i - 1].startsWith("--")));
|
|
5601
5683
|
if (command === "dev") {
|
|
5602
5684
|
if (!positional) {
|
|
5603
|
-
console.error(`Error: provide a .
|
|
5604
|
-
|
|
5685
|
+
console.error(`Error: provide a .hashquiz.md file or a decks folder
|
|
5686
|
+
hashquiz dev quiz.hashquiz.md`);
|
|
5605
5687
|
process.exit(1);
|
|
5606
5688
|
}
|
|
5607
5689
|
try {
|
|
@@ -5614,7 +5696,7 @@ if (command === "dev") {
|
|
|
5614
5696
|
const decksDir = positional ?? "decks";
|
|
5615
5697
|
const outDir = flag("--out") ?? "dist";
|
|
5616
5698
|
try {
|
|
5617
|
-
const count = buildSite({ decksDir, outDir });
|
|
5699
|
+
const count = buildSite({ decksDir, outDir, publicDir: flag("--public") });
|
|
5618
5700
|
console.log(`\u2713 Built ${count} deck(s) from ${decksDir} into ${outDir}`);
|
|
5619
5701
|
} catch (e) {
|
|
5620
5702
|
console.error(`\u2717 ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -5624,12 +5706,12 @@ if (command === "dev") {
|
|
|
5624
5706
|
process.exit(await supabaseCommand(args, process.env));
|
|
5625
5707
|
} else if (command === "check") {
|
|
5626
5708
|
if (!arg) {
|
|
5627
|
-
console.error(`Error: provide a .
|
|
5628
|
-
|
|
5709
|
+
console.error(`Error: provide a .hashquiz.md file path
|
|
5710
|
+
hashquiz check quiz.hashquiz.md`);
|
|
5629
5711
|
process.exit(1);
|
|
5630
5712
|
}
|
|
5631
5713
|
try {
|
|
5632
|
-
const content =
|
|
5714
|
+
const content = readFileSync4(resolve7(arg), "utf-8");
|
|
5633
5715
|
const quiz = parseQuizFile(content);
|
|
5634
5716
|
const result = validateQuiz(quiz);
|
|
5635
5717
|
if (result.valid) {
|
package/package.json
CHANGED
package/supabase/config.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# https://supabase.com/docs/guides/local-development/cli/config
|
|
3
3
|
# A string used to distinguish different Supabase projects on the same host. Defaults to the
|
|
4
4
|
# working directory name when running `supabase init`.
|
|
5
|
-
project_id = "
|
|
5
|
+
project_id = "hashquiz"
|
|
6
6
|
|
|
7
7
|
[api]
|
|
8
8
|
enabled = true
|
|
@@ -3476,7 +3476,7 @@ function splitBlocks(content) {
|
|
|
3476
3476
|
const metaBlock = pieces[0];
|
|
3477
3477
|
const rest = pieces.slice(1);
|
|
3478
3478
|
if (rest.length % 2 !== 0) {
|
|
3479
|
-
throw new Error(`Malformed .
|
|
3479
|
+
throw new Error(`Malformed .hashquiz.md file: expected an even number of blocks after the meta section, got ${rest.length}`);
|
|
3480
3480
|
}
|
|
3481
3481
|
const questionBlocks = [];
|
|
3482
3482
|
for (let i = 0;i < rest.length; i += 2) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
-- Solo live mode: finished solo runs, their answers, the scoring-mode switch and
|
|
1
|
+
-- Solo live mode: finished solo runs, their answers, the scoring-mode switch and HashQuiz leads.
|
|
2
2
|
-- anon never writes solo_runs / solo_answers directly: browser mode goes through submit_solo_run
|
|
3
3
|
-- (security definer, gated by solo_settings.scoring_mode), edge mode through the solo-submit
|
|
4
4
|
-- Edge Function (service role). See docs/TECHNICAL_GUIDE.md.
|
|
@@ -129,7 +129,7 @@ end;
|
|
|
129
129
|
$$;
|
|
130
130
|
|
|
131
131
|
-- Rank of a run within its deck leaderboard: score desc, total_time_ms asc, finished_at asc
|
|
132
|
-
-- (same order as compareRuns in @
|
|
132
|
+
-- (same order as compareRuns in @hashquiz/core).
|
|
133
133
|
create function public.solo_rank(p_run_id uuid)
|
|
134
134
|
returns int
|
|
135
135
|
language sql
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.solo-catalog[data-v-09d9ea2c]{width:100%;margin-top:2.5rem}.solo-catalog__title[data-v-09d9ea2c]{text-align:center;color:var(--hq-text-muted);margin:0 0 1rem;font-size:1rem;font-weight:600}.solo-catalog__list[data-v-09d9ea2c]{flex-direction:column;gap:.75rem;margin:0;padding:0;list-style:none;display:flex}.solo-catalog__card[data-v-09d9ea2c]{color:inherit;border-radius:var(--hq-radius);text-decoration:none;display:block}.solo-catalog__card[data-v-09d9ea2c] .qip{transition:border-color .15s,transform .12s steps(2,end),box-shadow .12s steps(2,end)}.solo-catalog__card[data-v-09d9ea2c]:hover .qip{border-color:var(--hq-accent);transform:translate(calc(var(--hq-pixel) * -1), calc(var(--hq-pixel) * -1));box-shadow:var(--hq-pixel) var(--hq-pixel) 0 var(--hq-accent-2)}.solo-catalog__card[data-v-09d9ea2c]:focus-visible{outline:2px solid var(--hq-accent);outline-offset:3px}@media (prefers-reduced-motion:reduce){.solo-catalog__card[data-v-09d9ea2c]:hover .qip{transform:none}}
|
|
@@ -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-
|
|
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
|
+
.solo-board[data-v-bddd0413]{flex-direction:column;gap:.5rem;width:100%;display:flex}.solo-board__title[data-v-bddd0413]{color:var(--hq-text-muted);margin:0;font-size:.8rem}.solo-board__list[data-v-bddd0413]{flex-direction:column;gap:.35rem;margin:0;padding:0;list-style:none;display:flex}.solo-board__row[data-v-bddd0413]{background:var(--hq-surface);border:1px solid var(--hq-border);border-radius:var(--hq-radius-sm);grid-template-columns:2rem 1fr auto 3.5rem;align-items:center;gap:.5rem;padding:.55rem .75rem;font-size:.95rem;display:grid}.solo-board__row--live[data-v-bddd0413]{border-style:dashed}.solo-board__row--mine[data-v-bddd0413]{border-color:var(--hq-accent);background:color-mix(in srgb, var(--hq-accent) 18%, var(--hq-surface))}.solo-board__row--gap[data-v-bddd0413]{margin-top:.5rem}.solo-board__rank[data-v-bddd0413]{color:var(--hq-text-muted);font-weight:700}.solo-board__badge[data-v-bddd0413]{color:var(--hq-accent-2);font-weight:600}.solo-board__dot[data-v-bddd0413]:before{content:"";border-radius:var(--hq-radius-sm);background:var(--hq-accent-2);width:.5rem;height:.5rem;animation:1.6s steps(2,jump-none) infinite solo-pulse-bddd0413;display:block}@keyframes solo-pulse-bddd0413{50%{opacity:.3}}@media (prefers-reduced-motion:reduce){.solo-board__dot[data-v-bddd0413]:before{animation:none}}.solo-board__name[data-v-bddd0413]{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.solo-board__meta[data-v-bddd0413]{color:var(--hq-text-muted);font-variant-numeric:tabular-nums;font-size:.8rem}.solo-board__score[data-v-bddd0413]{text-align:right;font-variant-numeric:tabular-nums;font-weight:700}.solo-board__empty[data-v-bddd0413]{color:var(--hq-text-muted);margin:0;font-size:.9rem}
|