-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrenderer.d.ts
380 lines (305 loc) · 8.97 KB
/
renderer.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/* eslint-disable max-classes-per-file, @typescript-eslint/no-use-before-define */
declare module '@getflywheel/local/renderer' {
import {
ApolloClient,
NormalizedCacheObject,
} from '@apollo/client';
import { DownloaderItemProps } from '@getflywheel/local-components';
import Local, { GenericObject } from '@getflywheel/local';
import { FC, ReactNode } from 'react';
import ReactRouter from 'react-router-dom';
import { HooksMain } from '@getflywheel/local/main';
export { default as gql } from 'graphql-tag';
export { RouteComponentProps } from 'react-router-dom';
type ReactNodeLike = ReactNode | string | number;
export class HooksRenderer extends HooksMain {
static deprecatedHooks: {
content: {match: string | RegExp, replacement: string, version: string}[],
};
static addContent(hook: any, callback: any, priority?: number): void;
static doContent(hook: any, ...args: any[]): any[];
}
export type SiteMessage = Omit<DownloaderItemProps, 'onCancel'> | undefined;
export type RouterMode = 'standard' | 'localhost';
export class RouterStore {
mode: RouterMode;
setMode(mode: RouterMode): void;
}
export class OfflineStore {
offline: boolean;
}
export class FlywheelStore {
// Global type FlywheelOwner
user: any;
authed: boolean;
setAuthenticationStatus(authed: boolean): void;
removeUser(): void;
refreshFlyAPI(): Promise<void>;
refreshFlyAPIThrottle(): any;
}
export interface SiteSettings extends Local.NewSiteInfo, Omit<Local.NewSiteDefaults, 'environment'> {}
export interface CreateSiteStep {
disabled?: boolean;
key: string,
path: string,
name?: string,
component?: React.ReactNode,
}
export interface CreateSiteRadioOption {
[path: string]: {
label: string;
content: JSX.Element;
}
}
export interface CreateSiteDefinition {
name: string;
option: {
label: string;
description: JSX.Element;
};
steps: CreateSiteStep[]
}
export class CreateSiteStore {
siteSettings: SiteSettings;
/**
* Defines the options and steps associated with creating sites.
* Initialized with site definitions that live in flywheel-local nested in the 'CreateSite' dir
*/
createSiteDefinitions: CreateSiteDefinition[];
/**
* Specifies the radio block option selected on the main CreateSite page
*
* Defaults to the "add-site" flow
*/
selectedCreateSiteFlow: string;
/**
* The selectedCreateSiteDefinition defines the next steps for a user in the CreateSite flow
*/
selectedCreateSiteDefinition: CreateSiteDefinition | undefined;
/**
* Build and filter the options for the CreateSite Radio Block
*/
createSiteRadioOptions: CreateSiteRadioOption;
/**
* Gives an array of steps with route fields associated with creating a site.
*
* Allows defaultSteps to be filtered via CreateSite:Steps filter
*/
createSiteSteps: CreateSiteStep[];
resetDefaults(): void;
updateSiteSettings(newSiteSettings: Partial<SiteSettings>): void;
updateCreateSiteDefinitions(updatedSiteDefinitions: CreateSiteDefinition[]): void;
updateSelectedCreateSiteFlow(flow: string): void;
}
export interface WPEUserInfo {
userId?: string
wpeEmail?: string
error?: string
}
export class WPEStore {
/**
* Observable WPE Authentication status
*/
authed: boolean;
/**
* Observable WPE Account ID
* Obtained from WPE CAPI client with valid username and password
*/
userId: string | undefined;
/**
* Class constructor
* Sets a listener for CAPI.AUTHED to update the authed observable
* Initializes the authed status on app lift
*
* @note the presence of an accountId means that a user/pass has authenticated with CAPI
*/
constructor();
/**
* Is there an Account ID set or available from the main thread?
* Set the authed status accordingly
*/
initAuthStatus(): Promise<void>;
/**
* @note It is possible an accountId is not provided
* in this case do not set any authed status as truthy
*
* @param {string} accountId
*/
setAuthenticationStatus(accountInfo?: WPEUserInfo): Promise<void>;
removeUser(): Promise<void>;
}
export class HubStore {
// Global type HubUser
user: any;
setUser(user: any): void;
hasValidSeat: boolean;
// Global type LocalSubscriptionSeat
hubSeat: any;
/**
* Log a user in
*/
login(): void;
/**
* Log a user out
*/
logout(): Promise<void>;
/**
* Helper to refresh Hub user access tokens from renderer process
*/
refreshHubAuth(): Promise<void>;
}
export enum BannerStoreDomain {
ALL = 'all',
SITEINFO = 'siteinfo',
BLUEPRINTS = 'blueprints',
MARKETPLACE = 'marketplace',
CONNECT = 'connect',
SELECTSITE = 'selectsite',
}
export interface IBanner {
id: string,
component: React.ReactNode | (() => JSX.Element),
domain?: BannerStoreDomain,
}
export class BannerStore {
banners: IBanner[];
addBanner(banner: IBanner): void;
removeBanner(bannerId: string): void;
}
type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export class RootStore {
static getInstance(
$mock: RecursivePartial<RootStore> | undefined,
$prewipe: boolean,
forceNewInstance: boolean,
): RootStore;
constructor(forceNewInstance: boolean);
hasValidSeat: boolean;
$router: RouterStore;
// Todo: the types for the Connect stores run deep, setting to any here for now
$connect: any;
$offline: OfflineStore;
$flywheel: FlywheelStore;
// Todo: the types for the Connect stores run deep, setting to any here for now
$magicSyncViewer: any;
// Todo: typing SitesStore would be quite an endeavor
$sites: any;
$createSite: CreateSiteStore;
$wpe: WPEStore;
$hub: HubStore;
$banner: BannerStore;
}
export interface AddonRendererContext {
environment: {
appPath: any;
userHome: any;
version: any;
userDataPath: any;
};
process: NodeJS.Process;
electron: typeof Electron;
fileSystem: any;
fileSystemJetpack: any;
notifier: {
notify: ({ title, message, open }: {
title?: string;
message?: string;
/** url to open via shell.openExternal */
open?: string;
}) => void;
};
React: typeof React;
ReactRouter: Partial<typeof ReactRouter>;
events: {
send: any;
};
storage: {
get?: (defaultValue?: any) => void;
set?: (value: any) => void;
};
store: RootStore
hooks: typeof HooksRenderer;
}
/** Mobx data stores */
export const $offline: {
/** offline observable toggled based on user internet connection */
offline: boolean,
};
export const $hub: {
/** Current logged in user */
user: HubUser;
/** Set new user in mobx store */
setUser: (user: HubUser | null) => void;
/** login user */
login: () => void;
/** logout of Local Account */
logout: () => void;
};
export interface ConfirmArgs {
title: ReactNodeLike
message?: ReactNodeLike
messageBottom?: ReactNodeLike
messageCheckbox?: ReactNodeLike
checkboxLabel?: string
buttonText?: string
buttonDisabled?: boolean
onSubmit?: (...any) => any
cancelButtonText: string
buttonClass: string
topIcon: any
topIconColor: any
largeConfirmButtonText: string
showBottomHr: boolean
}
/**
* Utility function to send an IPC event to the renderer thread and await either a success or error response and
* return it as a Promise.
*
* The channel will automatically be tokenized to ensure a response came from the expected request.
*
* @see LocalMain.addIpcAsyncListener()
*/
export function ipcAsync(channel: string, ...additionalArgs: any[]): Promise<any>;
/**
* Utility function to send an IPC event to the renderer.
*/
export function sendIPCEvent(channel: string, ...args: any[]): void;
export function confirm(args: ConfirmArgs): Promise<any>;
interface MenuContentRowItem {
/* The name of the row to render on the left hand side (left column) of the row */
name: string;
/* the component to render on the right hand side (right column) of the row */
component: FC;
}
export interface PreferencesSection {
/* The name to call the section. If this is omitted, a subheader will not be created */
subHeader?: string;
/* the single row item or list of row itmes to render in the section */
rows: MenuContentRowItem | MenuContentRowItem[];
}
/**
* Interface describing the expected shape for a config object that adds a new item to the
* settings view via the 'preferencesMenuItems' filter hook
*/
export interface AddonSettingsItem {
/* the sub path that the menu should be mounted under for React Router */
path: string;
/* the display name to show in the sidebar and title section of "Preferences" */
displayName: string;
/* The section, or sections to render */
sections: FC | PreferencesSection[];
/* the function to call on click of the apply button */
onApply: () => void;
/* additional props to pass to MenuContentRowItem(s) or the section override component */
sectionsProps?: GenericObject;
}
/**
* GraphQL
*/
export const localApolloClient: ApolloClient<NormalizedCacheObject>;
export function useLocalSitesSubs(
subscribeToMore: any
): void;
}