mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-24 10:09:32 -06:00
In sandboxed iframes without allow-same-origin (or other opaque origin contexts), accessing `navigator.serviceWorker` throws a SecurityError synchronously. - Guard `info().serviceWorker` evaluation with try/catch to return `false` on SecurityError (#1585) - Guard PWA serviceWorker registration with try/catch to let the web app load rather than hanging (#1582) - Add contributor credit entry for @krinry in `contributors/people.toml`
This commit is contained in:
@@ -71,7 +71,13 @@
|
||||
...ec.info(),
|
||||
crossOriginIsolated: self.crossOriginIsolated,
|
||||
webgpu: !!navigator.gpu,
|
||||
serviceWorker: !!(navigator.serviceWorker && navigator.serviceWorker.controller),
|
||||
serviceWorker: (() => {
|
||||
try {
|
||||
return !!(navigator.serviceWorker && navigator.serviceWorker.controller);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
})(),
|
||||
load: window.effectcraftLoad,
|
||||
}),
|
||||
// Browser storage (OPFS / IndexedDB): save without downloading, list, remove, wait for writes.
|
||||
@@ -83,8 +89,14 @@
|
||||
workerFrameCheck: (params) => ec.workerFrameCheck(params ?? {}).then(JSON.parse),
|
||||
};
|
||||
// Offline start and install (PWA): the service worker caches the app's files.
|
||||
if ("serviceWorker" in navigator && !new URLSearchParams(location.search).has("nosw")) {
|
||||
navigator.serviceWorker.register("sw.js").catch((e) => console.warn("service worker:", e));
|
||||
if (!new URLSearchParams(location.search).has("nosw")) {
|
||||
try {
|
||||
if ("serviceWorker" in navigator && navigator.serviceWorker) {
|
||||
navigator.serviceWorker.register("sw.js").catch((e) => console.warn("service worker:", e));
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("service worker:", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
// Compile once: the page and its render workers instantiate the same module.
|
||||
|
||||
@@ -87,3 +87,7 @@ sync_github_name = false
|
||||
real_name = "Marco Arnulfo"
|
||||
display_name = "Marco Arnulfo"
|
||||
sync_github_name = false
|
||||
|
||||
[people.krinry]
|
||||
display_name = "krinry"
|
||||
sync_github_name = true
|
||||
|
||||
Reference in New Issue
Block a user