platform-DmdVEw_C.mjs 4.2 KB

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