diff --git a/demo/src/App.tsx b/demo/src/App.tsx index d35025d5..e80953c9 100644 --- a/demo/src/App.tsx +++ b/demo/src/App.tsx @@ -24,20 +24,8 @@ export default function App() { const [formData, setFormData] = useState(""); const [jsonResult, setJsonResult] = useState([]); - //TODO: finish - function isMemoryModel(obj: any): obj is MemoryModel { - return ( - (typeof obj.isClass === "boolean" && - typeof obj.name === "string" && - obj.isClass && - obj.id === null) || - (!obj.isClass && - (typeof obj.id === "string" || typeof obj.id === "number")) - ); - } const onSubmit = async (event) => { event.preventDefault(); - //TODO: use isMemoryModel for input validation setJsonResult(JSON.parse(formData)); }; diff --git a/demo/src/MemoryModels.tsx b/demo/src/MemoryModels.tsx index 1dfa6081..34b2e4a4 100644 --- a/demo/src/MemoryModels.tsx +++ b/demo/src/MemoryModels.tsx @@ -1,7 +1,6 @@ import React from "react"; import { Button, Card, CardContent, TextField, Grid } from "@mui/material"; -//TODO: might use for input validation, double check the type definitions interface MemoryModel { isClass: boolean; name: string; diff --git a/demo/src/SvgDisplay.tsx b/demo/src/SvgDisplay.tsx index 100d3200..500939fe 100644 --- a/demo/src/SvgDisplay.tsx +++ b/demo/src/SvgDisplay.tsx @@ -1,23 +1,23 @@ import React, { useRef, useEffect } from "react"; import mem from "../../src/index"; // TODO: replace with import of the package after it's been published -const DEMO_OBJECTS = [ - { - isClass: true, - name: "__main__", - id: null, - value: { lst1: 82, lst2: 84, p: 99, d: 10, t: 11 }, - stack_frame: true, - }, - { - isClass: false, - name: "str", - id: 19, - value: "David is cool!", - style: ["highlight"], - }, - { isClass: false, name: "int", id: 13, value: 7 }, -]; +// const DEMO_OBJECTS = [ +// { +// isClass: true, +// name: "__main__", +// id: null, +// value: { lst1: 82, lst2: 84, p: 99, d: 10, t: 11 }, +// stack_frame: true, +// }, +// { +// isClass: false, +// name: "str", +// id: 19, +// value: "David is cool!", +// style: ["highlight"], +// }, +// { isClass: false, name: "int", id: 13, value: 7 }, +// ]; export default function SvgDisplay(props) { const canvasRef = useRef(null); diff --git a/demo/src/index.tsx b/demo/src/index.tsx index 6aa66ed1..d76f59ef 100644 --- a/demo/src/index.tsx +++ b/demo/src/index.tsx @@ -3,10 +3,14 @@ import { createRoot } from "react-dom/client"; import App from "./App"; import "@picocss/pico"; import "./css/styles"; +("use client"); +import { ErrorBoundary } from "react-error-boundary"; const root = createRoot(document.getElementById("app")); root.render( - + Something went wrong}> + + ); diff --git a/demo/webpack.config.js b/demo/webpack.config.js index b342ce6f..6457dcba 100644 --- a/demo/webpack.config.js +++ b/demo/webpack.config.js @@ -14,6 +14,9 @@ module.exports = [ }, compress: true, port: 9000, + client: { + overlay: false, + }, }, module: { rules: [ diff --git a/package-lock.json b/package-lock.json index 6e35f958..e965f32c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "dependencies": { "@xmldom/xmldom": "^0.8.6", "deepmerge": "^4.3.1", + "react-error-boundary": "^4.0.12", "roughjs": "^4.5.0" }, "devDependencies": { @@ -16879,6 +16880,17 @@ "react": "^18.2.0" } }, + "node_modules/react-error-boundary": { + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-4.0.12.tgz", + "integrity": "sha512-kJdxdEYlb7CPC1A0SeUY38cHpjuu6UkvzKiAmqmOFL21VRfMhOcWxTCBgLVCO0VEMh9JhFNcVaXlV4/BTpiwOA==", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "peerDependencies": { + "react": ">=16.13.1" + } + }, "node_modules/react-error-overlay": { "version": "6.0.11", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", diff --git a/package.json b/package.json index 2dcca24d..e9881143 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "dependencies": { "@xmldom/xmldom": "^0.8.6", "deepmerge": "^4.3.1", + "react-error-boundary": "^4.0.12", "roughjs": "^4.5.0" }, "devDependencies": {