source: trip-planner-front/node_modules/@angular/cdk/__ivy_ngcc__/fesm2015/platform.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 16.1 KB
Line 
1import * as i0 from '@angular/core';
2import { Injectable, Inject, PLATFORM_ID, NgModule } from '@angular/core';
3import { isPlatformBrowser } from '@angular/common';
4
5/**
6 * @license
7 * Copyright Google LLC All Rights Reserved.
8 *
9 * Use of this source code is governed by an MIT-style license that can be
10 * found in the LICENSE file at https://angular.io/license
11 */
12// Whether the current platform supports the V8 Break Iterator. The V8 check
13// is necessary to detect all Blink based browsers.
14import * as ɵngcc0 from '@angular/core';
15let hasV8BreakIterator;
16// We need a try/catch around the reference to `Intl`, because accessing it in some cases can
17// cause IE to throw. These cases are tied to particular versions of Windows and can happen if
18// the consumer is providing a polyfilled `Map`. See:
19// https://github.com/Microsoft/ChakraCore/issues/3189
20// https://github.com/angular/components/issues/15687
21try {
22 hasV8BreakIterator = (typeof Intl !== 'undefined' && Intl.v8BreakIterator);
23}
24catch (_a) {
25 hasV8BreakIterator = false;
26}
27/**
28 * Service to detect the current platform by comparing the userAgent strings and
29 * checking browser-specific global properties.
30 */
31class Platform {
32 constructor(_platformId) {
33 this._platformId = _platformId;
34 // We want to use the Angular platform check because if the Document is shimmed
35 // without the navigator, the following checks will fail. This is preferred because
36 // sometimes the Document may be shimmed without the user's knowledge or intention
37 /** Whether the Angular application is being rendered in the browser. */
38 this.isBrowser = this._platformId ?
39 isPlatformBrowser(this._platformId) : typeof document === 'object' && !!document;
40 /** Whether the current browser is Microsoft Edge. */
41 this.EDGE = this.isBrowser && /(edge)/i.test(navigator.userAgent);
42 /** Whether the current rendering engine is Microsoft Trident. */
43 this.TRIDENT = this.isBrowser && /(msie|trident)/i.test(navigator.userAgent);
44 // EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
45 /** Whether the current rendering engine is Blink. */
46 this.BLINK = this.isBrowser && (!!(window.chrome || hasV8BreakIterator) &&
47 typeof CSS !== 'undefined' && !this.EDGE && !this.TRIDENT);
48 // Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
49 // ensure that Webkit runs standalone and is not used as another engine's base.
50 /** Whether the current rendering engine is WebKit. */
51 this.WEBKIT = this.isBrowser &&
52 /AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT;
53 /** Whether the current platform is Apple iOS. */
54 this.IOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) &&
55 !('MSStream' in window);
56 // It's difficult to detect the plain Gecko engine, because most of the browsers identify
57 // them self as Gecko-like browsers and modify the userAgent's according to that.
58 // Since we only cover one explicit Firefox case, we can simply check for Firefox
59 // instead of having an unstable check for Gecko.
60 /** Whether the current browser is Firefox. */
61 this.FIREFOX = this.isBrowser && /(firefox|minefield)/i.test(navigator.userAgent);
62 /** Whether the current platform is Android. */
63 // Trident on mobile adds the android platform to the userAgent to trick detections.
64 this.ANDROID = this.isBrowser && /android/i.test(navigator.userAgent) && !this.TRIDENT;
65 // Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake
66 // this and just place the Safari keyword in the userAgent. To be more safe about Safari every
67 // Safari browser should also use Webkit as its layout engine.
68 /** Whether the current browser is Safari. */
69 this.SAFARI = this.isBrowser && /safari/i.test(navigator.userAgent) && this.WEBKIT;
70 }
71}
72Platform.ɵfac = function Platform_Factory(t) { return new (t || Platform)(ɵngcc0.ɵɵinject(PLATFORM_ID)); };
73Platform.ɵprov = i0.ɵɵdefineInjectable({ factory: function Platform_Factory() { return new Platform(i0.ɵɵinject(i0.PLATFORM_ID)); }, token: Platform, providedIn: "root" });
74Platform.ctorParameters = () => [
75 { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }
76];
77(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(Platform, [{
78 type: Injectable,
79 args: [{ providedIn: 'root' }]
80 }], function () { return [{ type: Object, decorators: [{
81 type: Inject,
82 args: [PLATFORM_ID]
83 }] }]; }, null); })();
84
85/**
86 * @license
87 * Copyright Google LLC All Rights Reserved.
88 *
89 * Use of this source code is governed by an MIT-style license that can be
90 * found in the LICENSE file at https://angular.io/license
91 */
92class PlatformModule {
93}
94PlatformModule.ɵfac = function PlatformModule_Factory(t) { return new (t || PlatformModule)(); };
95PlatformModule.ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({ type: PlatformModule });
96PlatformModule.ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({});
97(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(PlatformModule, [{
98 type: NgModule,
99 args: [{}]
100 }], null, null); })();
101
102/**
103 * @license
104 * Copyright Google LLC All Rights Reserved.
105 *
106 * Use of this source code is governed by an MIT-style license that can be
107 * found in the LICENSE file at https://angular.io/license
108 */
109/** Cached result Set of input types support by the current browser. */
110let supportedInputTypes;
111/** Types of `<input>` that *might* be supported. */
112const candidateInputTypes = [
113 // `color` must come first. Chrome 56 shows a warning if we change the type to `color` after
114 // first changing it to something else:
115 // The specified value "" does not conform to the required format.
116 // The format is "#rrggbb" where rr, gg, bb are two-digit hexadecimal numbers.
117 'color',
118 'button',
119 'checkbox',
120 'date',
121 'datetime-local',
122 'email',
123 'file',
124 'hidden',
125 'image',
126 'month',
127 'number',
128 'password',
129 'radio',
130 'range',
131 'reset',
132 'search',
133 'submit',
134 'tel',
135 'text',
136 'time',
137 'url',
138 'week',
139];
140/** @returns The input types supported by this browser. */
141function getSupportedInputTypes() {
142 // Result is cached.
143 if (supportedInputTypes) {
144 return supportedInputTypes;
145 }
146 // We can't check if an input type is not supported until we're on the browser, so say that
147 // everything is supported when not on the browser. We don't use `Platform` here since it's
148 // just a helper function and can't inject it.
149 if (typeof document !== 'object' || !document) {
150 supportedInputTypes = new Set(candidateInputTypes);
151 return supportedInputTypes;
152 }
153 let featureTestInput = document.createElement('input');
154 supportedInputTypes = new Set(candidateInputTypes.filter(value => {
155 featureTestInput.setAttribute('type', value);
156 return featureTestInput.type === value;
157 }));
158 return supportedInputTypes;
159}
160
161/**
162 * @license
163 * Copyright Google LLC All Rights Reserved.
164 *
165 * Use of this source code is governed by an MIT-style license that can be
166 * found in the LICENSE file at https://angular.io/license
167 */
168/** Cached result of whether the user's browser supports passive event listeners. */
169let supportsPassiveEvents;
170/**
171 * Checks whether the user's browser supports passive event listeners.
172 * See: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
173 */
174function supportsPassiveEventListeners() {
175 if (supportsPassiveEvents == null && typeof window !== 'undefined') {
176 try {
177 window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
178 get: () => supportsPassiveEvents = true
179 }));
180 }
181 finally {
182 supportsPassiveEvents = supportsPassiveEvents || false;
183 }
184 }
185 return supportsPassiveEvents;
186}
187/**
188 * Normalizes an `AddEventListener` object to something that can be passed
189 * to `addEventListener` on any browser, no matter whether it supports the
190 * `options` parameter.
191 * @param options Object to be normalized.
192 */
193function normalizePassiveListenerOptions(options) {
194 return supportsPassiveEventListeners() ? options : !!options.capture;
195}
196
197/**
198 * @license
199 * Copyright Google LLC All Rights Reserved.
200 *
201 * Use of this source code is governed by an MIT-style license that can be
202 * found in the LICENSE file at https://angular.io/license
203 */
204/** Cached result of the way the browser handles the horizontal scroll axis in RTL mode. */
205let rtlScrollAxisType;
206/** Cached result of the check that indicates whether the browser supports scroll behaviors. */
207let scrollBehaviorSupported;
208/** Check whether the browser supports scroll behaviors. */
209function supportsScrollBehavior() {
210 if (scrollBehaviorSupported == null) {
211 // If we're not in the browser, it can't be supported. Also check for `Element`, because
212 // some projects stub out the global `document` during SSR which can throw us off.
213 if (typeof document !== 'object' || !document || typeof Element !== 'function' || !Element) {
214 scrollBehaviorSupported = false;
215 return scrollBehaviorSupported;
216 }
217 // If the element can have a `scrollBehavior` style, we can be sure that it's supported.
218 if ('scrollBehavior' in document.documentElement.style) {
219 scrollBehaviorSupported = true;
220 }
221 else {
222 // At this point we have 3 possibilities: `scrollTo` isn't supported at all, it's
223 // supported but it doesn't handle scroll behavior, or it has been polyfilled.
224 const scrollToFunction = Element.prototype.scrollTo;
225 if (scrollToFunction) {
226 // We can detect if the function has been polyfilled by calling `toString` on it. Native
227 // functions are obfuscated using `[native code]`, whereas if it was overwritten we'd get
228 // the actual function source. Via https://davidwalsh.name/detect-native-function. Consider
229 // polyfilled functions as supporting scroll behavior.
230 scrollBehaviorSupported = !/\{\s*\[native code\]\s*\}/.test(scrollToFunction.toString());
231 }
232 else {
233 scrollBehaviorSupported = false;
234 }
235 }
236 }
237 return scrollBehaviorSupported;
238}
239/**
240 * Checks the type of RTL scroll axis used by this browser. As of time of writing, Chrome is NORMAL,
241 * Firefox & Safari are NEGATED, and IE & Edge are INVERTED.
242 */
243function getRtlScrollAxisType() {
244 // We can't check unless we're on the browser. Just assume 'normal' if we're not.
245 if (typeof document !== 'object' || !document) {
246 return 0 /* NORMAL */;
247 }
248 if (rtlScrollAxisType == null) {
249 // Create a 1px wide scrolling container and a 2px wide content element.
250 const scrollContainer = document.createElement('div');
251 const containerStyle = scrollContainer.style;
252 scrollContainer.dir = 'rtl';
253 containerStyle.width = '1px';
254 containerStyle.overflow = 'auto';
255 containerStyle.visibility = 'hidden';
256 containerStyle.pointerEvents = 'none';
257 containerStyle.position = 'absolute';
258 const content = document.createElement('div');
259 const contentStyle = content.style;
260 contentStyle.width = '2px';
261 contentStyle.height = '1px';
262 scrollContainer.appendChild(content);
263 document.body.appendChild(scrollContainer);
264 rtlScrollAxisType = 0 /* NORMAL */;
265 // The viewport starts scrolled all the way to the right in RTL mode. If we are in a NORMAL
266 // browser this would mean that the scrollLeft should be 1. If it's zero instead we know we're
267 // dealing with one of the other two types of browsers.
268 if (scrollContainer.scrollLeft === 0) {
269 // In a NEGATED browser the scrollLeft is always somewhere in [-maxScrollAmount, 0]. For an
270 // INVERTED browser it is always somewhere in [0, maxScrollAmount]. We can determine which by
271 // setting to the scrollLeft to 1. This is past the max for a NEGATED browser, so it will
272 // return 0 when we read it again.
273 scrollContainer.scrollLeft = 1;
274 rtlScrollAxisType =
275 scrollContainer.scrollLeft === 0 ? 1 /* NEGATED */ : 2 /* INVERTED */;
276 }
277 scrollContainer.parentNode.removeChild(scrollContainer);
278 }
279 return rtlScrollAxisType;
280}
281
282/**
283 * @license
284 * Copyright Google LLC All Rights Reserved.
285 *
286 * Use of this source code is governed by an MIT-style license that can be
287 * found in the LICENSE file at https://angular.io/license
288 */
289let shadowDomIsSupported;
290/** Checks whether the user's browser support Shadow DOM. */
291function _supportsShadowDom() {
292 if (shadowDomIsSupported == null) {
293 const head = typeof document !== 'undefined' ? document.head : null;
294 shadowDomIsSupported = !!(head && (head.createShadowRoot || head.attachShadow));
295 }
296 return shadowDomIsSupported;
297}
298/** Gets the shadow root of an element, if supported and the element is inside the Shadow DOM. */
299function _getShadowRoot(element) {
300 if (_supportsShadowDom()) {
301 const rootNode = element.getRootNode ? element.getRootNode() : null;
302 // Note that this should be caught by `_supportsShadowDom`, but some
303 // teams have been able to hit this code path on unsupported browsers.
304 if (typeof ShadowRoot !== 'undefined' && ShadowRoot && rootNode instanceof ShadowRoot) {
305 return rootNode;
306 }
307 }
308 return null;
309}
310/**
311 * Gets the currently-focused element on the page while
312 * also piercing through Shadow DOM boundaries.
313 */
314function _getFocusedElementPierceShadowDom() {
315 let activeElement = typeof document !== 'undefined' && document ?
316 document.activeElement : null;
317 while (activeElement && activeElement.shadowRoot) {
318 const newActiveElement = activeElement.shadowRoot.activeElement;
319 if (newActiveElement === activeElement) {
320 break;
321 }
322 else {
323 activeElement = newActiveElement;
324 }
325 }
326 return activeElement;
327}
328/** Gets the target of an event while accounting for Shadow DOM. */
329function _getEventTarget(event) {
330 // If an event is bound outside the Shadow DOM, the `event.target` will
331 // point to the shadow root so we have to use `composedPath` instead.
332 return (event.composedPath ? event.composedPath()[0] : event.target);
333}
334
335/**
336 * @license
337 * Copyright Google LLC All Rights Reserved.
338 *
339 * Use of this source code is governed by an MIT-style license that can be
340 * found in the LICENSE file at https://angular.io/license
341 */
342let testGlobals;
343// We check the Node-specific `global` first, because tools tend to add a fake
344// `window` in Node environments which won't actually receive global variables.
345if (typeof global !== 'undefined') {
346 testGlobals = global;
347}
348else if (typeof window !== 'undefined') {
349 testGlobals = window;
350}
351else {
352 testGlobals = {};
353}
354/** Gets whether the code is currently running in a test environment. */
355function _isTestEnvironment() {
356 return (typeof testGlobals.__karma__ !== 'undefined' && !!testGlobals.__karma__) ||
357 (typeof testGlobals.jasmine !== 'undefined' && !!testGlobals.jasmine) ||
358 (typeof testGlobals.jest !== 'undefined' && !!testGlobals.jest) ||
359 (typeof testGlobals.Mocha !== 'undefined' && !!testGlobals.Mocha);
360}
361
362/**
363 * @license
364 * Copyright Google LLC All Rights Reserved.
365 *
366 * Use of this source code is governed by an MIT-style license that can be
367 * found in the LICENSE file at https://angular.io/license
368 */
369
370/**
371 * Generated bundle index. Do not edit.
372 */
373
374export { Platform, PlatformModule, _getEventTarget, _getFocusedElementPierceShadowDom, _getShadowRoot, _isTestEnvironment, _supportsShadowDom, getRtlScrollAxisType, getSupportedInputTypes, normalizePassiveListenerOptions, supportsPassiveEventListeners, supportsScrollBehavior };
375
376//# sourceMappingURL=platform.js.map
Note: See TracBrowser for help on using the repository browser.