Fix runtime errors: PerformanceObserver, localStorage, crypto.randomUUID, hydration issues, and linting errors

This commit is contained in:
2026-01-10 16:54:28 +01:00
parent ca2ed13446
commit a980ee8fcd
8 changed files with 22 additions and 23 deletions

View File

@@ -38,7 +38,8 @@ export async function GET(request: NextRequest) {
cls: ((p.performance as Record<string, unknown>)?.coreWebVitals as Record<string, unknown>)?.cls as number || 0 cls: ((p.performance as Record<string, unknown>)?.coreWebVitals as Record<string, unknown>)?.cls as number || 0
})); }));
const avgLighthouse = projectsWithPerformance.length > 0 // Calculate average lighthouse score (currently unused but kept for future use)
const _avgLighthouse = projectsWithPerformance.length > 0
? Math.round(projectsWithPerformance.reduce((sum, p) => sum + p.lighthouse, 0) / projectsWithPerformance.length) ? Math.round(projectsWithPerformance.reduce((sum, p) => sum + p.lighthouse, 0) / projectsWithPerformance.length)
: 0; : 0;

View File

@@ -28,18 +28,18 @@ export default function KernelPanic404() {
let audioCtx: AudioContext | null = null; let audioCtx: AudioContext | null = null;
let systemFrozen = false; let systemFrozen = false;
let currentMusic: any = null; let currentMusic: AudioBufferSourceNode | null = null;
let hawkinsActive = false; let hawkinsActive = false;
let fsocietyActive = false; let fsocietyActive = false;
// Timers storage to clear on unmount // Timers storage to clear on unmount
const timers: (NodeJS.Timeout | number)[] = []; const timers: (NodeJS.Timeout | number)[] = [];
const interval = (fn: Function, ms: number) => { const interval = (fn: () => void, ms: number) => {
const id = setInterval(fn, ms); const id = setInterval(fn, ms);
timers.push(id); timers.push(id);
return id; return id;
}; };
const timeout = (fn: Function, ms: number) => { const timeout = (fn: () => void, ms: number) => {
const id = setTimeout(fn, ms); const id = setTimeout(fn, ms);
timers.push(id); timers.push(id);
return id; return id;
@@ -49,7 +49,7 @@ export default function KernelPanic404() {
function initAudio() { function initAudio() {
if (!audioCtx) { if (!audioCtx) {
const AudioContextClass = const AudioContextClass =
window.AudioContext || (window as any).webkitAudioContext; window.AudioContext || (window as typeof window & { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;
if (AudioContextClass) { if (AudioContextClass) {
audioCtx = new AudioContextClass(); audioCtx = new AudioContextClass();
} }
@@ -444,6 +444,7 @@ export default function KernelPanic404() {
} }
/* --- FILE SYSTEM --- */ /* --- FILE SYSTEM --- */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const fileSystem: any = { const fileSystem: any = {
home: { home: {
type: "dir", type: "dir",
@@ -551,7 +552,7 @@ export default function KernelPanic404() {
let currentPath = fileSystem.home.children.guest; let currentPath = fileSystem.home.children.guest;
let pathStr = "~"; let pathStr = "~";
let commandHistory: string[] = []; const commandHistory: string[] = [];
let historyIndex = -1; let historyIndex = -1;
/* --- UTILS --- */ /* --- UTILS --- */
@@ -671,7 +672,7 @@ export default function KernelPanic404() {
// Clear initial output // Clear initial output
output!.innerHTML = ""; output!.innerHTML = "";
for (let msg of bootMessages) { for (const msg of bootMessages) {
printLine(msg.t, msg.type); printLine(msg.t, msg.type);
await sleep(msg.d); await sleep(msg.d);
} }
@@ -794,7 +795,7 @@ export default function KernelPanic404() {
if (suggestions.length === 0) { if (suggestions.length === 0) {
try { try {
playSynth("beep"); playSynth("beep");
} catch (e) {} } catch {}
return; return;
} }
@@ -817,13 +818,13 @@ export default function KernelPanic404() {
input.setSelectionRange(input.value.length, input.value.length); input.setSelectionRange(input.value.length, input.value.length);
try { try {
playSynth("beep"); playSynth("beep");
} catch (e) {} } catch {}
} else { } else {
// Multiple matches // Multiple matches
printLine(`Possible completions: ${suggestions.join(" ")}`, "log-dim"); printLine(`Possible completions: ${suggestions.join(" ")}`, "log-dim");
try { try {
playSynth("beep"); playSynth("beep");
} catch (e) {} } catch {}
} }
} }
@@ -832,7 +833,7 @@ export default function KernelPanic404() {
if (systemFrozen || !input) { if (systemFrozen || !input) {
try { try {
playSynth("beep"); playSynth("beep");
} catch (e) {} } catch {}
return; return;
} }
@@ -871,7 +872,7 @@ export default function KernelPanic404() {
args.includes("-a") || args.includes("-la") || args.includes("-l"); args.includes("-a") || args.includes("-la") || args.includes("-l");
const longFormat = args.includes("-l") || args.includes("-la"); const longFormat = args.includes("-l") || args.includes("-la");
let items = Object.keys(currentPath.children).filter( const items = Object.keys(currentPath.children).filter(
(n) => !n.startsWith(".") || showHidden, (n) => !n.startsWith(".") || showHidden,
); );
@@ -1177,7 +1178,7 @@ export default function KernelPanic404() {
overlay.style.display = "none"; overlay.style.display = "none";
overlay.innerHTML = ""; overlay.innerHTML = "";
const sporeInterval = interval(() => { const _sporeInterval = interval(() => {
const spore = document.createElement("div"); const spore = document.createElement("div");
spore.className = "spore"; spore.className = "spore";
spore.style.left = Math.random() * 100 + "%"; spore.style.left = Math.random() * 100 + "%";
@@ -1187,7 +1188,7 @@ export default function KernelPanic404() {
setTimeout(() => spore.remove(), 3000); setTimeout(() => spore.remove(), 3000);
}, 300); }, 300);
const glitchInterval = interval(() => { const _glitchInterval = interval(() => {
if (!hawkinsActive) return; if (!hawkinsActive) return;
body.style.filter = "hue-rotate(180deg) contrast(1.3) brightness(0.9)"; body.style.filter = "hue-rotate(180deg) contrast(1.3) brightness(0.9)";
setTimeout( setTimeout(
@@ -1412,7 +1413,7 @@ export default function KernelPanic404() {
try { try {
playSynth("key"); playSynth("key");
} catch (e) {} } catch {}
if (e.key === "ArrowUp" && historyIndex > 0) { if (e.key === "ArrowUp" && historyIndex > 0) {
historyIndex--; historyIndex--;

View File

@@ -2,7 +2,7 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { motion, Variants } from "framer-motion"; import { motion, Variants } from "framer-motion";
import { ExternalLink, Github, Layers, ArrowRight, ArrowLeft, Calendar } from "lucide-react"; import { ExternalLink, Github, ArrowRight, Calendar } from "lucide-react";
import Link from "next/link"; import Link from "next/link";
import Image from "next/image"; import Image from "next/image";

View File

@@ -59,7 +59,7 @@ function EditorPageContent() {
const [isSaving, setIsSaving] = useState(false); const [isSaving, setIsSaving] = useState(false);
const [isCreating, setIsCreating] = useState(!projectId); const [isCreating, setIsCreating] = useState(!projectId);
const [showPreview, setShowPreview] = useState(false); const [showPreview, setShowPreview] = useState(false);
const [isTyping, setIsTyping] = useState(false); const [_isTyping, setIsTyping] = useState(false);
const [history, setHistory] = useState<typeof formData[]>([]); const [history, setHistory] = useState<typeof formData[]>([]);
const [historyIndex, setHistoryIndex] = useState(-1); const [historyIndex, setHistoryIndex] = useState(-1);
const [originalFormData, setOriginalFormData] = useState<typeof formData | null>(null); const [originalFormData, setOriginalFormData] = useState<typeof formData | null>(null);

View File

@@ -282,7 +282,7 @@ const AdminPage = () => {
onClick={() => { onClick={() => {
try { try {
localStorage.removeItem('admin_lockout'); localStorage.removeItem('admin_lockout');
} catch (error) { } catch {
// Ignore errors // Ignore errors
} }
window.location.reload(); window.location.reload();

View File

@@ -1,12 +1,11 @@
"use client"; "use client";
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import { ExternalLink, Calendar, Tag, ArrowLeft, Github as GithubIcon, Share2 } from 'lucide-react'; import { ExternalLink, Calendar, ArrowLeft, Github as GithubIcon, Share2 } from 'lucide-react';
import Link from 'next/link'; import Link from 'next/link';
import { useParams } from 'next/navigation'; import { useParams } from 'next/navigation';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import Image from 'next/image';
interface Project { interface Project {
id: number; id: number;

View File

@@ -4,9 +4,7 @@ import { useState, useEffect, useCallback } from 'react';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import { import {
BarChart3, BarChart3,
TrendingUp,
Eye, Eye,
Heart,
Zap, Zap,
Globe, Globe,
Activity, Activity,

View File

@@ -324,7 +324,7 @@ export const useWebVitals = () => {
observers.forEach(observer => { observers.forEach(observer => {
try { try {
observer.disconnect(); observer.disconnect();
} catch (error) { } catch {
// Silently fail // Silently fail
} }
}); });