UNPKG

dynamicsmobile

Version:

Allows development of off-line mobile and web business apps over the Dynamics Mobile platform. More info on https://www.dynamicsmobile.com

49 lines 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPlatformType = exports.PlatformType = void 0; var PlatformType; (function (PlatformType) { PlatformType[PlatformType["Web"] = 0] = "Web"; PlatformType[PlatformType["Android"] = 1] = "Android"; PlatformType[PlatformType["iOS"] = 2] = "iOS"; PlatformType[PlatformType["Windows"] = 3] = "Windows"; PlatformType[PlatformType["Test"] = 4] = "Test"; PlatformType[PlatformType["Backend"] = 5] = "Backend"; })(PlatformType || (exports.PlatformType = PlatformType = {})); function getPlatformType(testableUserAgent) { var _a; // Check if 'process' is defined before accessing it if (typeof process !== 'undefined') { if (process.env && process.env.NODE_ENV == "test") { return PlatformType.Test; } } if (typeof window === 'undefined') { return PlatformType.Backend; } var userAgent; if (testableUserAgent) userAgent = testableUserAgent; else if (typeof navigator === 'object') userAgent = navigator.userAgent; var isIosWebview = /(iPhone|iPod|iPad|Macintosh).*AppleWebKit(?!.*Safari)/i.test(userAgent); var isAndroidWebview = /wv\)/i.test(userAgent); var isWindowsWebview = /Edg\//i.test(userAgent); if (isAndroidWebview) return PlatformType.Android; else if (isIosWebview) return PlatformType.iOS; //app in webview else // if window.chrome.webview exists return windows platform, because there is no way to tell from user agent string // between Win10 WebView2 and Web browser if (isWindowsWebview && typeof window === 'object' && ((_a = window.chrome) === null || _a === void 0 ? void 0 : _a.webview)) { return PlatformType.Windows; } else { return PlatformType.Web; } } exports.getPlatformType = getPlatformType; //# sourceMappingURL=dms-platform-type.js.map