-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathipc-types.d.ts
118 lines (103 loc) · 2.81 KB
/
ipc-types.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack
// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on
// whether you're running in development or production).
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
// Defined in webpack.main.config.ts
declare const COMMIT_HASH: string | undefined;
interface ShowNotificationOptions extends Electron.NotificationConstructorOptions {
showIcon: boolean;
}
interface StoppedSiteDetails {
running: false;
id: string;
name: string;
path: string;
port: number;
phpVersion: string;
wpVersion?: string;
customDomain?: string;
enableHttps?: boolean;
adminPassword?: string;
tlsKey?: string;
tlsCert?: string;
themeDetails?: {
name: string;
path: string;
slug: string;
isBlockTheme: boolean;
supportsWidgets: boolean;
supportsMenus: boolean;
};
isAddingSite?: boolean;
autoStart?: boolean;
}
interface StartedSiteDetails extends StoppedSiteDetails {
running: true;
url: string;
}
type SiteDetails = StartedSiteDetails | StoppedSiteDetails;
interface Snapshot {
url: string;
atomicSiteId: number;
localSiteId: string;
date: number;
isLoading?: boolean;
isDeleting?: boolean;
name?: string;
sequence?: number;
userId?: number;
}
type InstalledApps = {
vscode: boolean;
phpstorm: boolean;
nova: boolean;
webstorm: boolean;
sublime: boolean;
atom: boolean;
windsurf: boolean;
cursor: boolean;
};
type InstalledTerminals = {
terminal: boolean;
iterm: boolean;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Tail< T extends any[] > = ( ( ...args: T ) => any ) extends ( _: any, ...tail: infer U ) => any
? U
: never;
// IpcApi functions have the same signatures as the functions in ipc-handlers.ts, except
// with the first parameter removed.
type IpcApi = {
[ K in keyof typeof import('./ipc-handlers') ]: (
...args: Tail< Parameters< ( typeof import('./ipc-handlers') )[ K ] > >
) => ReturnType< ( typeof import('./ipc-handlers') )[ K ] >;
} & {
/**
* `webUtils.getPathForFile` is available only inside preload script, that's why this one
* function is exception and need to be defined here manually.
*
* See https://www.electronjs.org/docs/latest/breaking-changes#planned-breaking-api-changes-320
* for more details.
*/
getPathForFile: ( file: File ) => string;
};
interface AppGlobals {
platform: NodeJS.Platform;
appName: string;
appVersion: string;
arm64Translation: boolean;
pressableSyncEnabled: boolean;
terminalWpCliEnabled: boolean;
preferredEditor: boolean;
}
// Our IPC objects will be attached to the `window` global
interface Window {
ipcApi: IpcApi;
appGlobals: AppGlobals;
}
// Network
interface WpcomNetworkError extends Error {
code: string;
status: number;
}