Skip to content

Commit 5a1040d

Browse files
committed
Read the environment in blazor.web
1 parent 6284b44 commit 5a1040d

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/Components/Web.JS/src/Services/ComponentDescriptorDiscovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ type ServerComponentMarker = {
355355

356356
type WebAssemblyComponentMarker = {
357357
type: 'webassembly';
358-
environment: string | undefined;
359358
} & WebAssemblyMarkerData;
360359

361360
type AutoComponentMarker = {
@@ -383,4 +382,5 @@ type WebAssemblyMarkerData = {
383382
assembly: string;
384383
parameterDefinitions: string;
385384
parameterValues: string;
385+
environment: string | undefined;
386386
} & CommonMarkerData;

src/Components/Web.JS/src/Services/WebRootComponentManager.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ export class WebRootComponentManager implements DescriptorHandler, RootComponent
105105
// may take a long time to load, so starting to load them now potentially reduces
106106
// the time to interactvity.
107107
if (descriptor.type === 'webassembly') {
108-
this.startLoadingWebAssemblyIfNotStarted();
108+
this.startLoadingWebAssemblyIfNotStarted(descriptor.environment);
109109
} else if (descriptor.type === 'auto') {
110110
// If the WebAssembly runtime starts downloading because an Auto component was added to
111111
// the page, we limit the maximum number of parallel WebAssembly resource downloads to 1
112112
// so that the performance of any Blazor Server circuit is minimally impacted.
113-
this.startLoadingWebAssemblyIfNotStarted(/* maxParallelDownloadsOverride */ 1);
113+
this.startLoadingWebAssemblyIfNotStarted(descriptor.environment, /* maxParallelDownloadsOverride */ 1);
114114
}
115115

116116
const ssrComponentId = this._nextSsrComponentId++;
@@ -125,15 +125,14 @@ export class WebRootComponentManager implements DescriptorHandler, RootComponent
125125
this.circuitMayHaveNoRootComponents();
126126
}
127127

128-
private async startLoadingWebAssemblyIfNotStarted(maxParallelDownloadsOverride?: number) {
128+
private async startLoadingWebAssemblyIfNotStarted(environment: string | undefined, maxParallelDownloadsOverride?: number) {
129129
if (hasStartedLoadingWebAssemblyPlatform()) {
130130
return;
131131
}
132132

133133
setWaitForRootComponents();
134134

135-
// MF TODO: Pass the environment
136-
const loadWebAssemblyPromise = loadWebAssemblyPlatformIfNotStarted(undefined);
135+
const loadWebAssemblyPromise = loadWebAssemblyPlatformIfNotStarted(environment);
137136
const bootConfig = await waitForBootConfigLoaded();
138137

139138
if (maxParallelDownloadsOverride !== undefined) {
@@ -179,12 +178,11 @@ export class WebRootComponentManager implements DescriptorHandler, RootComponent
179178
}
180179
}
181180

182-
private async startWebAssemblyIfNotStarted() {
183-
this.startLoadingWebAssemblyIfNotStarted();
181+
private async startWebAssemblyIfNotStarted(environment?: string) {
182+
this.startLoadingWebAssemblyIfNotStarted(environment);
184183

185184
if (!hasStartedWebAssembly()) {
186-
// MF TODO: Pass the environment
187-
await startWebAssembly(this, undefined);
185+
await startWebAssembly(this, environment);
188186
}
189187
}
190188

src/Shared/Components/ComponentMarker.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,19 @@ internal struct ComponentMarker
5757
// Serialized values of the component's parameters.
5858
public string? ParameterValues { get; set; }
5959

60+
// The WebHost Environment
61+
public string? Environment { get; set; }
62+
6063
#endregion
6164

62-
public static ComponentMarker Create(string type, bool prerendered, ComponentMarkerKey? key)
65+
public static ComponentMarker Create(string type, bool prerendered, ComponentMarkerKey? key, string? environment = null)
6366
{
6467
return new()
6568
{
6669
Type = type,
6770
PrerenderId = prerendered ? GeneratePrerenderId() : null,
6871
Key = key,
72+
Environment = environment
6973
};
7074
}
7175

0 commit comments

Comments
 (0)