From 72ad4153d21eefb9f17808ec6f1a0ab3b2faf4bb Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Wed, 5 Aug 2026 18:14:34 +0000 Subject: [PATCH] Deploy --- src/components/VulaSandboxBoundary.tsx | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/components/VulaSandboxBoundary.tsx diff --git a/src/components/VulaSandboxBoundary.tsx b/src/components/VulaSandboxBoundary.tsx new file mode 100644 index 0000000..9b9ffdb --- /dev/null +++ b/src/components/VulaSandboxBoundary.tsx @@ -0,0 +1,43 @@ +'use client' +import { Component, ErrorInfo, ReactNode } from 'react' + +interface Props { children: ReactNode } +interface State { hasError: boolean; error: string } + +export class VulaSandboxBoundary extends Component { + constructor(props: Props) { + super(props) + this.state = { hasError: false, error: '' } + } + + static getDerivedStateFromError(error: Error): State { + return { hasError: true, error: error.message } + } + + componentDidCatch(error: Error, info: ErrorInfo): void { + try { + const parent = typeof window !== 'undefined' && window !== window.parent ? window.parent : null + if (parent) { + parent.postMessage( + { type: 'VULA_SANDBOX_ERROR', error: error.message, stack: error.stack, componentStack: info.componentStack }, + '*' + ) + } + } catch (_) { /* cross-origin postMessage can throw — swallow */ } + } + + render() { + if (this.state.hasError) { + return ( +
+
+
+

Fixing detected issue…

+

{this.state.error}

+
+
+ ) + } + return this.props.children + } +}