Skip to content

Commit

Permalink
Merge 06ae4ee into 3c103f7
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalourdio committed Jun 25, 2020
2 parents 3c103f7 + 06ae4ee commit 98235ec
Show file tree
Hide file tree
Showing 15 changed files with 1,735 additions and 1,486 deletions.
8 changes: 5 additions & 3 deletions browserslist → .browserslistrc
Expand Up @@ -5,8 +5,10 @@
# You can see what browsers were selected by your queries by running:
# npx browserslist

> 0.5%
last 2 versions
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 iOS major versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog

## v8.0.0
- Added angular 10 support.

## v7.0.0
- Added angular 9 support.
- BC break : `AbstractLoader` has been renamed to `AbstractLoaderDirective`. See [here](https://next.angular.io/guide/deprecations#undecorated-base-classes) and [here](https://angular.io/guide/styleguide#style-02-03).
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -36,7 +36,8 @@ The HTTP interceptor listens to all HTTP requests and shows a spinner / loader i
| >=1.0.0 <3.2.0 | ^6.0.0 |
| >=3.2.0 <5.1.0 | ^7.0.0 |
| >=6.0.0 <7.0.0 | ^8.0.0 |
| >=7.0.0 | ^9.0.0 |
| >=7.0.0 <8.0.0 | ^9.0.0 |
| >=8.0.0 | ^10.0.0 |

If you experience errors like below, **please double check the version you use.**

Expand Down
49 changes: 24 additions & 25 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "ng-http-loader",
"version": "7.0.0",
"version": "8.0.0-beta.0",
"scripts": {
"ng": "ng",
"build": "ng build",
Expand Down Expand Up @@ -38,44 +38,43 @@
"url": "https://github.com/mpalourdio/ng-http-loader/issues"
},
"dependencies": {
"tslib": "^1.10.0"
"tslib": "^2.0.0"
},
"peerDependencies": {
"@angular/common": "^9.1.0",
"@angular/core": "^9.1.0",
"rxjs": "^6.5.4"
"@angular/common": "^10.0.0",
"@angular/core": "^10.0.0",
"rxjs": "^6.5.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.0",
"@angular-devkit/build-ng-packagr": "~0.901.0",
"@angular/cli": "^9.1.0",
"@angular/common": "^9.1.0",
"@angular/compiler": "^9.1.0",
"@angular/compiler-cli": "^9.1.0",
"@angular/core": "^9.1.0",
"@angular/platform-browser": "^9.1.0",
"@angular/platform-browser-dynamic": "^9.1.0",
"@angular-devkit/build-angular": "~0.1000.0",
"@angular-devkit/build-ng-packagr": "~0.1000.0",
"@angular/cli": "^10.0.0",
"@angular/common": "^10.0.0",
"@angular/compiler": "^10.0.0",
"@angular/compiler-cli": "^10.0.0",
"@angular/core": "^10.0.0",
"@angular/platform-browser": "^10.0.0",
"@angular/platform-browser-dynamic": "^10.0.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"codelyzer": "^6.0.0-next.1",
"coveralls": "^3.0.1",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.2",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-firefox-launcher": "^1.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"ng-packagr": "^9.1.0",
"karma-jasmine": "~3.3.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^10.0.0",
"puppeteer": "^3.0.0",
"rxjs": "^6.5.4",
"rxjs": "^6.5.5",
"rxjs-tslint-rules": "^4.13.0",
"ts-node": "~8.3.0",
"tslib": "^1.10.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3",
"zone.js": "~0.10.2"
"typescript": "~3.9.5",
"zone.js": "~0.10.3"
}
}
2 changes: 1 addition & 1 deletion src/lib/components/abstract.loader.directive.ts
Expand Up @@ -12,5 +12,5 @@ import { Input, Directive } from '@angular/core';
@Directive()
export abstract class AbstractLoaderDirective {

@Input() public backgroundColor: string;
@Input() public backgroundColor!: string;
}
28 changes: 9 additions & 19 deletions src/lib/components/ng-http-loader.component.ts
Expand Up @@ -22,11 +22,11 @@ import { Spinkit } from '../spinkits';
export class NgHttpLoaderComponent implements OnInit {

public spinkit = Spinkit;
public isVisible$: Observable<boolean>;
public isVisible$!: Observable<boolean>;
private visibleUntil = Date.now();

@Input() public backdrop = true;
@Input() public backgroundColor: string;
@Input() public backgroundColor!: string;
@Input() public debounceDelay = 0;
@Input() public entryComponent: any = null;
@Input() public extraDuration = 0;
Expand All @@ -35,11 +35,17 @@ export class NgHttpLoaderComponent implements OnInit {
@Input() public filteredUrlPatterns: string[] = [];
@Input() public minDuration = 0;
@Input() public opacity = '.7';
@Input() public spinner = Spinkit.skWave;
@Input() public spinner: string | null = Spinkit.skWave;

constructor(private pendingRequestsInterceptor: PendingRequestsInterceptor, private spinnerVisibility: SpinnerVisibilityService) {
}

public ngOnInit(): void {
this.initIsvisibleObservable();
this.nullifySpinnerIfEntryComponentIsDefined();
this.initFilters();
}

private initIsvisibleObservable(): void {
const [showSpinner$, hideSpinner$] = partition(this.pendingRequestsInterceptor.pendingRequestsStatus$, h => h);

Expand All @@ -55,12 +61,6 @@ export class NgHttpLoaderComponent implements OnInit {
);
}

public ngOnInit(): void {
this.initIsvisibleObservable();
this.nullifySpinnerIfEntryComponentIsDefined();
this.initFilters();
}

private nullifySpinnerIfEntryComponentIsDefined(): void {
if (this.entryComponent) {
this.spinner = null;
Expand All @@ -74,10 +74,6 @@ export class NgHttpLoaderComponent implements OnInit {
}

private initFilteredUrlPatterns(): void {
if (!(this.filteredUrlPatterns instanceof Array)) {
throw new TypeError('`filteredUrlPatterns` must be an array.');
}

if (!!this.filteredUrlPatterns.length) {
this.filteredUrlPatterns.forEach(e =>
this.pendingRequestsInterceptor.filteredUrlPatterns.push(new RegExp(e))
Expand All @@ -86,16 +82,10 @@ export class NgHttpLoaderComponent implements OnInit {
}

private initFilteredMethods(): void {
if (!(this.filteredMethods instanceof Array)) {
throw new TypeError('`filteredMethods` must be an array.');
}
this.pendingRequestsInterceptor.filteredMethods = this.filteredMethods;
}

private initFilteredHeaders(): void {
if (!(this.filteredHeaders instanceof Array)) {
throw new TypeError('`filteredHeaders` must be an array.');
}
this.pendingRequestsInterceptor.filteredHeaders = this.filteredHeaders;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/pending-requests-interceptor.service.ts
Expand Up @@ -22,7 +22,7 @@ export class PendingRequestsInterceptor implements HttpInterceptor {
private _filteredUrlPatterns: RegExp[] = [];
private _filteredMethods: string[] = [];
private _filteredHeaders: string[] = [];
private _forceByPass: boolean;
private _forceByPass = false;

get pendingRequestsStatus$(): Observable<boolean> {
return this._pendingRequestsStatus$.asObservable();
Expand Down
15 changes: 0 additions & 15 deletions src/test/components/ng-http-loader.component.spec.ts
Expand Up @@ -252,21 +252,6 @@ describe('NgHttpLoaderComponent', () => {
expect(isVisible).toBeFalsy();
}));

it('should throw an error if filteredUrlPatterns is not an array', () => {
component.filteredUrlPatterns = null;
expect(() => component.ngOnInit()).toThrow(new Error('`filteredUrlPatterns` must be an array.'));
});

it('should throw an error if filteredMethods is not an array', () => {
component.filteredMethods = null;
expect(() => component.ngOnInit()).toThrow(new Error('`filteredMethods` must be an array.'));
});

it('should throw an error if filteredHeaders is not an array', () => {
component.filteredHeaders = null;
expect(() => component.ngOnInit()).toThrow(new Error('`filteredHeaders` must be an array.'));
});

it('should show the spinner even if the component is created after the HTTP request is performed', fakeAsync(() => {
http.get('/fake').subscribe();

Expand Down
1 change: 1 addition & 0 deletions src/test/ng-http-loader.module.spec.ts
Expand Up @@ -23,6 +23,7 @@ describe('NgHttpLoaderModule', () => {

it('should create an instance with providers via forRoot()', () => {
const ngHttpLoaderModuleWithProviders = NgHttpLoaderModule.forRoot();
// @ts-ignore
expect(ngHttpLoaderModuleWithProviders.providers[0][0].useExisting.name).toEqual(PendingRequestsInterceptor.name);
});
});
27 changes: 27 additions & 0 deletions tsconfig.base.json
@@ -0,0 +1,27 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"strictTemplates": true,
"strictInjectionParameters": true
}
}
38 changes: 16 additions & 22 deletions tsconfig.json
@@ -1,23 +1,17 @@
/*
This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
It is not intended to be used to perform a compilation.
To learn more about this file see: https://angular.io/config/solution-tsconfig.
*/
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
"files": [],
"references": [
{
"path": "././tsconfig.lib.json"
},
{
"path": "././tsconfig.spec.json"
}
]
}
5 changes: 2 additions & 3 deletions tsconfig.lib.json
@@ -1,12 +1,11 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"types": [],
"lib": [
"dom",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.lib.prod.json
@@ -1,6 +1,7 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}
}
5 changes: 2 additions & 3 deletions tsconfig.spec.json
@@ -1,10 +1,9 @@
{
"extends": "./tsconfig.json",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine",
"node"
"jasmine"
]
},
"files": [
Expand Down

0 comments on commit 98235ec

Please sign in to comment.