ngx-progressbar
Version:
<p align="center"> <img height="200px" width="200px" style="text-align: center;" src="https://rawcdn.githack.com/MurhafSousli/ngx-progressbar/e5f30ba33c83690da3249ef2a665e6168b8caeb1/projects/ngx-progressbar-demo/src/assets/logo.svg"> <h1 align="cen
1 lines • 6.46 kB
Source Map (JSON)
{"version":3,"file":"ngx-progressbar-router.mjs","sources":["../../../projects/ngx-progressbar/router/src/ng-progress-router-default.ts","../../../projects/ngx-progressbar/router/src/ng-progress-router.model.ts","../../../projects/ngx-progressbar/router/src/ng-progress-router.directive.ts","../../../projects/ngx-progressbar/router/src/ngx-progressbar-router.ts"],"sourcesContent":["import { NavigationCancel, NavigationEnd, NavigationError, NavigationStart } from '@angular/router';\r\nimport { NgProgressRouterOptions } from './ng-progress-router.model';\r\n\r\nexport const defaultRouterOptions: NgProgressRouterOptions = {\r\n minDuration: 0,\r\n startEvents: [NavigationStart],\r\n completeEvents: [NavigationEnd, NavigationCancel, NavigationError]\r\n};\r\n","import { InjectionToken, Provider, Type } from '@angular/core';\r\nimport { Event } from '@angular/router';\r\nimport { defaultRouterOptions } from './ng-progress-router-default';\r\n\r\nexport interface NgProgressRouterOptions {\r\n minDuration?: number;\r\n startEvents?: Type<Event>[];\r\n completeEvents?: Type<Event>[];\r\n}\r\n\r\nexport const NG_PROGRESS_ROUTER_OPTIONS: InjectionToken<NgProgressRouterOptions> = new InjectionToken<NgProgressRouterOptions>('NG_PROGRESS_ROUTER_OPTIONS', {\r\n providedIn: 'root',\r\n factory: () => defaultRouterOptions\r\n});\r\n\r\nexport function provideNgProgressRouter(options: NgProgressRouterOptions): Provider {\r\n return {\r\n provide: NG_PROGRESS_ROUTER_OPTIONS,\r\n useValue: { ...defaultRouterOptions, ...options },\r\n }\r\n}\r\n","import { Directive, inject, Type } from '@angular/core';\r\nimport { Event, Router } from '@angular/router';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { filter, map, tap } from 'rxjs';\r\nimport { NgProgressRef } from 'ngx-progressbar';\r\nimport { NG_PROGRESS_ROUTER_OPTIONS, NgProgressRouterOptions } from './ng-progress-router.model';\r\n\r\n/**\r\n * Check if a router event type exists in an array of router event types\r\n */\r\nfunction eventExists(routerEvent: Event, events: Type<Event>[]): boolean {\r\n return events.some((e: Type<Event>) => routerEvent instanceof e);\r\n}\r\n\r\n@Directive()\r\nclass NgProgressRouterBase {\r\n\r\n private readonly router: Router = inject(Router);\r\n\r\n private readonly config: NgProgressRouterOptions = inject(NG_PROGRESS_ROUTER_OPTIONS);\r\n\r\n readonly progressRef: NgProgressRef = inject(NgProgressRef, { host: true, self: true });\r\n\r\n constructor() {\r\n let completeTimeout: ReturnType<typeof setTimeout>;\r\n\r\n // Previously in v13, we had the router events toggle converted to a signal,\r\n // the issue with toSignal is when the new route is loaded too fast, it won't start the progressbar, causing the tests to break.\r\n // Therefore, we switched back to stream subscription to make sure it always starts and completes with the route events.\r\n this.router.events.pipe(\r\n filter((event: Event) => eventExists(event, [...this.config.startEvents, ...this.config.completeEvents])),\r\n map((event: Event) => eventExists(event, this.config.startEvents)),\r\n tap((toggle: boolean) => {\r\n clearTimeout(completeTimeout);\r\n if (toggle) {\r\n this.progressRef.start();\r\n } else {\r\n completeTimeout = setTimeout(() => {\r\n this.progressRef.complete();\r\n }, this.config.minDuration);\r\n }\r\n }),\r\n takeUntilDestroyed()\r\n ).subscribe();\r\n }\r\n}\r\n\r\n@Directive({\r\n standalone: true,\r\n selector: 'ng-progress[ngProgressRouter]'\r\n})\r\nexport class NgProgressRouter extends NgProgressRouterBase {\r\n}\r\n\r\n@Directive({\r\n standalone: true,\r\n selector: '[ngProgressRouter]:not(ng-progress)',\r\n hostDirectives: [NgProgressRef]\r\n})\r\nexport class NgProgressRouterRef extends NgProgressRouterBase {\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;AAGO,MAAM,oBAAoB,GAA4B;AAC3D,IAAA,WAAW,EAAE,CAAC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