PeakSWC.RemoteBlazorWebView.RemoteComponents
10.0.15.2
See the version list below for details.
dotnet add package PeakSWC.RemoteBlazorWebView.RemoteComponents --version 10.0.15.2
NuGet\Install-Package PeakSWC.RemoteBlazorWebView.RemoteComponents -Version 10.0.15.2
<PackageReference Include="PeakSWC.RemoteBlazorWebView.RemoteComponents" Version="10.0.15.2" />
<PackageVersion Include="PeakSWC.RemoteBlazorWebView.RemoteComponents" Version="10.0.15.2" />
<PackageReference Include="PeakSWC.RemoteBlazorWebView.RemoteComponents" />
paket add PeakSWC.RemoteBlazorWebView.RemoteComponents --version 10.0.15.2
#r "nuget: PeakSWC.RemoteBlazorWebView.RemoteComponents, 10.0.15.2"
#:package PeakSWC.RemoteBlazorWebView.RemoteComponents@10.0.15.2
#addin nuget:?package=PeakSWC.RemoteBlazorWebView.RemoteComponents&version=10.0.15.2
#tool nuget:?package=PeakSWC.RemoteBlazorWebView.RemoteComponents&version=10.0.15.2
Remote components
Run a Blazor component in its own process and show it inside your app, in a sandboxed iframe. Use it when a piece of UI should be isolated from the app: it can run with fewer rights than the app, crash without taking the app down, and can't touch the app's page.
app process component process (RemoteComponentHost)
┌──────────────────────────────┐ stdin: "set" ┌──────────────────────────────┐
│ <MyFrame Open=... Value=...> │ ────────────────▶ │ MyReceiver (contract values) │
│ iframe sandbox, opaque │ ◀──────────────── │ root component (your UI) │
│ origin, height only │ stdout: "call" │ RemoteBlazorWebView client │
└──────────────┬───────────────┘ └──────────────┬───────────────┘
└──── iframe src = <relay>/<id> ◀── relay ◀────────┘
- Data goes over the process's stdin/stdout, newline-delimited JSON (
RemoteComponentMessage): the app sendssetwith the contract values that changed, the component sendscallfor a callback. Nothing crosses through the browser, so when the app is viewed remotely, the remote browser can't forge either side. - The iframe is sandboxed without
allow-same-origin(RemoteComponentFrame.DefaultSandbox), so it has an opaque origin. The onlypostMessagethe app's page accepts from it is its height (rbwv-remote-height), matched by the sending window.
Mirrors
When the app's page is mirrored (a read-only /mirror/<id> view), the mirror renders the same page, frame included. If the mirror
loaded the component's page as well, the relay would take that as a reload and the component's process would restart. So the frame
is rendered without src: data-rbwv-src holds the component's page, and data-rbwv-mirror-src the relay's read-only view of it
(RemoteComponentSession.MirrorSource, by default <relay>/mirror/<id>). The app's page loads the first (remotecomponents.js); a
mirror page loads the second (the RemoteWebView script), or nothing when the session has no mirror source. The component's process
allows mirrors by default (RemoteComponentHostOptions.EnableMirrors). Mirrors can't click or type in it, like the rest of the mirror.
A contract, and what the generator writes from it
Declare what crosses between the two processes as an interface, in a library both sides reference:
[RemoteComponentContract]
public interface IClock
{
string TimeZone { get; } // a value: app -> component
Alarm? NextAlarm { get; } // any JSON-serializable type
Task Snooze(); // a callback: component -> app
Task Picked(DateTimeOffset when); // at most one argument
}
The source generator in this package writes:
ClockFramefor the app, a component with[Parameter] TimeZone,NextAlarm,EventCallback SnoozeandEventCallback<DateTimeOffset> Picked:<ClockFrame Open="ct => launcher.StartAsync(ct)" TimeZone="@zone" NextAlarm="@alarm" Snooze="OnSnooze" Title="Clock" />ClockReceiverfor the component's process: implementsIClockwith the values the app sent (Changedfires when they change); callingSnooze()sends the callback. Register it in the host and injectIClock(orClockReceiver) in the UI:return RemoteComponentHost.Run(new RemoteComponentHostOptions { ServerUri = relay, GrpcBaseUri = grpc, Id = id, ExitWhenInputCloses = true, RootComponent = typeof(ClockRoot), ConfigureServices = (services, connection) => services.AddRemoteComponentReceiver<ClockReceiver>(connection), });
Values and arguments must be JSON-serializable (RemoteComponentJson.Options: web defaults, enums as strings). Values are sent
when they change (compared as JSON), all of them the first time. Rules the generator enforces: RBWRC001 for a member that isn't a
get-only property or a Task method with at most one argument, RBWRC002 for a generic or nested interface, RBWRC003 for a member name
already defined on RemoteComponentFrameBase or RemoteComponentReceiverBase. Names can be set with
[RemoteComponentContract(FrameName = "...", ReceiverName = "...")].
Razor compiles before source generators run, so a .razor file can't use a frame generated in its own project: keep the contract
in a separate library.
The pieces
| Side | Type | Package |
|---|---|---|
| App | RemoteComponentFrameBase: the iframe, sends values, raises callbacks. Open starts the process and returns a RemoteComponentSession (the frame's address and the RemoteComponentConnection to the process) |
this one |
| Component process | RemoteComponentHost.Run(options): the never-shown WPF window with a RemoteBlazorWebView client of the relay; exits when the frame closes or reloads, or the app exits |
PeakSWC.RemoteBlazorWebView.Wpf |
| Component process | RemoteComponentReceiverBase: holds the values the app sent, raises Changed, sends callbacks; services.AddRemoteComponentReceiver<T>(connection) |
this one |
How the component's process notices that the app has gone: with ExitWhenInputCloses = true it exits when its stdin ends, which
Windows does as soon as the app exits, crashes or is killed (the app must keep its end of the pipe open while the component is shown,
as RemoteComponentSession does). Without a pipe on stdin, ParentProcessId polls the process list every 2 seconds instead.
How the app starts the process (token, folder, relay) is up to it: Open is a function you pass to the frame. The relay is usually
an embedded one (PeakSWC.RemoteWebViewService.Lib) with FrameAncestors set to the app's origin and AllowOpaqueOrigin = true.
The component's host page
Include the height script (RemoteComponentFrame.HeightScript) so the app can size the frame:
<script>
(function () {
var last = 0;
function post() {
var h = Math.ceil(document.documentElement.scrollHeight);
if (h !== last) { last = h; window.parent.postMessage({ type: 'rbwv-remote-height', height: h }, '*'); }
}
if (window.ResizeObserver) new ResizeObserver(post).observe(document.documentElement);
window.addEventListener('load', post);
})();
</script>
<script src="_framework/blazor.webview.js"></script>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.15)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.15)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PeakSWC.RemoteBlazorWebView.RemoteComponents:
| Package | Downloads |
|---|---|
|
PeakSWC.RemoteBlazorWebView.Wpf
This package will transport the user interface from an app built using BlazorWebView to a server running in the cloud. This allows an app running behind a firewall to be accessed through a browser by accessing the cloud server. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Based on maui 10.0.15.2
Changes since 10.0.14
Merge pull request #98 from budcribar/claude/project-thread-xv5i5s
Refuse GetIds on a relay that requires sign-in
Merge pull request #97 from budcribar/claude/project-thread-89es12
Mirror: wait for the WebView before showing the mirror on connect
Tests: say which session is short when the relay's file totals don't match
Merge pull request #96 from budcribar/claude/project-thread-89es12
Bump to 10.0.15.2 with release notes
Merge pull request #90 from budcribar/claude/project-thread-i544zb
Merge pull request #91 from budcribar/claude/project-thread-89es12
Merge pull request #94 from budcribar/claude/project-thread-wg41g7
Set-RailwayAgentKeys: create its link folder under -WhatIf too
Merge pull request #95 from budcribar/claude/project-thread-mj8jra
Set-RailwayAgentKeys: define a function when dot-sourced, link the relay project itself
Relay: send non-owner browsers in shared sessions to the mirror, log page requests
Relay: an EndSession is an expected disconnect, and keeps the requester label
Add scripts/Set-RailwayAgentKeys.ps1 to set the relay's enrollment keys on Railway
AgentHub: add ReleaseAvailableCommand broadcast and AgentAdmin.PublishRelease RPC
Merge pull request #93 from budcribar/claude/project-thread-3r4wyp-end-reason
Check connectionState in the lost-connection end-to-end test
Merge pull request #92 from budcribar/claude/project-thread-3r4wyp
Merge branch 'claude/project-thread-3r4wyp' into claude/project-thread-3r4wyp-end-reason
Tests: pass a shutdown reason in the null/whitespace id test
Relay: ReasonedCancellationTokenSource records why a session's token was cancelled
Relay: record why a session ends next to its token, so follow-on cancellations log at Debug
Relay: log every session shutdown with its reason
Publish the stream's connection state in window.RemoteControl
Relay: refuse agents outside Development when AGENT_ENROLLMENT_KEYS is unset
Merge pull request #88 from budcribar/claude/client-key
Agent protocol: add STAGE_CONSENT_TIMED_OUT launch stage (#89)
Relay: a browser that leaves straight after joining is taken out of the session
Relay: a request must carry the key of the connection it names
Merge pull request #87 from budcribar/claude/voice-controls-warning
Voice without controls is reported in the console
Relay: /status is open without sign-in and reports only a finished registration
Relay: the owner's own window is never locked out or taken for a refresh
Relay: EndSession RPC and a requester label for signed-in callers
Include RemoteTicket in Railway watchPatterns
Fix relay ticket signature interoperability with RemoteWebViewAdmin and fallback signing key
Fix unattended consent check for platform admins with null group scope
Support reading ticket from query parameter and set relay auth cookie
Add signed RemoteTicket relay authorization and tenant policy hooks
Add a Fast filter for the desktop and tutorial tests
Tests: wait for the relay's file totals before checking them
Merge branch 'claude/session-bar-opt-in': session bar is opt-in, templates, restart keeps the owner role (10.0.15.1)
A page comes back from a restart with the query it was opened with
Session bar is opt-in: no placeholder, no bar; a template makes it the app's own
Merge branch 'claude/session-bar-slot-declared': session bar waits for a declared placeholder (10.0.15.1)
Generator README and ShareControl doc comment mention the host-page tag for the session bar
Version 10.0.15.1 (was 10.0.16): the first three parts follow the .NET release
Test: visibility waits take their own options type
Session bar waits for a declared placeholder instead of floating at startup (10.0.16)
Release workflow publishes to NuGet when dry_run is off (trusted publishing, nuget-org approval)
10-client test waits 2 minutes before attaching browsers again (idle sessions must survive)
Full list: https://github.com/budcribar/RemoteBlazorWebView/compare/10.0.14...78554ab12c9890900cfa70e917c4ca8231fc7a17