source: trip-planner-front/node_modules/@angular/cdk/fesm2015/platform.js@ fa375fe

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

initial commit

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