@@ -15,25 +15,54 @@ import {
1515} from '@sentry/core' ;
1616import type { Client , Integration , Span } from '@sentry/types' ;
1717import { logger } from '@sentry/utils' ;
18- import type { BeforeLeaveEventArgs , Location , RouteSectionProps , RouterProps } from '@solidjs/router' ;
1918import { createEffect , mergeProps , splitProps } from 'solid-js' ;
2019import type { Component , JSX , ParentProps } from 'solid-js' ;
2120import { createComponent } from 'solid-js/web' ;
2221import { DEBUG_BUILD } from './debug-build' ;
2322
24- const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet < Client > ( ) ;
23+ // Vendored solid router types so that we don't need to depend on solid router.
24+ // These are not exhaustive and loose on purpose.
25+ interface Location {
26+ pathname : string ;
27+ }
2528
26- type UserBeforeLeave = ( listener : ( e : BeforeLeaveEventArgs ) => void ) => void ;
27- type UseLocation = ( ) => Location ;
29+ interface BeforeLeaveEventArgs {
30+ from : Location ;
31+ to : string | number ;
32+ }
2833
29- let _useBeforeLeave : UserBeforeLeave ;
30- let _useLocation : UseLocation ;
34+ interface RouteSectionProps < T = unknown > {
35+ location : Location ;
36+ data ?: T ;
37+ children ?: JSX . Element ;
38+ }
39+
40+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41+ type RouteDefinition < S extends string | string [ ] = any , T = unknown > = {
42+ path ?: S ;
43+ children ?: RouteDefinition | RouteDefinition [ ] ;
44+ component ?: Component < RouteSectionProps < T > > ;
45+ } ;
46+
47+ interface RouterProps {
48+ base ?: string ;
49+ root ?: Component < RouteSectionProps > ;
50+ children ?: JSX . Element | RouteDefinition | RouteDefinition [ ] ;
51+ }
3152
3253interface SolidRouterOptions {
3354 useBeforeLeave : UserBeforeLeave ;
3455 useLocation : UseLocation ;
3556}
3657
58+ type UserBeforeLeave = ( listener : ( e : BeforeLeaveEventArgs ) => void ) => void ;
59+ type UseLocation = ( ) => Location ;
60+
61+ const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet < Client > ( ) ;
62+
63+ let _useBeforeLeave : UserBeforeLeave ;
64+ let _useLocation : UseLocation ;
65+
3766function handleNavigation ( location : string ) : void {
3867 const client = getClient ( ) ;
3968 if ( ! client || ! CLIENTS_WITH_INSTRUMENT_NAVIGATION . has ( client ) ) {
0 commit comments