mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
29
blocksuite/framework/global/src/env/index.ts
vendored
Normal file
29
blocksuite/framework/global/src/env/index.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
const agent = globalThis.navigator?.userAgent ?? '';
|
||||
const platform = globalThis.navigator?.platform;
|
||||
|
||||
export const IS_WEB =
|
||||
typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
|
||||
export const IS_NODE = typeof process !== 'undefined' && !IS_WEB;
|
||||
|
||||
export const IS_SAFARI = /Apple Computer/.test(globalThis.navigator?.vendor);
|
||||
|
||||
export const IS_FIREFOX =
|
||||
IS_WEB && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||
|
||||
export const IS_ANDROID = /Android \d/.test(agent);
|
||||
|
||||
export const IS_IOS =
|
||||
IS_SAFARI &&
|
||||
(/Mobile\/\w+/.test(agent) || globalThis.navigator?.maxTouchPoints > 2);
|
||||
|
||||
export const IS_MAC = /Mac/i.test(platform);
|
||||
|
||||
export const IS_IPAD =
|
||||
/iPad/i.test(platform) ||
|
||||
/iPad/i.test(agent) ||
|
||||
(/Macintosh/i.test(agent) && globalThis.navigator?.maxTouchPoints > 2);
|
||||
|
||||
export const IS_WINDOWS = /Win/.test(platform);
|
||||
|
||||
export const IS_MOBILE = IS_IOS || IS_IPAD || IS_ANDROID;
|
||||
Reference in New Issue
Block a user