source: trip-planner-front/node_modules/@angular/material/schematics/ng-update/migrations/hammer-gestures-v9/hammer-gestures-migration.d.ts

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: 7.6 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 { SchematicContext, Tree } from '@angular-devkit/schematics';
9import { DevkitMigration, PostMigrationAction, ResolvedResource } from '@angular/cdk/schematics';
10import * as ts from 'typescript';
11export declare class HammerGesturesMigration extends DevkitMigration<null> {
12 enabled: boolean;
13 private _printer;
14 private _importManager;
15 private _nodeFailures;
16 /**
17 * Whether custom HammerJS events provided by the Material gesture
18 * config are used in a template.
19 */
20 private _customEventsUsedInTemplate;
21 /** Whether standard HammerJS events are used in a template. */
22 private _standardEventsUsedInTemplate;
23 /** Whether HammerJS is accessed at runtime. */
24 private _usedInRuntime;
25 /**
26 * List of imports that make "hammerjs" available globally. We keep track of these
27 * since we might need to remove them if Hammer is not used.
28 */
29 private _installImports;
30 /**
31 * List of identifiers which resolve to the gesture config from Angular Material.
32 */
33 private _gestureConfigReferences;
34 /**
35 * List of identifiers which resolve to the "HAMMER_GESTURE_CONFIG" token from
36 * "@angular/platform-browser".
37 */
38 private _hammerConfigTokenReferences;
39 /**
40 * List of identifiers which resolve to the "HammerModule" from
41 * "@angular/platform-browser".
42 */
43 private _hammerModuleReferences;
44 /**
45 * List of identifiers that have been deleted from source files. This can be
46 * used to determine if certain imports are still used or not.
47 */
48 private _deletedIdentifiers;
49 visitTemplate(template: ResolvedResource): void;
50 visitNode(node: ts.Node): void;
51 postAnalysis(): void;
52 /**
53 * Sets up the hammer gesture config in the current project. To achieve this, the
54 * following steps are performed:
55 * 1) Create copy of Angular Material gesture config.
56 * 2) Rewrite all references to the Angular Material gesture config to the
57 * new gesture config.
58 * 3) Setup the HAMMER_GESTURE_CONFIG in the root app module (if not done already).
59 * 4) Setup the "HammerModule" in the root app module (if not done already).
60 */
61 private _setupHammerWithCustomEvents;
62 /**
63 * Sets up the standard hammer module in the project and removes all
64 * references to the deprecated Angular Material gesture config.
65 */
66 private _setupHammerWithStandardEvents;
67 /**
68 * Removes Hammer from the current project. The following steps are performed:
69 * 1) Delete all TypeScript imports to "hammerjs".
70 * 2) Remove references to the Angular Material gesture config.
71 * 3) Remove "hammerjs" from all index HTML files of the current project.
72 */
73 private _removeHammerSetup;
74 /**
75 * Removes the gesture config setup by deleting all found references to the Angular
76 * Material gesture config. Additionally, unused imports to the hammer gesture config
77 * token from "@angular/platform-browser" will be removed as well.
78 */
79 private _removeMaterialGestureConfigSetup;
80 /** Removes all references to the "HammerModule" from "@angular/platform-browser". */
81 private _removeHammerModuleReferences;
82 /**
83 * Checks if the given node is a reference to the hammer gesture config
84 * token from platform-browser. If so, keeps track of the reference.
85 */
86 private _checkForHammerGestureConfigToken;
87 /**
88 * Checks if the given node is a reference to the HammerModule from
89 * "@angular/platform-browser". If so, keeps track of the reference.
90 */
91 private _checkForHammerModuleReference;
92 /**
93 * Checks if the given node is an import to the HammerJS package. Imports to
94 * HammerJS which load specific symbols from the package are considered as
95 * runtime usage of Hammer. e.g. `import {Symbol} from "hammerjs";`.
96 */
97 private _checkHammerImports;
98 /**
99 * Checks if the given node accesses the global "Hammer" symbol at runtime. If so,
100 * the migration rule state will be updated to reflect that Hammer is used at runtime.
101 */
102 private _checkForRuntimeHammerUsage;
103 /**
104 * Checks if the given node references the gesture config from Angular Material.
105 * If so, we keep track of the found symbol reference.
106 */
107 private _checkForMaterialGestureConfig;
108 /**
109 * Checks if the given Hammer gesture config token reference is part of an
110 * Angular provider definition that sets up a custom gesture config.
111 */
112 private _checkForCustomGestureConfigSetup;
113 /**
114 * Determines an available file name for the gesture config which should
115 * be stored in the specified file path.
116 */
117 private _getAvailableGestureConfigFileName;
118 /** Replaces a given gesture config reference with a new import. */
119 private _replaceGestureConfigReference;
120 /**
121 * Removes a given gesture config reference and its corresponding import from
122 * its containing source file. Imports will be always removed, but in some cases,
123 * where it's not guaranteed that a removal can be performed safely, we just
124 * create a migration failure (and add a TODO if possible).
125 */
126 private _removeGestureConfigReference;
127 /** Removes the given hammer config token import if it is not used. */
128 private _removeHammerConfigTokenImportIfUnused;
129 /** Removes Hammer from all index HTML files of the current project. */
130 private _removeHammerFromIndexFile;
131 /** Sets up the Hammer gesture config in the root module if needed. */
132 private _setupNewGestureConfigInRootModule;
133 /**
134 * Gets the TypeScript symbol of the root module by looking for the module
135 * bootstrap expression in the specified source file.
136 */
137 private _getRootModuleSymbol;
138 /** Sets up the "HammerModule" in the root module of the current project. */
139 private _setupHammerModuleInRootModule;
140 /** Prints a given node within the specified source file. */
141 private _printNode;
142 /** Gets all referenced gesture config identifiers of a given source file */
143 private _getGestureConfigIdentifiersOfFile;
144 /** Gets the symbol that contains the value declaration of the specified node. */
145 private _getDeclarationSymbolOfNode;
146 /**
147 * Checks whether the given expression resolves to a hammer gesture config
148 * token reference from "@angular/platform-browser".
149 */
150 private _isReferenceToHammerConfigToken;
151 /**
152 * Creates migration failures of the collected node failures. The returned migration
153 * failures are updated to reflect the post-migration state of source files. Meaning
154 * that failure positions are corrected if source file modifications shifted lines.
155 */
156 private _createMigrationFailures;
157 /** Global state of whether Hammer is used in any analyzed project target. */
158 static globalUsesHammer: boolean;
159 /**
160 * Static migration rule method that will be called once all project targets
161 * have been migrated individually. This method can be used to make changes based
162 * on the analysis of the individual targets. For example: we only remove Hammer
163 * from the "package.json" if it is not used in *any* project target.
164 */
165 static globalPostMigration(tree: Tree, context: SchematicContext): PostMigrationAction;
166 /**
167 * Removes the hammer package from the workspace "package.json".
168 * @returns Whether Hammer was set up and has been removed from the "package.json"
169 */
170 private static _removeHammerFromPackageJson;
171}
Note: See TracBrowser for help on using the repository browser.