| 
									
										
										
										
											2024-01-04 16:20:37 -05:00
										 |  |  | import { app, IncomingMessage, session } from 'electron/main'; | 
					
						
							| 
									
										
										
										
											2023-02-20 12:57:38 -08:00
										 |  |  | import type { ClientRequestConstructorOptions } from 'electron/main'; | 
					
						
							| 
									
										
										
										
											2024-01-04 16:20:37 -05:00
										 |  |  | import { ClientRequest } from '@electron/internal/common/api/net-client-request'; | 
					
						
							| 
									
										
										
										
											2020-09-29 09:03:33 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-04 16:20:37 -05:00
										 |  |  | const { isOnline } = process._linkedBinding('electron_common_net'); | 
					
						
							| 
									
										
										
										
											2016-09-21 17:35:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-13 09:36:20 -07:00
										 |  |  | export function request (options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) { | 
					
						
							| 
									
										
										
										
											2024-01-04 16:20:37 -05:00
										 |  |  |   if (!app.isReady()) { | 
					
						
							|  |  |  |     throw new Error('net module can only be used after app is ready'); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   return new ClientRequest(options, callback); | 
					
						
							| 
									
										
										
										
											2020-07-13 09:36:20 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-21 04:55:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-20 12:57:38 -08:00
										 |  |  | export function fetch (input: RequestInfo, init?: RequestInit): Promise<Response> { | 
					
						
							|  |  |  |   return session.defaultSession.fetch(input, init); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-02 00:53:00 -07:00
										 |  |  | export function resolveHost (host: string, options?: Electron.ResolveHostOptions): Promise<Electron.ResolvedHost> { | 
					
						
							|  |  |  |   return session.defaultSession.resolveHost(host, options); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-21 04:55:06 +02:00
										 |  |  | exports.isOnline = isOnline; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Object.defineProperty(exports, 'online', { | 
					
						
							|  |  |  |   get: () => isOnline() | 
					
						
							|  |  |  | }); |