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

26 lines
911 B
TypeScript
Raw Normal View History

2024-06-07 12:53:24 +00:00
const iOS = () => [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
].includes(navigator.platform)
// iPad on iOS 13 detection
|| (navigator.userAgent.includes("Mac") && "ontouchend" in document)
2022-04-15 14:24:30 +00:00
/**
* Check if AudioContext is supported by the current browser.
2024-06-07 12:53:24 +00:00
* Notice that event though iOS technically supports AudioContext, turning it on will cause a problem
* where switching to another app will pause script execution and mute the audio.
2022-04-15 14:24:30 +00:00
*/
2024-06-07 12:53:24 +00:00
export const isAudioContextSupported = process.env.NODE_ENV !== 'test' && !iOS()
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'
2022-12-23 15:44:34 +00:00
export const isFullscreenSupported = () => Boolean(document.fullscreenEnabled)