Class NiteDevServer
The development server behind /_nite. Source files are compiled on request (one esbuild
transform each, cached until the file changes), bare imports resolve through an import map to
pre-bundled dependencies, and a file watcher drives hot updates over a WebSocket: React
components refresh in place, CSS swaps in place, and anything else reloads the page.
public sealed class NiteDevServer : INiteAssets, IAsyncDisposable
- Inheritance
-
NiteDevServer
- Implements
- Inherited Members
Constructors
NiteDevServer(NiteProject, HttpClient, ILoggerFactory)
public NiteDevServer(NiteProject project, HttpClient http, ILoggerFactory loggerFactory)
Parameters
projectNiteProjecthttpHttpClientloggerFactoryILoggerFactory
Properties
IsDevelopment
public bool IsDevelopment { get; }
Property Value
Methods
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
GetHeadAsync(HttpContext)
public ValueTask<NiteHead> GetHeadAsync(HttpContext context)
Parameters
contextHttpContext
Returns
GetHtmlAsync(string, HttpContext)
Renders an HTML entry (such as index.html) with its scripts and styles wired up.
public ValueTask<string> GetHtmlAsync(string page, HttpContext context)
Parameters
pagestringcontextHttpContext
Returns
GetIslandAsync(string, HttpContext)
Resolves an island by name (its path under the islands folder, without extension).
public ValueTask<NiteAsset> GetIslandAsync(string name, HttpContext context)
Parameters
namestringcontextHttpContext
Returns
GetModuleAsync(string, HttpContext)
Resolves an entry module by its path relative to the client root.
public ValueTask<NiteAsset> GetModuleAsync(string source, HttpContext context)
Parameters
sourcestringcontextHttpContext
Returns
HandleAsync(HttpContext)
Handles a request under /_nite (the prefix is already in PathBase).
public Task HandleAsync(HttpContext context)
Parameters
contextHttpContext
Returns
Start(Task?)
Starts installing, scanning and pre-bundling in the background. Safe to call more than once.
public void Start(Task? hostStarted = null)
Parameters
hostStartedTaskCompletes when the host has started. Startup waits for it, because telemetry listeners (OpenTelemetry's) subscribe as the host starts and would miss the startup trace otherwise.