UNPKG

portkey-ai

Version:
53 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isRunningInBrowser = exports.getBrowserInfo = void 0; function getBrowserInfo() { if (typeof navigator === 'undefined' || !navigator) { return null; } // NOTE: The order matters here! const browserPatterns = [ { key: 'edge', pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ }, { key: 'ie', pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ }, { key: 'ie', // eslint-disable-next-line no-useless-escape pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/, }, { key: 'chrome', pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/, }, { key: 'firefox', pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/, }, { key: 'safari', pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/, }, ]; // Find the FIRST matching browser for (const { key, pattern } of browserPatterns) { const match = pattern.exec(navigator.userAgent); if (match) { const major = match[1] || 0; const minor = match[2] || 0; const patch = match[3] || 0; return { browser: key, version: `${major}.${minor}.${patch}` }; } } return null; } exports.getBrowserInfo = getBrowserInfo; const isRunningInBrowser = () => { return ( // @ts-ignore typeof window !== 'undefined' && // @ts-ignore typeof window.document !== 'undefined' && // @ts-ignore typeof navigator !== 'undefined'); }; exports.isRunningInBrowser = isRunningInBrowser; //# sourceMappingURL=core.js.map