@flosportsinc/ng-window
Version:
For use in unit testing and Angular Universal applications.
91 lines (84 loc) • 3.36 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
typeof define === 'function' && define.amd ? define('@flosportsinc/ng-window', ['exports', '@angular/core'], factory) :
(global = global || self, factory((global.flosportsinc = global.flosportsinc || {}, global.flosportsinc['ng-window'] = {}), global.ng.core));
}(this, function (exports, core) { 'use strict';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var WINDOW = new core.InjectionToken('fs.wnd');
/** @type {?} */
var WINDOW_IS_DEFINED = new core.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: core.Injectable }
];
/** @nocollapse */
WindowService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: core.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: core.NgModule, args: [{
providers: [
WindowService,
{
provide: WINDOW_IS_DEFINED,
useFactory: isWindowDefinedFactory
},
{
provide: WINDOW,
useFactory: winFactory,
deps: [WINDOW_IS_DEFINED]
}
]
},] }
];
return FloWindowModule;
}());
exports.FloWindowModule = FloWindowModule;
exports.WINDOW = WINDOW;
exports.WINDOW_IS_DEFINED = WINDOW_IS_DEFINED;
exports.WindowService = WindowService;
exports.isWindowDefinedFactory = isWindowDefinedFactory;
exports.winFactory = winFactory;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=flosportsinc-ng-window.umd.js.map