@@ -15,33 +15,45 @@ import { shouldAutoStart } from './BootCommon';
15
15
import { Blazor } from './GlobalExports' ;
16
16
import { WebStartOptions } from './Platform/WebStartOptions' ;
17
17
import { attachStreamingRenderingListener } from './Rendering/StreamingRendering' ;
18
- import { attachProgressivelyEnhancedNavigationListener } from './Services/NavigationEnhancement' ;
18
+ import { attachProgressivelyEnhancedNavigationListener , detachProgressivelyEnhancedNavigationListener } from './Services/NavigationEnhancement' ;
19
19
import { WebAssemblyComponentDescriptor } from './Services/ComponentDescriptorDiscovery' ;
20
20
import { ServerComponentDescriptor , discoverComponents } from './Services/ComponentDescriptorDiscovery' ;
21
21
22
22
let started = false ;
23
+ let webStartOptions : Partial < WebStartOptions > | undefined ;
23
24
24
25
async function boot ( options ?: Partial < WebStartOptions > ) : Promise < void > {
25
26
if ( started ) {
26
27
throw new Error ( 'Blazor has already started.' ) ;
27
28
}
28
29
started = true ;
29
- await activateInteractiveComponents ( options ) ;
30
+ webStartOptions = options ;
30
31
31
32
attachStreamingRenderingListener ( options ?. ssr ) ;
32
- attachProgressivelyEnhancedNavigationListener ( ) ;
33
+ attachProgressivelyEnhancedNavigationListener ( activateInteractiveComponents ) ;
34
+ await activateInteractiveComponents ( ) ;
33
35
}
34
36
35
- async function activateInteractiveComponents ( options ?: Partial < WebStartOptions > ) {
37
+ async function activateInteractiveComponents ( ) {
36
38
const serverComponents = discoverComponents ( document , 'server' ) as ServerComponentDescriptor [ ] ;
37
39
const webAssemblyComponents = discoverComponents ( document , 'webassembly' ) as WebAssemblyComponentDescriptor [ ] ;
38
40
39
41
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 ) ;
41
48
}
42
49
43
50
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 ) ;
45
57
}
46
58
}
47
59
0 commit comments