@@ -11,13 +11,6 @@ import {
1111} from "./types.js" ;
1212import highlightConfig from "./highlightConfig.js" ;
1313
14- let JSDOM : any = null ;
15-
16- if ( typeof window === "undefined" ) {
17- const pkgs = typeof window === "undefined" ? [ "jsdom" ] : [ ] ;
18- JSDOM = ( await import ( pkgs [ 0 ] ) ) . JSDOM ;
19- }
20-
2114function findNodeIdx ( nodes : CDPNode [ ] , nodeId : number ) : number {
2215 for ( let i = 0 ; i < nodes . length ; i ++ ) {
2316 if ( nodes [ i ] . nodeId === nodeId ) {
@@ -27,13 +20,13 @@ function findNodeIdx(nodes: CDPNode[], nodeId: number): number {
2720 return null ;
2821}
2922
30- type CDPClient = {
23+ export type CDPClient = {
3124 send : ( method : string , params ?: object ) => Promise < any > ;
3225 on : ( event : string , callback : ( data : any ) => void ) => void ;
3326 off : ( event : string , callback : ( data : any ) => void ) => void ;
3427} ;
3528
36- type InspectorOptions = {
29+ export type InspectorOptions = {
3730 documentImpl ?: DOMImplementation ;
3831 eventTimeout ?: number ;
3932} ;
@@ -174,10 +167,12 @@ export class Inspector extends EventEmitter {
174167
175168 if ( options . documentImpl ) {
176169 this . documentImpl = options . documentImpl ;
170+ } else if ( window ?. document ?. implementation ) {
171+ this . documentImpl = window . document . implementation ;
177172 } else {
178- this . documentImpl = JSDOM
179- ? new JSDOM ( "<!DOCTYPE html>" ) . window . document . implementation
180- : window . document . implementation ;
173+ throw new Error (
174+ "No window.document.implementation. documentImpl must be provided in your environment." ,
175+ ) ;
181176 }
182177 this . eventTimeout = options . eventTimeout || 100 ;
183178 }
0 commit comments