Skip to content

Commit 0a62a77

Browse files
authored
Merge pull request #86 from itsaplev/master
Add angular 13 support
2 parents 6913836 + ad1adee commit 0a62a77

File tree

9 files changed

+139
-28
lines changed

9 files changed

+139
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ chrome-profiler-events*.json
3131
.history/*
3232

3333
# misc
34+
/.angular/cache
3435
/.sass-cache
3536
/connect.lock
3637
/coverage

angular.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,113 @@
66
"version": 1,
77
"newProjectRoot": "projects",
88
"projects": {
9+
"ngx-flow-demo": {
10+
"root": "",
11+
"sourceRoot": "src",
12+
"projectType": "application",
13+
"prefix": "app",
14+
"schematics": {},
15+
"architect": {
16+
"build": {
17+
"builder": "@angular-devkit/build-angular:browser",
18+
"options": {
19+
"outputPath": "dist/ngx-flow-demo",
20+
"index": "src/index.html",
21+
"main": "src/main.ts",
22+
"polyfills": "src/polyfills.ts",
23+
"tsConfig": "src/tsconfig.app.json",
24+
"assets": [
25+
"src/favicon.ico",
26+
"src/assets"
27+
],
28+
"styles": [
29+
"src/styles.css"
30+
],
31+
"scripts": []
32+
},
33+
"configurations": {
34+
"production": {
35+
"fileReplacements": [
36+
{
37+
"replace": "src/environments/environment.ts",
38+
"with": "src/environments/environment.prod.ts"
39+
}
40+
],
41+
"optimization": false,
42+
"outputHashing": "all",
43+
"sourceMap": true,
44+
"namedChunks": false,
45+
"aot": false,
46+
"extractLicenses": true,
47+
"vendorChunk": false,
48+
"buildOptimizer": false
49+
},
50+
"development": {
51+
"fileReplacements": [
52+
{
53+
"replace": "src/environments/environment.ts",
54+
"with": "src/environments/environment.prod.ts"
55+
}
56+
],
57+
"optimization": false,
58+
"outputHashing": "all",
59+
"sourceMap": true,
60+
"namedChunks": false,
61+
"aot": false,
62+
"extractLicenses": true,
63+
"vendorChunk": false,
64+
"buildOptimizer": false
65+
}
66+
}
67+
},
68+
"serve": {
69+
"builder": "@angular-devkit/build-angular:dev-server",
70+
"options": {
71+
"browserTarget": "ngx-flow-demo:build"
72+
},
73+
"configurations": {
74+
"production": {
75+
"browserTarget": "ngx-flow-demo:build:browser"
76+
}
77+
}
78+
},
79+
"extract-i18n": {
80+
"builder": "@angular-devkit/build-angular:extract-i18n",
81+
"options": {
82+
"browserTarget": "ngx-flow-demo:build"
83+
}
84+
},
85+
"test": {
86+
"builder": "@angular-devkit/build-angular:karma",
87+
"options": {
88+
"main": "src/test.ts",
89+
"polyfills": "src/polyfills.ts",
90+
"tsConfig": "src/tsconfig.spec.json",
91+
"karmaConfig": "src/karma.conf.js",
92+
"styles": [
93+
"src/styles.css"
94+
],
95+
"scripts": [],
96+
"assets": [
97+
"src/favicon.ico",
98+
"src/assets"
99+
]
100+
}
101+
},
102+
"lint": {
103+
"builder": "@angular-devkit/build-angular:tslint",
104+
"options": {
105+
"tsConfig": [
106+
"src/tsconfig.app.json",
107+
"src/tsconfig.spec.json"
108+
],
109+
"exclude": [
110+
"**/node_modules/**"
111+
]
112+
}
113+
}
114+
}
115+
},
9116
"ngx-flow": {
10117
"projectType": "library",
11118
"root": "projects/ngx-flow",

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@
2121
},
2222
"private": true,
2323
"dependencies": {
24-
"@angular/animations": "~12.1.0-",
25-
"@angular/common": "~12.1.0-",
26-
"@angular/compiler": "~12.1.0-",
27-
"@angular/core": "~12.1.0-",
28-
"@angular/forms": "~12.1.0-",
29-
"@angular/platform-browser": "~12.1.0-",
30-
"@angular/platform-browser-dynamic": "~12.1.0-",
31-
"@angular/router": "~12.1.0-",
24+
"@angular/animations": "~13.3.1",
25+
"@angular/common": "~13.3.1",
26+
"@angular/compiler": "~13.3.1",
27+
"@angular/core": "~13.3.1",
28+
"@angular/forms": "~13.3.1",
29+
"@angular/platform-browser": "~13.3.1",
30+
"@angular/platform-browser-dynamic": "~13.3.1",
31+
"@angular/router": "~13.3.1",
3232
"@flowjs/flow.js": "^2.13.0",
3333
"rxjs": "~6.6.0",
3434
"tslib": "^2.2.0",
3535
"zone.js": "~0.11.4"
3636
},
3737
"devDependencies": {
38-
"@angular-devkit/build-angular": "~12.1.3",
39-
"@angular/cli": "~12.1.3",
40-
"@angular/compiler-cli": "~12.1.0-",
38+
"@angular-devkit/build-angular": "~13.3.1",
39+
"@angular/cli": "~13.3.1",
40+
"@angular/compiler-cli": "~13.3.1",
4141
"@types/flowjs": "2.13.3",
4242
"@types/jasmine": "~3.8.0",
4343
"@types/node": "^12.11.1",
@@ -47,7 +47,7 @@
4747
"karma-coverage": "~2.0.3",
4848
"karma-jasmine": "~4.0.0",
4949
"karma-jasmine-html-reporter": "~1.7.0",
50-
"ng-packagr": "^12.1.0",
51-
"typescript": "~4.3.2"
50+
"ng-packagr": "^13.3.0",
51+
"typescript": "~4.6.3"
5252
}
5353
}

projects/ngx-flow/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"url": "https://github.com/flowjs/ngx-flow"
1212
},
1313
"peerDependencies": {
14-
"@angular/common": "^12.1.0-",
15-
"@angular/core": "^12.1.0-",
14+
"@angular/common": "^13.3.1-",
15+
"@angular/core": "^13.3.1-",
1616
"@flowjs/flow.js": "^2.13.0"
1717
},
1818
"dependencies": {

projects/ngx-flow/src/test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ declare const require: {
1818
// First, initialize the Angular testing environment.
1919
getTestBed().initTestEnvironment(
2020
BrowserDynamicTestingModule,
21-
platformBrowserDynamicTesting()
21+
platformBrowserDynamicTesting(), {
22+
teardown: { destroyAfterEach: false }
23+
}
2224
);
2325
// Then we find all the tests.
2426
const context = require.context('./', true, /\.spec\.ts$/);

src/app/app.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h1>ngx-flow example</h1>
2727
<div class="transfers">
2828
<div class="transfer"
2929
[ngClass]="{'transfer--error': transfer.error, 'transfer--success': transfer.success}"
30-
*ngFor="let transfer of (flow.transfers$ | async).transfers; trackBy: trackTransfer">
30+
*ngFor="let transfer of (flow.transfers$ | async)?.transfers; trackBy: trackByTransfer">
3131
<div class="name">name: {{transfer.name}}</div>
3232
<div>progress: {{transfer.progress | percent}}</div>
3333
<div>size: {{transfer.size | number: '1.0'}} bytes</div>
@@ -47,5 +47,5 @@ <h1>ngx-flow example</h1>
4747
</div>
4848
</div>
4949
<button type="button" (click)="flow.upload()" [disabled]="!(flow.somethingToUpload$ | async)">Start upload</button>
50-
<button type="button" (click)="flow.cancel()" [disabled]="!(flow.transfers$ | async).transfers.length">Cancel all</button>
51-
Total progress: {{(flow.transfers$ | async).totalProgress | percent}}
50+
<button type="button" (click)="flow.cancel()" [disabled]="!(flow.transfers$ | async)?.transfers?.length">Cancel all</button>
51+
Total progress: {{(flow.transfers$ | async)?.totalProgress | percent}}

src/app/app.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
ViewChild,
55
AfterViewInit,
66
OnDestroy,
7-
ChangeDetectorRef
7+
ChangeDetectorRef,
8+
TrackByFunction
89
} from '@angular/core';
910
import { Transfer } from 'projects/ngx-flow/src/public_api';
1011
import { FlowDirective } from 'projects/ngx-flow/src/lib/flow.directive';
@@ -17,29 +18,28 @@ import { Subscription } from 'rxjs';
1718
changeDetection: ChangeDetectionStrategy.OnPush
1819
})
1920
export class AppComponent implements AfterViewInit, OnDestroy {
20-
@ViewChild('flow', { static: false })
21-
flow: FlowDirective;
21+
@ViewChild('flow', { static: false }) flow: FlowDirective | undefined;
2222

23-
autoUploadSubscription: Subscription;
23+
autoUploadSubscription: Subscription | undefined;
2424

2525
constructor(private cd: ChangeDetectorRef) {}
2626

2727
ngAfterViewInit() {
28-
this.autoUploadSubscription = this.flow.events$.subscribe(event => {
28+
this.autoUploadSubscription = this.flow?.events$.subscribe(event => {
2929
switch (event.type) {
3030
case 'filesSubmitted':
31-
return this.flow.upload();
31+
return this.flow?.upload();
3232
case 'newFlowJsInstance':
3333
this.cd.detectChanges();
3434
}
3535
});
3636
}
3737

3838
ngOnDestroy() {
39-
this.autoUploadSubscription.unsubscribe();
39+
this.autoUploadSubscription?.unsubscribe();
4040
}
4141

42-
trackTransfer(transfer: Transfer) {
42+
trackByTransfer(index: number, transfer: Transfer) {
4343
return transfer.id;
4444
}
4545
}

src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
33

44
import { AppComponent } from './app.component';
5-
import { NgxFlowModule, FlowInjectionToken } from '@flowjs/ngx-flow';
5+
import { NgxFlowModule, FlowInjectionToken } from 'ngx-flow';
66
import Flow from '@flowjs/flow.js';
77

88
@NgModule({

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"forceConsistentCasingInFileNames": true,
88
"strict": true,
99
"noImplicitReturns": true,
10+
"noImplicitAny": false,
1011
"noFallthroughCasesInSwitch": true,
1112
"sourceMap": true,
1213
"declaration": false,

0 commit comments

Comments
 (0)