1
1
import _ from 'lodash' ;
2
+ import { ParserConfiguration , 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 extends ParserConfiguration = ParserConfiguration ,
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
/**
@@ -232,7 +240,12 @@ const serverHandshakeP = (
232
240
233
241
let loading = false ;
234
242
let app : App | undefined ;
235
- export async function boot ( opts : BootOpts ) : Promise < App > {
243
+ export async function boot <
244
+ S = any ,
245
+ M = any ,
246
+ C extends ParserConfiguration = ParserConfiguration ,
247
+ PP extends Record < string , ParserFn < S , any , C > > = any
248
+ > ( opts : BootOpts < S , M , C , PP > ) : Promise < App > {
236
249
if ( app ) {
237
250
appLog . debug ( 'App already booted!' ) ;
238
251
return app ;
@@ -321,12 +334,12 @@ export async function boot(opts: BootOpts): Promise<App> {
321
334
// register platform specific event handlers
322
335
opts . hub . onRegister ( opts . hub . hub , config ) ;
323
336
324
- // emergency button should be used when a supported with
325
- // UX hack in place didn't see any UX change, so they
326
- // can report the problem and we can handle it.
327
- // initializeEmergencyButton();
337
+ // render shared ui if configuration is given
338
+ if ( opts . ui ) {
339
+ renderUI ( { hub : opts . hub . hub , ... opts . ui } ) ;
340
+ }
328
341
329
- // because the URL has been for sure reloaded, be sure to also
342
+ // because the URL has been for sure reloaded, be sure to also clear cache
330
343
clearCache ( ) ;
331
344
332
345
// send the configuration to the server to register the extension
0 commit comments