Debian Codegraph @

node/@xterm/xterm/src/vs/base/browser/canIUse.ts

raw
1 /*---------------------------------------------------------------------------------------------
2 * Copyright (c) Microsoft Corporation. All rights reserved.
3 * Licensed under the MIT License. See License.txt in the project root for license information.
4 *--------------------------------------------------------------------------------------------*/
5
6 import * as browser from 'vs/base/browser/browser';
7 import { mainWindow } from 'vs/base/browser/window';
8 import * as platform from 'vs/base/common/platform';
9
10 export const enum KeyboardSupport {
11 Always,
12 FullScreen,
13 None
14 }
15
16 const safeNavigator = typeof navigator === 'object' ? navigator : {} as { [key: string]: any };
17
18 /**
19 * Browser feature we can support in current platform, browser and environment.
20 */
21 export const BrowserFeatures = {
22 clipboard: {
23 writeText: (
24 platform.isNative
25 || (document.queryCommandSupported && document.queryCommandSupported('copy'))
26 || !!(safeNavigator && safeNavigator.clipboard && safeNavigator.clipboard.writeText)
27 ),
28 readText: (
29 platform.isNative
30 || !!(safeNavigator && safeNavigator.clipboard && safeNavigator.clipboard.readText)
31 )
32 },
33 keyboard: (() => {
34 if (platform.isNative || browser.isStandalone()) {
35 return KeyboardSupport.Always;
36 }
37
38 if ((<any>safeNavigator).keyboard || browser.isSafari) {
39 return KeyboardSupport.FullScreen;
40 }
41
42 return KeyboardSupport.None;
43 })(),
44
45 // 'ontouchstart' in window always evaluates to true with typescript's modern typings. This causes `window` to be
46 // `never` later in `window.navigator`. That's why we need the explicit `window as Window` cast
47 touch: 'ontouchstart' in mainWindow || safeNavigator.maxTouchPoints > 0,
48 pointerEvents: mainWindow.PointerEvent && ('ontouchstart' in mainWindow || navigator.maxTouchPoints > 0)
49 };