sokko-g/website/src/features/toolboxes/toolboxModuleRegistry.js
Shinuwa aa8bb1ebaa Split dailyShare.js and document the shared exported functions with JSDoc
dailyShare.js held fillTemplate and formatCountdown, used across the whole TCG,
under a Daily Card name. They now live in textFormat.js at the root, and the
Daily Card helpers in daily/dailyFormat.js.

173 exported functions that other files call now explain what they return and
how they treat missing values: the server game rules, the toolbox storage chain,
the shared hooks and utilities, and the TCG display helpers. website/AGENTS.md
asks the same of new shared functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 13:32:20 +01:00

215 lines
7.5 KiB
JavaScript

/**
* @file Inventaire des outils de toolbox : pour chaque type, libellé, catégorie de la Librairie, icône et
* chargeur différé du composant.
*
* Contexte : source de vérité de la liste des outils, lue par l'interface, la Librairie, l'import et le stockage.
* Points d'entrée : `TOOLBOX_MODULE_DEFINITIONS`, `TOOLBOX_MODULES`, `TOOLBOX_MODULE_LOADERS`,
* `LIBRARY_CATEGORY_DEFINITIONS`, `getToolboxModuleDefinition`.
* Utilisé par : modules/toolboxModuleComponents.jsx, AddToolControls.jsx, toolboxStorage.js,
* toolboxImportValidation.js, la Librairie, l'accueil ; la validation des données et les tests.
* Attention : ajouter un outil ici ne suffit pas (compacteur, textes, Librairie, validation) : suivre la recette
* de CONTRIBUTING.md.
* @see website/src/features/toolboxes/README.md
*/
export const TOOLBOX_MODULE_DEFINITIONS = {
notepad: {
label: "Bloc Note",
defaultTitle: "Bloc Note",
mode: "Texte riche",
icon: "notepad",
editable: true,
scrollable: true,
addable: false,
libraryCategory: "notesTracking"
},
memos: {
label: "Mémos",
defaultTitle: "Mémos",
mode: "Post-it courts",
icon: "memos",
editable: true,
scrollable: true,
copyDependency: { type: "taskPlanner", dataField: "plannerLink" },
libraryCategory: "notesTracking"
},
checklist: {
label: "Checklist",
defaultTitle: "Checklist",
mode: "Catégories + sans catégorie",
icon: "checklist",
editable: true,
scrollable: true,
libraryCategory: "notesTracking"
},
images: {
label: "Images",
defaultTitle: "Images",
mode: "Média",
icon: "picture",
editable: true,
scrollable: true,
libraryCategory: "references"
},
links: {
label: "Liens",
defaultTitle: "Liens",
mode: "Liste simple",
icon: "link",
editable: true,
scrollable: true,
libraryCategory: "references"
},
counters: {
label: "Compteurs",
defaultTitle: "Compteurs",
mode: "Valeurs",
icon: "abacus",
editable: true,
scrollable: true,
libraryCategory: "notesTracking"
},
randomizer: {
label: "Randomizer",
defaultTitle: "Randomizer",
mode: "Dé + roue + équipes",
icon: "dice",
editable: true,
addable: false,
scrollable: true,
libraryCategory: "calculationData"
},
rngSimulator: {
label: "Simulateur de chance",
defaultTitle: "Simulateur de chance",
mode: "Taux + simulations",
icon: "clover",
editable: true,
scrollable: true,
libraryCategory: "calculationData"
},
combos: {
label: "Combos",
defaultTitle: "Combos",
mode: "Catégories",
icon: "controller",
editable: true,
scrollable: true,
libraryCategory: "buildsCommands"
},
calculator: {
label: "Calculateur",
defaultTitle: "Calculateur",
mode: "Arborescence",
icon: "calculator",
editable: true,
addable: false,
libraryCategory: "calculationData"
},
table: {
label: "Tableau",
defaultTitle: "Tableau",
mode: "Grille + formules",
icon: "table",
editable: true,
addable: false,
scrollable: true,
libraryCategory: "calculationData"
},
goalTree: {
label: "Arbre d'objectifs",
defaultTitle: "Arbre d'objectifs",
mode: "Objectifs + quantités",
icon: "diagram",
editable: true,
scrollable: true,
libraryCategory: "calculationData"
},
timer: {
label: "Timer",
defaultTitle: "Timer",
mode: "Chrono + comptes à rebours",
icon: "clock",
editable: true,
addable: false,
libraryCategory: "timeRoutines"
},
calendar: {
label: "Calendrier",
defaultTitle: "Calendrier",
mode: "Agenda hebdomadaire",
icon: "calendar",
editable: true,
scrollable: true,
libraryCategory: "timeRoutines"
},
taskPlanner: {
label: "Planificateur de tâches",
defaultTitle: "Planificateur de tâches",
mode: "Catégories + parent/enfant",
icon: "tasklist",
editable: true,
scrollable: true,
libraryCategory: "timeRoutines"
},
equipmentPlanner: {
label: "Planificateur d'équipements",
defaultTitle: "Planificateur d'équipements",
mode: "Build + sertissages",
icon: "chest-armor",
editable: true,
scrollable: true,
libraryCategory: "buildsCommands"
},
imageAnnotation: {
label: "Annotation d'images",
defaultTitle: "Annotation d'images",
mode: "Image + marqueurs",
icon: "map",
editable: true,
libraryCategory: "references"
}
};
export const TOOLBOX_MODULES = Object.fromEntries(Object.entries(TOOLBOX_MODULE_DEFINITIONS).map(([type, definition]) => [
type,
{ label: definition.label, icon: definition.icon }
]));
export const TOOLBOX_MODULE_LOADERS = {
notepad: () => import("./modules/NotepadModule.jsx").then((module) => ({ default: module.NotepadModule })),
memos: () => import("./modules/MemosModule.jsx").then((module) => ({ default: module.MemosModule })),
checklist: () => import("./modules/ChecklistModule.jsx").then((module) => ({ default: module.ChecklistModule })),
images: () => import("./modules/ImagesModule.jsx").then((module) => ({ default: module.ImagesModule })),
links: () => import("./modules/LinksModule.jsx").then((module) => ({ default: module.LinksModule })),
counters: () => import("./modules/CountersModule.jsx").then((module) => ({ default: module.CountersModule })),
randomizer: () => import("./modules/RandomizerModule.jsx").then((module) => ({ default: module.RandomizerModule })),
rngSimulator: () => import("./modules/RngSimulatorModule.jsx").then((module) => ({ default: module.RngSimulatorModule })),
combos: () => import("./modules/CombosModule.jsx").then((module) => ({ default: module.CombosModule })),
calculator: () => import("./modules/CalculatorModule.jsx").then((module) => ({ default: module.CalculatorModule })),
calendar: () => import("./modules/CalendarModule.jsx").then((module) => ({ default: module.CalendarModule })),
table: () => import("./modules/TableModule.jsx").then((module) => ({ default: module.TableModule })),
goalTree: () => import("./modules/GoalTreeModule.jsx").then((module) => ({ default: module.GoalTreeModule })),
timer: () => import("./modules/TimerModule.jsx").then((module) => ({ default: module.TimerModule })),
taskPlanner: () => import("./modules/TaskPlannerModule.jsx").then((module) => ({ default: module.TaskPlannerModule })),
equipmentPlanner: () => import("./modules/EquipmentPlannerModule.jsx").then((module) => ({ default: module.EquipmentPlannerModule })),
imageAnnotation: () => import("./modules/ImageAnnotationModule.jsx").then((module) => ({ default: module.ImageAnnotationModule }))
};
export const LIBRARY_CATEGORY_DEFINITIONS = [
{ key: "notesTracking", types: ["memos", "notepad", "checklist", "counters"] },
{ key: "references", types: ["images", "imageAnnotation", "links"] },
{ key: "calculationData", types: ["calculator", "table", "goalTree", "randomizer", "rngSimulator"] },
{ key: "timeRoutines", types: ["timer", "calendar", "taskPlanner"] },
{ key: "buildsCommands", types: ["combos", "equipmentPlanner"] }
];
/** Définition d'un type d'outil (titre, catégorie, chargeur…). Un type inconnu retombe sur le Bloc-notes au lieu de casser la page. */
export function getToolboxModuleDefinition(type) {
return TOOLBOX_MODULE_DEFINITIONS[type] || TOOLBOX_MODULE_DEFINITIONS.notepad;
}
/** Titre donné à un nouvel outil de ce type. */
export function getDefaultModuleTitle(type) {
return getToolboxModuleDefinition(type).defaultTitle || "Outil";
}