formaui-net.Framework.JavaScript.Interop
1.0.0-preview.10
Prefix Reserved
See the version list below for details.
dotnet add package formaui-net.Framework.JavaScript.Interop --version 1.0.0-preview.10
NuGet\Install-Package formaui-net.Framework.JavaScript.Interop -Version 1.0.0-preview.10
<PackageReference Include="formaui-net.Framework.JavaScript.Interop" Version="1.0.0-preview.10" />
<PackageVersion Include="formaui-net.Framework.JavaScript.Interop" Version="1.0.0-preview.10" />
<PackageReference Include="formaui-net.Framework.JavaScript.Interop" />
paket add formaui-net.Framework.JavaScript.Interop --version 1.0.0-preview.10
#r "nuget: formaui-net.Framework.JavaScript.Interop, 1.0.0-preview.10"
#:package formaui-net.Framework.JavaScript.Interop@1.0.0-preview.10
#addin nuget:?package=formaui-net.Framework.JavaScript.Interop&version=1.0.0-preview.10&prerelease
#tool nuget:?package=formaui-net.Framework.JavaScript.Interop&version=1.0.0-preview.10&prerelease
Forma.Framework.JavaScript.Interop
The bases Forma's C# wrappers over JavaScript modules are built from, and the scripts that Forma's other scripts share. A wrapper built on them imports its module on first use, and again on the next use after an import failed, logs a failed import or call under its owner's logger, and reports a dropped circuit as a call that did not run.
The package comes with formaui-net.Blazor. Its scripts are served from
_content/forma/core/scripts/.
Writing a wrapper
A wrapper takes the IJSEnvironment it runs in and names its module's path. A behavior, a module
that attaches to an element for a lifetime, derives from JSInterop and exposes a typed
AttachAsync:
using Forma.Framework.JavaScript.Interop;
using Microsoft.AspNetCore.Components;
public sealed class PanGesture(IJSEnvironment js)
: JSInterop(js, "./_content/forma/browser/scripts/behaviors/PanGesture.js")
{
public ValueTask<bool> AttachAsync(ElementReference container, string action, string whileClass)
=> AttachCoreAsync(container, new AttachOptions { Action = action, WhileClass = whileClass });
private sealed record AttachOptions
{
public required string Action { get; init; }
public required string WhileClass { get; init; }
}
}
An operation, a module of stateless calls, holds a JSModule and calls it through TryInvoke*:
using Forma.Framework.JavaScript.Interop;
public sealed class Clipboard(IJSEnvironment js) : IAsyncDisposable
{
private readonly JSModule _module = new(js, "./_content/forma/browser/scripts/operations/Clipboard.js");
public ValueTask<bool> WriteAsync(string text)
=> _module.TryInvokeVoidAsync("write", text);
public ValueTask DisposeAsync()
=> _module.DisposeAsync();
}
An export that answers with content a reader can make large, a text or a list of every item, answers
through the transfer, Transfer.of(value), and the wrapper reads it with TryInvokeTextAsync or
TryInvokeJsonAsync, naming the size it accepts in bytes:
public ValueTask<string?> ComposeAsync(string html)
=> _module.TryInvokeTextAsync("compose", js.TransferOptions.MaximumLength, html);
The value travels inline while the call carrying it fits the transfer's budget, under Blazor Server's
default message limit, and as a stream past it, which Blazor sends in chunks under any limit. A value
larger than the wrapper accepts is refused before it is read, and the call answers null as a call
that did not run does.
A component builds a wrapper from its Context.JS, the environment carrying the component's logger
and RuntimeId, attaches it from OnAfterRenderAsync, and disposes it from DisposeAsyncCore. An
attach that a later attach, a detach or the disposal overtakes releases the instance it gets and
reports that it did not attach, so a component disposed mid-attach leaves nothing attached; a module
whose import is still under way is released once it completes, without the disposal waiting for it. A
call on the attached instance still in flight as a detach or the disposal releases it reports that it did
not run, so a teardown never waits behind a call a reloaded Blazor Hybrid page never answers. A service
builds its own environment from the runtime and logger it is given:
_environment = new JSEnvironment(js, logger, Guid.CreateVersion7());
| Type | What it is |
|---|---|
IJSEnvironment |
A JS runtime carrying the RuntimeId and Logger of the owner whose interop it runs, and the TransferOptions that bound what the browser sends that owner through the transfer. |
JSEnvironment |
An IJSEnvironment over an IJSRuntime. |
JSInterop |
The base of a wrapper whose module attaches to an element: AttachCoreAsync, InvokeAsync on the attached instance and InvokeJsonAsync for what it answers through the transfer, InvokeModuleAsync on the module's exports, DetachAsync, IsAttached, and disposal as teardown. |
JSModule |
A lazily imported module: InvokeAsync and InvokeVoidAsync throw on failure, TryInvokeAsync and TryInvokeVoidAsync return default or false, and TryInvokeTextAsync and TryInvokeJsonAsync read what an export answered through the transfer. |
JSTransfer |
A value the browser sent .NET through the transfer, inline or streamed, which its receiver reads up to the size it accepts or discards. |
JSTransferException |
A value refused for its size, or broken on its way. |
JSTransferOptions |
The size a value with no maximum of its own may reach, which a host registers; 16 MiB by default. |
UnavailableJSRuntime |
A runtime whose every call throws JSRuntimeUnavailableException, for a container with no runtime of its own. |
ServiceProviderExtensions.GetJSRuntime |
The JS runtime the platform registered, or UnavailableJSRuntime.Instance where it registered none, so a service built on the runtime resolves in any registration order. |
ServiceProviderExtensions.GetJSTransferOptions |
The transfer options the host registered, or JSTransferOptions.Default. |
Shared scripts
A script in another assembly imports one of these by its path under _content/forma/core/scripts/,
as a behavior served from _content/forma/browser/scripts/behaviors/ does:
import { tell } from '../../../core/scripts/Owner.js';
| Script | What it is |
|---|---|
Controls.js |
The selectors of native controls: what Tab reaches and what handles its own press. |
Direction.js |
Whether an element lays out right to left. |
FrameScheduler.js |
One piece of work held to the next animation frame, however often it is requested before then. |
Owner.js |
tell(owner, method, ...args), which reports to a script's .NET owner. |
Sanitizer.js |
sanitize(html), which reduces untrusted markup to what a document may carry. |
Scrolling.js |
Which elements scroll, and the nearest ancestor of an element that does. |
Transfer.js |
Transfer.of(value), which carries a value to .NET inline within the budget and as a stream past it. |
License
Apache License 2.0, under the repository's LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Microsoft.JSInterop (>= 11.0.0)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on formaui-net.Framework.JavaScript.Interop:
| Package | Downloads |
|---|---|
|
formaui-net.Framework.Culture.Browser.Interop
The page's culture coordinator: one per document, it orders every culture switch on the page, gives each the next number in the document's sequence, and delivers the accepted pair to the culture state of every runtime registered with it, each Interactive Server circuit and WebAssembly runtime on the page, so they converge on one pair. |
|
|
formaui-net.Framework.Input.Interop
The input router: the script that resolves every key, press, wheel turn and drop on the page to one owner, and the C# a component registers its elements through. |
|
|
formaui-net.Framework.Browser.Interop
The browser capabilities Forma's components reach through JavaScript. |
|
|
formaui-net.Blazor
A Blazor component library for .NET 11: form inputs and pickers, dialogs, popovers and toasts, toolbars and menus, tabs and layout, file pickers, uploaders and viewers, icons, emoji and windows. |
|
|
formaui-net.Blazor.DataView
FormaDataView, the collection component of the Forma component library. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.27 | 82 | 12/3/2026 |
| 1.0.0-preview.26 | 89 | 12/3/2026 |
| 1.0.0-preview.25 | 98 | 12/2/2026 |
| 1.0.0-preview.24 | 130 | 12/1/2026 |
| 1.0.0-preview.23 | 197 | 11/30/2026 |
| 1.0.0-preview.22 | 199 | 11/30/2026 |
| 1.0.0-preview.21 | 203 | 11/29/2026 |
| 1.0.0-preview.20 | 186 | 11/26/2026 |
| 1.0.0-preview.19 | 182 | 11/26/2026 |
| 1.0.0-preview.18 | 172 | 11/26/2026 |
| 1.0.0-preview.17 | 156 | 11/26/2026 |
| 1.0.0-preview.16 | 159 | 11/24/2026 |
| 1.0.0-preview.15 | 152 | 11/23/2026 |
| 1.0.0-preview.14 | 150 | 11/23/2026 |
| 1.0.0-preview.13 | 151 | 11/21/2026 |
| 1.0.0-preview.12 | 151 | 11/20/2026 |
| 1.0.0-preview.11 | 152 | 11/18/2026 |
| 1.0.0-preview.10 | 156 | 11/17/2026 |
| 1.0.0-preview.9 | 185 | 11/17/2026 |
| 1.0.0-preview.8 | 156 | 11/17/2026 |
What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.10/CHANGELOG.md