PeakSWC.RemoteBlazorWebView.RemoteComponents
10.0.15.3
See the version list below for details.
dotnet add package PeakSWC.RemoteBlazorWebView.RemoteComponents --version 10.0.15.3
NuGet\Install-Package PeakSWC.RemoteBlazorWebView.RemoteComponents -Version 10.0.15.3
<PackageReference Include="PeakSWC.RemoteBlazorWebView.RemoteComponents" Version="10.0.15.3" />
<PackageVersion Include="PeakSWC.RemoteBlazorWebView.RemoteComponents" Version="10.0.15.3" />
<PackageReference Include="PeakSWC.RemoteBlazorWebView.RemoteComponents" />
paket add PeakSWC.RemoteBlazorWebView.RemoteComponents --version 10.0.15.3
#r "nuget: PeakSWC.RemoteBlazorWebView.RemoteComponents, 10.0.15.3"
#:package PeakSWC.RemoteBlazorWebView.RemoteComponents@10.0.15.3
#addin nuget:?package=PeakSWC.RemoteBlazorWebView.RemoteComponents&version=10.0.15.3
#tool nuget:?package=PeakSWC.RemoteBlazorWebView.RemoteComponents&version=10.0.15.3
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.3
Changes since 10.0.14
Bump to 10.0.15.3 with release notes
Merge pull request #114 from budcribar/fix/anycpu-packages
Emit AnyCPU IL for source generators and NuGet library packages
Merge pull request #113 from budcribar/security/remaining-review-fixes
Relay: keep a waiting session entry until its last waiter leaves
Harden relay against remaining security review findings (F1, F5, F6, F8, F9)
Merge pull request #112 from budcribar/claude/project-thread-l4oiwa
Relay: the admin site's service ticket may use the metrics calls
Relay: pass scheduled metrics from agents to Admin
Merge pull request #111 from budcribar/claude/project-thread-w37cul
Merge pull request #110 from budcribar/claude/project-thread-dzkzt6
Give control of agent-started sessions to the user who asked for them
Relay: gRPC error details only in Development, add HSTS
Merge pull request #109 from budcribar/claude/project-thread-pm2nrz
Merge pull request #107 from budcribar/agent-tokens-and-ticket-headers
Accept a newly issued agent token over the remembered one
Add per-agent token binding, ticket role claims, and header/cookie-only ticket reading
Merge pull request #105 from budcribar/claude/project-thread-9is2oo
Merge remote-tracking branch 'origin/net10' into claude/project-thread-9is2oo
Merge pull request #106 from budcribar/claude/project-thread-q0tq2b
Merge pull request #104 from budcribar/claude/project-thread-bf73xe
Apply session sign-in rules to the relay's gRPC calls
Relay: list clients and groups for the signed-in caller
Require a configured RelayTicket signing key of at least 32 bytes
Merge pull request #103 from budcribar/claude/project-thread-24nqqb
Refuse RPCD updates without an admin key and carry the installer log
Merge pull request #102 from budcribar/cursor/forward-update-rpcd-a474
Forward remote RPCD updates from Admin to the fleet agent
Merge pull request #100 from budcribar/claude/project-thread-ghzw1f
Merge pull request #101 from budcribar/claude/project-thread-izqv9b
Log why the relay refused an agent's enrollment key
Photino: fire ReadyToConnect only after WebView2 has started
CI: give manual and release runs a concurrency group of their own
Windows tests: warm up every tutorial build, not only Photino
Windows tests: warm up all three Photino tutorial builds
Tests: wait for the WebView2 page after the DevTools connect
Windows tests: warm up Chrome before the EndToEnd suite
Windows tests: warm up the shards' first browser and WebView2 starts
Windows tests: run the desktop tests as parallel shards
Merge pull request #99 from budcribar/claude/project-thread-kfekiw
Pass the PC's boot time from the agent to Admin
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
Full list: https://github.com/budcribar/RemoteBlazorWebView/compare/10.0.14...b5756b88971ab46b06600ec3edf9d95d074ff078