Use esm.sh instead of unpkg as Ruffle CDN
This way admins don't have to change their content security policy
This commit is contained in:
parent
0e7105f1f7
commit
25fe3ceca1
4 changed files with 9 additions and 9 deletions
|
@ -95,18 +95,18 @@ function handleError(error: unknown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws if unpkg shits itself
|
* @throws if esm.sh shits itself
|
||||||
*/
|
*/
|
||||||
async function loadRuffle() {
|
async function loadRuffle() {
|
||||||
if (window.RufflePlayer !== undefined) return;
|
if (window.RufflePlayer !== undefined) return;
|
||||||
loadingStatus.value = 'Loading Ruffle player';
|
loadingStatus.value = 'Loading Ruffle player';
|
||||||
await import('@ruffle-rs/ruffle'); // Assumption: this will throw if unpkg has a hiccup or something. If not, the next undefined check will catch it.
|
await import('@ruffle-rs/ruffle'); // Assumption: this will throw if esm.sh has a hiccup or something. If not, the next undefined check will catch it.
|
||||||
window.RufflePlayer = window.RufflePlayer as PublicAPILike | PublicAPI | undefined; // Assert unknown type due to side effects
|
window.RufflePlayer = window.RufflePlayer as PublicAPILike | PublicAPI | undefined; // Assert unknown type due to side effects
|
||||||
if (window.RufflePlayer === undefined) throw Error('unpkg has shit itself, but not in an expected way (has unpkg permanently shut down? how close is the heat death of the universe?)');
|
if (window.RufflePlayer === undefined) throw Error('esm.sh has shit itself, but not in an expected way (has esm.sh permanently shut down? how close is the heat death of the universe?)');
|
||||||
|
|
||||||
window.RufflePlayer.config = {
|
window.RufflePlayer.config = {
|
||||||
// Options affecting the whole page
|
// Options affecting the whole page
|
||||||
'publicPath': `https://unpkg.com/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/`,
|
'publicPath': `https://esm.sh/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/`,
|
||||||
'polyfills': false,
|
'polyfills': false,
|
||||||
|
|
||||||
// Options affecting files only
|
// Options affecting files only
|
||||||
|
@ -153,7 +153,7 @@ function createPlayer() {
|
||||||
const ruffleAPI = (window.RufflePlayer as PublicAPI).newest();
|
const ruffleAPI = (window.RufflePlayer as PublicAPI).newest();
|
||||||
if (ruffleAPI === null) {
|
if (ruffleAPI === null) {
|
||||||
// This error exists because non-null assertions are forbidden, apparently.
|
// This error exists because non-null assertions are forbidden, apparently.
|
||||||
throw Error('Ruffle could not get the latest Ruffle source. Since we\'re loading from unpkg this is genuinely impossible and you must\'ve done something incredibly cursed.');
|
throw Error('Ruffle could not get the latest Ruffle source. Since we\'re loading from esm.sh this is genuinely impossible and you must\'ve done something incredibly cursed.');
|
||||||
}
|
}
|
||||||
return ruffleAPI;
|
return ruffleAPI;
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
content="default-src 'self' https://newassets.hcaptcha.com/ https://challenges.cloudflare.com/ http://localhost:7493/;
|
||||||
worker-src 'self' blob:;
|
worker-src 'self' blob:;
|
||||||
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com https://esm.sh https://cdn.jsdelivr.net https://unpkg.com;
|
script-src 'self' 'unsafe-eval' https://*.hcaptcha.com https://challenges.cloudflare.com https://esm.sh https://cdn.jsdelivr.net;
|
||||||
style-src 'self' 'unsafe-inline';
|
style-src 'self' 'unsafe-inline';
|
||||||
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 activitypub.software secure.gravatar.com avatars.githubusercontent.com;
|
img-src 'self' data: blob: www.google.com xn--931a.moe localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 activitypub.software secure.gravatar.com avatars.githubusercontent.com;
|
||||||
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
media-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000;
|
||||||
connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com https://api.listenbrainz.org https://api.friendlycaptcha.com https://unpkg.com;
|
connect-src 'self' localhost:3000 localhost:5173 127.0.0.1:5173 127.0.0.1:3000 https://newassets.hcaptcha.com https://api.listenbrainz.org https://api.friendlycaptcha.com;
|
||||||
frame-src *;"
|
frame-src *;"
|
||||||
/>
|
/>
|
||||||
<meta property="og:site_name" content="[DEV BUILD] Misskey" />
|
<meta property="og:site_name" content="[DEV BUILD] Misskey" />
|
||||||
|
|
|
@ -33,7 +33,7 @@ const externalPackages = [
|
||||||
path(id: string, pattern: RegExp): string {
|
path(id: string, pattern: RegExp): string {
|
||||||
const match = pattern.exec(id)?.groups;
|
const match = pattern.exec(id)?.groups;
|
||||||
return match
|
return match
|
||||||
? `https://unpkg.com/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/${match['file']}`
|
? `https://esm.sh/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/${match['file']}`
|
||||||
: id;
|
: id;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,7 +35,7 @@ const externalPackages = [
|
||||||
path(id: string, pattern: RegExp): string {
|
path(id: string, pattern: RegExp): string {
|
||||||
const match = pattern.exec(id)?.groups;
|
const match = pattern.exec(id)?.groups;
|
||||||
return match
|
return match
|
||||||
? `https://unpkg.com/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/${match['file']}`
|
? `https://esm.sh/@ruffle-rs/ruffle@${packageInfo.dependencies['@ruffle-rs/ruffle']}/${match['file']}`
|
||||||
: id;
|
: id;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue