File tree Expand file tree Collapse file tree
packages/devtools-utils/src Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -27,22 +27,21 @@ export function createReactPanel<
2727 mount : ( el : HTMLElement , theme : 'light' | 'dark' ) => void
2828 unmount : ( ) => void
2929 } ,
30- > ( devtoolsPackageName : string , importName = 'default' ) {
30+ > (
31+ CoreClass : new ( ) => TCoreDevtoolsClass
32+ ) {
3133 function Panel ( props : TComponentProps ) {
3234 const devToolRef = useRef < HTMLDivElement > ( null )
3335 const devtools = useRef < TCoreDevtoolsClass | null > ( null )
3436 useEffect ( ( ) => {
3537 if ( devtools . current ) return
3638
37- import ( /* @vite -ignore */ devtoolsPackageName ) . then (
38- ( { [ importName ] : Core } ) => {
39- devtools . current = new Core ( )
39+ devtools . current = new CoreClass ( )
40+
41+ if ( devToolRef . current ) {
42+ devtools . current . mount ( devToolRef . current , props ?. theme ?? 'dark' )
43+ }
4044
41- if ( devToolRef . current && devtools . current ) {
42- devtools . current . mount ( devToolRef . current , props ?. theme ?? 'dark' )
43- }
44- } ,
45- )
4645
4746 return ( ) => {
4847 devtools . current ?. unmount ( )
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export function constructCoreClass(importPath: string) {
1616 #Component: any
1717 #ThemeProvider: any
1818
19- constructor ( ) { }
19+ constructor ( ) { }
2020
2121 async mount < T extends HTMLElement > ( el : T , theme : 'light' | 'dark' ) {
2222 const { lazy } = await import ( 'solid-js' )
@@ -61,8 +61,10 @@ export function constructCoreClass(importPath: string) {
6161 constructor ( ) {
6262 super ( )
6363 }
64- async mount < T extends HTMLElement > ( _el : T , _theme : 'light' | 'dark' ) { }
65- unmount ( ) { }
64+ async mount < T extends HTMLElement > ( _el : T , _theme : 'light' | 'dark' ) { }
65+ unmount ( ) { }
6666 }
6767 return [ DevtoolsCore , NoOpDevtoolsCore ] as const
6868}
69+
70+ export type ClassType = ReturnType < typeof constructCoreClass > [ 0 ]
Original file line number Diff line number Diff line change 11/** @jsxImportSource solid-js - we use Solid.js as JSX here */
22
33import { onCleanup , onMount } from 'solid-js'
4+ import type { ClassType } from './class'
45
56export interface DevtoolsPanelProps {
67 theme ?: 'light' | 'dark'
78}
89
910export function createSolidPanel <
1011 TComponentProps extends DevtoolsPanelProps | undefined ,
11- > ( importPath : string , importName = 'default' ) {
12+ > ( CoreClass : ClassType ) {
1213 function Panel ( props : TComponentProps ) {
1314 let devToolRef : HTMLDivElement | undefined
1415
15- onMount ( async ( ) => {
16- const devtools = await import ( /* @vite -ignore */ importPath ) . then (
17- ( mod ) => new mod [ importName ] ( ) ,
18- )
16+ onMount ( ( ) => {
17+ const devtools = new CoreClass ( )
18+
1919 if ( devToolRef ) {
2020 devtools . mount ( devToolRef , props ?. theme ?? 'dark' )
2121
You can’t perform that action at this time.
0 commit comments