// Internal for testing. internal async Task RunAsyncCore(CancellationToken cancellationToken, WebAssemblyCultureProvider?cultureProvider = null) { if (_started) { throw new InvalidOperationException("The host has already started."); } _started = true; cultureProvider ??= WebAssemblyCultureProvider.Instance !; cultureProvider.ThrowIfCultureChangeIsUnsupported(); // Application developers might have configured the culture based on some ambient state // such as local storage, url etc as part of their Program.Main(Async). // This is the earliest opportunity to fetch satellite assemblies for this selection. await cultureProvider.LoadCurrentCultureResourcesAsync(); var manager = Services.GetRequiredService <ComponentStatePersistenceManager>(); var store = !string.IsNullOrEmpty(_persistedState) ? new PrerenderComponentApplicationStore(_persistedState) : new PrerenderComponentApplicationStore(); await manager.RestoreStateAsync(store); if (MetadataUpdater.IsSupported) { await WebAssemblyHotReload.InitializeAsync(); } var tcs = new TaskCompletionSource(); using (cancellationToken.Register(() => tcs.TrySetResult())) { var loggerFactory = Services.GetRequiredService <ILoggerFactory>(); var jsComponentInterop = new JSComponentInterop(_rootComponents.JSComponents); _renderer = new WebAssemblyRenderer(Services, loggerFactory, jsComponentInterop); WebAssemblyNavigationManager.Instance.CreateLogger(loggerFactory); var initializationTcs = new TaskCompletionSource(); WebAssemblyCallQueue.Schedule((_rootComponents, _renderer, initializationTcs), static async state =>
private Task?InitializeHotReloadAsync() { // In Development scenarios, wait for hot reload to apply deltas before initiating rendering. return(WebAssemblyHotReload.InitializeAsync()); }