diff --git a/ivette/src/frama-c/react-three-css2drenderer.d.ts b/ivette/src/dome/@type/global.d.ts similarity index 88% rename from ivette/src/frama-c/react-three-css2drenderer.d.ts rename to ivette/src/dome/@type/global.d.ts index ea2d9ce6f51a0787586b80cd0ce73e8db8b44300..d9c41a5001b5c6d58c270a69c60a42df5da79701 100644 --- a/ivette/src/frama-c/react-three-css2drenderer.d.ts +++ b/ivette/src/dome/@type/global.d.ts @@ -20,4 +20,13 @@ /* */ /* ************************************************************************ */ +// Declare markdown files +declare module '*.md?raw' { + const content: string; + export default content; +} + +declare module 'react-flame-graph'; +declare module 'react-pivottable/PivotTableUI'; declare module 'three/examples/jsm/renderers/CSS2DRenderer'; +declare module 'react-cytoscapejs'; diff --git a/ivette/src/dome/renderer/dome.tsx b/ivette/src/dome/renderer/dome.tsx index b2d3354f0e0db8d66ff75b3e8fd9b88c4c1aac82..c13738851f1d066bb039ff5b55e74763a8959747 100644 --- a/ivette/src/dome/renderer/dome.tsx +++ b/ivette/src/dome/renderer/dome.tsx @@ -43,7 +43,6 @@ import React from 'react'; import Emitter from 'events'; import { createRoot } from 'react-dom/client'; import { ipcRenderer } from 'electron'; -import { join } from 'path'; import SYS, * as System from 'dome/system'; import { State, GlobalState, useGlobalState } from './data/states'; @@ -830,27 +829,21 @@ export function useFileContent( path: string, ): string { const [ fileContent, setFileContent ] = React.useState(""); - const callback = useProtected(setFileContent); - System.readFile(path) - .then((response) => callback(response.toString())) - .catch((error) => { + React.useEffect(() => { + let alive = true; + System.readFile(path) + .then((response) => { + if(alive) setFileContent(response.toString()); + }) + .catch((error) => { // eslint-disable-next-line no-console console.error('Error while loading the file :', error); }); + return () => { alive = false; }; + }, [path]); return fileContent; } -/** - * A hook to retrieve text from a doc file. - * @param path Path from ivette's 'doc' directory - */ -export function useDocContent( - path: string, -): string { - return useFileContent(join(process.cwd(), 'ivette/doc/', path)); -} - - /** Debounced callback (waiting time in milliseconds). The returned callback will be only fired when the component is mounted. diff --git a/ivette/src/frama-c/plugins/dive/react-cytoscapejs.d.ts b/ivette/src/frama-c/plugins/dive/react-cytoscapejs.d.ts deleted file mode 100644 index fc4d2717258121687db9873214e252e8e39a081f..0000000000000000000000000000000000000000 --- a/ivette/src/frama-c/plugins/dive/react-cytoscapejs.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* This file is part of Frama-C. */ -/* */ -/* Copyright (C) 2007-2024 */ -/* CEA (Commissariat à l'énergie atomique et aux énergies */ -/* alternatives) */ -/* */ -/* you can redistribute it and/or modify it under the terms of the GNU */ -/* Lesser General Public License as published by the Free Software */ -/* Foundation, version 2.1. */ -/* */ -/* It is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* See the GNU Lesser General Public License version 2.1 */ -/* for more details (enclosed in the file licenses/LGPLv2.1). */ -/* */ -/* ************************************************************************ */ - -declare module 'react-cytoscapejs'; diff --git a/ivette/src/frama-c/react-flame-graph.d.ts b/ivette/src/frama-c/react-flame-graph.d.ts deleted file mode 100644 index ff0062665305dbcce1dea513f2bd7856c6b4e3bc..0000000000000000000000000000000000000000 --- a/ivette/src/frama-c/react-flame-graph.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* This file is part of Frama-C. */ -/* */ -/* Copyright (C) 2007-2024 */ -/* CEA (Commissariat à l'énergie atomique et aux énergies */ -/* alternatives) */ -/* */ -/* you can redistribute it and/or modify it under the terms of the GNU */ -/* Lesser General Public License as published by the Free Software */ -/* Foundation, version 2.1. */ -/* */ -/* It is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* See the GNU Lesser General Public License version 2.1 */ -/* for more details (enclosed in the file licenses/LGPLv2.1). */ -/* */ -/* ************************************************************************ */ - -declare module 'react-flame-graph'; diff --git a/ivette/src/frama-c/react-pivottable.d.ts b/ivette/src/frama-c/react-pivottable.d.ts deleted file mode 100644 index fb9030bdf0eaea0c08a022de8cfb790bb02cbd6c..0000000000000000000000000000000000000000 --- a/ivette/src/frama-c/react-pivottable.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* This file is part of Frama-C. */ -/* */ -/* Copyright (C) 2007-2024 */ -/* CEA (Commissariat à l'énergie atomique et aux énergies */ -/* alternatives) */ -/* */ -/* you can redistribute it and/or modify it under the terms of the GNU */ -/* Lesser General Public License as published by the Free Software */ -/* Foundation, version 2.1. */ -/* */ -/* It is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ -/* GNU Lesser General Public License for more details. */ -/* */ -/* See the GNU Lesser General Public License version 2.1 */ -/* for more details (enclosed in the file licenses/LGPLv2.1). */ -/* */ -/* ************************************************************************ */ - -declare module 'react-pivottable/PivotTableUI';