@@ -15,33 +15,45 @@ import { shouldAutoStart } from './BootCommon';
1515import { Blazor } from './GlobalExports' ;
1616import { WebStartOptions } from './Platform/WebStartOptions' ;
1717import { attachStreamingRenderingListener } from './Rendering/StreamingRendering' ;
18- import { attachProgressivelyEnhancedNavigationListener } from './Services/NavigationEnhancement' ;
18+ import { attachProgressivelyEnhancedNavigationListener , detachProgressivelyEnhancedNavigationListener } from './Services/NavigationEnhancement' ;
1919import { WebAssemblyComponentDescriptor } from './Services/ComponentDescriptorDiscovery' ;
2020import { ServerComponentDescriptor , discoverComponents } from './Services/ComponentDescriptorDiscovery' ;
2121
2222let started = false ;
23+ let webStartOptions : Partial < WebStartOptions > | undefined ;
2324
2425async function boot ( options ?: Partial < WebStartOptions > ) : Promise < void > {
2526 if ( started ) {
2627 throw new Error ( 'Blazor has already started.' ) ;
2728 }
2829 started = true ;
29- await activateInteractiveComponents ( options ) ;
30+ webStartOptions = options ;
3031
3132 attachStreamingRenderingListener ( options ?. ssr ) ;
32- attachProgressivelyEnhancedNavigationListener ( ) ;
33+ attachProgressivelyEnhancedNavigationListener ( activateInteractiveComponents ) ;
34+ await activateInteractiveComponents ( ) ;
3335}
3436
35- async function activateInteractiveComponents ( options ?: Partial < WebStartOptions > ) {
37+ async function activateInteractiveComponents ( ) {
3638 const serverComponents = discoverComponents ( document , 'server' ) as ServerComponentDescriptor [ ] ;
3739 const webAssemblyComponents = discoverComponents ( document , 'webassembly' ) as WebAssemblyComponentDescriptor [ ] ;
3840
3941 if ( serverComponents . length ) {
40- await startCircuit ( options ?. circuit , serverComponents ) ;
42+ // TEMPORARY until https://github.com/dotnet/aspnetcore/issues/48763 is implemented
43+ // As soon we we see you have interactive components, we'll stop doing enhanced nav even if you don't have an interactive router
44+ // This is because, otherwise, we would need a way to add new interactive root components to an existing circuit and that's #48763
45+ detachProgressivelyEnhancedNavigationListener ( ) ;
46+
47+ await startCircuit ( webStartOptions ?. circuit , serverComponents ) ;
4148 }
4249
4350 if ( webAssemblyComponents . length ) {
44- await startWebAssembly ( options ?. webAssembly , webAssemblyComponents ) ;
51+ // TEMPORARY until https://github.com/dotnet/aspnetcore/issues/48763 is implemented
52+ // As soon we we see you have interactive components, we'll stop doing enhanced nav even if you don't have an interactive router
53+ // This is because, otherwise, we would need a way to add new interactive root components to an existing WebAssembly runtime and that's #48763
54+ detachProgressivelyEnhancedNavigationListener ( ) ;
55+
56+ await startWebAssembly ( webStartOptions ?. webAssembly , webAssemblyComponents ) ;
4557 }
4658}
4759
0 commit comments