/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Inject, Injectable, PLATFORM_ID } from '@angular/core'; import { isPlatformBrowser } from '@angular/common'; import * as i0 from "@angular/core"; // Whether the current platform supports the V8 Break Iterator. The V8 check // is necessary to detect all Blink based browsers. let hasV8BreakIterator; // We need a try/catch around the reference to `Intl`, because accessing it in some cases can // cause IE to throw. These cases are tied to particular versions of Windows and can happen if // the consumer is providing a polyfilled `Map`. See: // https://github.com/Microsoft/ChakraCore/issues/3189 // https://github.com/angular/components/issues/15687 try { hasV8BreakIterator = typeof Intl !== 'undefined' && Intl.v8BreakIterator; } catch { hasV8BreakIterator = false; } /** * Service to detect the current platform by comparing the userAgent strings and * checking browser-specific global properties. */ export class Platform { constructor(_platformId) { this._platformId = _platformId; // We want to use the Angular platform check because if the Document is shimmed // without the navigator, the following checks will fail. This is preferred because // sometimes the Document may be shimmed without the user's knowledge or intention /** Whether the Angular application is being rendered in the browser. */ this.isBrowser = this._platformId ? isPlatformBrowser(this._platformId) : typeof document === 'object' && !!document; /** Whether the current browser is Microsoft Edge. */ this.EDGE = this.isBrowser && /(edge)/i.test(navigator.userAgent); /** Whether the current rendering engine is Microsoft Trident. */ this.TRIDENT = this.isBrowser && /(msie|trident)/i.test(navigator.userAgent); // EdgeHTML and Trident mock Blink specific things and need to be excluded from this check. /** Whether the current rendering engine is Blink. */ this.BLINK = this.isBrowser && !!(window.chrome || hasV8BreakIterator) && typeof CSS !== 'undefined' && !this.EDGE && !this.TRIDENT; // Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to // ensure that Webkit runs standalone and is not used as another engine's base. /** Whether the current rendering engine is WebKit. */ this.WEBKIT = this.isBrowser && /AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT; /** Whether the current platform is Apple iOS. */ this.IOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window); // It's difficult to detect the plain Gecko engine, because most of the browsers identify // them self as Gecko-like browsers and modify the userAgent's according to that. // Since we only cover one explicit Firefox case, we can simply check for Firefox // instead of having an unstable check for Gecko. /** Whether the current browser is Firefox. */ this.FIREFOX = this.isBrowser && /(firefox|minefield)/i.test(navigator.userAgent); /** Whether the current platform is Android. */ // Trident on mobile adds the android platform to the userAgent to trick detections. this.ANDROID = this.isBrowser && /android/i.test(navigator.userAgent) && !this.TRIDENT; // Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake // this and just place the Safari keyword in the userAgent. To be more safe about Safari every // Safari browser should also use Webkit as its layout engine. /** Whether the current browser is Safari. */ this.SAFARI = this.isBrowser && /safari/i.test(navigator.userAgent) && this.WEBKIT; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: Platform, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: Platform, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: Platform, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return [{ type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID] }] }]; } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGxhdGZvcm0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3BsYXRmb3JtL3BsYXRmb3JtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxNQUFNLEVBQUUsVUFBVSxFQUFFLFdBQVcsRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUM5RCxPQUFPLEVBQUMsaUJBQW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