string RootAttributes { get; }
Source
Gets serialized attributes placed on the theme root.
Provides the immutable Web document for the configured default AppSurface theme.
AppSurfaceThemeDocument GetDocument()
Source
Gets the current safe document snapshot.
A renderable document, or AppSurfaceThemeDocument.Empty when it is unsafe.
Builds and retains the immutable Web document from the neutral default-theme resolver.
Represents the deterministic HTML fragments required to apply one AppSurface theme resolution.
The document contains no request-specific values. In particular, HeadContent never contains a CSP nonce; the live head TagHelper adds one only to its inline style element. Only the package serializer can create a renderable instance, so adapters cannot accidentally bypass the validated neutral-theme boundary.
string RootAttributes { get; }
Source
Gets serialized attributes placed on the theme root.
string RootThemeId { get; }
Source
Gets the theme identifier for the root metadata.
string RootThemeMode { get; }
Source
Gets the rendered theme mode for the root metadata.
string RootSchemaVersion { get; }
Source
Gets the rendered payload schema version for the root metadata.
string RootStyle { get; }
Source
Gets the safe color-scheme declaration for the theme root.
string HeadContent { get; }
Source
Gets serialized head metadata and critical CSS without a nonce.
AppSurfaceThemeDocument Empty { get; }
Source
Gets an empty document used when a resolver cannot produce a safe renderable snapshot.
bool IsRenderable { get; }
Source
Gets a value indicating whether the document contains renderable theme fragments.
Configures the browser-local System/Light/Dark preference enhancement for Web theme documents.
The enhancement stores only an explicit Light or Dark selection in browser local storage for the current origin; selecting System removes that value and returns to the operating-system preference. It neither reads nor writes cookies, server-side preference state, or additional document URLs.
AppSurfaceThemePreferenceOptions Snapshot()
Source
Validates and copies this configuration for service registration.
A validated snapshot detached from the caller's mutable options instance.
ArgumentExceptionStorageKey is blank, unsafe for an HTML data attribute, or longer than 64 characters.string StorageKey { get; set; }
Source
Gets or sets the origin-scoped local-storage key used for explicit Light or Dark selection.
The default is as_theme. Keys must contain 1 to 64 non-whitespace characters and cannot include quote or control characters because the value is emitted as an encoded HTML data attribute.
Provides the documented request-item key for a host-generated AppSurface theme CSP nonce.
string? Get(HttpContext httpContext)
Source
Gets the host-generated nonce from the current request, when one is available.
httpContextCurrent request context.The nonce supplied by the host, or null when the host does not use a nonce-based CSP.
Provides a cached System-first document for browser-local theme preferences.
The neutral resolver is evaluated exactly once during construction. The resulting document is cached for every request and is empty when the resolved pair cannot safely be serialized. This provider does not inspect HTTP state or browser storage; the deterministic bootstrap performs browser-local selection after rendering.
AppSurfaceThemeDocument GetDocument()
Source
Gets the cached document without re-resolving the configured theme pair.
The cached renderable document, or an empty document when the resolved pair was unsafe.
Renders the deterministic browser bootstrap for local theme preferences.
The bootstrap reads the configured origin-scoped local-storage key before the critical theme style renders, applies a System/Light/Dark selection to the document root, and synchronizes every rendered preference control. Storage access is best-effort: blocked or malformed browser storage falls back to the System mode without affecting server rendering, HTTP state, or the canonical document URL. Keep Script deterministic because CspHash is the public Content Security Policy source expression for its exact contents.
string Render(string? nonce)
Source
Renders the bootstrap script with an optional encoded CSP nonce.
nonceThe request-specific nonce, if the host uses nonce-based CSP.A script element that supplies the configured storage key by data attribute.
string StorageKey { get; }
Source
Gets the encoded-data-attribute-safe key read and written by the browser bootstrap.
string CspHash { get; }
Source
Gets the stable sha256- source expression for Script.
Provides the stable CSP source hash for the opt-in theme-preference bootstrap.
The hash covers only the deterministic inline script emitted by <appsurface-theme-head> after AppSurfaceWebThemingServiceCollectionExtensions.AddAppSurfaceWebThemePreferences(Microsoft.Extensions.DependencyInjection.IServiceCollection, Action{AppSurfaceThemePreferenceOptions}?). The configured storage key is supplied by an encoded data attribute, so it does not change this value. A dynamic host can instead supply its request nonce through the TagHelper. Static hosts remain responsible for separately hashing their generated critical styles.
string ScriptHash { get; }
Source
Gets the sha256- source expression for the deterministic bootstrap script.
Serializes validated neutral theme resolutions into deterministic Web document fragments.
AppSurfaceThemeDocument Serialize(AppSurfaceThemeResolution resolution)
Source
Creates a deterministic, nonce-free document for a neutral theme resolution.
resolutionThe sealed neutral theme resolution.A renderable document, or AppSurfaceThemeDocument.Empty when the snapshot is unsafe.
AppSurfaceThemeDocument SerializePreference(AppSurfaceThemeResolution resolution)
Source
Creates the System-first document used by the browser-local preference enhancement.
resolutionThe configured theme-pair resolution whose Light and Dark branches are emitted.A document with System, Light, and Dark selectors, or AppSurfaceThemeDocument.Empty when the resolution is unsafe to render.
This method deliberately replaces the configured startup mode with System while retaining the same Light and Dark pair. The browser bootstrap can then select an explicit branch without changing the URL or duplicating the HTML document. Safety validation is repeated before serialization so an invalid resolution fails closed instead of emitting partially trusted markup.
bool TrySerialize(AppSurfaceThemeResolution? resolution, out AppSurfaceThemeDocument document)
Source
Attempts to create a deterministic document from a neutral theme resolution.
resolutionThe sealed neutral theme resolution.documentThe renderable document when the snapshot is safe.true when all values are safe to emit; otherwise false.
string SerializeHeadContent(AppSurfaceThemeDocument document, string? nonce = null)
Source
Adds an encoded nonce to the live inline style in a previously serialized head fragment.
documentThe nonce-free document.nonceThe CSP nonce to apply to the inline style, if present.Head content with the nonce applied only to the inline style element.