2023-02-20 20:57:38 +00:00
|
|
|
import { IncomingMessage, session } from 'electron/main';
|
|
|
|
import type { ClientRequestConstructorOptions } from 'electron/main';
|
|
|
|
import { ClientRequest } from '@electron/internal/browser/api/net-client-request';
|
2020-09-29 16:03:33 +00:00
|
|
|
|
2023-02-20 20:57:38 +00:00
|
|
|
const { isOnline } = process._linkedBinding('electron_browser_net');
|
2016-09-21 15:35:03 +00:00
|
|
|
|
2020-07-13 16:36:20 +00:00
|
|
|
export function request (options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) {
|
2016-09-29 13:24:28 +00:00
|
|
|
return new ClientRequest(options, callback);
|
2020-07-13 16:36:20 +00:00
|
|
|
}
|
2020-10-21 02:55:06 +00:00
|
|
|
|
2023-02-20 20:57:38 +00:00
|
|
|
export function fetch (input: RequestInfo, init?: RequestInit): Promise<Response> {
|
|
|
|
return session.defaultSession.fetch(input, init);
|
|
|
|
}
|
|
|
|
|
2023-05-02 07:53:00 +00:00
|
|
|
export function resolveHost (host: string, options?: Electron.ResolveHostOptions): Promise<Electron.ResolvedHost> {
|
|
|
|
return session.defaultSession.resolveHost(host, options);
|
|
|
|
}
|
|
|
|
|
2020-10-21 02:55:06 +00:00
|
|
|
exports.isOnline = isOnline;
|
|
|
|
|
|
|
|
Object.defineProperty(exports, 'online', {
|
|
|
|
get: () => isOnline()
|
|
|
|
});
|