koel/resources/assets/js/utils/supports.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-04-15 14:24:30 +00:00
import isMobile from 'ismobilejs'
/**
* Check if AudioContext is supported by the current browser.
*/
2022-05-14 15:13:29 +00:00
export const isAudioContextSupported = (() => {
if (process.env.NODE_ENV === 'test') {
return false
}
2022-04-15 14:24:30 +00:00
// Apple devices just don't love AudioContext that much.
if (isMobile.apple.device) {
return false
}
const ContextClass = window.AudioContext ||
window.webkitAudioContext ||
window.mozAudioContext ||
window.oAudioContext ||
window.msAudioContext
if (!ContextClass) {
return false
}
// Safari (MacOS & iOS alike) has webkitAudioContext, but is buggy.
// @link http://caniuse.com/#search=audiocontext
return Boolean((new ContextClass()).createMediaElementSource)
2022-04-15 14:24:30 +00:00
})()
/**
* Checks if HTML5 clipboard can be used.
*/
2022-05-14 15:13:29 +00:00
export const isClipboardSupported = 'execCommand' in document
2022-04-15 14:24:30 +00:00
/**
* Checks if the browser supports reading (and thus uploading) a whole directory.
*/
2022-05-14 15:13:29 +00:00
export const isDirectoryReadingSupported = window.DataTransferItem &&
2022-04-15 14:24:30 +00:00
typeof window.DataTransferItem.prototype.webkitGetAsEntry === 'function'