source: trip-planner-front/node_modules/@angular/compiler-cli/ngcc/src/host/commonjs_host.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: 37.0 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8(function (factory) {
9 if (typeof module === "object" && typeof module.exports === "object") {
10 var v = factory(require, exports);
11 if (v !== undefined) module.exports = v;
12 }
13 else if (typeof define === "function" && define.amd) {
14 define("@angular/compiler-cli/ngcc/src/host/commonjs_host", ["require", "exports", "tslib", "typescript", "@angular/compiler-cli/src/ngtsc/file_system", "@angular/compiler-cli/ngcc/src/utils", "@angular/compiler-cli/ngcc/src/host/commonjs_umd_utils", "@angular/compiler-cli/ngcc/src/host/esm2015_host", "@angular/compiler-cli/ngcc/src/host/esm5_host"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.CommonJsReflectionHost = void 0;
20 var tslib_1 = require("tslib");
21 var ts = require("typescript");
22 var file_system_1 = require("@angular/compiler-cli/src/ngtsc/file_system");
23 var utils_1 = require("@angular/compiler-cli/ngcc/src/utils");
24 var commonjs_umd_utils_1 = require("@angular/compiler-cli/ngcc/src/host/commonjs_umd_utils");
25 var esm2015_host_1 = require("@angular/compiler-cli/ngcc/src/host/esm2015_host");
26 var esm5_host_1 = require("@angular/compiler-cli/ngcc/src/host/esm5_host");
27 var CommonJsReflectionHost = /** @class */ (function (_super) {
28 tslib_1.__extends(CommonJsReflectionHost, _super);
29 function CommonJsReflectionHost(logger, isCore, src, dts) {
30 if (dts === void 0) { dts = null; }
31 var _this = _super.call(this, logger, isCore, src, dts) || this;
32 _this.commonJsExports = new utils_1.FactoryMap(function (sf) { return _this.computeExportsOfCommonJsModule(sf); });
33 _this.topLevelHelperCalls = new utils_1.FactoryMap(function (helperName) { return new utils_1.FactoryMap(function (sf) { return sf.statements.map(function (stmt) { return _this.getHelperCall(stmt, [helperName]); })
34 .filter(utils_1.isDefined); }); });
35 _this.program = src.program;
36 _this.compilerHost = src.host;
37 return _this;
38 }
39 CommonJsReflectionHost.prototype.getImportOfIdentifier = function (id) {
40 var requireCall = this.findCommonJsImport(id);
41 if (requireCall === null) {
42 return null;
43 }
44 return { from: requireCall.arguments[0].text, name: id.text };
45 };
46 CommonJsReflectionHost.prototype.getDeclarationOfIdentifier = function (id) {
47 return this.getCommonJsModuleDeclaration(id) || _super.prototype.getDeclarationOfIdentifier.call(this, id);
48 };
49 CommonJsReflectionHost.prototype.getExportsOfModule = function (module) {
50 return _super.prototype.getExportsOfModule.call(this, module) || this.commonJsExports.get(module.getSourceFile());
51 };
52 /**
53 * Search statements related to the given class for calls to the specified helper.
54 *
55 * In CommonJS these helper calls can be outside the class's IIFE at the top level of the
56 * source file. Searching the top level statements for helpers can be expensive, so we
57 * try to get helpers from the IIFE first and only fall back on searching the top level if
58 * no helpers are found.
59 *
60 * @param classSymbol the class whose helper calls we are interested in.
61 * @param helperNames the names of the helpers (e.g. `__decorate`) whose calls we are interested
62 * in.
63 * @returns an array of nodes of calls to the helper with the given name.
64 */
65 CommonJsReflectionHost.prototype.getHelperCallsForClass = function (classSymbol, helperNames) {
66 var esm5HelperCalls = _super.prototype.getHelperCallsForClass.call(this, classSymbol, helperNames);
67 if (esm5HelperCalls.length > 0) {
68 return esm5HelperCalls;
69 }
70 else {
71 var sourceFile = classSymbol.declaration.valueDeclaration.getSourceFile();
72 return this.getTopLevelHelperCalls(sourceFile, helperNames);
73 }
74 };
75 /**
76 * Find all the helper calls at the top level of a source file.
77 *
78 * We cache the helper calls per source file so that we don't have to keep parsing the code for
79 * each class in a file.
80 *
81 * @param sourceFile the source who may contain helper calls.
82 * @param helperNames the names of the helpers (e.g. `__decorate`) whose calls we are interested
83 * in.
84 * @returns an array of nodes of calls to the helper with the given name.
85 */
86 CommonJsReflectionHost.prototype.getTopLevelHelperCalls = function (sourceFile, helperNames) {
87 var _this = this;
88 var calls = [];
89 helperNames.forEach(function (helperName) {
90 var helperCallsMap = _this.topLevelHelperCalls.get(helperName);
91 calls.push.apply(calls, tslib_1.__spreadArray([], tslib_1.__read(helperCallsMap.get(sourceFile))));
92 });
93 return calls;
94 };
95 CommonJsReflectionHost.prototype.computeExportsOfCommonJsModule = function (sourceFile) {
96 var e_1, _a, e_2, _b;
97 var moduleMap = new Map();
98 try {
99 for (var _c = tslib_1.__values(this.getModuleStatements(sourceFile)), _d = _c.next(); !_d.done; _d = _c.next()) {
100 var statement = _d.value;
101 if (commonjs_umd_utils_1.isExportsStatement(statement)) {
102 var exportDeclaration = this.extractBasicCommonJsExportDeclaration(statement);
103 moduleMap.set(exportDeclaration.name, exportDeclaration.declaration);
104 }
105 else if (commonjs_umd_utils_1.isWildcardReexportStatement(statement)) {
106 var reexports = this.extractCommonJsWildcardReexports(statement, sourceFile);
107 try {
108 for (var reexports_1 = (e_2 = void 0, tslib_1.__values(reexports)), reexports_1_1 = reexports_1.next(); !reexports_1_1.done; reexports_1_1 = reexports_1.next()) {
109 var reexport = reexports_1_1.value;
110 moduleMap.set(reexport.name, reexport.declaration);
111 }
112 }
113 catch (e_2_1) { e_2 = { error: e_2_1 }; }
114 finally {
115 try {
116 if (reexports_1_1 && !reexports_1_1.done && (_b = reexports_1.return)) _b.call(reexports_1);
117 }
118 finally { if (e_2) throw e_2.error; }
119 }
120 }
121 else if (commonjs_umd_utils_1.isDefinePropertyReexportStatement(statement)) {
122 var exportDeclaration = this.extractCommonJsDefinePropertyExportDeclaration(statement);
123 if (exportDeclaration !== null) {
124 moduleMap.set(exportDeclaration.name, exportDeclaration.declaration);
125 }
126 }
127 }
128 }
129 catch (e_1_1) { e_1 = { error: e_1_1 }; }
130 finally {
131 try {
132 if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
133 }
134 finally { if (e_1) throw e_1.error; }
135 }
136 return moduleMap;
137 };
138 CommonJsReflectionHost.prototype.extractBasicCommonJsExportDeclaration = function (statement) {
139 var _a;
140 var exportExpression = commonjs_umd_utils_1.skipAliases(statement.expression.right);
141 var node = statement.expression.left;
142 var declaration = (_a = this.getDeclarationOfExpression(exportExpression)) !== null && _a !== void 0 ? _a : {
143 kind: 1 /* Inline */,
144 node: node,
145 implementation: exportExpression,
146 known: null,
147 viaModule: null,
148 };
149 return { name: node.name.text, declaration: declaration };
150 };
151 CommonJsReflectionHost.prototype.extractCommonJsWildcardReexports = function (statement, containingFile) {
152 var reexportArg = statement.expression.arguments[0];
153 var requireCall = commonjs_umd_utils_1.isRequireCall(reexportArg) ?
154 reexportArg :
155 ts.isIdentifier(reexportArg) ? commonjs_umd_utils_1.findRequireCallReference(reexportArg, this.checker) : null;
156 if (requireCall === null) {
157 return [];
158 }
159 var importPath = requireCall.arguments[0].text;
160 var importedFile = this.resolveModuleName(importPath, containingFile);
161 if (importedFile === undefined) {
162 return [];
163 }
164 var importedExports = this.getExportsOfModule(importedFile);
165 if (importedExports === null) {
166 return [];
167 }
168 var viaModule = commonjs_umd_utils_1.isExternalImport(importPath) ? importPath : null;
169 var reexports = [];
170 importedExports.forEach(function (declaration, name) {
171 if (viaModule !== null && declaration.viaModule === null) {
172 declaration = tslib_1.__assign(tslib_1.__assign({}, declaration), { viaModule: viaModule });
173 }
174 reexports.push({ name: name, declaration: declaration });
175 });
176 return reexports;
177 };
178 CommonJsReflectionHost.prototype.extractCommonJsDefinePropertyExportDeclaration = function (statement) {
179 var args = statement.expression.arguments;
180 var name = args[1].text;
181 var getterFnExpression = commonjs_umd_utils_1.extractGetterFnExpression(statement);
182 if (getterFnExpression === null) {
183 return null;
184 }
185 var declaration = this.getDeclarationOfExpression(getterFnExpression);
186 if (declaration !== null) {
187 return { name: name, declaration: declaration };
188 }
189 return {
190 name: name,
191 declaration: {
192 kind: 1 /* Inline */,
193 node: args[1],
194 implementation: getterFnExpression,
195 known: null,
196 viaModule: null,
197 },
198 };
199 };
200 CommonJsReflectionHost.prototype.findCommonJsImport = function (id) {
201 // Is `id` a namespaced property access, e.g. `Directive` in `core.Directive`?
202 // If so capture the symbol of the namespace, e.g. `core`.
203 var nsIdentifier = commonjs_umd_utils_1.findNamespaceOfIdentifier(id);
204 return nsIdentifier && commonjs_umd_utils_1.findRequireCallReference(nsIdentifier, this.checker);
205 };
206 /**
207 * Handle the case where the identifier represents a reference to a whole CommonJS
208 * module, i.e. the result of a call to `require(...)`.
209 *
210 * @param id the identifier whose declaration we are looking for.
211 * @returns a declaration if `id` refers to a CommonJS module, or `null` otherwise.
212 */
213 CommonJsReflectionHost.prototype.getCommonJsModuleDeclaration = function (id) {
214 var requireCall = commonjs_umd_utils_1.findRequireCallReference(id, this.checker);
215 if (requireCall === null) {
216 return null;
217 }
218 var importPath = requireCall.arguments[0].text;
219 var module = this.resolveModuleName(importPath, id.getSourceFile());
220 if (module === undefined) {
221 return null;
222 }
223 var viaModule = commonjs_umd_utils_1.isExternalImport(importPath) ? importPath : null;
224 return { node: module, known: null, viaModule: viaModule, identity: null, kind: 0 /* Concrete */ };
225 };
226 /**
227 * If this is an IFE then try to grab the outer and inner classes otherwise fallback on the super
228 * class.
229 */
230 CommonJsReflectionHost.prototype.getDeclarationOfExpression = function (expression) {
231 var inner = esm2015_host_1.getInnerClassDeclaration(expression);
232 if (inner !== null) {
233 var outer = esm2015_host_1.getOuterNodeFromInnerDeclaration(inner);
234 if (outer !== null && commonjs_umd_utils_1.isExportsAssignment(outer)) {
235 return {
236 kind: 1 /* Inline */,
237 node: outer.left,
238 implementation: inner,
239 known: null,
240 viaModule: null,
241 };
242 }
243 }
244 return _super.prototype.getDeclarationOfExpression.call(this, expression);
245 };
246 CommonJsReflectionHost.prototype.resolveModuleName = function (moduleName, containingFile) {
247 if (this.compilerHost.resolveModuleNames) {
248 var moduleInfo = this.compilerHost.resolveModuleNames([moduleName], containingFile.fileName, undefined, undefined, this.program.getCompilerOptions())[0];
249 return moduleInfo && this.program.getSourceFile(file_system_1.absoluteFrom(moduleInfo.resolvedFileName));
250 }
251 else {
252 var moduleInfo = ts.resolveModuleName(moduleName, containingFile.fileName, this.program.getCompilerOptions(), this.compilerHost);
253 return moduleInfo.resolvedModule &&
254 this.program.getSourceFile(file_system_1.absoluteFrom(moduleInfo.resolvedModule.resolvedFileName));
255 }
256 };
257 return CommonJsReflectionHost;
258 }(esm5_host_1.Esm5ReflectionHost));
259 exports.CommonJsReflectionHost = CommonJsReflectionHost;
260});
261//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbW9uanNfaG9zdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyLWNsaS9uZ2NjL3NyYy9ob3N0L2NvbW1vbmpzX2hvc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOzs7Ozs7Ozs7Ozs7OztJQUVILCtCQUFpQztJQUVqQywyRUFBNEQ7SUFJNUQsOERBQStDO0lBRS9DLDZGQUF5WDtJQUN6WCxpRkFBMEY7SUFDMUYsMkVBQStDO0lBRy9DO1FBQTRDLGtEQUFrQjtRQVU1RCxnQ0FBWSxNQUFjLEVBQUUsTUFBZSxFQUFFLEdBQWtCLEVBQUUsR0FBOEI7WUFBOUIsb0JBQUEsRUFBQSxVQUE4QjtZQUEvRixZQUNFLGtCQUFNLE1BQU0sRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLEdBQUcsQ0FBQyxTQUdoQztZQWJTLHFCQUFlLEdBQUcsSUFBSSxrQkFBVSxDQUN0QyxVQUFBLEVBQUUsSUFBSSxPQUFBLEtBQUksQ0FBQyw4QkFBOEIsQ0FBQyxFQUFFLENBQUMsRUFBdkMsQ0FBdUMsQ0FBQyxDQUFDO1lBQ3pDLHlCQUFtQixHQUN6QixJQUFJLGtCQUFVLENBQ1YsVUFBQSxVQUFVL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