UNPKG

@kyosho-/ng-config

Version:

Configuration and options service for Angular applications.

109 lines (102 loc) 4.31 kB
import * as i0 from '@angular/core'; import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core'; import { CONFIG_PROVIDER } from '@kyosho-/ng-config'; import * as i1 from '@angular/common/http'; /** * @license * Copyright DagonMetric. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found under the LICENSE file in the root directory of this source tree. */ const HTTP_CONFIG_PROVIDER_OPTIONS = new InjectionToken('HttpConfigProviderOptions'); /** * Implements an HTTP client API for HttpConfigProvider that relies on the Angular HttpClient. */ class HttpConfigProvider { get name() { return 'HttpConfigProvider'; } get endpoint() { return this.configEndpoint; } constructor(httpClient, injector, options) { this.httpClient = httpClient; if (typeof options.endpoint === 'string') { this.configEndpoint = options.endpoint; } else { this.configEndpoint = injector.get(options.endpoint); } } load() { return this.httpClient.get(this.configEndpoint); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.4", ngImport: i0, type: HttpConfigProvider, deps: [{ token: i1.HttpClient }, { token: i0.Injector }, { token: HTTP_CONFIG_PROVIDER_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.4", ngImport: i0, type: HttpConfigProvider, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.4", ngImport: i0, type: HttpConfigProvider, decorators: [{ type: Injectable, args: [{ providedIn: 'root', }] }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: i0.Injector }, { type: undefined, decorators: [{ type: Inject, args: [HTTP_CONFIG_PROVIDER_OPTIONS] }] }]; } }); /** * @license * Copyright DagonMetric. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found under the LICENSE file in the root directory of this source tree. */ /** * The `NGMODULE` for providing `HttpConfigProvider`. */ class HttpConfigProviderModule { /** * Call this method to provide options for configuring the `HttpConfigProvider`. * @param options An option object for `HttpConfigProvider`. */ static configure(options) { return { ngModule: HttpConfigProviderModule, providers: [ { provide: HTTP_CONFIG_PROVIDER_OPTIONS, useValue: options } ] }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.4", ngImport: i0, type: HttpConfigProviderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.4", ngImport: i0, type: HttpConfigProviderModule }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.4", ngImport: i0, type: HttpConfigProviderModule, providers: [ { provide: CONFIG_PROVIDER, useClass: HttpConfigProvider, multi: true } ] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.4", ngImport: i0, type: HttpConfigProviderModule, decorators: [{ type: NgModule, args: [{ providers: [ { provide: CONFIG_PROVIDER, useClass: HttpConfigProvider, multi: true } ] }] }] }); /* * Public API Surface of ng-config */ /** * Generated bundle index. Do not edit. */ export { HTTP_CONFIG_PROVIDER_OPTIONS, HttpConfigProvider, HttpConfigProviderModule }; //# sourceMappingURL=kyosho--ng-config-http-config.mjs.map