File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,14 @@ import type {
99} from "./types/socketIO/index.ts" ;
1010export type { Manager , ManagerOptions , Socket , SocketOptions } ;
1111
12- declare function io (
13- uri : string ,
14- opts ?: Partial < ManagerOptions & SocketOptions > ,
15- ) : Socket ;
12+ declare global {
13+ interface Window {
14+ io (
15+ uri : string ,
16+ opts ?: Partial < ManagerOptions & SocketOptions > ,
17+ ) : Socket ;
18+ }
19+ }
1620const version = "4.2.0" ;
1721
1822export async function socketIO ( ) {
@@ -23,17 +27,17 @@ export async function socketIO() {
2327 } ) ;
2428}
2529
26- function importSocketIO ( ) : Promise < typeof io > {
30+ function importSocketIO ( ) : Promise < Window [ "io" ] > {
2731 const url =
2832 `https://cdnjs.cloudflare.com/ajax/libs/socket.io/${ version } /socket.io.min.js` ;
2933 if ( document . querySelector ( `script[src="${ url } "]` ) ) {
30- return Promise . resolve ( io ) ;
34+ return Promise . resolve ( window . io ) ;
3135 }
3236
3337 const script = document . createElement ( "script" ) ;
3438 script . src = url ;
3539 return new Promise ( ( resolve , reject ) => {
36- script . onload = ( ) => resolve ( io ) ;
40+ script . onload = ( ) => resolve ( window . io ) ;
3741 script . onerror = ( e ) => reject ( e ) ;
3842 document . head . append ( script ) ;
3943 } ) ;
You can’t perform that action at this time.
0 commit comments