Skip to content

Releases

NetWasm.UI 0.16.0

Choose a tag to compare

@github-actions github-actions released this 23 Nov 10:33

Changed

  • Breaking: NetWasm.UI is built with NetWasm.Sdk 0.15.1 for net10.0-netwasm, which replaces
    netwasm0.1. NwUi, NwUi.Browser and NwUi.Workers ship net10.0-netwasm builds in place of
    netwasm0.1 ones, and the templates create net10.0-netwasm apps. To upgrade an app, pin
    NetWasm.Sdk 0.15.1, change its target framework and update the NwUi packages together; see
    Upgrading from netwasm0.1.
  • The templates, samples and benchmarks set NetWasmTypeNames to false: none of them reads type
    names, and NetWasm.Sdk 0.15 would otherwise publish a type-names file the page fetches at startup.

Added

  • samples/Tsp: a route optimizer (traveling salesman) in a pool of Web Workers that stream
    shorter tours while the page stays responsive. It is published on GitHub Pages under /tsp/ and
    linked from the examples page. See Web Workers.

NetWasm.UI 0.15.1

Choose a tag to compare

@github-actions github-actions released this 19 Nov 14:56

Added

  • NwUi.Workers also targets netstandard2.1, with only the attributes and WorkerException, so a
    contracts project can target .NET Standard and be shared with servers and unit tests.
    samples/Workers.Contracts now does. See Web Workers.

NetWasm.UI 0.15.0

Choose a tag to compare

@github-actions github-actions released this 19 Nov 14:37

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.

NetWasm.UI 0.14.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 20:33

Changed

  • nwui.dom keeps the browser's compiled code for applying a batch across the browser's own
    garbage collections. It created a reader object per batch, and when a collection freed the
    shape of those short-lived readers (or of a cleared list's rows) the browser threw away the
    code compiled for them, so the next batch ran slower while it was compiled again. One reader
    now reads every batch, and each template keeps one node shaped like its clones' root.
  • A template clone releases its node ids with one op (new ReleaseBlock op) instead of one per
    node, and clones whose ids follow each other share that op. Clearing a list of 1,000 rows
    sends 18 bytes instead of 25 KB, and replacing one sends a third less. A host of your own has
    to handle the new op.
  • The keyed list builds no table of the old keys' positions when none of them stays in the new
    list (a list replaced by new rows, or rows removed from one end).
  • The benchmark runner forces the same last-resort GC before the measured click as
    js-framework-benchmark does, instead of a plain one.

NetWasm.UI 0.13.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 12:33

Added

  • TemplateRuntime.Rows, TemplateRow and Template.Listen: the rows of a keyed list as clones of
    one template, filled in by functions of the row that all rows share. See
    Rows. New TemplateListener op.
  • benchmarks/WasmBench: the keyed benchmark's C# side under Wasmtime, with times that repeat
    within about 1 % and exact allocation and batch sizes. See
    Benchmarks.

Changed

  • .nwui: the element of an @foreach body is compiled to rows of a template. A row is one
    clone and one object: its @expr text and bound attributes are one effect, and its @on…
    handlers for delegated events are registered once for the whole list. Creating rows takes about
    40 % less time on the C# side and sends about 40 % fewer bytes to the host. Templates need no
    change. Two things behave differently, see
    Rows of an @foreach:
    • A row whose key gets a different item in a new list (another object, or for a value type a
      value that is not equal) now shows that item in all of its content. A row that is only
      bindings and delegated handlers takes it in place; a row with a component, a block, @bind,
      @ref or other content that is applied once is built again for it. Before, the row kept the
      object it was created for. Keep the same object to keep the row.
    • The bindings of a row are evaluated together when something one of them reads changes. Only
      values that differ are written to the DOM.
  • Each and every other keyed list follow the same rule: a key that stays but gets a different
    item has its row disposed and rendered again for that item, in the same place. Before, the row
    kept the object it was created for. Lists without @key (the items are the keys) are not
    affected. See Conditionals and lists.
  • nwui.dom clones a template from its own inert document (a template with custom elements is
    still imported first) and finds a clone's text holes when they are first written to, instead of
    walking to every hole of every clone. Creating 10,000 rows spends about 8 ms less in the browser.
  • The keyed list reuses its keys and lookup tables from one list to the next, and it clears a list
    or swaps two rows without building them. Swapping two of 1,000 rows no longer allocates per row.
  • The benchmark runner warms up every case the way js-framework-benchmark does: create 10,000
    rows, append and select row were measured with less or no warm-up before.
  • The benchmark app is a .nwui template (benchmarks/NetWasmBench/BenchApp.nwui), so the
    benchmark measures what the template compiler emits.

NetWasm.UI 0.12.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 09:06

Added

  • NwUi.AspNetCore: hosts a NetWasm.UI app in ASP.NET Core on the same origin as your API.
    app.MapNetWasmUI() serves the client with the right MIME types and the prerendered page for
    each route; app.UseNetWasmUIDevServer() adds live reload and the error overlay in
    development (rebuilds use O0 and reuse the startup prerender, about 5 s; turn that off with
    NetWasmUIReusePrerender=false); setting
    NetWasmUIClientProject publishes the client into the server on build
    and publish. See ASP.NET Core
    and the new samples/Hosted.
  • Template: dotnet new netwasm-ui-hosted creates a client, an ASP.NET Core server and a
    shared library (Home, Counter and Weather, prerendering, live reload). Needs .NET 11.

Changed

  • Live reload also reloads the page when the connection to the dev server comes back, for
    example after dotnet watch restarts the server.

NetWasm.UI 0.11.0

Choose a tag to compare

@github-actions github-actions released this 16 Nov 09:53

Added

  • Attribute splatting: on a component tag, lowercase or dashed attributes (class, aria-*,
    data-*…) and @on… handlers go to the new Component.Attributes, and @attributes="expr"
    applies them to an element (or forwards them to another component). class and style join
    the element's own value. From C#, use Html.Splat. See
    Attribute splatting and the new
    live example.
  • TemplateInstance.Text(int, int) and Text(int, Func<int>): integer text holes (also @expr of
    type int in .nwui) go to the host as a number (new SetTextInt op) instead of a C# string.
  • Primitives for component libraries (see
    Building component libraries and the new
    samples/Primitives):
    • Element calls: Element.Call(method, args…) and the helpers ShowModal, Show, Close,
      ShowPopover, HidePopover, TogglePopover, Blur, Select, ScrollIntoView, applied in
      order with the other DOM updates. BrowserDom.GetHandle(element) returns the element as a
      JSObject.
    • Document and window listeners: Html.OnDocument, Html.OnWindow (with within for
      outside-click detection) and Html.OnResize, owned by the current component or effect run.
    • Synchronous DOM reads: Element.GetRect, Contains, HasFocus, Html.ActiveElementId and
      Html.Viewport (new IDomQueries host interface). They flush pending updates first and
      throw while building or inside an effect.
    • DomEvent.TargetId, RelatedTargetId, Inside, RelatedInside, NewState and
      IsTarget(element).
    • Html.Portal(target, …) and the Portal component render content elsewhere in the document.
    • Html.UseId(prefix) for unique ids.
    • Slot<T> (slots with a parameter) with .With(arg).
  • Templates: @typeparam T [where …] for generic components, generic component tags with
    explicit type arguments (<Select TItem="Fruit">), <template slot="Row" context="item"> for
    Slot<T> properties, @render(slot, arg), and @bind-Prop="signal" on component tags.
    inert, novalidate, formnovalidate, default, playsinline and nomodule are boolean
    attributes.

Changed

  • Breaking: on a component tag, an attribute whose name starts lowercase or contains - is no
    longer assigned to a property of that name; it goes to Attributes. Rename such properties to
    PascalCase. A component property named Attributes now hides the base one.
  • Breaking: in .nwui templates, a bool written into an attribute value
    (aria-expanded="@open") renders as "true"/"false" instead of "True"/"False", which is
    what ARIA and CSS selectors such as [aria-selected=true] expect. Update selectors and tests
    that match the capitalized value.
  • Clearing or replacing a keyed list (Each/For) removes the old rows with one RemoveRange op
    instead of one Remove per row. When the list is its parent's only content, the browser host
    empties the parent in one call.

NetWasm.UI 0.10.0

Choose a tag to compare

@github-actions github-actions released this 15 Nov 13:40

NetWasm.Sdk 0.14.2. NetWasm now includes its framework (LINQ, System.Text.Json, HttpClient,
regular expressions, XML and more) in every netwasm0.1 project, and apps can use NuGet
packages built for .NET Standard. The demo app's Wasm drops from 92 to 88 KB (Brotli).

Upgrading: set "NetWasm.Sdk": "0.14.2" under msbuild-sdks in your global.json, and
remove references to NetWasm.System.* packages such as NetWasm.System.Net.Http and
NetWasm.System.Text.Json: the framework includes them now.

Added

  • Libraries and packages: NuGet and .NET Standard packages, what fails at
    run time, component libraries with .nwui files, and what libraries cost in size.

Changed

  • NetWasm.Sdk 0.13.0 → 0.14.2. samples/Fetch no longer references the NetWasm.System.*
    packages; its Wasm drops from 463 to 435 KB (Brotli).

NetWasm.UI 0.9.0

Choose a tag to compare

@github-actions github-actions released this 13 Nov 13:35

NetWasm 0.13.0 with its NetWasmGC collector, and the first per-row speedups from the profile in
#2, contributed by @zion-sati. The demo app's
Wasm drops from 108 to 92 KB (Brotli), and allocation-heavy work is up to 2× faster. See
Benchmarks.

Upgrading: set "NetWasm.Sdk": "0.13.0" under msbuild-sdks in your global.json, and any
NetWasm.System.* packages to 0.13.0. To use NetWasmGC like the template does, add
<NetWasmGarbageCollector>NetWasm</NetWasmGarbageCollector> to your app's project file.

Added

  • TemplateInstance.With(hole, content) overloads for one, two and three pieces of content, so the
    common case allocates no params array. Existing code, including the generated .nwui
    templates, picks them up when it is rebuilt.
  • benchmarks/Runner --gc NetWasm,Compact adds the Oz app built with each named NetWasm collector,
    so a run compares collectors side by side.

Changed

  • NetWasm.Sdk 0.13.0 (was 0.12.2). The Counter sample's Wasm is 17% smaller (Brotli, at Oz, with
    the same collector).
  • The template, the samples, the site and the benchmark app use NetWasm's NetWasmGC collector
    (<NetWasmGarbageCollector>NetWasm</NetWasmGarbageCollector>): it allocates small objects inline
    and collects faster than the default Compact collector, for about 1.6 KB more download. An app
    that removes the property keeps Compact.
  • NetWasm 0.13.0 programs no longer carry type names, so GetType().Name reads type#<id> unless
    NetWasmTypeNames writes the names beside the program (on in Debug). NetWasm.UI does not read
    type names.
  • nwui.dom keeps the page's nodes in an array indexed by node id instead of a Map, and the
    renderer reuses the ids of released nodes (a template clone reuses a released block of its size),
    so the array stays dense in a long-running app. A node handle used after its scope disposed it
    now reaches whichever node reuses the id rather than failing; as before, such use is a bug.
  • Node.Dispose() and TemplateInstance.Dispose() release their ids at most once, so disposing
    twice cannot hand one id to two live nodes. Disposing a template-hole handle (Root,
    Element(hole)) does nothing; its TemplateInstance releases it.
  • Counter size budget tightened to 96 KiB Wasm / 144 KiB total (Brotli).

NetWasm.UI 0.8.0

Choose a tag to compare

@github-actions github-actions released this 13 Nov 09:59

The first screen can now be rendered into the HTML at publish time, so visitors see content
before the Wasm has loaded:

<PropertyGroup>
  <NetWasmUIPrerender>true</NetWasmUIPrerender>
  <NetWasmUIPrerenderShell>404.html</NetWasmUIPrerenderShell>
</PropertyGroup>
<ItemGroup>
  <NetWasmUIPrerenderRoute Include="/about;/blog" />
</ItemGroup>

This is a snapshot, not hydration: links work right away, but event handlers start with the
app, which then replaces the markup. Hydration is planned next. The build runs the published
Wasm in the Node that NetWasm ships, so nothing more needs to be installed. See
Why Node and not .NET?.

Added

  • Prerendering (opt-in): with NetWasmUIPrerender=true, dotnet publish runs the app in Node
    for / and each NetWasmUIPrerenderRoute, and writes the rendered HTML into the mount
    element of index.html, about.html and so on. Content shows before the Wasm has loaded, and
    the app replaces it when it starts. NetWasmUIPrerenderShell writes a bare page, e.g.
    404.html, for the SPA fallback. See Prerendering.
  • The project website prerenders its home, examples and benchmarks pages.
  • nwui-dev serves /about from about.html when it exists, then 404.html, then
    index.html, as static hosts do.