Commit to raw.esm.sh

This commit also adds an error message for when the Content Security Policy is likely at fault for blocking it.
This commit is contained in:
CenTdemeern1 2024-10-16 19:26:33 +02:00
parent 4c674610a2
commit cc5bb6457f
4 changed files with 15 additions and 6 deletions

View file

@ -106,7 +106,7 @@ async function loadRuffle() {
window.RufflePlayer.config = {
// Options affecting the whole page
'publicPath': `https://esm.sh/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/`,
'publicPath': `https://raw.esm.sh/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/`,
'polyfills': false,
// Options affecting files only
@ -171,7 +171,16 @@ function loadContent() {
loadingStatus.value = 'Loading Flash file';
player.value.load(url.value).then(() => {
loadingStatus.value = undefined;
}).catch(handleError);
}).catch(error => {
fetch('https://raw.esm.sh/', {
mode: 'cors',
}).then(() => {
handleError(error); // Unexpected error
}).catch(() => {
// Must be CSP because esm.sh should be online if `loadRuffle()` didn't fail
handleError('raw.esm.sh could not be accessed, meaning this instance\'s Content Security Policy is likely out of date. Please contact your instance administrators.');
});
});
}
function playPause() {