mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
1 line
18 KiB
JSON
1 line
18 KiB
JSON
|
|
{"ast":null,"code":"import _asyncToGenerator from \"C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { WebPlugin } from '@capacitor/core';\nexport class DeviceWeb extends WebPlugin {\n getId() {\n var _this = this;\n return _asyncToGenerator(function* () {\n return {\n uuid: _this.getUid()\n };\n })();\n }\n getInfo() {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n if (typeof navigator === 'undefined' || !navigator.userAgent) {\n throw _this2.unavailable('Device API not available in this browser');\n }\n const ua = navigator.userAgent;\n const uaFields = _this2.parseUa(ua);\n return {\n model: uaFields.model,\n platform: 'web',\n operatingSystem: uaFields.operatingSystem,\n osVersion: uaFields.osVersion,\n manufacturer: navigator.vendor,\n isVirtual: false,\n webViewVersion: uaFields.browserVersion\n };\n })();\n }\n getBatteryInfo() {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n if (typeof navigator === 'undefined' || !navigator.getBattery) {\n throw _this3.unavailable('Device API not available in this browser');\n }\n let battery = {};\n try {\n battery = yield navigator.getBattery();\n } catch (e) {\n // Let it fail, we don't care\n }\n return {\n batteryLevel: battery.level,\n isCharging: battery.charging\n };\n })();\n }\n getLanguageCode() {\n return _asyncToGenerator(function* () {\n return {\n value: navigator.language.split('-')[0].toLowerCase()\n };\n })();\n }\n getLanguageTag() {\n return _asyncToGenerator(function* () {\n return {\n value: navigator.language\n };\n })();\n }\n parseUa(ua) {\n const uaFields = {};\n const start = ua.indexOf('(') + 1;\n let end = ua.indexOf(') AppleWebKit');\n if (ua.indexOf(') Gecko') !== -1) {\n end = ua.indexOf(') Gecko');\n }\n const fields = ua.substring(start, end);\n if (ua.indexOf('Android') !== -1) {\n const tmpFields = fields.replace('; wv', '').split('; ').pop();\n if (tmpFields) {\n uaFields.model = tmpFields.split(' Build')[0];\n }\n uaFields.osVersion = fields.split('; ')[1];\n } else {\n uaFields.model = fields.split('; ')[0];\n if (typeof navigator !== 'undefined' && navigator.oscpu) {\n uaFields.osVersion = navigator.oscpu;\n } else {\n if (ua.indexOf('Windows') !== -1) {\n uaFields.osVersion = fields;\n } else {\n const tmpFields = fields.split('; ').pop();\n if (tmpFields) {\n const lastParts = tmpFields.replace(' like Mac OS X', '').split(' ');\n uaFields.osVersion = lastParts[lastParts.length - 1].replace(/_/g, '.');\n }\n }\n }\n }\n if (/android/i.test(ua)) {\n uaFields.operatingSystem = 'android';\n } else if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) {\n uaFields.operatingSystem = 'ios';\n } else if (/Win/.test(ua)) {\n uaFields.operatingSystem = 'windows';\n } else if (/Mac/i.test(ua)) {\n uaFields.operatingSystem = 'mac';\n } else {\n uaFields.operatingSystem = 'unknown';\n }\n // Check for browsers based on non-standard javascript apis, only not user agent\n const isFirefox = !!window.InstallTrigger;\n const isSafari = !!window.ApplePaySession;\n const isChrome = !!window.chrome;\n const isEdge = /Edg/.test(ua);\n const isFirefoxIOS = /FxiOS/.test(ua);\n const isChromeIOS = /CriOS/.test(ua);\n const isEdgeIOS = /EdgiOS/.test(ua);\n // FF and Edge User Agents both end with \"/MAJOR.MINOR\"\n if (isSafari || isChrome && !isEdge || isFirefoxIOS || isChromeIOS || isEdgeIOS) {\n // Safari version comes as \"... Version/MAJOR.MINOR ...\"\n // Chrome version comes as \"... Chrome/MAJOR.MINOR ...\"\n // FirefoxIOS versi
|