export async function fetchBootConfigAsync ( ) { const bootConfigResponse = await fetch ( '_framework/blazor.boot.json' , { method : 'Get' , credentials : 'include' } ) ; return bootConfigResponse . json ( ) as Promise < BootJsonData > ; } export function loadEmbeddedResourcesAsync ( bootConfig ) { const cssLoadingPromises = bootConfig . cssReferences . map ( cssReference => { const linkElement = document . createElement ( 'link' ) ; linkElement . rel = 'stylesheet' ; linkElement . href = cssReference ; return loadResourceFromElement ( linkElement ) ; } ) ; const jsLoadingPromises = bootConfig . jsReferences . map ( jsReference => { const scriptElement = document . createElement ( 'script' ) ; scriptElement . src = jsReference ; return loadResourceFromElement ( scriptElement ) ; } ) ; return Promise . all ( cssLoadingPromises . concat ( jsLoadingPromises ) ) ; } function loadResourceFromElement ( element ) { return new Promise ( ( resolve , reject ) => { element . onload = resolve ; element . onerror = reject ; document . head ! . appendChild ( element ) ; } ) ; } interface BootJsonData { main : string ; entryPoint : string ; assemblyReferences : string [ ] ; cssReferences : string [ ] ; jsReferences : string [ ] ; linkerEnabled : boolean ; } export function shouldAutoStart ( ) { return ! ! ( document && document . currentScript && document . currentScript . getAttribute ( 'autostart' ) !== 'false' ) ; }