source: trip-planner-front/node_modules/@angular/material/schematics/ng-update/migrations/theming-api-v12/migration.mjs

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: 50.2 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.migrateFileContent = void 0;
11const config_1 = require("./config");
12/** Possible pairs of comment characters in a Sass file. */
13const commentPairs = new Map([['/*', '*/'], ['//', '\n']]);
14/** Prefix for the placeholder that will be used to escape comments. */
15const commentPlaceholderStart = '__<<ngThemingMigrationEscapedComment';
16/** Suffix for the comment escape placeholder. */
17const commentPlaceholderEnd = '>>__';
18/**
19 * Migrates the content of a file to the new theming API. Note that this migration is using plain
20 * string manipulation, rather than the AST from PostCSS and the schematics string manipulation
21 * APIs, because it allows us to run it inside g3 and to avoid introducing new dependencies.
22 * @param fileContent Content of the file.
23 * @param oldMaterialPrefix Prefix with which the old Material imports should start.
24 * Has to end with a slash. E.g. if `@import '~@angular/material/theming'` should be
25 * matched, the prefix would be `~@angular/material/`.
26 * @param oldCdkPrefix Prefix with which the old CDK imports should start.
27 * Has to end with a slash. E.g. if `@import '~@angular/cdk/overlay'` should be
28 * matched, the prefix would be `~@angular/cdk/`.
29 * @param newMaterialImportPath New import to the Material theming API (e.g. `~@angular/material`).
30 * @param newCdkImportPath New import to the CDK Sass APIs (e.g. `~@angular/cdk`).
31 * @param excludedImports Pattern that can be used to exclude imports from being processed.
32 */
33function migrateFileContent(fileContent, oldMaterialPrefix, oldCdkPrefix, newMaterialImportPath, newCdkImportPath, extraMaterialSymbols = {}, excludedImports) {
34 let { content, placeholders } = escapeComments(fileContent);
35 const materialResults = detectImports(content, oldMaterialPrefix, excludedImports);
36 const cdkResults = detectImports(content, oldCdkPrefix, excludedImports);
37 // Try to migrate the symbols even if there are no imports. This is used
38 // to cover the case where the Components symbols were used transitively.
39 content = migrateCdkSymbols(content, newCdkImportPath, placeholders, cdkResults);
40 content = migrateMaterialSymbols(content, newMaterialImportPath, materialResults, placeholders, extraMaterialSymbols);
41 content = replaceRemovedVariables(content, config_1.removedMaterialVariables);
42 // We can assume that the migration has taken care of any Components symbols that were
43 // imported transitively so we can always drop the old imports. We also assume that imports
44 // to the new entry points have been added already.
45 if (materialResults.imports.length) {
46 content = replaceRemovedVariables(content, config_1.unprefixedRemovedVariables);
47 content = removeStrings(content, materialResults.imports);
48 }
49 if (cdkResults.imports.length) {
50 content = removeStrings(content, cdkResults.imports);
51 }
52 return restoreComments(content, placeholders);
53}
54exports.migrateFileContent = migrateFileContent;
55/**
56 * Counts the number of imports with a specific prefix and extracts their namespaces.
57 * @param content File content in which to look for imports.
58 * @param prefix Prefix that the imports should start with.
59 * @param excludedImports Pattern that can be used to exclude imports from being processed.
60 */
61function detectImports(content, prefix, excludedImports) {
62 if (prefix[prefix.length - 1] !== '/') {
63 // Some of the logic further down makes assumptions about the import depth.
64 throw Error(`Prefix "${prefix}" has to end in a slash.`);
65 }
66 // List of `@use` namespaces from which Angular CDK/Material APIs may be referenced.
67 // Since we know that the library doesn't have any name collisions, we can treat all of these
68 // namespaces as equivalent.
69 const namespaces = [];
70 const imports = [];
71 const pattern = new RegExp(`@(import|use) +['"]${escapeRegExp(prefix)}.*['"].*;?\n`, 'g');
72 let match = null;
73 while (match = pattern.exec(content)) {
74 const [fullImport, type] = match;
75 if (excludedImports === null || excludedImports === void 0 ? void 0 : excludedImports.test(fullImport)) {
76 continue;
77 }
78 if (type === 'use') {
79 const namespace = extractNamespaceFromUseStatement(fullImport);
80 if (namespaces.indexOf(namespace) === -1) {
81 namespaces.push(namespace);
82 }
83 }
84 imports.push(fullImport);
85 }
86 return { imports, namespaces };
87}
88/** Migrates the Material symbols in a file. */
89function migrateMaterialSymbols(content, importPath, detectedImports, commentPlaceholders, extraMaterialSymbols = {}) {
90 const initialContent = content;
91 const namespace = 'mat';
92 // Migrate the mixins.
93 const mixinsToUpdate = Object.assign(Object.assign({}, config_1.materialMixins), extraMaterialSymbols.mixins);
94 content = renameSymbols(content, mixinsToUpdate, detectedImports.namespaces, mixinKeyFormatter, getMixinValueFormatter(namespace));
95 // Migrate the functions.
96 const functionsToUpdate = Object.assign(Object.assign({}, config_1.materialFunctions), extraMaterialSymbols.functions);
97 content = renameSymbols(content, functionsToUpdate, detectedImports.namespaces, functionKeyFormatter, getFunctionValueFormatter(namespace));
98 // Migrate the variables.
99 const variablesToUpdate = Object.assign(Object.assign({}, config_1.materialVariables), extraMaterialSymbols.variables);
100 content = renameSymbols(content, variablesToUpdate, detectedImports.namespaces, variableKeyFormatter, getVariableValueFormatter(namespace));
101 if (content !== initialContent) {
102 // Add an import to the new API only if any of the APIs were being used.
103 content = insertUseStatement(content, importPath, namespace, commentPlaceholders);
104 }
105 return content;
106}
107/** Migrates the CDK symbols in a file. */
108function migrateCdkSymbols(content, importPath, commentPlaceholders, detectedImports) {
109 const initialContent = content;
110 const namespace = 'cdk';
111 // Migrate the mixins.
112 content = renameSymbols(content, config_1.cdkMixins, detectedImports.namespaces, mixinKeyFormatter, getMixinValueFormatter(namespace));
113 // Migrate the variables.
114 content = renameSymbols(content, config_1.cdkVariables, detectedImports.namespaces, variableKeyFormatter, getVariableValueFormatter(namespace));
115 // Previously the CDK symbols were exposed through `material/theming`, but now we have a
116 // dedicated entrypoint for the CDK. Only add an import for it if any of the symbols are used.
117 if (content !== initialContent) {
118 content = insertUseStatement(content, importPath, namespace, commentPlaceholders);
119 }
120 return content;
121}
122/**
123 * Renames all Sass symbols in a file based on a pre-defined mapping.
124 * @param content Content of a file to be migrated.
125 * @param mapping Mapping between symbol names and their replacements.
126 * @param namespaces Names to iterate over and pass to getKeyPattern.
127 * @param getKeyPattern Function used to turn each of the keys into a regex.
128 * @param formatValue Formats the value that will replace any matches of the pattern returned by
129 * `getKeyPattern`.
130 */
131function renameSymbols(content, mapping, namespaces, getKeyPattern, formatValue) {
132 // The null at the end is so that we make one last pass to cover non-namespaced symbols.
133 [...namespaces.slice(), null].forEach(namespace => {
134 Object.keys(mapping).forEach(key => {
135 const pattern = getKeyPattern(namespace, key);
136 // Sanity check since non-global regexes will only replace the first match.
137 if (pattern.flags.indexOf('g') === -1) {
138 throw Error('Replacement pattern must be global.');
139 }
140 content = content.replace(pattern, formatValue(mapping[key]));
141 });
142 });
143 return content;
144}
145/** Inserts an `@use` statement in a string. */
146function insertUseStatement(content, importPath, namespace, commentPlaceholders) {
147 // If the content already has the `@use` import, we don't need to add anything.
148 if (new RegExp(`@use +['"]${importPath}['"]`, 'g').test(content)) {
149 return content;
150 }
151 // Sass will throw an error if an `@use` statement comes after another statement. The safest way
152 // to ensure that we conform to that requirement is by always inserting our imports at the top
153 // of the file. Detecting where the user's content starts is tricky, because there are many
154 // different kinds of syntax we'd have to account for. One approach is to find the first `@import`
155 // and insert before it, but the problem is that Sass allows `@import` to be placed anywhere.
156 let newImportIndex = 0;
157 // One special case is if the file starts with a license header which we want to preserve on top.
158 if (content.trim().startsWith(commentPlaceholderStart)) {
159 const commentStartIndex = content.indexOf(commentPlaceholderStart);
160 newImportIndex = content.indexOf(commentPlaceholderEnd, commentStartIndex + 1) +
161 commentPlaceholderEnd.length;
162 // If the leading comment doesn't end with a newline,
163 // we need to insert the import at the next line.
164 if (!commentPlaceholders[content.slice(commentStartIndex, newImportIndex)].endsWith('\n')) {
165 newImportIndex = Math.max(newImportIndex, content.indexOf('\n', newImportIndex) + 1);
166 }
167 }
168 return content.slice(0, newImportIndex) + `@use '${importPath}' as ${namespace};\n` +
169 content.slice(newImportIndex);
170}
171/** Formats a migration key as a Sass mixin invocation. */
172function mixinKeyFormatter(namespace, name) {
173 // Note that adding a `(` at the end of the pattern would be more accurate, but mixin
174 // invocations don't necessarily have to include the parentheses. We could add `[(;]`,
175 // but then we won't know which character to include in the replacement string.
176 return new RegExp(`@include +${escapeRegExp((namespace ? namespace + '.' : '') + name)}`, 'g');
177}
178/** Returns a function that can be used to format a Sass mixin replacement. */
179function getMixinValueFormatter(namespace) {
180 // Note that adding a `(` at the end of the pattern would be more accurate,
181 // but mixin invocations don't necessarily have to include the parentheses.
182 return name => `@include ${namespace}.${name}`;
183}
184/** Formats a migration key as a Sass function invocation. */
185function functionKeyFormatter(namespace, name) {
186 const functionName = escapeRegExp(`${namespace ? namespace + '.' : ''}${name}(`);
187 return new RegExp(`(?<![-_a-zA-Z0-9])${functionName}`, 'g');
188}
189/** Returns a function that can be used to format a Sass function replacement. */
190function getFunctionValueFormatter(namespace) {
191 return name => `${namespace}.${name}(`;
192}
193/** Formats a migration key as a Sass variable. */
194function variableKeyFormatter(namespace, name) {
195 const variableName = escapeRegExp(`${namespace ? namespace + '.' : ''}$${name}`);
196 return new RegExp(`${variableName}(?![-_a-zA-Z0-9])`, 'g');
197}
198/** Returns a function that can be used to format a Sass variable replacement. */
199function getVariableValueFormatter(namespace) {
200 return name => `${namespace}.$${name}`;
201}
202/** Escapes special regex characters in a string. */
203function escapeRegExp(str) {
204 return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
205}
206/** Removes all strings from another string. */
207function removeStrings(content, toRemove) {
208 return toRemove
209 .reduce((accumulator, current) => accumulator.replace(current, ''), content)
210 .replace(/^\s+/, '');
211}
212/** Parses out the namespace from a Sass `@use` statement. */
213function extractNamespaceFromUseStatement(fullImport) {
214 const closeQuoteIndex = Math.max(fullImport.lastIndexOf(`"`), fullImport.lastIndexOf(`'`));
215 if (closeQuoteIndex > -1) {
216 const asExpression = 'as ';
217 const asIndex = fullImport.indexOf(asExpression, closeQuoteIndex);
218 // If we found an ` as ` expression, we consider the rest of the text as the namespace.
219 if (asIndex > -1) {
220 return fullImport.slice(asIndex + asExpression.length).split(';')[0].trim();
221 }
222 // Otherwise the namespace is the name of the file that is being imported.
223 const lastSlashIndex = fullImport.lastIndexOf('/', closeQuoteIndex);
224 if (lastSlashIndex > -1) {
225 const fileName = fullImport.slice(lastSlashIndex + 1, closeQuoteIndex)
226 // Sass allows for leading underscores to be omitted and it technically supports .scss.
227 .replace(/^_|(\.import)?\.scss$|\.import$/g, '');
228 // Sass ignores `/index` and infers the namespace as the next segment in the path.
229 if (fileName === 'index') {
230 const nextSlashIndex = fullImport.lastIndexOf('/', lastSlashIndex - 1);
231 if (nextSlashIndex > -1) {
232 return fullImport.slice(nextSlashIndex + 1, lastSlashIndex);
233 }
234 }
235 else {
236 return fileName;
237 }
238 }
239 }
240 throw Error(`Could not extract namespace from import "${fullImport}".`);
241}
242/**
243 * Replaces variables that have been removed with their values.
244 * @param content Content of the file to be migrated.
245 * @param variables Mapping between variable names and their values.
246 */
247function replaceRemovedVariables(content, variables) {
248 Object.keys(variables).forEach(variableName => {
249 // Note that the pattern uses a negative lookahead to exclude
250 // variable assignments, because they can't be migrated.
251 const regex = new RegExp(`\\$${escapeRegExp(variableName)}(?!\\s+:|:)`, 'g');
252 content = content.replace(regex, variables[variableName]);
253 });
254 return content;
255}
256/**
257 * Replaces all of the comments in a Sass file with placeholders and
258 * returns the list of placeholders so they can be restored later.
259 */
260function escapeComments(content) {
261 const placeholders = {};
262 let commentCounter = 0;
263 let [openIndex, closeIndex] = findComment(content);
264 while (openIndex > -1 && closeIndex > -1) {
265 const placeholder = commentPlaceholderStart + (commentCounter++) + commentPlaceholderEnd;
266 placeholders[placeholder] = content.slice(openIndex, closeIndex);
267 content = content.slice(0, openIndex) + placeholder + content.slice(closeIndex);
268 [openIndex, closeIndex] = findComment(content);
269 }
270 return { content, placeholders };
271}
272/** Finds the start and end index of a comment in a file. */
273function findComment(content) {
274 // Add an extra new line at the end so that we can correctly capture single-line comments
275 // at the end of the file. It doesn't really matter that the end index will be out of bounds,
276 // because `String.prototype.slice` will clamp it to the string length.
277 content += '\n';
278 for (const [open, close] of commentPairs.entries()) {
279 const openIndex = content.indexOf(open);
280 if (openIndex > -1) {
281 const closeIndex = content.indexOf(close, openIndex + 1);
282 return closeIndex > -1 ? [openIndex, closeIndex + close.length] : [-1, -1];
283 }
284 }
285 return [-1, -1];
286}
287/** Restores the comments that have been escaped by `escapeComments`. */
288function restoreComments(content, placeholders) {
289 Object.keys(placeholders).forEach(key => content = content.replace(key, placeholders[key]));
290 return content;
291}
292//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlncmF0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL3NjaGVtYXRpY3MvbmctdXBkYXRlL21pZ3JhdGlvbnMvdGhlbWluZy1hcGktdjEyL21pZ3JhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7OztHQU1HOzs7QUFFSCxxQ0FRa0I7QUFlbEIsMkRBQTJEO0FBQzNELE1BQU0sWUFBWSxHQUFHLElBQUksR0FBRyxDQUFpQixDQUFDLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUUzRSx1RUFBdUU7QUFDdkUsTUFBTSx1QkFBdUIsR0FBRyxzQ0FBc0MsQ0FBQztBQUV2RSxpREFBaUQ7QUFDakQsTUFBTSxxQkFBcUIsR0FBRyxNQUFNLENBQUM7QUFFckM7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFDSCxTQUFnQixrQkFBa0IsQ0FBQyxXQUFtQixFQUNuQixpQkFBeUIsRUFDekIsWUFBb0IsRUFDcEIscUJBQTZCLEVBQzdCLGdCQUF3QixFQUN4Qix1QkFBcUMsRUFBRSxFQUN2QyxlQUF3QjtJQUN6RCxJQUFJLEVBQUMsT0FBTyxFQUFFLFlBQVksRUFBQyxHQUFHLGNBQWMsQ0FBQyxXQUFXLENBQUMsQ0FBQztJQUMxRCxNQUFNLGVBQWUsR0FBRyxhQUFhL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