The next-generation file converter. Open source, fully local* and free forever.
feat: toasts for cross-origin isolation reloads/fails
JovannMC984528f488f7
diff --git a/messages/en.json b/messages/en.jsonindex 6f9c025..d98f35a 100644--- a/messages/en.json+++ b/messages/en.json@@ -524,6 +524,11 @@"warnings": {"settings_change": "Changed setting '{setting}' from '{oldValue}' to '{newValue}' for '{file}' ({to}) to prevent conversion failure.","file_type_mismatch": "File '{filename}' is named {expected}, but was detected as {actual}. This may cause conversion issues."+ },+ "sw": {+ "reload_success": "Your page was reloaded automatically to enable cross-origin isolation, which is required for certain features to work.",+ "reload_error": "Your page was reloaded automatically to enable cross-origin isolation, which is required for certain features to work, however it was not enabled successfully. Some features may not work as expected.",+ "not_isolated": "Cross-origin isolation is not enabled, which is required for certain features to work. Some features may not work as expected."}},"privacy": {diff --git a/src/lib/util/sw.ts b/src/lib/util/sw.tsindex 6da1d5c..c77bc8b 100644--- a/src/lib/util/sw.ts+++ b/src/lib/util/sw.ts@@ -1,4 +1,6 @@+import { m } from "#lib/paraglide/messages.js";import { browser } from "$app/env";+import { ToastManager } from "./toast.svelte";const COI_RELOAD_KEY = "vertCoiReloaded";@@ -48,11 +50,32 @@ class ServiceWorkerManager {if (controlled || isolated) {// success (or resumed) — allow a future reload for SW updates- sessionStorage.removeItem(COI_RELOAD_KEY);- if (controlled && !isolated)++ if (sessionStorage.getItem(COI_RELOAD_KEY) && isolated) {+ // page was reloaded and is now isolated+ ToastManager.add({+ type: "info",+ message: m["workers.sw.reload_success"](),+ });+ sessionStorage.removeItem(COI_RELOAD_KEY);+ } else if (sessionStorage.getItem(COI_RELOAD_KEY) && !isolated) {+ // page was reloaded but is still not isolated+ ToastManager.add({+ type: "error",+ message: m["workers.sw.reload_error"](),+ });+ sessionStorage.removeItem(COI_RELOAD_KEY);+ }++ if (controlled && !isolated) {console.warn(- "[SW Manager] service worker active but page is not cross-origin isolated; wasm-vips will be unavailable.",+ "[SW Manager] service worker active but page is not cross-origin isolated. wasm-vips and other features may not work.",);+ ToastManager.add({+ type: "error",+ message: m["workers.sw.not_isolated"](),+ });+ }return;}