- ErrorBoundary.tsx wraps widget — crashes show fallback, not blank void - build.sh v1.1.0: removed ALL PHP file copies (Chronicler deploys manually) - Added set -e / set -u for fail-fast - Added TypeScript pre-flight check (yarn tsc --noEmit) before build - Added dynamic Blueprint controller detection via find - Widget injection now wrapped in <ModpackErrorBoundary> - Pre-commit PHP lint hook at scripts/pre-commit-hook.sh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
839 B
TypeScript
28 lines
839 B
TypeScript
import React, { Component, ErrorInfo, ReactNode } from "react";
|
|
|
|
interface Props { children?: ReactNode; fallback?: ReactNode; }
|
|
interface State { hasError: boolean; }
|
|
|
|
class ModpackErrorBoundary extends Component<Props, State> {
|
|
public state: State = { hasError: false };
|
|
|
|
public static getDerivedStateFromError(_: Error): State {
|
|
return { hasError: true };
|
|
}
|
|
|
|
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
console.error("ModpackChecker Component Error:", error, errorInfo);
|
|
}
|
|
|
|
public render() {
|
|
if (this.state.hasError) {
|
|
return this.props.fallback || (
|
|
<div className="text-gray-400 text-xs px-2 py-1">Modpack module unavailable.</div>
|
|
);
|
|
}
|
|
return this.props.children;
|
|
}
|
|
}
|
|
|
|
export default ModpackErrorBoundary;
|