error fix + embedding extensability (#110)
* embed mode: make embedding options more extensible ui: unify service worker not available errors, show same error in standard/embed mode, including when loaded over http - more customizations for extended embed, allow hiding 'browse contents' button - simplify title updates - make error page / icon more customizable - autoupdating in editable mode: don't update if previous one didn't finish, make customizable, don't autoupdate at all over >=100 pages * dependencies: update ruffle to 2022-07-02 * bump to 1.6.1, update CHANGELIST
This commit is contained in:
+25
-6
@@ -1,5 +1,11 @@
|
||||
import { register } from "register-service-worker";
|
||||
|
||||
let appName = "ReplayWeb.page";
|
||||
|
||||
// ===========================================================================
|
||||
function setAppName(newAppName) {
|
||||
appName = newAppName;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
function registerSW(name = "sw.js", scope = "./") {
|
||||
@@ -10,10 +16,9 @@ function registerSW(name = "sw.js", scope = "./") {
|
||||
reject = rej;
|
||||
});
|
||||
|
||||
if (!navigator.serviceWorker) {
|
||||
const errMsg = `Sorry, ReplayWeb.page won't work in this browser as Service Workers are not supported.
|
||||
Please try a different browser.
|
||||
(Service Workers are disabled in Firefox in Private Mode. If Using Private Mode in Firefox, try regular mode)`;
|
||||
const errMsg = getSWErrorMsg();
|
||||
|
||||
if (errMsg) {
|
||||
console.error(errMsg);
|
||||
reject(errMsg);
|
||||
}
|
||||
@@ -27,13 +32,27 @@ Please try a different browser.
|
||||
|
||||
error (error) {
|
||||
console.error("Error during service worker registration:", error);
|
||||
reject(`ReplayWeb.page could not be loaded due to the following error:\n${error.toString()}`);
|
||||
reject(`${appName} could not be loaded due to the following error:\n${error.toString()}`);
|
||||
}
|
||||
});
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
function getSWErrorMsg() {
|
||||
if (navigator.serviceWorker) {
|
||||
return null;
|
||||
}
|
||||
if (window.location.protocol === "http:") {
|
||||
return `\
|
||||
Sorry, the ${appName} system must be loaded from an HTTPS URL, but was loaded from: ${window.location.host}.
|
||||
Please try loading this page from an HTTPS URL`;
|
||||
} else {
|
||||
return `Sorry, ${appName} won't work in this browser as Service Workers are not supported.
|
||||
Please try a different browser.
|
||||
(Service Workers are disabled in Firefox in Private Mode. If Using Private Mode in Firefox, try regular mode)`;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
async function digestMessage(message, hashtype) {
|
||||
@@ -137,4 +156,4 @@ function parseURLSchemeHostPath(url) {
|
||||
|
||||
|
||||
export { digestMessage, tsToDate, getTS, getPageDateTS, getReplayLink, sourceToId, parseURLSchemeHostPath,
|
||||
registerSW };
|
||||
registerSW, getSWErrorMsg, setAppName };
|
||||
|
||||
Reference in New Issue
Block a user