Cirreum.Services.Wasm
1.0.25
dotnet add package Cirreum.Services.Wasm --version 1.0.25
NuGet\Install-Package Cirreum.Services.Wasm -Version 1.0.25
<PackageReference Include="Cirreum.Services.Wasm" Version="1.0.25" />
<PackageVersion Include="Cirreum.Services.Wasm" Version="1.0.25" />
<PackageReference Include="Cirreum.Services.Wasm" />
paket add Cirreum.Services.Wasm --version 1.0.25
#r "nuget: Cirreum.Services.Wasm, 1.0.25"
#:package Cirreum.Services.Wasm@1.0.25
#addin nuget:?package=Cirreum.Services.Wasm&version=1.0.25
#tool nuget:?package=Cirreum.Services.Wasm&version=1.0.25
Cirreum.Services.Wasm
Foundational services infrastructure for WebAssembly client applications
Overview
Cirreum.Services.Wasm provides the standard browser/WebAssembly runtime implementations of core Cirreum infrastructure services. It delivers WebAssembly-specific implementations for state management, session handling, browser storage integration, and user activity monitoring designed specifically for Blazor WebAssembly applications.
This package sits in the Infrastructure layer of the Cirreum stack:
Base → Common → Core → Infrastructure → Runtime → Runtime Extensions
↑
Cirreum.Services.Wasm
Key Features
📡 State Management
A synchronous notification system designed around Blazor WASM's unique runtime characteristics. In WASM, JavaScript runs on the same thread as .NET, enabling direct synchronous JS interop with zero task scheduling overhead.
All state types implement IApplicationState. Subscribe to changes and notify subscribers through IStateManager:
// Subscribe to state changes
stateManager.Subscribe<IThemeState>(state => jsModule.ApplyTheme(state.Current));
// Notify subscribers after mutation
stateManager.NotifySubscribers<IThemeState>();
State hierarchy:
ScopedNotificationState ← batched notification base class
RemoteState ← async data loading with load/refresh lifecycle
StateContainer ← key/value storage with encryption support
PersistableStateContainer ← adds JSON serialization/deserialization
LocalState ← browser localStorage backed
SessionState ← browser sessionStorage backed
🔄 Remote State & Initialization
RemoteState is the base class for client-side state that loads data from backend services. It manages loading/refreshing lifecycle with guard checks and integrates with the notification system.
public class ProductsState(
IProductApi api,
IStateManager stateManager
) : RemoteState, IProductsState {
public IReadOnlyList<Product> Products { get; private set; } = [];
protected override async Task LoadCoreAsync(CancellationToken cancellationToken) {
Products = await api.GetAllAsync(cancellationToken);
}
protected override void OnStateHasChanged() {
stateManager.NotifySubscribers<IProductsState>(this);
}
}
Registration uses RegisterRemoteState on the state builder, which automatically wires up IInitializable discovery for startup initialization:
services.AddClientState(state => {
state.RegisterRemoteState<IProductsState, ProductsState>();
});
The IInitializationOrchestrator coordinates startup, running all IInitializable services in order and reporting progress through IInitializationState for splash screens and loading indicators.
📋 Initialization State
IInitializationState tracks application startup progress with deterministic task counting and error collection. It enables splash screens and loading indicators to display meaningful progress.
// Subscribe to initialization progress
stateManager.Subscribe<IInitializationState>(state => {
progressBar.Value = state.CompletedTasks;
progressBar.Max = state.TotalTasks;
statusLabel.Text = state.DisplayStatus;
});
Key properties: IsInitializing, TotalTasks, CompletedTasks, DisplayStatus, HasErrors, Errors. Errors are captured as InitializationError records with store name, exception details, and timestamp — allowing the UI to surface partial failures without blocking the entire startup pipeline.
🔔 Notification State
INotificationState provides in-app notification management with read/dismiss semantics. Notifications are stored newest-first and support soft dismissal (hidden but retained) and hard removal.
// Add a notification
notificationState.AddNotification(
Notification.Create("Deployment complete", "v2.1 deployed to production", NotificationType.Success)
);
// React to notification changes
stateManager.Subscribe<INotificationState>(state => {
badge.Count = state.UnreadCount;
});
Operations: AddNotification, MarkAsRead / MarkAllAsRead, Dismiss / DismissAll, RemoveNotification, ClearAll. The Notifications property automatically filters dismissed items, while UnreadCount reflects only unread, non-dismissed notifications.
🔒 Session Management
Sophisticated lifecycle management with configurable timeout stages and activity monitoring:
- SafeZone (0–90% of timeout) — minimal monitoring, low overhead
- WatchZone (90–100%) — active monitoring with debounced session extension
var sessionManager = serviceProvider.GetRequiredService<ISessionManager>();
sessionManager.SessionStageChanged += stage => {
if (stage == SessionStage.WatchZone) {
ShowSessionExpiryWarning();
}
};
🗄️ Browser Storage
Local and session storage abstractions with WebAssembly file system support:
ILocalStorageService— browserlocalStorageISessionStorageService— browsersessionStorage- WebAssembly file system integration for client-side file operations
👤 User Presence
Activity detection through DOM events and HTTP call interception with configurable throttling. Drives IUserPresenceState notifications via the JS interop path.
🔐 Security
Claims-based user context management and authentication state integration for WASM clients.
Registration
// Register all core client state services with defaults
builder.AddClientState();
// Or with custom configuration
builder.AddClientState(state => {
state.RegisterRemoteState<IProductsState, ProductsState>();
state.RegisterDecryptor(StateEncryptionKinds.CUSTOM, new CustomDecryptor());
});
Built-in services registered by AddClientState:
| Service | Purpose |
|---|---|
IStateManager |
Core state management and subscriber notification |
IInitializationState |
Startup progress tracking and error collection |
INotificationState |
In-app notification management |
IThemeState |
Application theme state |
IPageState |
Page title and navigation metadata |
IUserPresenceState |
User activity detection |
IMemoryState |
In-memory state container |
ISessionState |
Browser sessionStorage backed container |
ILocalState |
Browser localStorage backed container |
Architecture
State Notification Design
The StateManager maintains a subscriber dictionary of Action<TState> delegates, with version-tracked caching for efficient subscriber list retrieval. Source-generated logging ([LoggerMessage]) is used throughout for zero-overhead log filtering.
Subscribers → _subscribers dict → notified by NotifySubscribers
ScopedNotificationState
ScopedNotificationState is the base class for all state that batches notifications. Two mechanisms are provided:
| Mechanism | Use When |
|---|---|
NotifyStateChanged() |
Single mutation — one property changed |
CreateNotificationScope() |
Multiple mutations — batch into one notification |
Never wrap single-mutation methods in CreateNotificationScope. Callers use scopes to batch multiple method calls — internal scopes break that pattern.
State Container Encryption
StateContainer supports pluggable encryption for persisted values. Encryption is applied to the entire serialized JSON blob before storage. Algorithm IDs are appended to ciphertext to support migration between encryption schemes via keyed DI services.
Contribution Guidelines
Be conservative with new abstractions
The API surface must remain stable and meaningful.Limit dependency expansion
Only add foundational, version-stable dependencies.Favor additive, non-breaking changes
Breaking changes ripple through the entire ecosystem.Include thorough unit tests
All primitives and patterns should be independently testable.Document architectural decisions
Context and reasoning should be clear for future maintainers.Follow .NET conventions
Use established patterns from Microsoft.Extensions.* libraries.
Documentation
- CLAUDE.md — AI-assisted development context
Versioning
Cirreum.Services.Wasm follows Semantic Versioning:
- Major - Breaking API changes
- Minor - New features, backward compatible
- Patch - Bug fixes, backward compatible
Given its foundational role, major version bumps are rare and carefully considered.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Cirreum Foundation Framework
Layered simplicity for modern .NET
| 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
- Cirreum.Core (>= 5.2.0)
- Cirreum.Startup (>= 1.0.116)
- Cirreum.Storage.Browser (>= 1.0.108)
- Microsoft.AspNetCore.Components (>= 10.0.7)
- Microsoft.AspNetCore.Components.WebAssembly.Authentication (>= 10.0.7)
- Microsoft.Extensions.Http (>= 10.0.7)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Cirreum.Services.Wasm:
| Package | Downloads |
|---|---|
|
Cirreum.Runtime.Wasm
The Cirreum Runtime Client. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.25 | 135 | 5/11/2026 |
| 1.0.24 | 131 | 5/7/2026 |
| 1.0.23 | 122 | 5/1/2026 |
| 1.0.22 | 135 | 4/28/2026 |
| 1.0.21 | 132 | 4/27/2026 |
| 1.0.20 | 161 | 4/26/2026 |
| 1.0.19 | 167 | 4/14/2026 |
| 1.0.18 | 141 | 4/13/2026 |
| 1.0.17 | 132 | 4/13/2026 |
| 1.0.16 | 126 | 4/10/2026 |
| 1.0.15 | 104 | 4/10/2026 |
| 1.0.14 | 136 | 3/25/2026 |
| 1.0.12 | 132 | 3/21/2026 |
| 1.0.11 | 261 | 3/17/2026 |
| 1.0.10 | 231 | 3/16/2026 |
| 1.0.9 | 361 | 3/14/2026 |
| 1.0.8 | 162 | 3/13/2026 |
| 1.0.7 | 111 | 3/12/2026 |
| 1.0.6 | 186 | 3/9/2026 |
| 1.0.5 | 110 | 3/6/2026 |