import { Component, ReactNode, Suspense, lazy } from "react"; import { AlertCircle, Loader2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { WindowInstance } from "@/types/app"; // Lazy load all viewer components for better code splitting const NipRenderer = lazy(() => import("./NipRenderer").then((m) => ({ default: m.NipRenderer })), ); const ManPage = lazy(() => import("./ManPage")); const ReqViewer = lazy(() => import("./ReqViewer")); const EventDetailViewer = lazy(() => import("./EventDetailViewer").then((m) => ({ default: m.EventDetailViewer })), ); const ProfileViewer = lazy(() => import("./ProfileViewer").then((m) => ({ default: m.ProfileViewer })), ); const EncodeViewer = lazy(() => import("./EncodeViewer")); const DecodeViewer = lazy(() => import("./DecodeViewer")); const RelayViewer = lazy(() => import("./RelayViewer").then((m) => ({ default: m.RelayViewer })), ); const KindRenderer = lazy(() => import("./KindRenderer")); const KindsViewer = lazy(() => import("./KindsViewer")); const NipsViewer = lazy(() => import("./NipsViewer")); const DebugViewer = lazy(() => import("./DebugViewer").then((m) => ({ default: m.DebugViewer })), ); const ConnViewer = lazy(() => import("./ConnViewer")); const ChatViewer = lazy(() => import("./ChatViewer").then((m) => ({ default: m.ChatViewer })), ); const GroupListViewer = lazy(() => import("./GroupListViewer").then((m) => ({ default: m.GroupListViewer })), ); const SpellsViewer = lazy(() => import("./SpellsViewer").then((m) => ({ default: m.SpellsViewer })), ); const SpellbooksViewer = lazy(() => import("./SpellbooksViewer").then((m) => ({ default: m.SpellbooksViewer })), ); const BlossomViewer = lazy(() => import("./BlossomViewer").then((m) => ({ default: m.BlossomViewer })), ); const WalletViewer = lazy(() => import("./WalletViewer")); const ZapWindow = lazy(() => import("./ZapWindow").then((m) => ({ default: m.ZapWindow })), ); const CountViewer = lazy(() => import("./CountViewer")); const PostViewer = lazy(() => import("./PostViewer").then((m) => ({ default: m.PostViewer })), ); const SettingsViewer = lazy(() => import("./SettingsViewer").then((m) => ({ default: m.SettingsViewer })), ); const EventLogViewer = lazy(() => import("./EventLogViewer").then((m) => ({ default: m.EventLogViewer })), ); // Loading fallback component function ViewerLoading() { return (
Loading...
{this.state.error?.message || "An unexpected error occurred in this window."}
{error instanceof Error ? error.message : "An unexpected error occurred"}