diff --git a/src/App/App.tsx b/src/App/App.tsx index 743d7fa..15b54b8 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -43,7 +43,7 @@ export function App() { function onRaise(inputEvent: string, param: any) { if (rt.length>0 && rtIdx!==undefined && ast.inputEvents.some(e => e.event === inputEvent)) { - const simtime = getSimTime(time, performance.now()); + const simtime = getSimTime(time, Math.round(performance.now())); const nextConfig = handleInputEvent(simtime, {kind: "input", name: inputEvent, param}, ast, rt[rtIdx]!); appendNewConfig(inputEvent, simtime, nextConfig); } @@ -107,7 +107,7 @@ export function App() { appendNewConfig('', nextInterrupt, nextConfig); } if (time.kind === "realtime") { - const wallclkDelay = getWallClkDelay(time, nextInterrupt, performance.now()); + const wallclkDelay = getWallClkDelay(time, nextInterrupt, Math.round(performance.now())); // console.log('scheduling timeout after', wallclkDelay); timeout = setTimeout(raiseTimeEvent, wallclkDelay); } diff --git a/src/App/BottomPanel.tsx b/src/App/BottomPanel.tsx index b892f8a..f72f8f0 100644 --- a/src/App/BottomPanel.tsx +++ b/src/App/BottomPanel.tsx @@ -3,8 +3,10 @@ import { TraceableError } from "../statecharts/parser"; import "./BottomPanel.css"; +import head from "../head.svg" ; + export function BottomPanel(props: {errors: TraceableError[]}) { - const [greeting, setGreeting] = useState("Welcome to StateBuddy, buddy!"); + const [greeting, setGreeting] = useState(<> "Welcome to StateBuddy, buddy!"); useEffect(() => { setTimeout(() => { diff --git a/src/App/TopPanel.tsx b/src/App/TopPanel.tsx index b8ab889..85828b8 100644 --- a/src/App/TopPanel.tsx +++ b/src/App/TopPanel.tsx @@ -316,7 +316,7 @@ export function TopPanel({rt, rtIdx, time, setTime, onInit, onClear, onRaise, on
~}> setShowKeys(e.target.checked)}> - +
diff --git a/src/VisualEditor/VisualEditor.tsx b/src/VisualEditor/VisualEditor.tsx index 3f657dc..bb0e88e 100644 --- a/src/VisualEditor/VisualEditor.tsx +++ b/src/VisualEditor/VisualEditor.tsx @@ -133,16 +133,29 @@ export function VisualEditor({ast, setAST, rt, errors, setErrors, mode, highligh const refSVG = useRef(null); useEffect(() => { - const compressedState = window.location.hash.slice(1); try { + const compressedState = window.location.hash.slice(1); + console.log('get old state'); const ds = new DecompressionStream("deflate"); const writer = ds.writable.getWriter(); - writer.write(Uint8Array.fromBase64(compressedState)); - writer.close(); + writer.write(Uint8Array.fromBase64(compressedState)).catch(e => { + console.error("could not recover state:", e); + }); + writer.close().catch(e => { + console.error("could not recover state:", e); + }); new Response(ds.readable).arrayBuffer().then(decompressedBuffer => { - const recoveredState = JSON.parse(new TextDecoder().decode(decompressedBuffer)); - setState(recoveredState); + try { + console.log('recovering state'); + const recoveredState = JSON.parse(new TextDecoder().decode(decompressedBuffer)); + setState(recoveredState); + } + catch (e) { + console.error("could not recover state:", e); + } + }).catch(e => { + console.error("could not recover state:", e); }); } catch (e) { diff --git a/src/head.svg b/src/head.svg new file mode 100644 index 0000000..cd6fb6e --- /dev/null +++ b/src/head.svg @@ -0,0 +1,4570 @@ + + + +