-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.d.ts
79 lines (58 loc) · 1.68 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import {type BrowserWindow} from 'electron';
export type Options = {
/**
The directory to serve, relative to the app root directory.
*/
directory: string;
/**
Custom scheme. For example, `foo` results in your `directory` being available at `foo://-`.
@default 'app'
*/
scheme?: string;
/**
Custom hostname.
@default '-'
*/
hostname?: string;
/**
Custom HTML filename. This gets appended with `'.html'`.
@default 'index'
*/
file?: string;
/**
Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
Useful for testing purposes.
@default true
*/
isCorsEnabled?: boolean;
/**
The [partition](https://electronjs.org/docs/api/session#sessionfrompartitionpartition-options) where the protocol should be installed, if not using Electron's default partition.
@default electron.session.defaultSession
*/
partition?: string;
};
/**
Load the index file in the window.
*/
export type LoadURL = (window: BrowserWindow, searchParameters?: Record<string, string> | URLSearchParams) => Promise<void>; // eslint-disable-line @typescript-eslint/naming-convention
/**
Static file serving for Electron apps.
@example
```
import {app, BrowserWindow} from 'electron';
import serve from 'electron-serve';
const loadURL = serve({directory: 'renderer'});
let mainWindow;
(async () => {
await app.whenReady();
mainWindow = new BrowserWindow();
await loadURL(mainWindow);
// Or optionally with search parameters.
await loadURL(mainWindow, {id: 4, foo: 'bar'});
// The above is equivalent to this:
await mainWindow.loadURL('app://-');
// The `-` is just the required hostname.
})();
```
*/
export default function electronServe(options: Options): LoadURL;