import '@dotnet/jsinterop' ; import './GlobalExports' ; import * as Environment from './Environment' ; import { monoPlatform } from './Platform/Mono/MonoPlatform' ; import { getAssemblyNameFromUrl } from './Platform/Url' ; import { renderBatch } from './Rendering/Renderer' ; import { SharedMemoryRenderBatch } from './Rendering/RenderBatch/SharedMemoryRenderBatch' ; import { Pointer } from './Platform/Platform' ; import { fetchBootConfigAsync , loadEmbeddedResourcesAsync , shouldAutoStart } from './BootCommon' ; import { setEventDispatcher } from './Rendering/RendererEventDispatcher' ; let started = false ; async function boot ( options ? ) { if ( started ) { throw new Error ( 'Blazor has already started.' ) ; } started = true ; setEventDispatcher ( ( eventDescriptor , eventArgs ) => DotNet . invokeMethodAsync ( 'Microsoft.AspNetCore.Blazor' , 'DispatchEvent' , eventDescriptor , JSON . stringify ( eventArgs ) ) ) ; const platform = Environment . setPlatform ( monoPlatform ) ; window [ 'Blazor' ] . platform = platform ; window [ 'Blazor' ] . _internal . renderBatch = ( browserRendererId , batchAddress ) => { renderBatch ( browserRendererId , new SharedMemoryRenderBatch ( batchAddress ) ) ; } ; window [ 'Blazor' ] . _internal . navigationManager . listenForNavigationEvents ( async ( uri , intercepted ) : Promise < void > => { await DotNet . invokeMethodAsync ( 'Microsoft.AspNetCore.Blazor' , 'NotifyLocationChanged' , uri , intercepted ) ; } ) ; const bootConfig = await fetchBootConfigAsync ( ) ; const embeddedResourcesPromise = loadEmbeddedResourcesAsync ( bootConfig ) ; if ( ! bootConfig . linkerEnabled ) { console . info ( 'Blazor is running in dev mode without IL stripping. To make the bundle size significantly smaller, publish the application or see https://go.microsoft.com/fwlink/?linkid=870414' ) ; } const loadAssemblyUrls = [ bootConfig . main ] . concat ( bootConfig . assemblyReferences ) . map ( filename => `_framework/_bin/${ filename }` ) ; try { await platform . start ( loadAssemblyUrls ) ; } catch ( ex ) { throw new Error ( `Failed to start platform. Reason: ${ ex }` ) ; } await embeddedResourcesPromise ; const mainAssemblyName = getAssemblyNameFromUrl ( bootConfig . main ) ; platform . callEntryPoint ( mainAssemblyName , bootConfig . entryPoint , [ ] ) ; } window [ 'Blazor' ] . start = boot ; if ( shouldAutoStart ( ) ) { boot ( ) ; }