mirror of
https://github.com/hanzoai/openid-client.git
synced 2026-09-24 17:01:10 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
// @ts-ignore
|
|
export const isBun = typeof Bun !== 'undefined'
|
|
|
|
// @ts-ignore
|
|
export const isDeno = typeof Deno !== 'undefined'
|
|
|
|
export const isElectron =
|
|
// @ts-ignore
|
|
typeof process !== 'undefined' && process.versions?.electron !== undefined
|
|
|
|
export const isNode =
|
|
// @ts-ignore
|
|
!isBun && !isElectron && !isDeno && typeof process !== 'undefined'
|
|
|
|
export const isEdgeRuntime =
|
|
// @ts-ignore
|
|
typeof EdgeRuntime !== 'undefined'
|
|
|
|
export const isBrowser =
|
|
typeof navigator !== 'undefined' &&
|
|
navigator.userAgent?.startsWith?.('Mozilla/5.0 ')
|
|
|
|
const BOWSER = 'https://cdn.jsdelivr.net/npm/[email protected]/src/bowser.js'
|
|
|
|
let parsedUserAgent
|
|
async function parseUserAgent() {
|
|
const { default: Bowser } = await import(BOWSER)
|
|
parsedUserAgent ||= Bowser.parse(window.navigator.userAgent)
|
|
return parsedUserAgent
|
|
}
|
|
|
|
async function isEngine(engine: string) {
|
|
const userAgentData = await parseUserAgent()
|
|
return userAgentData.engine.name === engine
|
|
}
|
|
|
|
export const isBlink = isBrowser && (await isEngine('Blink'))
|
|
|
|
export const isWebKit = isBrowser && (await isEngine('WebKit'))
|
|
|
|
export const isGecko = isBrowser && (await isEngine('Gecko'))
|
|
|
|
export const isWorkerd =
|
|
typeof navigator !== 'undefined' &&
|
|
navigator.userAgent === 'Cloudflare-Workers'
|