fix(pdf,excalidraw): BUG-001 + BUG-002
CI / lint (push) Successful in 47s
CI / security (push) Successful in 32s
CI / test (push) Successful in 1m0s
CI / build (push) Successful in 30s
CI / e2e (push) Successful in 9m22s
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s

BUG-001 (PDF stream 500) : le nom Unicode du fichier etait injecte brut
dans Content-Disposition -> en-tete HTTP invalide -> 500. Nouveau helper
_content_disposition (RFC 5987 : filename ASCII + filename*=UTF-8'').
Applique aux 2 branches /pdf/stream. Test: tests/test_pdf_stream.py.

BUG-002 (Excalidraw 'Loading...' infini) : deux causes.
1) L'import esm.sh avec ?alias=react:... etait propage a chaque dep
   transitive; esm.sh renvoie 408 sur les builds a gamme semver (jotai@>=2.9.2)
   -> import entier echoue. On retire l'alias et on utilise React 19 coherent
   (spec a gamme + target identique a celle d'Excalidraw) -> plus de 408.
2) L'editeur passait la prop legacy 'excalidrawRef', inoperante en 0.18
   (la prop reelle est 'excalidrawAPI') -> l'API n'etait jamais recue,
   le 'Loading' ne se masquait pas, save/export morts.

Verifie : 534 tests backend verts (dont 3 nouveaux PDF) + E2E navigateur
(loading masque + cycle requestSave->save OK).
This commit is contained in:
2026-09-09 13:04:40 -04:00
parent 212753f311
commit e4aca3b31e
4 changed files with 102 additions and 26 deletions
+19 -21
View File
@@ -92,26 +92,20 @@
<button id="btn-export-svg" title="Export SVG">📐 SVG</button>
</div>
<!-- Import map: force ALL modules (Excalidraw + sub-deps) to use React 18.3.1 -->
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/[email protected]",
"react-dom": "https://esm.sh/re[email protected]",
"react-dom/": "https://esm.sh/[email protected]/"
}
}
</script>
<!-- Single module script -->
<!-- Excalidraw is loaded from esm.sh WITHOUT the `?alias=react:…` query.
The alias gets propagated by esm.sh to every transitive dependency; for
range-version deps (e.g. jotai@>=2.9.2) esm.sh then tries to rebuild the
range + alias variant and times out (HTTP 408) → the whole import fails →
the diagram stays stuck on "Loading Excalidraw…". Dropping the alias lets
esm.sh resolve a consistent React 19 (Excalidraw 0.18's default), which
loads reliably. -->
<script type="module">
import React from "react";
import ReactDOM from "react-dom/client";
import React from "https://esm.sh/react@^19.2.0?target=es2022";
import { createRoot } from "https://esm.sh/react-dom@^19.2.0/client?target=es2022";
import { decompressFromBase64 } from "https://esm.sh/[email protected]";
import * as ExcalidrawLib from "https://esm.sh/@excalidraw/[email protected]?alias=react:[email protected],react-dom:[email protected]";
import * as ExcalidrawLib from "https://esm.sh/@excalidraw/[email protected]";
window.React = React;
window.ReactDOM = ReactDOM;
window.EXCALIDRAW_ASSET_PATH = "https://esm.sh/@excalidraw/[email protected]/dist/prod/";
window.ExcalidrawLib = ExcalidrawLib;
@@ -186,7 +180,11 @@
function App({ initialData, theme }) {
const [appState, setAppState] = React.useState(null);
const excalidrawRef = React.useCallback((api) => {
// Excalidraw 0.18 exposes its imperative API through the `excalidrawAPI`
// prop, called with the API object once mounted (NOT the legacy
// `excalidrawRef` name). Without this the loading overlay never hides
// and save/export stay dead.
const onReady = React.useCallback((api) => {
if (api) {
excalidrawAPI = api;
loadingEl.classList.add("hidden");
@@ -201,7 +199,7 @@
}, []);
return React.createElement(Excalidraw, {
excalidrawRef: excalidrawRef,
excalidrawAPI: onReady,
initialData: initialData,
onChange: onChange,
theme: theme,
@@ -247,10 +245,10 @@
setTheme(currentTheme);
try {
if (typeof ReactDOM.createRoot !== "function") {
throw new Error("ReactDOM.createRoot is not available — check react-dom/client import");
if (typeof createRoot !== "function") {
throw new Error("createRoot is not available — check react-dom/client import");
}
ReactDOM.createRoot(document.getElementById("root")).render(
createRoot(document.getElementById("root")).render(
React.createElement(App, {
initialData: initialData,
theme: currentTheme,