Skip to content

NetWasm.UI 0.15.0

Choose a tag to compare

@github-actions github-actions released this 19 Nov 14:37
· 8 commits to main since this release

Removed

  • NetWasmUIReusePrerender (NwUi.AspNetCore): UseNetWasmUIDevServer no longer keeps the pages
    prerendered at startup across rebuilds. Putting them back did not reliably match what the new
    build wrote. A client with NetWasmUIPrerender now prerenders on every rebuild, which takes a
    few seconds longer. Remove the property if you set it; to skip prerendering in development, set
    NetWasmUIPrerender only for Release in the client project, see
    ASP.NET Core.

Added

  • NwUi.Workers (preview): C# services in Web Workers. Mark an interface [WorkerContract],
    implement it in a worker project with [WorkerService] and register it in the app with
    AddWorker<T>() (one stateful worker) or AddWorkerPool<T>() (parallel, stateless calls).
    A source generator writes both sides. Supports CancellationToken (cooperative, or
    terminateOnCancel), IProgress<T>, IAsyncEnumerable<T> with back pressure, and JSON
    arguments through a JsonSerializerContext. See Web Workers and
    samples/Workers.
  • The page no longer preloads netwasm.runtime.worker.*.mjs, which only runs inside workers.
  • Library assets: a component library declares stylesheets, JavaScript modules and fonts with
    <NwUiAsset Include="…" />. Apps serve them at _content/<PackageId>/, bundle the modules
    for [JSImport], and (with NwUi.Browser) link the stylesheets from index.html (in the project
    folder or in wwwroot) at build time, before the app's own CSS, so prerendered pages are styled
    on first paint. Opt out with NetWasmUIInjectAssets=false. Works for project and package
    references, and a netstandard2.1 library packs its assets too. See
    Stylesheets, scripts and fonts.
  • ListenerFlags.Capture and ListenerFlags.Passive (@onfocus:capture,
    @onwheel:passive): the listener is added to the element instead of being delegated.
    Passive with PreventDefault throws. OnDocument and OnWindow accept them too.
  • Focus: element.FocusFirst() and FocusLast() focus the first or last tabbable element
    inside an element after the pending DOM updates, and Html.Focus(id) focuses the element
    ActiveElementId() returned. samples/Primitives.Kit builds a FocusScope (trap and
    restore) and roving focus on them.
  • Exit animations: When(…).AnimateExit() and Each(…).AnimateExit(), @if (…) animate-exit
    and @foreach (…) animate-exit in templates. Removed content gets data-state="closed" and
    stays in the DOM until its CSS animations finish; shown content gets data-state="open". See
    Exit animations.
  • NwUi.Testing (preview): TestRenderer.Render(component) renders components in a .NET test
    without a browser, with Find, Click, Input, KeyDown, Focused and more. See
    Testing.
  • NwUi also builds for netstandard2.1, so a component library can target netstandard2.1 and
    work in browser apps, prerendering and net10.0 tests alike. See
    Your own libraries.
  • Building a headless library: how to layer headless and
    design-system libraries on these pieces, with API conventions, compound components, dialog and
    menu patterns, an accessibility checklist and pitfalls.
  • dotnet new netwasm-ui-lib (NwUi.Templates): a netstandard2.1 headless component library with
    a Disclosure and a test project on NwUi.Testing.
  • Build a component library: a tutorial from the template
    to a themed library and packages. samples/Primitives.Kit gains a Disclosure and compound
    Tabs (Tabs, TabList, Tab, TabPanel), and samples/Primitives.Theme is a design-system
    library on top of it, with its stylesheet as an NwUiAsset.
  • EventChannel<T>: a typed, synchronous event channel for in-app pub/sub. Publish runs every handler in
    one batch, and a Subscribe made while building a component ends with that component. Handler
    errors go to the subscriber's error boundary. See Events.
  • Services.AddServiceProvider(IServiceProvider): Inject<T>() falls back to any
    IServiceProvider, such as a Microsoft.Extensions.DependencyInjection container from
    NetWasm.Microsoft.Extensions.DependencyInjection, for types that are not registered by type.
    AddServiceProvider(Func<IServiceProvider>) creates the provider per providing scope and disposes
    it with that scope, so () => root.CreateScope().ServiceProvider gives each subtree its own
    container scope. See Using Microsoft.Extensions.DependencyInjection.

Changed

  • A custom DOM host (createDomHost replacement or a host of your own) must handle two new ops:
    RemoveAnimated (28) and FocusEdge (29). See the op table. The
    hosts in NwUi.Browser and the prerenderer handle them.
  • The templates, samples and docs no longer declare an empty Main in Program.cs. A
    JsModule app only needs its [JSExport] methods. Existing apps can delete theirs.
  • The benchmark runner waits until a page has made no request for 500 ms before the setup clicks,
    as js-framework-benchmark does. Starting the warm-up right after the app is ready made some
    cases of the JavaScript frameworks faster than the official benchmark measures them. The same
    wait keeps the runner from polling the page while NetWasm.UI is still starting, which had added
    about 5 ms to its startup figure.
  • A computation keeps its first two sources inline, and a signal its first two observers. A list
    row whose bindings read two signals (its label and the selected key, say) no longer allocates
    two arrays for the second one.
  • A Scope keeps its first registration inline. A list row's scope, which owns one thing, no
    longer allocates an array of eight.
  • A template row whose bindings ask a Selector about the row's own @key
    (class="@(isSelected.Is(row.Id) ? "danger" : null)" on a row with @key="row.Id") is told
    about selection changes through its list, instead of the selector keeping a node and a
    dictionary entry per row. Only a selector with the default comparer does this; others work as
    before.
  • The renderer no longer keeps a render batch buffer that one large batch grew (a list of thousands
    of rows) for the small batches after it. It kept two of them, about 1 MB each after 10,000 rows;
    a later large batch grows its buffer again.