SpawnDev.BlazorJS.Photino
1.0.2
See the version list below for details.
dotnet add package SpawnDev.BlazorJS.Photino --version 1.0.2
NuGet\Install-Package SpawnDev.BlazorJS.Photino -Version 1.0.2
<PackageReference Include="SpawnDev.BlazorJS.Photino" Version="1.0.2" />
<PackageVersion Include="SpawnDev.BlazorJS.Photino" Version="1.0.2" />
<PackageReference Include="SpawnDev.BlazorJS.Photino" />
paket add SpawnDev.BlazorJS.Photino --version 1.0.2
#r "nuget: SpawnDev.BlazorJS.Photino, 1.0.2"
#:package SpawnDev.BlazorJS.Photino@1.0.2
#addin nuget:?package=SpawnDev.BlazorJS.Photino&version=1.0.2
#tool nuget:?package=SpawnDev.BlazorJS.Photino&version=1.0.2
SpawnDev.BlazorJS.Photino
Use this package to create shared services accessible to your Blazor WebAssembly windows.
Use this package in Blazor WebAssembly for interop with services running in the Photino.Net app.
Run Blazor WebAssembly in Photino.Net apps with 2 way interop between the app and Blazor WebAssembly instances.
Why
Photino.Blazor already exists, why use this?
Answer
Like Photino.Blazor, SpawnDev.BlazorJS.Photino provides shared services that run in the Photino app that each window can use. But SpawnDev.BlazorJS.Photino adds the benefits of Blazor WebAssembly + SpawnDev.BlazorJS which gives access to all of the awesome browser Web APIs like WebRTC, Canvas, WebGL, WEbGPU, etc. directly from C#, no Javascript required.
Example
Photino.Net app
Program.cs
// Create RemoteServiceProviderBuilder
var appBuilder = PhotinoBlazorWASMAppBuilder.CreateDefault(args);
// Blazor WebAssembly instances can call these services using expressions or
// an interface DispatchProxy provided by the PhotinoAppDispatcher service
// Singleton services are shared with all windows
// Scoped services are per-window
// Transient are per call
// The demo uses this service via an interface DispatchProxy
appBuilder.Services.AddSingleton<IConsoleLogger, ConsoleLogger>();
// build
var app = appBuilder.Build();
/// <summary>
/// If true, closing the main window will hide it instead of closing it.<br/>
/// This allows the app to stay alive until all windows are closed.<br/>
/// NOTE: Only supported when PhotinoWindow.IsWindowsPlatform == true<br/>
/// Default: false
/// </summary>
app.IndependentWindows = false;
/// <summary>
/// If true the app will not exit when there are no windows except invisible MainWindow.<br/>
/// Setting this to true is useful for a system tray icon that can be used to create a new window or show the main one.<br/>
/// NOTE: Only supported when PhotinoWindow.IsWindowsPlatform == true<br/>
/// Default: false
/// </summary>
app.InvisibleKeepAlive = false;
#if DEBUG
// Set the Url where the Blazor WebAssembly dev server is hosting when DEBUG
// if not set, the app's "wwwroot/index.html" path will be used.
// In production a release build of your Blazor WASM app could be served from there.
app.SetAppBaseUri("https://localhost:7174/");
#endif
// Start app. Show main window
app.Run();
Blazor WebAssembly app
Program.cs
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
// BlazorJSRuntime (PhotinoAppDispatcher dependency)
builder.Services.AddBlazorJSRuntime();
// PhotinoAppDispatcher lets Blazor WASM call into the Photino hosting app (if available) using:
// Expressions:
// var result = await PhotinoAppDispatcher.Run<TService, TResult>(service => service.SomeMethod(someVariable1, someVariable2));
// - or -
// Interface DispatchProxy:
// var service = PhotinoAppDispatcher.GetService<TService>() where TService : interface
// var result = await service.SomeMethod(someVariable1, someVariable2);
// - or -
// Register Photino host app service interface DispatchProxy and use as a normal service
// (See IConsoleLogger below)
builder.Services.AddSingleton<PhotinoAppDispatcher>();
// This adds IConsoleLogger provided by PhotinoAppDispatcher which will relay all
// async method calls to the Photino app instance via an interface DispatchProxy
builder.Services.AddSingleton(sp => sp.GetRequiredService<PhotinoAppDispatcher>().GetService<IConsoleLogger>());
// Start
await builder.Build().BlazorJSRunAsync();
Example usage:
Connected to Photino app services: @PhotinoAppDispatcher.IsReady
<br />
<button disabled="@(!PhotinoAppDispatcher.IsReady)" class="btn btn-primary" @onclick="OpenWindow">Open Window</button>
<button disabled="@(!PhotinoAppDispatcher.IsReady)" class="btn btn-primary" @onclick="CloseThisWindow">Close this window</button>
@code {
[Inject]
PhotinoAppDispatcher PhotinoAppDispatcher { get; set; } = default!;
[Inject]
IConsoleLogger ConsoleLogger { get; set; } = default!;
private async Task OpenWindow()
{
// this calls IConsoleLogger.LogAsync() which relays the call to the Photino host app IConsoleLogger service
await ConsoleLogger.LogAsync(">> Window being opened by " + PhotinoAppDispatcher.WindowId);
// call PhotinoBlazorWASMApp.OpenWindow() in the Photino host app on the PhotinoBlazorWASMApp service
var windowId = await PhotinoAppDispatcher.Run<PhotinoBlazorWASMApp, string>(s => s.OpenWindow());
// this calls IConsoleLogger.LogAsync() which relays the call to the Photino host app IConsoleLogger service
await ConsoleLogger.LogAsync(">> Window opened: " + windowId);
}
private async Task CloseThisWindow()
{
// this calls IConsoleLogger.LogAsync() which relays the call to the Photino host app IConsoleLogger service
await ConsoleLogger.LogAsync(">> Window closing: " + PhotinoAppDispatcher.WindowId);
// call PhotinoBlazorWASMWindow.Close() in the Photino host app on this window's PhotinoBlazorWASMWindow instance
await PhotinoAppDispatcher.Run<PhotinoBlazorWASMWindow>(s => s.Close());
}
}
Blazor WebAssembly libraries
Blazor WebAssembly libraries ready to use in your next Photino Blazor WebAssembly app.
- TransformersJS - Use Transformers.js to run pretrained models with the ONNX Runtime
- WebTorrents - WebTorrent peer to peer file sharing
- SocketIO - Socket.IO bidirectional and low-latency communication for every platform
- PeerJS - PeerJS simplifies peer-to-peer data, video, and audio calls
- Cryptography - A cross platform cryptography library ECDSA, ECDH, AES-CBC, etc
- More - More Blazor WebAssembly projects by LostBeard
- Nuget Packages - Blazor WebAssembly Nuget packages by LostBeard
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Microsoft.AspNetCore.Components.WebAssembly (>= 8.0.21)
- Photino.NET (>= 3.2.3)
- SpawnDev.BlazorJS.WebWorkers (>= 2.24.0)
- System.Text.Json (>= 8.0.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SpawnDev.BlazorJS.Photino:
| Package | Downloads |
|---|---|
|
SpawnDev.BlazorJS.Photino.App
Blazor WebAssembly in Photino. Use this package in the Photino.Net app project. |
GitHub repositories
This package is not used by any popular GitHub repositories.