source: trip-planner-front/node_modules/@angular/compiler-cli/src/transformers/metadata_reader.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: 15.8 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/src/transformers/metadata_reader", ["require", "exports", "tslib", "@angular/compiler-cli/src/metadata/index", "@angular/compiler-cli/src/transformers/util"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.readMetadata = exports.createMetadataReaderCache = void 0;
20 var tslib_1 = require("tslib");
21 var metadata_1 = require("@angular/compiler-cli/src/metadata/index");
22 var util_1 = require("@angular/compiler-cli/src/transformers/util");
23 function createMetadataReaderCache() {
24 var data = new Map();
25 return { data: data };
26 }
27 exports.createMetadataReaderCache = createMetadataReaderCache;
28 function readMetadata(filePath, host, cache) {
29 var metadatas = cache && cache.data.get(filePath);
30 if (metadatas) {
31 return metadatas;
32 }
33 if (host.fileExists(filePath)) {
34 // If the file doesn't exists then we cannot return metadata for the file.
35 // This will occur if the user referenced a declared module for which no file
36 // exists for the module (i.e. jQuery or angularjs).
37 if (util_1.DTS.test(filePath)) {
38 metadatas = readMetadataFile(host, filePath);
39 if (!metadatas) {
40 // If there is a .d.ts file but no metadata file we need to produce a
41 // metadata from the .d.ts file as metadata files capture reexports
42 // (starting with v3).
43 metadatas = [upgradeMetadataWithDtsData(host, { '__symbolic': 'module', 'version': 1, 'metadata': {} }, filePath)];
44 }
45 }
46 else {
47 var metadata = host.getSourceFileMetadata(filePath);
48 metadatas = metadata ? [metadata] : [];
49 }
50 }
51 if (cache && (!host.cacheMetadata || host.cacheMetadata(filePath))) {
52 cache.data.set(filePath, metadatas);
53 }
54 return metadatas;
55 }
56 exports.readMetadata = readMetadata;
57 function readMetadataFile(host, dtsFilePath) {
58 var metadataPath = dtsFilePath.replace(util_1.DTS, '.metadata.json');
59 if (!host.fileExists(metadataPath)) {
60 return undefined;
61 }
62 try {
63 var metadataOrMetadatas = JSON.parse(host.readFile(metadataPath));
64 var metadatas = metadataOrMetadatas ?
65 (Array.isArray(metadataOrMetadatas) ? metadataOrMetadatas : [metadataOrMetadatas]) :
66 [];
67 if (metadatas.length) {
68 var maxMetadata = metadatas.reduce(function (p, c) { return p.version > c.version ? p : c; });
69 if (maxMetadata.version < metadata_1.METADATA_VERSION) {
70 metadatas.push(upgradeMetadataWithDtsData(host, maxMetadata, dtsFilePath));
71 }
72 }
73 return metadatas;
74 }
75 catch (e) {
76 console.error("Failed to read JSON file " + metadataPath);
77 throw e;
78 }
79 }
80 function upgradeMetadataWithDtsData(host, oldMetadata, dtsFilePath) {
81 // patch v1 to v3 by adding exports and the `extends` clause.
82 // patch v3 to v4 by adding `interface` symbols for TypeAlias
83 var newMetadata = {
84 '__symbolic': 'module',
85 'version': metadata_1.METADATA_VERSION,
86 'metadata': tslib_1.__assign({}, oldMetadata.metadata),
87 };
88 if (oldMetadata.exports) {
89 newMetadata.exports = oldMetadata.exports;
90 }
91 if (oldMetadata.importAs) {
92 newMetadata.importAs = oldMetadata.importAs;
93 }
94 if (oldMetadata.origins) {
95 newMetadata.origins = oldMetadata.origins;
96 }
97 var dtsMetadata = host.getSourceFileMetadata(dtsFilePath);
98 if (dtsMetadata) {
99 for (var prop in dtsMetadata.metadata) {
100 if (!newMetadata.metadata[prop]) {
101 newMetadata.metadata[prop] = dtsMetadata.metadata[prop];
102 }
103 }
104 if (dtsMetadata['importAs'])
105 newMetadata['importAs'] = dtsMetadata['importAs'];
106 // Only copy exports from exports from metadata prior to version 3.
107 // Starting with version 3 the collector began collecting exports and
108 // this should be redundant. Also, with bundler will rewrite the exports
109 // which will hoist the exports from modules referenced indirectly causing
110 // the imports to be different than the .d.ts files and using the .d.ts file
111 // exports would cause the StaticSymbolResolver to redirect symbols to the
112 // incorrect location.
113 if ((!oldMetadata.version || oldMetadata.version < 3) && dtsMetadata.exports) {
114 newMetadata.exports = dtsMetadata.exports;
115 }
116 }
117 return newMetadata;
118 }
119});
120//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0YWRhdGFfcmVhZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXItY2xpL3NyYy90cmFuc2Zvcm1lcnMvbWV0YWRhdGFfcmVhZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7Ozs7Ozs7Ozs7Ozs7SUFJSCxxRUFBNkQ7SUFFN0Qsb0VBQTJCO0lBZ0IzQixTQUFnQix5QkFBeUI7UUFDdkMsSUFBTSxJQUFJLEdBQUcsSUFBSSxHQUFHLEVBQXNDLENBQUM7UUFDM0QsT0FBTyxFQUFDLElBQUksTUFBQSxFQUFDLENBQUM7SUFDaEIsQ0FBQztJQUhELDhEQUdDO0lBRUQsU0FBZ0IsWUFBWSxDQUN4QixRQUFnQixFQUFFLElBQXdCLEVBQUUsS0FBMkI7UUFFekUsSUFBSSxTQUFTLEdBQUcsS0FBSyxJQUFJLEtBQUssQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBQ2xELElBQUksU0FBUyxFQUFFO1lBQ2IsT0FBTyxTQUFTLENBQUM7U0FDbEI7UUFDRCxJQUFJLElBQUksQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLEVBQUU7WUFDN0IsMEVBQTBFO1lBQzFFLDZFQUE2RTtZQUM3RSxvREFBb0Q7WUFDcEQsSUFBSSxVQUFHLENBQUMsSUFB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