runtime-config-loader 4.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,58 @@
1
- # runtime-config-loader
1
+ # Angular Runtime Configuration Loader
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Most applications require certain configuration values that can be changed at runtime of the app. The `environment.ts` files in an Angular application technically work for setting configuration values in an app, but those are buildtime configuration values. This means that they are set when the application is built, and can't be changed unless the app is built again.
4
4
 
5
- ## Running unit tests
5
+ ## Overview
6
6
 
7
- Run `nx test runtime-config-loader` to execute the unit tests.
7
+ This library provides an easy way to load one or more JSON files with configuration values or make one or more HTTP GET calls to an API endpoint that returns those values. The config objects that are returned from the call(s) will be combined into a single configuration object. You can then use that configuration throughout the application. The default location of the JSON file is in the `assets` folder, at `./assets/config.json`. When the service loads the file, it stores that configuration object in a local variable which can be accessed via the `getConfig()` and `getConfigObjectKey(key: string)` methods. `getConfig` returns the entire configuration object; `getConfigObjectKey(key: string)` returns part of the configuration object, namely the part defined by the key passed in. In some cases, the `config.json` is not finished loading before other modules/services are, so the above methods will return null. If that is the case, subscribe to the `configSubject` and access the configuration object that way.
8
+
9
+ ## How to Implement
10
+
11
+ In your `app.module.ts` file, add the following to the `@NgModule` decorator:
12
+
13
+ ```ts
14
+ imports: [..., RuntimeConfigLoaderModule, ...],
15
+ ```
16
+
17
+ That's it; it's that simple. In the `RuntimeConfigLoaderModule`, the `APP_INITIALIZER` token is used to run a function which loads the configuration from a file or an API endpoint that can be used throughout the application.
18
+
19
+ If you implement the library exactly as it is above, the configuration file needs to be in the `./assets/config.json` location as mentioned above. If you'd like to load the file from a different location, provide that location in the `.forRoot()` method when importing the `RuntimeConfigLoaderModule`:
20
+
21
+ ```ts
22
+ imports: [
23
+ ...,
24
+ RuntimeConfigLoaderModule.forRoot(
25
+ { configUrl: './path/to/config/config.json' }
26
+ ),
27
+ ...]
28
+ ```
29
+
30
+ If you want to load multiple files, the value of `configUrl` should be an array of strings:
31
+
32
+ ```ts
33
+ imports: [
34
+ ...,
35
+ RuntimeConfigLoaderModule.forRoot(
36
+ { configUrl: ['./path/to/config/config-1.json', './path/to/config/config-2.json'] }
37
+ ),
38
+ ...]
39
+ ```
40
+
41
+ > Make sure that the path(s) you provide here is accessible by the Angular application, meaning that the file is somewhere the app can load it. In my opinion, the `assets` folder is the easiest place to work from.
42
+
43
+ ## Multiple Config Paths
44
+
45
+ One reason you may want to load multiple configuration objects is so that you can set the configuration on your machine without affecting anyone else. For example, you could have a `local.config.json` file that is not included in source control. Some of the values in that file would overwrite the values in a config file that everyone can use. Another use case is that some config values don't change between environments, and some do. The ones that don't change could go in one file, the ones that do change could go in a second file. Each developer/environment can provide the second file with values they want or need.
46
+
47
+ It's important to know that if an attribute is repeated in two configuration files, the latest value is kept. So, let's say you have `apiUrl` in both files, `config-1.json` and `config-2.json`. Let's assume the files are passed in to the `forRoot` method like this:
48
+
49
+ ```ts
50
+ imports: [
51
+ ...,
52
+ RuntimeConfigLoaderModule.forRoot(
53
+ { configUrl: ['./path/to/config/config-1.json', './path/to/config/config-2.json'] }
54
+ ),
55
+ ...]
56
+ ```
57
+
58
+ In this case, the `apiUrl` value from `config-2.json` will override the value from `config-1.json`.
@@ -0,0 +1,4 @@
1
+ export * from './lib/runtime-config-loader.module';
2
+ export * from './lib/runtime-config';
3
+ export * from './lib/runtime-config-loader/runtime-config-loader.service';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL3J1bnRpbWUtY29uZmlnLWxvYWRlci9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxvQ0FBb0MsQ0FBQztBQUNuRCxjQUFjLHNCQUFzQixDQUFDO0FBQ3JDLGNBQWMsMkRBQTJELENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2xpYi9ydW50aW1lLWNvbmZpZy1sb2FkZXIubW9kdWxlJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3J1bnRpbWUtY29uZmlnJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3J1bnRpbWUtY29uZmlnLWxvYWRlci9ydW50aW1lLWNvbmZpZy1sb2FkZXIuc2VydmljZSc7XG4iXX0=
@@ -0,0 +1,53 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Injectable, Optional } from '@angular/core';
3
+ import { RuntimeConfig } from '../runtime-config';
4
+ import { forkJoin, of, Subject } from 'rxjs';
5
+ import { catchError, take, tap } from 'rxjs/operators';
6
+ import * as i0 from "@angular/core";
7
+ import * as i1 from "@angular/common/http";
8
+ import * as i2 from "../runtime-config";
9
+ export class RuntimeConfigLoaderService {
10
+ constructor(_http, config) {
11
+ this._http = _http;
12
+ this.configUrl = './assets/config.json';
13
+ this.configObject = null;
14
+ this.configSubject = new Subject();
15
+ if (config) {
16
+ this.configUrl = config.configUrl;
17
+ }
18
+ }
19
+ loadConfig() {
20
+ const urls = Array.isArray(this.configUrl)
21
+ ? this.configUrl
22
+ : [this.configUrl];
23
+ const observables = urls.map((url) => this.makeHttpCall(url));
24
+ return forkJoin(observables).pipe(tap((configDataArray) => {
25
+ this.configObject = configDataArray.reduce((acc, configData) => {
26
+ return { ...acc, ...configData };
27
+ }, {});
28
+ this.configSubject.next(this.configObject);
29
+ }), catchError((err) => {
30
+ console.error('Error loading config: ', err);
31
+ this.configObject = null;
32
+ this.configSubject.next(this.configObject);
33
+ return of(null);
34
+ }));
35
+ }
36
+ makeHttpCall(url) {
37
+ return this._http.get(url).pipe(take(1));
38
+ }
39
+ getConfig() {
40
+ return this.configObject;
41
+ }
42
+ getConfigObjectKey(key) {
43
+ return this.configObject ? this.configObject[key] : null;
44
+ }
45
+ }
46
+ RuntimeConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService, deps: [{ token: i1.HttpClient }, { token: i2.RuntimeConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
47
+ RuntimeConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService });
48
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService, decorators: [{
49
+ type: Injectable
50
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.RuntimeConfig, decorators: [{
51
+ type: Optional
52
+ }] }]; } });
53
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVudGltZS1jb25maWctbG9hZGVyLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL3J1bnRpbWUtY29uZmlnLWxvYWRlci9zcmMvbGliL3J1bnRpbWUtY29uZmlnLWxvYWRlci9ydW50aW1lLWNvbmZpZy1sb2FkZXIuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDbEQsT0FBTyxFQUFFLFVBQVUsRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDckQsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ2xELE9BQU8sRUFBRSxRQUFRLEVBQWMsRUFBRSxFQUFFLE9BQU8sRUFBTyxNQUFNLE1BQU0sQ0FBQztBQUM5RCxPQUFPLEVBQUUsVUFBVSxFQUFFLElBQUksRUFBRSxHQUFHLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQzs7Ozt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0 +1,49 @@
1
+ import { HttpClientModule } from '@angular/common/http';
2
+ import { APP_INITIALIZER, NgModule } from '@angular/core';
3
+ import { RuntimeConfig } from './runtime-config';
4
+ import { RuntimeConfigLoaderService } from './runtime-config-loader/runtime-config-loader.service';
5
+ import * as i0 from "@angular/core";
6
+ export function initConfig(configSvc) {
7
+ return () => configSvc.loadConfig();
8
+ }
9
+ export class RuntimeConfigLoaderModule {
10
+ static forRoot(config) {
11
+ return {
12
+ ngModule: RuntimeConfigLoaderModule,
13
+ providers: [
14
+ {
15
+ provide: RuntimeConfig,
16
+ useValue: config,
17
+ },
18
+ RuntimeConfigLoaderService,
19
+ ],
20
+ };
21
+ }
22
+ }
23
+ RuntimeConfigLoaderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
24
+ RuntimeConfigLoaderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, imports: [HttpClientModule] });
25
+ RuntimeConfigLoaderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, providers: [
26
+ RuntimeConfigLoaderService,
27
+ {
28
+ provide: APP_INITIALIZER,
29
+ useFactory: initConfig,
30
+ deps: [RuntimeConfigLoaderService],
31
+ multi: true,
32
+ },
33
+ ], imports: [[HttpClientModule]] });
34
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, decorators: [{
35
+ type: NgModule,
36
+ args: [{
37
+ imports: [HttpClientModule],
38
+ providers: [
39
+ RuntimeConfigLoaderService,
40
+ {
41
+ provide: APP_INITIALIZER,
42
+ useFactory: initConfig,
43
+ deps: [RuntimeConfigLoaderService],
44
+ multi: true,
45
+ },
46
+ ],
47
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Q2xpZW50TW9kdWxlXSxcblx0cHJvdmlkZXJzOiBbXG5cdFx0UnVudGltZUNvbmZpZ0xvYWRlclNlcnZpY2UsXG5cdFx0e1xuXHRcdFx0cHJvdmlkZTogQVBQX0lOSVRJQUxJWkVSLFxuXHRcdFx0dXNlRmFjdG9yeTogaW5pdENvbmZpZyxcblx0XHRcdGRlcHM6IFtSdW50aW1lQ29uZmlnTG9hZGVyU2VydmljZV0sXG5cdFx0XHRtdWx0aTogdHJ1ZSxcblx0XHR9LFxuXHRdLFxufSlcbmV4cG9ydCBjbGFzcyBSdW50aW1lQ29uZmlnTG9hZGVyTW9kdWxlIHtcblx0c3RhdGljIGZvclJvb3QoXG5cdFx0Y29uZmlnOiBSdW50aW1lQ29uZmlnXG5cdCk6IE1vZHVsZVdpdGhQcm92aWRlcnM8UnVudGltZUNvbmZpZ0xvYWRlck1vZHVsZT4ge1xuXHRcdHJldHVybiB7XG5cdFx0XHRuZ01vZHVsZTogUnVudGltZUNvbmZpZ0xvYWRlck1vZHVsZSxcblx0XHRcdHByb3ZpZGVyczogW1xuXHRcdFx0XHR7XG5cdFx0XHRcdFx0cHJvdmlkZTogUnVudGltZUNvbmZpZyxcblx0XHRcdFx0XHR1c2VWYWx1ZTogY29uZmlnLFxuXHRcdFx0XHR9LFxuXHRcdFx0XHRSdW50aW1lQ29uZmlnTG9hZGVyU2VydmljZSxcblx0XHRcdF0sXG5cdFx0fTtcblx0fVxufVxuIl19
@@ -0,0 +1,6 @@
1
+ export class RuntimeConfig {
2
+ constructor(obj = {}) {
3
+ this.configUrl = obj.configUrl || './assets/config.json';
4
+ }
5
+ }
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVudGltZS1jb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL3J1bnRpbWUtY29uZmlnLWxvYWRlci9zcmMvbGliL3J1bnRpbWUtY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sT0FBTyxhQUFhO0lBR3pCLFlBQVksTUFBVyxFQUFFO1FBQ3hCLElBQUksQ0FBQyxTQUFTLEdBQUcsR0FBRyxDQUFDLFNBQVMsSUFBSSxzQkFBc0IsQ0FBQztJQUMxRCxDQUFDO0NBQ0QiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY2xhc3MgUnVudGltZUNvbmZpZyB7XG5cdGNvbmZpZ1VybDogc3RyaW5nIHwgc3RyaW5nW107XG5cblx0Y29uc3RydWN0b3Iob2JqOiBhbnkgPSB7fSkge1xuXHRcdHRoaXMuY29uZmlnVXJsID0gb2JqLmNvbmZpZ1VybCB8fCAnLi9hc3NldHMvY29uZmlnLmpzb24nO1xuXHR9XG59XG4iXX0=
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVudGltZS1jb25maWctbG9hZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vbGlicy9ydW50aW1lLWNvbmZpZy1sb2FkZXIvc3JjL3J1bnRpbWUtY29uZmlnLWxvYWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
@@ -0,0 +1,110 @@
1
+ import * as i1 from '@angular/common/http';
2
+ import { HttpClientModule } from '@angular/common/http';
3
+ import * as i0 from '@angular/core';
4
+ import { Injectable, Optional, APP_INITIALIZER, NgModule } from '@angular/core';
5
+ import { Subject, forkJoin, of } from 'rxjs';
6
+ import { tap, catchError, take } from 'rxjs/operators';
7
+
8
+ class RuntimeConfig {
9
+ constructor(obj = {}) {
10
+ this.configUrl = obj.configUrl || './assets/config.json';
11
+ }
12
+ }
13
+
14
+ class RuntimeConfigLoaderService {
15
+ constructor(_http, config) {
16
+ this._http = _http;
17
+ this.configUrl = './assets/config.json';
18
+ this.configObject = null;
19
+ this.configSubject = new Subject();
20
+ if (config) {
21
+ this.configUrl = config.configUrl;
22
+ }
23
+ }
24
+ loadConfig() {
25
+ const urls = Array.isArray(this.configUrl)
26
+ ? this.configUrl
27
+ : [this.configUrl];
28
+ const observables = urls.map((url) => this.makeHttpCall(url));
29
+ return forkJoin(observables).pipe(tap((configDataArray) => {
30
+ this.configObject = configDataArray.reduce((acc, configData) => {
31
+ return Object.assign(Object.assign({}, acc), configData);
32
+ }, {});
33
+ this.configSubject.next(this.configObject);
34
+ }), catchError((err) => {
35
+ console.error('Error loading config: ', err);
36
+ this.configObject = null;
37
+ this.configSubject.next(this.configObject);
38
+ return of(null);
39
+ }));
40
+ }
41
+ makeHttpCall(url) {
42
+ return this._http.get(url).pipe(take(1));
43
+ }
44
+ getConfig() {
45
+ return this.configObject;
46
+ }
47
+ getConfigObjectKey(key) {
48
+ return this.configObject ? this.configObject[key] : null;
49
+ }
50
+ }
51
+ RuntimeConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService, deps: [{ token: i1.HttpClient }, { token: RuntimeConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
52
+ RuntimeConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService });
53
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService, decorators: [{
54
+ type: Injectable
55
+ }], ctorParameters: function () {
56
+ return [{ type: i1.HttpClient }, { type: RuntimeConfig, decorators: [{
57
+ type: Optional
58
+ }] }];
59
+ } });
60
+
61
+ function initConfig(configSvc) {
62
+ return () => configSvc.loadConfig();
63
+ }
64
+ class RuntimeConfigLoaderModule {
65
+ static forRoot(config) {
66
+ return {
67
+ ngModule: RuntimeConfigLoaderModule,
68
+ providers: [
69
+ {
70
+ provide: RuntimeConfig,
71
+ useValue: config,
72
+ },
73
+ RuntimeConfigLoaderService,
74
+ ],
75
+ };
76
+ }
77
+ }
78
+ RuntimeConfigLoaderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
79
+ RuntimeConfigLoaderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, imports: [HttpClientModule] });
80
+ RuntimeConfigLoaderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, providers: [
81
+ RuntimeConfigLoaderService,
82
+ {
83
+ provide: APP_INITIALIZER,
84
+ useFactory: initConfig,
85
+ deps: [RuntimeConfigLoaderService],
86
+ multi: true,
87
+ },
88
+ ], imports: [[HttpClientModule]] });
89
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, decorators: [{
90
+ type: NgModule,
91
+ args: [{
92
+ imports: [HttpClientModule],
93
+ providers: [
94
+ RuntimeConfigLoaderService,
95
+ {
96
+ provide: APP_INITIALIZER,
97
+ useFactory: initConfig,
98
+ deps: [RuntimeConfigLoaderService],
99
+ multi: true,
100
+ },
101
+ ],
102
+ }]
103
+ }] });
104
+
105
+ /**
106
+ * Generated bundle index. Do not edit.
107
+ */
108
+
109
+ export { RuntimeConfig, RuntimeConfigLoaderModule, RuntimeConfigLoaderService, initConfig };
110
+ //# sourceMappingURL=runtime-config-loader.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-config-loader.mjs","sources":["../../../../libs/runtime-config-loader/src/lib/runtime-config.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader/runtime-config-loader.service.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader.module.ts","../../../../libs/runtime-config-loader/src/runtime-config-loader.ts"],"sourcesContent":["export class RuntimeConfig {\n\tconfigUrl: string | string[];\n\n\tconstructor(obj: any = {}) {\n\t\tthis.configUrl = obj.configUrl || './assets/config.json';\n\t}\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable, Optional } from '@angular/core';\nimport { RuntimeConfig } from '../runtime-config';\nimport { forkJoin, Observable, of, Subject, zip } from 'rxjs';\nimport { catchError, take, tap } from 'rxjs/operators';\n\n@Injectable()\nexport class RuntimeConfigLoaderService {\n\tprivate configUrl: string | string[] = './assets/config.json';\n\tprivate configObject: any = null;\n\tpublic configSubject: Subject<any> = new Subject<any>();\n\n\tconstructor(private _http: HttpClient, @Optional() config: RuntimeConfig) {\n\t\tif (config) {\n\t\t\tthis.configUrl = config.configUrl;\n\t\t}\n\t}\n\n\tloadConfig(): Observable<any> {\n\t\tconst urls: string[] = Array.isArray(this.configUrl)\n\t\t\t? this.configUrl\n\t\t\t: [this.configUrl];\n\n\t\tconst observables: Observable<any>[] = urls.map((url) =>\n\t\t\tthis.makeHttpCall(url)\n\t\t);\n\n\t\treturn forkJoin(observables).pipe(\n\t\t\ttap((configDataArray: any[]) => {\n\t\t\t\tthis.configObject = configDataArray.reduce(\n\t\t\t\t\t(acc, configData) => {\n\t\t\t\t\t\treturn { ...acc, ...configData };\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t}),\n\t\t\tcatchError((err: any) => {\n\t\t\t\tconsole.error('Error loading config: ', err);\n\t\t\t\tthis.configObject = null;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t\treturn of(null);\n\t\t\t})\n\t\t);\n\t}\n\n\tprivate makeHttpCall(url: string): Observable<any> {\n\t\treturn this._http.get(url).pipe(take(1));\n\t}\n\n\tgetConfig() {\n\t\treturn this.configObject;\n\t}\n\n\tgetConfigObjectKey(key: string) {\n\t\treturn this.configObject ? this.configObject[key] : null;\n\t}\n}\n","import { HttpClientModule } from '@angular/common/http';\nimport { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';\nimport { RuntimeConfig } from './runtime-config';\nimport { RuntimeConfigLoaderService } from './runtime-config-loader/runtime-config-loader.service';\n\nexport function initConfig(configSvc: RuntimeConfigLoaderService) {\n\treturn () => configSvc.loadConfig();\n}\n\n@NgModule({\n\timports: [HttpClientModule],\n\tproviders: [\n\t\tRuntimeConfigLoaderService,\n\t\t{\n\t\t\tprovide: APP_INITIALIZER,\n\t\t\tuseFactory: initConfig,\n\t\t\tdeps: [RuntimeConfigLoaderService],\n\t\t\tmulti: true,\n\t\t},\n\t],\n})\nexport class RuntimeConfigLoaderModule {\n\tstatic forRoot(\n\t\tconfig: RuntimeConfig\n\t): ModuleWithProviders<RuntimeConfigLoaderModule> {\n\t\treturn {\n\t\t\tngModule: RuntimeConfigLoaderModule,\n\t\t\tproviders: [\n\t\t\t\t{\n\t\t\t\t\tprovide: RuntimeConfig,\n\t\t\t\t\tuseValue: config,\n\t\t\t\t},\n\t\t\t\tRuntimeConfigLoaderService,\n\t\t\t],\n\t\t};\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i2.RuntimeConfig"],"mappings":";;;;;;;MAAa,aAAa,CAAA;IAGzB,WAAY,CAAA,MAAW,EAAE,EAAA;QACxB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,sBAAsB,CAAC;KACzD;AACD;;MCCY,0BAA0B,CAAA;IAKtC,WAAoB,CAAA,KAAiB,EA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A,CAAA,QAAA,EAAA,CAAA,CAAA;AAAzB,yBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,YAX3B,gBAAgB,CAAA,EAAA,CAAA,CAAA;AAWd,yBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,EAV1B,SAAA,EAAA;QACV,0BAA0B;AAC1B,QAAA;AACC,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,UAAU,EAAE,UAAU;YACtB,IAAI,EAAE,CAAC,0BAA0B,CAAC;AAClC,YAAA,KAAK,EAAE,IAAI;AACX,SAAA;KACD,EATQ,OAAA,EAAA,CAAA,CAAC,gBAAgB,CAAC,CAAA,EAAA,CAAA,CAAA;2FAWf,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAZrC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACT,OAAO,EAAE,CAAC,gBAAgB,CAAC;AAC3B,oBAAA,SAAS,EAAE;wBACV,0BAA0B;AAC1B,wBAAA;AACC,4BAAA,OAAO,EAAE,eAAe;AACxB,4BAAA,UAAU,EAAE,UAAU;4BACtB,IAAI,EAAE,CAAC,0BAA0B,CAAC;AAClC,4BAAA,KAAK,EAAE,IAAI;AACX,yBAAA;AACD,qBAAA;iBACD,CAAA;;;ACpBD;;AAEG;;;;"}
@@ -2,8 +2,8 @@ import * as i1 from '@angular/common/http';
2
2
  import { HttpClientModule } from '@angular/common/http';
3
3
  import * as i0 from '@angular/core';
4
4
  import { Injectable, Optional, APP_INITIALIZER, NgModule } from '@angular/core';
5
- import { Subject, of } from 'rxjs';
6
- import { tap, catchError } from 'rxjs/operators';
5
+ import { Subject, forkJoin, of } from 'rxjs';
6
+ import { tap, catchError, take } from 'rxjs/operators';
7
7
 
8
8
  class RuntimeConfig {
9
9
  constructor(obj = {}) {
@@ -22,8 +22,14 @@ class RuntimeConfigLoaderService {
22
22
  }
23
23
  }
24
24
  loadConfig() {
25
- return this._http.get(this.configUrl).pipe(tap((configData) => {
26
- this.configObject = configData;
25
+ const urls = Array.isArray(this.configUrl)
26
+ ? this.configUrl
27
+ : [this.configUrl];
28
+ const observables = urls.map((url) => this.makeHttpCall(url));
29
+ return forkJoin(observables).pipe(tap((configDataArray) => {
30
+ this.configObject = configDataArray.reduce((acc, configData) => {
31
+ return { ...acc, ...configData };
32
+ }, {});
27
33
  this.configSubject.next(this.configObject);
28
34
  }), catchError((err) => {
29
35
  console.error('Error loading config: ', err);
@@ -32,6 +38,9 @@ class RuntimeConfigLoaderService {
32
38
  return of(null);
33
39
  }));
34
40
  }
41
+ makeHttpCall(url) {
42
+ return this._http.get(url).pipe(take(1));
43
+ }
35
44
  getConfig() {
36
45
  return this.configObject;
37
46
  }
@@ -39,9 +48,9 @@ class RuntimeConfigLoaderService {
39
48
  return this.configObject ? this.configObject[key] : null;
40
49
  }
41
50
  }
42
- RuntimeConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderService, deps: [{ token: i1.HttpClient }, { token: RuntimeConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
43
- RuntimeConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderService });
44
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderService, decorators: [{
51
+ RuntimeConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService, deps: [{ token: i1.HttpClient }, { token: RuntimeConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
52
+ RuntimeConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService });
53
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderService, decorators: [{
45
54
  type: Injectable
46
55
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: RuntimeConfig, decorators: [{
47
56
  type: Optional
@@ -64,9 +73,9 @@ class RuntimeConfigLoaderModule {
64
73
  };
65
74
  }
66
75
  }
67
- RuntimeConfigLoaderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
68
- RuntimeConfigLoaderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, imports: [HttpClientModule] });
69
- RuntimeConfigLoaderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, providers: [
76
+ RuntimeConfigLoaderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
77
+ RuntimeConfigLoaderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, imports: [HttpClientModule] });
78
+ RuntimeConfigLoaderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, providers: [
70
79
  RuntimeConfigLoaderService,
71
80
  {
72
81
  provide: APP_INITIALIZER,
@@ -75,7 +84,7 @@ RuntimeConfigLoaderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0
75
84
  multi: true,
76
85
  },
77
86
  ], imports: [[HttpClientModule]] });
78
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, decorators: [{
87
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RuntimeConfigLoaderModule, decorators: [{
79
88
  type: NgModule,
80
89
  args: [{
81
90
  imports: [HttpClientModule],
@@ -96,4 +105,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImpor
96
105
  */
97
106
 
98
107
  export { RuntimeConfig, RuntimeConfigLoaderModule, RuntimeConfigLoaderService, initConfig };
99
- //# sourceMappingURL=runtime-config-loader.js.map
108
+ //# sourceMappingURL=runtime-config-loader.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-config-loader.mjs","sources":["../../../../libs/runtime-config-loader/src/lib/runtime-config.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader/runtime-config-loader.service.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader.module.ts","../../../../libs/runtime-config-loader/src/runtime-config-loader.ts"],"sourcesContent":["export class RuntimeConfig {\n\tconfigUrl: string | string[];\n\n\tconstructor(obj: any = {}) {\n\t\tthis.configUrl = obj.configUrl || './assets/config.json';\n\t}\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable, Optional } from '@angular/core';\nimport { RuntimeConfig } from '../runtime-config';\nimport { forkJoin, Observable, of, Subject, zip } from 'rxjs';\nimport { catchError, take, tap } from 'rxjs/operators';\n\n@Injectable()\nexport class RuntimeConfigLoaderService {\n\tprivate configUrl: string | string[] = './assets/config.json';\n\tprivate configObject: any = null;\n\tpublic configSubject: Subject<any> = new Subject<any>();\n\n\tconstructor(private _http: HttpClient, @Optional() config: RuntimeConfig) {\n\t\tif (config) {\n\t\t\tthis.configUrl = config.configUrl;\n\t\t}\n\t}\n\n\tloadConfig(): Observable<any> {\n\t\tconst urls: string[] = Array.isArray(this.configUrl)\n\t\t\t? this.configUrl\n\t\t\t: [this.configUrl];\n\n\t\tconst observables: Observable<any>[] = urls.map((url) =>\n\t\t\tthis.makeHttpCall(url)\n\t\t);\n\n\t\treturn forkJoin(observables).pipe(\n\t\t\ttap((configDataArray: any[]) => {\n\t\t\t\tthis.configObject = configDataArray.reduce(\n\t\t\t\t\t(acc, configData) => {\n\t\t\t\t\t\treturn { ...acc, ...configData };\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t}),\n\t\t\tcatchError((err: any) => {\n\t\t\t\tconsole.error('Error loading config: ', err);\n\t\t\t\tthis.configObject = null;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t\treturn of(null);\n\t\t\t})\n\t\t);\n\t}\n\n\tprivate makeHttpCall(url: string): Observable<any> {\n\t\treturn this._http.get(url).pipe(take(1));\n\t}\n\n\tgetConfig() {\n\t\treturn this.configObject;\n\t}\n\n\tgetConfigObjectKey(key: string) {\n\t\treturn this.configObject ? this.configObject[key] : null;\n\t}\n}\n","import { HttpClientModule } from '@angular/common/http';\nimport { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';\nimport { RuntimeConfig } from './runtime-config';\nimport { RuntimeConfigLoaderService } from './runtime-config-loader/runtime-config-loader.service';\n\nexport function initConfig(configSvc: RuntimeConfigLoaderService) {\n\treturn () => configSvc.loadConfig();\n}\n\n@NgModule({\n\timports: [HttpClientModule],\n\tproviders: [\n\t\tRuntimeConfigLoaderService,\n\t\t{\n\t\t\tprovide: APP_INITIALIZER,\n\t\t\tuseFactory: initConfig,\n\t\t\tdeps: [RuntimeConfigLoaderService],\n\t\t\tmulti: true,\n\t\t},\n\t],\n})\nexport class RuntimeConfigLoaderModule {\n\tstatic forRoot(\n\t\tconfig: RuntimeConfig\n\t): ModuleWithProviders<RuntimeConfigLoaderModule> {\n\t\treturn {\n\t\t\tngModule: RuntimeConfigLoaderModule,\n\t\t\tproviders: [\n\t\t\t\t{\n\t\t\t\t\tprovide: RuntimeConfig,\n\t\t\t\t\tuseValue: config,\n\t\t\t\t},\n\t\t\t\tRuntimeConfigLoaderService,\n\t\t\t],\n\t\t};\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i2.RuntimeConfig"],"mappings":";;;;;;;MAAa,aAAa,CAAA;AAGzB,IAAA,WAAA,CAAY,MAAW,EAAE,EAAA;QACxB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,sBAAsB,CAAC;KACzD;AACD;;MCCY,0BAA0B,CAAA;IAKtC,WAAoB,CAAA,KAAiB,EAAc,MAAqB,EAAA;QAApD,IAAK,CAAA,KAAA,GAAL,KAAK,CAAY;QAJ7B,IAAS,CAAA,SAAA,GAAsB,sBAAsB,CAAC;QACtD,IAAY,CAAA,YAAA,GAAQ,IAAI,CAAC;AAC1B,QAAA,IAAA,CAAA,aAAa,GAAiB,IAAI,OAAO,EAAO,CAAC;AAGvD,QAAA,IAAI,MAAM,EAAE;AACX,YAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;AAClC,SAAA;KACD;IAED,UAAU,GAAA;QACT,MAAM,IAAI,GAAa,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;cACjD,IAAI,CAAC,SAAS;AAChB,cAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAEpB,QAAA,MAAM,WAAW,GAAsB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KACnD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CACtB,CAAC;AAEF,QAAA,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,CAChC,GAAG,CAAC,CAAC,eAAsB,KAAI;AAC9B,YAAA,IAAI,CAA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AAS,EAAE;wBACV,0BAA0B;AAC1B,wBAAA;AACC,4BAAA,OAAO,EAAE,eAAe;AACxB,4BAAA,UAAU,EAAE,UAAU;4BACtB,IAAI,EAAE,CAAC,0BAA0B,CAAC;AAClC,4BAAA,KAAK,EAAE,IAAI;AACX,yBAAA;AACD,qBAAA;AACD,iBAAA,CAAA;;;ACpBD;;AAEG;;;;"}
@@ -9,6 +9,7 @@ export declare class RuntimeConfigLoaderService {
9
9
  configSubject: Subject<any>;
10
10
  constructor(_http: HttpClient, config: RuntimeConfig);
11
11
  loadConfig(): Observable<any>;
12
+ private makeHttpCall;
12
13
  getConfig(): any;
13
14
  getConfigObjectKey(key: string): any;
14
15
  static ɵfac: i0.ɵɵFactoryDeclaration<RuntimeConfigLoaderService, [null, { optional: true; }]>;
@@ -1,4 +1,4 @@
1
1
  export declare class RuntimeConfig {
2
- configUrl: string;
2
+ configUrl: string | string[];
3
3
  constructor(obj?: any);
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runtime-config-loader",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "author": {
5
5
  "email": "preston.j.lamb@gmail.com",
6
6
  "name": "Preston Lamb",
@@ -23,18 +23,32 @@
23
23
  "config"
24
24
  ],
25
25
  "peerDependencies": {
26
- "@angular/common": ">=12.0.0",
27
- "@angular/core": ">=12.0.0",
28
- "rxjs": "~6.6.0"
26
+ "@angular/common": ">=13.0.0",
27
+ "@angular/core": ">=13.0.0",
28
+ "rxjs": "~6.6.0",
29
+ "@angular/platform-browser-dynamic": "13.3.5"
29
30
  },
30
31
  "dependencies": {
31
32
  "tslib": "^2.3.0"
32
33
  },
33
- "main": "bundles/runtime-config-loader.umd.js",
34
- "module": "fesm2015/runtime-config-loader.js",
35
- "es2015": "fesm2015/runtime-config-loader.js",
36
- "esm2015": "esm2015/runtime-config-loader.js",
37
- "fesm2015": "fesm2015/runtime-config-loader.js",
34
+ "module": "fesm2015/runtime-config-loader.mjs",
35
+ "es2020": "fesm2020/runtime-config-loader.mjs",
36
+ "esm2020": "esm2020/runtime-config-loader.mjs",
37
+ "fesm2020": "fesm2020/runtime-config-loader.mjs",
38
+ "fesm2015": "fesm2015/runtime-config-loader.mjs",
38
39
  "typings": "runtime-config-loader.d.ts",
40
+ "exports": {
41
+ "./package.json": {
42
+ "default": "./package.json"
43
+ },
44
+ ".": {
45
+ "types": "./runtime-config-loader.d.ts",
46
+ "esm2020": "./esm2020/runtime-config-loader.mjs",
47
+ "es2020": "./fesm2020/runtime-config-loader.mjs",
48
+ "es2015": "./fesm2015/runtime-config-loader.mjs",
49
+ "node": "./fesm2015/runtime-config-loader.mjs",
50
+ "default": "./fesm2020/runtime-config-loader.mjs"
51
+ }
52
+ },
39
53
  "sideEffects": false
40
54
  }
Binary file
@@ -1,137 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('rxjs'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('runtime-config-loader', ['exports', '@angular/common/http', '@angular/core', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['runtime-config-loader'] = {}, global.ng.common.http, global.ng.core, global.rxjs, global.rxjs.operators));
5
- }(this, (function (exports, i1, i0, rxjs, operators) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
29
-
30
- var RuntimeConfig = /** @class */ (function () {
31
- function RuntimeConfig(obj) {
32
- if (obj === void 0) { obj = {}; }
33
- this.configUrl = obj.configUrl || './assets/config.json';
34
- }
35
- return RuntimeConfig;
36
- }());
37
-
38
- var RuntimeConfigLoaderService = /** @class */ (function () {
39
- function RuntimeConfigLoaderService(_http, config) {
40
- this._http = _http;
41
- this.configUrl = './assets/config.json';
42
- this.configObject = null;
43
- this.configSubject = new rxjs.Subject();
44
- if (config) {
45
- this.configUrl = config.configUrl;
46
- }
47
- }
48
- RuntimeConfigLoaderService.prototype.loadConfig = function () {
49
- var _this = this;
50
- return this._http.get(this.configUrl).pipe(operators.tap(function (configData) {
51
- _this.configObject = configData;
52
- _this.configSubject.next(_this.configObject);
53
- }), operators.catchError(function (err) {
54
- console.error('Error loading config: ', err);
55
- _this.configObject = null;
56
- _this.configSubject.next(_this.configObject);
57
- return rxjs.of(null);
58
- }));
59
- };
60
- RuntimeConfigLoaderService.prototype.getConfig = function () {
61
- return this.configObject;
62
- };
63
- RuntimeConfigLoaderService.prototype.getConfigObjectKey = function (key) {
64
- return this.configObject ? this.configObject[key] : null;
65
- };
66
- return RuntimeConfigLoaderService;
67
- }());
68
- RuntimeConfigLoaderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: RuntimeConfigLoaderService, deps: [{ token: i1__namespace.HttpClient }, { token: RuntimeConfig, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
69
- RuntimeConfigLoaderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: RuntimeConfigLoaderService });
70
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: RuntimeConfigLoaderService, decorators: [{
71
- type: i0.Injectable
72
- }], ctorParameters: function () {
73
- return [{ type: i1__namespace.HttpClient }, { type: RuntimeConfig, decorators: [{
74
- type: i0.Optional
75
- }] }];
76
- } });
77
-
78
- function initConfig(configSvc) {
79
- return function () { return configSvc.loadConfig(); };
80
- }
81
- var RuntimeConfigLoaderModule = /** @class */ (function () {
82
- function RuntimeConfigLoaderModule() {
83
- }
84
- RuntimeConfigLoaderModule.forRoot = function (config) {
85
- return {
86
- ngModule: RuntimeConfigLoaderModule,
87
- providers: [
88
- {
89
- provide: RuntimeConfig,
90
- useValue: config,
91
- },
92
- RuntimeConfigLoaderService,
93
- ],
94
- };
95
- };
96
- return RuntimeConfigLoaderModule;
97
- }());
98
- RuntimeConfigLoaderModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: RuntimeConfigLoaderModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
99
- RuntimeConfigLoaderModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: RuntimeConfigLoaderModule, imports: [i1.HttpClientModule] });
100
- RuntimeConfigLoaderModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: RuntimeConfigLoaderModule, providers: [
101
- RuntimeConfigLoaderService,
102
- {
103
- provide: i0.APP_INITIALIZER,
104
- useFactory: initConfig,
105
- deps: [RuntimeConfigLoaderService],
106
- multi: true,
107
- },
108
- ], imports: [[i1.HttpClientModule]] });
109
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: RuntimeConfigLoaderModule, decorators: [{
110
- type: i0.NgModule,
111
- args: [{
112
- imports: [i1.HttpClientModule],
113
- providers: [
114
- RuntimeConfigLoaderService,
115
- {
116
- provide: i0.APP_INITIALIZER,
117
- useFactory: initConfig,
118
- deps: [RuntimeConfigLoaderService],
119
- multi: true,
120
- },
121
- ],
122
- }]
123
- }] });
124
-
125
- /**
126
- * Generated bundle index. Do not edit.
127
- */
128
-
129
- exports.RuntimeConfig = RuntimeConfig;
130
- exports.RuntimeConfigLoaderModule = RuntimeConfigLoaderModule;
131
- exports.RuntimeConfigLoaderService = RuntimeConfigLoaderService;
132
- exports.initConfig = initConfig;
133
-
134
- Object.defineProperty(exports, '__esModule', { value: true });
135
-
136
- })));
137
- //# sourceMappingURL=runtime-config-loader.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-config-loader.umd.js","sources":["../../../../libs/runtime-config-loader/src/lib/runtime-config.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader/runtime-config-loader.service.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader.module.ts","../../../../libs/runtime-config-loader/src/runtime-config-loader.ts"],"sourcesContent":["export class RuntimeConfig {\n\tconfigUrl: string;\n\n\tconstructor(obj: any = {}) {\n\t\tthis.configUrl = obj.configUrl || './assets/config.json';\n\t}\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable, Optional } from '@angular/core';\nimport { RuntimeConfig } from '../runtime-config';\nimport { Observable, of, Subject } from 'rxjs';\nimport { catchError, tap } from 'rxjs/operators';\n\n@Injectable()\nexport class RuntimeConfigLoaderService {\n\tprivate configUrl: string = './assets/config.json';\n\tprivate configObject: any = null;\n\tpublic configSubject: Subject<any> = new Subject<any>();\n\n\tconstructor(private _http: HttpClient, @Optional() config: RuntimeConfig) {\n\t\tif (config) {\n\t\t\tthis.configUrl = config.configUrl;\n\t\t}\n\t}\n\n\tloadConfig(): Observable<any> {\n\t\treturn this._http.get(this.configUrl).pipe(\n\t\t\ttap((configData: any) => {\n\t\t\t\tthis.configObject = configData;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t}),\n\t\t\tcatchError((err: any) => {\n\t\t\t\tconsole.error('Error loading config: ', err);\n\t\t\t\tthis.configObject = null;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t\treturn of(null);\n\t\t\t})\n\t\t);\n\t}\n\n\tgetConfig() {\n\t\treturn this.configObject;\n\t}\n\n\tgetConfigObjectKey(key: string) {\n\t\treturn this.configObject ? this.configObject[key] : null;\n\t}\n}\n","import { HttpClientModule } from '@angular/common/http';\nimport { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';\nimport { RuntimeConfig } from './runtime-config';\nimport { RuntimeConfigLoaderService } from './runtime-config-loader/runtime-config-loader.service';\n\nexport function initConfig(configSvc: RuntimeConfigLoaderService) {\n\treturn () => configSvc.loadConfig();\n}\n\n@NgModule({\n\timports: [HttpClientModule],\n\tproviders: [\n\t\tRuntimeConfigLoaderService,\n\t\t{\n\t\t\tprovide: APP_INITIALIZER,\n\t\t\tuseFactory: initConfig,\n\t\t\tdeps: [RuntimeConfigLoaderService],\n\t\t\tmulti: true,\n\t\t},\n\t],\n})\nexport class RuntimeConfigLoaderModule {\n\tstatic forRoot(\n\t\tconfig: RuntimeConfig\n\t): ModuleWithProviders<RuntimeConfigLoaderModule> {\n\t\treturn {\n\t\t\tngModule: RuntimeConfigLoaderModule,\n\t\t\tproviders: [\n\t\t\t\t{\n\t\t\t\t\tprovide: RuntimeConfig,\n\t\t\t\t\tuseValue: config,\n\t\t\t\t},\n\t\t\t\tRuntimeConfigLoaderService,\n\t\t\t],\n\t\t};\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["Subject","tap","catchError","of","Injectable","Optional","HttpClientModule","APP_INITIALIZER","NgModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGC,uBAAY,GAAa;YAAb,oBAAA,EAAA,QAAa;YACxB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,sBAAsB,CAAC;SACzD;4BACD;KAAA;;;QCMA,oCAAoB,KAAiB,EAAc,MAAqB;YAApD,UAAK,GAAL,KAAK,CAAY;YAJ7B,cAAS,GAAW,sBAAsB,CAAC;YAC3C,iBAAY,GAAQ,IAAI,CAAC;YAC1B,kBAAa,GA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D,0BAA0B;iBAC1B;aACD,CAAC;SACF;;;gJAdW,yBAAyB;iJAAzB,yBAAyB,YAX3BC,mBAAgB;iJAWd,yBAAyB,aAV1B;YACV,0BAA0B;YAC1B;gBACC,OAAO,EAAEC,kBAAe;gBACxB,UAAU,EAAE,UAAU;gBACtB,IAAI,EAAE,CAAC,0BAA0B,CAAC;gBAClC,KAAK,EAAE,IAAI;aACX;SACD,YATQ,CAACD,mBAAgB,CAAC;qHAWf,yBAAyB;sBAZrCE,WAAQ;uBAAC;wBACT,OAAO,EAAE,CAACF,mBAAgB,CAAC;wBAC3B,SAAS,EAAE;4BACV,0BAA0B;4BAC1B;gCACC,OAAO,EAAEC,kBAAe;gCACxB,UAAU,EAAE,UAAU;gCACtB,IAAI,EAAE,CAAC,0BAA0B,CAAC;gCAClC,KAAK,EAAE,IAAI;6BACX;yBACD;qBACD;;;ICpBD;;;;;;;;;;;;;;;"}
package/esm2015/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from './lib/runtime-config-loader.module';
2
- export * from './lib/runtime-config';
3
- export * from './lib/runtime-config-loader/runtime-config-loader.service';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/runtime-config-loader/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,2DAA2D,CAAC","sourcesContent":["export * from './lib/runtime-config-loader.module';\nexport * from './lib/runtime-config';\nexport * from './lib/runtime-config-loader/runtime-config-loader.service';\n"]}
@@ -1,44 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { Injectable, Optional } from '@angular/core';
3
- import { RuntimeConfig } from '../runtime-config';
4
- import { of, Subject } from 'rxjs';
5
- import { catchError, tap } from 'rxjs/operators';
6
- import * as i0 from "@angular/core";
7
- import * as i1 from "@angular/common/http";
8
- import * as i2 from "../runtime-config";
9
- export class RuntimeConfigLoaderService {
10
- constructor(_http, config) {
11
- this._http = _http;
12
- this.configUrl = './assets/config.json';
13
- this.configObject = null;
14
- this.configSubject = new Subject();
15
- if (config) {
16
- this.configUrl = config.configUrl;
17
- }
18
- }
19
- loadConfig() {
20
- return this._http.get(this.configUrl).pipe(tap((configData) => {
21
- this.configObject = configData;
22
- this.configSubject.next(this.configObject);
23
- }), catchError((err) => {
24
- console.error('Error loading config: ', err);
25
- this.configObject = null;
26
- this.configSubject.next(this.configObject);
27
- return of(null);
28
- }));
29
- }
30
- getConfig() {
31
- return this.configObject;
32
- }
33
- getConfigObjectKey(key) {
34
- return this.configObject ? this.configObject[key] : null;
35
- }
36
- }
37
- RuntimeConfigLoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderService, deps: [{ token: i1.HttpClient }, { token: i2.RuntimeConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
38
- RuntimeConfigLoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderService });
39
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderService, decorators: [{
40
- type: Injectable
41
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i2.RuntimeConfig, decorators: [{
42
- type: Optional
43
- }] }]; } });
44
- //# sourceMappingURL=runtime-config-loader.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-config-loader.service.js","sourceRoot":"","sources":["../../../../../../libs/runtime-config-loader/src/lib/runtime-config-loader/runtime-config-loader.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAA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0B;2FAA1B,0BAA0B;kBADtC,UAAU;;0BAM8B,QAAQ","sourcesContent":["import { HttpClient } from '@angular/common/http';\nimport { Injectable, Optional } from '@angular/core';\nimport { RuntimeConfig } from '../runtime-config';\nimport { Observable, of, Subject } from 'rxjs';\nimport { catchError, tap } from 'rxjs/operators';\n\n@Injectable()\nexport class RuntimeConfigLoaderService {\n\tprivate configUrl: string = './assets/config.json';\n\tprivate configObject: any = null;\n\tpublic configSubject: Subject<any> = new Subject<any>();\n\n\tconstructor(private _http: HttpClient, @Optional() config: RuntimeConfig) {\n\t\tif (config) {\n\t\t\tthis.configUrl = config.configUrl;\n\t\t}\n\t}\n\n\tloadConfig(): Observable<any> {\n\t\treturn this._http.get(this.configUrl).pipe(\n\t\t\ttap((configData: any) => {\n\t\t\t\tthis.configObject = configData;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t}),\n\t\t\tcatchError((err: any) => {\n\t\t\t\tconsole.error('Error loading config: ', err);\n\t\t\t\tthis.configObject = null;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t\treturn of(null);\n\t\t\t})\n\t\t);\n\t}\n\n\tgetConfig() {\n\t\treturn this.configObject;\n\t}\n\n\tgetConfigObjectKey(key: string) {\n\t\treturn this.configObject ? this.configObject[key] : null;\n\t}\n}\n"]}
@@ -1,49 +0,0 @@
1
- import { HttpClientModule } from '@angular/common/http';
2
- import { APP_INITIALIZER, NgModule } from '@angular/core';
3
- import { RuntimeConfig } from './runtime-config';
4
- import { RuntimeConfigLoaderService } from './runtime-config-loader/runtime-config-loader.service';
5
- import * as i0 from "@angular/core";
6
- export function initConfig(configSvc) {
7
- return () => configSvc.loadConfig();
8
- }
9
- export class RuntimeConfigLoaderModule {
10
- static forRoot(config) {
11
- return {
12
- ngModule: RuntimeConfigLoaderModule,
13
- providers: [
14
- {
15
- provide: RuntimeConfig,
16
- useValue: config,
17
- },
18
- RuntimeConfigLoaderService,
19
- ],
20
- };
21
- }
22
- }
23
- RuntimeConfigLoaderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
24
- RuntimeConfigLoaderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, imports: [HttpClientModule] });
25
- RuntimeConfigLoaderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, providers: [
26
- RuntimeConfigLoaderService,
27
- {
28
- provide: APP_INITIALIZER,
29
- useFactory: initConfig,
30
- deps: [RuntimeConfigLoaderService],
31
- multi: true,
32
- },
33
- ], imports: [[HttpClientModule]] });
34
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: RuntimeConfigLoaderModule, decorators: [{
35
- type: NgModule,
36
- args: [{
37
- imports: [HttpClientModule],
38
- providers: [
39
- RuntimeConfigLoaderService,
40
- {
41
- provide: APP_INITIALIZER,
42
- useFactory: initConfig,
43
- deps: [RuntimeConfigLoaderService],
44
- multi: true,
45
- },
46
- ],
47
- }]
48
- }] });
49
- //# sourceMappingURL=runtime-config-loader.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-config-loader.module.js","sourceRoot":"","sources":["../../../../../libs/runtime-config-loader/src/lib/runtime-config-loader.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAuB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAC;;AAEnG,MAAM,UAAU,UAAU,CAAC,SAAqC;IAC/D,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;AACrC,CAAC;AAcD,MAAM,OAAO,yBAAyB;IACrC,MAAM,CAAC,OAAO,CACb,MAAqB;QAErB,OAAO;YACN,QAAQ,EAAE,yBAAyB;YACnC,SAAS,EAAE;gBACV;oBACC,OAAO,EAAE,aAAa;oBACtB,QAAQ,EAAE,MAAM;iBAChB;gBACD,0BAA0B;aAC1B;SACD,CAAC;IACH,CAAC;;sHAdW,yBAAyB;uHAAzB,yBAAyB,YAX3B,gBAAgB;uHAWd,yBAAyB,aAV1B;QACV,0BAA0B;QAC1B;YACC,OAAO,EAAE,eAAe;YACxB,UAAU,EAAE,UAAU;YACtB,IAAI,EAAE,CAAC,0BAA0B,CAAC;YAClC,KAAK,EAAE,IAAI;SACX;KACD,YATQ,CAAC,gBAAgB,CAAC;2FAWf,yBAAyB;kBAZrC,QAAQ;mBAAC;oBACT,OAAO,EAAE,CAAC,gBAAgB,CAAC;oBAC3B,SAAS,EAAE;wBACV,0BAA0B;wBAC1B;4BACC,OAAO,EAAE,eAAe;4BACxB,UAAU,EAAE,UAAU;4BACtB,IAAI,EAAE,CAAC,0BAA0B,CAAC;4BAClC,KAAK,EAAE,IAAI;yBACX;qBACD;iBACD","sourcesContent":["import { HttpClientModule } from '@angular/common/http';\nimport { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';\nimport { RuntimeConfig } from './runtime-config';\nimport { RuntimeConfigLoaderService } from './runtime-config-loader/runtime-config-loader.service';\n\nexport function initConfig(configSvc: RuntimeConfigLoaderService) {\n\treturn () => configSvc.loadConfig();\n}\n\n@NgModule({\n\timports: [HttpClientModule],\n\tproviders: [\n\t\tRuntimeConfigLoaderService,\n\t\t{\n\t\t\tprovide: APP_INITIALIZER,\n\t\t\tuseFactory: initConfig,\n\t\t\tdeps: [RuntimeConfigLoaderService],\n\t\t\tmulti: true,\n\t\t},\n\t],\n})\nexport class RuntimeConfigLoaderModule {\n\tstatic forRoot(\n\t\tconfig: RuntimeConfig\n\t): ModuleWithProviders<RuntimeConfigLoaderModule> {\n\t\treturn {\n\t\t\tngModule: RuntimeConfigLoaderModule,\n\t\t\tproviders: [\n\t\t\t\t{\n\t\t\t\t\tprovide: RuntimeConfig,\n\t\t\t\t\tuseValue: config,\n\t\t\t\t},\n\t\t\t\tRuntimeConfigLoaderService,\n\t\t\t],\n\t\t};\n\t}\n}\n"]}
@@ -1,6 +0,0 @@
1
- export class RuntimeConfig {
2
- constructor(obj = {}) {
3
- this.configUrl = obj.configUrl || './assets/config.json';
4
- }
5
- }
6
- //# sourceMappingURL=runtime-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-config.js","sourceRoot":"","sources":["../../../../../libs/runtime-config-loader/src/lib/runtime-config.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAa;IAGzB,YAAY,MAAW,EAAE;QACxB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,sBAAsB,CAAC;IAC1D,CAAC;CACD","sourcesContent":["export class RuntimeConfig {\n\tconfigUrl: string;\n\n\tconstructor(obj: any = {}) {\n\t\tthis.configUrl = obj.configUrl || './assets/config.json';\n\t}\n}\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './index';
5
- //# sourceMappingURL=runtime-config-loader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-config-loader.js","sourceRoot":"","sources":["../../../../libs/runtime-config-loader/src/runtime-config-loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-config-loader.js","sources":["../../../../libs/runtime-config-loader/src/lib/runtime-config.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader/runtime-config-loader.service.ts","../../../../libs/runtime-config-loader/src/lib/runtime-config-loader.module.ts","../../../../libs/runtime-config-loader/src/runtime-config-loader.ts"],"sourcesContent":["export class RuntimeConfig {\n\tconfigUrl: string;\n\n\tconstructor(obj: any = {}) {\n\t\tthis.configUrl = obj.configUrl || './assets/config.json';\n\t}\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable, Optional } from '@angular/core';\nimport { RuntimeConfig } from '../runtime-config';\nimport { Observable, of, Subject } from 'rxjs';\nimport { catchError, tap } from 'rxjs/operators';\n\n@Injectable()\nexport class RuntimeConfigLoaderService {\n\tprivate configUrl: string = './assets/config.json';\n\tprivate configObject: any = null;\n\tpublic configSubject: Subject<any> = new Subject<any>();\n\n\tconstructor(private _http: HttpClient, @Optional() config: RuntimeConfig) {\n\t\tif (config) {\n\t\t\tthis.configUrl = config.configUrl;\n\t\t}\n\t}\n\n\tloadConfig(): Observable<any> {\n\t\treturn this._http.get(this.configUrl).pipe(\n\t\t\ttap((configData: any) => {\n\t\t\t\tthis.configObject = configData;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t}),\n\t\t\tcatchError((err: any) => {\n\t\t\t\tconsole.error('Error loading config: ', err);\n\t\t\t\tthis.configObject = null;\n\t\t\t\tthis.configSubject.next(this.configObject);\n\t\t\t\treturn of(null);\n\t\t\t})\n\t\t);\n\t}\n\n\tgetConfig() {\n\t\treturn this.configObject;\n\t}\n\n\tgetConfigObjectKey(key: string) {\n\t\treturn this.configObject ? this.configObject[key] : null;\n\t}\n}\n","import { HttpClientModule } from '@angular/common/http';\nimport { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core';\nimport { RuntimeConfig } from './runtime-config';\nimport { RuntimeConfigLoaderService } from './runtime-config-loader/runtime-config-loader.service';\n\nexport function initConfig(configSvc: RuntimeConfigLoaderService) {\n\treturn () => configSvc.loadConfig();\n}\n\n@NgModule({\n\timports: [HttpClientModule],\n\tproviders: [\n\t\tRuntimeConfigLoaderService,\n\t\t{\n\t\t\tprovide: APP_INITIALIZER,\n\t\t\tuseFactory: initConfig,\n\t\t\tdeps: [RuntimeConfigLoaderService],\n\t\t\tmulti: true,\n\t\t},\n\t],\n})\nexport class RuntimeConfigLoaderModule {\n\tstatic forRoot(\n\t\tconfig: RuntimeConfig\n\t): ModuleWithProviders<RuntimeConfigLoaderModule> {\n\t\treturn {\n\t\t\tngModule: RuntimeConfigLoaderModule,\n\t\t\tproviders: [\n\t\t\t\t{\n\t\t\t\t\tprovide: RuntimeConfig,\n\t\t\t\t\tuseValue: config,\n\t\t\t\t},\n\t\t\t\tRuntimeConfigLoaderService,\n\t\t\t],\n\t\t};\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAAa,aAAa;IAGzB,YAAY,MAAW,EAAE;QACxB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,sBAAsB,CAAC;KACzD;;;MCEW,0BAA0B;IAKtC,YAAoB,KAAiB,EAAc,MAAqB;QAApD,UAAK,GAAL,KAAK,CAAY;QAJ7B,cAAS,GAAW,sBAAsB,CAAC;QAC3C,iBAAY,GAAQ,IAAI,CAAC;QAC1B,kBAAa,GAAiB,IAAI,OAAO,EAAO,CAAC;QAGvD,IAAI,MAAM,EAAE;YACX,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;SAClC;KACD;IAED,UAAU;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CACzC,GAAG,CAAC,CAAC,UAAe;YACnB,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC;YAC/B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC3C,CAAC,EACF,UAAU,CAAC,CAAC,GAAQ;YACnB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;YAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,aAAa,CAAC,IAA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