1+ import { SlotErrorBoundary } from './error-boundary' ;
12import { store } from './store' ;
23import type { Interceptor , InterceptorOptions , SlotName } from './types' ;
34
@@ -15,11 +16,14 @@ export function before<P extends Record<string, any> = Record<string, any>>(
1516 Comp : React . FC < P > ,
1617 opts ?: InterceptorOptions ,
1718) : ( ) => void {
19+ const label = `before:${ Comp . displayName || Comp . name || '?' } ` ;
1820 return intercept < P > (
1921 name ,
2022 ( props , next ) => (
2123 < >
22- < Comp { ...props } />
24+ < SlotErrorBoundary slotName = { name } label = { label } >
25+ < Comp { ...props } />
26+ </ SlotErrorBoundary >
2327 { next ( ) }
2428 </ >
2529 ) ,
@@ -33,12 +37,15 @@ export function after<P extends Record<string, any> = Record<string, any>>(
3337 Comp : React . FC < P > ,
3438 opts ?: InterceptorOptions ,
3539) : ( ) => void {
40+ const label = `after:${ Comp . displayName || Comp . name || '?' } ` ;
3641 return intercept < P > (
3742 name ,
3843 ( props , next ) => (
3944 < >
4045 { next ( ) }
41- < Comp { ...props } />
46+ < SlotErrorBoundary slotName = { name } label = { label } >
47+ < Comp { ...props } />
48+ </ SlotErrorBoundary >
4249 </ >
4350 ) ,
4451 { priority : 100 , ...opts } ,
@@ -64,9 +71,14 @@ export function replace<P extends Record<string, any> = Record<string, any>>(
6471 Replacement : React . FC < P > ,
6572 opts ?: { id ?: string , priority ?: number } ,
6673) : ( ) => void {
74+ const label = `replace:${ Replacement . displayName || Replacement . name || '?' } ` ;
6775 return intercept < P > (
6876 name ,
69- ( props , _next ) => < Replacement { ...props } /> ,
77+ ( props , _next ) => (
78+ < SlotErrorBoundary slotName = { name } label = { label } >
79+ < Replacement { ...props } />
80+ </ SlotErrorBoundary >
81+ ) ,
7082 { priority : 0 , ...opts } ,
7183 ) ;
7284}
@@ -77,9 +89,14 @@ export function wrap<P extends Record<string, any> = Record<string, any>>(
7789 Wrapper : React . FC < { children : React . ReactNode } & P > ,
7890 opts ?: InterceptorOptions ,
7991) : ( ) => void {
92+ const label = `wrap:${ Wrapper . displayName || Wrapper . name || '?' } ` ;
8093 return intercept < P > (
8194 name ,
82- ( props , next ) => < Wrapper { ...props } > { next ( ) } </ Wrapper > ,
95+ ( props , next ) => (
96+ < SlotErrorBoundary slotName = { name } label = { label } >
97+ < Wrapper { ...props } > { next ( ) } </ Wrapper >
98+ </ SlotErrorBoundary >
99+ ) ,
83100 { priority : - 10 , ...opts } ,
84101 ) ;
85102}
0 commit comments