UNPKG

@flosportsinc/ng-window

Version:

For use in unit testing and Angular Universal applications.

78 lines (73 loc) 2.44 kB
import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var WINDOW = new InjectionToken('fs.wnd'); /** @type {?} */ var WINDOW_IS_DEFINED = new InjectionToken('fs.wnd-def'); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var WindowService = /** @class */ (function () { function WindowService(_window) { var _this = this; this._window = _window; this.window = (/** * @template T * @return {?} */ function () { return (/** @type {?} */ (_this._window)); }); } WindowService.decorators = [ { type: Injectable } ]; /** @nocollapse */ WindowService.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: Inject, args: [WINDOW,] }] } ]; }; return WindowService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ // for handling bundlers that might not have access to window object globally. /** * @param {?} isWindowDefined * @return {?} */ function winFactory(isWindowDefined) { return isWindowDefined ? window : {}; } /** * @return {?} */ function isWindowDefinedFactory() { return typeof window !== 'undefined'; } var FloWindowModule = /** @class */ (function () { function FloWindowModule() { } FloWindowModule.decorators = [ { type: NgModule, args: [{ providers: [ WindowService, { provide: WINDOW_IS_DEFINED, useFactory: isWindowDefinedFactory }, { provide: WINDOW, useFactory: winFactory, deps: [WINDOW_IS_DEFINED] } ] },] } ]; return FloWindowModule; }()); export { FloWindowModule, WINDOW, WINDOW_IS_DEFINED, WindowService, isWindowDefinedFactory, winFactory }; //# sourceMappingURL=flosportsinc-ng-window.js.map