Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Extensions.Logging;

namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Options that flow from the server to the Blazor client in the browser
/// via a DOM comment. Only serializable options are included; callbacks stay
/// with JS initializers.
/// </summary>
public sealed class BrowserOptions
{
/// <summary>
/// Gets or sets the log level for the Blazor JS runtime. Applies to all render modes.
/// Maps to <c>WebStartOptions.logLevel</c>.
/// </summary>
public LogLevel? LogLevel { get; set; }

/// <summary>Gets the WebAssembly-specific options.</summary>
public WebAssemblyBrowserOptions WebAssembly { get; } = new();

/// <summary>Gets the interactive server (circuit) specific options.</summary>
public InteractiveServerBrowserOptions Server { get; } = new();

/// <summary>Gets the SSR-specific options.</summary>
public SsrBrowserOptions Ssr { get; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Serializable subset of <c>CircuitStartOptions</c>.
/// Serializable subset of <c>CircuitStartOptions</c> for the interactive server render mode.
/// Non-serializable options (<c>configureSignalR</c>, <c>reconnectionHandler</c>,
/// <c>circuitHandlers</c>) must use <c>Blazor.start()</c> or JS initializers.
/// </summary>
public sealed class ServerBrowserOptions
public sealed class InteractiveServerBrowserOptions
{
/// <summary>
/// Maximum reconnection attempts before giving up.
/// Gets or sets the maximum reconnection attempts before giving up.
/// Maps to <c>CircuitStartOptions.reconnectionOptions.maxRetries</c>.
/// </summary>
public int? ReconnectionMaxRetries { get; set; }

/// <summary>
/// Base interval in milliseconds between reconnection attempts (scalar form).
/// Gets or sets the base interval between reconnection attempts (scalar form).
/// The function form <c>(retryCount, currentMs) => number</c> requires JS.
/// Maps to <c>CircuitStartOptions.reconnectionOptions.retryIntervalMilliseconds</c>.
/// </summary>
public int? ReconnectionRetryIntervalMilliseconds { get; set; }
public TimeSpan? ReconnectionRetryInterval { get; set; }

/// <summary>
/// CSS ID of the reconnection dialog element.
/// Gets or sets the CSS ID of the reconnection dialog element.
/// Maps to <c>CircuitStartOptions.reconnectionOptions.dialogId</c>.
/// </summary>
public string? ReconnectionDialogId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ namespace Microsoft.AspNetCore.Components;
public sealed class SsrBrowserOptions
{
/// <summary>
/// When true, disables DOM preservation during enhanced navigation.
/// Gets or sets a value indicating whether the DOM is preserved during enhanced navigation.
/// When <see langword="false"/>, DOM preservation is disabled. <see langword="null"/> leaves the value unset.
/// Maps to <c>SsrStartOptions.disableDomPreservation</c>.
/// </summary>
public bool? DisableDomPreservation { get; set; }
public bool? PreserveDom { get; set; }

/// <summary>
/// Timeout in milliseconds before an inactive circuit is disposed.
/// Gets or sets the timeout before an inactive circuit is disposed.
/// Maps to <c>SsrStartOptions.circuitInactivityTimeoutMs</c>.
/// </summary>
public int? CircuitInactivityTimeoutMs { get; set; }
public TimeSpan? CircuitInactivityTimeout { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ namespace Microsoft.AspNetCore.Components;
public sealed class WebAssemblyBrowserOptions
{
/// <summary>
/// Hosting environment name (e.g., "Development", "Production").
/// Gets or sets the hosting environment name (e.g., "Development", "Production").
/// Maps to <c>WebAssemblyStartOptions.environment</c>.
/// </summary>
public string? EnvironmentName { get; set; }

/// <summary>
/// Application culture in BCP 47 format (e.g., "en-US").
/// Gets or sets the application culture in BCP 47 format (e.g., "en-US").
/// Maps to <c>WebAssemblyStartOptions.applicationCulture</c>.
/// </summary>
public string? ApplicationCulture { get; set; }

/// <summary>
/// Environment variables for the .NET WebAssembly runtime.
/// Gets the environment variables for the .NET WebAssembly runtime.
/// Use for OTEL endpoints, service URLs, etc.
/// </summary>
public Dictionary<string, string> EnvironmentVariables { get; set; } = new();
public IDictionary<string, string> EnvironmentVariables { get; } = new Dictionary<string, string>();
}
44 changes: 20 additions & 24 deletions src/Components/Components/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,31 @@ Microsoft.AspNetCore.Components.IComponentPropertyActivator.GetActivator(System.
*REMOVED*Microsoft.AspNetCore.Components.Routing.Router.PreferExactMatches.get -> bool
*REMOVED*Microsoft.AspNetCore.Components.Routing.Router.PreferExactMatches.set -> void
static Microsoft.Extensions.DependencyInjection.CascadingValueServiceCollectionExtensions.TryAddCascadingValueSupplier<TAttribute>(this Microsoft.Extensions.DependencyInjection.IServiceCollection! serviceCollection, System.Func<System.IServiceProvider!, System.Func<Microsoft.AspNetCore.Components.Rendering.ComponentState!, TAttribute!, Microsoft.AspNetCore.Components.CascadingParameterInfo, Microsoft.AspNetCore.Components.CascadingParameterSubscription!>!>! subscribeFactory) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
Microsoft.AspNetCore.Components.BrowserConfiguration
Microsoft.AspNetCore.Components.BrowserConfiguration.BrowserConfiguration() -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.LogLevel.get -> int?
Microsoft.AspNetCore.Components.BrowserConfiguration.LogLevel.set -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.Server.get -> Microsoft.AspNetCore.Components.ServerBrowserOptions!
Microsoft.AspNetCore.Components.BrowserConfiguration.Server.set -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.Ssr.get -> Microsoft.AspNetCore.Components.SsrBrowserOptions!
Microsoft.AspNetCore.Components.BrowserConfiguration.Ssr.set -> void
Microsoft.AspNetCore.Components.BrowserConfiguration.WebAssembly.get -> Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions!
Microsoft.AspNetCore.Components.BrowserConfiguration.WebAssembly.set -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions
Microsoft.AspNetCore.Components.ServerBrowserOptions.ServerBrowserOptions() -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionDialogId.get -> string?
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionDialogId.set -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionMaxRetries.get -> int?
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionMaxRetries.set -> void
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionRetryIntervalMilliseconds.get -> int?
Microsoft.AspNetCore.Components.ServerBrowserOptions.ReconnectionRetryIntervalMilliseconds.set -> void
Microsoft.AspNetCore.Components.BrowserOptions
Microsoft.AspNetCore.Components.BrowserOptions.BrowserOptions() -> void
Microsoft.AspNetCore.Components.BrowserOptions.LogLevel.get -> Microsoft.Extensions.Logging.LogLevel?
Microsoft.AspNetCore.Components.BrowserOptions.LogLevel.set -> void
Microsoft.AspNetCore.Components.BrowserOptions.Server.get -> Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions!
Microsoft.AspNetCore.Components.BrowserOptions.Ssr.get -> Microsoft.AspNetCore.Components.SsrBrowserOptions!
Microsoft.AspNetCore.Components.BrowserOptions.WebAssembly.get -> Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions!
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions.InteractiveServerBrowserOptions() -> void
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions.ReconnectionDialogId.get -> string?
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions.ReconnectionDialogId.set -> void
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions.ReconnectionMaxRetries.get -> int?
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions.ReconnectionMaxRetries.set -> void
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions.ReconnectionRetryInterval.get -> System.TimeSpan?
Microsoft.AspNetCore.Components.InteractiveServerBrowserOptions.ReconnectionRetryInterval.set -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions
Microsoft.AspNetCore.Components.SsrBrowserOptions.SsrBrowserOptions() -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions.CircuitInactivityTimeoutMs.get -> int?
Microsoft.AspNetCore.Components.SsrBrowserOptions.CircuitInactivityTimeoutMs.set -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions.DisableDomPreservation.get -> bool?
Microsoft.AspNetCore.Components.SsrBrowserOptions.DisableDomPreservation.set -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions.CircuitInactivityTimeout.get -> System.TimeSpan?
Microsoft.AspNetCore.Components.SsrBrowserOptions.CircuitInactivityTimeout.set -> void
Microsoft.AspNetCore.Components.SsrBrowserOptions.PreserveDom.get -> bool?
Microsoft.AspNetCore.Components.SsrBrowserOptions.PreserveDom.set -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.WebAssemblyBrowserOptions() -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.ApplicationCulture.get -> string?
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.ApplicationCulture.set -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentName.get -> string?
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentName.set -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentVariables.get -> System.Collections.Generic.Dictionary<string!, string!>!
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentVariables.set -> void
Microsoft.AspNetCore.Components.WebAssemblyBrowserOptions.EnvironmentVariables.get -> System.Collections.Generic.IDictionary<string!, string!>!
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Http;

namespace Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Extension methods on <see cref="HttpContext"/> for accessing <see cref="BrowserConfiguration"/>.
/// Extension methods on <see cref="HttpContext"/> for accessing <see cref="BrowserOptions"/>.
/// </summary>
public static class BrowserConfigurationHttpContextExtensions
public static class BrowserOptionsHttpContextExtensions
{
private static readonly object Key = new();

/// <summary>
/// Gets the <see cref="BrowserConfiguration"/> for the current request.
/// Gets the <see cref="BrowserOptions"/> for the current request.
/// If not already set, seeds from endpoint metadata or creates a new instance.
/// </summary>
/// <param name="context">The <see cref="HttpContext"/>.</param>
/// <returns>The <see cref="BrowserConfiguration"/> for the current request.</returns>
public static BrowserConfiguration GetBrowserConfiguration(this HttpContext context)
/// <returns>The <see cref="BrowserOptions"/> for the current request.</returns>
public static BrowserOptions GetBrowserOptions(this HttpContext context)
{
ArgumentNullException.ThrowIfNull(context);

if (!context.Items.TryGetValue(Key, out var result))
{
// Seed from endpoint metadata if available
var metadataConfig = context.GetEndpoint()?.Metadata.GetMetadata<BrowserConfiguration>();
var config = metadataConfig ?? new BrowserConfiguration();
var metadataConfig = context.GetEndpoint()?.Metadata.GetMetadata<BrowserOptions>();
var config = metadataConfig ?? new BrowserOptions();
context.Items[Key] = config;
return config;
}

return (BrowserConfiguration)result!;
return (BrowserOptions)result!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ namespace Microsoft.AspNetCore.Components;

/// <summary>
/// A component that configures the Blazor browser runtime by merging
/// configuration into the <see cref="BrowserConfiguration"/> on the current
/// <see cref="HttpContext"/>. The merged configuration is emitted as
/// options into the <see cref="BrowserOptions"/> on the current
/// <see cref="HttpContext"/>. The merged options are emitted as
/// a <c>&lt;!--Blazor-Configuration:{...}--&gt;</c> DOM comment by the renderer.
/// </summary>
public sealed class ConfigureBrowser : IComponent
{
private RenderHandle _renderHandle;

/// <summary>
/// Gets or sets the <see cref="BrowserConfiguration"/> to merge.
/// Gets or sets the <see cref="BrowserOptions"/> to merge.
/// </summary>
[Parameter, EditorRequired]
public BrowserConfiguration Configuration { get; set; } = default!;
public BrowserOptions Options { get; set; } = default!;

/// <summary>
/// Gets or sets the <see cref="HttpContext"/> for the current request.
Expand All @@ -38,14 +38,14 @@ Task IComponent.SetParametersAsync(ParameterView parameters)

if (HttpContext is not null)
{
var existing = HttpContext.GetBrowserConfiguration();
MergeInto(existing, Configuration);
var existing = HttpContext.GetBrowserOptions();
MergeInto(existing, Options);
}

return Task.CompletedTask;
}

internal static void MergeInto(BrowserConfiguration target, BrowserConfiguration source)
internal static void MergeInto(BrowserOptions target, BrowserOptions source)
{
target.LogLevel = source.LogLevel ?? target.LogLevel;

Expand All @@ -59,11 +59,11 @@ internal static void MergeInto(BrowserConfiguration target, BrowserConfiguration

// Server
target.Server.ReconnectionMaxRetries = source.Server.ReconnectionMaxRetries ?? target.Server.ReconnectionMaxRetries;
target.Server.ReconnectionRetryIntervalMilliseconds = source.Server.ReconnectionRetryIntervalMilliseconds ?? target.Server.ReconnectionRetryIntervalMilliseconds;
target.Server.ReconnectionRetryInterval = source.Server.ReconnectionRetryInterval ?? target.Server.ReconnectionRetryInterval;
target.Server.ReconnectionDialogId = source.Server.ReconnectionDialogId ?? target.Server.ReconnectionDialogId;

// SSR
target.Ssr.DisableDomPreservation = source.Ssr.DisableDomPreservation ?? target.Ssr.DisableDomPreservation;
target.Ssr.CircuitInactivityTimeoutMs = source.Ssr.CircuitInactivityTimeoutMs ?? target.Ssr.CircuitInactivityTimeoutMs;
target.Ssr.PreserveDom = source.Ssr.PreserveDom ?? target.Ssr.PreserveDom;
target.Ssr.CircuitInactivityTimeout = source.Ssr.CircuitInactivityTimeout ?? target.Ssr.CircuitInactivityTimeout;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,25 @@ public static RazorComponentsEndpointConventionBuilder WithStaticAssets(
}

/// <summary>
/// Configures a <see cref="BrowserConfiguration"/> that will be emitted as a DOM comment
/// Configures a <see cref="BrowserOptions"/> that will be emitted as a DOM comment
/// to the browser for all Razor component endpoints.
/// </summary>
/// <param name="builder">The <see cref="RazorComponentsEndpointConventionBuilder"/>.</param>
/// <param name="configure">An action to configure the <see cref="BrowserConfiguration"/>.</param>
/// <param name="configureOptions">An action to configure the <see cref="BrowserOptions"/>.</param>
/// <returns>The <see cref="RazorComponentsEndpointConventionBuilder"/>.</returns>
public static RazorComponentsEndpointConventionBuilder WithBrowserConfiguration(
public static RazorComponentsEndpointConventionBuilder WithBrowserOptions(
this RazorComponentsEndpointConventionBuilder builder,
Action<BrowserConfiguration> configure)
Action<BrowserOptions> configureOptions)
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(configure);
ArgumentNullException.ThrowIfNull(configureOptions);

var config = new BrowserConfiguration();
configure(config);
var options = new BrowserOptions();
configureOptions(options);

builder.Add(endpointBuilder =>
{
endpointBuilder.Metadata.Add(config);
endpointBuilder.Metadata.Add(options);
});

return builder;
Expand Down
10 changes: 5 additions & 5 deletions src/Components/Endpoints/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Microsoft.AspNetCore.Components.ITempData.Keep(string! key) -> void
Microsoft.AspNetCore.Components.ITempData.Peek(string! key) -> object?
Microsoft.AspNetCore.Components.ConfigureBrowser
Microsoft.AspNetCore.Components.ConfigureBrowser.ConfigureBrowser() -> void
Microsoft.AspNetCore.Components.ConfigureBrowser.Configuration.get -> Microsoft.AspNetCore.Components.BrowserConfiguration!
Microsoft.AspNetCore.Components.ConfigureBrowser.Configuration.set -> void
Microsoft.AspNetCore.Components.ConfigureBrowser.Options.get -> Microsoft.AspNetCore.Components.BrowserOptions!
Microsoft.AspNetCore.Components.ConfigureBrowser.Options.set -> void
Microsoft.AspNetCore.Components.ConfigureBrowser.HttpContext.get -> Microsoft.AspNetCore.Http.HttpContext?
Microsoft.AspNetCore.Components.ConfigureBrowser.HttpContext.set -> void
Microsoft.AspNetCore.Http.BrowserConfigurationHttpContextExtensions
static Microsoft.AspNetCore.Http.BrowserConfigurationHttpContextExtensions.GetBrowserConfiguration(this Microsoft.AspNetCore.Http.HttpContext! context) -> Microsoft.AspNetCore.Components.BrowserConfiguration!
static Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilderExtensions.WithBrowserConfiguration(this Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder! builder, System.Action<Microsoft.AspNetCore.Components.BrowserConfiguration!>! configure) -> Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder!
Microsoft.AspNetCore.Components.BrowserOptionsHttpContextExtensions
static Microsoft.AspNetCore.Components.BrowserOptionsHttpContextExtensions.GetBrowserOptions(this Microsoft.AspNetCore.Http.HttpContext! context) -> Microsoft.AspNetCore.Components.BrowserOptions!
static Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilderExtensions.WithBrowserOptions(this Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder! builder, System.Action<Microsoft.AspNetCore.Components.BrowserOptions!>! configureOptions) -> Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder!
Loading
Loading