import { Title, Meta } from "@solidjs/meta"; import { HttpStatusCode } from "@solidjs/start"; import { useNavigate, useLocation } from "@solidjs/router"; import { createSignal, onCleanup, onMount, For, Show } from "solid-js"; import { CommandHistoryItem, createTerminalCommands, executeTerminalCommand } from "~/lib/terminal-commands"; // Component that crashes when rendered function CrashComponent() { throw new Error("Terminal crash test - triggering error boundary"); } export default function NotFound() { const navigate = useNavigate(); const location = useLocation(); const [glitchText, setGlitchText] = createSignal("404"); const [command, setCommand] = createSignal(""); const [history, setHistory] = createSignal([]); const [historyIndex, setHistoryIndex] = createSignal(-1); const [shouldCrash, setShouldCrash] = createSignal(false); let inputRef: HTMLInputElement | undefined; const addToHistory = ( cmd: string, output: string, type: "success" | "error" | "info" ) => { if (cmd === "clear") { setHistory([]); } else { setHistory([...history(), { command: cmd, output, type }]); } }; const commands = createTerminalCommands({ navigate, location, addToHistory, triggerCrash: () => setShouldCrash(true) }); const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Enter") { executeTerminalCommand(command(), commands, addToHistory); setCommand(""); setHistoryIndex(-1); } else if (e.key === "ArrowUp") { e.preventDefault(); const allCommands = history().map((h) => h.command); if (allCommands.length > 0) { const newIndex = historyIndex() === -1 ? allCommands.length - 1 : Math.max(0, historyIndex() - 1); setHistoryIndex(newIndex); setCommand(allCommands[newIndex]); } } else if (e.key === "ArrowDown") { e.preventDefault(); const allCommands = history().map((h) => h.command); if (historyIndex() !== -1) { const newIndex = Math.min(allCommands.length - 1, historyIndex() + 1); setHistoryIndex(newIndex); setCommand(allCommands[newIndex]); } } else if (e.key === "Tab") { e.preventDefault(); const typed = command().toLowerCase(); const matches = Object.keys(commands).filter((cmd) => cmd.startsWith(typed) ); if (matches.length === 1) { setCommand(matches[0]); } else if (matches.length > 1) { addToHistory(command(), matches.join(" "), "info"); } } else if (e.key === "l" && e.ctrlKey) { e.preventDefault(); setHistory([]); } }; onMount(() => { const glitchChars = "!@#$%^&*()_+-=[]{}|;':\",./<>?~`0123456789"; const originalText = "404"; const glitchInterval = setInterval(() => { if (Math.random() > 0.85) { let glitched = ""; for (let i = 0; i < originalText.length; i++) { if (Math.random() > 0.7) { glitched += glitchChars[Math.floor(Math.random() * glitchChars.length)]; } else { glitched += originalText[i]; } } setGlitchText(glitched); setTimeout(() => setGlitchText(originalText), 100); } }, 300); inputRef?.focus(); onCleanup(() => { clearInterval(glitchInterval); }); }); return ( <> {/*@ts-ignore (this is intentional)*/} 404 Not Found | Michael Freno
inputRef?.focus()} > {/* Scanline effect */}
{/* Main content */}
{/* Terminal header */}
freno@terminal : ~ $
{/* 404 Error Display */}
error: HTTP {glitchText()} - Not Found
✗
Failed to resolve route
The requested path does not exist in the routing table
→ Location:{" "} {location.pathname}
ℹ Type help to see available commands, or try one of the suggestions below
{/* Command suggestions */}
Quick commands:
{/* Command history */} 0}>
{(item) => (
freno@terminal : ~ $ {item.command}
{item.output}
)}
{/* Interactive input */}
freno@terminal : ~ $ setCommand(e.currentTarget.value)} onKeyDown={handleKeyDown} class="text-text caret-text ml-1 flex-1 border-none bg-transparent outline-none" autocomplete="off" spellcheck={false} />
{/* Footer */}
404{" "} | Page Not Found
{/* Custom styles */}
); }