Skip to content

Commit d6a8b3e

Browse files
authored
Merge branch 'master' into mkirova/fix-8458
2 parents 7c07ada + bf614af commit d6a8b3e

File tree

265 files changed

+9201
-8697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+9201
-8697
lines changed

CHANGELOG.md

Lines changed: 29 additions & 23 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 48 additions & 48 deletions
Large diffs are not rendered by default.

angular.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"optimization": true,
5151
"outputHashing": "all",
5252
"sourceMap": false,
53-
"extractCss": true,
5453
"namedChunks": false,
5554
"extractLicenses": true,
5655
"vendorChunk": false,
@@ -162,7 +161,7 @@
162161
"prefix": "lib",
163162
"architect": {
164163
"build": {
165-
"builder": "@angular-devkit/build-ng-packagr:build",
164+
"builder": "@angular-devkit/build-angular:ng-packagr",
166165
"options": {
167166
"tsConfig": "projects/igniteui-angular/tsconfig.lib.json",
168167
"project": "projects/igniteui-angular/ng-package.json"

package-lock.json

Lines changed: 4027 additions & 5914 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
},
4646
"private": true,
4747
"dependencies": {
48-
"@angular/animations": "^10.1.0",
49-
"@angular/common": "^10.1.0",
50-
"@angular/compiler": "^10.1.0",
51-
"@angular/core": "^10.1.0",
52-
"@angular/forms": "^10.1.0",
53-
"@angular/platform-browser": "^10.1.0",
54-
"@angular/platform-browser-dynamic": "^10.1.0",
55-
"@angular/router": "^10.1.0",
48+
"@angular/animations": "^11.0.0-rc.1",
49+
"@angular/common": "^11.0.0-rc.1",
50+
"@angular/compiler": "^11.0.0-rc.1",
51+
"@angular/core": "^11.0.0-rc.1",
52+
"@angular/forms": "^11.0.0-rc.1",
53+
"@angular/platform-browser": "^11.0.0-rc.1",
54+
"@angular/platform-browser-dynamic": "^11.0.0-rc.1",
55+
"@angular/router": "^11.0.0-rc.1",
5656
"@igniteui/material-icons-extended": "^2.4.0",
5757
"@types/hammerjs": "^2.0.36",
5858
"@types/source-map": "0.5.2",
@@ -71,12 +71,11 @@
7171
"zone.js": "~0.10.3"
7272
},
7373
"devDependencies": {
74-
"@angular-devkit/build-angular": "~0.1001.0",
75-
"@angular-devkit/build-ng-packagr": "~0.1001.0",
76-
"@angular-devkit/schematics": "^10.1.0",
77-
"@angular/cli": "~10.1.0",
78-
"@angular/compiler-cli": "^10.1.0",
79-
"@angular/language-service": "^10.1.0",
74+
"@angular-devkit/build-angular": "~0.1100.0-rc.1",
75+
"@angular-devkit/schematics": "^11.0.0-rc.1",
76+
"@angular/cli": "~11.0.0-rc.1",
77+
"@angular/compiler-cli": "^11.0.0-rc.1",
78+
"@angular/language-service": "^11.0.0-rc.1",
8079
"@angularclass/hmr": "^2.1.3",
8180
"@types/jasmine": "^3.3.16",
8281
"@types/jasminewd2": "^2.0.8",
@@ -101,7 +100,7 @@
101100
"jasmine": "~3.5.0",
102101
"jasmine-core": "~3.5.0",
103102
"jasmine-spec-reporter": "~5.0.2",
104-
"karma": "~5.0.0",
103+
"karma": "~5.2.3",
105104
"karma-chrome-launcher": "~3.1.0",
106105
"karma-coverage-istanbul-reporter": "^3.0.3",
107106
"karma-jasmine": "~3.3.0",
@@ -110,7 +109,7 @@
110109
"karma-junit-reporter": "~2.0.1",
111110
"karma-spec-reporter": "~0.0.32",
112111
"lunr": "^2.3.8",
113-
"ng-packagr": "^10.1.0",
112+
"ng-packagr": "^11.0.0-next.3",
114113
"pngcrush": "^2.0.1",
115114
"protractor": "~7.0.0",
116115
"sassdoc": "^2.7.3",

projects/igniteui-angular/migrations/common/UpdateChanges.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class UpdateChanges {
147147
}
148148

149149
/** Add condition function. */
150-
public addCondition(conditionName: string, callback: (ownerMatch: string) => boolean) {
150+
public addCondition(conditionName: string, callback: (ownerMatch: string, path: string) => boolean) {
151151
this.conditionFunctions.set(conditionName, callback);
152152
}
153153

@@ -266,7 +266,7 @@ export class UpdateChanges {
266266

267267
for (const match of matches) {
268268
let replaceStatement = replace;
269-
if (!this.areConditionsFulfiled(match, change.conditions)) {
269+
if (!this.areConditionsFulfilled(match, change.conditions, entryPath)) {
270270
continue;
271271
}
272272

@@ -403,12 +403,12 @@ export class UpdateChanges {
403403
}
404404
}
405405

406-
private areConditionsFulfiled(match: string, conditions: string[]): boolean {
406+
private areConditionsFulfilled(match: string, conditions: string[], entryPath: string): boolean {
407407
if (conditions) {
408408
for (const condition of conditions) {
409409
if (this.conditionFunctions && this.conditionFunctions.has(condition)) {
410410
const callback = this.conditionFunctions.get(condition);
411-
if (callback && !callback(match)) {
411+
if (callback && !callback(match, entryPath)) {
412412
return false;
413413
}
414414
}

projects/igniteui-angular/migrations/common/tsUtils.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,39 @@ export function createProjectService(serverHost: tss.server.ServerHost): tss.ser
223223
export function getTypeDefinitionAtPosition(langServ: tss.LanguageService, entryPath: string, position: number): tss.DefinitionInfo | null {
224224
const definition = langServ.getDefinitionAndBoundSpan(entryPath, position)?.definitions[0];
225225
if (!definition) { return null; }
226+
227+
// if the definition's kind is a reference, the identifier is a template variable referred in an internal/external template
226228
if (definition.kind.toString() === 'reference') {
227-
// template variable in an internal/external template
228229
return langServ.getDefinitionAndBoundSpan(entryPath, definition.textSpan.start).definitions[0];
229230
}
230231
let typeDefs = langServ.getTypeDefinitionAtPosition(entryPath, definition.textSpan.start);
232+
// if there are no type definitions found, the identifier is a ts property, referred in an internal/external template
233+
// or is a reference in a decorator
231234
if (!typeDefs) {
232-
// ts property referred in an internal/external template
233-
const classDeclaration = langServ
234-
.getProgram()
235-
.getSourceFile(definition.fileName)
235+
/*
236+
normally, the tsserver will consider non .ts files as external to the project
237+
however, we load .html files which we can handle with the Angular language service
238+
here we're only looking for definitions in a .ts source file
239+
we call the getSourceFile function which accesses a map of files, previously loaded by the tsserver
240+
at this point the map contains all .html files that we've included
241+
we have to ignore them, since the language service will attempt to parse them as .ts files
242+
*/
243+
if (!definition.fileName.endsWith('.ts')) { return null; }
244+
245+
const sourceFile = langServ.getProgram().getSourceFile(definition.fileName);
246+
if (!sourceFile) { return null; }
247+
248+
const classDeclaration = sourceFile
236249
.statements
237250
.filter(<(a: tss.Statement) => a is tss.ClassDeclaration>(m => m.kind === tss.SyntaxKind.ClassDeclaration))
238251
.find(m => m.name.getText() === definition.containerName);
239-
const member: ts.ClassElement = classDeclaration
240-
?.members
241-
.find(m => m.name.getText() === definition.name);
242-
if (!member || !member.name) { return null; }
252+
253+
// there must be at least one class declaration in the .ts file and the property must belong to it
254+
if (!classDeclaration) { return null; }
255+
256+
const member: ts.ClassElement = classDeclaration.members.find(m => m.name.getText() === definition.name);
257+
if (!member?.name) { return null; }
258+
243259
typeDefs = langServ.getTypeDefinitionAtPosition(definition.fileName, member.name.getStart() + 1);
244260
}
245261
if (typeDefs?.length) {

projects/igniteui-angular/migrations/common/util.ts

Lines changed: 162 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@ import * as path from 'path';
33
import { SchematicContext, Tree } from '@angular-devkit/schematics';
44
import { WorkspaceSchema, WorkspaceProject, ProjectType } from '@schematics/angular/utility/workspace-models';
55
import { execSync } from 'child_process';
6+
import {
7+
Attribute,
8+
Comment,
9+
Element,
10+
Expansion,
11+
ExpansionCase,
12+
getHtmlTagDefinition,
13+
HtmlParser,
14+
Node,
15+
Text,
16+
Visitor
17+
} from '@angular/compiler';
18+
import { replaceMatch } from './tsUtils';
619

720
const configPaths = ['/.angular.json', '/angular.json'];
821

922
export function getProjectPaths(config: WorkspaceSchema, appendPrefix = true): string[] {
1023
const sourceDirs = [];
11-
let globalPrefix;
1224

13-
if (config.schematics && config.schematics['@schematics/angular:component']) {
14-
// updated projects have global prefix rather than per-project:
15-
globalPrefix = config.schematics['@schematics/angular:component'].prefix;
16-
}
1725
const projects = getProjects(config);
1826
for (const proj of projects) {
1927
let sourcePath = path.join('/', proj.sourceRoot);
20-
if (appendPrefix && (proj.prefix || globalPrefix)) {
21-
sourcePath = path.join(sourcePath, proj.prefix || globalPrefix);
28+
if (appendPrefix && (proj.prefix)) {
29+
sourcePath = path.join(sourcePath, proj.prefix);
2230
}
2331
sourceDirs.push(normalize(sourcePath));
2432
}
@@ -116,3 +124,150 @@ export function tryUninstallPackage(context: SchematicContext, packageManager: s
116124
.warn(`Could not uninstall ${pkg}, you may want to uninstall it manually.`, JSON.parse(e));
117125
}
118126
}
127+
128+
interface TagOffset {
129+
start: number;
130+
end: number;
131+
}
132+
133+
export interface SourceOffset {
134+
startTag: TagOffset;
135+
endTag: TagOffset;
136+
file: {
137+
content: string;
138+
url: string;
139+
};
140+
node?: Element;
141+
}
142+
143+
144+
export class FileChange {
145+
146+
constructor(
147+
public position = 0,
148+
public text = '',
149+
public replaceText = '',
150+
public type: 'insert' | 'replace' = 'insert'
151+
) {}
152+
153+
apply(content: string) {
154+
if (this.type === 'insert') {
155+
return `${content.substring(0, this.position)}${this.text}${content.substring(this.position)}`;
156+
}
157+
return replaceMatch(content, this.replaceText, this.text, this.position);
158+
}
159+
}
160+
161+
/**
162+
* Parses an Angular template file/content and returns an array of the root nodes of the file.
163+
*
164+
* @param host
165+
* @param filePath
166+
* @param encoding
167+
*/
168+
export function parseFile(host: Tree, filePath: string, encoding = 'utf8') {
169+
return new HtmlParser().parse(host.read(filePath).toString(encoding), filePath).rootNodes;
170+
}
171+
172+
export function findElementNodes(root: Node[], tag: string | string[]): Node[] {
173+
const tags = new Set(Array.isArray(tag) ? tag : [tag]);
174+
return flatten(Array.isArray(root) ? root : [root])
175+
.filter((node: Element) => tags.has(node.name));
176+
}
177+
178+
export function hasAttribute(root: Element, attribute: string | string[]) {
179+
const attrs = Array.isArray(attribute) ? attribute : [attribute];
180+
return !!root.attrs.find(a => attrs.includes(a.name));
181+
}
182+
183+
export function getAttribute(root: Element, attribute: string | string[]) {
184+
const attrs = Array.isArray(attribute) ? attribute : [attribute];
185+
return root.attrs.filter(a => attrs.includes(a.name));
186+
}
187+
188+
export function getSourceOffset(element: Element): SourceOffset {
189+
const { startSourceSpan, endSourceSpan } = element;
190+
return {
191+
startTag: { start: startSourceSpan.start.offset, end: startSourceSpan.end.offset },
192+
endTag: { start: endSourceSpan.start.offset, end: endSourceSpan.end.offset },
193+
file: {
194+
content: startSourceSpan.start.file.content,
195+
url: startSourceSpan.start.file.url
196+
},
197+
node: element
198+
};
199+
}
200+
201+
202+
function isElement(node: Node | Element): node is Element {
203+
return (node as Element).children !== undefined;
204+
}
205+
206+
/**
207+
* Given an array of `Node` objects, flattens the ast tree to a single array.
208+
* De facto only `Element` type objects have children.
209+
*
210+
* @param list
211+
*/
212+
export function flatten(list: Node[]) {
213+
let node: Node;
214+
let r: Node[] = [];
215+
216+
for (let i = 0; i < list.length; i++) {
217+
node = list[i];
218+
r.push(node);
219+
220+
if (isElement(node)) {
221+
r = r.concat(flatten(node.children));
222+
}
223+
}
224+
return r;
225+
}
226+
227+
/**
228+
* https://github.com/angular/angular/blob/master/packages/compiler/test/ml_parser/util/util.ts
229+
*
230+
* May be useful for validating the output of our own migrations,
231+
*/
232+
class SerializerVisitor implements Visitor {
233+
234+
visitElement(element: Element, context: any): any {
235+
if (getHtmlTagDefinition(element.name).isVoid) {
236+
return `<${element.name}${this._visitAll(element.attrs, ' ')}/>`;
237+
}
238+
239+
return `<${element.name}${this._visitAll(element.attrs, ' ')}>${this._visitAll(element.children)}</${element.name}>`;
240+
}
241+
242+
visitAttribute(attribute: Attribute, context: any): any {
243+
return attribute.value === '' ? `${attribute.name}` : `${attribute.name}="${attribute.value}"`;
244+
}
245+
246+
visitText(text: Text, context: any): any {
247+
return text.value;
248+
}
249+
250+
visitComment(comment: Comment, context: any): any {
251+
return `<!--${comment.value}-->`;
252+
}
253+
254+
visitExpansion(expansion: Expansion, context: any): any {
255+
return `{${expansion.switchValue}, ${expansion.type},${this._visitAll(expansion.cases)}}`;
256+
}
257+
258+
visitExpansionCase(expansionCase: ExpansionCase, context: any): any {
259+
return ` ${expansionCase.value} {${this._visitAll(expansionCase.expression)}}`;
260+
}
261+
262+
private _visitAll(nodes: Node[], join: string = ''): string {
263+
if (nodes.length === 0) {
264+
return '';
265+
}
266+
return join + nodes.map(a => a.visit(this, null)).join(join);
267+
}
268+
}
269+
270+
271+
export function serializeNodes(nodes: Node[]): string[] {
272+
return nodes.map(node => node.visit(new SerializerVisitor(), null));
273+
}

projects/igniteui-angular/migrations/migration-collection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
"version": "10.2.0",
8686
"description": "Updates Ignite UI for Angular from v10.1.x to v10.2.0",
8787
"factory": "./update-10_2_0"
88+
},
89+
"migration-18": {
90+
"version": "11.0.0",
91+
"description": "Updates Ignite UI for Angular from v10.2.x to v11.0.0",
92+
"factory": "./update-11_0_0"
8893
}
8994
}
9095
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"@scheme": "../../common/schema/binding.schema.json",
3+
"changes": [
4+
{
5+
"name": "showToolbar",
6+
"remove": "true",
7+
"owner": {
8+
"selector": "igx-grid",
9+
"type": "component"
10+
}
11+
},
12+
{
13+
"name": "showToolbar",
14+
"remove": "true",
15+
"owner": {
16+
"selector": "igx-tree-grid",
17+
"type": "component"
18+
}
19+
},
20+
{
21+
"name": "showToolbar",
22+
"remove": "true",
23+
"owner": {
24+
"selector": "igx-hierarchical-grid",
25+
"type": "component"
26+
}
27+
},
28+
{
29+
"name": "showToolbar",
30+
"remove": "true",
31+
"owner": {
32+
"selector": "igx-row-island",
33+
"type": "component"
34+
}
35+
}
36+
]
37+
}

0 commit comments

Comments
 (0)