sokko-g/e2e/fixtures/toolbox-tutorial-probe.js
Shinuwa 22b397ebfa Document Sokko G's architecture and folders, and move JavaScript file headers to JSDoc @file blocks
Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md
(setup and step-by-step recipes) and a README in each main folder, with an
index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to
JSDoc @file blocks, define a three-level header template in website/AGENTS.md
and check the header in tests/file-headers.test.mjs.

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

55 lines
1.9 KiB
JavaScript

/**
* @file Monte la page toolbox sous StrictMode pour contrôler les demandes de tutoriel et les changements
* d'identité.
*/
import { createElement, StrictMode, useState } from "react";
import { createRoot } from "react-dom/client";
import { flushSync } from "react-dom";
import { ToolboxPage } from "../../website/src/features/toolboxes/ToolboxPages.jsx";
export function mountToolboxTutorialProbe(element, siteContent) {
const root = createRoot(element);
const writes = [];
const pendingChanges = [];
let setInputs;
function createToolbox(id) {
const defaultSpaceId = `space-${id}`;
return {
id,
name: id,
modules: [],
spaces: [{ id: defaultSpaceId, name: "Défaut", moduleOrder: { one: [], two: [[], []] } }],
defaultSpaceId,
activeSpaceId: defaultSpaceId,
tutorial: id !== "c"
};
}
function Probe() {
const [inputs, updateInputs] = useState({
toolboxId: "a", pendingTutorialToolboxId: "",
toolboxes: ["a", "b", "c"].map(createToolbox)
});
setInputs = updateInputs;
return createElement(ToolboxPage, {
...inputs, siteContent, actions: {},
getToolboxGame: () => null,
getModuleData: (_toolbox, _module, fallback) => fallback,
updateModuleData: () => {},
updateToolbox: (toolbox) => {
writes.push(toolbox);
updateInputs((current) => ({ ...current, toolboxes: current.toolboxes.map((item) => item.id === toolbox.id ? toolbox : item) }));
},
setPendingTutorialToolboxId: (id) => {
pendingChanges.push(id);
updateInputs((current) => ({ ...current, pendingTutorialToolboxId: id }));
}
});
}
flushSync(() => root.render(createElement(StrictMode, null, createElement(Probe))));
return {
writes, pendingChanges,
update: (patch) => flushSync(() => setInputs((current) => ({ ...current, ...patch }))),
unmount: () => flushSync(() => root.unmount())
};
}