Skip to content

Commit 39564d5

Browse files
authored
[blazor] Read appsettings loaded by the runtime into the VFS (#48326)
1 parent 426b8b4 commit 39564d5

File tree

6 files changed

+5
-59
lines changed

6 files changed

+5
-59
lines changed

src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { WebAssemblyComponentDescriptor, discoverComponents, discoverPersistedSt
1717
import { attachRootComponentToElement, attachRootComponentToLogicalElement } from '../../Rendering/Renderer';
1818
import { WebAssemblyComponentAttacher } from '../WebAssemblyComponentAttacher';
1919
import { fetchAndInvokeInitializers } from '../../JSInitializers/JSInitializers.WebAssembly';
20-
import { WebAssemblyConfigLoader } from '../WebAssemblyConfigLoader';
2120

2221
// initially undefined and only fully initialized after createEmscriptenModuleInstance()
2322
export let BINDING: BINDINGType = undefined as any;
@@ -280,9 +279,9 @@ function prepareRuntimeConfig(options: Partial<WebAssemblyStartOptions>, platfor
280279
}
281280
};
282281

283-
platformApi.jsInitializer = await fetchAndInvokeInitializers(bootConfig, options);
282+
Blazor._internal.getApplicationEnvironment = () => bootConfig.applicationEnvironment!;
284283

285-
WebAssemblyConfigLoader.initAsync(bootConfig, bootConfig.applicationEnvironment!, options || {});
284+
platformApi.jsInitializer = await fetchAndInvokeInitializers(bootConfig, options);
286285
};
287286

288287

src/Components/Web.JS/src/Platform/WebAssemblyConfigLoader.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyHostBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ private WebAssemblyHostEnvironment InitializeEnvironment(IInternalJSImportMethod
159159

160160
foreach (var configFile in configFiles)
161161
{
162-
var appSettingsJson = jsMethods.GetConfig(configFile);
163-
if (appSettingsJson != null)
162+
if (File.Exists(configFile))
164163
{
164+
var appSettingsJson = File.ReadAllBytes(configFile);
165+
165166
// Perf: Using this over AddJsonStream. This allows the linker to trim out the "File"-specific APIs and assemblies
166167
// for Configuration, of where there are several.
167168
Configuration.Add<JsonStreamConfigurationSource>(s => s.Stream = new MemoryStream(appSettingsJson));

src/Components/WebAssembly/WebAssembly/src/Services/IInternalJSImportMethods.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ internal interface IInternalJSImportMethods
99

1010
string GetApplicationEnvironment();
1111

12-
byte[]? GetConfig(string configFile);
13-
1412
void NavigationManager_EnableNavigationInterception();
1513

1614
void NavigationManager_ScrollToElement(string id);

src/Components/WebAssembly/WebAssembly/src/Services/InternalJSImportMethods.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public string GetPersistedState()
1919
public string GetApplicationEnvironment()
2020
=> GetApplicationEnvironmentCore();
2121

22-
public byte[]? GetConfig(string configFile)
23-
=> GetConfigCore(configFile);
24-
2522
public void NavigationManager_EnableNavigationInterception()
2623
=> NavigationManager_EnableNavigationInterceptionCore();
2724

@@ -61,9 +58,6 @@ public string RegisteredComponents_GetParameterValues(int id)
6158
[JSImport("Blazor._internal.getApplicationEnvironment", "blazor-internal")]
6259
private static partial string GetApplicationEnvironmentCore();
6360

64-
[JSImport("Blazor._internal.getConfig", "blazor-internal")]
65-
private static partial byte[] GetConfigCore(string configFile);
66-
6761
[JSImport(BrowserNavigationManagerInterop.EnableNavigationInterception, "blazor-internal")]
6862
private static partial void NavigationManager_EnableNavigationInterceptionCore();
6963

src/Components/WebAssembly/WebAssembly/test/TestInternalJSImportMethods.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public TestInternalJSImportMethods(string environment = "Production")
1717
public string GetApplicationEnvironment()
1818
=> _environment;
1919

20-
public byte[] GetConfig(string configFile)
21-
=> null;
22-
2320
public string GetPersistedState()
2421
=> null;
2522

0 commit comments

Comments
 (0)