11import _ from 'lodash' ;
2+ import { ParserConfiguration , ParserFn } from '../providers/parser.provider' ;
23import { HandshakeResponse } from '../models/HandshakeBody' ;
34import { clearCache } from '../providers/dataDonation.provider' ;
45import { FIXED_USER_NAME , initializeKey } from './background/account' ;
@@ -16,6 +17,7 @@ import log from './logger';
1617import HubEvent from './models/HubEvent' ;
1718import { ServerLookup } from './models/Message' ;
1819import UserSettings from './models/UserSettings' ;
20+ import { renderUI , RenderUIProps } from './ui' ;
1921import { bo } from './utils/browser.utils' ;
2022
2123// instantiate a proper logger
@@ -67,7 +69,12 @@ interface SetupObserverOpts {
6769 onLocationChange : ( oldLocation : string , newLocation : string ) => void ;
6870}
6971
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+ > {
7178 payload : ServerLookup [ 'payload' ] ;
7279 mapLocalConfig : (
7380 c : UserSettings ,
@@ -79,6 +86,7 @@ export interface BootOpts {
7986 onRegister : ( h : Hub < HubEvent > , config : UserSettings ) => void ;
8087 } ;
8188 onAuthenticated : ( res : any ) => void ;
89+ ui ?: Omit < RenderUIProps < S , M , C , PP > , 'hub' > ;
8290}
8391
8492/**
@@ -232,7 +240,12 @@ const serverHandshakeP = (
232240
233241let loading = false ;
234242let 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 > {
236249 if ( app ) {
237250 appLog . debug ( 'App already booted!' ) ;
238251 return app ;
@@ -321,12 +334,12 @@ export async function boot(opts: BootOpts): Promise<App> {
321334 // register platform specific event handlers
322335 opts . hub . onRegister ( opts . hub . hub , config ) ;
323336
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+ }
328341
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
330343 clearCache ( ) ;
331344
332345 // send the configuration to the server to register the extension
0 commit comments