source: trip-planner-front/node_modules/@angular-devkit/build-angular/src/utils/build-browser-features.js

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

initial commit

  • Property mode set to 100644
File size: 3.1 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12}) : (function(o, m, k, k2) {
13 if (k2 === undefined) k2 = k;
14 o[k2] = m[k];
15}));
16var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17 Object.defineProperty(o, "default", { enumerable: true, value: v });
18}) : function(o, v) {
19 o["default"] = v;
20});
21var __importStar = (this && this.__importStar) || function (mod) {
22 if (mod && mod.__esModule) return mod;
23 var result = {};
24 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25 __setModuleDefault(result, mod);
26 return result;
27};
28var __importDefault = (this && this.__importDefault) || function (mod) {
29 return (mod && mod.__esModule) ? mod : { "default": mod };
30};
31Object.defineProperty(exports, "__esModule", { value: true });
32exports.BuildBrowserFeatures = void 0;
33const browserslist_1 = __importDefault(require("browserslist"));
34const caniuse_lite_1 = require("caniuse-lite");
35const ts = __importStar(require("typescript"));
36class BuildBrowserFeatures {
37 constructor(projectRoot) {
38 this.projectRoot = projectRoot;
39 this.supportedBrowsers = browserslist_1.default(undefined, { path: this.projectRoot });
40 }
41 /**
42 * True, when one or more browsers requires ES5
43 * support and the script target is ES2015 or greater.
44 */
45 isDifferentialLoadingNeeded(scriptTarget) {
46 const es6TargetOrLater = scriptTarget > ts.ScriptTarget.ES5;
47 return es6TargetOrLater && this.isEs5SupportNeeded();
48 }
49 /**
50 * True, when one or more browsers requires ES5 support
51 */
52 isEs5SupportNeeded() {
53 return !this.isFeatureSupported('es6-module');
54 }
55 /**
56 * True, when a browser feature is supported partially or fully.
57 */
58 isFeatureSupported(featureId) {
59 // y: feature is fully available
60 // n: feature is unavailable
61 // a: feature is partially supported
62 // x: feature is prefixed
63 const criteria = ['y', 'a'];
64 const data = caniuse_lite_1.feature(caniuse_lite_1.features[featureId]);
65 return !this.supportedBrowsers.some((browser) => {
66 const [agentId, version] = browser.split(' ');
67 const browserData = data.stats[agentId];
68 const featureStatus = (browserData && browserData[version]);
69 // We are only interested in the first character
70 // Ex: when 'a #4 #5', we only need to check for 'a'
71 // as for such cases we should polyfill these features as needed
72 return !featureStatus || !criteria.includes(featureStatus.charAt(0));
73 });
74 }
75}
76exports.BuildBrowserFeatures = BuildBrowserFeatures;
Note: See TracBrowser for help on using the repository browser.