Files
EnvelopeGenerator/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Components/App.razor
TekH 712fdb61d3 Improve Blazor WASM error handling and bump version
Enhanced error handling in Blazor WebAssembly startup:
- Added `getErrorText` to extract error messages.
- Introduced `isWasmStartupFailure` for WASM-specific errors.
- Updated `showStartupFallback` to prevent duplicate execution.
- Refined event listeners for `unhandledrejection` and `error`.
- Removed unused `started` variable.

Updated `EnvelopeGenerator.Server.csproj` version numbers:
- `Version` to 1.12.0-beta.
- `FileVersion` to 1.12.0.0.
- `AssemblyVersion` to 1.12.0.0.
2026-11-19 19:56:45 +01:00

134 lines
5.0 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/css/flag-icons.min.css" />
<link rel="stylesheet" href="css/app.css" />
<link rel="stylesheet" href="css/envelope-viewer.css" />
<link rel="stylesheet" href="_content/MudBlazor/MudBlazor.min.css" />
<link rel="stylesheet" href="EnvelopeGenerator.Server.styles.css" />
<HeadOutlet />
<!-- Apply saved theme immediately on page load — before WASM boots.
Reads localStorage["signflow.theme"] to avoid flash of default theme. -->
<script>
(function () {
var allowed = { 'blazing-dark': true, 'blazing-berry': true, 'purple': true };
var theme = localStorage.getItem('signflow.theme');
if (!theme || !allowed[theme]) theme = 'blazing-berry';
var bsTheme = theme === 'blazing-dark' ? 'dark' : 'light';
document.documentElement.setAttribute('data-sf-theme', theme);
document.documentElement.setAttribute('data-bs-theme', bsTheme);
var link = document.createElement('link');
link.id = 'dx-theme-link';
link.rel = 'stylesheet';
link.href = '_content/DevExpress.Blazor.Themes/' + theme + '.bs5.min.css';
document.head.appendChild(link);
})();
</script>
</head>
<body>
<Routes />
<div id="sf-client-startup-fallback" class="sf-startup-fallback" hidden>
<div class="sf-startup-fallback__card" role="alert" aria-live="assertive">
<h2>Application could not start</h2>
<p>
Your browser or its current settings don't support required features.
Please update the browser or contact IT support.
</p>
<button type="button" class="btn btn-primary btn-sm" onclick="location.reload()">Reload</button>
</div>
</div>
<script src="_content/DevExpress.Blazor.Resources/js/preload-script.js"></script>
<script src="js/typed.umd.js"></script>
<script src="js/receiver-signature.js?v=9"></script>
<script src="js/signflow-theme.js"></script>
<script src="js/envelope-editor.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="_framework/blazor.web.js" autostart="false"></script>
<script>
(function () {
var fallbackShown = false;
function getErrorText(reason) {
if (!reason) {
return '';
}
if (typeof reason === 'string') {
return reason;
}
if (reason && typeof reason.message === 'string') {
return reason.message;
}
try {
return JSON.stringify(reason);
} catch {
return String(reason);
}
}
function isWasmStartupFailure(reason) {
var text = getErrorText(reason).toLowerCase();
return text.indexOf('wasm simd') >= 0 ||
text.indexOf('failed to start platform') >= 0 ||
text.indexOf('instantiate_wasm_module') >= 0 ||
text.indexOf('mono_download_assets') >= 0 ||
text.indexOf('/_framework/dotnet') >= 0;
}
function showStartupFallback(reason) {
if (fallbackShown) {
return;
}
var root = document.getElementById('sf-client-startup-fallback');
if (!root) {
return;
}
if (reason) {
console.error('Blazor startup failed:', reason);
}
fallbackShown = true;
root.removeAttribute('hidden');
root.hidden = false;
root.style.display = 'flex';
}
if (!window.WebAssembly || !window.Blazor || typeof window.Blazor.start !== 'function') {
showStartupFallback('Browser/runtime prerequisites are missing.');
return;
}
window.addEventListener('unhandledrejection', function (event) {
if (isWasmStartupFailure(event.reason)) {
showStartupFallback(event.reason);
}
});
window.addEventListener('error', function (event) {
var reason = event.error || event.message;
if (isWasmStartupFailure(reason)) {
showStartupFallback(reason);
}
});
window.Blazor.start({
webAssembly: {}
}).catch(function (error) {
showStartupFallback(error);
});
})();
</script>
</body>
</html>