Remove some polyfills

This should reduce the runtime size & load times somewhat by removing polyfills for older browsers which are not used much
This commit is contained in:
AaronDewes 2022-08-09 15:06:07 +00:00
parent 625fdf5bca
commit 64644b57e3
6 changed files with 27 additions and 163 deletions

View file

@ -45,13 +45,7 @@ async function checkCrypto() {
);
return true;
} catch (err) {
try {
window.asmCrypto = await import('asmcrypto.js');
await import('@dannycoates/webcrypto-liner/build/shim');
return true;
} catch (e) {
return false;
}
return false;
}
}
@ -66,25 +60,12 @@ function checkStreams() {
}
}
async function polyfillStreams() {
try {
await import('@mattiasbuelens/web-streams-polyfill');
return true;
} catch (e) {
return false;
}
}
export default async function getCapabilities() {
const browser = browserName();
const isMobile = /mobi|android/i.test(navigator.userAgent);
const serviceWorker = 'serviceWorker' in navigator && browser !== 'edge';
let crypto = await checkCrypto();
const nativeStreams = checkStreams();
let polyStreams = false;
if (!nativeStreams) {
polyStreams = await polyfillStreams();
}
let account = typeof AUTH_CONFIG !== 'undefined';
try {
account = account && !!localStorage;
@ -106,10 +87,10 @@ export default async function getCapabilities() {
account,
crypto,
serviceWorker,
streamUpload: nativeStreams || polyStreams,
streamUpload: nativeStreams,
streamDownload:
nativeStreams && serviceWorker && browser !== 'safari' && !mobileFirefox,
multifile: nativeStreams || polyStreams,
multifile: nativeStreams,
share,
standalone
};