1
1
import _ from 'lodash' ;
2
+ import { ParserFn } from '../providers/parser.provider' ;
2
3
import { HandshakeResponse } from '../models/HandshakeBody' ;
3
4
import { clearCache } from '../providers/dataDonation.provider' ;
4
5
import { FIXED_USER_NAME , initializeKey } from './background/account' ;
@@ -16,6 +17,7 @@ import log from './logger';
16
17
import HubEvent from './models/HubEvent' ;
17
18
import { ServerLookup } from './models/Message' ;
18
19
import UserSettings from './models/UserSettings' ;
20
+ import { renderUI , RenderUIProps } from './ui' ;
19
21
import { bo } from './utils/browser.utils' ;
20
22
21
23
// instantiate a proper logger
@@ -67,7 +69,12 @@ interface SetupObserverOpts {
67
69
onLocationChange : ( oldLocation : string , newLocation : string ) => void ;
68
70
}
69
71
70
- export interface BootOpts {
72
+ export interface BootOpts <
73
+ S = any ,
74
+ M = any ,
75
+ C = any ,
76
+ PP extends Record < string , ParserFn < S , any , C > > = any
77
+ > {
71
78
payload : ServerLookup [ 'payload' ] ;
72
79
mapLocalConfig : (
73
80
c : UserSettings ,
@@ -79,6 +86,7 @@ export interface BootOpts {
79
86
onRegister : ( h : Hub < HubEvent > , config : UserSettings ) => void ;
80
87
} ;
81
88
onAuthenticated : ( res : any ) => void ;
89
+ ui ?: Omit < RenderUIProps < S , M , C , PP > , 'hub' > ;
82
90
}
83
91
84
92
/**
@@ -227,7 +235,12 @@ const serverHandshakeP = (
227
235
228
236
let loading = false ;
229
237
let app : App | undefined ;
230
- export async function boot ( opts : BootOpts ) : Promise < App > {
238
+ export async function boot <
239
+ S = any ,
240
+ M = any ,
241
+ C = any ,
242
+ PP extends Record < string , ParserFn < S , any , C > > = any
243
+ > ( opts : BootOpts < S , M , C , PP > ) : Promise < App > {
231
244
if ( app ) {
232
245
appLog . debug ( 'App already booted!' ) ;
233
246
return app ;
@@ -316,12 +329,12 @@ export async function boot(opts: BootOpts): Promise<App> {
316
329
// register platform specific event handlers
317
330
opts . hub . onRegister ( opts . hub . hub , config ) ;
318
331
319
- // emergency button should be used when a supported with
320
- // UX hack in place didn't see any UX change, so they
321
- // can report the problem and we can handle it.
322
- // initializeEmergencyButton();
332
+ // render shared ui if configuration is given
333
+ if ( opts . ui ) {
334
+ renderUI ( { hub : opts . hub . hub , ... opts . ui } ) ;
335
+ }
323
336
324
- // because the URL has been for sure reloaded, be sure to also
337
+ // because the URL has been for sure reloaded, be sure to also clear cache
325
338
clearCache ( ) ;
326
339
327
340
// send the configuration to the server to register the extension
0 commit comments