big-moving.ru/api/soft/monako/esm/vs/base/common/platform.js

81 lines
3.0 KiB
JavaScript
Raw Normal View History

2022-06-24 15:29:23 +05:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var LANGUAGE_DEFAULT = 'en';
var _isWindows = false;
var _isMacintosh = false;
var _isLinux = false;
var _isNative = false;
var _isWeb = false;
var _locale = undefined;
var _language = LANGUAGE_DEFAULT;
var _translationsConfigFile = undefined;
var isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer');
// OS detection
if (typeof navigator === 'object' && !isElectronRenderer) {
var userAgent = navigator.userAgent;
_isWindows = userAgent.indexOf('Windows') >= 0;
_isMacintosh = userAgent.indexOf('Macintosh') >= 0;
_isLinux = userAgent.indexOf('Linux') >= 0;
_isWeb = true;
_locale = navigator.language;
_language = _locale;
}
else if (typeof process === 'object') {
_isWindows = (process.platform === 'win32');
_isMacintosh = (process.platform === 'darwin');
_isLinux = (process.platform === 'linux');
_locale = LANGUAGE_DEFAULT;
_language = LANGUAGE_DEFAULT;
var rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
if (rawNlsConfig) {
try {
var nlsConfig = JSON.parse(rawNlsConfig);
var resolved = nlsConfig.availableLanguages['*'];
_locale = nlsConfig.locale;
// VSCode's default language is 'en'
_language = resolved ? resolved : LANGUAGE_DEFAULT;
_translationsConfigFile = nlsConfig._translationsConfigFile;
}
catch (e) {
}
}
_isNative = true;
}
var _platform = 0 /* Web */;
if (_isNative) {
if (_isMacintosh) {
_platform = 1 /* Mac */;
}
else if (_isWindows) {
_platform = 3 /* Windows */;
}
else if (_isLinux) {
_platform = 2 /* Linux */;
}
}
export var isWindows = _isWindows;
export var isMacintosh = _isMacintosh;
export var isLinux = _isLinux;
export var isNative = _isNative;
export var isWeb = _isWeb;
var _globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {});
export var globals = _globals;
var _setImmediate = null;
export function setImmediate(callback) {
if (_setImmediate === null) {
if (globals.setImmediate) {
_setImmediate = globals.setImmediate.bind(globals);
}
else if (typeof process !== 'undefined' && typeof process.nextTick === 'function') {
_setImmediate = process.nextTick.bind(process);
}
else {
_setImmediate = globals.setTimeout.bind(globals);
}
}
return _setImmediate(callback);
}
export var OS = (_isMacintosh ? 2 /* Macintosh */ : (_isWindows ? 1 /* Windows */ : 3 /* Linux */));