UNPKG

zorro-ext-subin

Version:
1,317 lines 2.79 MB
import { APP_INITIALIZER, ApplicationRef, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentFactory, ComponentFactoryResolver, ContentChild, ContentChildren, Directive, ElementRef, EventEmitter, Host, HostBinding, HostListener, Inject, Injectable, InjectionToken, Injector, Input, IterableDiffers, NgModule, NgZone, Optional, Output, Pipe, Renderer, Renderer2, SkipSelf, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef, ViewEncapsulation, forwardRef } from '@angular/core'; import { FormsModule, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms'; import { CommonModule, DOCUMENT } from '@angular/common'; import { fromEvent as fromEvent$1 } from 'rxjs/observable/fromEvent'; import { animate, state, style, transition, trigger } from '@angular/animations'; import { CdkConnectedOverlay, Overlay, OverlayModule } from '@angular/cdk/overlay'; import { BACKSPACE, DOWN_ARROW, ENTER, LEFT_ARROW, RIGHT_ARROW, TAB, UP_ARROW } from '@angular/cdk/keycodes'; import { Subject as Subject$1 } from 'rxjs/Subject'; import { BehaviorSubject as BehaviorSubject$1 } from 'rxjs/BehaviorSubject'; import { merge as merge$1 } from 'rxjs/observable/merge'; import { ObserversModule } from '@angular/cdk/observers'; import { Observable as Observable$1 } from 'rxjs/Observable'; import { Directionality } from '@angular/cdk/bidi'; import { of as of$1 } from 'rxjs/observable/of'; import { HttpClient, HttpEventType, HttpHeaders, HttpRequest, HttpResponse } from '@angular/common/http'; import { ComponentPortal } from '@angular/cdk/portal'; import { Headers, Http, RequestOptions } from '@angular/http'; import { Router } from '@angular/router'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/toPromise'; import 'rxjs/add/observable/throw'; import 'rxjs/add/operator/map'; /** * 常规Hostlistener监听事件 */ var DragBoxDirective = /** @class */ (function () { /** * @param {?} rd2 * @param {?} el */ function DragBoxDirective(rd2, el) { this.rd2 = rd2; this.el = el; } /** * @return {?} */ DragBoxDirective.prototype.ngOnInit = function () { var _e = this.center(this.box), x = _e.x, y = _e.y; this.center(this.box); }; /** * @return {?} */ DragBoxDirective.prototype.ngOnDestroy = function () { this.dragging = false; }; /** * @param {?} event * @param {?} target * @return {?} */ DragBoxDirective.prototype.mousedown = function (event, target) { if (target.className.indexOf('ant-modal-close-x') !== -1) return; event.stopPropagation(); this.dragging = true; this.pageSize = event; }; /** * @param {?} __0 * @return {?} */ DragBoxDirective.prototype.mousemove = function (_e) { var pageX = _e.pageX, pageY = _e.pageY; var /** @type {?} */ dom = this.box; if (this.dragging) { var /** @type {?} */ deltaX = pageX - this.pageSize.pageX, /** @type {?} */ deltaY = pageY - this.pageSize.pageY, /** @type {?} */ distanceX = document.documentElement.offsetWidth - dom.offsetWidth, /** @type {?} */ distanceY = document.documentElement.offsetHeight - dom.offsetHeight, /** @type {?} */ leftPos = parseInt(dom.offsetLeft), /** @type {?} */ topPos = parseInt(dom.offsetTop); dom.style.left = (leftPos >= 0 ? (leftPos <= distanceX ? leftPos + deltaX : distanceX) : 0) + 'px'; dom.style.top = (topPos >= 0 ? (topPos <= distanceY ? topPos + deltaY : distanceY) : 0) + 'px'; this.pageSize = { pageX: pageX, pageY: pageY }; } return false; }; /** * @param {?} event * @return {?} */ DragBoxDirective.prototype.mouseup = function (event) { this.dragging = false; }; /** * @param {?} event * @return {?} */ DragBoxDirective.prototype.resize = function (event) { this.center(this.box); }; /** * @return {?} */ DragBoxDirective.prototype.getViewport = function () { var /** @type {?} */ win = window, /** @type {?} */ d = document, /** @type {?} */ e = d.documentElement, /** @type {?} */ g = d.getElementsByTagName('body')[0], /** @type {?} */ w = win.innerWidth || e.clientWidth || g.clientWidth, /** @type {?} */ h = win.innerHeight || e.clientHeight || g.clientHeight; return { width: w, height: h }; }; /** * @param {?} ele * @return {?} */ DragBoxDirective.prototype.center = function (ele) { var /** @type {?} */ viewport = this.getViewport(), /** @type {?} */ x = Math.max((viewport.width - ele.offsetWidth) / 2, 0), /** @type {?} */ y = Math.max((viewport.height - ele.offsetHeight) / 2, 0); this.box.style.position = "fixed"; this.box.style.zIndex = 1000; this.box.style.left = x + 'px'; this.box.style.top = y + 'px'; return { x: x, y: y }; }; return DragBoxDirective; }()); DragBoxDirective.decorators = [ { type: Directive, args: [{ selector: '[drag-box]' },] }, ]; /** * @nocollapse */ DragBoxDirective.ctorParameters = function () { return [ { type: Renderer2, }, { type: ElementRef, }, ]; }; DragBoxDirective.propDecorators = { 'box': [{ type: Input },], 'mousedown': [{ type: HostListener, args: ['mousedown', ['$event', '$event.target'],] },], 'mousemove': [{ type: HostListener, args: ['document:mousemove', ['$event'],] },], 'mouseup': [{ type: HostListener, args: ['document:mouseup', ['$event'],] },], 'resize': [{ type: HostListener, args: ['window:resize', ['$event'],] },], }; var DirectivesModule = /** @class */ (function () { function DirectivesModule() { } return DirectivesModule; }()); DirectivesModule.decorators = [ { type: NgModule, args: [{ declarations: [ DragBoxDirective ], exports: [ DragBoxDirective ] },] }, ]; /** * @nocollapse */ DirectivesModule.ctorParameters = function () { return []; }; var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } function isFunction(x) { return typeof x === 'function'; } var isFunction_2 = isFunction; var isFunction_1 = { isFunction: isFunction_2 }; var isArray_1 = Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); var isArray = { isArray: isArray_1 }; function isObject(x) { return x != null && typeof x === 'object'; } var isObject_2 = isObject; var isObject_1 = { isObject: isObject_2 }; // typeof any so that it we don't have to cast when comparing a result to the error object var errorObject_1 = { e: {} }; var errorObject = { errorObject: errorObject_1 }; var tryCatchTarget; function tryCatcher() { try { return tryCatchTarget.apply(this, arguments); } catch (e) { errorObject.errorObject.e = e; return errorObject.errorObject; } } function tryCatch(fn) { tryCatchTarget = fn; return tryCatcher; } var tryCatch_2 = tryCatch; var tryCatch_1 = { tryCatch: tryCatch_2 }; var __extends$2 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /** * An error thrown when one or more errors have occurred during the * `unsubscribe` of a {@link Subscription}. */ var UnsubscriptionError = (function (_super) { __extends$2(UnsubscriptionError, _super); function UnsubscriptionError(errors) { _super.call(this); this.errors = errors; var err = Error.call(this, errors ? errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) { return ((i + 1) + ") " + err.toString()); }).join('\n ') : ''); this.name = err.name = 'UnsubscriptionError'; this.stack = err.stack; this.message = err.message; } return UnsubscriptionError; }(Error)); var UnsubscriptionError_2 = UnsubscriptionError; var UnsubscriptionError_1 = { UnsubscriptionError: UnsubscriptionError_2 }; /** * Represents a disposable resource, such as the execution of an Observable. A * Subscription has one important method, `unsubscribe`, that takes no argument * and just disposes the resource held by the subscription. * * Additionally, subscriptions may be grouped together through the `add()` * method, which will attach a child Subscription to the current Subscription. * When a Subscription is unsubscribed, all its children (and its grandchildren) * will be unsubscribed as well. * * @class Subscription */ var Subscription = (function () { /** * @param {function(): void} [unsubscribe] A function describing how to * perform the disposal of resources when the `unsubscribe` method is called. */ function Subscription(unsubscribe) { /** * A flag to indicate whether this Subscription has already been unsubscribed. * @type {boolean} */ this.closed = false; this._parent = null; this._parents = null; this._subscriptions = null; if (unsubscribe) { this._unsubscribe = unsubscribe; } } /** * Disposes the resources held by the subscription. May, for instance, cancel * an ongoing Observable execution or cancel any other type of work that * started when the Subscription was created. * @return {void} */ Subscription.prototype.unsubscribe = function () { var hasErrors = false; var errors; if (this.closed) { return; } var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions; this.closed = true; this._parent = null; this._parents = null; // null out _subscriptions first so any child subscriptions that attempt // to remove themselves from this subscription will noop this._subscriptions = null; var index = -1; var len = _parents ? _parents.length : 0; // if this._parent is null, then so is this._parents, and we // don't have to remove ourselves from any parent subscriptions. while (_parent) { _parent.remove(this); // if this._parents is null or index >= len, // then _parent is set to null, and the loop exits _parent = ++index < len && _parents[index] || null; } if (isFunction_1.isFunction(_unsubscribe)) { var trial = tryCatch_1.tryCatch(_unsubscribe).call(this); if (trial === errorObject.errorObject) { hasErrors = true; errors = errors || (errorObject.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ? flattenUnsubscriptionErrors(errorObject.errorObject.e.errors) : [errorObject.errorObject.e]); } } if (isArray.isArray(_subscriptions)) { index = -1; len = _subscriptions.length; while (++index < len) { var sub = _subscriptions[index]; if (isObject_1.isObject(sub)) { var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub); if (trial === errorObject.errorObject) { hasErrors = true; errors = errors || []; var err = errorObject.errorObject.e; if (err instanceof UnsubscriptionError_1.UnsubscriptionError) { errors = errors.concat(flattenUnsubscriptionErrors(err.errors)); } else { errors.push(err); } } } } } if (hasErrors) { throw new UnsubscriptionError_1.UnsubscriptionError(errors); } }; /** * Adds a tear down to be called during the unsubscribe() of this * Subscription. * * If the tear down being added is a subscription that is already * unsubscribed, is the same reference `add` is being called on, or is * `Subscription.EMPTY`, it will not be added. * * If this subscription is already in an `closed` state, the passed * tear down logic will be executed immediately. * * @param {TeardownLogic} teardown The additional logic to execute on * teardown. * @return {Subscription} Returns the Subscription used or created to be * added to the inner subscriptions list. This Subscription can be used with * `remove()` to remove the passed teardown logic from the inner subscriptions * list. */ Subscription.prototype.add = function (teardown) { if (!teardown || (teardown === Subscription.EMPTY)) { return Subscription.EMPTY; } if (teardown === this) { return this; } var subscription = teardown; switch (typeof teardown) { case 'function': subscription = new Subscription(teardown); case 'object': if (subscription.closed || typeof subscription.unsubscribe !== 'function') { return subscription; } else if (this.closed) { subscription.unsubscribe(); return subscription; } else if (typeof subscription._addParent !== 'function' /* quack quack */) { var tmp = subscription; subscription = new Subscription(); subscription._subscriptions = [tmp]; } break; default: throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.'); } var subscriptions = this._subscriptions || (this._subscriptions = []); subscriptions.push(subscription); subscription._addParent(this); return subscription; }; /** * Removes a Subscription from the internal list of subscriptions that will * unsubscribe during the unsubscribe process of this Subscription. * @param {Subscription} subscription The subscription to remove. * @return {void} */ Subscription.prototype.remove = function (subscription) { var subscriptions = this._subscriptions; if (subscriptions) { var subscriptionIndex = subscriptions.indexOf(subscription); if (subscriptionIndex !== -1) { subscriptions.splice(subscriptionIndex, 1); } } }; Subscription.prototype._addParent = function (parent) { var _a = this, _parent = _a._parent, _parents = _a._parents; if (!_parent || _parent === parent) { // If we don't have a parent, or the new parent is the same as the // current parent, then set this._parent to the new parent. this._parent = parent; } else if (!_parents) { // If there's already one parent, but not multiple, allocate an Array to // store the rest of the parent Subscriptions. this._parents = [parent]; } else if (_parents.indexOf(parent) === -1) { // Only add the new parent to the _parents list if it's not already there. _parents.push(parent); } }; Subscription.EMPTY = (function (empty) { empty.closed = true; return empty; }(new Subscription())); return Subscription; }()); var Subscription_2 = Subscription; function flattenUnsubscriptionErrors(errors) { return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []); } var Subscription_1 = { Subscription: Subscription_2 }; var empty = { closed: true, next: function (value) { }, error: function (err) { throw err; }, complete: function () { } }; var Observer = { empty: empty }; // CommonJS / Node have global context exposed as "global" variable. // We don't want to include the whole node.d.ts this this compilation unit so we'll just fake // the global "global" var for now. var __window = typeof window !== 'undefined' && window; var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self; var __global = typeof commonjsGlobal !== 'undefined' && commonjsGlobal; var _root = __window || __global || __self; var root_1 = _root; // Workaround Closure Compiler restriction: The body of a goog.module cannot use throw. // This is needed when used with angular/tsickle which inserts a goog.module statement. // Wrap in IIFE (function () { if (!_root) { throw new Error('RxJS could not find any global context (window, self, global)'); } })(); var root = { root: root_1 }; var rxSubscriber = createCommonjsModule(function (module, exports) { var Symbol = root.root.Symbol; exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ? Symbol.for('rxSubscriber') : '@@rxSubscriber'; /** * @deprecated use rxSubscriber instead */ exports.$$rxSubscriber = exports.rxSubscriber; }); var rxSubscriber_1 = rxSubscriber.rxSubscriber; var rxSubscriber_2 = rxSubscriber.$$rxSubscriber; var __extends$1 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /** * Implements the {@link Observer} interface and extends the * {@link Subscription} class. While the {@link Observer} is the public API for * consuming the values of an {@link Observable}, all Observers get converted to * a Subscriber, in order to provide Subscription-like capabilities such as * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for * implementing operators, but it is rarely used as a public API. * * @class Subscriber<T> */ var Subscriber = (function (_super) { __extends$1(Subscriber, _super); /** * @param {Observer|function(value: T): void} [destinationOrNext] A partially * defined Observer or a `next` callback function. * @param {function(e: ?any): void} [error] The `error` callback of an * Observer. * @param {function(): void} [complete] The `complete` callback of an * Observer. */ function Subscriber(destinationOrNext, error, complete) { _super.call(this); this.syncErrorValue = null; this.syncErrorThrown = false; this.syncErrorThrowable = false; this.isStopped = false; switch (arguments.length) { case 0: this.destination = Observer.empty; break; case 1: if (!destinationOrNext) { this.destination = Observer.empty; break; } if (typeof destinationOrNext === 'object') { if (destinationOrNext instanceof Subscriber) { this.syncErrorThrowable = destinationOrNext.syncErrorThrowable; this.destination = destinationOrNext; this.destination.add(this); } else { this.syncErrorThrowable = true; this.destination = new SafeSubscriber(this, destinationOrNext); } break; } default: this.syncErrorThrowable = true; this.destination = new SafeSubscriber(this, destinationOrNext, error, complete); break; } } Subscriber.prototype[rxSubscriber.rxSubscriber] = function () { return this; }; /** * A static factory for a Subscriber, given a (potentially partial) definition * of an Observer. * @param {function(x: ?T): void} [next] The `next` callback of an Observer. * @param {function(e: ?any): void} [error] The `error` callback of an * Observer. * @param {function(): void} [complete] The `complete` callback of an * Observer. * @return {Subscriber<T>} A Subscriber wrapping the (partially defined) * Observer represented by the given arguments. */ Subscriber.create = function (next, error, complete) { var subscriber = new Subscriber(next, error, complete); subscriber.syncErrorThrowable = false; return subscriber; }; /** * The {@link Observer} callback to receive notifications of type `next` from * the Observable, with a value. The Observable may call this method 0 or more * times. * @param {T} [value] The `next` value. * @return {void} */ Subscriber.prototype.next = function (value) { if (!this.isStopped) { this._next(value); } }; /** * The {@link Observer} callback to receive notifications of type `error` from * the Observable, with an attached {@link Error}. Notifies the Observer that * the Observable has experienced an error condition. * @param {any} [err] The `error` exception. * @return {void} */ Subscriber.prototype.error = function (err) { if (!this.isStopped) { this.isStopped = true; this._error(err); } }; /** * The {@link Observer} callback to receive a valueless notification of type * `complete` from the Observable. Notifies the Observer that the Observable * has finished sending push-based notifications. * @return {void} */ Subscriber.prototype.complete = function () { if (!this.isStopped) { this.isStopped = true; this._complete(); } }; Subscriber.prototype.unsubscribe = function () { if (this.closed) { return; } this.isStopped = true; _super.prototype.unsubscribe.call(this); }; Subscriber.prototype._next = function (value) { this.destination.next(value); }; Subscriber.prototype._error = function (err) { this.destination.error(err); this.unsubscribe(); }; Subscriber.prototype._complete = function () { this.destination.complete(); this.unsubscribe(); }; Subscriber.prototype._unsubscribeAndRecycle = function () { var _a = this, _parent = _a._parent, _parents = _a._parents; this._parent = null; this._parents = null; this.unsubscribe(); this.closed = false; this.isStopped = false; this._parent = _parent; this._parents = _parents; return this; }; return Subscriber; }(Subscription_1.Subscription)); var Subscriber_2 = Subscriber; /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ var SafeSubscriber = (function (_super) { __extends$1(SafeSubscriber, _super); function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) { _super.call(this); this._parentSubscriber = _parentSubscriber; var next; var context = this; if (isFunction_1.isFunction(observerOrNext)) { next = observerOrNext; } else if (observerOrNext) { next = observerOrNext.next; error = observerOrNext.error; complete = observerOrNext.complete; if (observerOrNext !== Observer.empty) { context = Object.create(observerOrNext); if (isFunction_1.isFunction(context.unsubscribe)) { this.add(context.unsubscribe.bind(context)); } context.unsubscribe = this.unsubscribe.bind(this); } } this._context = context; this._next = next; this._error = error; this._complete = complete; } SafeSubscriber.prototype.next = function (value) { if (!this.isStopped && this._next) { var _parentSubscriber = this._parentSubscriber; if (!_parentSubscriber.syncErrorThrowable) { this.__tryOrUnsub(this._next, value); } else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) { this.unsubscribe(); } } }; SafeSubscriber.prototype.error = function (err) { if (!this.isStopped) { var _parentSubscriber = this._parentSubscriber; if (this._error) { if (!_parentSubscriber.syncErrorThrowable) { this.__tryOrUnsub(this._error, err); this.unsubscribe(); } else { this.__tryOrSetError(_parentSubscriber, this._error, err); this.unsubscribe(); } } else if (!_parentSubscriber.syncErrorThrowable) { this.unsubscribe(); throw err; } else { _parentSubscriber.syncErrorValue = err; _parentSubscriber.syncErrorThrown = true; this.unsubscribe(); } } }; SafeSubscriber.prototype.complete = function () { var _this = this; if (!this.isStopped) { var _parentSubscriber = this._parentSubscriber; if (this._complete) { var wrappedComplete = function () { return _this._complete.call(_this._context); }; if (!_parentSubscriber.syncErrorThrowable) { this.__tryOrUnsub(wrappedComplete); this.unsubscribe(); } else { this.__tryOrSetError(_parentSubscriber, wrappedComplete); this.unsubscribe(); } } else { this.unsubscribe(); } } }; SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) { try { fn.call(this._context, value); } catch (err) { this.unsubscribe(); throw err; } }; SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) { try { fn.call(this._context, value); } catch (err) { parent.syncErrorValue = err; parent.syncErrorThrown = true; return true; } return false; }; SafeSubscriber.prototype._unsubscribe = function () { var _parentSubscriber = this._parentSubscriber; this._context = null; this._parentSubscriber = null; _parentSubscriber.unsubscribe(); }; return SafeSubscriber; }(Subscriber)); var Subscriber_1 = { Subscriber: Subscriber_2 }; var __extends = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /* tslint:enable:max-line-length */ /** * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from the previous item. * * If a comparator function is provided, then it will be called for each item to test for whether or not that value should be emitted. * * If a comparator function is not provided, an equality check is used by default. * * @example <caption>A simple example with numbers</caption> * Observable.of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4) * .distinctUntilChanged() * .subscribe(x => console.log(x)); // 1, 2, 1, 2, 3, 4 * * @example <caption>An example using a compare function</caption> * interface Person { * age: number, * name: string * } * * Observable.of<Person>( * { age: 4, name: 'Foo'}, * { age: 7, name: 'Bar'}, * { age: 5, name: 'Foo'}) * { age: 6, name: 'Foo'}) * .distinctUntilChanged((p: Person, q: Person) => p.name === q.name) * .subscribe(x => console.log(x)); * * // displays: * // { age: 4, name: 'Foo' } * // { age: 7, name: 'Bar' } * // { age: 5, name: 'Foo' } * * @see {@link distinct} * @see {@link distinctUntilKeyChanged} * * @param {function} [compare] Optional comparison function called to test if an item is distinct from the previous item in the source. * @return {Observable} An Observable that emits items from the source Observable with distinct values. * @method distinctUntilChanged * @owner Observable */ function distinctUntilChanged(compare, keySelector) { return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); }; } var distinctUntilChanged_2 = distinctUntilChanged; var DistinctUntilChangedOperator = (function () { function DistinctUntilChangedOperator(compare, keySelector) { this.compare = compare; this.keySelector = keySelector; } DistinctUntilChangedOperator.prototype.call = function (subscriber, source) { return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector)); }; return DistinctUntilChangedOperator; }()); /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ var DistinctUntilChangedSubscriber = (function (_super) { __extends(DistinctUntilChangedSubscriber, _super); function DistinctUntilChangedSubscriber(destination, compare, keySelector) { _super.call(this, destination); this.keySelector = keySelector; this.hasKey = false; if (typeof compare === 'function') { this.compare = compare; } } DistinctUntilChangedSubscriber.prototype.compare = function (x, y) { return x === y; }; DistinctUntilChangedSubscriber.prototype._next = function (value) { var keySelector = this.keySelector; var key = value; if (keySelector) { key = tryCatch_1.tryCatch(this.keySelector)(value); if (key === errorObject.errorObject) { return this.destination.error(errorObject.errorObject.e); } } var result = false; if (this.hasKey) { result = tryCatch_1.tryCatch(this.compare)(this.key, key); if (result === errorObject.errorObject) { return this.destination.error(errorObject.errorObject.e); } } else { this.hasKey = true; } if (Boolean(result) === false) { this.key = key; this.destination.next(value); } }; return DistinctUntilChangedSubscriber; }(Subscriber_1.Subscriber)); var distinctUntilChanged_1 = { distinctUntilChanged: distinctUntilChanged_2 }; var __extends$5 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /** * A unit of work to be executed in a {@link Scheduler}. An action is typically * created from within a Scheduler and an RxJS user does not need to concern * themselves about creating and manipulating an Action. * * ```ts * class Action<T> extends Subscription { * new (scheduler: Scheduler, work: (state?: T) => void); * schedule(state?: T, delay: number = 0): Subscription; * } * ``` * * @class Action<T> */ var Action = (function (_super) { __extends$5(Action, _super); function Action(scheduler, work) { _super.call(this); } /** * Schedules this action on its parent Scheduler for execution. May be passed * some context object, `state`. May happen at some point in the future, * according to the `delay` parameter, if specified. * @param {T} [state] Some contextual data that the `work` function uses when * called by the Scheduler. * @param {number} [delay] Time to wait before executing the work, where the * time unit is implicit and defined by the Scheduler. * @return {void} */ Action.prototype.schedule = function (state$$1, delay) { if (delay === void 0) { delay = 0; } return this; }; return Action; }(Subscription_1.Subscription)); var Action_2 = Action; var Action_1 = { Action: Action_2 }; var __extends$4 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ var AsyncAction = (function (_super) { __extends$4(AsyncAction, _super); function AsyncAction(scheduler, work) { _super.call(this, scheduler, work); this.scheduler = scheduler; this.work = work; this.pending = false; } AsyncAction.prototype.schedule = function (state$$1, delay) { if (delay === void 0) { delay = 0; } if (this.closed) { return this; } // Always replace the current state with the new state. this.state = state$$1; // Set the pending flag indicating that this action has been scheduled, or // has recursively rescheduled itself. this.pending = true; var id = this.id; var scheduler = this.scheduler; // // Important implementation note: // // Actions only execute once by default, unless rescheduled from within the // scheduled callback. This allows us to implement single and repeat // actions via the same code path, without adding API surface area, as well // as mimic traditional recursion but across asynchronous boundaries. // // However, JS runtimes and timers distinguish between intervals achieved by // serial `setTimeout` calls vs. a single `setInterval` call. An interval of // serial `setTimeout` calls can be individually delayed, which delays // scheduling the next `setTimeout`, and so on. `setInterval` attempts to // guarantee the interval callback will be invoked more precisely to the // interval period, regardless of load. // // Therefore, we use `setInterval` to schedule single and repeat actions. // If the action reschedules itself with the same delay, the interval is not // canceled. If the action doesn't reschedule, or reschedules with a // different delay, the interval will be canceled after scheduled callback // execution. // if (id != null) { this.id = this.recycleAsyncId(scheduler, id, delay); } this.delay = delay; // If this action has already an async Id, don't request a new one. this.id = this.id || this.requestAsyncId(scheduler, this.id, delay); return this; }; AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) { if (delay === void 0) { delay = 0; } return root.root.setInterval(scheduler.flush.bind(scheduler, this), delay); }; AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) { if (delay === void 0) { delay = 0; } // If this action is rescheduled with the same delay time, don't clear the interval id. if (delay !== null && this.delay === delay && this.pending === false) { return id; } // Otherwise, if the action's delay time is different from the current delay, // or the action has been rescheduled before it's executed, clear the interval id return root.root.clearInterval(id) && undefined || undefined; }; /** * Immediately executes this action and the `work` it contains. * @return {any} */ AsyncAction.prototype.execute = function (state$$1, delay) { if (this.closed) { return new Error('executing a cancelled action'); } this.pending = false; var error = this._execute(state$$1, delay); if (error) { return error; } else if (this.pending === false && this.id != null) { // Dequeue if the action didn't reschedule itself. Don't call // unsubscribe(), because the action could reschedule later. // For example: // ``` // scheduler.schedule(function doWork(counter) { // /* ... I'm a busy worker bee ... */ // var originalAction = this; // /* wait 100ms before rescheduling the action */ // setTimeout(function () { // originalAction.schedule(counter + 1); // }, 100); // }, 1000); // ``` this.id = this.recycleAsyncId(this.scheduler, this.id, null); } }; AsyncAction.prototype._execute = function (state$$1, delay) { var errored = false; var errorValue = undefined; try { this.work(state$$1); } catch (e) { errored = true; errorValue = !!e && e || new Error(e); } if (errored) { this.unsubscribe(); return errorValue; } }; AsyncAction.prototype._unsubscribe = function () { var id = this.id; var scheduler = this.scheduler; var actions = scheduler.actions; var index = actions.indexOf(this); this.work = null; this.state = null; this.pending = false; this.scheduler = null; if (index !== -1) { actions.splice(index, 1); } if (id != null) { this.id = this.recycleAsyncId(scheduler, id, null); } this.delay = null; }; return AsyncAction; }(Action_1.Action)); var AsyncAction_2 = AsyncAction; var AsyncAction_1 = { AsyncAction: AsyncAction_2 }; /** * An execution context and a data structure to order tasks and schedule their * execution. Provides a notion of (potentially virtual) time, through the * `now()` getter method. * * Each unit of work in a Scheduler is called an {@link Action}. * * ```ts * class Scheduler { * now(): number; * schedule(work, delay?, state?): Subscription; * } * ``` * * @class Scheduler */ var Scheduler = (function () { function Scheduler(SchedulerAction, now) { if (now === void 0) { now = Scheduler.now; } this.SchedulerAction = SchedulerAction; this.now = now; } /** * Schedules a function, `work`, for execution. May happen at some point in * the future, according to the `delay` parameter, if specified. May be passed * some context object, `state`, which will be passed to the `work` function. * * The given arguments will be processed an stored as an Action object in a * queue of actions. * * @param {function(state: ?T): ?Subscription} work A function representing a * task, or some unit of work to be executed by the Scheduler. * @param {number} [delay] Time to wait before executing the work, where the * time unit is implicit and defined by the Scheduler itself. * @param {T} [state] Some contextual data that the `work` function uses when * called by the Scheduler. * @return {Subscription} A subscription in order to be able to unsubscribe * the scheduled work. */ Scheduler.prototype.schedule = function (work, delay, state$$1) { if (delay === void 0) { delay = 0; } return new this.SchedulerAction(this, work).schedule(state$$1, delay); }; Scheduler.now = Date.now ? Date.now : function () { return +new Date(); }; return Scheduler; }()); var Scheduler_2 = Scheduler; var Scheduler_1 = { Scheduler: Scheduler_2 }; var __extends$6 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var AsyncScheduler = (function (_super) { __extends$6(AsyncScheduler, _super); function AsyncScheduler() { _super.apply(this, arguments); this.actions = []; /** * A flag to indicate whether the Scheduler is currently executing a batch of * queued actions. * @type {boolean} */ this.active = false; /** * An internal ID used to track the latest asynchronous task such as those * coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and * others. * @type {any} */ this.scheduled = undefined; } AsyncScheduler.prototype.flush = function (action) { var actions = this.actions; if (this.active) { actions.push(action); return; } var error; this.active = true; do { if (error = action.execute(action.state, action.delay)) { break; } } while (action = actions.shift()); // exhaust the scheduler queue this.active = false; if (error) { while (action = actions.shift()) { action.unsubscribe(); } throw error; } }; return AsyncScheduler; }(Scheduler_1.Scheduler)); var AsyncScheduler_2 = AsyncScheduler; var AsyncScheduler_1 = { AsyncScheduler: AsyncScheduler_2 }; /** * * Async Scheduler * * <span class="informal">Schedule task as if you used setTimeout(task, duration)</span> * * `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript * event loop queue. It is best used to delay tasks in time or to schedule tasks repeating * in intervals. * * If you just want to "defer" task, that is to perform it right after currently * executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`), * better choice will be the {@link asap} scheduler. * * @example <caption>Use async scheduler to delay task</caption> * const task = () => console.log('it works!'); * * Rx.Scheduler.async.schedule(task, 2000); * * // After 2 seconds logs: * // "it works!" * * * @example <caption>Use async scheduler to repeat task in intervals</caption> * function task(state) { * console.log(state); * this.schedule(state + 1, 1000); // `this` references currently executing Action, * // which we reschedule with new state and delay * } * * Rx.Scheduler.async.schedule(task, 3000, 0); * * // Logs: * // 0 after 3s * // 1 after 4s * // 2 after 5s * // 3 after 6s * * @static true * @name async * @owner Scheduler */ var async_1 = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); var async = { async: async_1 }; var __extends$7 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ var OuterSubscriber = (function (_super) { __extends$7(OuterSubscriber, _super); function OuterSubscriber() { _super.apply(this, arguments); } OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { this.destination.next(innerValue); }; OuterSubscriber.prototype.notifyError = function (error, innerSub) { this.destination.error(error); }; OuterSubscriber.prototype.notifyComplete = function (innerSub) { this.destination.complete(); }; return OuterSubscriber; }(Subscriber_1.Subscriber)); var OuterSubscriber_2 = OuterSubscriber; var OuterSubscriber_1 = { OuterSubscriber: OuterSubscriber_2 }; var isArrayLike_1 = (function (x) { return x && typeof x.length === 'number'; }); var isArrayLike = { isArrayLike: isArrayLike_1 }; function isPromise(value) { return value && typeof value.subscribe !== 'function' && typeof value.then === 'function'; } var isPromise_2 = isPromise; var isPromise_1 = { isPromise: isPromise_2 }; function toSubscriber(nextOrObserver, error, complete) { if (nextOrObserver) { if (nextOrObserver instanceof Subscriber_1.Subscriber) { return nextOrObserver; } if (nextOrObserver[rxSubscriber.rxSubscriber]) { return nextOrObserver[rxSubscriber.rxSubscriber](); } } if (!nextOrObserver && !error && !complete) { return new Subscriber_1.Subscriber(Observer.empty); } return new Subscriber_1.Subscriber(nextOrObserver, error, complete); } var toSubscriber_2 = toSubscriber; var toSubscriber_1 = { toSubscriber: toSubscriber_2 }; var observable = createCommonjsModule(function (module, exports) { function getSymbolObservable(context) { var $$observable; var Symbol = context.Symbol; if (typeof Symbol === 'function') { if (Symbol.observable) { $$observable = Symbol.observable; } else { $$observable = Symbol('observable'); Symbol.observable = $$observable; } } else { $$observable = '@@observable'; } return $$observable; } exports.getSymbolObservable = getSymbolObservable; exports.observable = getSymbolObservable(root.root); /** * @deprecated use observable instead */ exports.$$observable = exports.observable; }); var observable_1 = observable.getSymbolObservable; var observable_2 = observable.observable; var observable_3 = observable.$$observable; /* tslint:disable:no-empty */ function noop() { } var noop_2 = noop; var noop_1 = { noop: noop_2 }; /* tslint:enable:max-line-length */ function pipe() { var fns = []; for (var _i = 0; _i < arguments.length; _i++) { fns[_i - 0] = arguments[_i]; } return pipeFromArray(fns); } var pipe_2 = pipe; /* @internal */ function pipeFromArray(fns) { if (!fns) { return noop_1.noop; } if (fns.length === 1) { return fns[0]; } return function piped(input) { return fns.reduce(function (prev, fn) { return fn(prev); }, input); }; } var pipeFromArray_1 = pipeFromArray; var pipe_1 = { pipe: pipe_2, pipeFromArray: pipeFromArray_1 }; /** * A representation of any set of values over any amount of time. This is the most basic building block * of RxJS. * * @class Observable<T> */ var Observable$2 = (function () { /** * @constructor * @param {Function} subscribe the function that is called when the Observable is * initially subscribed to. This function is given a Subscriber, to which new values * can be `next`ed, or an `error` method can be called to raise an error, or * `complete` can be called to notify of a successful completion. */ function Observable$$1(subscribe) { this._isScalar = false; if (subscribe) { this._subscribe = subscribe; } } /** * Creates a new Observable, with this Observable as the source, and the passed * operator defined as the new observable's operator. * @method lift * @param {Operator} operator the operator defining the operation to take on the observable * @return {Observable} a new observ