source: trip-planner-front/node_modules/@angular/compiler-cli/src/transformers/util.js@ 76712b2

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

initial commit

  • Property mode set to 100644
File size: 11.9 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/util", ["require", "exports", "tslib", "@angular/compiler", "path", "typescript", "@angular/compiler-cli/src/transformers/api"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.stripComment = exports.ngToTsDiagnostic = exports.relativeToRootDirs = exports.isInRootDir = exports.createMessageDiagnostic = exports.userError = exports.error = exports.tsStructureIsReused = exports.TS = exports.DTS = exports.GENERATED_FILES = void 0;
20 var tslib_1 = require("tslib");
21 var compiler_1 = require("@angular/compiler");
22 var path = require("path");
23 var ts = require("typescript");
24 var api_1 = require("@angular/compiler-cli/src/transformers/api");
25 exports.GENERATED_FILES = /(.*?)\.(ngfactory|shim\.ngstyle|ngstyle|ngsummary)\.(js|d\.ts|ts)$/;
26 exports.DTS = /\.d\.ts$/;
27 exports.TS = /^(?!.*\.d\.ts$).*\.ts$/;
28 // Note: This is an internal property in TypeScript. Use it only for assertions and tests.
29 function tsStructureIsReused(program) {
30 return program.structureIsReused;
31 }
32 exports.tsStructureIsReused = tsStructureIsReused;
33 function error(msg) {
34 throw new Error("Internal error: " + msg);
35 }
36 exports.error = error;
37 function userError(msg) {
38 throw compiler_1.syntaxError(msg);
39 }
40 exports.userError = userError;
41 function createMessageDiagnostic(messageText) {
42 return {
43 file: undefined,
44 start: undefined,
45 length: undefined,
46 category: ts.DiagnosticCategory.Message,
47 messageText: messageText,
48 code: api_1.DEFAULT_ERROR_CODE,
49 source: api_1.SOURCE,
50 };
51 }
52 exports.createMessageDiagnostic = createMessageDiagnostic;
53 function isInRootDir(fileName, options) {
54 return !options.rootDir || pathStartsWithPrefix(options.rootDir, fileName);
55 }
56 exports.isInRootDir = isInRootDir;
57 function relativeToRootDirs(filePath, rootDirs) {
58 var e_1, _a;
59 if (!filePath)
60 return filePath;
61 try {
62 for (var _b = tslib_1.__values(rootDirs || []), _c = _b.next(); !_c.done; _c = _b.next()) {
63 var dir = _c.value;
64 var rel = pathStartsWithPrefix(dir, filePath);
65 if (rel) {
66 return rel;
67 }
68 }
69 }
70 catch (e_1_1) { e_1 = { error: e_1_1 }; }
71 finally {
72 try {
73 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
74 }
75 finally { if (e_1) throw e_1.error; }
76 }
77 return filePath;
78 }
79 exports.relativeToRootDirs = relativeToRootDirs;
80 function pathStartsWithPrefix(prefix, fullPath) {
81 var rel = path.relative(prefix, fullPath);
82 return rel.startsWith('..') ? null : rel;
83 }
84 /**
85 * Converts a ng.Diagnostic into a ts.Diagnostic.
86 * This looses some information, and also uses an incomplete object as `file`.
87 *
88 * I.e. only use this where the API allows only a ts.Diagnostic.
89 */
90 function ngToTsDiagnostic(ng) {
91 var file;
92 var start;
93 var length;
94 if (ng.span) {
95 // Note: We can't use a real ts.SourceFile,
96 // but we can at least mirror the properties `fileName` and `text`, which
97 // are mostly used for error reporting.
98 file = { fileName: ng.span.start.file.url, text: ng.span.start.file.content };
99 start = ng.span.start.offset;
100 length = ng.span.end.offset - start;
101 }
102 return {
103 file: file,
104 messageText: ng.messageText,
105 category: ng.category,
106 code: ng.code,
107 start: start,
108 length: length,
109 };
110 }
111 exports.ngToTsDiagnostic = ngToTsDiagnostic;
112 /**
113 * Strip multiline comment start and end markers from the `commentText` string.
114 *
115 * This will also strip the JSDOC comment start marker (`/**`).
116 */
117 function stripComment(commentText) {
118 return commentText.replace(/^\/\*\*?/, '').replace(/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