Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/base/browser/canIUse.ts
3292 views
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 './browser.js';
7
import { mainWindow } from './window.js';
8
import * as platform from '../common/platform.js';
9
10
export const enum KeyboardSupport {
11
Always,
12
FullScreen,
13
None
14
}
15
16
/**
17
* Browser feature we can support in current platform, browser and environment.
18
*/
19
export const BrowserFeatures = {
20
clipboard: {
21
writeText: (
22
platform.isNative
23
|| (document.queryCommandSupported && document.queryCommandSupported('copy'))
24
|| !!(navigator && navigator.clipboard && navigator.clipboard.writeText)
25
),
26
readText: (
27
platform.isNative
28
|| !!(navigator && navigator.clipboard && navigator.clipboard.readText)
29
)
30
},
31
keyboard: (() => {
32
if (platform.isNative || browser.isStandalone()) {
33
return KeyboardSupport.Always;
34
}
35
36
if ((<any>navigator).keyboard || browser.isSafari) {
37
return KeyboardSupport.FullScreen;
38
}
39
40
return KeyboardSupport.None;
41
})(),
42
43
// 'ontouchstart' in window always evaluates to true with typescript's modern typings. This causes `window` to be
44
// `never` later in `window.navigator`. That's why we need the explicit `window as Window` cast
45
touch: 'ontouchstart' in mainWindow || navigator.maxTouchPoints > 0,
46
pointerEvents: mainWindow.PointerEvent && ('ontouchstart' in mainWindow || navigator.maxTouchPoints > 0)
47
};
48
49