();
@@ -43,7 +43,7 @@ export class NgFileSelectDirective implements OnInit, OnDestroy {
}
ngOnDestroy() {
- if (this.el){
+ if (this.el) {
this.el.removeEventListener('change', this.fileListener, false);
this._sub.forEach(sub => sub.unsubscribe());
}
diff --git a/projects/ngx-uploader/src/lib/ngx-uploader.class.ts b/projects/ngx-uploader/src/lib/ngx-uploader.class.ts
index d62bb666..dc7345e6 100644
--- a/projects/ngx-uploader/src/lib/ngx-uploader.class.ts
+++ b/projects/ngx-uploader/src/lib/ngx-uploader.class.ts
@@ -1,6 +1,5 @@
import { EventEmitter } from '@angular/core';
-import { Observable, Subject, Subscription } from 'rxjs';
-import { mergeMap, finalize } from 'rxjs/operators';
+import { Observable, Subject, Subscription, mergeMap, finalize } from 'rxjs';
import { UploadFile, UploadOutput, UploadInput, UploadStatus, BlobFile } from './interfaces';
export function humanizeBytes(bytes: number): string {
@@ -46,33 +45,33 @@ export class NgUploaderService {
}
handleFiles(incomingFiles: FileList): void {
- const allowedIncomingFiles: File[] = [].reduce.call(
+ const allowedIncomingFiles = [].reduce.call(
incomingFiles,
- (acc: File[], checkFile: File, i: number) => {
- const futureQueueLength = acc.length + this.queue.length + 1;
+ (acc: unknown, checkFile: File, i: number) => {
+ const futureQueueLength = (acc as File[]).length + this.queue.length + 1;
if (
this.isContentTypeAllowed(checkFile.type) &&
futureQueueLength <= this.maxUploads &&
this.isFileSizeAllowed(checkFile.size)
) {
- acc = acc.concat(checkFile);
+ acc = (acc as File[]).concat(checkFile);
} else {
const rejectedFile: UploadFile = this.makeUploadFile(checkFile, i);
this.serviceEvents.emit({ type: 'rejected', file: rejectedFile });
}
- return acc;
- },
- []
- );
+ return acc as File[];
+ }, [] as File[]) as File[];
+
+
this.queue.push(
- ...[].map.call(allowedIncomingFiles, (file: File, i: number) => {
+ ...allowedIncomingFiles.map((file: File, i: number) => {
const uploadFile: UploadFile = this.makeUploadFile(file, i);
this.serviceEvents.emit({ type: 'addedToQueue', file: uploadFile });
return uploadFile;
})
- );
+ )
this.serviceEvents.emit({ type: 'allAddedToQueue' });
}
@@ -349,7 +348,7 @@ export class NgUploaderService {
private parseResponseHeaders(httpHeaders: string): { [key: string]: string } {
if (!httpHeaders) {
- return;
+ return {};
}
return httpHeaders
diff --git a/projects/ngx-uploader/tsconfig.lib.json b/projects/ngx-uploader/tsconfig.lib.json
index f77a3aa7..543fd474 100644
--- a/projects/ngx-uploader/tsconfig.lib.json
+++ b/projects/ngx-uploader/tsconfig.lib.json
@@ -1,31 +1,14 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
- "declarationMap": true,
- "module": "es2015",
- "moduleResolution": "node",
"declaration": true,
- "sourceMap": true,
+ "declarationMap": true,
"inlineSources": true,
- "experimentalDecorators": true,
- "importHelpers": true,
- "types": [],
- "lib": [
- "dom",
- "es2015"
- ]
- },
- "angularCompilerOptions": {
- "skipTemplateCodegen": true,
- "strictMetadataEmit": true,
- "fullTemplateTypeCheck": true,
- "strictInjectionParameters": true,
- "flatModuleId": "AUTOGENERATED",
- "flatModuleOutFile": "AUTOGENERATED"
+ "types": []
},
"exclude": [
- "src/test.ts",
"**/*.spec.ts"
]
}
diff --git a/projects/ngx-uploader/tsconfig.lib.prod.json b/projects/ngx-uploader/tsconfig.lib.prod.json
index 6330633d..06de549e 100644
--- a/projects/ngx-uploader/tsconfig.lib.prod.json
+++ b/projects/ngx-uploader/tsconfig.lib.prod.json
@@ -1,3 +1,4 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
@@ -6,4 +7,4 @@
"angularCompilerOptions": {
"compilationMode": "partial"
}
-}
\ No newline at end of file
+}
diff --git a/projects/ngx-uploader/tsconfig.spec.json b/projects/ngx-uploader/tsconfig.spec.json
index 16da33db..ce7048bc 100644
--- a/projects/ngx-uploader/tsconfig.spec.json
+++ b/projects/ngx-uploader/tsconfig.spec.json
@@ -1,15 +1,12 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
- "jasmine",
- "node"
+ "jasmine"
]
},
- "files": [
- "src/test.ts"
- ],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
diff --git a/projects/ngx-uploader/tslint.json b/projects/ngx-uploader/tslint.json
deleted file mode 100644
index 15870999..00000000
--- a/projects/ngx-uploader/tslint.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "extends": "../../tslint.json",
- "rules": {
- "directive-selector": [
- true,
- "attribute",
- "ng",
- "camelCase"
- ],
- "component-selector": [
- true,
- "element",
- "ng",
- "kebab-case"
- ]
- }
-}
diff --git a/src/app/app.component.html b/src/app/app.component.html
index b5365535..85ef5790 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -47,13 +47,13 @@ ngx-uploader
- {{ f.progress?.data?.percentage }}%
+ {{ f.progress.data?.percentage }}%
Uploading...
Done
- {{ f.progress?.data?.speedHuman }}
- ETA {{ f.progress?.data?.etaHuman }}
+ {{ f.progress.data?.speedHuman }}
+ ETA {{ f.progress.data?.etaHuman }}
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index c71e7b0a..7b6a89d0 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -7,15 +7,15 @@ import { UploadOutput, UploadInput, UploadFile, humanizeBytes, UploaderOptions,
})
export class AppComponent {
url = '/upload';
- formData: FormData;
+ formData!: FormData;
files: UploadFile[];
uploadInput: EventEmitter;
humanizeBytes: Function;
- dragOver: boolean;
+ dragOver!: boolean;
options: UploaderOptions;
constructor() {
- this.options = { concurrency: 1, maxUploads: 3, maxFileSize: 1000000 };
+ this.options = { concurrency: 1, maxUploads: 10 };
this.files = [];
this.uploadInput = new EventEmitter();
this.humanizeBytes = humanizeBytes;
diff --git a/src/styles/app.sass b/src/styles/app.sass
index 996fe662..e25bb042 100644
--- a/src/styles/app.sass
+++ b/src/styles/app.sass
@@ -1,8 +1,7 @@
@charset 'utf8'
@import url('https://fonts.googleapis.com/css?family=Roboto:100,300,400,600,700')
-@import url('https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css')
-@import '../../node_modules/bulma/bulma'
+@import 'bulma/bulma'
$blue: #13EBFF
$green: #6CEFBD
diff --git a/tsconfig.api.json b/tsconfig.api.json
index 001a8220..caa2ee1a 100644
--- a/tsconfig.api.json
+++ b/tsconfig.api.json
@@ -2,11 +2,11 @@
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
- "target": "es5",
+ "target": "es2022",
"sourceMap": false,
"experimentalDecorators": true,
"lib": [
- "es2017",
+ "es2022",
"dom"
],
"outDir": "dist/api",
diff --git a/tsconfig.json b/tsconfig.json
index 25416dce..71fbb959 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,27 +1,38 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
- "importHelpers": true,
- "module": "es2020",
"outDir": "./dist/out-tsc",
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "noImplicitOverride": true,
+ "noPropertyAccessFromIndexSignature": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
- "moduleResolution": "node",
+ "downlevelIteration": true,
"experimentalDecorators": true,
+ "moduleResolution": "node",
+ "importHelpers": true,
"target": "ES2022",
- "typeRoots": [
- "node_modules/@types"
- ],
+ "module": "ES2022",
+ "useDefineForClassFields": false,
"lib": [
- "es2018",
+ "ES2022",
"dom"
],
"paths": {
"ngx-uploader": [
"projects/ngx-uploader/src/public_api"
]
- },
- "useDefineForClassFields": false
+ }
+ },
+ "angularCompilerOptions": {
+ "enableI18nLegacyMessageIdFormat": false,
+ "strictInjectionParameters": true,
+ "strictInputAccessModifiers": true,
+ "strictTemplates": true
}
}
diff --git a/tslint.json b/tslint.json
deleted file mode 100644
index 8f644525..00000000
--- a/tslint.json
+++ /dev/null
@@ -1,129 +0,0 @@
-{
- "rulesDirectory": [
- "node_modules/codelyzer"
- ],
- "rules": {
- "arrow-return-shorthand": true,
- "callable-types": true,
- "class-name": true,
- "comment-format": [
- true,
- "check-space"
- ],
- "curly": true,
- "deprecation": {
- "severity": "warn"
- },
- "eofline": true,
- "forin": true,
- "import-blacklist": [
- true,
- "rxjs/Rx"
- ],
- "import-spacing": true,
- "indent": [
- true,
- "spaces"
- ],
- "interface-over-type-literal": true,
- "label-position": true,
- "max-line-length": [
- true,
- 140
- ],
- "member-access": false,
- "member-ordering": [
- true,
- {
- "order": [
- "static-field",
- "instance-field",
- "static-method",
- "instance-method"
- ]
- }
- ],
- "no-arg": true,
- "no-bitwise": true,
- "no-console": [
- true,
- "debug",
- "info",
- "time",
- "timeEnd",
- "trace"
- ],
- "no-construct": true,
- "no-debugger": true,
- "no-duplicate-super": true,
- "no-empty": false,
- "no-empty-interface": true,
- "no-eval": true,
- "no-inferrable-types": [
- true,
- "ignore-params"
- ],
- "no-misused-new": true,
- "no-non-null-assertion": true,
- "no-shadowed-variable": true,
- "no-string-literal": false,
- "no-string-throw": true,
- "no-switch-case-fall-through": true,
- "no-trailing-whitespace": true,
- "no-unnecessary-initializer": true,
- "no-unused-expression": true,
- "no-var-keyword": true,
- "object-literal-sort-keys": false,
- "one-line": [
- true,
- "check-open-brace",
- "check-catch",
- "check-else",
- "check-whitespace"
- ],
- "prefer-const": true,
- "quotemark": [
- true,
- "single"
- ],
- "radix": true,
- "semicolon": [
- true,
- "always"
- ],
- "triple-equals": [
- true,
- "allow-null-check"
- ],
- "typedef-whitespace": [
- true,
- {
- "call-signature": "nospace",
- "index-signature": "nospace",
- "parameter": "nospace",
- "property-declaration": "nospace",
- "variable-declaration": "nospace"
- }
- ],
- "unified-signatures": true,
- "variable-name": false,
- "whitespace": [
- true,
- "check-branch",
- "check-decl",
- "check-operator",
- "check-separator",
- "check-type"
- ],
- "no-output-on-prefix": true,
- "use-input-property-decorator": true,
- "use-output-property-decorator": true,
- "use-host-property-decorator": true,
- "no-input-rename": true,
- "no-output-rename": true,
- "use-life-cycle-interface": true,
- "use-pipe-transform-interface": true,
- "component-class-suffix": true,
- "directive-class-suffix": true
- }
-}