File tree Expand file tree Collapse file tree 7 files changed +38
-12
lines changed
Expand file tree Collapse file tree 7 files changed +38
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @tanstack/devtools-utils ' : patch
3+ ---
4+
5+ fix issue with unmounting of devtools
Original file line number Diff line number Diff line change 1+ ---
2+ ' @tanstack/devtools ' : patch
3+ ---
4+
5+ fix issue with popup window
Original file line number Diff line number Diff line change @@ -32,18 +32,16 @@ export function createReactPanel<
3232 const devToolRef = useRef < HTMLDivElement > ( null )
3333 const devtools = useRef < TCoreDevtoolsClass | null > ( null )
3434 useEffect ( ( ) => {
35- if ( devtools . current ) return
36-
37- devtools . current = new CoreClass ( )
35+ const instance = new CoreClass ( )
36+ devtools . current = instance
3837
3938 if ( devToolRef . current ) {
40- devtools . current . mount ( devToolRef . current , props ?. theme ?? 'dark' )
39+ instance . mount ( devToolRef . current , props ?. theme ?? 'dark' )
4140 }
4241
4342 return ( ) => {
44- if ( devToolRef . current ) {
45- devtools . current ?. unmount ( )
46- }
43+ instance . unmount ( )
44+ devtools . current = null
4745 }
4846 } , [ props ?. theme ] )
4947
Original file line number Diff line number Diff line change @@ -14,13 +14,16 @@ import type { JSX } from 'solid-js'
1414export function constructCoreClass ( Component : ( ) => JSX . Element ) {
1515 class DevtoolsCore {
1616 #isMounted = false
17+ #isMounting = false
18+ #mountCb: ( ( ) => void ) | null = null
1719 #dispose?: ( ) => void
1820 #Component: any
1921 #ThemeProvider: any
2022
2123 constructor ( ) { }
2224
2325 async mount < T extends HTMLElement > ( el : T , theme : 'light' | 'dark' ) {
26+ this . #isMounting = true
2427 const { lazy } = await import ( 'solid-js' )
2528 const { render, Portal } = await import ( 'solid-js/web' )
2629 if ( this . #isMounted) {
@@ -49,13 +52,25 @@ export function constructCoreClass(Component: () => JSX.Element) {
4952 )
5053 } , mountTo )
5154 this . #isMounted = true
55+ this . #isMounting = false
5256 this . #dispose = dispose
57+ if ( this . #mountCb) {
58+ this . #mountCb( )
59+ this . #mountCb = null
60+ }
5361 }
5462
5563 unmount ( ) {
56- if ( ! this . #isMounted) {
64+ if ( ! this . #isMounted && ! this . #isMounting ) {
5765 throw new Error ( 'Devtools is not mounted' )
5866 }
67+ if ( this . #isMounting) {
68+ this . #mountCb = ( ) => {
69+ this . #dispose?.( )
70+ this . #isMounted = false
71+ }
72+ return
73+ }
5974 this . #dispose?.( )
6075 this . #isMounted = false
6176 }
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ export const SourceInspector = () => {
8080 e . stopPropagation ( )
8181
8282 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
83- const baseUrl = new URL ( import . meta. env ?. BASE_URL ?? '/' , location . origin )
83+ const baseUrl = new URL ( import . meta? .env ?. BASE_URL ?? '/' , location . origin )
8484 const url = new URL (
8585 `__tsd/open-source?source=${ encodeURIComponent (
8686 highlightState . dataSource ,
Original file line number Diff line number Diff line change @@ -54,8 +54,9 @@ export const PiPProvider = (props: PiPProviderProps) => {
5454 'Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.' ,
5555 )
5656 }
57-
58- import . meta. hot ?. on ( 'vite:beforeUpdate' , ( ) => {
57+ // can be run outside of vite so we ignore the rule
58+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
59+ import . meta?. hot ?. on ( 'vite:beforeUpdate' , ( ) => {
5960 localStorage . setItem ( 'pip_open' , 'false' )
6061 closePipWindow ( )
6162 } )
Original file line number Diff line number Diff line change @@ -63,7 +63,9 @@ export class TanStackDevtoolsCore {
6363
6464 mount < T extends HTMLElement > ( el : T ) {
6565 // tsup-preset-solid statically replaces this variable during build, which eliminates this code from server bundle
66- if ( import . meta. env . SSR ) return
66+ // can be run outside of vite so we ignore the rule
67+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
68+ if ( import . meta?. env ?. SSR ) return
6769
6870 if ( this . #isMounted) {
6971 throw new Error ( 'Devtools is already mounted' )
You can’t perform that action at this time.
0 commit comments