1 | (function (factory) {
|
---|
2 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
3 | var v = factory(require, exports);
|
---|
4 | if (v !== undefined) module.exports = v;
|
---|
5 | }
|
---|
6 | else if (typeof define === "function" && define.amd) {
|
---|
7 | define("@angular/compiler-cli/ngcc/src/utils", ["require", "exports", "tslib", "typescript", "@angular/compiler-cli/src/ngtsc/file_system", "@angular/compiler-cli/src/ngtsc/reflection"], factory);
|
---|
8 | }
|
---|
9 | })(function (require, exports) {
|
---|
10 | "use strict";
|
---|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
12 | exports.stripExtension = exports.stripDollarSuffix = exports.getTsHelperFnFromIdentifier = exports.getTsHelperFnFromDeclaration = exports.resolveFileWithPostfixes = exports.FactoryMap = exports.isRelativePath = exports.hasNameIdentifier = exports.findAll = exports.getNameText = exports.isDefined = exports.getOriginalSymbol = void 0;
|
---|
13 | var tslib_1 = require("tslib");
|
---|
14 | /**
|
---|
15 | * @license
|
---|
16 | * Copyright Google LLC All Rights Reserved.
|
---|
17 | *
|
---|
18 | * Use of this source code is governed by an MIT-style license that can be
|
---|
19 | * found in the LICENSE file at https://angular.io/license
|
---|
20 | */
|
---|
21 | var ts = require("typescript");
|
---|
22 | var file_system_1 = require("@angular/compiler-cli/src/ngtsc/file_system");
|
---|
23 | var reflection_1 = require("@angular/compiler-cli/src/ngtsc/reflection");
|
---|
24 | function getOriginalSymbol(checker) {
|
---|
25 | return function (symbol) {
|
---|
26 | return ts.SymbolFlags.Alias & symbol.flags ? checker.getAliasedSymbol(symbol) : symbol;
|
---|
27 | };
|
---|
28 | }
|
---|
29 | exports.getOriginalSymbol = getOriginalSymbol;
|
---|
30 | function isDefined(value) {
|
---|
31 | return (value !== undefined) && (value !== null);
|
---|
32 | }
|
---|
33 | exports.isDefined = isDefined;
|
---|
34 | function getNameText(name) {
|
---|
35 | return ts.isIdentifier(name) || ts.isLiteralExpression(name) ? name.text : name.getText();
|
---|
36 | }
|
---|
37 | exports.getNameText = getNameText;
|
---|
38 | /**
|
---|
39 | * Parse down the AST and capture all the nodes that satisfy the test.
|
---|
40 | * @param node The start node.
|
---|
41 | * @param test The function that tests whether a node should be included.
|
---|
42 | * @returns a collection of nodes that satisfy the test.
|
---|
43 | */
|
---|
44 | function findAll(node, test) {
|
---|
45 | var nodes = [];
|
---|
46 | findAllVisitor(node);
|
---|
47 | return nodes;
|
---|
48 | function findAllVisitor(n) {
|
---|
49 | if (test(n)) {
|
---|
50 | nodes.push(n);
|
---|
51 | }
|
---|
52 | else {
|
---|
53 | n.forEachChild(function (child) { return findAllVisitor(child); });
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|
57 | exports.findAll = findAll;
|
---|
58 | /**
|
---|
59 | * Does the given declaration have a name which is an identifier?
|
---|
60 | * @param declaration The declaration to test.
|
---|
61 | * @returns true if the declaration has an identifier for a name.
|
---|
62 | */
|
---|
63 | function hasNameIdentifier(declaration) {
|
---|
64 | var namedDeclaration = declaration;
|
---|
65 | return namedDeclaration.name !== undefined && ts.isIdentifier(namedDeclaration.name);
|
---|
66 | }
|
---|
67 | exports.hasNameIdentifier = hasNameIdentifier;
|
---|
68 | /**
|
---|
69 | * Test whether a path is "relative".
|
---|
70 | *
|
---|
71 | * Relative paths start with `/`, `./` or `../` (or the Windows equivalents); or are simply `.` or
|
---|
72 | * `..`.
|
---|
73 | */
|
---|
74 | function isRelativePath(path) {
|
---|
75 | return file_system_1.isRooted(path) || /^\.\.?(\/|\\|$)/.test(path);
|
---|
76 | }
|
---|
77 | exports.isRelativePath = isRelativePath;
|
---|
78 | /**
|
---|
79 | * A `Map`-like object that can compute and memoize a missing value for any key.
|
---|
80 | *
|
---|
81 | * The computed values are memoized, so the factory function is not called more than once per key.
|
---|
82 | * This is useful for storing values that are expensive to compute and may be used multiple times.
|
---|
83 | */
|
---|
84 | // NOTE:
|
---|
85 | // Ideally, this class should extend `Map`, but that causes errors in ES5 transpiled code:
|
---|
86 | // `TypeError: Constructor Map requires 'new'`
|
---|
87 | var FactoryMap = /** @class */ (function () {
|
---|
88 | function FactoryMap(factory, entries) {
|
---|
89 | this.factory = factory;
|
---|
90 | this.internalMap = new Map(entries);
|
---|
91 | }
|
---|
92 | FactoryMap.prototype.get = function (key) {
|
---|
93 | if (!this.internalMap.has(key)) {
|
---|
94 | this.internalMap.set(key, this.factory(key));
|
---|
95 | }
|
---|
96 | return this.internalMap.get(key);
|
---|
97 | };
|
---|
98 | FactoryMap.prototype.set = function (key, value) {
|
---|
99 | this.internalMap.set(key, value);
|
---|
100 | };
|
---|
101 | return FactoryMap;
|
---|
102 | }());
|
---|
103 | exports.FactoryMap = FactoryMap;
|
---|
104 | /**
|
---|
105 | * Attempt to resolve a `path` to a file by appending the provided `postFixes`
|
---|
106 | * to the `path` and checking if the file exists on disk.
|
---|
107 | * @returns An absolute path to the first matching existing file, or `null` if none exist.
|
---|
108 | */
|
---|
109 | function resolveFileWithPostfixes(fs, path, postFixes) {
|
---|
110 | var e_1, _a;
|
---|
111 | try {
|
---|
112 | for (var postFixes_1 = tslib_1.__values(postFixes), postFixes_1_1 = postFixes_1.next(); !postFixes_1_1.done; postFixes_1_1 = postFixes_1.next()) {
|
---|
113 | var postFix = postFixes_1_1.value;
|
---|
114 | var testPath = file_system_1.absoluteFrom(path + postFix);
|
---|
115 | if (fs.exists(testPath) && fs.stat(testPath).isFile()) {
|
---|
116 | return testPath;
|
---|
117 | }
|
---|
118 | }
|
---|
119 | }
|
---|
120 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
121 | finally {
|
---|
122 | try {
|
---|
123 | if (postFixes_1_1 && !postFixes_1_1.done && (_a = postFixes_1.return)) _a.call(postFixes_1);
|
---|
124 | }
|
---|
125 | finally { if (e_1) throw e_1.error; }
|
---|
126 | }
|
---|
127 | return null;
|
---|
128 | }
|
---|
129 | exports.resolveFileWithPostfixes = resolveFileWithPostfixes;
|
---|
130 | /**
|
---|
131 | * Determine whether a function declaration corresponds with a TypeScript helper function, returning
|
---|
132 | * its kind if so or null if the declaration does not seem to correspond with such a helper.
|
---|
133 | */
|
---|
134 | function getTsHelperFnFromDeclaration(decl) {
|
---|
135 | if (!ts.isFunctionDeclaration(decl) && !ts.isVariableDeclaration(decl)) {
|
---|
136 | return null;
|
---|
137 | }
|
---|
138 | if (decl.name === undefined || !ts.isIdentifier(decl.name)) {
|
---|
139 | return null;
|
---|
140 | }
|
---|
141 | return getTsHelperFnFromIdentifier(decl.name);
|
---|
142 | }
|
---|
143 | exports.getTsHelperFnFromDeclaration = getTsHelperFnFromDeclaration;
|
---|
144 | /**
|
---|
145 | * Determine whether an identifier corresponds with a TypeScript helper function (based on its
|
---|
146 | * name), returning its kind if so or null if the identifier does not seem to correspond with such a
|
---|
147 | * helper.
|
---|
148 | */
|
---|
149 | function getTsHelperFnFromIdentifier(id) {
|
---|
150 | switch (stripDollarSuffix(id.text)) {
|
---|
151 | case '__assign':
|
---|
152 | return reflection_1.KnownDeclaration.TsHelperAssign;
|
---|
153 | case '__spread':
|
---|
154 | return reflection_1.KnownDeclaration.TsHelperSpread;
|
---|
155 | case '__spreadArrays':
|
---|
156 | return reflection_1.KnownDeclaration.TsHelperSpreadArrays;
|
---|
157 | case '__spreadArray':
|
---|
158 | return reflection_1.KnownDeclaration.TsHelperSpreadArray;
|
---|
159 | case '__read':
|
---|
160 | return reflection_1.KnownDeclaration.TsHelperRead;
|
---|
161 | default:
|
---|
162 | return null;
|
---|
163 | }
|
---|
164 | }
|
---|
165 | exports.getTsHelperFnFromIdentifier = getTsHelperFnFromIdentifier;
|
---|
166 | /**
|
---|
167 | * An identifier may become repeated when bundling multiple source files into a single bundle, so
|
---|
168 | * bundlers have a strategy of suffixing non-unique identifiers with a suffix like $2. This function
|
---|
169 | * strips off such suffixes, so that ngcc deals with the canonical name of an identifier.
|
---|
170 | * @param value The value to strip any suffix of, if applicable.
|
---|
171 | * @returns The canonical representation of the value, without any suffix.
|
---|
172 | */
|
---|
173 | function stripDollarSuffix(value) {
|
---|
174 | return value.replace(/\$\d+$/, '');
|
---|
175 | }
|
---|
176 | exports.stripDollarSuffix = stripDollarSuffix;
|
---|
177 | function stripExtension(fileName) {
|
---|
178 | return fileName.replace(/\..+$/, '');
|
---|
179 | }
|
---|
180 | exports.stripExtension = stripExtension;
|
---|
181 | });
|
---|
182 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci1jbGkvbmdjYy9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7OztJQUFBOzs7Ozs7T0FNRztJQUNILCtCQUFpQztJQUVqQywyRUFBdUc7SUFDdkcseUVBQTZFO0lBd0I3RSxTQUFnQixpQkFBaUIsQ0FBQyxPQUF1QjtRQUN2RCxPQUFPLFVBQVMsTUFBaUI7WUFDL0IsT0FBTyxFQUFFLENBQUMsV0FBVyxDQUFDLEtBQUssR0FBRyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQztRQUN6RixDQUFDLENBQUM7SUFDSixDQUFDO0lBSkQsOENBSUM7SUFFRCxTQUFnQixTQUFTLENBQUksS0FBdUI7UUFDbEQsT0FBTyxDQUFDLEtBQUssS0FBSyxTQUFTLENBQUMsSUFBSSxDQUFDLEtBQUssS0FBSyxJQUFJLENBQUMsQ0FBQztJQUNuRCxDQUFDO0lBRkQsOEJBRUM7SUFFRCxTQUFnQixXQUFXLENBQUMsSUFBb0M7UUFDOUQsT0FBTyxFQUFFLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxtQkFBbUIsQ0FBQyxJQUFJLENB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