continued cleanup
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import { useNavigate } from "@solidjs/router";
|
|
||||||
import { createSignal, onCleanup, onMount } from "solid-js";
|
import { createSignal, onCleanup, onMount } from "solid-js";
|
||||||
import { TerminalErrorPage } from "~/components/TerminalErrorPage";
|
import { TerminalErrorPage } from "~/components/TerminalErrorPage";
|
||||||
import { useDarkMode } from "~/context/darkMode";
|
|
||||||
import { glitchText } from "~/lib/client-utils";
|
import { glitchText } from "~/lib/client-utils";
|
||||||
|
|
||||||
export interface ErrorBoundaryFallbackProps {
|
export interface ErrorBoundaryFallbackProps {
|
||||||
@@ -12,23 +10,6 @@ export interface ErrorBoundaryFallbackProps {
|
|||||||
export default function ErrorBoundaryFallback(
|
export default function ErrorBoundaryFallback(
|
||||||
props: ErrorBoundaryFallbackProps
|
props: ErrorBoundaryFallbackProps
|
||||||
) {
|
) {
|
||||||
let navigate: ((path: string) => void) | undefined;
|
|
||||||
try {
|
|
||||||
navigate = useNavigate();
|
|
||||||
} catch (e) {
|
|
||||||
navigate = (path: string) => {
|
|
||||||
window.location.href = path;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let isDark: () => boolean;
|
|
||||||
try {
|
|
||||||
const darkMode = useDarkMode();
|
|
||||||
isDark = darkMode.isDark;
|
|
||||||
} catch (e) {
|
|
||||||
isDark = () => true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [glitchError, setGlitchError] = createSignal("ERROR");
|
const [glitchError, setGlitchError] = createSignal("ERROR");
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -83,12 +64,10 @@ export default function ErrorBoundaryFallback(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const quickActions = (
|
const quickActions = (
|
||||||
<div class="mb-8 w-full max-w-4xl space-y-3 font-mono text-sm">
|
<>
|
||||||
<div class="text-subtext1">Quick actions:</div>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => props.reset()}
|
onClick={() => props.reset()}
|
||||||
class="group border-surface0 bg-mantle hover:border-yellow hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
class="group border-surface0 bg-mantle hover:border-yellow hover:bg-surface0 flex w-full cursor-pointer items-center gap-2 border px-4 py-3 text-left transition-all"
|
||||||
>
|
>
|
||||||
<span class="text-green">$</span>
|
<span class="text-green">$</span>
|
||||||
<span class="text-yellow group-hover:text-peach">./reset</span>
|
<span class="text-yellow group-hover:text-peach">./reset</span>
|
||||||
@@ -97,39 +76,11 @@ export default function ErrorBoundaryFallback(
|
|||||||
[Try again]
|
[Try again]
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
<button
|
|
||||||
onClick={() => navigate!("/")}
|
|
||||||
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
|
||||||
>
|
|
||||||
<span class="text-green">$</span>
|
|
||||||
<span class="text-blue group-hover:text-sky">cd</span>
|
|
||||||
<span class="text-text group-hover:text-blue">~</span>
|
|
||||||
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
|
||||||
[Return home]
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => window.history.back()}
|
|
||||||
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
|
||||||
>
|
|
||||||
<span class="text-green">$</span>
|
|
||||||
<span class="text-blue group-hover:text-sky">cd</span>
|
|
||||||
<span class="text-text group-hover:text-blue">..</span>
|
|
||||||
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
|
||||||
[Go back]
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TerminalErrorPage
|
<TerminalErrorPage
|
||||||
navigate={navigate!}
|
|
||||||
location={{
|
|
||||||
pathname: typeof window !== "undefined" ? window.location.pathname : "/"
|
|
||||||
}}
|
|
||||||
errorContent={errorContent}
|
errorContent={errorContent}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
footer={
|
footer={
|
||||||
@@ -138,7 +89,6 @@ export default function ErrorBoundaryFallback(
|
|||||||
Runtime Exception
|
Runtime Exception
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
commandContext={{ isDark }}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import {
|
|||||||
CommandContext
|
CommandContext
|
||||||
} from "~/lib/terminal-commands";
|
} from "~/lib/terminal-commands";
|
||||||
import { Btop } from "~/components/Btop";
|
import { Btop } from "~/components/Btop";
|
||||||
|
import { useLocation, useNavigate } from "@solidjs/router";
|
||||||
|
import { useDarkMode } from "~/context/darkMode";
|
||||||
|
|
||||||
interface TerminalErrorPageProps {
|
interface TerminalErrorPageProps {
|
||||||
navigate: (path: string) => void;
|
|
||||||
location: { pathname: string };
|
|
||||||
errorContent: JSX.Element;
|
errorContent: JSX.Element;
|
||||||
quickActions: JSX.Element;
|
quickActions: JSX.Element;
|
||||||
footer: JSX.Element;
|
footer: JSX.Element;
|
||||||
@@ -24,6 +24,9 @@ export function TerminalErrorPage(props: TerminalErrorPageProps) {
|
|||||||
const [btopOpen, setBtopOpen] = createSignal(false);
|
const [btopOpen, setBtopOpen] = createSignal(false);
|
||||||
let inputRef: HTMLInputElement | undefined;
|
let inputRef: HTMLInputElement | undefined;
|
||||||
let footerRef: HTMLDivElement | undefined;
|
let footerRef: HTMLDivElement | undefined;
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
const { isDark } = useDarkMode();
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (history().length > 0) {
|
if (history().length > 0) {
|
||||||
@@ -46,10 +49,11 @@ export function TerminalErrorPage(props: TerminalErrorPageProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const commands = createTerminalCommands({
|
const commands = createTerminalCommands({
|
||||||
navigate: props.navigate,
|
navigate,
|
||||||
location: props.location,
|
location,
|
||||||
addToHistory,
|
addToHistory,
|
||||||
openBtop: () => setBtopOpen(true),
|
openBtop: () => setBtopOpen(true),
|
||||||
|
isDark: isDark,
|
||||||
...props.commandContext
|
...props.commandContext
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,12 +102,42 @@ export function TerminalErrorPage(props: TerminalErrorPageProps) {
|
|||||||
inputRef?.focus();
|
inputRef?.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const quickActions = (
|
||||||
|
<div class="mb-8 w-full max-w-4xl space-y-3 font-mono text-sm">
|
||||||
|
<div class="text-subtext1">Quick actions:</div>
|
||||||
|
{props.quickActions}
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={() => navigate!("/")}
|
||||||
|
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full cursor-pointer items-center gap-2 border px-4 py-3 text-left transition-all"
|
||||||
|
>
|
||||||
|
<span class="text-green">$</span>
|
||||||
|
<span class="text-blue group-hover:text-sky">cd</span>
|
||||||
|
<span class="text-text group-hover:text-blue">~</span>
|
||||||
|
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
||||||
|
[Return home]
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={() => window.history.back()}
|
||||||
|
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full cursor-pointer items-center gap-2 border px-4 py-3 text-left transition-all"
|
||||||
|
>
|
||||||
|
<span class="text-green">$</span>
|
||||||
|
<span class="text-blue group-hover:text-sky">cd</span>
|
||||||
|
<span class="text-text group-hover:text-blue">..</span>
|
||||||
|
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
||||||
|
[Go back]
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class={`relative min-h-screen w-full overflow-hidden`}
|
class={`relative min-h-screen w-full overflow-hidden`}
|
||||||
onClick={() => inputRef?.focus()}
|
onClick={() => inputRef?.focus()}
|
||||||
>
|
>
|
||||||
{/* Scanline effect */}
|
|
||||||
<div class="pointer-events-none absolute inset-0 z-20 opacity-5">
|
<div class="pointer-events-none absolute inset-0 z-20 opacity-5">
|
||||||
<div
|
<div
|
||||||
class="h-full w-full"
|
class="h-full w-full"
|
||||||
@@ -115,17 +149,9 @@ export function TerminalErrorPage(props: TerminalErrorPageProps) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main content */}
|
|
||||||
<div class="relative z-10 flex min-h-screen flex-col items-start justify-start px-4 py-16 lg:px-16">
|
<div class="relative z-10 flex min-h-screen flex-col items-start justify-start px-4 py-16 lg:px-16">
|
||||||
{/* Terminal header */}
|
|
||||||
|
|
||||||
{/* Error Content - passed as prop */}
|
|
||||||
{props.errorContent}
|
{props.errorContent}
|
||||||
|
{quickActions}
|
||||||
{/* Quick Actions - passed as prop */}
|
|
||||||
{props.quickActions}
|
|
||||||
|
|
||||||
{/* Command history */}
|
|
||||||
<Show when={history().length > 0}>
|
<Show when={history().length > 0}>
|
||||||
<div class="mb-4 w-full max-w-4xl font-mono text-sm">
|
<div class="mb-4 w-full max-w-4xl font-mono text-sm">
|
||||||
<For each={history()}>
|
<For each={history()}>
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import { useLocation, useNavigate } from "@solidjs/router";
|
|||||||
import { createSignal, onMount, onCleanup } from "solid-js";
|
import { createSignal, onMount, onCleanup } from "solid-js";
|
||||||
import { glitchText } from "~/lib/client-utils";
|
import { glitchText } from "~/lib/client-utils";
|
||||||
import { TerminalErrorPage } from "~/components/TerminalErrorPage";
|
import { TerminalErrorPage } from "~/components/TerminalErrorPage";
|
||||||
import { useDarkMode } from "~/context/darkMode";
|
|
||||||
|
|
||||||
export default function Page_401() {
|
export default function Page_401() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [glitch401, setGlitch401] = createSignal("401");
|
const [glitch401, setGlitch401] = createSignal("401");
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -60,9 +58,8 @@ export default function Page_401() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
const quickActions = (
|
const quickActions = (
|
||||||
<div class="mb-8 w-full max-w-4xl space-y-3 font-mono text-sm">
|
<>
|
||||||
<div class="text-subtext1">Quick actions:</div>
|
{" "}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate("/login")}
|
onClick={() => navigate("/login")}
|
||||||
class="group border-surface0 bg-mantle hover:border-yellow hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
class="group border-surface0 bg-mantle hover:border-yellow hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
||||||
@@ -74,40 +71,9 @@ export default function Page_401() {
|
|||||||
[Login]
|
[Login]
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
<button
|
|
||||||
onClick={() => navigate("/")}
|
|
||||||
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
|
||||||
>
|
|
||||||
<span class="text-green">$</span>
|
|
||||||
<span class="text-blue group-hover:text-sky">cd</span>
|
|
||||||
<span class="text-text group-hover:text-blue">~</span>
|
|
||||||
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
|
||||||
[Return home]
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => window.history.back()}
|
|
||||||
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
|
||||||
>
|
|
||||||
<span class="text-green">$</span>
|
|
||||||
<span class="text-blue group-hover:text-sky">cd</span>
|
|
||||||
<span class="text-text group-hover:text-blue">..</span>
|
|
||||||
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
|
||||||
[Go back]
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let isDark: () => boolean;
|
|
||||||
try {
|
|
||||||
const darkMode = useDarkMode();
|
|
||||||
isDark = darkMode.isDark;
|
|
||||||
} catch (e) {
|
|
||||||
isDark = () => true;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageHead
|
<PageHead
|
||||||
@@ -116,8 +82,6 @@ export default function Page_401() {
|
|||||||
/>
|
/>
|
||||||
<HttpStatusCode code={401} />
|
<HttpStatusCode code={401} />
|
||||||
<TerminalErrorPage
|
<TerminalErrorPage
|
||||||
navigate={navigate}
|
|
||||||
location={location}
|
|
||||||
errorContent={errorContent}
|
errorContent={errorContent}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
disableTerminal
|
disableTerminal
|
||||||
@@ -127,7 +91,6 @@ export default function Page_401() {
|
|||||||
<span class="text-subtext0">|</span> Unauthorized Access
|
<span class="text-subtext0">|</span> Unauthorized Access
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
commandContext={{ isDark }}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,22 +1,19 @@
|
|||||||
import { PageHead } from "~/components/PageHead";
|
import { PageHead } from "~/components/PageHead";
|
||||||
import { HttpStatusCode } from "@solidjs/start";
|
import { HttpStatusCode } from "@solidjs/start";
|
||||||
import { useNavigate, useLocation } from "@solidjs/router";
|
import { useLocation, useNavigate } from "@solidjs/router";
|
||||||
import { createSignal, onCleanup, onMount, Show } from "solid-js";
|
import { createSignal, onCleanup, onMount, Show } from "solid-js";
|
||||||
import { TerminalErrorPage } from "~/components/TerminalErrorPage";
|
import { TerminalErrorPage } from "~/components/TerminalErrorPage";
|
||||||
import { useDarkMode } from "~/context/darkMode";
|
|
||||||
import { glitchText } from "~/lib/client-utils";
|
import { glitchText } from "~/lib/client-utils";
|
||||||
|
|
||||||
// Component that crashes when rendered
|
|
||||||
function CrashComponent() {
|
function CrashComponent() {
|
||||||
throw new Error("Terminal crash test - triggering error boundary");
|
throw new Error("Terminal crash test - triggering error boundary");
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function NotFound() {
|
export default function NotFound() {
|
||||||
const navigate = useNavigate();
|
|
||||||
const location = useLocation();
|
|
||||||
const { isDark } = useDarkMode();
|
|
||||||
const [glitch404, setGlitch404] = createSignal("404");
|
const [glitch404, setGlitch404] = createSignal("404");
|
||||||
const [shouldCrash, setShouldCrash] = createSignal(false);
|
const [shouldCrash, setShouldCrash] = createSignal(false);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const interval = glitchText(glitch404(), setGlitch404);
|
const interval = glitchText(glitch404(), setGlitch404);
|
||||||
@@ -67,33 +64,7 @@ export default function NotFound() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const quickActions = (
|
const quickActions = (
|
||||||
<div class="mb-8 w-full max-w-4xl space-y-3 font-mono text-sm">
|
<>
|
||||||
<div class="text-subtext1">Quick commands:</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => navigate("/")}
|
|
||||||
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
|
||||||
>
|
|
||||||
<span class="text-green">$</span>
|
|
||||||
<span class="text-blue group-hover:text-sky">cd</span>
|
|
||||||
<span class="text-text group-hover:text-blue">~</span>
|
|
||||||
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
|
||||||
[Return home]
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={() => window.history.back()}
|
|
||||||
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
|
||||||
>
|
|
||||||
<span class="text-green">$</span>
|
|
||||||
<span class="text-blue group-hover:text-sky">cd</span>
|
|
||||||
<span class="text-text group-hover:text-blue">..</span>
|
|
||||||
<span class="text-subtext1 ml-auto opacity-0 transition-opacity group-hover:opacity-100">
|
|
||||||
[Go back]
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate("/blog")}
|
onClick={() => navigate("/blog")}
|
||||||
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
class="group border-surface0 bg-mantle hover:border-blue hover:bg-surface0 flex w-full items-center gap-2 border px-4 py-3 text-left transition-all"
|
||||||
@@ -105,7 +76,7 @@ export default function NotFound() {
|
|||||||
[View blog]
|
[View blog]
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -120,20 +91,17 @@ export default function NotFound() {
|
|||||||
/>
|
/>
|
||||||
<HttpStatusCode code={404} />
|
<HttpStatusCode code={404} />
|
||||||
<TerminalErrorPage
|
<TerminalErrorPage
|
||||||
navigate={navigate}
|
|
||||||
location={location}
|
|
||||||
errorContent={errorContent}
|
errorContent={errorContent}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
|
commandContext={{
|
||||||
|
triggerCrash: () => setShouldCrash(true)
|
||||||
|
}}
|
||||||
footer={
|
footer={
|
||||||
<>
|
<>
|
||||||
<span class="text-red">404</span>{" "}
|
<span class="text-red">404</span>{" "}
|
||||||
<span class="text-subtext0">|</span> Page Not Found
|
<span class="text-subtext0">|</span> Page Not Found
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
commandContext={{
|
|
||||||
triggerCrash: () => setShouldCrash(true),
|
|
||||||
isDark: isDark
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user