Compare commits

...

2 commits

Author SHA1 Message Date
ca39b76282 Standardize public images on WebP and add conversion tooling
All checks were successful
Deploy Sokko G / deploy (push) Successful in 20s
2026-10-23 12:12:02 +02:00
75592d7d7a Fix cache policy for stable public assets 2026-10-23 10:41:10 +02:00
886 changed files with 673 additions and 129 deletions

View file

@ -102,3 +102,7 @@
{"id":"int-a7f31afcb66a0c2f9a2802ec7fcb0f25","kind":"field_change","created_at":"2026-10-22T20:52:18.039208354Z","actor":"Shinuwa","issue_id":"sokko-g-203","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Ajout Librairie vers toolbox livré avec copie vide/état courant, création transactionnelle, remappage des IDs et dépendances, tests unitaires et Playwright."}}
{"id":"int-a4d97f7295591e6d4affc3be37716e82","kind":"field_change","created_at":"2026-10-22T20:59:56.2557932Z","actor":"Shinuwa","issue_id":"sokko-g-xnm","extra":{"field":"status","new_value":"deferred","old_value":"open"}}
{"id":"int-1d89b4925c5f2f13cc06799a38e7aa0a","kind":"field_change","created_at":"2026-10-22T21:26:48.145195662Z","actor":"Shinuwa","issue_id":"sokko-g-qru","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Vulnerable build dependencies updated within compatible ranges; npm ci and npm audit succeed with 0 vulnerabilities; check, 195 development E2E tests, and 2 production E2E tests pass."}}
{"id":"int-f9129c0d163031072641ff2ba12cef12","kind":"field_change","created_at":"2026-10-23T08:38:03.134514281Z","actor":"Shinuwa","issue_id":"sokko-g-x8x","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Cache immutable limité aux assets Vite hashés ; HTML et 404 en no-store, JSON et fichiers stables en no-cache. Test HTTP direct de server.mjs ajouté, remplacement d’image et bundle manquant couverts, politique proxy documentée. Validation : 163 tests Node, 195 E2E développement et 2 E2E production via check:full. Le proxy externe reste à vérifier lors d’une livraison autorisée."}}
{"id":"int-b012ccf740a63f5c425f769b6c047930","kind":"field_change","created_at":"2026-10-23T09:39:02.686427451Z","actor":"Shinuwa","issue_id":"sokko-g-wuh","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Profil reproductible ajouté avec budgets. Illustrations générales, onboarding, covers, heroes et 226 assets Aniimo convertis en WebP sans doublons PNG ; images publiques 119936848 -> 19050339 octets. Accueil 3383725 -> 1475772 octets transférés, Aniimo 18671748 -> 2605952, CSS gzip 69968 -> 67769. Inspection visuelle des échantillons et dimensions Aniimo 512x840 vérifiées. check:full vert : 163 tests Node, 195 E2E développement, 2 E2E production. Aucun commit ni push."}}
{"id":"int-bea709bf0f61ecac93a4a81a3566b14c","kind":"field_change","created_at":"2026-10-23T09:47:41.81042291Z","actor":"Shinuwa","issue_id":"sokko-g-wuh","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Ajout du workflow réutilisable images:convert basé sur ffmpeg : conversion ciblée fichier/dossier, conservation PNG par défaut, remplacement et écrasement explicites, dry-run, réglages qualité/preset/sans perte, écriture atomique et refus automatique d’un WebP plus lourd. Vérifié sur un PNG déjà optimisé conservé et une illustration réduite de 650838 à 143492 octets ; npm run check vert avec 163 tests Node et build."}}
{"id":"int-94ccc3ac8e0dc0c9ea3aaf1b4eeceb99","kind":"field_change","created_at":"2026-10-23T10:08:54.90535458Z","actor":"Shinuwa","issue_id":"sokko-g-wuh","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"All public raster assets now use WebP, future PNG conversion is automated, legacy toolbox icon paths migrate safely, performance budgets are documented, and check:full passes."}}

View file

@ -34,6 +34,8 @@ npm run build
Le build est généré dans `website/dist`.
`npm start` sert cette version statique avec `server.mjs`.
La politique de cache HTTP et les vérifications attendues côté proxy sont
documentées dans [`docs/DELIVERY.md`](docs/DELIVERY.md).
## Configuration
@ -104,6 +106,12 @@ de la machine et ne couvrent pas le décodage des images dans une toolbox ouvert
Le profil suit les lectures groupées et ciblées et vérifie que les valeurs des
outils Images restent sur disque tant qu'aucune toolbox n'est ouverte.
Pour mesurer les ressources publiques de l'accueil et d'Aniimo, lancer
`npm run profile:assets -- current`. Le protocole, la référence avant/après et
les budgets sont documentés dans [`docs/PERFORMANCE.md`](docs/PERFORMANCE.md).
Cette documentation décrit aussi `npm run images:convert`, la commande prévue
pour convertir les prochains PNG vers le format raster WebP utilisé par le site.
## Contenu éditable
Les contenus maintenus à la main sont regroupés dans `website/public/data`.
@ -121,7 +129,8 @@ Les contenus maintenus à la main sont regroupés dans `website/public/data`.
| `website/public/data/diablo4/affixes_types.json` | Données et filtres des affixes Diablo IV. |
| `website/public/data/toolbox-icons.json` | Manifeste des icônes SVG réutilisables. |
Les images publiques sont dans `website/public/static`.
Les images publiques sont dans `website/public/static`. Les images raster
livrées par le site utilisent WebP ; les icônes vectorielles utilisent SVG.
Les index de listes sont générés automatiquement par :

39
docs/DELIVERY.md Normal file
View file

@ -0,0 +1,39 @@
# Livraison
## Serveur statique
`npm run build` produit l'application dans `website/dist`. `npm start` sert ce
répertoire avec `server.mjs`. Les tests de Vite Preview couvrent le comportement
du build dans le navigateur, mais pas les en-têtes HTTP de ce serveur Node.
La politique de cache du serveur est la suivante :
| Ressource | `Cache-Control` | Raison |
| --- | --- | --- |
| HTML et fallback des routes React | `no-store` | Le document doit toujours pouvoir pointer vers le build courant. |
| JSON éditorial et données de jeu | `no-cache` | Le navigateur peut stocker la réponse, mais doit la redemander avant réutilisation. |
| Fichiers hashés sous `/assets/` | `public, max-age=31536000, immutable` | Une nouvelle version reçoit une nouvelle URL lors du build Vite. |
| Images, icônes et autres fichiers à URL stable | `no-cache` | Un remplacement au même chemin doit être visible sans vider le cache. |
| Ressources absentes | `no-store` | Un ancien bundle manquant ne doit pas laisser une réponse 404 persistante. |
`tests/server-cache.test.mjs` démarre directement `server.mjs` sur un port
éphémère et vérifie ces cinq cas. Il ne remplace pas les tests E2E de production,
qui continuent à valider le chargement et la récupération d'un bundle périmé.
## Proxy de production
La configuration du proxy et le script `/usr/local/bin/deploy-sokko-g` sont
externes à ce dépôt. Le proxy doit transmettre les en-têtes ci-dessus sans
ajouter de cache immuable aux URL stables. Cette propriété doit être vérifiée
sur l'origine publique après une livraison autorisée, par exemple avec :
```bash
curl -I https://example.invalid/
curl -I https://example.invalid/data/site.json
curl -I https://example.invalid/static/img/dragon-sidebar.webp
curl -I https://example.invalid/assets/<fichier-hashé>.js
```
Le nom du bundle doit être repris depuis le build effectivement livré. Une
prévisualisation Vite locale ne permet pas de conclure sur les règles ajoutées
par le proxy.

95
docs/PERFORMANCE.md Normal file
View file

@ -0,0 +1,95 @@
# Performance des ressources publiques
## Profil reproductible
Le profil construit la production, la sert avec `server.mjs` sur un port local
éphémère et ouvre un contexte Chromium neuf en 1440 × 900, sans limitation du
réseau. Il mesure d'abord l'accueil à cache froid, puis une navigation vers la
liste Aniimo dans le même contexte.
```bash
npm run profile:assets -- current
```
Le rapport détaillé est écrit dans
`.local/performance/public-assets-current.json`, hors Git. La mesure doit être
exécutée seule, sans autre build ou test navigateur en parallèle. Les octets de
transfert incluent les en-têtes du serveur HTTP local ; ils servent à comparer
des passages réalisés avec le même protocole, pas à prédire exactement le coût
sur l'origine publique.
## Référence du 23 octobre 2026
Les deux passages utilisent le même build, le même serveur, Chromium, le même
viewport et le même ordre de navigation.
| Mesure | Avant | Après | Évolution |
| --- | ---: | ---: | ---: |
| Images dans `public/static/img` | 119 936 848 o | 17 841 722 o | -85,1 % |
| Accueil à froid, transfert total | 3 383 725 o | 1 483 124 o | -56,2 % |
| Accueil à froid, images | 2 355 022 o | 460 312 o | -80,5 % |
| Aniimo après l'accueil, transfert total | 18 671 748 o | 2 599 378 o | -86,1 % |
| Aniimo après l'accueil, images | 18 455 371 o | 2 389 575 o | -87,1 % |
| CSS initial brut | 494 099 o | 480 835 o | -2,7 % |
| CSS initial gzip | 69 968 o | 67 769 o | -3,1 % |
Toutes les images raster livrées depuis `public/static/img` utilisent désormais
WebP à leurs dimensions d'origine. Les réglages retenus après inspection des
exemples sont une qualité 90 pour les portraits et illustrations, 92 pour les
captures contenant du texte et 88 pour les covers et heroes. Les petites images
métier de Monster Hunter Wilds et les icônes de toolbox utilisent WebP sans
perte. Les ressources vectorielles restent en SVG.
Les styles du catalogue `/design-system`, disponible uniquement en
développement, sont chargés avec sa page au lieu d'être inclus dans la feuille
de production initiale.
## Ajouter une nouvelle image raster
La conversion est volontairement séparée de `npm run build` : le build ne doit
pas réécrire les sources ni dépendre de `ffmpeg`. Pour convertir un fichier ou
un dossier récursivement :
```bash
npm run images:convert -- website/public/static/img/nouvelle-image.png
npm run images:convert -- website/public/static/img/nouveau-dossier
```
Le format raster canonique du site est WebP. La commande crée le WebP dans le
même dossier et supprime le PNG après une conversion réussie. Les réglages
peuvent être adaptés au contenu :
```bash
# Illustration ou portrait : réglage par défaut
npm run images:convert -- chemin/image.png --quality=90 --preset=picture
# Capture contenant de petits textes
npm run images:convert -- chemin/capture.png --quality=92 --preset=picture
# Cover ou grand arrière-plan
npm run images:convert -- chemin/hero.png --quality=88 --preset=picture
# Icône ou image devant rester strictement sans perte
npm run images:convert -- chemin/icone.png --lossless
```
Utiliser `--keep-source` seulement pour conserver temporairement le PNG pendant
une comparaison visuelle, puis le supprimer avant le commit. `--force` autorise
le remplacement d'un WebP existant et `--dry-run` affiche le travail prévu sans
écrire de fichier. Si le WebP obtenu est plus lourd, la commande conserve le PNG
et n'écrit rien ; `--allow-larger` permet de forcer exceptionnellement ce
résultat afin de garder le format canonique.
## Budgets du profil
Le script échoue si l'un des plafonds suivants est dépassé :
| Mesure | Plafond |
| --- | ---: |
| Images publiques | 25 000 000 o |
| Accueil à froid | 1 750 000 o transférés |
| Aniimo après l'accueil | 3 000 000 o transférés |
| Chaque bundle CSS | 70 000 o gzip |
Ces plafonds gardent une marge pour les évolutions éditoriales. Ils s'appliquent
au profil local explicite et ne sont pas lancés par `npm run check`.

View file

@ -171,7 +171,7 @@ Les toolboxes sont stockées dans `kv/toolboxes`.
"id": "tbx1",
"name": "Monster Hunter Wilds",
"gameId": "mhwilds",
"icon": "/static/img/toolbox-icons/toolbox.png",
"icon": "/static/img/toolbox-icons/toolbox.webp",
"customCover": "data:image/webp;base64,...",
"modules": [
{
@ -203,6 +203,7 @@ Notes :
- `gameId` est vide pour une toolbox libre.
- `icon` est utilisé uniquement pour les toolboxes libres.
- Les anciens chemins d'icône en `.png` sont normalisés vers leur équivalent `.webp` à la lecture et à l'import.
- `customCover` est une image rectangulaire optionnelle utilisée comme cover de card pour les toolboxes libres. Elle est stockée en data URL image après recadrage, sans conserver le fichier original.
- `moduleColumns` vaut `1` ou `2` et contrôle l'affichage de la page toolbox complète ; le panneau latéral utilise toujours l'ordre une colonne.
- `spaces` contient de un à cinq espaces dans l'ordre de leurs onglets. L'espace identifié par `defaultSpaceId` reste toujours premier et ne peut pas être supprimé, même après renommage.

View file

@ -18,6 +18,7 @@ not bugs, missing scenarios or a percentage of work remaining.
| Data loss, startup failure, deferred media | `e2e/persistence.spec.js`, `storage-startup.spec.js`, `deferred-media.spec.js`; Node persistence queue and image action tests |
| React lifecycle, shared editing and navigation | `e2e/editor-lifecycle.spec.js`, `inline-edit.spec.js`, `form-reorder.spec.js`, `shell-behavior.spec.js`, `session-state.spec.js` |
| Public data loading, retry and stale responses | `e2e/app-data.spec.js` |
| HTTP cache policy of the delivered Node server | `tests/server-cache.test.mjs`; production E2E remains responsible for stale bundle recovery |
| Shared reorder policy and module order | `e2e/grouped-reorder.spec.js`, `module-order.spec.js` |
| Toolbox creation, import/export, text exchange | `e2e/toolbox.spec.js`, `text-exchange.spec.js`; Node toolbox module tests |
| Links: creation, copy, category removal preserving links, deletion and reload | `e2e/basic-tools.spec.js` |
@ -49,6 +50,8 @@ automatic follow-on batches required to finish this audit.
Run targeted tests while implementing a grouped change, then `npm run check:full`
as the final gate: lint, Node tests, build, development E2E and production E2E.
Use the direct Node server test for HTTP headers; Vite Preview does not exercise
the cache policy implemented by `server.mjs` or any production proxy override.
Review the diff and report actual failures or limits before closing the task.
Do not introduce visual snapshots solely to prove that a page loads.
Keep detailed command logs outside tracked source and report concise results.

View file

@ -43,6 +43,8 @@ Fichiers : `features/toolboxes/ToolboxPages.jsx`, `ToolboxCard.jsx`, `styles/too
Constats S03/S04/S05. Effort moyen, à découper en changements indépendants. Dépend de C06 pour livrer correctement des assets publics remplacés.
**État au 23 octobre 2026 : réalisé.** Toutes les images raster publiques utilisent WebP sans doublon PNG. Une commande dédiée convertit les prochains PNG et supprime la source après succès ; elle refuse par défaut les résultats plus lourds. Les anciens chemins d'icône toolbox en `.png` sont normalisés vers WebP. Les styles du catalogue de développement sont chargés avec sa route. Le profil reproductible, le tableau avant/après et les budgets sont consignés dans [`docs/PERFORMANCE.md`](../../PERFORMANCE.md).
### Mesure de référence et images
1. Refaire les mesures accueil et Aniimo avec build, serveur, viewport, cache et protocole identiques. Séparer poids total du dépôt et octets réellement transférés.

View file

@ -122,7 +122,7 @@ test("catalogue, overview and deferred Aniimo loading preserve filters across na
await page.locator('a.game-card-cover[href="#/games/aniimo"]').click();
await expect(page.getByRole("heading", { name: "Aniimo", exact: true })).toBeVisible();
const cover = page.locator('.aniimo-home-card img');
await expect(cover).toHaveAttribute("src", "/static/img/aniimo/emberpup__basic_form.png");
await expect(cover).toHaveAttribute("src", "/static/img/aniimo/emberpup__basic_form.webp");
await expect(cover).toHaveCSS("object-fit", "cover");
await expect(cover).toHaveCSS("object-position", "50% 38%");
await expect(cover).toHaveCSS("height", "120px");

View file

@ -4,9 +4,9 @@ import { readFile } from "node:fs/promises";
import { Buffer } from "node:buffer";
import { fileURLToPath, URL } from "node:url";
const imagePath = fileURLToPath(new URL("../website/public/static/img/toolbox-icons/sword.png", import.meta.url));
const imagePath = fileURLToPath(new URL("../website/public/static/img/toolbox-icons/sword.webp", import.meta.url));
const fixture = JSON.parse(await readFile(new URL("./fixtures/toolbox-export.json", import.meta.url), "utf8"));
const cover = `data:image/png;base64,${(await readFile(imagePath)).toString("base64")}`;
const cover = `data:image/webp;base64,${(await readFile(imagePath)).toString("base64")}`;
const { games } = JSON.parse(await readFile(new URL("../website/public/data/games.json", import.meta.url), "utf8"));
const gameCover = games.find((game) => game.id === "mhwilds").images.cardCover;
@ -43,7 +43,7 @@ test("saves a cropped cover through reload and export/import, then returns to an
const creation = page.getByRole("dialog", { name: "Nouvelle toolbox" });
await creation.getByLabel("Nom").fill("Cover workflow");
await creation.getByRole("button", { name: "Créer" }).click();
await expect(picker(page).locator("img")).toHaveAttribute("src", /toolbox\.png$/);
await expect(picker(page).locator("img")).toHaveAttribute("src", /toolbox\.webp$/);
await picker(page).click();
await page.getByRole("button", { name: "Utiliser l'icône sword", exact: true }).click();
const editor = await uploadCover(page);
@ -59,7 +59,7 @@ test("saves a cropped cover through reload and export/import, then returns to an
await expect(page.getByRole("link", { name: "Ouvrir Cover workflow", exact: true }).first().locator("img")).toHaveAttribute("src", savedCover);
const exported = await exportToolbox(page, "Cover workflow");
expect(exported.toolbox.customCover).toBe(savedCover);
expect(exported.toolbox.icon).toMatch(/sword\.png$/);
expect(exported.toolbox.icon).toMatch(/sword\.webp$/);
exported.toolbox.name = "Imported cover";
await page.getByText("Importer une toolbox", { exact: true }).locator('input[type="file"]').setInputFiles({
name: "export.json", mimeType: "application/json", buffer: Buffer.from(JSON.stringify(exported)),
@ -70,9 +70,9 @@ test("saves a cropped cover through reload and export/import, then returns to an
await expect(page.getByRole("button", { name: "Remplacer l'image de card" })).toHaveAttribute("aria-pressed", "true");
await expect(page.getByRole("button", { name: "Utiliser l'icône sword", exact: true })).toHaveAttribute("aria-pressed", "false");
await page.getByRole("button", { name: "Utiliser l'icône sword", exact: true }).click();
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.png$/);
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.webp$/);
await page.reload();
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.png$/);
await expect(picker(page).locator("img")).toHaveAttribute("src", /sword\.webp$/);
await page.goto("/#/toolboxes");
expect((await exportToolbox(page, "Imported cover")).toolbox.customCover || "").toBe("");
});

View file

@ -15,6 +15,8 @@
"test": "node --test",
"test:e2e": "playwright test",
"test:e2e:production": "npm run build && playwright test --config playwright.production.config.js",
"images:convert": "node scripts/convert-public-images.mjs",
"profile:assets": "npm run build && node scripts/measure-public-assets.mjs",
"profile:toolboxes": "npm run build && node scripts/profile-toolbox-loading.mjs"
},
"dependencies": {

View file

@ -0,0 +1,152 @@
// Rôle : convertit des PNG publics vers le format WebP canonique du site.
import { spawn } from "node:child_process";
import { readdir, rename, rm, stat } from "node:fs/promises";
import path from "node:path";
const PRESETS = new Set(["default", "picture", "photo", "drawing", "icon", "text"]);
const options = {
allowLarger: false,
dryRun: false,
force: false,
lossless: false,
preset: "picture",
keepSource: false,
quality: 90
};
const inputs = [];
function printHelp() {
console.log(`Usage: npm run images:convert -- <fichier-ou-dossier...> [options]
Convertit récursivement les fichiers PNG en WebP dans le même dossier.
Chaque PNG source est supprimé après une conversion réussie.
Options :
--quality=<1-100> Qualité avec pertes (défaut : 90)
--preset=<nom> default, picture, photo, drawing, icon ou text
--lossless Utilise WebP sans perte ; ignore quality et preset
--allow-larger Accepte un WebP plus lourd que le PNG source
--keep-source Conserve le PNG source pour une comparaison ponctuelle
--force Remplace un WebP déjà présent
--dry-run Affiche les conversions sans écrire de fichier
--help Affiche cette aide`);
}
for (const argument of process.argv.slice(2)) {
if (argument === "--help" || argument === "-h") {
printHelp();
process.exit(0);
} else if (argument === "--allow-larger") options.allowLarger = true;
else if (argument === "--dry-run") options.dryRun = true;
else if (argument === "--force") options.force = true;
else if (argument === "--lossless") options.lossless = true;
else if (argument === "--keep-source") options.keepSource = true;
else if (argument.startsWith("--quality=")) options.quality = Number(argument.slice("--quality=".length));
else if (argument.startsWith("--preset=")) options.preset = argument.slice("--preset=".length);
else if (argument.startsWith("--")) throw new Error(`Option inconnue : ${argument}`);
else inputs.push(argument);
}
if (!Number.isInteger(options.quality) || options.quality < 1 || options.quality > 100) {
throw new Error("--quality doit être un entier compris entre 1 et 100.");
}
if (!PRESETS.has(options.preset)) throw new Error(`Preset WebP inconnu : ${options.preset}`);
if (inputs.length === 0) {
printHelp();
process.exitCode = 1;
} else {
await convertInputs();
}
async function collectPngFiles(input) {
const inputPath = path.resolve(input);
const inputStat = await stat(inputPath);
if (inputStat.isFile()) {
if (!inputPath.toLowerCase().endsWith(".png")) throw new Error(`Le fichier n'est pas un PNG : ${input}`);
return [inputPath];
}
if (!inputStat.isDirectory()) throw new Error(`Entrée non prise en charge : ${input}`);
const entries = await readdir(inputPath, { withFileTypes: true });
return (await Promise.all(entries.map((entry) => {
const entryPath = path.join(inputPath, entry.name);
if (entry.isDirectory()) return collectPngFiles(entryPath);
return entry.isFile() && entry.name.toLowerCase().endsWith(".png") ? [entryPath] : [];
}))).flat();
}
function runFfmpeg(argumentsList) {
return new Promise((resolve, reject) => {
const child = spawn("ffmpeg", argumentsList, { stdio: ["ignore", "ignore", "pipe"] });
let stderr = "";
child.stderr.setEncoding("utf8");
child.stderr.on("data", (chunk) => { stderr += chunk; });
child.once("error", (error) => reject(error.code === "ENOENT" ? new Error("ffmpeg est requis pour convertir les images.") : error));
child.once("close", (code) => code === 0 ? resolve() : reject(new Error(stderr.trim() || `ffmpeg a quitté avec le code ${code}.`)));
});
}
async function convertImage(source) {
const target = source.replace(/\.png$/i, ".webp");
const relativeSource = path.relative(process.cwd(), source);
const relativeTarget = path.relative(process.cwd(), target);
try {
await stat(target);
if (!options.force) {
console.log(`Ignoré : ${relativeTarget} existe déjà (utiliser --force pour le remplacer).`);
return null;
}
} catch (error) {
if (error.code !== "ENOENT") throw error;
}
if (options.dryRun) {
console.log(`[simulation] ${relativeSource} -> ${relativeTarget}${options.keepSource ? "" : " puis suppression du PNG"}`);
return null;
}
const temporaryTarget = `${target}.${process.pid}.tmp.webp`;
const encoding = options.lossless
? ["-lossless", "1", "-quality", "100", "-compression_level", "6", "-pix_fmt", "bgra"]
: ["-preset", options.preset, "-quality", String(options.quality), "-compression_level", "6"];
try {
await runFfmpeg(["-y", "-v", "error", "-i", source, "-c:v", "libwebp", ...encoding, temporaryTarget]);
const [sourceStat, targetStat] = await Promise.all([stat(source), stat(temporaryTarget)]);
if (targetStat.size === 0) throw new Error(`La conversion de ${relativeSource} a produit un fichier vide.`);
if (targetStat.size >= sourceStat.size && !options.allowLarger) {
await rm(temporaryTarget);
console.log(`Conservé : ${relativeSource}, le WebP serait plus lourd (${sourceStat.size} -> ${targetStat.size} octets).`);
return null;
}
await rename(temporaryTarget, target);
if (!options.keepSource) await rm(source);
console.log(`${relativeSource} -> ${relativeTarget} (${sourceStat.size} -> ${targetStat.size} octets)`);
return { sourceBytes: sourceStat.size, targetBytes: targetStat.size };
} catch (error) {
await rm(temporaryTarget, { force: true });
throw error;
}
}
async function convertInputs() {
const collected = (await Promise.all(inputs.map(collectPngFiles))).flat();
const sources = [...new Set(collected)].sort((left, right) => left.localeCompare(right, "fr"));
if (sources.length === 0) {
console.log("Aucun fichier PNG trouvé.");
return;
}
const results = [];
for (const source of sources) {
const result = await convertImage(source);
if (result) results.push(result);
}
if (options.dryRun || results.length === 0) return;
const sourceBytes = results.reduce((total, result) => total + result.sourceBytes, 0);
const targetBytes = results.reduce((total, result) => total + result.targetBytes, 0);
const difference = Math.abs((sourceBytes - targetBytes) * 100 / sourceBytes).toFixed(1);
const evolution = targetBytes <= sourceBytes ? `${difference} % de moins` : `${difference} % de plus`;
console.log(`${results.length} image(s) convertie(s) : ${sourceBytes} -> ${targetBytes} octets (${evolution}).`);
if (options.keepSource) console.log("Les PNG source sont conservés pour comparaison.");
}

View file

@ -0,0 +1,139 @@
// Rôle : mesure les octets chargés par l'accueil et Aniimo sur le build servi par le serveur Node.
import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
import { platform } from "node:os";
import { basename, join } from "node:path";
import { gzipSync } from "node:zlib";
import assert from "node:assert/strict";
import { chromium } from "@playwright/test";
import { createStaticServer } from "../server.mjs";
const label = String(process.argv[2] || "current").replace(/[^a-z0-9_-]+/gi, "-");
const viewport = { width: 1440, height: 900 };
const budgets = {
publicImageBytes: 25_000_000,
cssGzipBytes: 70_000,
routeTransferBytes: {
"home-cold": 1_750_000,
"aniimo-after-home": 3_000_000
}
};
async function listFiles(root) {
const entries = await readdir(root, { withFileTypes: true });
return (await Promise.all(entries.map(async (entry) => {
const path = join(root, entry.name);
return entry.isDirectory() ? listFiles(path) : [path];
}))).flat();
}
async function measureEntries(page, includeDocument) {
return page.evaluate(({ withDocument }) => {
const resources = performance.getEntriesByType("resource");
const entries = withDocument ? [...performance.getEntriesByType("navigation"), ...resources] : resources;
const summarize = (values) => ({
requests: values.length,
transferBytes: values.reduce((sum, entry) => sum + entry.transferSize, 0),
encodedBytes: values.reduce((sum, entry) => sum + entry.encodedBodySize, 0),
decodedBytes: values.reduce((sum, entry) => sum + entry.decodedBodySize, 0)
});
return {
...summarize(entries),
images: summarize(resources.filter((entry) => entry.initiatorType === "img" || /\.(?:png|webp|jpe?g)(?:\?|$)/i.test(entry.name))),
styles: summarize(resources.filter((entry) => entry.initiatorType === "link" && /\.css(?:\?|$)/i.test(entry.name))),
largestTransfers: [...resources]
.sort((left, right) => right.transferSize - left.transferSize)
.slice(0, 10)
.map((entry) => ({ path: new URL(entry.name).pathname, transferBytes: entry.transferSize }))
};
}, { withDocument: includeDocument });
}
async function routeReport(page, { name, route, selector, includeDocument }) {
if (!includeDocument) await page.evaluate(() => performance.clearResourceTimings());
await page.goto(route, { waitUntil: "networkidle" });
await page.locator(selector).first().waitFor({ state: "visible" });
await page.waitForTimeout(500);
const metrics = await measureEntries(page, includeDocument);
const images = await page.locator("img").evaluateAll(async (nodes) => {
const loaded = nodes.filter((node) => node.complete && node.naturalWidth > 0);
await Promise.all(loaded.map((node) => node.decode()));
return { present: nodes.length, decoded: loaded.length };
});
return { name, route, ...metrics, imageElements: images };
}
const imageFiles = await listFiles("website/public/static/img");
const cssFiles = (await listFiles("website/dist/assets")).filter((file) => file.endsWith(".css"));
const server = createStaticServer();
await new Promise((resolve, reject) => {
server.once("error", reject);
server.listen(0, "127.0.0.1", resolve);
});
let browser;
try {
const address = server.address();
const baseURL = `http://127.0.0.1:${address.port}`;
browser = await chromium.launch();
const context = await browser.newContext({ viewport, serviceWorkers: "block" });
const page = await context.newPage();
const errors = [];
page.on("pageerror", (error) => errors.push(error.message));
page.on("requestfailed", (request) => errors.push(`${request.url()}: ${request.failure()?.errorText || "request failed"}`));
const routes = [];
routes.push(await routeReport(page, {
name: "home-cold",
route: `${baseURL}/#/`,
selector: ".home-page, .hero",
includeDocument: true
}));
routes.push(await routeReport(page, {
name: "aniimo-after-home",
route: `${baseURL}/#/games/aniimo/aniimos`,
selector: ".aniimo-grid .aniimo-card",
includeDocument: false
}));
assert.deepEqual(errors, []);
const css = await Promise.all(cssFiles.map(async (file) => {
const content = await readFile(file);
return { file: basename(file), bytes: content.length, gzipBytes: gzipSync(content).length };
}));
const report = {
measuredAt: new Date().toISOString(),
label,
platform: platform(),
browser: browser.version(),
viewport,
protocol: "HTTP/1.1 local server.mjs, fresh browser context, no throttling",
budgets,
repository: {
publicImageFiles: imageFiles.length,
publicImageBytes: (await Promise.all(imageFiles.map((file) => stat(file)))).reduce((sum, entry) => sum + entry.size, 0),
css
},
routes
};
await mkdir(".local/performance", { recursive: true });
const output = `.local/performance/public-assets-${label}.json`;
await writeFile(output, `${JSON.stringify(report, null, 2)}\n`);
console.table(routes.map((route) => ({
route: route.name,
requests: route.requests,
transferBytes: route.transferBytes,
imageRequests: route.images.requests,
imageTransferBytes: route.images.transferBytes
})));
console.log(`CSS: ${css.map((entry) => `${entry.file} ${entry.bytes} bytes (${entry.gzipBytes} gzip)`).join(", ")}`);
console.log(`Public images: ${report.repository.publicImageFiles} files, ${report.repository.publicImageBytes} bytes`);
console.log(`Report: ${output}`);
assert.ok(report.repository.publicImageBytes <= budgets.publicImageBytes, `Public images exceed ${budgets.publicImageBytes} bytes`);
assert.ok(css.every((entry) => entry.gzipBytes <= budgets.cssGzipBytes), `A CSS bundle exceeds ${budgets.cssGzipBytes} gzip bytes`);
for (const route of routes) {
assert.ok(route.transferBytes <= budgets.routeTransferBytes[route.name], `${route.name} exceeds ${budgets.routeTransferBytes[route.name]} transfer bytes`);
}
} finally {
await browser?.close();
await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
}

View file

@ -1,19 +1,16 @@
// Rôle : sert l'application Vite construite ou les sources publiques en local.
// Rôle : sert l'application Vite construite ou les sources publiques avec leur politique de cache.
import { createReadStream, existsSync, statSync } from "node:fs";
import { loadProjectEnv } from "./scripts/load-project-env.mjs";
import { createServer } from "node:http";
import { extname, join, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const modulePath = fileURLToPath(import.meta.url);
const projectRoot = resolve(fileURLToPath(new URL(".", import.meta.url)));
const websiteRoot = join(projectRoot, "website");
const distRoot = join(websiteRoot, "dist");
const root = existsSync(distRoot) ? distRoot : websiteRoot;
const publicRoot = existsSync(distRoot) ? distRoot : join(websiteRoot, "public");
loadProjectEnv();
const port = Number(process.env.PORT || 5173);
const defaultRoot = existsSync(distRoot) ? distRoot : websiteRoot;
const defaultPublicRoot = existsSync(distRoot) ? distRoot : join(websiteRoot, "public");
const types = {
".html": "text/html; charset=utf-8",
@ -33,11 +30,11 @@ function isInsideRoot(parent, file) {
return Boolean(relativePath) && !relativePath.startsWith("..") && !relativePath.startsWith("/");
}
function fileIfReadable(file) {
return isInsideRoot(root, file) && existsSync(file) && statSync(file).isFile() ? file : null;
function fileIfReadable(parent, file) {
return isInsideRoot(parent, file) && existsSync(file) && statSync(file).isFile() ? file : null;
}
function resolvePath(url) {
function resolvePath(url, root, publicRoot) {
let requested;
try {
requested = decodeURIComponent(new URL(url, "http://localhost").pathname);
@ -45,46 +42,68 @@ function resolvePath(url) {
return null;
}
const candidate = fileIfReadable(resolve(root, `.${requested}`));
const candidate = fileIfReadable(root, resolve(root, `.${requested}`));
if (candidate) return candidate;
const publicCandidate = fileIfReadable(resolve(publicRoot, `.${requested}`));
if (publicCandidate && isInsideRoot(publicRoot, publicCandidate)) return publicCandidate;
const publicCandidate = fileIfReadable(publicRoot, resolve(publicRoot, `.${requested}`));
if (publicCandidate) return publicCandidate;
return extname(requested) ? null : join(root, "index.html");
}
const server = createServer((req, res) => {
const file = resolvePath(req.url || "/");
if (!file || !existsSync(file)) {
res.writeHead(404);
res.end("Not found");
return;
}
function isVersionedAsset(root, file) {
const relativePath = relative(root, file).replaceAll("\\", "/");
const fileName = relativePath.split("/").at(-1) || "";
return relativePath.startsWith("assets/") && /-[a-z0-9_-]{8,}\.[^.]+(?:\.map)?$/i.test(fileName);
}
function getCacheControl(root, file) {
const extension = extname(file);
const cacheControl = extension === ".html"
? "no-store"
: extension === ".json"
? "no-cache"
: "public, max-age=31536000, immutable";
res.writeHead(200, {
"Content-Type": types[extname(file)] || "application/octet-stream",
"Cache-Control": cacheControl
if (extension === ".html") return "no-store";
if (extension === ".json") return "no-cache";
if (isVersionedAsset(root, file)) return "public, max-age=31536000, immutable";
return "no-cache";
}
export function createStaticServer({ root = defaultRoot, publicRoot = defaultPublicRoot } = {}) {
return createServer((req, res) => {
const file = resolvePath(req.url || "/", root, publicRoot);
if (!file || !existsSync(file)) {
res.writeHead(404, {
"Content-Type": "text/plain; charset=utf-8",
"Cache-Control": "no-store"
});
res.end("Not found");
return;
}
res.writeHead(200, {
"Content-Type": types[extname(file)] || "application/octet-stream",
"Cache-Control": getCacheControl(root, file)
});
createReadStream(file).pipe(res);
});
createReadStream(file).pipe(res);
});
}
server.on("error", (error) => {
if (error.code === "EADDRINUSE") {
console.error(`Port ${port} is already in use. Set PORT to another value.`);
export function startServer() {
loadProjectEnv();
const port = Number(process.env.PORT || 5173);
const server = createStaticServer();
server.on("error", (error) => {
if (error.code === "EADDRINUSE") {
console.error(`Port ${port} is already in use. Set PORT to another value.`);
process.exit(1);
}
console.error(error);
process.exit(1);
}
});
console.error(error);
process.exit(1);
});
server.listen(port, () => {
console.log(`Sokko G dev server running at http://localhost:${port}`);
});
return server;
}
server.listen(port, () => {
console.log(`Sokko G dev server running at http://localhost:${port}`);
});
if (process.argv[1] && resolve(process.argv[1]) === modulePath) startServer();

View file

@ -10,6 +10,11 @@ const readJson = async (path) => JSON.parse(await readFile(`website/public/data/
const [aniimos, fr, en] = await Promise.all([readJson("aniimo/aniimos.json"), readJson("aniimo/i18n/fr.json"), readJson("aniimo/i18n/en.json")]);
const data = prepareAniimoData(aniimos, fr, en);
function readWebpCanvasSize(webp) {
assert.equal(webp.toString("ascii", 12, 16), "VP8X");
return [webp.readUIntLE(24, 3) + 1, webp.readUIntLE(27, 3) + 1];
}
test("Aniimo attributes have valid stats and matching totals", () => {
validateAniimoData(aniimos, [fr, en]);
const invalid = structuredClone(aniimos[0]);
@ -24,14 +29,15 @@ test("Aniimo data has valid variants, translations, portraits and icons", async
validateAniimoData(aniimos, [fr, en]);
const game = (await readJson("games.json")).games.find((game) => game.id === "aniimo");
assert.ok(game);
assert.equal(game.images.aniimosCover, "/static/img/aniimo/emberpup__basic_form.png");
assert.equal(game.images.aniimosCover, "/static/img/aniimo/emberpup__basic_form.webp");
const assets = new Set([game.images.cardCover, game.images.heroBg, game.images.aniimosCover, ...data.variants.map((variant) => variant.image)]);
for (const option of Object.values(data.filterOptions).flat()) assets.add(`/static/img/aniimo/${option}.png`);
for (const option of Object.values(data.filterOptions).flat()) assets.add(`/static/img/aniimo/${option}.webp`);
await Promise.all([...assets].map((asset) => access(`website/public${asset}`)));
for (const variant of data.variants) {
const png = await readFile(`website/public${variant.image}`);
assert.equal(png.readUInt32BE(16), 512);
assert.equal(png.readUInt32BE(20), 840);
const webp = await readFile(`website/public${variant.image}`);
assert.equal(webp.toString("ascii", 0, 4), "RIFF");
assert.equal(webp.toString("ascii", 8, 12), "WEBP");
assert.deepEqual(readWebpCanvasSize(webp), [512, 840]);
}
});

View file

@ -64,8 +64,8 @@ test("mhwilds data and assets are available", async () => {
assert.ok(site.toolboxes.storageHelp.items.length >= 3);
assert.equal(games.games[0].id, "mhwilds");
assert.equal(games.games[0].eyebrow, "Guide de jeu");
assert.match(games.games[0].images.cardCover, /games\/mhwilds\/card-cover\.png/);
assert.match(games.games[0].images.heroBg, /games\/mhwilds\/hero-bg\.png/);
assert.match(games.games[0].images.cardCover, /games\/mhwilds\/card-cover\.webp/);
assert.match(games.games[0].images.heroBg, /games\/mhwilds\/hero-bg\.webp/);
assert.ok(monsters.monsters.length > 0);
assert.deepEqual(monsters.elements, ["fire", "water", "thunder", "ice", "dragon"]);
validateMonsterData(monsters.monsters);
@ -105,9 +105,9 @@ test("mhwilds data and assets are available", async () => {
const monsterCardSource = await readFile("website/src/features/games/mhwilds/cards/MonsterCard.jsx", "utf8");
assert.match(monsterCardSource, /monster-card/);
assert.match(monsterCardSource, /monster\.hitzones/);
await readFile("website/public/static/img/mhwilds/chatacabra.png");
await readFile("website/public/static/img/games/mhwilds/card-cover.png");
await readFile("website/public/static/img/games/mhwilds/hero-bg.png");
await readFile("website/public/static/img/mhwilds/chatacabra.webp");
await readFile("website/public/static/img/games/mhwilds/card-cover.webp");
await readFile("website/public/static/img/games/mhwilds/hero-bg.webp");
});
test("diablo4 data and route are available", async () => {
@ -119,14 +119,14 @@ test("diablo4 data and route are available", async () => {
const diablo4Game = games.games.find((game) => game.id === "diablo4");
assert.ok(diablo4Game, "games.json must declare diablo4");
assert.match(diablo4Game.images.cardCover, /games\/diablo4\/card-cover\.png/);
assert.match(diablo4Game.images.heroBg, /games\/diablo4\/hero-bg\.png/);
assert.match(diablo4Game.images.cardCover, /games\/diablo4\/card-cover\.webp/);
assert.match(diablo4Game.images.heroBg, /games\/diablo4\/hero-bg\.webp/);
validateDiablo4Affixes(affixes);
assert.match(routeSource, /game\.id === "diablo4"/);
assert.match(pageSource, /category === "affixes"/);
assert.match(listingSource, /diablo4\.filterOptions\.affixes/);
await readFile("website/public/static/img/games/diablo4/card-cover.png");
await readFile("website/public/static/img/games/diablo4/hero-bg.png");
await readFile("website/public/static/img/games/diablo4/card-cover.webp");
await readFile("website/public/static/img/games/diablo4/hero-bg.webp");
await readFile("website/public/static/icons/axe.svg");
await readFile("website/public/static/icons/cube.svg");
await readFile("website/public/static/icons/fire.svg");

View file

@ -0,0 +1,67 @@
// Rôle : vérifie les en-têtes de cache du serveur Node sur des fichiers de production représentatifs.
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import assert from "node:assert/strict";
import { test } from "node:test";
import { createStaticServer } from "../server.mjs";
async function writeFixture(root, path, content) {
const file = join(root, path);
await mkdir(dirname(file), { recursive: true });
await writeFile(file, content);
return file;
}
test("production server separates stable files from versioned assets", async (t) => {
const root = await mkdtemp(join(tmpdir(), "sokko-server-cache-"));
await writeFixture(root, "index.html", "<main>Sokko G</main>");
await writeFixture(root, "data/site.json", JSON.stringify({ title: "Sokko G" }));
await writeFixture(root, "assets/index-Ab12_cd34.js", "console.log('versioned');");
await writeFixture(root, "assets/runtime.js", "console.log('stable');");
const imageFile = await writeFixture(root, "static/img/hero.png", "image-v1");
const server = createStaticServer({ root, publicRoot: root });
await new Promise((resolve, reject) => {
server.once("error", reject);
server.listen(0, "127.0.0.1", resolve);
});
t.after(async () => {
await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
await rm(root, { recursive: true, force: true });
});
const address = server.address();
const request = (path) => fetch(`http://127.0.0.1:${address.port}${path}`);
const html = await request("/");
assert.equal(html.status, 200);
assert.equal(html.headers.get("cache-control"), "no-store");
const spaFallback = await request("/toolbox/example");
assert.equal(spaFallback.status, 200);
assert.equal(spaFallback.headers.get("cache-control"), "no-store");
const json = await request("/data/site.json");
assert.equal(json.status, 200);
assert.equal(json.headers.get("cache-control"), "no-cache");
const bundle = await request("/assets/index-Ab12_cd34.js");
assert.equal(bundle.status, 200);
assert.equal(bundle.headers.get("cache-control"), "public, max-age=31536000, immutable");
const stableScript = await request("/assets/runtime.js");
assert.equal(stableScript.status, 200);
assert.equal(stableScript.headers.get("cache-control"), "no-cache");
const firstImage = await request("/static/img/hero.png");
assert.equal(firstImage.headers.get("cache-control"), "no-cache");
assert.equal(await firstImage.text(), "image-v1");
await writeFile(imageFile, "image-v2");
const replacedImage = await request("/static/img/hero.png");
assert.equal(await replacedImage.text(), "image-v2");
const missingBundle = await request("/assets/index-OldHash9.js");
assert.equal(missingBundle.status, 404);
assert.equal(missingBundle.headers.get("cache-control"), "no-store");
});

View file

@ -31,7 +31,7 @@ test("vite entrypoint and app shell are wired", async () => {
assert.match(routeContent, /features\/games\/GameRoute\.jsx/);
assert.doesNotMatch(shell, /content\.navigation\.library/);
assert.match(shell, /sidebar-about-link/);
assert.match(shell, /dragon-sidebar\.png/);
assert.match(shell, /dragon-sidebar\.webp/);
assert.match(shell, /ImportButton/);
assert.match(shell, /compactSidebar/);
assert.match(shell, /reducedSidebar/);
@ -48,7 +48,7 @@ test("vite entrypoint and app shell are wired", async () => {
assert.match(overlays, /uid\("marker"\)/);
assert.match(imageViewer, /export function ImageViewer/);
assert.match(imageViewer, /function openImageInNewTab/);
assert.match(homePage, /dragon-home\.png/);
assert.match(homePage, /dragon-home\.webp/);
assert.match(aboutPage, /module-icon-\$\{group\.icon \|\| "notepad"\}/);
});
@ -112,20 +112,20 @@ test("legacy icons and primary images are available", async () => {
await readFile("website/public/static/icons/shield.svg", "utf8");
await readFile("website/public/static/icons/wing.svg", "utf8");
await readFile("website/public/favicon.ico");
await readFile("website/public/static/img/dragon-home.png");
await readFile("website/public/static/img/dragon-sidebar.png");
await readFile("website/public/static/img/dragon-dual-monitor.png");
await readFile("website/public/static/img/dragon-session-tools.png");
await readFile("website/public/static/img/dragon-game-guides.png");
await readFile("website/public/static/img/dragon-local-data.png");
await readFile("website/public/static/img/dragon-contribution-data.png");
await readFile("website/public/static/img/dragon-gameguide.png");
await readFile("website/public/static/img/dragon-toolbox.png");
await readFile("website/public/static/img/onboarding/toolbox-overview.png");
await readFile("website/public/static/img/onboarding/toolbox-tools.png");
await readFile("website/public/static/img/onboarding/toolbox-save.png");
await readFile("website/public/static/img/onboarding/toolbox-game-link.png");
await readFile("website/public/static/img/toolbox-icons/toolbox.png");
await readFile("website/public/static/img/toolbox-icons/sword.png");
await readFile("website/public/static/img/toolbox-icons/puzzle.png");
await readFile("website/public/static/img/dragon-home.webp");
await readFile("website/public/static/img/dragon-sidebar.webp");
await readFile("website/public/static/img/dragon-dual-monitor.webp");
await readFile("website/public/static/img/dragon-session-tools.webp");
await readFile("website/public/static/img/dragon-game-guides.webp");
await readFile("website/public/static/img/dragon-local-data.webp");
await readFile("website/public/static/img/dragon-contribution-data.webp");
await readFile("website/public/static/img/dragon-gameguide.webp");
await readFile("website/public/static/img/dragon-toolbox.webp");
await readFile("website/public/static/img/onboarding/toolbox-overview.webp");
await readFile("website/public/static/img/onboarding/toolbox-tools.webp");
await readFile("website/public/static/img/onboarding/toolbox-save.webp");
await readFile("website/public/static/img/onboarding/toolbox-game-link.webp");
await readFile("website/public/static/img/toolbox-icons/toolbox.webp");
await readFile("website/public/static/img/toolbox-icons/sword.webp");
await readFile("website/public/static/img/toolbox-icons/puzzle.webp");
});

View file

@ -14,7 +14,7 @@ import { formatUpdatedAt, isHtmlEmpty, queryBlockFormat, queryCommandState } fro
import { createBalancedTeams, drawWeightedEntries, filterExclusionsForPlayers, getDiceShape, rollDice } from "../website/src/features/toolboxes/modules/randomizerUtils.js";
import { calculateAtLeastOneProbability, calculateDrawsForChance, calculateRngCostSummary, calculateRngRealDrawsSummary, calculateRngSummary, getAveragePositionStatus, getDurationPresetsForAverageHours, getEffectiveRate, normalizeCostString, normalizeRateString, simulateRngDraws } from "../website/src/features/toolboxes/modules/rngSimulatorUtils.js";
import { getTimePatternRecurrenceMs, getTimePatternTargetMs } from "../website/src/features/toolboxes/modules/timerUtils.js";
import { compactModuleDataForStorage, createToolboxExportPayload, moduleStorageKey, normalizeCalculatorData, normalizeChecklistData, normalizeCombosData, normalizeCountersData, normalizeEquipmentPlannerData, normalizeGoalTreeData, normalizeImageAnnotationData, normalizeLinksData, normalizeMemosData, normalizeModuleOrder, normalizeNotepadData, normalizeRandomizerData, normalizeRngSimulatorData, normalizeTableData, normalizeTaskPlannerData, normalizeTimerData, normalizeToolbox, normalizeUrl, remapMemosPlannerLink, summarizeEquipmentPlannerData } from "../website/src/features/toolboxes/storage/toolboxStorage.js";
import { compactModuleDataForStorage, createToolboxExportPayload, moduleStorageKey, normalizeCalculatorData, normalizeChecklistData, normalizeCombosData, normalizeCountersData, normalizeEquipmentPlannerData, normalizeGoalTreeData, normalizeImageAnnotationData, normalizeLinksData, normalizeMemosData, normalizeModuleOrder, normalizeNotepadData, normalizeRandomizerData, normalizeRngSimulatorData, normalizeTableData, normalizeTaskPlannerData, normalizeTimerData, normalizeToolbox, normalizeToolboxIcon, normalizeUrl, remapMemosPlannerLink, summarizeEquipmentPlannerData } from "../website/src/features/toolboxes/storage/toolboxStorage.js";
import { createToolboxSpace, deleteToolboxSpace, moveToolboxModule, reorderToolboxSpaces } from "../website/src/features/toolboxes/toolboxSpaceUtils.js";
import { applyGroupedReorderOperation, completeGroupOrder, getBoundaryItemId, getGroupedEntries, moveGroupOrder, moveGroupOrderToEnd, moveGroupOrderToStart, moveItem, moveItemGroup } from "../website/src/hooks/useGroupedReorder.js";
@ -1014,6 +1014,12 @@ test("toolbox modules preserve only active shell display options", () => {
assert.equal("collapsed" in toolbox.modules[1], false);
});
test("legacy PNG toolbox icons normalize to canonical WebP paths", () => {
assert.equal(normalizeToolboxIcon("/static/img/toolbox-icons/sword.png"), "/static/img/toolbox-icons/sword.webp");
assert.equal(normalizeToolboxIcon("/static/img/toolbox-icons/sword.webp"), "/static/img/toolbox-icons/sword.webp");
assert.equal(normalizeToolboxIcon("/static/img/toolbox-icons/unknown.png"), "/static/img/toolbox-icons/toolbox.webp");
});
test("legacy toolbox order becomes a persistent default space", () => {
const legacy = {
id: "legacy",

View file

@ -5,8 +5,8 @@
"title": "Monster Hunter Wilds",
"eyebrow": "Guide de jeu",
"images": {
"cardCover": "/static/img/games/mhwilds/card-cover.png",
"heroBg": "/static/img/games/mhwilds/hero-bg.png"
"cardCover": "/static/img/games/mhwilds/card-cover.webp",
"heroBg": "/static/img/games/mhwilds/hero-bg.webp"
},
"summary": "Repères rapides pour préparer une chasse, suivre les priorités et garder les infos utiles sur un second écran.",
"sections": [
@ -41,8 +41,8 @@
"title": "Diablo IV",
"eyebrow": "Guide de jeu",
"images": {
"cardCover": "/static/img/games/diablo4/card-cover.png",
"heroBg": "/static/img/games/diablo4/hero-bg.png"
"cardCover": "/static/img/games/diablo4/card-cover.webp",
"heroBg": "/static/img/games/diablo4/hero-bg.webp"
},
"summary": "Repères rapides pour consulter, filtrer et comparer les affixes utiles pendant la préparation d'un build.",
"sections": [
@ -61,9 +61,9 @@
"title": "Aniimo",
"eyebrow": "Guide de jeu",
"images": {
"cardCover": "/static/img/games/aniimo/card-cover.png",
"heroBg": "/static/img/games/aniimo/hero-bg.png",
"aniimosCover": "/static/img/aniimo/emberpup__basic_form.png"
"cardCover": "/static/img/games/aniimo/card-cover.webp",
"heroBg": "/static/img/games/aniimo/hero-bg.webp",
"aniimosCover": "/static/img/aniimo/emberpup__basic_form.webp"
},
"summary": "Retrouvez les Aniimos et leurs variantes selon leurs éléments, leur rôle et leurs compétences de logis.",
"sections": [

View file

@ -1620,25 +1620,25 @@
],
"slides": [
{
"src": "/static/img/onboarding/toolbox-overview.png",
"src": "/static/img/onboarding/toolbox-overview.webp",
"alt": "Aperçu d'une toolbox Sokko G",
"title": "Un espace unique",
"text": "Regroupez les informations utiles à votre session dans une interface locale."
},
{
"src": "/static/img/onboarding/toolbox-tools.png",
"src": "/static/img/onboarding/toolbox-tools.webp",
"alt": "Aperçu des outils disponibles dans une toolbox",
"title": "Des outils à choisir",
"text": "Ajoutez seulement les outils dont vous avez besoin pour votre jeu ou votre objectif."
},
{
"src": "/static/img/onboarding/toolbox-save.png",
"src": "/static/img/onboarding/toolbox-save.webp",
"alt": "Aperçu d'une sauvegarde de toolbox",
"title": "Des sauvegardes simples",
"text": "Exportez vos toolboxes pour les conserver ou les partager."
},
{
"src": "/static/img/onboarding/toolbox-game-link.png",
"src": "/static/img/onboarding/toolbox-game-link.webp",
"alt": "Aperçu d'une toolbox associée à une page jeu",
"title": "Jeu et notes côte à côte",
"text": "Associez une toolbox à une page jeu pour garder vos repères personnels à proximité."
@ -1647,7 +1647,7 @@
"cards": [
{
"icon": "toolbox",
"image": "/static/img/dragon-toolbox.png",
"image": "/static/img/dragon-toolbox.webp",
"title": "Toolboxes",
"text": "Votre espace personnel : notes, listes, images, liens et outils pratiques enregistrés dans ce navigateur.",
"action": "Gérer mes toolboxes",
@ -1655,7 +1655,7 @@
},
{
"icon": "controller",
"image": "/static/img/dragon-gameguide.png",
"image": "/static/img/dragon-gameguide.webp",
"title": "Guides de jeux",
"text": "Les pages de référence disponibles. Vous pouvez ensuite y associer votre toolbox pour garder vos infos à côté.",
"action": "Voir les jeux",
@ -1715,7 +1715,7 @@
"sections": [
{
"icon": "controller",
"image": "/static/img/dragon-session-tools.png",
"image": "/static/img/dragon-session-tools.webp",
"title": "Un support pour jouer plus efficacement",
"text": "Sokko G garde vos informations utiles à portée de main :",
"bullets": ["Objectifs", "Notes", "Images", "Timers", "Liens", "Calculs", "Suivis"],
@ -1723,19 +1723,19 @@
},
{
"icon": "picture",
"image": "/static/img/dragon-dual-monitor.png",
"image": "/static/img/dragon-dual-monitor.webp",
"title": "Pensé pour le second écran",
"text": "De plus en plus de joueurs utilisent deux écrans.\nSokko G profite de cet espace pour garder l’essentiel visible pendant que le jeu reste au premier plan : un guide, une checklist, une carte annotée ou un timer.\nVous consultez vos repères d’un coup d’œil, sans interrompre la partie."
},
{
"icon": "toolbox",
"image": "/static/img/dragon-game-guides.png",
"image": "/static/img/dragon-game-guides.webp",
"title": "Guides de jeux et toolboxes",
"text": "Le site propose des pages de jeux qui servent de guides ou de références.\nVos toolboxes restent personnelles, mais elles peuvent être associées à un jeu.\nCela permet de garder les informations générales d’un côté, et vos notes, outils ou suivis de session juste à côté."
},
{
"icon": "export",
"image": "/static/img/dragon-local-data.png",
"image": "/static/img/dragon-local-data.webp",
"title": "Stockage local : avantages et limites",
"text": "Vos toolboxes restent dans le navigateur utilisé :",
"bullets": ["Pas de compte", "Pas de configuration serveur", "Pas de synchronisation imposée"],
@ -1781,7 +1781,7 @@
"contribute": {
"eyebrow": "Contribuer",
"title": "Proposer une liste de données",
"image": "/static/img/dragon-contribution-data.png",
"image": "/static/img/dragon-contribution-data.webp",
"imageAlt": "Mascotte dragon préparant une liste de données structurée",
"description": "Les contributions attendues sont des listes de données, pas des guides complets. Une liste bien préparée permet de mettre à disposition une checklist complète, prête à être utilisée dans une toolbox.",
"blocks": [

Binary file not shown.

Before

Width:  |  Height:  |  Size: 548 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 501 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 578 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 548 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 513 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 704 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 495 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,020 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Some files were not shown because too many files have changed in this diff Show more