1 | /**
|
2 | * @license
|
3 | * Copyright Google LLC All Rights Reserved.
|
4 | *
|
5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | * found in the LICENSE file at https://angular.io/license
|
7 | */
|
8 | import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
|
9 | import { isPlatformBrowser } from '@angular/common';
|
10 | import * as i0 from "@angular/core";
|
11 | // Whether the current platform supports the V8 Break Iterator. The V8 check
|
12 | // is necessary to detect all Blink based browsers.
|
13 | let hasV8BreakIterator;
|
14 | // We need a try/catch around the reference to `Intl`, because accessing it in some cases can
|
15 | // cause IE to throw. These cases are tied to particular versions of Windows and can happen if
|
16 | // the consumer is providing a polyfilled `Map`. See:
|
17 | // https://github.com/Microsoft/ChakraCore/issues/3189
|
18 | // https://github.com/angular/components/issues/15687
|
19 | try {
|
20 | hasV8BreakIterator = typeof Intl !== 'undefined' && Intl.v8BreakIterator;
|
21 | }
|
22 | catch {
|
23 | hasV8BreakIterator = false;
|
24 | }
|
25 | /**
|
26 | * Service to detect the current platform by comparing the userAgent strings and
|
27 | * checking browser-specific global properties.
|
28 | */
|
29 | class Platform {
|
30 | constructor(_platformId) {
|
31 | this._platformId = _platformId;
|
32 | // We want to use the Angular platform check because if the Document is shimmed
|
33 | // without the navigator, the following checks will fail. This is preferred because
|
34 | // sometimes the Document may be shimmed without the user's knowledge or intention
|
35 | /** Whether the Angular application is being rendered in the browser. */
|
36 | this.isBrowser = this._platformId
|
37 | ? isPlatformBrowser(this._platformId)
|
38 | : typeof document === 'object' && !!document;
|
39 | /** Whether the current browser is Microsoft Edge. */
|
40 | this.EDGE = this.isBrowser && /(edge)/i.test(navigator.userAgent);
|
41 | /** Whether the current rendering engine is Microsoft Trident. */
|
42 | this.TRIDENT = this.isBrowser && /(msie|trident)/i.test(navigator.userAgent);
|
43 | // EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
|
44 | /** Whether the current rendering engine is Blink. */
|
45 | this.BLINK = this.isBrowser &&
|
46 | !!(window.chrome || hasV8BreakIterator) &&
|
47 | typeof CSS !== 'undefined' &&
|
48 | !this.EDGE &&
|
49 | !this.TRIDENT;
|
50 | // Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
|
51 | // ensure that Webkit runs standalone and is not used as another engine's base.
|
52 | /** Whether the current rendering engine is WebKit. */
|
53 | this.WEBKIT = this.isBrowser &&
|
54 | /AppleWebKit/i.test(navigator.userAgent) &&
|
55 | !this.BLINK &&
|
56 | !this.EDGE &&
|
57 | !this.TRIDENT;
|
58 | /** Whether the current platform is Apple iOS. */
|
59 | this.IOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);
|
60 | // It's difficult to detect the plain Gecko engine, because most of the browsers identify
|
61 | // them self as Gecko-like browsers and modify the userAgent's according to that.
|
62 | // Since we only cover one explicit Firefox case, we can simply check for Firefox
|
63 | // instead of having an unstable check for Gecko.
|
64 | /** Whether the current browser is Firefox. */
|
65 | this.FIREFOX = this.isBrowser && /(firefox|minefield)/i.test(navigator.userAgent);
|
66 | /** Whether the current platform is Android. */
|
67 | // Trident on mobile adds the android platform to the userAgent to trick detections.
|
68 | this.ANDROID = this.isBrowser && /android/i.test(navigator.userAgent) && !this.TRIDENT;
|
69 | // Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake
|
70 | // this and just place the Safari keyword in the userAgent. To be more safe about Safari every
|
71 | // Safari browser should also use Webkit as its layout engine.
|
72 | /** Whether the current browser is Safari. */
|
73 | this.SAFARI = this.isBrowser && /safari/i.test(navigator.userAgent) && this.WEBKIT;
|
74 | }
|
75 | static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: Platform, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
76 | static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: Platform, providedIn: 'root' }); }
|
77 | }
|
78 | export { Platform };
|
79 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: Platform, decorators: [{
|
80 | type: Injectable,
|
81 | args: [{ providedIn: 'root' }]
|
82 | }], ctorParameters: function () { return [{ type: Object, decorators: [{
|
83 | type: Inject,
|
84 | args: [PLATFORM_ID]
|
85 | }] }]; } });
|
86 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGxhdGZvcm0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3BsYXRmb3JtL3BsYXRmb3JtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxNQUFNLEVBQUUsVUFBVSxFQUFFLFdBQVcsRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUM5RCxPQUFPLEVBQUMsaUJBQWlCLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQzs7QUFFbEQsNEVBQTRFO0FBQzVFLG1EQUFtRDtBQUNuRCxJQUFJLGtCQUEyQixDQUFDO0FBRWhDLDZGQUE2RjtBQUM3Riw4RkFBOEY7QUFDOUYscURBQXFEO0FBQ3JELHNEQUFzRDtBQUN0RCxxREFBcUQ7QUFDckQsSUFBSTtJQUNGLGtCQUFrQixHQUFHLE9BQU8sSUFBSSxLQUFLLFdBQVcsSUFBSyxJQUFZLENBQUMsZUFBZSxDQUFDO0NBQ25GO0FBQUMsTUFBTTtJQUNOLGtCQUFrQixHQUFHLEtBQUssQ0FBQztDQUM1QjtBQUVEOzs7R0FHRztBQUNILE1BQ2EsUUFBUTtJQXVEbkIsWUFBeUMsV0FBbUI7UUFBbkIsZ0JBQVcsR0FBWCxXQUFXLENBQVE7UUF0RDVELCtFQUErRTtRQUMvRSxtRkFBbUY7UUFDbkYsa0ZBQWtGO1FBQ2xGLHdFQUF3RTtRQUN4RSx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