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 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.RippleSpeedFactorMigration = void 0;
|
---|
11 | const schematics_1 = require("@angular/cdk/schematics");
|
---|
12 | const ts = require("typescript");
|
---|
13 | const ripple_speed_factor_1 = require("./ripple-speed-factor");
|
---|
14 | /** Regular expression that matches [matRippleSpeedFactor]="$NUMBER" in templates. */
|
---|
15 | const speedFactorNumberRegex = /\[matRippleSpeedFactor]="(\d+(?:\.\d+)?)"/g;
|
---|
16 | /** Regular expression that matches [matRippleSpeedFactor]="$NOT_A_NUMBER" in templates. */
|
---|
17 | const speedFactorNotParseable = /\[matRippleSpeedFactor]="(?!\d+(?:\.\d+)?")(.*)"/g;
|
---|
18 | /**
|
---|
19 | * Note that will be added whenever a speed factor expression has been converted to calculate
|
---|
20 | * the according duration. This note should encourage people to clean up their code by switching
|
---|
21 | * away from the speed factors to explicit durations.
|
---|
22 | */
|
---|
23 | const removeNote = `TODO: Cleanup duration calculation.`;
|
---|
24 | /**
|
---|
25 | * Migration that walks through every property assignment and switches the global `baseSpeedFactor`
|
---|
26 | * ripple option to the new global animation config. Also updates every class member assignment
|
---|
27 | * that refers to MatRipple#speedFactor.
|
---|
28 | */
|
---|
29 | class RippleSpeedFactorMigration extends schematics_1.Migration {
|
---|
30 | constructor() {
|
---|
31 | super(...arguments);
|
---|
32 | // Only enable this rule if the migration targets version 7 as the ripple
|
---|
33 | // speed factor has been removed in that version.
|
---|
34 | this.enabled = this.targetVersion === schematics_1.TargetVersion.V7;
|
---|
35 | }
|
---|
36 | visitNode(node) {
|
---|
37 | if (ts.isBinaryExpression(node)) {
|
---|
38 | this._visitBinaryExpression(node);
|
---|
39 | }
|
---|
40 | else if (ts.isPropertyAssignment(node)) {
|
---|
41 | this._visitPropertyAssignment(node);
|
---|
42 | }
|
---|
43 | }
|
---|
44 | visitTemplate(template) {
|
---|
45 | let match;
|
---|
46 | while ((match = speedFactorNumberRegex.exec(template.content)) !== null) {
|
---|
47 | const newEnterDuration = ripple_speed_factor_1.convertSpeedFactorToDuration(parseFloat(match[1]));
|
---|
48 | this._replaceText(template.filePath, template.start + match.index, match[0].length, `[matRippleAnimation]="{enterDuration: ${newEnterDuration}}"`);
|
---|
49 | }
|
---|
50 | while ((match = speedFactorNotParseable.exec(template.content)) !== null) {
|
---|
51 | const newDurationExpression = ripple_speed_factor_1.createSpeedFactorConvertExpression(match[1]);
|
---|
52 | this._replaceText(template.filePath, template.start + match.index, match[0].length, `[matRippleAnimation]="{enterDuration: (${newDurationExpression})}"`);
|
---|
53 | }
|
---|
54 | }
|
---|
55 | /** Switches binary expressions (e.g. myRipple.speedFactor = 0.5) to the new animation config. */
|
---|
56 | _visitBinaryExpression(expression) {
|
---|
57 | if (!ts.isPropertyAccessExpression(expression.left)) {
|
---|
58 | return;
|
---|
59 | }
|
---|
60 | // Left side expression consists of target object and property name (e.g. myInstance.val)
|
---|
61 | const leftExpression = expression.left;
|
---|
62 | const targetTypeNode = this.typeChecker.getTypeAtLocation(leftExpression.expression);
|
---|
63 | if (!targetTypeNode.symbol) {
|
---|
64 | return;
|
---|
65 | }
|
---|
66 | const targetTypeName = targetTypeNode.symbol.getName();
|
---|
67 | const propertyName = leftExpression.name.getText();
|
---|
68 | const filePath = this.fileSystem.resolve(leftExpression.getSourceFile().fileName);
|
---|
69 | if (targetTypeName === 'MatRipple' && propertyName === 'speedFactor') {
|
---|
70 | if (ts.isNumericLiteral(expression.right)) {
|
---|
71 | const numericValue = parseFloat(expression.right.text);
|
---|
72 | const newEnterDurationValue = ripple_speed_factor_1.convertSpeedFactorToDuration(numericValue);
|
---|
73 | // Replace the `speedFactor` property name with `animation`.
|
---|
74 | this._replaceText(filePath, leftExpression.name.getStart(), leftExpression.name.getWidth(), 'animation');
|
---|
75 | // Replace the value assignment with the new animation config.
|
---|
76 | this._replaceText(filePath, expression.right.getStart(), expression.right.getWidth(), `{enterDuration: ${newEnterDurationValue}}`);
|
---|
77 | }
|
---|
78 | else {
|
---|
79 | // Handle the right expression differently if the previous speed factor value can't
|
---|
80 | // be resolved statically. In that case, we just create a TypeScript expression that
|
---|
81 | // calculates the explicit duration based on the non-static speed factor expression.
|
---|
82 | const newExpression = ripple_speed_factor_1.createSpeedFactorConvertExpression(expression.right.getText());
|
---|
83 | // Replace the `speedFactor` property name with `animation`.
|
---|
84 | this._replaceText(filePath, leftExpression.name.getStart(), leftExpression.name.getWidth(), 'animation');
|
---|
85 | // Replace the value assignment with the new animation config and remove TODO.
|
---|
86 | this._replaceText(filePath, expression.right.getStart(), expression.right.getWidth(), `/** ${removeNote} */ {enterDuration: ${newExpression}}`);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 | /**
|
---|
91 | * Switches the global option `baseSpeedFactor` to the new animation config. For this
|
---|
92 | * we assume that the `baseSpeedFactor` is not used in combination with individual
|
---|
93 | * speed factors.
|
---|
94 | */
|
---|
95 | _visitPropertyAssignment(assignment) {
|
---|
96 | // For switching the `baseSpeedFactor` global option we expect the property assignment
|
---|
97 | // to be inside of a normal object literal. Custom ripple global options cannot be
|
---|
98 | // witched automatically.
|
---|
99 | if (!ts.isObjectLiteralExpression(assignment.parent)) {
|
---|
100 | return;
|
---|
101 | }
|
---|
102 | // The assignment consists of a name (key) and initializer (value).
|
---|
103 | if (assignment.name.getText() !== 'baseSpeedFactor') {
|
---|
104 | return;
|
---|
105 | }
|
---|
106 | // We could technically lazily check for the MAT_RIPPLE_GLOBAL_OPTIONS injection token to
|
---|
107 | // be present, but it's not right to assume that everyone sets the ripple global options
|
---|
108 | // immediately in the provider object (e.g. it can happen that someone just imports the
|
---|
109 | // config from a separate file).
|
---|
110 | const { initializer, name } = assignment;
|
---|
111 | const filePath = this.fileSystem.resolve(assignment.getSourceFile().fileName);
|
---|
112 | if (ts.isNumericLiteral(initializer)) {
|
---|
113 | const numericValue = parseFloat(initializer.text);
|
---|
114 | const newEnterDurationValue = ripple_speed_factor_1.convertSpeedFactorToDuration(numericValue);
|
---|
115 | // Replace the `baseSpeedFactor` property name with `animation`.
|
---|
116 | this._replaceText(filePath, name.getStart(), name.getWidth(), 'animation');
|
---|
117 | // Replace the value assignment initializer with the new animation config.
|
---|
118 | this._replaceText(filePath, initializer.getStart(), initializer.getWidth(), `{enterDuration: ${newEnterDurationValue}}`);
|
---|
119 | }
|
---|
120 | else {
|
---|
121 | // Handle the right expression differently if the previous speed factor value can't
|
---|
122 | // be resolved statically. In that case, we just create a TypeScript expression that
|
---|
123 | // calculates the explicit duration based on the non-static speed factor expression.
|
---|
124 | const newExpression = ripple_speed_factor_1.createSpeedFactorConvertExpression(initializer.getText());
|
---|
125 | // Replace the `baseSpeedFactor` property name with `animation`.
|
---|
126 | this._replaceText(filePath, name.getStart(), name.getWidth(), 'animation');
|
---|
127 | // Replace the value assignment with the new animation config and remove TODO.
|
---|
128 | this._replaceText(filePath, initializer.getStart(), initializer.getWidth(), `/** ${removeNote} */ {enterDuration: ${newExpression}}`);
|
---|
129 | }
|
---|
130 | }
|
---|
131 | _replaceText(filePath, start, width, newText) {
|
---|
132 | const recorder = this.fileSystem.edit(filePath);
|
---|
133 | recorder.remove(start, width);
|
---|
134 | recorder.insertRight(start, newText);
|
---|
135 | }
|
---|
136 | }
|
---|
137 | exports.RippleSpeedFactorMigration = RippleSpeedFactorMigration;
|
---|
138 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmlwcGxlLXNwZWVkLWZhY3Rvci1taWdyYXRpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvc2NoZW1hdGljcy9uZy11cGRhdGUvbWlncmF0aW9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