source: trip-planner-front/node_modules/@angular/compiler/esm2015/src/output/source_map.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: 20.2 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 */
8import { utf8Encode } from '../util';
9// https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
10const VERSION = 3;
11const JS_B64_PREFIX = '# sourceMappingURL=data:application/json;base64,';
12export class SourceMapGenerator {
13 constructor(file = null) {
14 this.file = file;
15 this.sourcesContent = new Map();
16 this.lines = [];
17 this.lastCol0 = 0;
18 this.hasMappings = false;
19 }
20 // The content is `null` when the content is expected to be loaded using the URL
21 addSource(url, content = null) {
22 if (!this.sourcesContent.has(url)) {
23 this.sourcesContent.set(url, content);
24 }
25 return this;
26 }
27 addLine() {
28 this.lines.push([]);
29 this.lastCol0 = 0;
30 return this;
31 }
32 addMapping(col0, sourceUrl, sourceLine0, sourceCol0) {
33 if (!this.currentLine) {
34 throw new Error(`A line must be added before mappings can be added`);
35 }
36 if (sourceUrl != null && !this.sourcesContent.has(sourceUrl)) {
37 throw new Error(`Unknown source file "${sourceUrl}"`);
38 }
39 if (col0 == null) {
40 throw new Error(`The column in the generated code must be provided`);
41 }
42 if (col0 < this.lastCol0) {
43 throw new Error(`Mapping should be added in output order`);
44 }
45 if (sourceUrl && (sourceLine0 == null || sourceCol0 == null)) {
46 throw new Error(`The source location must be provided when a source url is provided`);
47 }
48 this.hasMappings = true;
49 this.lastCol0 = col0;
50 this.currentLine.push({ col0, sourceUrl, sourceLine0, sourceCol0 });
51 return this;
52 }
53 /**
54 * @internal strip this from published d.ts files due to
55 * https://github.com/microsoft/TypeScript/issues/36216
56 */
57 get currentLine() {
58 return this.lines.slice(-1)[0];
59 }
60 toJSON() {
61 if (!this.hasMappings) {
62 return null;
63 }
64 const sourcesIndex = new Map();
65 const sources = [];
66 const sourcesContent = [];
67 Array.from(this.sourcesContent.keys()).forEach((url, i) => {
68 sourcesIndex.set(url, i);
69 sources.push(url);
70 sourcesContent.push(this.sourcesContent.get(url) || null);
71 });
72 let mappings = '';
73 let lastCol0 = 0;
74 let lastSourceIndex = 0;
75 let lastSourceLine0 = 0;
76 let lastSourceCol0 = 0;
77 this.lines.forEach(segments => {
78 lastCol0 = 0;
79 mappings += segments
80 .map(segment => {
81 // zero-based starting column of the line in the generated code
82 let segAsStr = toBase64VLQ(segment.col0 - lastCol0);
83 lastCol0 = segment.col0;
84 if (segment.sourceUrl != null) {
85 // zero-based index into the “sources” list
86 segAsStr +=
87 toBase64VLQ(sourcesIndex.get(segment.sourceUrl) - lastSourceIndex);
88 lastSourceIndex = sourcesIndex.get(segment.sourceUrl);
89 // the zero-based starting line in the original source
90 segAsStr += toBase64VLQ(segment.sourceLine0 - lastSourceLine0);
91 lastSourceLine0 = segment.sourceLine0;
92 // the zero-based starting column in the original source
93 segAsStr += toBase64VLQ(segment.sourceCol0 - lastSourceCol0);
94 lastSourceCol0 = segment.sourceCol0;
95 }
96 return segAsStr;
97 })
98 .join(',');
99 mappings += ';';
100 });
101 mappings = mappings.slice(0, -1);
102 return {
103 'file': this.file || '',
104 'version': VERSION,
105 'sourceRoot': '',
106 'sources': sources,
107 'sourcesContent': sourcesContent,
108 'mappings': mappings,
109 };
110 }
111 toJsComment() {
112 return this.hasMappings ? '//' + JS_B64_PREFIX + toBase64String(JSON.stringify(this, null, 0)) :
113 '';
114 }
115}
116export function toBase64String(value) {
117 let b64 = '';
118 const encoded = utf8Encode(value);
119 for (let i = 0; i < encoded.length;) {
120 const i1 = encoded[i++];
121 const i2 = i < encoded.length ? encoded[i++] : null;
122 const i3 = i < encoded.length ? encoded[i++] : null;
123 b64 += toBase64Digit(i1 >> 2);
124 b64 += toBase64Digit(((i1 & 3) << 4) | (i2 === null ? 0 : i2 >> 4));
125 b64 += i2 === null ? '=' : toBase64Digit(((i2 & 15) << 2) | (i3 === null ? 0 : i3 >> 6));
126 b64 += i2 === null || i3 === null ? '=' : toBase64Digit(i3 & 63);
127 }
128 return b64;
129}
130function toBase64VLQ(value) {
131 value = value < 0 ? ((-value) << 1) + 1 : value << 1;
132 let out = '';
133 do {
134 let digit = value & 31;
135 value = value >> 5;
136 if (value > 0) {
137 digit = digit | 32;
138 }
139 out += toBase64Digit(digit);
140 } while (value > 0);
141 return out;
142}
143const B64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
144function toBase64Digit(value) {
145 if (value < 0 || value >= 64) {
146 throw new Error(`Can only encode value in the range [0, 63]`);
147 }
148 return B64_DIGITS[value];
149}
150//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic291cmNlX21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9vdXRwdXQvc291cmNlX21hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsVUFBVSxFQUFDLE1BQU0sU0FBUyxDQUFDO0FBRW5DLHVGQUF1RjtBQUN2RixNQUFNLE9BQU8sR0FBRyxDQUFDLENBQUM7QUFFbEIsTUFBTSxhQUFhLEdBQUcsa0RBQWtELENBQUM7QUFrQnpFLE1BQU0sT0FBTyxrQkFBa0I7SUFNN0IsWUFBb0IsT0FBb0IsSUFBSTtRQUF4QixTQUFJLEdBQUosSUFBSSxDQUFvQjtRQUxwQyxtQkFBYyxHQUE2QixJQUFJLEdBQUcsRUFBRSxDQUFDO1FBQ3JELFVBQUssR0FBZ0IsRUFBRSxDQUFDO1FBQ3hCLGFBQVEsR0FBVyxDQUFDLENBQUM7UUFDckIsZ0JBQVcsR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YXRlIGdldCBjdXJyZW50TGluZSgpOiBTZWdtZW50W118bnVsbCB7XG4gICAgcmV0dXJuIHRoaXMubGluZXMuc2xpY2UoLTEpWzBdO1xuICB9XG5cbiAgdG9KU09OKCk6IFNvdXJjZU1hcHxudWxsIHtcbiAgICBpZiAoIXRoaXMuaGFzTWFwcGluZ3MpIHtcbiAgICAgIHJldHVybiBudWxsO1xuICAgIH1cblxuICAgIGNvbnN0IHNvdXJjZXNJbmRleCA9IG5ldyBNYXA8c3RyaW5nLCBudW1iZXI+KCk7XG4gICAgY29uc3Qgc291cmNlczogc3RyaW5nW10gPSBbXTtcbiAgICBjb25zdCBzb3VyY2VzQ29udGVudDogKHN0cmluZ3xudWxsKVtdID0gW107XG5cbiAgICBBcnJheS5mcm9tKHRoaXMuc291cmNlc0NvbnRlbnQua2V5cygpKS5mb3JFYWNoKCh1cmw6IHN0cmluZywgaTogbnVtYmVyKSA9PiB7XG4gICAgICBzb3VyY2VzSW5kZXguc2V0KHVybCwgaSk7XG4gICAgICBzb3VyY2VzLnB1c2godXJsKTtcbiAgICAgIHNvdXJjZXNDb250ZW50LnB1c2godGhpcy5zb3VyY2VzQ29udGVudC5nZXQodXJsKSB8fCBudWxsKTtcbiAgICB9KTtcblxuICAgIGxldCBtYXBwaW5nczogc3RyaW5nID0gJyc7XG4gICAgbGV0IGxhc3RDb2wwOiBudW1iZXIgPSAwO1xuICAgIGxldCBsYXN0U291cmNlSW5kZXg6IG51bWJlciA9IDA7XG4gICAgbGV0IGxhc3RTb3VyY2VMaW5lMDogbnVtYmVyID0gMDtcbiAgICBsZXQgbGFzdFNvdXJjZUNvbDA6IG51bWJlciA9IDA7XG5cbiAgICB0aGlzLmxpbmVzLmZvckVhY2goc2VnbWVudHMgPT4ge1xuICAgICAgbGFzdENvbDAgPSAwO1xuXG4gICAgICBtYXBwaW5ncyArPSBzZWdtZW50c1xuICAgICAgICAgICAgICAgICAgICAgIC5tYXAoc2VnbWVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyB6ZXJvLWJhc2VkIHN0YXJ0aW5nIGNvbHVtbiBvZiB0aGUgbGluZSBpbiB0aGUgZ2VuZXJhdGVkIGNvZGVcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWdBc1N0ciA9IHRvQmFzZTY0VkxRKHNlZ21lbnQuY29sMCAtIGxhc3RDb2wwKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RDb2wwID0gc2VnbWVudC5jb2wwO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VnbWVudC5zb3VyY2VVcmwgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB6ZXJvLWJhc2VkIGluZGV4IGludG8gdGhlIOKAnHNvdXJjZXPigJ0gbGlzdFxuICAgICAgICAgICAgICAgICAgICAgICAgICBzZWdBc1N0ciArPVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9CYXNlNjRWTFEoc291cmNlc0luZGV4LmdldChzZWdtZW50LnNvdXJjZVVybCkhIC0gbGFzdFNvdXJjZUluZGV4KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFNvdXJjZUluZGV4ID0gc291cmNlc0luZGV4LmdldChzZWdtZW50LnNvdXJjZVVybCkhO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB0aGUgemVyby1iYXNlZCBzdGFydGluZyBsaW5lIGluIHRoZSBvcmlnaW5hbCBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgc2VnQXNTdHIgKz0gdG9CYXNlNjRWTFEoc2VnbWVudC5zb3VyY2VMaW5lMCEgLSBsYXN0U291cmNlTGluZTApO1xuICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0U291cmNlTGluZTAgPSBzZWdtZW50LnNvdXJjZUxpbmUwITtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdGhlIHplcm8tYmFzZWQgc3RhcnRpbmcgY29sdW1uIGluIHRoZSBvcmlnaW5hbCBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgc2VnQXNTdHIgKz0gdG9CYXNlNjRWTFEoc2VnbWVudC5zb3VyY2VDb2wwISAtIGxhc3RTb3VyY2VDb2wwKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFNvdXJjZUNvbDAgPSBzZWdtZW50LnNvdXJjZUNvbDAhO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2VnQXNTdHI7XG4gICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgICAuam9pbignLCcpO1xuICAgICAgbWFwcGluZ3MgKz0gJzsnO1xuICAgIH0pO1xuXG4gICAgbWFwcGluZ3MgPSBtYXBwaW5ncy5zbGljZSgwLCAtMSk7XG5cbiAgICByZXR1cm4ge1xuICAgICAgJ2ZpbGUnOiB0aGlzLmZpbGUgfHwgJycsXG4gICAgICAndmVyc2lvbic6IFZFUlNJT04sXG4gICAgICAnc291cmNlUm9vdCc6ICcnLFxuICAgICAgJ3NvdXJjZXMnOiBzb3VyY2VzLFxuICAgICAgJ3NvdXJjZXNDb250ZW50Jzogc291cmNlc0NvbnRlbnQsXG4gICAgICAnbWFwcGluZ3MnOiBtYXBwaW5ncyxcbiAgICB9O1xuICB9XG5cbiAgdG9Kc0NvbW1lbnQoKTogc3RyaW5nIHtcbiAgICByZXR1cm4gdGhpcy5oYXNNYXBwaW5ncyA/ICcvLycgKyBKU19CNjRfUFJFRklYICsgdG9CYXNlNjRTdHJpbmcoSlNPTi5zdHJpbmdpZnkodGhpcywgbnVsbCwgMCkpIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICcnO1xuICB9XG59XG5cbmV4cG9ydCBmdW5jdGlvbiB0b0Jhc2U2NFN0cmluZyh2YWx1ZTogc3RyaW5nKTogc3RyaW5nIHtcbiAgbGV0IGI2NCA9ICcnO1xuICBjb25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