import { Component } from "react"; /** * @typedef {{ * children: React.ReactNode, * boundaryName: string, * routeId: string, * buildId: string, * telemetry?: import("../../application/ports/telemetry-port.js").TelemetryPort, * fallback?: React.ReactNode * }} RenderBoundaryProps * @typedef {{ hasError: boolean }} RenderBoundaryState */ /** @extends {Component} */ export class RenderErrorBoundary extends Component { /** @param {RenderBoundaryProps} props */ constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError() { return { hasError: true }; } componentDidCatch() { try { this.props.telemetry?.emit("ui.render.failed", { route_id: this.props.routeId, build_id: this.props.buildId, component_boundary: this.props.boundaryName, }); } catch { // Telemetry must never recurse into another render failure. } } reset = () => { this.setState({ hasError: false }); }; render() { if (this.state.hasError) { return ( this.props.fallback ?? (

error.render_failure

) ); } return this.props.children; } } /** @param {Omit} props */ export function RouteBoundary(props) { return ; } /** @param {Omit} props */ export function FeatureBoundary(props) { return ; }