diff --git a/swinging-cat-rx/dist/app.js b/swinging-cat-rx/dist/app.js index 2768f32..b36e1cf 100644 --- a/swinging-cat-rx/dist/app.js +++ b/swinging-cat-rx/dist/app.js @@ -1,25408 +1,25922 @@ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; - +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { - +/******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) +/******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; - +/******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} /******/ }; - +/******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - +/******/ /******/ // Flag the module as loaded -/******/ module.loaded = true; - +/******/ module.l = true; +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } - - +/******/ +/******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; - +/******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; - +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; - +/******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(0); +/******/ return __webpack_require__(__webpack_require__.s = 90); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var root_1 = __webpack_require__(7); +var toSubscriber_1 = __webpack_require__(132); +var observable_1 = __webpack_require__(30); +/** + * A representation of any set of values over any amount of time. This is the most basic building block + * of RxJS. + * + * @class Observable + */ +var Observable = (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(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 observable with the Operator applied + */ + Observable.prototype.lift = function (operator) { + var observable = new Observable(); + observable.source = this; + observable.operator = operator; + return observable; + }; + /** + * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit. + * + * Use it when you have all these Observables, but still nothing is happening. + * + * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It + * might be for example a function that you passed to a {@link create} static factory, but most of the time it is + * a library implementation, which defines what and when will be emitted by an Observable. This means that calling + * `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often + * thought. + * + * Apart from starting the execution of an Observable, this method allows you to listen for values + * that an Observable emits, as well as for when it completes or errors. You can achieve this in two + * following ways. + * + * The first way is creating an object that implements {@link Observer} interface. It should have methods + * defined by that interface, but note that it should be just a regular JavaScript object, which you can create + * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular do + * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also + * that your object does not have to implement all methods. If you find yourself creating a method that doesn't + * do anything, you can simply omit it. Note however, that if `error` method is not provided, all errors will + * be left uncaught. + * + * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods. + * This means you can provide three functions as arguments to `subscribe`, where first function is equivalent + * of a `next` method, second of an `error` method and third of a `complete` method. Just as in case of Observer, + * if you do not need to listen for something, you can omit a function, preferably by passing `undefined` or `null`, + * since `subscribe` recognizes these functions by where they were placed in function call. When it comes + * to `error` function, just as before, if not provided, errors emitted by an Observable will be thrown. + * + * Whatever style of calling `subscribe` you use, in both cases it returns a Subscription object. + * This object allows you to call `unsubscribe` on it, which in turn will stop work that an Observable does and will clean + * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback + * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable. + * + * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously. + * It is an Observable itself that decides when these functions will be called. For example {@link of} + * by default emits all its values synchronously. Always check documentation for how given Observable + * will behave when subscribed and if its default behavior can be modified with a {@link Scheduler}. + * + * @example Subscribe with an Observer + * const sumObserver = { + * sum: 0, + * next(value) { + * console.log('Adding: ' + value); + * this.sum = this.sum + value; + * }, + * error() { // We actually could just remove this method, + * }, // since we do not really care about errors right now. + * complete() { + * console.log('Sum equals: ' + this.sum); + * } + * }; + * + * Rx.Observable.of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes. + * .subscribe(sumObserver); + * + * // Logs: + * // "Adding: 1" + * // "Adding: 2" + * // "Adding: 3" + * // "Sum equals: 6" + * + * + * @example Subscribe with functions + * let sum = 0; + * + * Rx.Observable.of(1, 2, 3) + * .subscribe( + * function(value) { + * console.log('Adding: ' + value); + * sum = sum + value; + * }, + * undefined, + * function() { + * console.log('Sum equals: ' + sum); + * } + * ); + * + * // Logs: + * // "Adding: 1" + * // "Adding: 2" + * // "Adding: 3" + * // "Sum equals: 6" + * + * + * @example Cancel a subscription + * const subscription = Rx.Observable.interval(1000).subscribe( + * num => console.log(num), + * undefined, + * () => console.log('completed!') // Will not be called, even + * ); // when cancelling subscription + * + * + * setTimeout(() => { + * subscription.unsubscribe(); + * console.log('unsubscribed!'); + * }, 2500); + * + * // Logs: + * // 0 after 1s + * // 1 after 2s + * // "unsubscribed!" after 2.5s + * + * + * @param {Observer|Function} observerOrNext (optional) Either an observer with methods to be called, + * or the first of three possible handlers, which is the handler for each value emitted from the subscribed + * Observable. + * @param {Function} error (optional) A handler for a terminal event resulting from an error. If no error handler is provided, + * the error will be thrown as unhandled. + * @param {Function} complete (optional) A handler for a terminal event resulting from successful completion. + * @return {ISubscription} a subscription reference to the registered handlers + * @method subscribe + */ + Observable.prototype.subscribe = function (observerOrNext, error, complete) { + var operator = this.operator; + var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete); + if (operator) { + operator.call(sink, this.source); + } + else { + sink.add(this.source ? this._subscribe(sink) : this._trySubscribe(sink)); + } + if (sink.syncErrorThrowable) { + sink.syncErrorThrowable = false; + if (sink.syncErrorThrown) { + throw sink.syncErrorValue; + } + } + return sink; + }; + Observable.prototype._trySubscribe = function (sink) { + try { + return this._subscribe(sink); + } + catch (err) { + sink.syncErrorThrown = true; + sink.syncErrorValue = err; + sink.error(err); + } + }; + /** + * @method forEach + * @param {Function} next a handler for each value emitted by the observable + * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise + * @return {Promise} a promise that either resolves on observable completion or + * rejects with the handled error + */ + Observable.prototype.forEach = function (next, PromiseCtor) { + var _this = this; + if (!PromiseCtor) { + if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) { + PromiseCtor = root_1.root.Rx.config.Promise; + } + else if (root_1.root.Promise) { + PromiseCtor = root_1.root.Promise; + } + } + if (!PromiseCtor) { + throw new Error('no Promise impl found'); + } + return new PromiseCtor(function (resolve, reject) { + // Must be declared in a separate statement to avoid a RefernceError when + // accessing subscription below in the closure due to Temporal Dead Zone. + var subscription; + subscription = _this.subscribe(function (value) { + if (subscription) { + // if there is a subscription, then we can surmise + // the next handling is asynchronous. Any errors thrown + // need to be rejected explicitly and unsubscribe must be + // called manually + try { + next(value); + } + catch (err) { + reject(err); + subscription.unsubscribe(); + } + } + else { + // if there is NO subscription, then we're getting a nexted + // value synchronously during subscription. We can just call it. + // If it errors, Observable's `subscribe` will ensure the + // unsubscription logic is called, then synchronously rethrow the error. + // After that, Promise will trap the error and send it + // down the rejection path. + next(value); + } + }, reject, resolve); + }); + }; + Observable.prototype._subscribe = function (subscriber) { + return this.source.subscribe(subscriber); + }; + /** + * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable + * @method Symbol.observable + * @return {Observable} this instance of the observable + */ + Observable.prototype[observable_1.observable] = function () { + return this; + }; + // HACK: Since TypeScript inherits static properties too, we have to + // fight against TypeScript here so Subject can have a different static create signature + /** + * Creates a new cold Observable by calling the Observable constructor + * @static true + * @owner Observable + * @method create + * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor + * @return {Observable} a new cold observable + */ + Observable.create = function (subscribe) { + return new Observable(subscribe); + }; + return Observable; +}()); +exports.Observable = Observable; +//# sourceMappingURL=Observable.js.map + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 isFunction_1 = __webpack_require__(28); +var Subscription_1 = __webpack_require__(4); +var Observer_1 = __webpack_require__(61); +var rxSubscriber_1 = __webpack_require__(29); +/** + * 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 + */ +var Subscriber = (function (_super) { + __extends(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_1.empty; + break; + case 1: + if (!destinationOrNext) { + this.destination = Observer_1.empty; + break; + } + if (typeof destinationOrNext === 'object') { + if (destinationOrNext instanceof Subscriber) { + 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_1.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} 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)); +exports.Subscriber = Subscriber; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SafeSubscriber = (function (_super) { + __extends(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_1.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)); +//# sourceMappingURL=Subscriber.js.map + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var OuterSubscriber = (function (_super) { + __extends(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)); +exports.OuterSubscriber = OuterSubscriber; +//# sourceMappingURL=OuterSubscriber.js.map + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var root_1 = __webpack_require__(7); +var isArrayLike_1 = __webpack_require__(63); +var isPromise_1 = __webpack_require__(64); +var isObject_1 = __webpack_require__(59); +var Observable_1 = __webpack_require__(0); +var iterator_1 = __webpack_require__(21); +var InnerSubscriber_1 = __webpack_require__(141); +var observable_1 = __webpack_require__(30); +function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) { + var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex); + if (destination.closed) { + return null; + } + if (result instanceof Observable_1.Observable) { + if (result._isScalar) { + destination.next(result.value); + destination.complete(); + return null; + } + else { + return result.subscribe(destination); + } + } + else if (isArrayLike_1.isArrayLike(result)) { + for (var i = 0, len = result.length; i < len && !destination.closed; i++) { + destination.next(result[i]); + } + if (!destination.closed) { + destination.complete(); + } + } + else if (isPromise_1.isPromise(result)) { + result.then(function (value) { + if (!destination.closed) { + destination.next(value); + destination.complete(); + } + }, function (err) { return destination.error(err); }) + .then(null, function (err) { + // Escaping the Promise trap: globally throw unhandled errors + root_1.root.setTimeout(function () { throw err; }); + }); + return destination; + } + else if (result && typeof result[iterator_1.iterator] === 'function') { + var iterator = result[iterator_1.iterator](); + do { + var item = iterator.next(); + if (item.done) { + destination.complete(); + break; + } + destination.next(item.value); + if (destination.closed) { + break; + } + } while (true); + } + else if (result && typeof result[observable_1.observable] === 'function') { + var obs = result[observable_1.observable](); + if (typeof obs.subscribe !== 'function') { + destination.error(new TypeError('Provided object does not correctly implement Symbol.observable')); + } + else { + return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex)); + } + } + else { + var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'"; + var msg = ("You provided " + value + " where a stream was expected.") + + ' You can provide an Observable, Promise, Array, or Iterable.'; + destination.error(new TypeError(msg)); + } + return null; +} +exports.subscribeToResult = subscribeToResult; +//# sourceMappingURL=subscribeToResult.js.map + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var isArray_1 = __webpack_require__(13); +var isObject_1 = __webpack_require__(59); +var isFunction_1 = __webpack_require__(28); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var UnsubscriptionError_1 = __webpack_require__(60); +/** + * 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_1.errorObject) { + hasErrors = true; + errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ? + flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]); + } + } + if (isArray_1.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_1.errorObject) { + hasErrors = true; + errors = errors || []; + var err = errorObject_1.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; +}()); +exports.Subscription = Subscription; +function flattenUnsubscriptionErrors(errors) { + return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []); +} +//# sourceMappingURL=Subscription.js.map + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var Subscriber_1 = __webpack_require__(1); +var Subscription_1 = __webpack_require__(4); +var ObjectUnsubscribedError_1 = __webpack_require__(31); +var SubjectSubscription_1 = __webpack_require__(62); +var rxSubscriber_1 = __webpack_require__(29); +/** + * @class SubjectSubscriber + */ +var SubjectSubscriber = (function (_super) { + __extends(SubjectSubscriber, _super); + function SubjectSubscriber(destination) { + _super.call(this, destination); + this.destination = destination; + } + return SubjectSubscriber; +}(Subscriber_1.Subscriber)); +exports.SubjectSubscriber = SubjectSubscriber; +/** + * @class Subject + */ +var Subject = (function (_super) { + __extends(Subject, _super); + function Subject() { + _super.call(this); + this.observers = []; + this.closed = false; + this.isStopped = false; + this.hasError = false; + this.thrownError = null; + } + Subject.prototype[rxSubscriber_1.rxSubscriber] = function () { + return new SubjectSubscriber(this); + }; + Subject.prototype.lift = function (operator) { + var subject = new AnonymousSubject(this, this); + subject.operator = operator; + return subject; + }; + Subject.prototype.next = function (value) { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + if (!this.isStopped) { + var observers = this.observers; + var len = observers.length; + var copy = observers.slice(); + for (var i = 0; i < len; i++) { + copy[i].next(value); + } + } + }; + Subject.prototype.error = function (err) { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + this.hasError = true; + this.thrownError = err; + this.isStopped = true; + var observers = this.observers; + var len = observers.length; + var copy = observers.slice(); + for (var i = 0; i < len; i++) { + copy[i].error(err); + } + this.observers.length = 0; + }; + Subject.prototype.complete = function () { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + this.isStopped = true; + var observers = this.observers; + var len = observers.length; + var copy = observers.slice(); + for (var i = 0; i < len; i++) { + copy[i].complete(); + } + this.observers.length = 0; + }; + Subject.prototype.unsubscribe = function () { + this.isStopped = true; + this.closed = true; + this.observers = null; + }; + Subject.prototype._trySubscribe = function (subscriber) { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + else { + return _super.prototype._trySubscribe.call(this, subscriber); + } + }; + Subject.prototype._subscribe = function (subscriber) { + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + else if (this.hasError) { + subscriber.error(this.thrownError); + return Subscription_1.Subscription.EMPTY; + } + else if (this.isStopped) { + subscriber.complete(); + return Subscription_1.Subscription.EMPTY; + } + else { + this.observers.push(subscriber); + return new SubjectSubscription_1.SubjectSubscription(this, subscriber); + } + }; + Subject.prototype.asObservable = function () { + var observable = new Observable_1.Observable(); + observable.source = this; + return observable; + }; + Subject.create = function (destination, source) { + return new AnonymousSubject(destination, source); + }; + return Subject; +}(Observable_1.Observable)); +exports.Subject = Subject; +/** + * @class AnonymousSubject + */ +var AnonymousSubject = (function (_super) { + __extends(AnonymousSubject, _super); + function AnonymousSubject(destination, source) { + _super.call(this); + this.destination = destination; + this.source = source; + } + AnonymousSubject.prototype.next = function (value) { + var destination = this.destination; + if (destination && destination.next) { + destination.next(value); + } + }; + AnonymousSubject.prototype.error = function (err) { + var destination = this.destination; + if (destination && destination.error) { + this.destination.error(err); + } + }; + AnonymousSubject.prototype.complete = function () { + var destination = this.destination; + if (destination && destination.complete) { + this.destination.complete(); + } + }; + AnonymousSubject.prototype._subscribe = function (subscriber) { + var source = this.source; + if (source) { + return this.source.subscribe(subscriber); + } + else { + return Subscription_1.Subscription.EMPTY; + } + }; + return AnonymousSubject; +}(Subject)); +exports.AnonymousSubject = AnonymousSubject; +//# sourceMappingURL=Subject.js.map + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; - __webpack_require__(1); +// typeof any so that it we don't have to cast when comparing a result to the error object +exports.errorObject = { e: {} }; +//# sourceMappingURL=errorObject.js.map - var _scene = __webpack_require__(57); +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { +// 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 global !== 'undefined' && global; +var _root = __window || __global || __self; +exports.root = _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)'); + } +})(); +//# sourceMappingURL=root.js.map +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(27))) + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var errorObject_1 = __webpack_require__(6); +var tryCatchTarget; +function tryCatcher() { + try { + return tryCatchTarget.apply(this, arguments); + } + catch (e) { + errorObject_1.errorObject.e = e; + return errorObject_1.errorObject; + } +} +function tryCatch(fn) { + tryCatchTarget = fn; + return tryCatcher; +} +exports.tryCatch = tryCatch; +; +//# sourceMappingURL=tryCatch.js.map + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var AsyncAction_1 = __webpack_require__(23); +var AsyncScheduler_1 = __webpack_require__(24); +/** + * + * Async Scheduler + * + * Schedule task as if you used setTimeout(task, duration) + * + * `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 Use async scheduler to delay task + * const task = () => console.log('it works!'); + * + * Rx.Scheduler.async.schedule(task, 2000); + * + * // After 2 seconds logs: + * // "it works!" + * + * + * @example Use async scheduler to repeat task in intervals + * 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 + */ +exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); +//# sourceMappingURL=async.js.map + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { - var _scene2 = _interopRequireDefault(_scene); +"use strict"; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - document.body.appendChild((0, _scene2.default)()); +Object.defineProperty(exports, "__esModule", { + value: true +}); -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _jss = __webpack_require__(2); - - var _jss2 = _interopRequireDefault(_jss); - - var _theme = __webpack_require__(56); - - var theme = _interopRequireWildcard(_theme); - - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var styles = { - '@global': { - body: { - height: '100%', - width: '100%', - margin: 0, - padding: 0, - backgroundColor: theme.colorBg, - overflow: 'hidden' - }, - html: { - height: '100%', - width: '100%', - margin: 0, - padding: 0, - backgroundColor: theme.colorBg, - overflow: 'hidden' - }, - '*': { - boxSizing: 'border-box', - position: 'relative', - '&:before': { - content: '""', - display: 'block', - boxSizing: 'border-box', - position: 'relative' - }, - '&:after': { - content: '""', - display: 'block', - boxSizing: 'border-box', - position: 'relative' - } - } - } - }; - - _jss2.default.createStyleSheet(styles).attach(); - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { +var _jss = __webpack_require__(50); - 'use strict'; +var _jss2 = _interopRequireDefault(_jss); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _jssPresetDefault = __webpack_require__(110); - var _jss = __webpack_require__(3); +var _jssPresetDefault2 = _interopRequireDefault(_jssPresetDefault); - var _jss2 = _interopRequireDefault(_jss); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var _jssPresetDefault = __webpack_require__(36); +exports.default = _jss2.default.setup((0, _jssPresetDefault2.default)()); - var _jssPresetDefault2 = _interopRequireDefault(_jssPresetDefault); +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process) {/** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = function() {}; + +if (process.env.NODE_ENV !== 'production') { + warning = function(condition, format, args) { + var len = arguments.length; + args = new Array(len > 2 ? len - 2 : 0); + for (var key = 2; key < len; key++) { + args[key - 2] = arguments[key]; + } + if (format === undefined) { + throw new Error( + '`warning(condition, format, ...args)` requires a warning ' + + 'message argument' + ); + } + + if (format.length < 10 || (/^[s\W]*$/).test(format)) { + throw new Error( + 'The warning format should be able to uniquely identify this ' + + 'warning. Please, use a more descriptive format than: ' + format + ); + } + + if (!condition) { + var argIndex = 0; + var message = 'Warning: ' + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch(x) {} + } + }; +} + +module.exports = warning; + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(38))) + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var colorBg = exports.colorBg = '#1F1F3C'; +var colorFurLight = exports.colorFurLight = '#D5E8F8'; +var colorFurDark = exports.colorFurDark = '#8B9BD9'; +var colorFeatures = exports.colorFeatures = '#4B4D75'; +var colorFeaturesLight = exports.colorFeaturesLight = '#9FA2CB'; +var colorYarn = exports.colorYarn = '#DB242A'; +var duration = exports.duration = '7s'; +var durationSeconds = exports.durationSeconds = 7; +var easing = exports.easing = 'cubic-bezier(0.5, 0, 0.5, 1)'; +var offset = exports.offset = '.5s'; +var swings = exports.swings = '5 -10 10 -15 23 -23 15 -10 5'; +var totalSwings = exports.totalSwings = 'length($swings)'; +var yarnLength = exports.yarnLength = 20; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +"use strict"; - exports.default = _jss2.default.setup((0, _jssPresetDefault2.default)()); +exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); +//# sourceMappingURL=isArray.js.map -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.create = exports.createGenerateClassName = exports.sheets = exports.RuleList = exports.SheetsManager = exports.SheetsRegistry = exports.getDynamicStyles = undefined; +function isScheduler(value) { + return value && typeof value.schedule === 'function'; +} +exports.isScheduler = isScheduler; +//# sourceMappingURL=isScheduler.js.map - var _getDynamicStyles = __webpack_require__(4); +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var ScalarObservable_1 = __webpack_require__(43); +var EmptyObservable_1 = __webpack_require__(16); +var isScheduler_1 = __webpack_require__(14); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var ArrayObservable = (function (_super) { + __extends(ArrayObservable, _super); + function ArrayObservable(array, scheduler) { + _super.call(this); + this.array = array; + this.scheduler = scheduler; + if (!scheduler && array.length === 1) { + this._isScalar = true; + this.value = array[0]; + } + } + ArrayObservable.create = function (array, scheduler) { + return new ArrayObservable(array, scheduler); + }; + /** + * Creates an Observable that emits some values you specify as arguments, + * immediately one after the other, and then emits a complete notification. + * + * Emits the arguments you provide, then completes. + * + * + * + * + * This static operator is useful for creating a simple Observable that only + * emits the arguments given, and the complete notification thereafter. It can + * be used for composing with other Observables, such as with {@link concat}. + * By default, it uses a `null` IScheduler, which means the `next` + * notifications are sent synchronously, although with a different IScheduler + * it is possible to determine when those notifications will be delivered. + * + * @example Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second. + * var numbers = Rx.Observable.of(10, 20, 30); + * var letters = Rx.Observable.of('a', 'b', 'c'); + * var interval = Rx.Observable.interval(1000); + * var result = numbers.concat(letters).concat(interval); + * result.subscribe(x => console.log(x)); + * + * @see {@link create} + * @see {@link empty} + * @see {@link never} + * @see {@link throw} + * + * @param {...T} values Arguments that represent `next` values to be emitted. + * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling + * the emissions of the `next` notifications. + * @return {Observable} An Observable that emits each given input value. + * @static true + * @name of + * @owner Observable + */ + ArrayObservable.of = function () { + var array = []; + for (var _i = 0; _i < arguments.length; _i++) { + array[_i - 0] = arguments[_i]; + } + var scheduler = array[array.length - 1]; + if (isScheduler_1.isScheduler(scheduler)) { + array.pop(); + } + else { + scheduler = null; + } + var len = array.length; + if (len > 1) { + return new ArrayObservable(array, scheduler); + } + else if (len === 1) { + return new ScalarObservable_1.ScalarObservable(array[0], scheduler); + } + else { + return new EmptyObservable_1.EmptyObservable(scheduler); + } + }; + ArrayObservable.dispatch = function (state) { + var array = state.array, index = state.index, count = state.count, subscriber = state.subscriber; + if (index >= count) { + subscriber.complete(); + return; + } + subscriber.next(array[index]); + if (subscriber.closed) { + return; + } + state.index = index + 1; + this.schedule(state); + }; + ArrayObservable.prototype._subscribe = function (subscriber) { + var index = 0; + var array = this.array; + var count = array.length; + var scheduler = this.scheduler; + if (scheduler) { + return scheduler.schedule(ArrayObservable.dispatch, 0, { + array: array, index: index, count: count, subscriber: subscriber + }); + } + else { + for (var i = 0; i < count && !subscriber.closed; i++) { + subscriber.next(array[i]); + } + subscriber.complete(); + } + }; + return ArrayObservable; +}(Observable_1.Observable)); +exports.ArrayObservable = ArrayObservable; +//# sourceMappingURL=ArrayObservable.js.map + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var EmptyObservable = (function (_super) { + __extends(EmptyObservable, _super); + function EmptyObservable(scheduler) { + _super.call(this); + this.scheduler = scheduler; + } + /** + * Creates an Observable that emits no items to the Observer and immediately + * emits a complete notification. + * + * Just emits 'complete', and nothing else. + * + * + * + * + * This static operator is useful for creating a simple Observable that only + * emits the complete notification. It can be used for composing with other + * Observables, such as in a {@link mergeMap}. + * + * @example Emit the number 7, then complete. + * var result = Rx.Observable.empty().startWith(7); + * result.subscribe(x => console.log(x)); + * + * @example Map and flatten only odd numbers to the sequence 'a', 'b', 'c' + * var interval = Rx.Observable.interval(1000); + * var result = interval.mergeMap(x => + * x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty() + * ); + * result.subscribe(x => console.log(x)); + * + * // Results in the following to the console: + * // x is equal to the count on the interval eg(0,1,2,3,...) + * // x will occur every 1000ms + * // if x % 2 is equal to 1 print abc + * // if x % 2 is not equal to 1 nothing will be output + * + * @see {@link create} + * @see {@link never} + * @see {@link of} + * @see {@link throw} + * + * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling + * the emission of the complete notification. + * @return {Observable} An "empty" Observable: emits only the complete + * notification. + * @static true + * @name empty + * @owner Observable + */ + EmptyObservable.create = function (scheduler) { + return new EmptyObservable(scheduler); + }; + EmptyObservable.dispatch = function (arg) { + var subscriber = arg.subscriber; + subscriber.complete(); + }; + EmptyObservable.prototype._subscribe = function (subscriber) { + var scheduler = this.scheduler; + if (scheduler) { + return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber }); + } + else { + subscriber.complete(); + } + }; + return EmptyObservable; +}(Observable_1.Observable)); +exports.EmptyObservable = EmptyObservable; +//# sourceMappingURL=EmptyObservable.js.map + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var ConnectableObservable_1 = __webpack_require__(78); +/* tslint:enable:max-line-length */ +/** + * Returns an Observable that emits the results of invoking a specified selector on items + * emitted by a ConnectableObservable that shares a single subscription to the underlying stream. + * + * + * + * @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through + * which the source sequence's elements will be multicast to the selector function + * or Subject to push source elements into. + * @param {Function} [selector] - Optional selector function that can use the multicasted source stream + * as many times as needed, without causing multiple subscriptions to the source stream. + * Subscribers to the given source will receive all notifications of the source from the + * time of the subscription forward. + * @return {Observable} An Observable that emits the results of invoking the selector + * on the items emitted by a `ConnectableObservable` that shares a single subscription to + * the underlying stream. + * @method multicast + * @owner Observable + */ +function multicast(subjectOrSubjectFactory, selector) { + var subjectFactory; + if (typeof subjectOrSubjectFactory === 'function') { + subjectFactory = subjectOrSubjectFactory; + } + else { + subjectFactory = function subjectFactory() { + return subjectOrSubjectFactory; + }; + } + if (typeof selector === 'function') { + return this.lift(new MulticastOperator(subjectFactory, selector)); + } + var connectable = Object.create(this, ConnectableObservable_1.connectableObservableDescriptor); + connectable.source = this; + connectable.subjectFactory = subjectFactory; + return connectable; +} +exports.multicast = multicast; +var MulticastOperator = (function () { + function MulticastOperator(subjectFactory, selector) { + this.subjectFactory = subjectFactory; + this.selector = selector; + } + MulticastOperator.prototype.call = function (subscriber, source) { + var selector = this.selector; + var subject = this.subjectFactory(); + var subscription = selector(subject).subscribe(subscriber); + subscription.add(source.subscribe(subject)); + return subscription; + }; + return MulticastOperator; +}()); +exports.MulticastOperator = MulticastOperator; +//# sourceMappingURL=multicast.js.map + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { - Object.defineProperty(exports, 'getDynamicStyles', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_getDynamicStyles)['default']; - } - }); +"use strict"; - var _SheetsRegistry = __webpack_require__(5); +var symbolObservable = __webpack_require__(94); - Object.defineProperty(exports, 'SheetsRegistry', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_SheetsRegistry)['default']; - } - }); +module.exports = function (fn) { + return Boolean(fn && fn[symbolObservable]); +}; - var _SheetsManager = __webpack_require__(6); - Object.defineProperty(exports, 'SheetsManager', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_SheetsManager)['default']; - } - }); +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { - var _RuleList = __webpack_require__(9); +"use strict"; - Object.defineProperty(exports, 'RuleList', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_RuleList)['default']; - } - }); - var _sheets = __webpack_require__(21); +Object.defineProperty(exports, "__esModule", { + value: true +}); - Object.defineProperty(exports, 'sheets', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_sheets)['default']; - } - }); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - var _createGenerateClassName = __webpack_require__(22); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - Object.defineProperty(exports, 'createGenerateClassName', { - enumerable: true, - get: function get() { - return _interopRequireDefault(_createGenerateClassName)['default']; - } - }); +var _warning = __webpack_require__(11); - var _Jss = __webpack_require__(24); +var _warning2 = _interopRequireDefault(_warning); - var _Jss2 = _interopRequireDefault(_Jss); +var _toCss = __webpack_require__(39); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _toCss2 = _interopRequireDefault(_toCss); - /** - * Creates a new instance of Jss. - */ - var create = exports.create = function create(options) { - return new _Jss2['default'](options); - }; +var _toCssValue = __webpack_require__(53); - /** - * A global Jss instance. - */ - exports['default'] = create(); +var _toCssValue2 = _interopRequireDefault(_toCssValue); -/***/ }, -/* 4 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - - /** - * Extracts a styles object with only props that contain function values. - */ - exports['default'] = function (styles) { - // eslint-disable-next-line no-shadow - function extract(styles) { - var to = null; - - for (var key in styles) { - var value = styles[key]; - var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); - - if (type === 'function') { - if (!to) to = {}; - to[key] = value; - } else if (type === 'object' && value !== null && !Array.isArray(value)) { - var extracted = extract(value); - if (extracted) { - if (!to) to = {}; - to[key] = extracted; - } - } - } - - return to; - } - - return extract(styles); - }; - -/***/ }, -/* 5 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - /** - * Sheets registry to access them all at one place. - */ - var SheetsRegistry = function () { - function SheetsRegistry() { - _classCallCheck(this, SheetsRegistry); - - this.registry = []; - } - - _createClass(SheetsRegistry, [{ - key: 'add', - - - /** - * Register a Style Sheet. - */ - value: function add(sheet) { - var registry = this.registry; - var index = sheet.options.index; - - - if (registry.indexOf(sheet) !== -1) return; - - if (registry.length === 0 || index >= this.index) { - registry.push(sheet); - return; - } - - // Find a position. - for (var i = 0; i < registry.length; i++) { - if (registry[i].options.index > index) { - registry.splice(i, 0, sheet); - return; - } - } - } - - /** - * Reset the registry. - */ - - }, { - key: 'reset', - value: function reset() { - this.registry = []; - } - - /** - * Remove a Style Sheet. - */ - - }, { - key: 'remove', - value: function remove(sheet) { - var index = this.registry.indexOf(sheet); - this.registry.splice(index, 1); - } - - /** - * Convert all attached sheets to a CSS string. - */ - - }, { - key: 'toString', - value: function toString(options) { - return this.registry.filter(function (sheet) { - return sheet.attached; - }).map(function (sheet) { - return sheet.toString(options); - }).join('\n'); - } - }, { - key: 'index', - - - /** - * Current highest index number. - */ - get: function get() { - return this.registry.length === 0 ? 0 : this.registry[this.registry.length - 1].options.index; - } - }]); - - return SheetsRegistry; - }(); - - exports['default'] = SheetsRegistry; - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _warning = __webpack_require__(7); - - var _warning2 = _interopRequireDefault(_warning); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - /** - * SheetsManager is like a WeakMap which is designed to count StyleSheet - * instances and attach/detach automatically. - */ - var SheetsManager = function () { - function SheetsManager() { - _classCallCheck(this, SheetsManager); - - this.sheets = []; - this.refs = []; - this.keys = []; - } - - _createClass(SheetsManager, [{ - key: 'get', - value: function get(key) { - var index = this.keys.indexOf(key); - return this.sheets[index]; - } - }, { - key: 'add', - value: function add(key, sheet) { - var sheets = this.sheets, - refs = this.refs, - keys = this.keys; - - var index = sheets.indexOf(sheet); - - if (index !== -1) return index; - - sheets.push(sheet); - refs.push(0); - keys.push(key); - - return sheets.length - 1; - } - }, { - key: 'manage', - value: function manage(key) { - var index = this.keys.indexOf(key); - var sheet = this.sheets[index]; - if (this.refs[index] === 0) sheet.attach(); - this.refs[index]++; - if (!this.keys[index]) this.keys.splice(index, 0, key); - return sheet; - } - }, { - key: 'unmanage', - value: function unmanage(key) { - var index = this.keys.indexOf(key); - if (index === -1) { - // eslint-ignore-next-line no-console - (0, _warning2['default'])(false, 'SheetsManager: can\'t find sheet to unmanage'); - return; - } - if (this.refs[index] > 0) { - this.refs[index]--; - if (this.refs[index] === 0) this.sheets[index].detach(); - } - } - }, { - key: 'size', - get: function get() { - return this.keys.length; - } - }]); - - return SheetsManager; - }(); - - exports['default'] = SheetsManager; - -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright 2014-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - - 'use strict'; - - /** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - - var warning = function() {}; - - if (process.env.NODE_ENV !== 'production') { - warning = function(condition, format, args) { - var len = arguments.length; - args = new Array(len > 2 ? len - 2 : 0); - for (var key = 2; key < len; key++) { - args[key - 2] = arguments[key]; - } - if (format === undefined) { - throw new Error( - '`warning(condition, format, ...args)` requires a warning ' + - 'message argument' - ); - } - - if (format.length < 10 || (/^[s\W]*$/).test(format)) { - throw new Error( - 'The warning format should be able to uniquely identify this ' + - 'warning. Please, use a more descriptive format than: ' + format - ); - } - - if (!condition) { - var argIndex = 0; - var message = 'Warning: ' + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - if (typeof console !== 'undefined') { - console.error(message); - } - try { - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch(x) {} - } - }; - } +var _isDynamicValue = __webpack_require__(54); - module.exports = warning; +var _isDynamicValue2 = _interopRequireDefault(_isDynamicValue); - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -/***/ }, -/* 8 */ -/***/ function(module, exports) { +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var StyleRule = function () { + function StyleRule(key, style, options) { + _classCallCheck(this, StyleRule); + + this.type = 'style'; + this.isProcessed = false; + var sheet = options.sheet, + Renderer = options.Renderer, + selector = options.selector; - // shim for using process in browser - var process = module.exports = {}; + this.key = key; + this.options = options; + this.style = style; + if (selector) this.selectorText = selector; + this.renderer = sheet ? sheet.renderer : new Renderer(); + } + + /** + * Set selector string. + * Attention: use this with caution. Most browsers didn't implement + * selectorText setter, so this may result in rerendering of entire Style Sheet. + */ + + + _createClass(StyleRule, [{ + key: 'prop', + + + /** + * Get or set a style property. + */ + value: function prop(name, nextValue) { + // The result of a dynamic value is prefixed with $ and is not innumerable in + // order to be ignored by all plugins or during stringification. + var $name = (0, _isDynamicValue2['default'])(this.style[name]) ? '$' + name : name; + + // Its a setter. + if (nextValue != null) { + // Don't do anything if the value has not changed. + if (this.style[$name] !== nextValue) { + nextValue = this.options.jss.plugins.onChangeValue(nextValue, name, this); + Object.defineProperty(this.style, $name, { + value: nextValue, + writable: true + }); + // Renderable is defined if StyleSheet option `link` is true. + if (this.renderable) this.renderer.setStyle(this.renderable, name, nextValue);else { + var sheet = this.options.sheet; + + if (sheet && sheet.attached) { + (0, _warning2['default'])(false, 'Rule is not linked. Missing sheet option "link: true".'); + } + } + } + return this; + } + + return this.style[$name]; + } + + /** + * Apply rule to an element inline. + */ + + }, { + key: 'applyTo', + value: function applyTo(renderable) { + var json = this.toJSON(); + for (var prop in json) { + this.renderer.setStyle(renderable, prop, json[prop]); + }return this; + } + + /** + * Returns JSON representation of the rule. + * Fallbacks are not supported. + * Useful for inline styles. + */ + + }, { + key: 'toJSON', + value: function toJSON() { + var json = {}; + for (var prop in this.style) { + var value = this.style[prop]; + if ((0, _isDynamicValue2['default'])(value)) json[prop] = this.style['$' + prop];else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object') json[prop] = value;else if (Array.isArray(value)) json[prop] = (0, _toCssValue2['default'])(value); + } + return json; + } + + /** + * Generates a CSS string. + */ + + }, { + key: 'toString', + value: function toString(options) { + return (0, _toCss2['default'])(this.selector, this.style, options); + } + }, { + key: 'selector', + set: function set(selector) { + if (selector === this.selectorText) return; + + this.selectorText = selector; + + if (this.renderable) { + var hasChanged = this.renderer.setSelector(this.renderable, selector); + + // If selector setter is not implemented, rerender the rule. + if (!hasChanged && this.renderable) { + var renderable = this.renderer.replaceRule(this.renderable, this); + if (renderable) this.renderable = renderable; + } + } + } + + /** + * Get selector string. + */ + , + get: function get() { + return this.selectorText; + } + }]); + + return StyleRule; +}(); + +exports['default'] = StyleRule; + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports.faceAnimation = faceAnimation; +exports.blinkAnimation = blinkAnimation; +exports.swingLegAnimation = swingLegAnimation; +exports.swingTailAnimation = swingTailAnimation; +exports.swingAnimation = swingAnimation; +exports.reverseSwingAnimation = reverseSwingAnimation; +exports.bobAnimation = bobAnimation; + +var _rxjs = __webpack_require__(58); + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* CONSTATNST */ + +var TRANSFORM = 'transform'; + +var percents = [100, 87.5, 75, 62.5, 50, 37.5, 25, 12.5, 0]; + +/* UTILS */ + +function createIterations(percents, values) { + return percents.map(function (percent, i) { + return { + percent: percent, + value: values[i] + }; + }); +} + +function createAnimationLoader(duration) { + var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + return _rxjs.Observable.interval(100).delay(delay).startWith(0).scan(function (x) { + return x > duration * 10 ? 0 : x + 1; + }, 0).map(function (x) { + return x * 10 / duration; + }); +} + +function getAnimationValue($animationLoader, iterations) { + return $animationLoader.map(function (percent) { + for (var i = 0; i < iterations.length; i++) { + if (percent >= iterations[i].percent) { + return iterations[i].value; + } + } + return iterations[iterations.length - 1].value; + }); +} + +function getTransformTransition() { + var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; + var transitionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'linear'; + + return { transition: TRANSFORM + ' ' + time + 's ' + transitionType }; +} + +function createAnimation(duration, delay, transitionType, transionTime, iterations, modifyStyle) { + var $animationLoader = createAnimationLoader(duration, delay); + return _extends(_defineProperty({}, TRANSFORM, getAnimationValue($animationLoader, iterations).map(modifyStyle)), getTransformTransition(transionTime, transitionType)); +} + +function createRotateAnimation(duration, delay, transitionType, values) { + var iterations = createIterations(percents, values); + return createAnimation(duration, delay, transitionType, 1, iterations, function (x) { + return 'rotate(' + x + 'deg)'; + }); +} + +/* ANIMATIONS */ + +function faceAnimation(duration, delay, transitionType) { + var values = [-2.5, 5, -7.5, 11.5, -11.5, 7.5, -5, 5, -2.5]; + var iterations = createIterations(percents, values); + return createAnimation(duration, delay, transitionType, 0.9, iterations, function (x) { + return 'translateX(' + x + 'px)'; + }); +} + +function blinkAnimation(duration, delay, transitionType) { + var iterations = [{ percent: 80, value: 1 }, { percent: 78, value: 0.1 }, { percent: 25, value: 1 }, { percent: 23, value: 0.1 }, { percent: 10, value: 1 }, { percent: 8, value: 0.1 }]; + return createAnimation(duration, delay, transitionType, 0.6, iterations, function (x) { + return 'scaleY(' + x + ')'; + }); +} + +function swingLegAnimation(duration, delay, transitionType) { + var values = [0.5, -1, 1.5, -2.3, 2.4, -1.5, 1, -1, 0.5]; + return createRotateAnimation(duration, delay, transitionType, values); +} + +function swingTailAnimation(duration, delay, transitionType) { + var values = [-2, 4, -6, 9.2, -9.2, 6, -4, 4, -2]; + return createRotateAnimation(duration, delay, transitionType, values); +} + +function swingAnimation(duration, delay, transitionType) { + var values = [5, -10, 15, -23, 23, -15, 10, -10, 5]; + return createRotateAnimation(duration, delay, transitionType, values); +} + +function reverseSwingAnimation(duration, delay, transitionType) { + var values = [-5, 10, -15, 23, -23, 15, -10, 10, -5]; + return createRotateAnimation(duration, delay, transitionType, values); +} + +function bobAnimation(duration, delay, transitionType) { + var iterations = [{ percent: 100, value: 0.4 }, { percent: 93.75, value: -0.4 }, { percent: 87.5, value: 0.4 }, { percent: 81.25, value: -0.4 }, { percent: 75, value: 0.4 }, { percent: 68.75, value: -0.4 }, { percent: 62.5, value: 0.4 }, { percent: 56.25, value: -0.4 }, { percent: 50, value: 0.4 }, { percent: 43.75, value: -0.4 }, { percent: 37.5, value: 0.4 }, { percent: 31.25, value: -0.4 }, { percent: 25, value: 0.4 }, { percent: 18.75, value: -0.4 }, { percent: 12.5, value: 0.4 }, { percent: 6.25, value: -0.4 }, { percent: 0, value: 0.4 }]; + return createAnimation(duration, delay, transitionType, 0.3, iterations, function (x) { + return 'translateY(' + x + 'rem)'; + }); +} + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var root_1 = __webpack_require__(7); +function symbolIteratorPonyfill(root) { + var Symbol = root.Symbol; + if (typeof Symbol === 'function') { + if (!Symbol.iterator) { + Symbol.iterator = Symbol('iterator polyfill'); + } + return Symbol.iterator; + } + else { + // [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC) + var Set_1 = root.Set; + if (Set_1 && typeof new Set_1()['@@iterator'] === 'function') { + return '@@iterator'; + } + var Map_1 = root.Map; + // required for compatability with es6-shim + if (Map_1) { + var keys = Object.getOwnPropertyNames(Map_1.prototype); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + // according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal. + if (key !== 'entries' && key !== 'size' && Map_1.prototype[key] === Map_1.prototype['entries']) { + return key; + } + } + } + return '@@iterator'; + } +} +exports.symbolIteratorPonyfill = symbolIteratorPonyfill; +exports.iterator = symbolIteratorPonyfill(root_1.root); +/** + * @deprecated use iterator instead + */ +exports.$$iterator = exports.iterator; +//# sourceMappingURL=iterator.js.map + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +/** + * Represents a push-based event or value that an {@link Observable} can emit. + * This class is particularly useful for operators that manage notifications, + * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and + * others. Besides wrapping the actual delivered value, it also annotates it + * with metadata of, for instance, what type of push message it is (`next`, + * `error`, or `complete`). + * + * @see {@link materialize} + * @see {@link dematerialize} + * @see {@link observeOn} + * + * @class Notification + */ +var Notification = (function () { + function Notification(kind, value, error) { + this.kind = kind; + this.value = value; + this.error = error; + this.hasValue = kind === 'N'; + } + /** + * Delivers to the given `observer` the value wrapped by this Notification. + * @param {Observer} observer + * @return + */ + Notification.prototype.observe = function (observer) { + switch (this.kind) { + case 'N': + return observer.next && observer.next(this.value); + case 'E': + return observer.error && observer.error(this.error); + case 'C': + return observer.complete && observer.complete(); + } + }; + /** + * Given some {@link Observer} callbacks, deliver the value represented by the + * current Notification to the correctly corresponding callback. + * @param {function(value: T): void} next An Observer `next` callback. + * @param {function(err: any): void} [error] An Observer `error` callback. + * @param {function(): void} [complete] An Observer `complete` callback. + * @return {any} + */ + Notification.prototype.do = function (next, error, complete) { + var kind = this.kind; + switch (kind) { + case 'N': + return next && next(this.value); + case 'E': + return error && error(this.error); + case 'C': + return complete && complete(); + } + }; + /** + * Takes an Observer or its individual callback functions, and calls `observe` + * or `do` methods accordingly. + * @param {Observer|function(value: T): void} nextOrObserver An Observer or + * the `next` callback. + * @param {function(err: any): void} [error] An Observer `error` callback. + * @param {function(): void} [complete] An Observer `complete` callback. + * @return {any} + */ + Notification.prototype.accept = function (nextOrObserver, error, complete) { + if (nextOrObserver && typeof nextOrObserver.next === 'function') { + return this.observe(nextOrObserver); + } + else { + return this.do(nextOrObserver, error, complete); + } + }; + /** + * Returns a simple Observable that just delivers the notification represented + * by this Notification instance. + * @return {any} + */ + Notification.prototype.toObservable = function () { + var kind = this.kind; + switch (kind) { + case 'N': + return Observable_1.Observable.of(this.value); + case 'E': + return Observable_1.Observable.throw(this.error); + case 'C': + return Observable_1.Observable.empty(); + } + throw new Error('unexpected notification kind value'); + }; + /** + * A shortcut to create a Notification instance of the type `next` from a + * given value. + * @param {T} value The `next` value. + * @return {Notification} The "next" Notification representing the + * argument. + */ + Notification.createNext = function (value) { + if (typeof value !== 'undefined') { + return new Notification('N', value); + } + return Notification.undefinedValueNotification; + }; + /** + * A shortcut to create a Notification instance of the type `error` from a + * given error. + * @param {any} [err] The `error` error. + * @return {Notification} The "error" Notification representing the + * argument. + */ + Notification.createError = function (err) { + return new Notification('E', undefined, err); + }; + /** + * A shortcut to create a Notification instance of the type `complete`. + * @return {Notification} The valueless "complete" Notification. + */ + Notification.createComplete = function () { + return Notification.completeNotification; + }; + Notification.completeNotification = new Notification('C'); + Notification.undefinedValueNotification = new Notification('N', undefined); + return Notification; +}()); +exports.Notification = Notification; +//# sourceMappingURL=Notification.js.map + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 root_1 = __webpack_require__(7); +var Action_1 = __webpack_require__(173); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var AsyncAction = (function (_super) { + __extends(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, delay) { + if (delay === void 0) { delay = 0; } + if (this.closed) { + return this; + } + // Always replace the current state with the new state. + this.state = state; + // 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_1.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_1.root.clearInterval(id) && undefined || undefined; + }; + /** + * Immediately executes this action and the `work` it contains. + * @return {any} + */ + AsyncAction.prototype.execute = function (state, delay) { + if (this.closed) { + return new Error('executing a cancelled action'); + } + this.pending = false; + var error = this._execute(state, 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, delay) { + var errored = false; + var errorValue = undefined; + try { + this.work(state); + } + 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)); +exports.AsyncAction = AsyncAction; +//# sourceMappingURL=AsyncAction.js.map + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Scheduler_1 = __webpack_require__(174); +var AsyncScheduler = (function (_super) { + __extends(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)); +exports.AsyncScheduler = AsyncScheduler; +//# sourceMappingURL=AsyncScheduler.js.map + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 an element was queried at a certain index of an + * Observable, but no such index or position exists in that sequence. + * + * @see {@link elementAt} + * @see {@link take} + * @see {@link takeLast} + * + * @class ArgumentOutOfRangeError + */ +var ArgumentOutOfRangeError = (function (_super) { + __extends(ArgumentOutOfRangeError, _super); + function ArgumentOutOfRangeError() { + var err = _super.call(this, 'argument out of range'); + this.name = err.name = 'ArgumentOutOfRangeError'; + this.stack = err.stack; + this.message = err.message; + } + return ArgumentOutOfRangeError; +}(Error)); +exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError; +//# sourceMappingURL=ArgumentOutOfRangeError.js.map + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { - // cached from whatever global is present so that test runners that stub it - // don't break things. But we need to wrap it in a try catch in case it is - // wrapped in strict mode code which doesn't define any globals. It's inside a - // function because try/catches deoptimize in certain engines. +"use strict"; - var cachedSetTimeout; - var cachedClearTimeout; - function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); - } - function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); - } - (function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } - } ()) - function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - } - function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _createRule = __webpack_require__(52); +var _createRule2 = _interopRequireDefault(_createRule); - } - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - - function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } - } +var _updateStyle = __webpack_require__(97); - function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); - } +var _updateStyle2 = _interopRequireDefault(_updateStyle); - process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } - }; - - // v8 likes predictible objects - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - Item.prototype.run = function () { - this.fun.apply(null, this.array); - }; - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; - - process.cwd = function () { return '/' }; - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); - }; - process.umask = function() { return 0; }; - - -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { +var _linkRule = __webpack_require__(55); - 'use strict'; +var _linkRule2 = _interopRequireDefault(_linkRule); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _StyleRule = __webpack_require__(19); - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +var _StyleRule2 = _interopRequireDefault(_StyleRule); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _createRule = __webpack_require__(10); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var _createRule2 = _interopRequireDefault(_createRule); +/** + * Contains rules objects and allows adding/removing etc. + * Is used for e.g. by `StyleSheet` or `ConditionalRule`. + */ +var RuleList = function () { - var _updateStyle = __webpack_require__(19); + // Original styles object. + function RuleList(options) { + _classCallCheck(this, RuleList); - var _updateStyle2 = _interopRequireDefault(_updateStyle); + this.map = {}; + this.raw = {}; + this.index = []; - var _linkRule = __webpack_require__(20); + this.options = options; + this.classes = options.classes; + } - var _linkRule2 = _interopRequireDefault(_linkRule); + /** + * Create and register rule. + * + * Will not render after Style Sheet was rendered the first time. + */ - var _StyleRule = __webpack_require__(11); - var _StyleRule2 = _interopRequireDefault(_StyleRule); + // Used to ensure correct rules order. - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + // Rules registry for access by .get() method. + // It contains the same rule registered by name and by selector. - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - /** - * Contains rules objects and allows adding/removing etc. - * Is used for e.g. by `StyleSheet` or `ConditionalRule`. - */ - var RuleList = function () { + _createClass(RuleList, [{ + key: 'add', + value: function add(name, decl, options) { + var _options = this.options, + parent = _options.parent, + sheet = _options.sheet, + jss = _options.jss, + Renderer = _options.Renderer, + generateClassName = _options.generateClassName; - // Original styles object. - function RuleList(options) { - _classCallCheck(this, RuleList); - this.map = {}; - this.raw = {}; - this.index = []; + options = _extends({ + classes: this.classes, + parent: parent, + sheet: sheet, + jss: jss, + Renderer: Renderer, + generateClassName: generateClassName + }, options); - this.options = options; - this.classes = options.classes; - } + if (!options.selector && this.classes[name]) { + options.selector = '.' + this.classes[name]; + } - /** - * Create and register rule. - * - * Will not render after Style Sheet was rendered the first time. - */ + this.raw[name] = decl; + var rule = (0, _createRule2['default'])(name, decl, options); + var className = void 0; - // Used to ensure correct rules order. + if (!options.selector && rule instanceof _StyleRule2['default']) { + className = generateClassName(rule, sheet); + rule.selector = '.' + className; + } - // Rules registry for access by .get() method. - // It contains the same rule registered by name and by selector. + this.register(rule, className); + var index = options.index === undefined ? this.index.length : options.index; + this.index.splice(index, 0, rule); - _createClass(RuleList, [{ - key: 'add', - value: function add(name, decl, options) { - var _options = this.options, - parent = _options.parent, - sheet = _options.sheet, - jss = _options.jss, - Renderer = _options.Renderer, - generateClassName = _options.generateClassName; + return rule; + } + /** + * Get a rule. + */ + + }, { + key: 'get', + value: function get(name) { + return this.map[name]; + } + + /** + * Delete a rule. + */ + + }, { + key: 'remove', + value: function remove(rule) { + this.unregister(rule); + this.index.splice(this.indexOf(rule), 1); + } + + /** + * Get index of a rule. + */ + + }, { + key: 'indexOf', + value: function indexOf(rule) { + return this.index.indexOf(rule); + } + + /** + * Run `onProcessRule()` plugins on every rule. + */ + + }, { + key: 'process', + value: function process() { + var plugins = this.options.jss.plugins; + // We need to clone array because if we modify the index somewhere else during a loop + // we end up with very hard-to-track-down side effects. + + this.index.slice(0).forEach(plugins.onProcessRule, plugins); + } + + /** + * Register a rule in `.map` and `.classes` maps. + */ + + }, { + key: 'register', + value: function register(rule, className) { + this.map[rule.key] = rule; + if (rule instanceof _StyleRule2['default']) { + this.map[rule.selector] = rule; + if (className) this.classes[rule.key] = className; + } + } + + /** + * Unregister a rule. + */ + + }, { + key: 'unregister', + value: function unregister(rule) { + delete this.map[rule.key]; + if (rule instanceof _StyleRule2['default']) { + delete this.map[rule.selector]; + delete this.classes[rule.key]; + } + } + + /** + * Update the function values with a new data. + */ + + }, { + key: 'update', + value: function update(name, data) { + if (typeof name === 'string') { + (0, _updateStyle2['default'])(this.get(name), data, RuleList); + return; + } + + for (var index = 0; index < this.index.length; index++) { + (0, _updateStyle2['default'])(this.index[index], name, RuleList); + } + } + + /** + * Link renderable rules with CSSRuleList. + */ + + }, { + key: 'link', + value: function link(cssRules) { + var map = this.options.sheet.renderer.getUnescapedKeysMap(this.index); + + for (var i = 0; i < cssRules.length; i++) { + var cssRule = cssRules[i]; + var _key = this.options.sheet.renderer.getKey(cssRule); + if (map[_key]) _key = map[_key]; + var rule = this.map[_key]; + if (rule) (0, _linkRule2['default'])(rule, cssRule); + } + } + + /** + * Convert rules to a CSS string. + */ + + }, { + key: 'toString', + value: function toString(options) { + var str = ''; + + for (var index = 0; index < this.index.length; index++) { + var rule = this.index[index]; + var css = rule.toString(options); + + // No need to render an empty rule. + if (!css) continue; + + if (str) str += '\n'; + str += css; + } + + return str; + } + }]); + + return RuleList; +}(); + +exports['default'] = RuleList; + +/***/ }), +/* 27 */ +/***/ (function(module, exports) { - options = _extends({ - classes: this.classes, - parent: parent, - sheet: sheet, - jss: jss, - Renderer: Renderer, - generateClassName: generateClassName - }, options); +var g; - if (!options.selector && this.classes[name]) { - options.selector = '.' + this.classes[name]; - } +// This works in non-strict mode +g = (function() { + return this; +})(); - this.raw[name] = decl; +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; +} - var rule = (0, _createRule2['default'])(name, decl, options); - var className = void 0; +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} - if (!options.selector && rule instanceof _StyleRule2['default']) { - className = generateClassName(rule, sheet); - rule.selector = '.' + className; - } +module.exports = g; - this.register(rule, className); - var index = options.index === undefined ? this.index.length : options.index; - this.index.splice(index, 0, rule); +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { - return rule; - } +"use strict"; - /** - * Get a rule. - */ - - }, { - key: 'get', - value: function get(name) { - return this.map[name]; - } - - /** - * Delete a rule. - */ - - }, { - key: 'remove', - value: function remove(rule) { - this.unregister(rule); - this.index.splice(this.indexOf(rule), 1); - } - - /** - * Get index of a rule. - */ - - }, { - key: 'indexOf', - value: function indexOf(rule) { - return this.index.indexOf(rule); - } - - /** - * Run `onProcessRule()` plugins on every rule. - */ - - }, { - key: 'process', - value: function process() { - var plugins = this.options.jss.plugins; - // We need to clone array because if we modify the index somewhere else during a loop - // we end up with very hard-to-track-down side effects. - - this.index.slice(0).forEach(plugins.onProcessRule, plugins); - } - - /** - * Register a rule in `.map` and `.classes` maps. - */ - - }, { - key: 'register', - value: function register(rule, className) { - this.map[rule.key] = rule; - if (rule instanceof _StyleRule2['default']) { - this.map[rule.selector] = rule; - if (className) this.classes[rule.key] = className; - } - } - - /** - * Unregister a rule. - */ - - }, { - key: 'unregister', - value: function unregister(rule) { - delete this.map[rule.key]; - if (rule instanceof _StyleRule2['default']) { - delete this.map[rule.selector]; - delete this.classes[rule.key]; - } - } - - /** - * Update the function values with a new data. - */ - - }, { - key: 'update', - value: function update(name, data) { - if (typeof name === 'string') { - (0, _updateStyle2['default'])(this.get(name), data, RuleList); - return; - } - - for (var index = 0; index < this.index.length; index++) { - (0, _updateStyle2['default'])(this.index[index], name, RuleList); - } - } - - /** - * Link renderable rules with CSSRuleList. - */ - - }, { - key: 'link', - value: function link(cssRules) { - var map = this.options.sheet.renderer.getUnescapedKeysMap(this.index); - - for (var i = 0; i < cssRules.length; i++) { - var cssRule = cssRules[i]; - var _key = this.options.sheet.renderer.getKey(cssRule); - if (map[_key]) _key = map[_key]; - var rule = this.map[_key]; - if (rule) (0, _linkRule2['default'])(rule, cssRule); - } - } - - /** - * Convert rules to a CSS string. - */ - - }, { - key: 'toString', - value: function toString(options) { - var str = ''; - - for (var index = 0; index < this.index.length; index++) { - var rule = this.index[index]; - var css = rule.toString(options); - - // No need to render an empty rule. - if (!css) continue; - - if (str) str += '\n'; - str += css; - } - - return str; - } - }]); - - return RuleList; - }(); - - exports['default'] = RuleList; - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { +function isFunction(x) { + return typeof x === 'function'; +} +exports.isFunction = isFunction; +//# sourceMappingURL=isFunction.js.map - 'use strict'; +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = createRule; +"use strict"; - var _warning = __webpack_require__(7); +var root_1 = __webpack_require__(7); +var Symbol = root_1.root.Symbol; +exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ? + Symbol.for('rxSubscriber') : '@@rxSubscriber'; +/** + * @deprecated use rxSubscriber instead + */ +exports.$$rxSubscriber = exports.rxSubscriber; +//# sourceMappingURL=rxSubscriber.js.map - var _warning2 = _interopRequireDefault(_warning); +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var root_1 = __webpack_require__(7); +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_1.root); +/** + * @deprecated use observable instead + */ +exports.$$observable = exports.observable; +//# sourceMappingURL=observable.js.map + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 an action is invalid because the object has been + * unsubscribed. + * + * @see {@link Subject} + * @see {@link BehaviorSubject} + * + * @class ObjectUnsubscribedError + */ +var ObjectUnsubscribedError = (function (_super) { + __extends(ObjectUnsubscribedError, _super); + function ObjectUnsubscribedError() { + var err = _super.call(this, 'object unsubscribed'); + this.name = err.name = 'ObjectUnsubscribedError'; + this.stack = err.stack; + this.message = err.message; + } + return ObjectUnsubscribedError; +}(Error)); +exports.ObjectUnsubscribedError = ObjectUnsubscribedError; +//# sourceMappingURL=ObjectUnsubscribedError.js.map + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subject_1 = __webpack_require__(5); +var Subscription_1 = __webpack_require__(4); +/** + * @class AsyncSubject + */ +var AsyncSubject = (function (_super) { + __extends(AsyncSubject, _super); + function AsyncSubject() { + _super.apply(this, arguments); + this.value = null; + this.hasNext = false; + this.hasCompleted = false; + } + AsyncSubject.prototype._subscribe = function (subscriber) { + if (this.hasError) { + subscriber.error(this.thrownError); + return Subscription_1.Subscription.EMPTY; + } + else if (this.hasCompleted && this.hasNext) { + subscriber.next(this.value); + subscriber.complete(); + return Subscription_1.Subscription.EMPTY; + } + return _super.prototype._subscribe.call(this, subscriber); + }; + AsyncSubject.prototype.next = function (value) { + if (!this.hasCompleted) { + this.value = value; + this.hasNext = true; + } + }; + AsyncSubject.prototype.error = function (error) { + if (!this.hasCompleted) { + _super.prototype.error.call(this, error); + } + }; + AsyncSubject.prototype.complete = function () { + this.hasCompleted = true; + if (this.hasNext) { + _super.prototype.next.call(this, this.value); + } + _super.prototype.complete.call(this); + }; + return AsyncSubject; +}(Subject_1.Subject)); +exports.AsyncSubject = AsyncSubject; +//# sourceMappingURL=AsyncSubject.js.map + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Converts a higher-order Observable into a first-order Observable which + * concurrently delivers all values that are emitted on the inner Observables. + * + * Flattens an Observable-of-Observables. + * + * + * + * `mergeAll` subscribes to an Observable that emits Observables, also known as + * a higher-order Observable. Each time it observes one of these emitted inner + * Observables, it subscribes to that and delivers all the values from the + * inner Observable on the output Observable. The output Observable only + * completes once all inner Observables have completed. Any error delivered by + * a inner Observable will be immediately emitted on the output Observable. + * + * @example Spawn a new interval Observable for each click event, and blend their outputs as one Observable + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000)); + * var firstOrder = higherOrder.mergeAll(); + * firstOrder.subscribe(x => console.log(x)); + * + * @example Count from 0 to 9 every second for each click, but only allow 2 concurrent timers + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10)); + * var firstOrder = higherOrder.mergeAll(2); + * firstOrder.subscribe(x => console.log(x)); + * + * @see {@link combineAll} + * @see {@link concatAll} + * @see {@link exhaust} + * @see {@link merge} + * @see {@link mergeMap} + * @see {@link mergeMapTo} + * @see {@link mergeScan} + * @see {@link switch} + * @see {@link zipAll} + * + * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner + * Observables being subscribed to concurrently. + * @return {Observable} An Observable that emits values coming from all the + * inner Observables emitted by the source Observable. + * @method mergeAll + * @owner Observable + */ +function mergeAll(concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + return this.lift(new MergeAllOperator(concurrent)); +} +exports.mergeAll = mergeAll; +var MergeAllOperator = (function () { + function MergeAllOperator(concurrent) { + this.concurrent = concurrent; + } + MergeAllOperator.prototype.call = function (observer, source) { + return source.subscribe(new MergeAllSubscriber(observer, this.concurrent)); + }; + return MergeAllOperator; +}()); +exports.MergeAllOperator = MergeAllOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var MergeAllSubscriber = (function (_super) { + __extends(MergeAllSubscriber, _super); + function MergeAllSubscriber(destination, concurrent) { + _super.call(this, destination); + this.concurrent = concurrent; + this.hasCompleted = false; + this.buffer = []; + this.active = 0; + } + MergeAllSubscriber.prototype._next = function (observable) { + if (this.active < this.concurrent) { + this.active++; + this.add(subscribeToResult_1.subscribeToResult(this, observable)); + } + else { + this.buffer.push(observable); + } + }; + MergeAllSubscriber.prototype._complete = function () { + this.hasCompleted = true; + if (this.active === 0 && this.buffer.length === 0) { + this.destination.complete(); + } + }; + MergeAllSubscriber.prototype.notifyComplete = function (innerSub) { + var buffer = this.buffer; + this.remove(innerSub); + this.active--; + if (buffer.length > 0) { + this._next(buffer.shift()); + } + else if (this.active === 0 && this.hasCompleted) { + this.destination.complete(); + } + }; + return MergeAllSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.MergeAllSubscriber = MergeAllSubscriber; +//# sourceMappingURL=mergeAll.js.map + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var isArray_1 = __webpack_require__(13); +function isNumeric(val) { + // parseFloat NaNs numeric-cast false positives (null|true|false|"") + // ...but misinterprets leading-number strings, particularly hex literals ("0x...") + // subtraction forces infinities to NaN + // adding 1 corrects loss of precision from parseFloat (#15100) + return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0; +} +exports.isNumeric = isNumeric; +; +//# sourceMappingURL=isNumeric.js.map + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { - var _StyleRule = __webpack_require__(11); +"use strict"; - var _StyleRule2 = _interopRequireDefault(_StyleRule); +function isDate(value) { + return value instanceof Date && !isNaN(+value); +} +exports.isDate = isDate; +//# sourceMappingURL=isDate.js.map - var _cloneStyle = __webpack_require__(18); +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subject_1 = __webpack_require__(5); +var queue_1 = __webpack_require__(72); +var Subscription_1 = __webpack_require__(4); +var observeOn_1 = __webpack_require__(46); +var ObjectUnsubscribedError_1 = __webpack_require__(31); +var SubjectSubscription_1 = __webpack_require__(62); +/** + * @class ReplaySubject + */ +var ReplaySubject = (function (_super) { + __extends(ReplaySubject, _super); + function ReplaySubject(bufferSize, windowTime, scheduler) { + if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; } + if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; } + _super.call(this); + this.scheduler = scheduler; + this._events = []; + this._bufferSize = bufferSize < 1 ? 1 : bufferSize; + this._windowTime = windowTime < 1 ? 1 : windowTime; + } + ReplaySubject.prototype.next = function (value) { + var now = this._getNow(); + this._events.push(new ReplayEvent(now, value)); + this._trimBufferThenGetEvents(); + _super.prototype.next.call(this, value); + }; + ReplaySubject.prototype._subscribe = function (subscriber) { + var _events = this._trimBufferThenGetEvents(); + var scheduler = this.scheduler; + var subscription; + if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + else if (this.hasError) { + subscription = Subscription_1.Subscription.EMPTY; + } + else if (this.isStopped) { + subscription = Subscription_1.Subscription.EMPTY; + } + else { + this.observers.push(subscriber); + subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber); + } + if (scheduler) { + subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler)); + } + var len = _events.length; + for (var i = 0; i < len && !subscriber.closed; i++) { + subscriber.next(_events[i].value); + } + if (this.hasError) { + subscriber.error(this.thrownError); + } + else if (this.isStopped) { + subscriber.complete(); + } + return subscription; + }; + ReplaySubject.prototype._getNow = function () { + return (this.scheduler || queue_1.queue).now(); + }; + ReplaySubject.prototype._trimBufferThenGetEvents = function () { + var now = this._getNow(); + var _bufferSize = this._bufferSize; + var _windowTime = this._windowTime; + var _events = this._events; + var eventsCount = _events.length; + var spliceCount = 0; + // Trim events that fall out of the time window. + // Start at the front of the list. Break early once + // we encounter an event that falls within the window. + while (spliceCount < eventsCount) { + if ((now - _events[spliceCount].time) < _windowTime) { + break; + } + spliceCount++; + } + if (eventsCount > _bufferSize) { + spliceCount = Math.max(spliceCount, eventsCount - _bufferSize); + } + if (spliceCount > 0) { + _events.splice(0, spliceCount); + } + return _events; + }; + return ReplaySubject; +}(Subject_1.Subject)); +exports.ReplaySubject = ReplaySubject; +var ReplayEvent = (function () { + function ReplayEvent(time, value) { + this.time = time; + this.value = value; + } + return ReplayEvent; +}()); +//# sourceMappingURL=ReplaySubject.js.map + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 an Observable or a sequence was queried but has no + * elements. + * + * @see {@link first} + * @see {@link last} + * @see {@link single} + * + * @class EmptyError + */ +var EmptyError = (function (_super) { + __extends(EmptyError, _super); + function EmptyError() { + var err = _super.call(this, 'no elements in sequence'); + this.name = err.name = 'EmptyError'; + this.stack = err.stack; + this.message = err.message; + } + return EmptyError; +}(Error)); +exports.EmptyError = EmptyError; +//# sourceMappingURL=EmptyError.js.map + +/***/ }), +/* 38 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = toCss; + +var _toCssValue = __webpack_require__(53); + +var _toCssValue2 = _interopRequireDefault(_toCssValue); + +var _isDynamicValue = __webpack_require__(54); + +var _isDynamicValue2 = _interopRequireDefault(_isDynamicValue); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +/** + * Indent a string. + * http://jsperf.com/array-join-vs-for + */ +function indentStr(str, indent) { + var result = ''; + for (var index = 0; index < indent; index++) { + result += ' '; + }return result + str; +} + +/** + * Converts a Rule to CSS string. + */ +function toCss(selector, style) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + var result = ''; + + if (!style) return result; + + var _options$indent = options.indent, + indent = _options$indent === undefined ? 0 : _options$indent; + var fallbacks = style.fallbacks; + + + indent++; + + // Apply fallbacks first. + if (fallbacks) { + // Array syntax {fallbacks: [{prop: value}]} + if (Array.isArray(fallbacks)) { + for (var index = 0; index < fallbacks.length; index++) { + var fallback = fallbacks[index]; + for (var prop in fallback) { + var value = fallback[prop]; + if (value != null) { + result += '\n' + indentStr(prop + ': ' + (0, _toCssValue2['default'])(value) + ';', indent); + } + } + } + } + // Object syntax {fallbacks: {prop: value}} + else { + for (var _prop in fallbacks) { + var _value = fallbacks[_prop]; + if (_value != null) { + result += '\n' + indentStr(_prop + ': ' + (0, _toCssValue2['default'])(_value) + ';', indent); + } + } + } + } + + var hasDynamicValue = false; + + for (var _prop2 in style) { + var _value2 = style[_prop2]; + if ((0, _isDynamicValue2['default'])(_value2)) { + _value2 = style['$' + _prop2]; + hasDynamicValue = true; + } + if (_value2 != null && _prop2 !== 'fallbacks') { + result += '\n' + indentStr(_prop2 + ': ' + (0, _toCssValue2['default'])(_value2) + ';', indent); + } + } + + if (!result && !hasDynamicValue) return result; + + indent--; + result = indentStr(selector + ' {' + result + '\n', indent) + indentStr('}', indent); + + return result; +} + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { - var _cloneStyle2 = _interopRequireDefault(_cloneStyle); +"use strict"; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - /** - * Create a rule instance. - */ - function createRule() { - var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unnamed'; - var decl = arguments[1]; - var options = arguments[2]; - var jss = options.jss; +Object.defineProperty(exports, "__esModule", { + value: true +}); - var declCopy = (0, _cloneStyle2['default'])(decl); +var _SheetsRegistry = __webpack_require__(51); - var rule = jss.plugins.onCreateRule(name, declCopy, options); - if (rule) return rule; +var _SheetsRegistry2 = _interopRequireDefault(_SheetsRegistry); - // It is an at-rule and it has no instance. - if (name[0] === '@') { - (0, _warning2['default'])(false, '[JSS] Unknown at-rule %s', name); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - return new _StyleRule2['default'](name, declCopy, options); - } +/** + * This is a global sheets registry. Only DomRenderer will add sheets to it. + * On the server one should use an own SheetsRegistry instance and add the + * sheets to it, because you need to make sure to create a new registry for + * each request in order to not leak sheets across requests. + */ +exports['default'] = new _SheetsRegistry2['default'](); -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _isInBrowser = __webpack_require__(42); + +var _isInBrowser2 = _interopRequireDefault(_isInBrowser); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var js = ''; /** + * Export javascript style and css style vendor prefixes. + * Based on "transform" support test. + */ + +var css = ''; + +// We should not do anything if required serverside. +if (_isInBrowser2['default']) { + // Order matters. We need to check Webkit the last one because + // other vendors use to add Webkit prefixes to some properties + var jsCssMap = { + Moz: '-moz-', + // IE did it wrong again ... + ms: '-ms-', + O: '-o-', + Webkit: '-webkit-' + }; + var style = document.createElement('p').style; + var testProp = 'Transform'; + + for (var key in jsCssMap) { + if (key + testProp in style) { + js = key; + css = jsCssMap[key]; + break; + } + } +} + +/** + * Vendor prefix string for the current browser. + * + * @type {{js: String, css: String}} + * @api public + */ +exports['default'] = { js: js, css: css }; + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +Object.defineProperty(exports, "__esModule", { + value: true +}); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - var _warning = __webpack_require__(7); +var isBrowser = exports.isBrowser = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && document.nodeType === 9; - var _warning2 = _interopRequireDefault(_warning); +exports.default = isBrowser; - var _toCss = __webpack_require__(12); +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var ScalarObservable = (function (_super) { + __extends(ScalarObservable, _super); + function ScalarObservable(value, scheduler) { + _super.call(this); + this.value = value; + this.scheduler = scheduler; + this._isScalar = true; + if (scheduler) { + this._isScalar = false; + } + } + ScalarObservable.create = function (value, scheduler) { + return new ScalarObservable(value, scheduler); + }; + ScalarObservable.dispatch = function (state) { + var done = state.done, value = state.value, subscriber = state.subscriber; + if (done) { + subscriber.complete(); + return; + } + subscriber.next(value); + if (subscriber.closed) { + return; + } + state.done = true; + this.schedule(state); + }; + ScalarObservable.prototype._subscribe = function (subscriber) { + var value = this.value; + var scheduler = this.scheduler; + if (scheduler) { + return scheduler.schedule(ScalarObservable.dispatch, 0, { + done: false, value: value, subscriber: subscriber + }); + } + else { + subscriber.next(value); + if (!subscriber.closed) { + subscriber.complete(); + } + } + }; + return ScalarObservable; +}(Observable_1.Observable)); +exports.ScalarObservable = ScalarObservable; +//# sourceMappingURL=ScalarObservable.js.map + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 ArrayObservable_1 = __webpack_require__(15); +var isArray_1 = __webpack_require__(13); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +var none = {}; +/* tslint:enable:max-line-length */ +/** + * Combines multiple Observables to create an Observable whose values are + * calculated from the latest values of each of its input Observables. + * + * Whenever any input Observable emits a value, it + * computes a formula using the latest values from all the inputs, then emits + * the output of that formula. + * + * + * + * `combineLatest` combines the values from this Observable with values from + * Observables passed as arguments. This is done by subscribing to each + * Observable, in order, and collecting an array of each of the most recent + * values any time any of the input Observables emits, then either taking that + * array and passing it as arguments to an optional `project` function and + * emitting the return value of that, or just emitting the array of recent + * values directly if there is no `project` function. + * + * @example Dynamically calculate the Body-Mass Index from an Observable of weight and one for height + * var weight = Rx.Observable.of(70, 72, 76, 79, 75); + * var height = Rx.Observable.of(1.76, 1.77, 1.78); + * var bmi = weight.combineLatest(height, (w, h) => w / (h * h)); + * bmi.subscribe(x => console.log('BMI is ' + x)); + * + * // With output to console: + * // BMI is 24.212293388429753 + * // BMI is 23.93948099205209 + * // BMI is 23.671253629592222 + * + * @see {@link combineAll} + * @see {@link merge} + * @see {@link withLatestFrom} + * + * @param {ObservableInput} other An input Observable to combine with the source + * Observable. More than one input Observables may be given as argument. + * @param {function} [project] An optional function to project the values from + * the combined latest values into a new value on the output Observable. + * @return {Observable} An Observable of projected values from the most recent + * values from each input Observable, or an array of the most recent values from + * each input Observable. + * @method combineLatest + * @owner Observable + */ +function combineLatest() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var project = null; + if (typeof observables[observables.length - 1] === 'function') { + project = observables.pop(); + } + // if the first and only other argument besides the resultSelector is an array + // assume it's been called with `combineLatest([obs1, obs2, obs3], project)` + if (observables.length === 1 && isArray_1.isArray(observables[0])) { + observables = observables[0].slice(); + } + observables.unshift(this); + return this.lift.call(new ArrayObservable_1.ArrayObservable(observables), new CombineLatestOperator(project)); +} +exports.combineLatest = combineLatest; +var CombineLatestOperator = (function () { + function CombineLatestOperator(project) { + this.project = project; + } + CombineLatestOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new CombineLatestSubscriber(subscriber, this.project)); + }; + return CombineLatestOperator; +}()); +exports.CombineLatestOperator = CombineLatestOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var CombineLatestSubscriber = (function (_super) { + __extends(CombineLatestSubscriber, _super); + function CombineLatestSubscriber(destination, project) { + _super.call(this, destination); + this.project = project; + this.active = 0; + this.values = []; + this.observables = []; + } + CombineLatestSubscriber.prototype._next = function (observable) { + this.values.push(none); + this.observables.push(observable); + }; + CombineLatestSubscriber.prototype._complete = function () { + var observables = this.observables; + var len = observables.length; + if (len === 0) { + this.destination.complete(); + } + else { + this.active = len; + this.toRespond = len; + for (var i = 0; i < len; i++) { + var observable = observables[i]; + this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i)); + } + } + }; + CombineLatestSubscriber.prototype.notifyComplete = function (unused) { + if ((this.active -= 1) === 0) { + this.destination.complete(); + } + }; + CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + var values = this.values; + var oldVal = values[outerIndex]; + var toRespond = !this.toRespond + ? 0 + : oldVal === none ? --this.toRespond : this.toRespond; + values[outerIndex] = innerValue; + if (toRespond === 0) { + if (this.project) { + this._tryProject(values); + } + else { + this.destination.next(values.slice()); + } + } + }; + CombineLatestSubscriber.prototype._tryProject = function (values) { + var result; + try { + result = this.project.apply(this, values); + } + catch (err) { + this.destination.error(err); + return; + } + this.destination.next(result); + }; + return CombineLatestSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.CombineLatestSubscriber = CombineLatestSubscriber; +//# sourceMappingURL=combineLatest.js.map + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var isScheduler_1 = __webpack_require__(14); +var ArrayObservable_1 = __webpack_require__(15); +var mergeAll_1 = __webpack_require__(33); +/* tslint:enable:max-line-length */ +/** + * Creates an output Observable which sequentially emits all values from every + * given input Observable after the current Observable. + * + * Concatenates multiple Observables together by + * sequentially emitting their values, one Observable after the other. + * + * + * + * Joins this Observable with multiple other Observables by subscribing to them + * one at a time, starting with the source, and merging their results into the + * output Observable. Will wait for each Observable to complete before moving + * on to the next. + * + * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 + * var timer = Rx.Observable.interval(1000).take(4); + * var sequence = Rx.Observable.range(1, 10); + * var result = timer.concat(sequence); + * result.subscribe(x => console.log(x)); + * + * // results in: + * // 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 + * + * @example Concatenate 3 Observables + * var timer1 = Rx.Observable.interval(1000).take(10); + * var timer2 = Rx.Observable.interval(2000).take(6); + * var timer3 = Rx.Observable.interval(500).take(10); + * var result = timer1.concat(timer2, timer3); + * result.subscribe(x => console.log(x)); + * + * // results in the following: + * // (Prints to console sequentially) + * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 + * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 + * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 + * + * @see {@link concatAll} + * @see {@link concatMap} + * @see {@link concatMapTo} + * + * @param {ObservableInput} other An input Observable to concatenate after the source + * Observable. More than one input Observables may be given as argument. + * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each + * Observable subscription on. + * @return {Observable} All values of each passed Observable merged into a + * single Observable, in order, in serial fashion. + * @method concat + * @owner Observable + */ +function concat() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + return this.lift.call(concatStatic.apply(void 0, [this].concat(observables))); +} +exports.concat = concat; +/* tslint:enable:max-line-length */ +/** + * Creates an output Observable which sequentially emits all values from given + * Observable and then moves on to the next. + * + * Concatenates multiple Observables together by + * sequentially emitting their values, one Observable after the other. + * + * + * + * `concat` joins multiple Observables together, by subscribing to them one at a time and + * merging their results into the output Observable. You can pass either an array of + * Observables, or put them directly as arguments. Passing an empty array will result + * in Observable that completes immediately. + * + * `concat` will subscribe to first input Observable and emit all its values, without + * changing or affecting them in any way. When that Observable completes, it will + * subscribe to then next Observable passed and, again, emit its values. This will be + * repeated, until the operator runs out of Observables. When last input Observable completes, + * `concat` will complete as well. At any given moment only one Observable passed to operator + * emits values. If you would like to emit values from passed Observables concurrently, check out + * {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact, + * `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`. + * + * Note that if some input Observable never completes, `concat` will also never complete + * and Observables following the one that did not complete will never be subscribed. On the other + * hand, if some Observable simply completes immediately after it is subscribed, it will be + * invisible for `concat`, which will just move on to the next Observable. + * + * If any Observable in chain errors, instead of passing control to the next Observable, + * `concat` will error immediately as well. Observables that would be subscribed after + * the one that emitted error, never will. + * + * If you pass to `concat` the same Observable many times, its stream of values + * will be "replayed" on every subscription, which means you can repeat given Observable + * as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious, + * you can always use {@link repeat}. + * + * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 + * var timer = Rx.Observable.interval(1000).take(4); + * var sequence = Rx.Observable.range(1, 10); + * var result = Rx.Observable.concat(timer, sequence); + * result.subscribe(x => console.log(x)); + * + * // results in: + * // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 + * + * + * @example Concatenate an array of 3 Observables + * var timer1 = Rx.Observable.interval(1000).take(10); + * var timer2 = Rx.Observable.interval(2000).take(6); + * var timer3 = Rx.Observable.interval(500).take(10); + * var result = Rx.Observable.concat([timer1, timer2, timer3]); // note that array is passed + * result.subscribe(x => console.log(x)); + * + * // results in the following: + * // (Prints to console sequentially) + * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 + * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 + * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 + * + * + * @example Concatenate the same Observable to repeat it + * const timer = Rx.Observable.interval(1000).take(2); + * + * Rx.Observable.concat(timer, timer) // concating the same Observable! + * .subscribe( + * value => console.log(value), + * err => {}, + * () => console.log('...and it is done!') + * ); + * + * // Logs: + * // 0 after 1s + * // 1 after 2s + * // 0 after 3s + * // 1 after 4s + * // "...and it is done!" also after 4s + * + * @see {@link concatAll} + * @see {@link concatMap} + * @see {@link concatMapTo} + * + * @param {ObservableInput} input1 An input Observable to concatenate with others. + * @param {ObservableInput} input2 An input Observable to concatenate with others. + * More than one input Observables may be given as argument. + * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each + * Observable subscription on. + * @return {Observable} All values of each passed Observable merged into a + * single Observable, in order, in serial fashion. + * @static true + * @name concat + * @owner Observable + */ +function concatStatic() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var scheduler = null; + var args = observables; + if (isScheduler_1.isScheduler(args[observables.length - 1])) { + scheduler = args.pop(); + } + if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) { + return observables[0]; + } + return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(1)); +} +exports.concatStatic = concatStatic; +//# sourceMappingURL=concat.js.map + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var Notification_1 = __webpack_require__(22); +/** + * + * Re-emits all notifications from source Observable with specified scheduler. + * + * Ensure a specific scheduler is used, from outside of an Observable. + * + * `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule + * notifications emitted by the source Observable. It might be useful, if you do not have control over + * internal scheduler of a given Observable, but want to control when its values are emitted nevertheless. + * + * Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable, + * but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal + * scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits + * notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`. + * An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split + * that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source + * Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a + * little bit more, to ensure that they are emitted at expected moments. + * + * As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications + * will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn` + * will delay all notifications - including error notifications - while `delay` will pass through error + * from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator + * for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used + * for notification emissions in general. + * + * @example Ensure values in subscribe are called just before browser repaint. + * const intervals = Rx.Observable.interval(10); // Intervals are scheduled + * // with async scheduler by default... + * + * intervals + * .observeOn(Rx.Scheduler.animationFrame) // ...but we will observe on animationFrame + * .subscribe(val => { // scheduler to ensure smooth animation. + * someDiv.style.height = val + 'px'; + * }); + * + * @see {@link delay} + * + * @param {IScheduler} scheduler Scheduler that will be used to reschedule notifications from source Observable. + * @param {number} [delay] Number of milliseconds that states with what delay every notification should be rescheduled. + * @return {Observable} Observable that emits the same notifications as the source Observable, + * but with provided scheduler. + * + * @method observeOn + * @owner Observable + */ +function observeOn(scheduler, delay) { + if (delay === void 0) { delay = 0; } + return this.lift(new ObserveOnOperator(scheduler, delay)); +} +exports.observeOn = observeOn; +var ObserveOnOperator = (function () { + function ObserveOnOperator(scheduler, delay) { + if (delay === void 0) { delay = 0; } + this.scheduler = scheduler; + this.delay = delay; + } + ObserveOnOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay)); + }; + return ObserveOnOperator; +}()); +exports.ObserveOnOperator = ObserveOnOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ObserveOnSubscriber = (function (_super) { + __extends(ObserveOnSubscriber, _super); + function ObserveOnSubscriber(destination, scheduler, delay) { + if (delay === void 0) { delay = 0; } + _super.call(this, destination); + this.scheduler = scheduler; + this.delay = delay; + } + ObserveOnSubscriber.dispatch = function (arg) { + var notification = arg.notification, destination = arg.destination; + notification.observe(destination); + this.unsubscribe(); + }; + ObserveOnSubscriber.prototype.scheduleMessage = function (notification) { + this.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination))); + }; + ObserveOnSubscriber.prototype._next = function (value) { + this.scheduleMessage(Notification_1.Notification.createNext(value)); + }; + ObserveOnSubscriber.prototype._error = function (err) { + this.scheduleMessage(Notification_1.Notification.createError(err)); + }; + ObserveOnSubscriber.prototype._complete = function () { + this.scheduleMessage(Notification_1.Notification.createComplete()); + }; + return ObserveOnSubscriber; +}(Subscriber_1.Subscriber)); +exports.ObserveOnSubscriber = ObserveOnSubscriber; +var ObserveOnMessage = (function () { + function ObserveOnMessage(notification, destination) { + this.notification = notification; + this.destination = destination; + } + return ObserveOnMessage; +}()); +exports.ObserveOnMessage = ObserveOnMessage; +//# sourceMappingURL=observeOn.js.map + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 ArrayObservable_1 = __webpack_require__(15); +var isArray_1 = __webpack_require__(13); +var Subscriber_1 = __webpack_require__(1); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +var iterator_1 = __webpack_require__(21); +/* tslint:enable:max-line-length */ +/** + * @param observables + * @return {Observable} + * @method zip + * @owner Observable + */ +function zipProto() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + return this.lift.call(zipStatic.apply(void 0, [this].concat(observables))); +} +exports.zipProto = zipProto; +/* tslint:enable:max-line-length */ +/** + * Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each + * of its input Observables. + * + * If the latest parameter is a function, this function is used to compute the created value from the input values. + * Otherwise, an array of the input values is returned. + * + * @example Combine age and name from different sources + * + * let age$ = Observable.of(27, 25, 29); + * let name$ = Observable.of('Foo', 'Bar', 'Beer'); + * let isDev$ = Observable.of(true, true, false); + * + * Observable + * .zip(age$, + * name$, + * isDev$, + * (age: number, name: string, isDev: boolean) => ({ age, name, isDev })) + * .subscribe(x => console.log(x)); + * + * // outputs + * // { age: 27, name: 'Foo', isDev: true } + * // { age: 25, name: 'Bar', isDev: true } + * // { age: 29, name: 'Beer', isDev: false } + * + * @param observables + * @return {Observable} + * @static true + * @name zip + * @owner Observable + */ +function zipStatic() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var project = observables[observables.length - 1]; + if (typeof project === 'function') { + observables.pop(); + } + return new ArrayObservable_1.ArrayObservable(observables).lift(new ZipOperator(project)); +} +exports.zipStatic = zipStatic; +var ZipOperator = (function () { + function ZipOperator(project) { + this.project = project; + } + ZipOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ZipSubscriber(subscriber, this.project)); + }; + return ZipOperator; +}()); +exports.ZipOperator = ZipOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ZipSubscriber = (function (_super) { + __extends(ZipSubscriber, _super); + function ZipSubscriber(destination, project, values) { + if (values === void 0) { values = Object.create(null); } + _super.call(this, destination); + this.iterators = []; + this.active = 0; + this.project = (typeof project === 'function') ? project : null; + this.values = values; + } + ZipSubscriber.prototype._next = function (value) { + var iterators = this.iterators; + if (isArray_1.isArray(value)) { + iterators.push(new StaticArrayIterator(value)); + } + else if (typeof value[iterator_1.iterator] === 'function') { + iterators.push(new StaticIterator(value[iterator_1.iterator]())); + } + else { + iterators.push(new ZipBufferIterator(this.destination, this, value)); + } + }; + ZipSubscriber.prototype._complete = function () { + var iterators = this.iterators; + var len = iterators.length; + if (len === 0) { + this.destination.complete(); + return; + } + this.active = len; + for (var i = 0; i < len; i++) { + var iterator = iterators[i]; + if (iterator.stillUnsubscribed) { + this.add(iterator.subscribe(iterator, i)); + } + else { + this.active--; // not an observable + } + } + }; + ZipSubscriber.prototype.notifyInactive = function () { + this.active--; + if (this.active === 0) { + this.destination.complete(); + } + }; + ZipSubscriber.prototype.checkIterators = function () { + var iterators = this.iterators; + var len = iterators.length; + var destination = this.destination; + // abort if not all of them have values + for (var i = 0; i < len; i++) { + var iterator = iterators[i]; + if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) { + return; + } + } + var shouldComplete = false; + var args = []; + for (var i = 0; i < len; i++) { + var iterator = iterators[i]; + var result = iterator.next(); + // check to see if it's completed now that you've gotten + // the next value. + if (iterator.hasCompleted()) { + shouldComplete = true; + } + if (result.done) { + destination.complete(); + return; + } + args.push(result.value); + } + if (this.project) { + this._tryProject(args); + } + else { + destination.next(args); + } + if (shouldComplete) { + destination.complete(); + } + }; + ZipSubscriber.prototype._tryProject = function (args) { + var result; + try { + result = this.project.apply(this, args); + } + catch (err) { + this.destination.error(err); + return; + } + this.destination.next(result); + }; + return ZipSubscriber; +}(Subscriber_1.Subscriber)); +exports.ZipSubscriber = ZipSubscriber; +var StaticIterator = (function () { + function StaticIterator(iterator) { + this.iterator = iterator; + this.nextResult = iterator.next(); + } + StaticIterator.prototype.hasValue = function () { + return true; + }; + StaticIterator.prototype.next = function () { + var result = this.nextResult; + this.nextResult = this.iterator.next(); + return result; + }; + StaticIterator.prototype.hasCompleted = function () { + var nextResult = this.nextResult; + return nextResult && nextResult.done; + }; + return StaticIterator; +}()); +var StaticArrayIterator = (function () { + function StaticArrayIterator(array) { + this.array = array; + this.index = 0; + this.length = 0; + this.length = array.length; + } + StaticArrayIterator.prototype[iterator_1.iterator] = function () { + return this; + }; + StaticArrayIterator.prototype.next = function (value) { + var i = this.index++; + var array = this.array; + return i < this.length ? { value: array[i], done: false } : { value: null, done: true }; + }; + StaticArrayIterator.prototype.hasValue = function () { + return this.array.length > this.index; + }; + StaticArrayIterator.prototype.hasCompleted = function () { + return this.array.length === this.index; + }; + return StaticArrayIterator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ZipBufferIterator = (function (_super) { + __extends(ZipBufferIterator, _super); + function ZipBufferIterator(destination, parent, observable) { + _super.call(this, destination); + this.parent = parent; + this.observable = observable; + this.stillUnsubscribed = true; + this.buffer = []; + this.isComplete = false; + } + ZipBufferIterator.prototype[iterator_1.iterator] = function () { + return this; + }; + // NOTE: there is actually a name collision here with Subscriber.next and Iterator.next + // this is legit because `next()` will never be called by a subscription in this case. + ZipBufferIterator.prototype.next = function () { + var buffer = this.buffer; + if (buffer.length === 0 && this.isComplete) { + return { value: null, done: true }; + } + else { + return { value: buffer.shift(), done: false }; + } + }; + ZipBufferIterator.prototype.hasValue = function () { + return this.buffer.length > 0; + }; + ZipBufferIterator.prototype.hasCompleted = function () { + return this.buffer.length === 0 && this.isComplete; + }; + ZipBufferIterator.prototype.notifyComplete = function () { + if (this.buffer.length > 0) { + this.isComplete = true; + this.parent.notifyInactive(); + } + else { + this.destination.complete(); + } + }; + ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.buffer.push(innerValue); + this.parent.checkIterators(); + }; + ZipBufferIterator.prototype.subscribe = function (value, index) { + return subscribeToResult_1.subscribeToResult(this, this.observable, this, index); + }; + return ZipBufferIterator; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=zip.js.map + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Applies a given `project` function to each value emitted by the source + * Observable, and emits the resulting values as an Observable. + * + * Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map), + * it passes each source value through a transformation function to get + * corresponding output values. + * + * + * + * Similar to the well known `Array.prototype.map` function, this operator + * applies a projection to each value and emits that projection in the output + * Observable. + * + * @example Map every click to the clientX position of that click + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var positions = clicks.map(ev => ev.clientX); + * positions.subscribe(x => console.log(x)); + * + * @see {@link mapTo} + * @see {@link pluck} + * + * @param {function(value: T, index: number): R} project The function to apply + * to each `value` emitted by the source Observable. The `index` parameter is + * the number `i` for the i-th emission that has happened since the + * subscription, starting from the number `0`. + * @param {any} [thisArg] An optional argument to define what `this` is in the + * `project` function. + * @return {Observable} An Observable that emits the values from the source + * Observable transformed by the given `project` function. + * @method map + * @owner Observable + */ +function map(project, thisArg) { + if (typeof project !== 'function') { + throw new TypeError('argument is not a function. Are you looking for `mapTo()`?'); + } + return this.lift(new MapOperator(project, thisArg)); +} +exports.map = map; +var MapOperator = (function () { + function MapOperator(project, thisArg) { + this.project = project; + this.thisArg = thisArg; + } + MapOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg)); + }; + return MapOperator; +}()); +exports.MapOperator = MapOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var MapSubscriber = (function (_super) { + __extends(MapSubscriber, _super); + function MapSubscriber(destination, project, thisArg) { + _super.call(this, destination); + this.project = project; + this.count = 0; + this.thisArg = thisArg || this; + } + // NOTE: This looks unoptimized, but it's actually purposefully NOT + // using try/catch optimizations. + MapSubscriber.prototype._next = function (value) { + var result; + try { + result = this.project.call(this.thisArg, value, this.count++); + } + catch (err) { + this.destination.error(err); + return; + } + this.destination.next(result); + }; + return MapSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=map.js.map + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/* tslint:enable:max-line-length */ +/** + * Applies an accumulator function over the source Observable, and returns the + * accumulated result when the source completes, given an optional seed value. + * + * Combines together all values emitted on the source, + * using an accumulator function that knows how to join a new source value into + * the accumulation from the past. + * + * + * + * Like + * [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce), + * `reduce` applies an `accumulator` function against an accumulation and each + * value of the source Observable (from the past) to reduce it to a single + * value, emitted on the output Observable. Note that `reduce` will only emit + * one value, only when the source Observable completes. It is equivalent to + * applying operator {@link scan} followed by operator {@link last}. + * + * Returns an Observable that applies a specified `accumulator` function to each + * item emitted by the source Observable. If a `seed` value is specified, then + * that value will be used as the initial value for the accumulator. If no seed + * value is specified, the first item of the source is used as the seed. + * + * @example Count the number of click events that happened in 5 seconds + * var clicksInFiveSeconds = Rx.Observable.fromEvent(document, 'click') + * .takeUntil(Rx.Observable.interval(5000)); + * var ones = clicksInFiveSeconds.mapTo(1); + * var seed = 0; + * var count = ones.reduce((acc, one) => acc + one, seed); + * count.subscribe(x => console.log(x)); + * + * @see {@link count} + * @see {@link expand} + * @see {@link mergeScan} + * @see {@link scan} + * + * @param {function(acc: R, value: T, index: number): R} accumulator The accumulator function + * called on each source value. + * @param {R} [seed] The initial accumulation value. + * @return {Observable} An Observable that emits a single value that is the + * result of accumulating the values emitted by the source Observable. + * @method reduce + * @owner Observable + */ +function reduce(accumulator, seed) { + var hasSeed = false; + // providing a seed of `undefined` *should* be valid and trigger + // hasSeed! so don't use `seed !== undefined` checks! + // For this reason, we have to check it here at the original call site + // otherwise inside Operator/Subscriber we won't know if `undefined` + // means they didn't provide anything or if they literally provided `undefined` + if (arguments.length >= 2) { + hasSeed = true; + } + return this.lift(new ReduceOperator(accumulator, seed, hasSeed)); +} +exports.reduce = reduce; +var ReduceOperator = (function () { + function ReduceOperator(accumulator, seed, hasSeed) { + if (hasSeed === void 0) { hasSeed = false; } + this.accumulator = accumulator; + this.seed = seed; + this.hasSeed = hasSeed; + } + ReduceOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ReduceSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed)); + }; + return ReduceOperator; +}()); +exports.ReduceOperator = ReduceOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ReduceSubscriber = (function (_super) { + __extends(ReduceSubscriber, _super); + function ReduceSubscriber(destination, accumulator, seed, hasSeed) { + _super.call(this, destination); + this.accumulator = accumulator; + this.hasSeed = hasSeed; + this.index = 0; + this.hasValue = false; + this.acc = seed; + if (!this.hasSeed) { + this.index++; + } + } + ReduceSubscriber.prototype._next = function (value) { + if (this.hasValue || (this.hasValue = this.hasSeed)) { + this._tryReduce(value); + } + else { + this.acc = value; + this.hasValue = true; + } + }; + ReduceSubscriber.prototype._tryReduce = function (value) { + var result; + try { + result = this.accumulator(this.acc, value, this.index++); + } + catch (err) { + this.destination.error(err); + return; + } + this.acc = result; + }; + ReduceSubscriber.prototype._complete = function () { + if (this.hasValue || this.hasSeed) { + this.destination.next(this.acc); + } + this.destination.complete(); + }; + return ReduceSubscriber; +}(Subscriber_1.Subscriber)); +exports.ReduceSubscriber = ReduceSubscriber; +//# sourceMappingURL=reduce.js.map + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { - var _toCss2 = _interopRequireDefault(_toCss); - - var _toCssValue = __webpack_require__(13); +"use strict"; - var _toCssValue2 = _interopRequireDefault(_toCssValue); - - var _isDynamicValue = __webpack_require__(14); - var _isDynamicValue2 = _interopRequireDefault(_isDynamicValue); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var StyleRule = function () { - function StyleRule(key, style, options) { - _classCallCheck(this, StyleRule); - - this.type = 'style'; - this.isProcessed = false; - var sheet = options.sheet, - Renderer = options.Renderer, - selector = options.selector; - - this.key = key; - this.options = options; - this.style = style; - if (selector) this.selectorText = selector; - this.renderer = sheet ? sheet.renderer : new Renderer(); - } - - /** - * Set selector string. - * Attention: use this with caution. Most browsers didn't implement - * selectorText setter, so this may result in rerendering of entire Style Sheet. - */ - - - _createClass(StyleRule, [{ - key: 'prop', - - - /** - * Get or set a style property. - */ - value: function prop(name, nextValue) { - // The result of a dynamic value is prefixed with $ and is not innumerable in - // order to be ignored by all plugins or during stringification. - var $name = (0, _isDynamicValue2['default'])(this.style[name]) ? '$' + name : name; - - // Its a setter. - if (nextValue != null) { - // Don't do anything if the value has not changed. - if (this.style[$name] !== nextValue) { - nextValue = this.options.jss.plugins.onChangeValue(nextValue, name, this); - Object.defineProperty(this.style, $name, { - value: nextValue, - writable: true - }); - // Renderable is defined if StyleSheet option `link` is true. - if (this.renderable) this.renderer.setStyle(this.renderable, name, nextValue);else { - var sheet = this.options.sheet; - - if (sheet && sheet.attached) { - (0, _warning2['default'])(false, 'Rule is not linked. Missing sheet option "link: true".'); - } - } - } - return this; - } - - return this.style[$name]; - } - - /** - * Apply rule to an element inline. - */ - - }, { - key: 'applyTo', - value: function applyTo(renderable) { - var json = this.toJSON(); - for (var prop in json) { - this.renderer.setStyle(renderable, prop, json[prop]); - }return this; - } - - /** - * Returns JSON representation of the rule. - * Fallbacks are not supported. - * Useful for inline styles. - */ - - }, { - key: 'toJSON', - value: function toJSON() { - var json = {}; - for (var prop in this.style) { - var value = this.style[prop]; - if ((0, _isDynamicValue2['default'])(value)) json[prop] = this.style['$' + prop];else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object') json[prop] = value;else if (Array.isArray(value)) json[prop] = (0, _toCssValue2['default'])(value); - } - return json; - } - - /** - * Generates a CSS string. - */ - - }, { - key: 'toString', - value: function toString(options) { - return (0, _toCss2['default'])(this.selector, this.style, options); - } - }, { - key: 'selector', - set: function set(selector) { - if (selector === this.selectorText) return; - - this.selectorText = selector; - - if (this.renderable) { - var hasChanged = this.renderer.setSelector(this.renderable, selector); - - // If selector setter is not implemented, rerender the rule. - if (!hasChanged && this.renderable) { - var renderable = this.renderer.replaceRule(this.renderable, this); - if (renderable) this.renderable = renderable; - } - } - } - - /** - * Get selector string. - */ - , - get: function get() { - return this.selectorText; - } - }]); - - return StyleRule; - }(); - - exports['default'] = StyleRule; - -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.create = exports.createGenerateClassName = exports.sheets = exports.RuleList = exports.SheetsManager = exports.SheetsRegistry = exports.getDynamicStyles = undefined; - 'use strict'; +var _getDynamicStyles = __webpack_require__(92); - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = toCss; +Object.defineProperty(exports, 'getDynamicStyles', { + enumerable: true, + get: function get() { + return _interopRequireDefault(_getDynamicStyles)['default']; + } +}); - var _toCssValue = __webpack_require__(13); +var _SheetsRegistry = __webpack_require__(51); - var _toCssValue2 = _interopRequireDefault(_toCssValue); +Object.defineProperty(exports, 'SheetsRegistry', { + enumerable: true, + get: function get() { + return _interopRequireDefault(_SheetsRegistry)['default']; + } +}); - var _isDynamicValue = __webpack_require__(14); +var _SheetsManager = __webpack_require__(93); - var _isDynamicValue2 = _interopRequireDefault(_isDynamicValue); +Object.defineProperty(exports, 'SheetsManager', { + enumerable: true, + get: function get() { + return _interopRequireDefault(_SheetsManager)['default']; + } +}); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _RuleList = __webpack_require__(26); - /** - * Indent a string. - * http://jsperf.com/array-join-vs-for - */ - function indentStr(str, indent) { - var result = ''; - for (var index = 0; index < indent; index++) { - result += ' '; - }return result + str; - } +Object.defineProperty(exports, 'RuleList', { + enumerable: true, + get: function get() { + return _interopRequireDefault(_RuleList)['default']; + } +}); - /** - * Converts a Rule to CSS string. - */ - function toCss(selector, style) { - var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - var result = ''; - - if (!style) return result; - - var _options$indent = options.indent, - indent = _options$indent === undefined ? 0 : _options$indent; - var fallbacks = style.fallbacks; - - - indent++; - - // Apply fallbacks first. - if (fallbacks) { - // Array syntax {fallbacks: [{prop: value}]} - if (Array.isArray(fallbacks)) { - for (var index = 0; index < fallbacks.length; index++) { - var fallback = fallbacks[index]; - for (var prop in fallback) { - var value = fallback[prop]; - if (value != null) { - result += '\n' + indentStr(prop + ': ' + (0, _toCssValue2['default'])(value) + ';', indent); - } - } - } - } - // Object syntax {fallbacks: {prop: value}} - else { - for (var _prop in fallbacks) { - var _value = fallbacks[_prop]; - if (_value != null) { - result += '\n' + indentStr(_prop + ': ' + (0, _toCssValue2['default'])(_value) + ';', indent); - } - } - } - } - - var hasDynamicValue = false; - - for (var _prop2 in style) { - var _value2 = style[_prop2]; - if ((0, _isDynamicValue2['default'])(_value2)) { - _value2 = style['$' + _prop2]; - hasDynamicValue = true; - } - if (_value2 != null && _prop2 !== 'fallbacks') { - result += '\n' + indentStr(_prop2 + ': ' + (0, _toCssValue2['default'])(_value2) + ';', indent); - } - } - - if (!result && !hasDynamicValue) return result; - - indent--; - result = indentStr(selector + ' {' + result + '\n', indent) + indentStr('}', indent); - - return result; - } +var _sheets = __webpack_require__(40); -/***/ }, -/* 13 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = toCssValue; - var joinWithSpace = function joinWithSpace(value) { - return value.join(' '); - }; - - /** - * Converts array values to string. - * - * `margin: [['5px', '10px']]` > `margin: 5px 10px;` - * `border: ['1px', '2px']` > `border: 1px, 2px;` - */ - function toCssValue(value) { - if (!Array.isArray(value)) return value; - - // Support space separated values. - if (Array.isArray(value[0])) { - return toCssValue(value.map(joinWithSpace)); - } - - return value.join(', '); - } +Object.defineProperty(exports, 'sheets', { + enumerable: true, + get: function get() { + return _interopRequireDefault(_sheets)['default']; + } +}); -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { +var _createGenerateClassName = __webpack_require__(56); - 'use strict'; +Object.defineProperty(exports, 'createGenerateClassName', { + enumerable: true, + get: function get() { + return _interopRequireDefault(_createGenerateClassName)['default']; + } +}); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _Jss = __webpack_require__(98); - var _isObservable = __webpack_require__(15); +var _Jss2 = _interopRequireDefault(_Jss); - var _isObservable2 = _interopRequireDefault(_isObservable); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +/** + * Creates a new instance of Jss. + */ +var create = exports.create = function create(options) { + return new _Jss2['default'](options); +}; - exports['default'] = function (value) { - return typeof value === 'function' || (0, _isObservable2['default'])(value); - }; +/** + * A global Jss instance. + */ +exports['default'] = create(); -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; - var symbolObservable = __webpack_require__(16); +"use strict"; - module.exports = function (fn) { - return Boolean(fn && fn[symbolObservable]); - }; +Object.defineProperty(exports, "__esModule", { + value: true +}); -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - /* WEBPACK VAR INJECTION */(function(global) {/* global window */ - 'use strict'; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - module.exports = __webpack_require__(17)(global || window || this); +/** + * Sheets registry to access them all at one place. + */ +var SheetsRegistry = function () { + function SheetsRegistry() { + _classCallCheck(this, SheetsRegistry); - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + this.registry = []; + } -/***/ }, -/* 17 */ -/***/ function(module, exports) { + _createClass(SheetsRegistry, [{ + key: 'add', - 'use strict'; - module.exports = function symbolObservablePonyfill(root) { - var result; - var Symbol = root.Symbol; + /** + * Register a Style Sheet. + */ + value: function add(sheet) { + var registry = this.registry; + var index = sheet.options.index; - if (typeof Symbol === 'function') { - if (Symbol.observable) { - result = Symbol.observable; - } else { - result = Symbol('observable'); - Symbol.observable = result; - } - } else { - result = '@@observable'; - } - return result; - }; + if (registry.indexOf(sheet) !== -1) return; + if (registry.length === 0 || index >= this.index) { + registry.push(sheet); + return; + } -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { + // Find a position. + for (var i = 0; i < registry.length; i++) { + if (registry[i].options.index > index) { + registry.splice(i, 0, sheet); + return; + } + } + } - 'use strict'; + /** + * Reset the registry. + */ - Object.defineProperty(exports, "__esModule", { - value: true - }); + }, { + key: 'reset', + value: function reset() { + this.registry = []; + } - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + /** + * Remove a Style Sheet. + */ - exports['default'] = cloneStyle; + }, { + key: 'remove', + value: function remove(sheet) { + var index = this.registry.indexOf(sheet); + this.registry.splice(index, 1); + } - var _isObservable = __webpack_require__(15); + /** + * Convert all attached sheets to a CSS string. + */ - var _isObservable2 = _interopRequireDefault(_isObservable); + }, { + key: 'toString', + value: function toString(options) { + return this.registry.filter(function (sheet) { + return sheet.attached; + }).map(function (sheet) { + return sheet.toString(options); + }).join('\n'); + } + }, { + key: 'index', - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var isArray = Array.isArray; - function cloneStyle(style) { - // Support empty values in case user ends up with them by accident. - if (style == null) return style; + /** + * Current highest index number. + */ + get: function get() { + return this.registry.length === 0 ? 0 : this.registry[this.registry.length - 1].options.index; + } + }]); - // Support string value for SimpleRule. - var typeOfStyle = typeof style === 'undefined' ? 'undefined' : _typeof(style); - if (typeOfStyle === 'string' || typeOfStyle === 'number') return style; + return SheetsRegistry; +}(); - // Support array for FontFaceRule. - if (isArray(style)) return style.map(cloneStyle); +exports['default'] = SheetsRegistry; - var newStyle = {}; - for (var name in style) { - var value = style[name]; - if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !(0, _isObservable2['default'])(value)) { - newStyle[name] = cloneStyle(value); - continue; - } - newStyle[name] = value; - } +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { - return newStyle; - } +"use strict"; -/***/ }, -/* 19 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - exports['default'] = function (rule, data, RuleList) { - if (rule.type === 'style') { - for (var prop in rule.style) { - var value = rule.style[prop]; - if (typeof value === 'function') { - rule.prop(prop, value(data)); - } - } - } else if (rule.rules instanceof RuleList) { - rule.rules.update(data); - } - }; - -/***/ }, -/* 20 */ -/***/ function(module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports["default"] = linkRule; - /** - * Link rule with CSSStyleRule and nested rules with corresponding nested cssRules if both exists. - */ - function linkRule(rule, cssRule) { - rule.renderable = cssRule; - if (rule.rules && cssRule.cssRules) rule.rules.link(cssRule.cssRules); - } -/***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = createRule; - 'use strict'; +var _warning = __webpack_require__(11); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _warning2 = _interopRequireDefault(_warning); - var _SheetsRegistry = __webpack_require__(5); +var _StyleRule = __webpack_require__(19); - var _SheetsRegistry2 = _interopRequireDefault(_SheetsRegistry); +var _StyleRule2 = _interopRequireDefault(_StyleRule); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _cloneStyle = __webpack_require__(96); - /** - * This is a global sheets registry. Only DomRenderer will add sheets to it. - * On the server one should use an own SheetsRegistry instance and add the - * sheets to it, because you need to make sure to create a new registry for - * each request in order to not leak sheets across requests. - */ - exports['default'] = new _SheetsRegistry2['default'](); +var _cloneStyle2 = _interopRequireDefault(_cloneStyle); -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - /* WEBPACK VAR INJECTION */(function(global, process) {'use strict'; +/** + * Create a rule instance. + */ +function createRule() { + var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unnamed'; + var decl = arguments[1]; + var options = arguments[2]; + var jss = options.jss; - Object.defineProperty(exports, "__esModule", { - value: true - }); + var declCopy = (0, _cloneStyle2['default'])(decl); - var _warning = __webpack_require__(7); + var rule = jss.plugins.onCreateRule(name, declCopy, options); + if (rule) return rule; - var _warning2 = _interopRequireDefault(_warning); + // It is an at-rule and it has no instance. + if (name[0] === '@') { + (0, _warning2['default'])(false, '[JSS] Unknown at-rule %s', name); + } - var _StyleSheet = __webpack_require__(23); + return new _StyleRule2['default'](name, declCopy, options); +} - var _StyleSheet2 = _interopRequireDefault(_StyleSheet); +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +"use strict"; - var globalRef = typeof window === 'undefined' ? global : window; - var ns = '2f1acc6c3a606b082e5eef5e54414ffb'; - if (globalRef[ns] == null) globalRef[ns] = 0; - // In case we have more than one JSS version. - var jssCounter = globalRef[ns]++; - var maxRules = 1e10; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = toCssValue; +var joinWithSpace = function joinWithSpace(value) { + return value.join(' '); +}; - var env = process.env.NODE_ENV; +/** + * Converts array values to string. + * + * `margin: [['5px', '10px']]` > `margin: 5px 10px;` + * `border: ['1px', '2px']` > `border: 1px, 2px;` + */ +function toCssValue(value) { + if (!Array.isArray(value)) return value; - /** - * Returns a function which generates unique class names based on counters. - * When new generator function is created, rule counter is reseted. - * We need to reset the rule counter for SSR for each request. - */ + // Support space separated values. + if (Array.isArray(value[0])) { + return toCssValue(value.map(joinWithSpace)); + } - exports['default'] = function () { - var ruleCounter = 0; + return value.join(', '); +} - return function (rule, sheet) { - ruleCounter += 1; +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { - if (ruleCounter > maxRules) { - (0, _warning2['default'])(false, 'You might have a memory leak. Rule counter is at %s.', ruleCounter); - } +"use strict"; - if (env === 'production') { - return 'c' + jssCounter + ruleCounter; - } - var prefix = sheet ? sheet.options.classNamePrefix || '' : ''; +Object.defineProperty(exports, "__esModule", { + value: true +}); - return '' + prefix + rule.key + '-' + jssCounter + '-' + ruleCounter; - }; - }; - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(8))) +var _isObservable = __webpack_require__(18); -/***/ }, -/* 23 */ -/***/ function(module, exports, __webpack_require__) { +var _isObservable2 = _interopRequireDefault(_isObservable); - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _linkRule = __webpack_require__(20); - - var _linkRule2 = _interopRequireDefault(_linkRule); - - var _RuleList = __webpack_require__(9); - - var _RuleList2 = _interopRequireDefault(_RuleList); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var StyleSheet = function () { - function StyleSheet(styles, options) { - _classCallCheck(this, StyleSheet); - - this.attached = false; - this.deployed = false; - this.linked = false; - this.classes = {}; - this.options = _extends({}, options, { - sheet: this, - parent: this, - classes: this.classes - }); - this.renderer = new options.Renderer(this); - this.rules = new _RuleList2['default'](this.options); - - for (var name in styles) { - this.rules.add(name, styles[name]); - } - - this.rules.process(); - } - - /** - * Attach renderable to the render tree. - */ - - - _createClass(StyleSheet, [{ - key: 'attach', - value: function attach() { - if (this.attached) return this; - if (!this.deployed) this.deploy(); - this.renderer.attach(); - if (!this.linked && this.options.link) this.link(); - this.attached = true; - return this; - } - - /** - * Remove renderable from render tree. - */ - - }, { - key: 'detach', - value: function detach() { - if (!this.attached) return this; - this.renderer.detach(); - this.attached = false; - return this; - } - - /** - * Add a rule to the current stylesheet. - * Will insert a rule also after the stylesheet has been rendered first time. - */ - - }, { - key: 'addRule', - value: function addRule(name, decl, options) { - var queue = this.queue; - - // Plugins can create rules. - // In order to preserve the right order, we need to queue all `.addRule` calls, - // which happen after the first `rules.add()` call. - - if (this.attached && !queue) this.queue = []; - - var rule = this.rules.add(name, decl, options); - this.options.jss.plugins.onProcessRule(rule); - - if (this.attached) { - if (!this.deployed) return rule; - // Don't insert rule directly if there is no stringified version yet. - // It will be inserted all together when .attach is called. - if (queue) queue.push(rule);else { - this.insertRule(rule); - if (this.queue) { - this.queue.forEach(this.insertRule, this); - this.queue = undefined; - } - } - return rule; - } - - // We can't add rules to a detached style node. - // We will redeploy the sheet once user will attach it. - this.deployed = false; - - return rule; - } - - /** - * Insert rule into the StyleSheet - */ - - }, { - key: 'insertRule', - value: function insertRule(rule) { - var renderable = this.renderer.insertRule(rule); - if (renderable && this.options.link) (0, _linkRule2['default'])(rule, renderable); - } - - /** - * Create and add rules. - * Will render also after Style Sheet was rendered the first time. - */ - - }, { - key: 'addRules', - value: function addRules(styles, options) { - var added = []; - for (var name in styles) { - added.push(this.addRule(name, styles[name], options)); - } - return added; - } - - /** - * Get a rule by name. - */ - - }, { - key: 'getRule', - value: function getRule(name) { - return this.rules.get(name); - } - - /** - * Delete a rule by name. - * Returns `true`: if rule has been deleted from the DOM. - */ - - }, { - key: 'deleteRule', - value: function deleteRule(name) { - var rule = this.rules.get(name); - - if (!rule) return false; - - this.rules.remove(rule); - - if (this.attached && rule.renderable) { - return this.renderer.deleteRule(rule.renderable); - } - - return true; - } - - /** - * Get index of a rule. - */ - - }, { - key: 'indexOf', - value: function indexOf(rule) { - return this.rules.indexOf(rule); - } - - /** - * Deploy pure CSS string to a renderable. - */ - - }, { - key: 'deploy', - value: function deploy() { - this.renderer.deploy(); - this.deployed = true; - return this; - } - - /** - * Link renderable CSS rules from sheet with their corresponding models. - */ - - }, { - key: 'link', - value: function link() { - var cssRules = this.renderer.getRules(); - - // Is undefined when VirtualRenderer is used. - if (cssRules) this.rules.link(cssRules); - this.linked = true; - return this; - } - - /** - * Update the function values with a new data. - */ - - }, { - key: 'update', - value: function update(name, data) { - this.rules.update(name, data); - return this; - } - - /** - * Convert rules to a CSS string. - */ - - }, { - key: 'toString', - value: function toString(options) { - return this.rules.toString(options); - } - }]); - - return StyleSheet; - }(); - - exports['default'] = StyleSheet; - -/***/ }, -/* 24 */ -/***/ function(module, exports, __webpack_require__) { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - 'use strict'; +exports['default'] = function (value) { + return typeof value === 'function' || (0, _isObservable2['default'])(value); +}; - Object.defineProperty(exports, "__esModule", { - value: true - }); +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +"use strict"; - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = linkRule; +/** + * Link rule with CSSStyleRule and nested rules with corresponding nested cssRules if both exists. + */ +function linkRule(rule, cssRule) { + rule.renderable = cssRule; + if (rule.rules && cssRule.cssRules) rule.rules.link(cssRule.cssRules); +} - var _isInBrowser = __webpack_require__(25); +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { - var _isInBrowser2 = _interopRequireDefault(_isInBrowser); +"use strict"; +/* WEBPACK VAR INJECTION */(function(global, process) { - var _StyleSheet = __webpack_require__(23); +Object.defineProperty(exports, "__esModule", { + value: true +}); - var _StyleSheet2 = _interopRequireDefault(_StyleSheet); +var _warning = __webpack_require__(11); - var _PluginsRegistry = __webpack_require__(26); +var _warning2 = _interopRequireDefault(_warning); - var _PluginsRegistry2 = _interopRequireDefault(_PluginsRegistry); +var _StyleSheet = __webpack_require__(57); - var _rules = __webpack_require__(27); +var _StyleSheet2 = _interopRequireDefault(_StyleSheet); - var _rules2 = _interopRequireDefault(_rules); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _observables = __webpack_require__(33); +var globalRef = typeof window === 'undefined' ? global : window; +var ns = '2f1acc6c3a606b082e5eef5e54414ffb'; +if (globalRef[ns] == null) globalRef[ns] = 0; +// In case we have more than one JSS version. +var jssCounter = globalRef[ns]++; - var _observables2 = _interopRequireDefault(_observables); +var maxRules = 1e10; - var _sheets = __webpack_require__(21); +var env = process.env.NODE_ENV; - var _sheets2 = _interopRequireDefault(_sheets); +/** + * Returns a function which generates unique class names based on counters. + * When new generator function is created, rule counter is reseted. + * We need to reset the rule counter for SSR for each request. + */ - var _StyleRule = __webpack_require__(11); +exports['default'] = function () { + var ruleCounter = 0; - var _StyleRule2 = _interopRequireDefault(_StyleRule); + return function (rule, sheet) { + ruleCounter += 1; - var _createGenerateClassName = __webpack_require__(22); + if (ruleCounter > maxRules) { + (0, _warning2['default'])(false, 'You might have a memory leak. Rule counter is at %s.', ruleCounter); + } - var _createGenerateClassName2 = _interopRequireDefault(_createGenerateClassName); + if (env === 'production') { + return 'c' + jssCounter + ruleCounter; + } - var _createRule2 = __webpack_require__(10); + var prefix = sheet ? sheet.options.classNamePrefix || '' : ''; - var _createRule3 = _interopRequireDefault(_createRule2); + return '' + prefix + rule.key + '-' + jssCounter + '-' + ruleCounter; + }; +}; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(27), __webpack_require__(38))) - var _DomRenderer = __webpack_require__(34); +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { - var _DomRenderer2 = _interopRequireDefault(_DomRenderer); +"use strict"; - var _VirtualRenderer = __webpack_require__(35); - var _VirtualRenderer2 = _interopRequireDefault(_VirtualRenderer); +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _linkRule = __webpack_require__(55); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +var _linkRule2 = _interopRequireDefault(_linkRule); - var defaultPlugins = _rules2['default'].concat([_observables2['default']]); +var _RuleList = __webpack_require__(26); - var Jss = function () { - function Jss(options) { - _classCallCheck(this, Jss); +var _RuleList2 = _interopRequireDefault(_RuleList); - this.version = "9.0.0"; - this.plugins = new _PluginsRegistry2['default'](); - this.options = { - createGenerateClassName: _createGenerateClassName2['default'], - Renderer: _isInBrowser2['default'] ? _DomRenderer2['default'] : _VirtualRenderer2['default'], - plugins: [] - }; - this.generateClassName = (0, _createGenerateClassName2['default'])(); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - // eslint-disable-next-line prefer-spread - this.use.apply(this, defaultPlugins); - this.setup(options); - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var StyleSheet = function () { + function StyleSheet(styles, options) { + _classCallCheck(this, StyleSheet); + + this.attached = false; + this.deployed = false; + this.linked = false; + this.classes = {}; + this.options = _extends({}, options, { + sheet: this, + parent: this, + classes: this.classes + }); + this.renderer = new options.Renderer(this); + this.rules = new _RuleList2['default'](this.options); + + for (var name in styles) { + this.rules.add(name, styles[name]); + } + + this.rules.process(); + } + + /** + * Attach renderable to the render tree. + */ + + + _createClass(StyleSheet, [{ + key: 'attach', + value: function attach() { + if (this.attached) return this; + if (!this.deployed) this.deploy(); + this.renderer.attach(); + if (!this.linked && this.options.link) this.link(); + this.attached = true; + return this; + } + + /** + * Remove renderable from render tree. + */ + + }, { + key: 'detach', + value: function detach() { + if (!this.attached) return this; + this.renderer.detach(); + this.attached = false; + return this; + } + + /** + * Add a rule to the current stylesheet. + * Will insert a rule also after the stylesheet has been rendered first time. + */ + + }, { + key: 'addRule', + value: function addRule(name, decl, options) { + var queue = this.queue; + + // Plugins can create rules. + // In order to preserve the right order, we need to queue all `.addRule` calls, + // which happen after the first `rules.add()` call. + + if (this.attached && !queue) this.queue = []; + + var rule = this.rules.add(name, decl, options); + this.options.jss.plugins.onProcessRule(rule); + + if (this.attached) { + if (!this.deployed) return rule; + // Don't insert rule directly if there is no stringified version yet. + // It will be inserted all together when .attach is called. + if (queue) queue.push(rule);else { + this.insertRule(rule); + if (this.queue) { + this.queue.forEach(this.insertRule, this); + this.queue = undefined; + } + } + return rule; + } + + // We can't add rules to a detached style node. + // We will redeploy the sheet once user will attach it. + this.deployed = false; + + return rule; + } + + /** + * Insert rule into the StyleSheet + */ + + }, { + key: 'insertRule', + value: function insertRule(rule) { + var renderable = this.renderer.insertRule(rule); + if (renderable && this.options.link) (0, _linkRule2['default'])(rule, renderable); + } + + /** + * Create and add rules. + * Will render also after Style Sheet was rendered the first time. + */ + + }, { + key: 'addRules', + value: function addRules(styles, options) { + var added = []; + for (var name in styles) { + added.push(this.addRule(name, styles[name], options)); + } + return added; + } + + /** + * Get a rule by name. + */ + + }, { + key: 'getRule', + value: function getRule(name) { + return this.rules.get(name); + } + + /** + * Delete a rule by name. + * Returns `true`: if rule has been deleted from the DOM. + */ + + }, { + key: 'deleteRule', + value: function deleteRule(name) { + var rule = this.rules.get(name); + + if (!rule) return false; + + this.rules.remove(rule); + + if (this.attached && rule.renderable) { + return this.renderer.deleteRule(rule.renderable); + } + + return true; + } + + /** + * Get index of a rule. + */ + + }, { + key: 'indexOf', + value: function indexOf(rule) { + return this.rules.indexOf(rule); + } + + /** + * Deploy pure CSS string to a renderable. + */ + + }, { + key: 'deploy', + value: function deploy() { + this.renderer.deploy(); + this.deployed = true; + return this; + } + + /** + * Link renderable CSS rules from sheet with their corresponding models. + */ + + }, { + key: 'link', + value: function link() { + var cssRules = this.renderer.getRules(); + + // Is undefined when VirtualRenderer is used. + if (cssRules) this.rules.link(cssRules); + this.linked = true; + return this; + } + + /** + * Update the function values with a new data. + */ + + }, { + key: 'update', + value: function update(name, data) { + this.rules.update(name, data); + return this; + } + + /** + * Convert rules to a CSS string. + */ + + }, { + key: 'toString', + value: function toString(options) { + return this.rules.toString(options); + } + }]); + + return StyleSheet; +}(); + +exports['default'] = StyleSheet; + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +/* tslint:disable:no-unused-variable */ +// Subject imported before Observable to bypass circular dependency issue since +// Subject extends Observable and Observable references Subject in it's +// definition +var Subject_1 = __webpack_require__(5); +exports.Subject = Subject_1.Subject; +exports.AnonymousSubject = Subject_1.AnonymousSubject; +/* tslint:enable:no-unused-variable */ +var Observable_1 = __webpack_require__(0); +exports.Observable = Observable_1.Observable; +// statics +/* tslint:disable:no-use-before-declare */ +__webpack_require__(133); +__webpack_require__(136); +__webpack_require__(139); +__webpack_require__(142); +__webpack_require__(144); +__webpack_require__(147); +__webpack_require__(149); +__webpack_require__(152); +__webpack_require__(156); +__webpack_require__(159); +__webpack_require__(162); +__webpack_require__(164); +__webpack_require__(167); +__webpack_require__(170); +__webpack_require__(175); +__webpack_require__(177); +__webpack_require__(179); +__webpack_require__(182); +__webpack_require__(184); +__webpack_require__(186); +__webpack_require__(189); +__webpack_require__(192); +__webpack_require__(195); +__webpack_require__(198); +__webpack_require__(201); +//dom +__webpack_require__(203); +__webpack_require__(205); +//operators +__webpack_require__(211); +__webpack_require__(213); +__webpack_require__(215); +__webpack_require__(217); +__webpack_require__(219); +__webpack_require__(221); +__webpack_require__(223); +__webpack_require__(225); +__webpack_require__(226); +__webpack_require__(227); +__webpack_require__(229); +__webpack_require__(231); +__webpack_require__(233); +__webpack_require__(235); +__webpack_require__(237); +__webpack_require__(239); +__webpack_require__(241); +__webpack_require__(243); +__webpack_require__(245); +__webpack_require__(247); +__webpack_require__(250); +__webpack_require__(251); +__webpack_require__(253); +__webpack_require__(255); +__webpack_require__(257); +__webpack_require__(259); +__webpack_require__(261); +__webpack_require__(263); +__webpack_require__(264); +__webpack_require__(266); +__webpack_require__(267); +__webpack_require__(269); +__webpack_require__(271); +__webpack_require__(276); +__webpack_require__(278); +__webpack_require__(280); +__webpack_require__(282); +__webpack_require__(284); +__webpack_require__(286); +__webpack_require__(288); +__webpack_require__(290); +__webpack_require__(291); +__webpack_require__(293); +__webpack_require__(295); +__webpack_require__(297); +__webpack_require__(298); +__webpack_require__(299); +__webpack_require__(300); +__webpack_require__(301); +__webpack_require__(303); +__webpack_require__(305); +__webpack_require__(306); +__webpack_require__(307); +__webpack_require__(308); +__webpack_require__(310); +__webpack_require__(313); +__webpack_require__(315); +__webpack_require__(317); +__webpack_require__(319); +__webpack_require__(321); +__webpack_require__(323); +__webpack_require__(324); +__webpack_require__(325); +__webpack_require__(327); +__webpack_require__(329); +__webpack_require__(331); +__webpack_require__(333); +__webpack_require__(335); +__webpack_require__(337); +__webpack_require__(339); +__webpack_require__(341); +__webpack_require__(343); +__webpack_require__(345); +__webpack_require__(347); +__webpack_require__(349); +__webpack_require__(351); +__webpack_require__(353); +__webpack_require__(355); +__webpack_require__(357); +__webpack_require__(364); +__webpack_require__(366); +__webpack_require__(368); +__webpack_require__(370); +__webpack_require__(372); +__webpack_require__(374); +__webpack_require__(376); +__webpack_require__(378); +__webpack_require__(379); +__webpack_require__(381); +__webpack_require__(382); +__webpack_require__(384); +__webpack_require__(386); +__webpack_require__(387); +__webpack_require__(389); +__webpack_require__(391); +__webpack_require__(393); +__webpack_require__(395); +__webpack_require__(397); +__webpack_require__(399); +__webpack_require__(401); +__webpack_require__(403); +__webpack_require__(404); +/* tslint:disable:no-unused-variable */ +var Subscription_1 = __webpack_require__(4); +exports.Subscription = Subscription_1.Subscription; +var Subscriber_1 = __webpack_require__(1); +exports.Subscriber = Subscriber_1.Subscriber; +var AsyncSubject_1 = __webpack_require__(32); +exports.AsyncSubject = AsyncSubject_1.AsyncSubject; +var ReplaySubject_1 = __webpack_require__(36); +exports.ReplaySubject = ReplaySubject_1.ReplaySubject; +var BehaviorSubject_1 = __webpack_require__(79); +exports.BehaviorSubject = BehaviorSubject_1.BehaviorSubject; +var ConnectableObservable_1 = __webpack_require__(78); +exports.ConnectableObservable = ConnectableObservable_1.ConnectableObservable; +var Notification_1 = __webpack_require__(22); +exports.Notification = Notification_1.Notification; +var EmptyError_1 = __webpack_require__(37); +exports.EmptyError = EmptyError_1.EmptyError; +var ArgumentOutOfRangeError_1 = __webpack_require__(25); +exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError_1.ArgumentOutOfRangeError; +var ObjectUnsubscribedError_1 = __webpack_require__(31); +exports.ObjectUnsubscribedError = ObjectUnsubscribedError_1.ObjectUnsubscribedError; +var TimeoutError_1 = __webpack_require__(84); +exports.TimeoutError = TimeoutError_1.TimeoutError; +var UnsubscriptionError_1 = __webpack_require__(60); +exports.UnsubscriptionError = UnsubscriptionError_1.UnsubscriptionError; +var timeInterval_1 = __webpack_require__(83); +exports.TimeInterval = timeInterval_1.TimeInterval; +var timestamp_1 = __webpack_require__(85); +exports.Timestamp = timestamp_1.Timestamp; +var TestScheduler_1 = __webpack_require__(406); +exports.TestScheduler = TestScheduler_1.TestScheduler; +var VirtualTimeScheduler_1 = __webpack_require__(89); +exports.VirtualTimeScheduler = VirtualTimeScheduler_1.VirtualTimeScheduler; +var AjaxObservable_1 = __webpack_require__(71); +exports.AjaxResponse = AjaxObservable_1.AjaxResponse; +exports.AjaxError = AjaxObservable_1.AjaxError; +exports.AjaxTimeoutError = AjaxObservable_1.AjaxTimeoutError; +var asap_1 = __webpack_require__(80); +var async_1 = __webpack_require__(9); +var queue_1 = __webpack_require__(72); +var animationFrame_1 = __webpack_require__(409); +var rxSubscriber_1 = __webpack_require__(29); +var iterator_1 = __webpack_require__(21); +var observable_1 = __webpack_require__(30); +/* tslint:enable:no-unused-variable */ +/** + * @typedef {Object} Rx.Scheduler + * @property {Scheduler} queue Schedules on a queue in the current event frame + * (trampoline scheduler). Use this for iteration operations. + * @property {Scheduler} asap Schedules on the micro task queue, which uses the + * fastest transport mechanism available, either Node.js' `process.nextTick()` + * or Web Worker MessageChannel or setTimeout or others. Use this for + * asynchronous conversions. + * @property {Scheduler} async Schedules work with `setInterval`. Use this for + * time-based operations. + * @property {Scheduler} animationFrame Schedules work with `requestAnimationFrame`. + * Use this for synchronizing with the platform's painting + */ +var Scheduler = { + asap: asap_1.asap, + queue: queue_1.queue, + animationFrame: animationFrame_1.animationFrame, + async: async_1.async +}; +exports.Scheduler = Scheduler; +/** + * @typedef {Object} Rx.Symbol + * @property {Symbol|string} rxSubscriber A symbol to use as a property name to + * retrieve an "Rx safe" Observer from an object. "Rx safety" can be defined as + * an object that has all of the traits of an Rx Subscriber, including the + * ability to add and remove subscriptions to the subscription chain and + * guarantees involving event triggering (can't "next" after unsubscription, + * etc). + * @property {Symbol|string} observable A symbol to use as a property name to + * retrieve an Observable as defined by the [ECMAScript "Observable" spec](https://github.com/zenparsing/es-observable). + * @property {Symbol|string} iterator The ES6 symbol to use as a property name + * to retrieve an iterator from an object. + */ +var Symbol = { + rxSubscriber: rxSubscriber_1.rxSubscriber, + observable: observable_1.observable, + iterator: iterator_1.iterator +}; +exports.Symbol = Symbol; +//# sourceMappingURL=Rx.js.map + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { - _createClass(Jss, [{ - key: 'setup', - value: function setup() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; +"use strict"; - if (options.createGenerateClassName) { - this.options.createGenerateClassName = options.createGenerateClassName; - // $FlowFixMe - this.generateClassName = options.createGenerateClassName(); - } +function isObject(x) { + return x != null && typeof x === 'object'; +} +exports.isObject = isObject; +//# sourceMappingURL=isObject.js.map - if (options.insertionPoint != null) this.options.insertionPoint = options.insertionPoint; - if (options.virtual || options.Renderer) { - this.options.Renderer = options.Renderer || (options.virtual ? _VirtualRenderer2['default'] : _DomRenderer2['default']); - } +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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(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)); +exports.UnsubscriptionError = UnsubscriptionError; +//# sourceMappingURL=UnsubscriptionError.js.map + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { - // eslint-disable-next-line prefer-spread - if (options.plugins) this.use.apply(this, options.plugins); +"use strict"; - return this; - } +exports.empty = { + closed: true, + next: function (value) { }, + error: function (err) { throw err; }, + complete: function () { } +}; +//# sourceMappingURL=Observer.js.map - /** - * Create a Style Sheet. - */ +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscription_1 = __webpack_require__(4); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SubjectSubscription = (function (_super) { + __extends(SubjectSubscription, _super); + function SubjectSubscription(subject, subscriber) { + _super.call(this); + this.subject = subject; + this.subscriber = subscriber; + this.closed = false; + } + SubjectSubscription.prototype.unsubscribe = function () { + if (this.closed) { + return; + } + this.closed = true; + var subject = this.subject; + var observers = subject.observers; + this.subject = null; + if (!observers || observers.length === 0 || subject.isStopped || subject.closed) { + return; + } + var subscriberIndex = observers.indexOf(this.subscriber); + if (subscriberIndex !== -1) { + observers.splice(subscriberIndex, 1); + } + }; + return SubjectSubscription; +}(Subscription_1.Subscription)); +exports.SubjectSubscription = SubjectSubscription; +//# sourceMappingURL=SubjectSubscription.js.map + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { - }, { - key: 'createStyleSheet', - value: function createStyleSheet(styles) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; +"use strict"; - var index = options.index; - if (typeof index !== 'number') { - index = _sheets2['default'].index === 0 ? 0 : _sheets2['default'].index + 1; - } - var sheet = new _StyleSheet2['default'](styles, _extends({}, options, { - jss: this, - generateClassName: options.generateClassName || this.generateClassName, - insertionPoint: this.options.insertionPoint, - Renderer: this.options.Renderer, - index: index - })); - this.plugins.onProcessSheet(sheet); +exports.isArrayLike = (function (x) { return x && typeof x.length === 'number'; }); +//# sourceMappingURL=isArrayLike.js.map - return sheet; - } +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Detach the Style Sheet and remove it from the registry. - */ +"use strict"; - }, { - key: 'removeStyleSheet', - value: function removeStyleSheet(sheet) { - sheet.detach(); - _sheets2['default'].remove(sheet); - return this; - } - - /** - * Create a rule without a Style Sheet. - */ - - }, { - key: 'createRule', - value: function createRule(name) { - var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - // Enable rule without name for inline styles. - if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { - options = style; - style = name; - name = undefined; - } - - // Cast from RuleFactoryOptions to RuleOptions - // https://stackoverflow.com/questions/41328728/force-casting-in-flow - var ruleOptions = options; - - ruleOptions.jss = this; - ruleOptions.Renderer = this.options.Renderer; - if (!ruleOptions.generateClassName) ruleOptions.generateClassName = this.generateClassName; - if (!ruleOptions.classes) ruleOptions.classes = {}; - var rule = (0, _createRule3['default'])(name, style, ruleOptions); - - if (!ruleOptions.selector && rule instanceof _StyleRule2['default']) { - rule.selector = '.' + ruleOptions.generateClassName(rule); - } - - this.plugins.onProcessRule(rule); - - return rule; - } - - /** - * Register plugin. Passed function will be invoked with a rule instance. - */ - - }, { - key: 'use', - value: function use() { - var _this = this; - - for (var _len = arguments.length, plugins = Array(_len), _key = 0; _key < _len; _key++) { - plugins[_key] = arguments[_key]; - } - - plugins.forEach(function (plugin) { - // Avoids applying same plugin twice, at least based on ref. - if (_this.options.plugins.indexOf(plugin) === -1) { - _this.options.plugins.push(plugin); - _this.plugins.use(plugin); - } - }); - - return this; - } - }]); - - return Jss; - }(); - - exports['default'] = Jss; - -/***/ }, -/* 25 */ -/***/ function(module, exports) { +function isPromise(value) { + return value && typeof value.subscribe !== 'function' && typeof value.then === 'function'; +} +exports.isPromise = isPromise; +//# sourceMappingURL=isPromise.js.map - "use strict"; +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 isArray_1 = __webpack_require__(13); +var isArrayLike_1 = __webpack_require__(63); +var isPromise_1 = __webpack_require__(64); +var PromiseObservable_1 = __webpack_require__(66); +var IteratorObservable_1 = __webpack_require__(154); +var ArrayObservable_1 = __webpack_require__(15); +var ArrayLikeObservable_1 = __webpack_require__(155); +var iterator_1 = __webpack_require__(21); +var Observable_1 = __webpack_require__(0); +var observeOn_1 = __webpack_require__(46); +var observable_1 = __webpack_require__(30); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var FromObservable = (function (_super) { + __extends(FromObservable, _super); + function FromObservable(ish, scheduler) { + _super.call(this, null); + this.ish = ish; + this.scheduler = scheduler; + } + /** + * Creates an Observable from an Array, an array-like object, a Promise, an + * iterable object, or an Observable-like object. + * + * Converts almost anything to an Observable. + * + * + * + * Convert various other objects and data types into Observables. `from` + * converts a Promise or an array-like or an + * [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable) + * object into an Observable that emits the items in that promise or array or + * iterable. A String, in this context, is treated as an array of characters. + * Observable-like objects (contains a function named with the ES2015 Symbol + * for Observable) can also be converted through this operator. + * + * @example Converts an array to an Observable + * var array = [10, 20, 30]; + * var result = Rx.Observable.from(array); + * result.subscribe(x => console.log(x)); + * + * // Results in the following: + * // 10 20 30 + * + * @example Convert an infinite iterable (from a generator) to an Observable + * function* generateDoubles(seed) { + * var i = seed; + * while (true) { + * yield i; + * i = 2 * i; // double it + * } + * } + * + * var iterator = generateDoubles(3); + * var result = Rx.Observable.from(iterator).take(10); + * result.subscribe(x => console.log(x)); + * + * // Results in the following: + * // 3 6 12 24 48 96 192 384 768 1536 + * + * @see {@link create} + * @see {@link fromEvent} + * @see {@link fromEventPattern} + * @see {@link fromPromise} + * + * @param {ObservableInput} ish A subscribable object, a Promise, an + * Observable-like, an Array, an iterable or an array-like object to be + * converted. + * @param {Scheduler} [scheduler] The scheduler on which to schedule the + * emissions of values. + * @return {Observable} The Observable whose values are originally from the + * input object that was converted. + * @static true + * @name from + * @owner Observable + */ + FromObservable.create = function (ish, scheduler) { + if (ish != null) { + if (typeof ish[observable_1.observable] === 'function') { + if (ish instanceof Observable_1.Observable && !scheduler) { + return ish; + } + return new FromObservable(ish, scheduler); + } + else if (isArray_1.isArray(ish)) { + return new ArrayObservable_1.ArrayObservable(ish, scheduler); + } + else if (isPromise_1.isPromise(ish)) { + return new PromiseObservable_1.PromiseObservable(ish, scheduler); + } + else if (typeof ish[iterator_1.iterator] === 'function' || typeof ish === 'string') { + return new IteratorObservable_1.IteratorObservable(ish, scheduler); + } + else if (isArrayLike_1.isArrayLike(ish)) { + return new ArrayLikeObservable_1.ArrayLikeObservable(ish, scheduler); + } + } + throw new TypeError((ish !== null && typeof ish || ish) + ' is not observable'); + }; + FromObservable.prototype._subscribe = function (subscriber) { + var ish = this.ish; + var scheduler = this.scheduler; + if (scheduler == null) { + return ish[observable_1.observable]().subscribe(subscriber); + } + else { + return ish[observable_1.observable]().subscribe(new observeOn_1.ObserveOnSubscriber(subscriber, scheduler, 0)); + } + }; + return FromObservable; +}(Observable_1.Observable)); +exports.FromObservable = FromObservable; +//# sourceMappingURL=FromObservable.js.map + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 root_1 = __webpack_require__(7); +var Observable_1 = __webpack_require__(0); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var PromiseObservable = (function (_super) { + __extends(PromiseObservable, _super); + function PromiseObservable(promise, scheduler) { + _super.call(this); + this.promise = promise; + this.scheduler = scheduler; + } + /** + * Converts a Promise to an Observable. + * + * Returns an Observable that just emits the Promise's + * resolved value, then completes. + * + * Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an + * Observable. If the Promise resolves with a value, the output Observable + * emits that resolved value as a `next`, and then completes. If the Promise + * is rejected, then the output Observable emits the corresponding Error. + * + * @example Convert the Promise returned by Fetch to an Observable + * var result = Rx.Observable.fromPromise(fetch('http://myserver.com/')); + * result.subscribe(x => console.log(x), e => console.error(e)); + * + * @see {@link bindCallback} + * @see {@link from} + * + * @param {PromiseLike} promise The promise to be converted. + * @param {Scheduler} [scheduler] An optional IScheduler to use for scheduling + * the delivery of the resolved value (or the rejection). + * @return {Observable} An Observable which wraps the Promise. + * @static true + * @name fromPromise + * @owner Observable + */ + PromiseObservable.create = function (promise, scheduler) { + return new PromiseObservable(promise, scheduler); + }; + PromiseObservable.prototype._subscribe = function (subscriber) { + var _this = this; + var promise = this.promise; + var scheduler = this.scheduler; + if (scheduler == null) { + if (this._isScalar) { + if (!subscriber.closed) { + subscriber.next(this.value); + subscriber.complete(); + } + } + else { + promise.then(function (value) { + _this.value = value; + _this._isScalar = true; + if (!subscriber.closed) { + subscriber.next(value); + subscriber.complete(); + } + }, function (err) { + if (!subscriber.closed) { + subscriber.error(err); + } + }) + .then(null, function (err) { + // escape the promise trap, throw unhandled errors + root_1.root.setTimeout(function () { throw err; }); + }); + } + } + else { + if (this._isScalar) { + if (!subscriber.closed) { + return scheduler.schedule(dispatchNext, 0, { value: this.value, subscriber: subscriber }); + } + } + else { + promise.then(function (value) { + _this.value = value; + _this._isScalar = true; + if (!subscriber.closed) { + subscriber.add(scheduler.schedule(dispatchNext, 0, { value: value, subscriber: subscriber })); + } + }, function (err) { + if (!subscriber.closed) { + subscriber.add(scheduler.schedule(dispatchError, 0, { err: err, subscriber: subscriber })); + } + }) + .then(null, function (err) { + // escape the promise trap, throw unhandled errors + root_1.root.setTimeout(function () { throw err; }); + }); + } + } + }; + return PromiseObservable; +}(Observable_1.Observable)); +exports.PromiseObservable = PromiseObservable; +function dispatchNext(arg) { + var value = arg.value, subscriber = arg.subscriber; + if (!subscriber.closed) { + subscriber.next(value); + subscriber.complete(); + } +} +function dispatchError(arg) { + var err = arg.err, subscriber = arg.subscriber; + if (!subscriber.closed) { + subscriber.error(err); + } +} +//# sourceMappingURL=PromiseObservable.js.map + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var ArrayObservable_1 = __webpack_require__(15); +var mergeAll_1 = __webpack_require__(33); +var isScheduler_1 = __webpack_require__(14); +/* tslint:enable:max-line-length */ +/** + * Creates an output Observable which concurrently emits all values from every + * given input Observable. + * + * Flattens multiple Observables together by blending + * their values into one Observable. + * + * + * + * `merge` subscribes to each given input Observable (either the source or an + * Observable given as argument), and simply forwards (without doing any + * transformation) all the values from all the input Observables to the output + * Observable. The output Observable only completes once all input Observables + * have completed. Any error delivered by an input Observable will be immediately + * emitted on the output Observable. + * + * @example Merge together two Observables: 1s interval and clicks + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var timer = Rx.Observable.interval(1000); + * var clicksOrTimer = clicks.merge(timer); + * clicksOrTimer.subscribe(x => console.log(x)); + * + * @example Merge together 3 Observables, but only 2 run concurrently + * var timer1 = Rx.Observable.interval(1000).take(10); + * var timer2 = Rx.Observable.interval(2000).take(6); + * var timer3 = Rx.Observable.interval(500).take(10); + * var concurrent = 2; // the argument + * var merged = timer1.merge(timer2, timer3, concurrent); + * merged.subscribe(x => console.log(x)); + * + * @see {@link mergeAll} + * @see {@link mergeMap} + * @see {@link mergeMapTo} + * @see {@link mergeScan} + * + * @param {ObservableInput} other An input Observable to merge with the source + * Observable. More than one input Observables may be given as argument. + * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input + * Observables being subscribed to concurrently. + * @param {Scheduler} [scheduler=null] The IScheduler to use for managing + * concurrency of input Observables. + * @return {Observable} An Observable that emits items that are the result of + * every input Observable. + * @method merge + * @owner Observable + */ +function merge() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + return this.lift.call(mergeStatic.apply(void 0, [this].concat(observables))); +} +exports.merge = merge; +/* tslint:enable:max-line-length */ +/** + * Creates an output Observable which concurrently emits all values from every + * given input Observable. + * + * Flattens multiple Observables together by blending + * their values into one Observable. + * + * + * + * `merge` subscribes to each given input Observable (as arguments), and simply + * forwards (without doing any transformation) all the values from all the input + * Observables to the output Observable. The output Observable only completes + * once all input Observables have completed. Any error delivered by an input + * Observable will be immediately emitted on the output Observable. + * + * @example Merge together two Observables: 1s interval and clicks + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var timer = Rx.Observable.interval(1000); + * var clicksOrTimer = Rx.Observable.merge(clicks, timer); + * clicksOrTimer.subscribe(x => console.log(x)); + * + * // Results in the following: + * // timer will emit ascending values, one every second(1000ms) to console + * // clicks logs MouseEvents to console everytime the "document" is clicked + * // Since the two streams are merged you see these happening + * // as they occur. + * + * @example Merge together 3 Observables, but only 2 run concurrently + * var timer1 = Rx.Observable.interval(1000).take(10); + * var timer2 = Rx.Observable.interval(2000).take(6); + * var timer3 = Rx.Observable.interval(500).take(10); + * var concurrent = 2; // the argument + * var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent); + * merged.subscribe(x => console.log(x)); + * + * // Results in the following: + * // - First timer1 and timer2 will run concurrently + * // - timer1 will emit a value every 1000ms for 10 iterations + * // - timer2 will emit a value every 2000ms for 6 iterations + * // - after timer1 hits it's max iteration, timer2 will + * // continue, and timer3 will start to run concurrently with timer2 + * // - when timer2 hits it's max iteration it terminates, and + * // timer3 will continue to emit a value every 500ms until it is complete + * + * @see {@link mergeAll} + * @see {@link mergeMap} + * @see {@link mergeMapTo} + * @see {@link mergeScan} + * + * @param {...ObservableInput} observables Input Observables to merge together. + * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input + * Observables being subscribed to concurrently. + * @param {Scheduler} [scheduler=null] The IScheduler to use for managing + * concurrency of input Observables. + * @return {Observable} an Observable that emits items that are the result of + * every input Observable. + * @static true + * @name merge + * @owner Observable + */ +function mergeStatic() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var concurrent = Number.POSITIVE_INFINITY; + var scheduler = null; + var last = observables[observables.length - 1]; + if (isScheduler_1.isScheduler(last)) { + scheduler = observables.pop(); + if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') { + concurrent = observables.pop(); + } + } + else if (typeof last === 'number') { + concurrent = observables.pop(); + } + if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) { + return observables[0]; + } + return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(concurrent)); +} +exports.mergeStatic = mergeStatic; +//# sourceMappingURL=merge.js.map + +/***/ }), +/* 68 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 isArray_1 = __webpack_require__(13); +var ArrayObservable_1 = __webpack_require__(15); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/* tslint:enable:max-line-length */ +/** + * Returns an Observable that mirrors the first source Observable to emit an item + * from the combination of this Observable and supplied Observables. + * @param {...Observables} ...observables Sources used to race for which Observable emits first. + * @return {Observable} An Observable that mirrors the output of the first Observable to emit an item. + * @method race + * @owner Observable + */ +function race() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + // if the only argument is an array, it was most likely called with + // `pair([obs1, obs2, ...])` + if (observables.length === 1 && isArray_1.isArray(observables[0])) { + observables = observables[0]; + } + return this.lift.call(raceStatic.apply(void 0, [this].concat(observables))); +} +exports.race = race; +function raceStatic() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + // if the only argument is an array, it was most likely called with + // `race([obs1, obs2, ...])` + if (observables.length === 1) { + if (isArray_1.isArray(observables[0])) { + observables = observables[0]; + } + else { + return observables[0]; + } + } + return new ArrayObservable_1.ArrayObservable(observables).lift(new RaceOperator()); +} +exports.raceStatic = raceStatic; +var RaceOperator = (function () { + function RaceOperator() { + } + RaceOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new RaceSubscriber(subscriber)); + }; + return RaceOperator; +}()); +exports.RaceOperator = RaceOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var RaceSubscriber = (function (_super) { + __extends(RaceSubscriber, _super); + function RaceSubscriber(destination) { + _super.call(this, destination); + this.hasFirst = false; + this.observables = []; + this.subscriptions = []; + } + RaceSubscriber.prototype._next = function (observable) { + this.observables.push(observable); + }; + RaceSubscriber.prototype._complete = function () { + var observables = this.observables; + var len = observables.length; + if (len === 0) { + this.destination.complete(); + } + else { + for (var i = 0; i < len && !this.hasFirst; i++) { + var observable = observables[i]; + var subscription = subscribeToResult_1.subscribeToResult(this, observable, observable, i); + if (this.subscriptions) { + this.subscriptions.push(subscription); + } + this.add(subscription); + } + this.observables = null; + } + }; + RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + if (!this.hasFirst) { + this.hasFirst = true; + for (var i = 0; i < this.subscriptions.length; i++) { + if (i !== outerIndex) { + var subscription = this.subscriptions[i]; + subscription.unsubscribe(); + this.remove(subscription); + } + } + this.subscriptions = null; + } + this.destination.next(innerValue); + }; + return RaceSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.RaceSubscriber = RaceSubscriber; +//# sourceMappingURL=race.js.map + +/***/ }), +/* 69 */ +/***/ (function(module, exports, __webpack_require__) { - Object.defineProperty(exports, "__esModule", { - value: true - }); +"use strict"; - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +/* tslint:disable:no-empty */ +function noop() { } +exports.noop = noop; +//# sourceMappingURL=noop.js.map - var isBrowser = exports.isBrowser = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && document.nodeType === 9; +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 FromObservable_1 = __webpack_require__(65); +var isArray_1 = __webpack_require__(13); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/* tslint:enable:max-line-length */ +/** + * When any of the provided Observable emits an complete or error notification, it immediately subscribes to the next one + * that was passed. + * + * Execute series of Observables no matter what, even if it means swallowing errors. + * + * + * + * `onErrorResumeNext` is an operator that accepts a series of Observables, provided either directly as + * arguments or as an array. If no single Observable is provided, returned Observable will simply behave the same + * as the source. + * + * `onErrorResumeNext` returns an Observable that starts by subscribing and re-emitting values from the source Observable. + * When its stream of values ends - no matter if Observable completed or emitted an error - `onErrorResumeNext` + * will subscribe to the first Observable that was passed as an argument to the method. It will start re-emitting + * its values as well and - again - when that stream ends, `onErrorResumeNext` will proceed to subscribing yet another + * Observable in provided series, no matter if previous Observable completed or ended with an error. This will + * be happening until there is no more Observables left in the series, at which point returned Observable will + * complete - even if the last subscribed stream ended with an error. + * + * `onErrorResumeNext` can be therefore thought of as version of {@link concat} operator, which is more permissive + * when it comes to the errors emitted by its input Observables. While `concat` subscribes to the next Observable + * in series only if previous one successfully completed, `onErrorResumeNext` subscribes even if it ended with + * an error. + * + * Note that you do not get any access to errors emitted by the Observables. In particular do not + * expect these errors to appear in error callback passed to {@link subscribe}. If you want to take + * specific actions based on what error was emitted by an Observable, you should try out {@link catch} instead. + * + * + * @example Subscribe to the next Observable after map fails + * Rx.Observable.of(1, 2, 3, 0) + * .map(x => { + * if (x === 0) { throw Error(); } + return 10 / x; + * }) + * .onErrorResumeNext(Rx.Observable.of(1, 2, 3)) + * .subscribe( + * val => console.log(val), + * err => console.log(err), // Will never be called. + * () => console.log('that\'s it!') + * ); + * + * // Logs: + * // 10 + * // 5 + * // 3.3333333333333335 + * // 1 + * // 2 + * // 3 + * // "that's it!" + * + * @see {@link concat} + * @see {@link catch} + * + * @param {...ObservableInput} observables Observables passed either directly or as an array. + * @return {Observable} An Observable that emits values from source Observable, but - if it errors - subscribes + * to the next passed Observable and so on, until it completes or runs out of Observables. + * @method onErrorResumeNext + * @owner Observable + */ +function onErrorResumeNext() { + var nextSources = []; + for (var _i = 0; _i < arguments.length; _i++) { + nextSources[_i - 0] = arguments[_i]; + } + if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) { + nextSources = nextSources[0]; + } + return this.lift(new OnErrorResumeNextOperator(nextSources)); +} +exports.onErrorResumeNext = onErrorResumeNext; +/* tslint:enable:max-line-length */ +function onErrorResumeNextStatic() { + var nextSources = []; + for (var _i = 0; _i < arguments.length; _i++) { + nextSources[_i - 0] = arguments[_i]; + } + var source = null; + if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) { + nextSources = nextSources[0]; + } + source = nextSources.shift(); + return new FromObservable_1.FromObservable(source, null).lift(new OnErrorResumeNextOperator(nextSources)); +} +exports.onErrorResumeNextStatic = onErrorResumeNextStatic; +var OnErrorResumeNextOperator = (function () { + function OnErrorResumeNextOperator(nextSources) { + this.nextSources = nextSources; + } + OnErrorResumeNextOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources)); + }; + return OnErrorResumeNextOperator; +}()); +var OnErrorResumeNextSubscriber = (function (_super) { + __extends(OnErrorResumeNextSubscriber, _super); + function OnErrorResumeNextSubscriber(destination, nextSources) { + _super.call(this, destination); + this.destination = destination; + this.nextSources = nextSources; + } + OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) { + this.subscribeToNextSource(); + }; + OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) { + this.subscribeToNextSource(); + }; + OnErrorResumeNextSubscriber.prototype._error = function (err) { + this.subscribeToNextSource(); + }; + OnErrorResumeNextSubscriber.prototype._complete = function () { + this.subscribeToNextSource(); + }; + OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () { + var next = this.nextSources.shift(); + if (next) { + this.add(subscribeToResult_1.subscribeToResult(this, next)); + } + else { + this.destination.complete(); + } + }; + return OnErrorResumeNextSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=onErrorResumeNext.js.map + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 root_1 = __webpack_require__(7); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var Observable_1 = __webpack_require__(0); +var Subscriber_1 = __webpack_require__(1); +var map_1 = __webpack_require__(48); +function getCORSRequest() { + if (root_1.root.XMLHttpRequest) { + return new root_1.root.XMLHttpRequest(); + } + else if (!!root_1.root.XDomainRequest) { + return new root_1.root.XDomainRequest(); + } + else { + throw new Error('CORS is not supported by your browser'); + } +} +function getXMLHttpRequest() { + if (root_1.root.XMLHttpRequest) { + return new root_1.root.XMLHttpRequest(); + } + else { + var progId = void 0; + try { + var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; + for (var i = 0; i < 3; i++) { + try { + progId = progIds[i]; + if (new root_1.root.ActiveXObject(progId)) { + break; + } + } + catch (e) { + } + } + return new root_1.root.ActiveXObject(progId); + } + catch (e) { + throw new Error('XMLHttpRequest is not supported by your browser'); + } + } +} +function ajaxGet(url, headers) { + if (headers === void 0) { headers = null; } + return new AjaxObservable({ method: 'GET', url: url, headers: headers }); +} +exports.ajaxGet = ajaxGet; +; +function ajaxPost(url, body, headers) { + return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers }); +} +exports.ajaxPost = ajaxPost; +; +function ajaxDelete(url, headers) { + return new AjaxObservable({ method: 'DELETE', url: url, headers: headers }); +} +exports.ajaxDelete = ajaxDelete; +; +function ajaxPut(url, body, headers) { + return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers }); +} +exports.ajaxPut = ajaxPut; +; +function ajaxPatch(url, body, headers) { + return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers }); +} +exports.ajaxPatch = ajaxPatch; +; +function ajaxGetJSON(url, headers) { + return new AjaxObservable({ method: 'GET', url: url, responseType: 'json', headers: headers }) + .lift(new map_1.MapOperator(function (x, index) { return x.response; }, null)); +} +exports.ajaxGetJSON = ajaxGetJSON; +; +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var AjaxObservable = (function (_super) { + __extends(AjaxObservable, _super); + function AjaxObservable(urlOrRequest) { + _super.call(this); + var request = { + async: true, + createXHR: function () { + return this.crossDomain ? getCORSRequest.call(this) : getXMLHttpRequest(); + }, + crossDomain: false, + withCredentials: false, + headers: {}, + method: 'GET', + responseType: 'json', + timeout: 0 + }; + if (typeof urlOrRequest === 'string') { + request.url = urlOrRequest; + } + else { + for (var prop in urlOrRequest) { + if (urlOrRequest.hasOwnProperty(prop)) { + request[prop] = urlOrRequest[prop]; + } + } + } + this.request = request; + } + AjaxObservable.prototype._subscribe = function (subscriber) { + return new AjaxSubscriber(subscriber, this.request); + }; + /** + * Creates an observable for an Ajax request with either a request object with + * url, headers, etc or a string for a URL. + * + * @example + * source = Rx.Observable.ajax('/products'); + * source = Rx.Observable.ajax({ url: 'products', method: 'GET' }); + * + * @param {string|Object} request Can be one of the following: + * A string of the URL to make the Ajax call. + * An object with the following properties + * - url: URL of the request + * - body: The body of the request + * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE + * - async: Whether the request is async + * - headers: Optional headers + * - crossDomain: true if a cross domain request, else false + * - createXHR: a function to override if you need to use an alternate + * XMLHttpRequest implementation. + * - resultSelector: a function to use to alter the output value type of + * the Observable. Gets {@link AjaxResponse} as an argument. + * @return {Observable} An observable sequence containing the XMLHttpRequest. + * @static true + * @name ajax + * @owner Observable + */ + AjaxObservable.create = (function () { + var create = function (urlOrRequest) { + return new AjaxObservable(urlOrRequest); + }; + create.get = ajaxGet; + create.post = ajaxPost; + create.delete = ajaxDelete; + create.put = ajaxPut; + create.patch = ajaxPatch; + create.getJSON = ajaxGetJSON; + return create; + })(); + return AjaxObservable; +}(Observable_1.Observable)); +exports.AjaxObservable = AjaxObservable; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var AjaxSubscriber = (function (_super) { + __extends(AjaxSubscriber, _super); + function AjaxSubscriber(destination, request) { + _super.call(this, destination); + this.request = request; + this.done = false; + var headers = request.headers = request.headers || {}; + // force CORS if requested + if (!request.crossDomain && !headers['X-Requested-With']) { + headers['X-Requested-With'] = 'XMLHttpRequest'; + } + // ensure content type is set + if (!('Content-Type' in headers) && !(root_1.root.FormData && request.body instanceof root_1.root.FormData) && typeof request.body !== 'undefined') { + headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; + } + // properly serialize body + request.body = this.serializeBody(request.body, request.headers['Content-Type']); + this.send(); + } + AjaxSubscriber.prototype.next = function (e) { + this.done = true; + var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination; + var response = new AjaxResponse(e, xhr, request); + destination.next(response); + }; + AjaxSubscriber.prototype.send = function () { + var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body; + var createXHR = request.createXHR; + var xhr = tryCatch_1.tryCatch(createXHR).call(request); + if (xhr === errorObject_1.errorObject) { + this.error(errorObject_1.errorObject.e); + } + else { + this.xhr = xhr; + // set up the events before open XHR + // https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest + // You need to add the event listeners before calling open() on the request. + // Otherwise the progress events will not fire. + this.setupEvents(xhr, request); + // open XHR + var result = void 0; + if (user) { + result = tryCatch_1.tryCatch(xhr.open).call(xhr, method, url, async, user, password); + } + else { + result = tryCatch_1.tryCatch(xhr.open).call(xhr, method, url, async); + } + if (result === errorObject_1.errorObject) { + this.error(errorObject_1.errorObject.e); + return null; + } + // timeout, responseType and withCredentials can be set once the XHR is open + if (async) { + xhr.timeout = request.timeout; + xhr.responseType = request.responseType; + } + if ('withCredentials' in xhr) { + xhr.withCredentials = !!request.withCredentials; + } + // set headers + this.setHeaders(xhr, headers); + // finally send the request + result = body ? tryCatch_1.tryCatch(xhr.send).call(xhr, body) : tryCatch_1.tryCatch(xhr.send).call(xhr); + if (result === errorObject_1.errorObject) { + this.error(errorObject_1.errorObject.e); + return null; + } + } + return xhr; + }; + AjaxSubscriber.prototype.serializeBody = function (body, contentType) { + if (!body || typeof body === 'string') { + return body; + } + else if (root_1.root.FormData && body instanceof root_1.root.FormData) { + return body; + } + if (contentType) { + var splitIndex = contentType.indexOf(';'); + if (splitIndex !== -1) { + contentType = contentType.substring(0, splitIndex); + } + } + switch (contentType) { + case 'application/x-www-form-urlencoded': + return Object.keys(body).map(function (key) { return (encodeURI(key) + "=" + encodeURI(body[key])); }).join('&'); + case 'application/json': + return JSON.stringify(body); + default: + return body; + } + }; + AjaxSubscriber.prototype.setHeaders = function (xhr, headers) { + for (var key in headers) { + if (headers.hasOwnProperty(key)) { + xhr.setRequestHeader(key, headers[key]); + } + } + }; + AjaxSubscriber.prototype.setupEvents = function (xhr, request) { + var progressSubscriber = request.progressSubscriber; + function xhrTimeout(e) { + var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request; + if (progressSubscriber) { + progressSubscriber.error(e); + } + subscriber.error(new AjaxTimeoutError(this, request)); //TODO: Make betterer. + } + ; + xhr.ontimeout = xhrTimeout; + xhrTimeout.request = request; + xhrTimeout.subscriber = this; + xhrTimeout.progressSubscriber = progressSubscriber; + if (xhr.upload && 'withCredentials' in xhr) { + if (progressSubscriber) { + var xhrProgress_1; + xhrProgress_1 = function (e) { + var progressSubscriber = xhrProgress_1.progressSubscriber; + progressSubscriber.next(e); + }; + if (root_1.root.XDomainRequest) { + xhr.onprogress = xhrProgress_1; + } + else { + xhr.upload.onprogress = xhrProgress_1; + } + xhrProgress_1.progressSubscriber = progressSubscriber; + } + var xhrError_1; + xhrError_1 = function (e) { + var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request; + if (progressSubscriber) { + progressSubscriber.error(e); + } + subscriber.error(new AjaxError('ajax error', this, request)); + }; + xhr.onerror = xhrError_1; + xhrError_1.request = request; + xhrError_1.subscriber = this; + xhrError_1.progressSubscriber = progressSubscriber; + } + function xhrReadyStateChange(e) { + var _a = xhrReadyStateChange, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request; + if (this.readyState === 4) { + // normalize IE9 bug (http://bugs.jquery.com/ticket/1450) + var status_1 = this.status === 1223 ? 204 : this.status; + var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response); + // fix status code when it is 0 (0 status is undocumented). + // Occurs when accessing file resources or on Android 4.1 stock browser + // while retrieving files from application cache. + if (status_1 === 0) { + status_1 = response ? 200 : 0; + } + if (200 <= status_1 && status_1 < 300) { + if (progressSubscriber) { + progressSubscriber.complete(); + } + subscriber.next(e); + subscriber.complete(); + } + else { + if (progressSubscriber) { + progressSubscriber.error(e); + } + subscriber.error(new AjaxError('ajax error ' + status_1, this, request)); + } + } + } + ; + xhr.onreadystatechange = xhrReadyStateChange; + xhrReadyStateChange.subscriber = this; + xhrReadyStateChange.progressSubscriber = progressSubscriber; + xhrReadyStateChange.request = request; + }; + AjaxSubscriber.prototype.unsubscribe = function () { + var _a = this, done = _a.done, xhr = _a.xhr; + if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') { + xhr.abort(); + } + _super.prototype.unsubscribe.call(this); + }; + return AjaxSubscriber; +}(Subscriber_1.Subscriber)); +exports.AjaxSubscriber = AjaxSubscriber; +/** + * A normalized AJAX response. + * + * @see {@link ajax} + * + * @class AjaxResponse + */ +var AjaxResponse = (function () { + function AjaxResponse(originalEvent, xhr, request) { + this.originalEvent = originalEvent; + this.xhr = xhr; + this.request = request; + this.status = xhr.status; + this.responseType = xhr.responseType || request.responseType; + switch (this.responseType) { + case 'json': + if ('response' in xhr) { + //IE does not support json as responseType, parse it internally + this.response = xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null'); + } + else { + this.response = JSON.parse(xhr.responseText || 'null'); + } + break; + case 'xml': + this.response = xhr.responseXML; + break; + case 'text': + default: + this.response = ('response' in xhr) ? xhr.response : xhr.responseText; + break; + } + } + return AjaxResponse; +}()); +exports.AjaxResponse = AjaxResponse; +/** + * A normalized AJAX error. + * + * @see {@link ajax} + * + * @class AjaxError + */ +var AjaxError = (function (_super) { + __extends(AjaxError, _super); + function AjaxError(message, xhr, request) { + _super.call(this, message); + this.message = message; + this.xhr = xhr; + this.request = request; + this.status = xhr.status; + } + return AjaxError; +}(Error)); +exports.AjaxError = AjaxError; +/** + * @see {@link ajax} + * + * @class AjaxTimeoutError + */ +var AjaxTimeoutError = (function (_super) { + __extends(AjaxTimeoutError, _super); + function AjaxTimeoutError(xhr, request) { + _super.call(this, 'ajax timeout', xhr, request); + } + return AjaxTimeoutError; +}(AjaxError)); +exports.AjaxTimeoutError = AjaxTimeoutError; +//# sourceMappingURL=AjaxObservable.js.map + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var QueueAction_1 = __webpack_require__(208); +var QueueScheduler_1 = __webpack_require__(209); +/** + * + * Queue Scheduler + * + * Put every next task on a queue, instead of executing it immediately + * + * `queue` scheduler, when used with delay, behaves the same as {@link async} scheduler. + * + * When used without delay, it schedules given task synchronously - executes it right when + * it is scheduled. However when called recursively, that is when inside the scheduled task, + * another task is scheduled with queue scheduler, instead of executing immediately as well, + * that task will be put on a queue and wait for current one to finish. + * + * This means that when you execute task with `queue` scheduler, you are sure it will end + * before any other task scheduled with that scheduler will start. + * + * @examples Schedule recursively first, then do something + * + * Rx.Scheduler.queue.schedule(() => { + * Rx.Scheduler.queue.schedule(() => console.log('second')); // will not happen now, but will be put on a queue + * + * console.log('first'); + * }); + * + * // Logs: + * // "first" + * // "second" + * + * + * @example Reschedule itself recursively + * + * Rx.Scheduler.queue.schedule(function(state) { + * if (state !== 0) { + * console.log('before', state); + * this.schedule(state - 1); // `this` references currently executing Action, + * // which we reschedule with new state + * console.log('after', state); + * } + * }, 0, 3); + * + * // In scheduler that runs recursively, you would expect: + * // "before", 3 + * // "before", 2 + * // "before", 1 + * // "after", 1 + * // "after", 2 + * // "after", 3 + * + * // But with queue it logs: + * // "before", 3 + * // "after", 3 + * // "before", 2 + * // "after", 2 + * // "before", 1 + * // "after", 1 + * + * + * @static true + * @name queue + * @owner Scheduler + */ +exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction); +//# sourceMappingURL=queue.js.map + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 subscribeToResult_1 = __webpack_require__(3); +var OuterSubscriber_1 = __webpack_require__(2); +/* tslint:enable:max-line-length */ +/** + * Projects each source value to an Observable which is merged in the output + * Observable. + * + * Maps each value to an Observable, then flattens all of + * these inner Observables using {@link mergeAll}. + * + * + * + * Returns an Observable that emits items based on applying a function that you + * supply to each item emitted by the source Observable, where that function + * returns an Observable, and then merging those resulting Observables and + * emitting the results of this merger. + * + * @example Map and flatten each letter to an Observable ticking every 1 second + * var letters = Rx.Observable.of('a', 'b', 'c'); + * var result = letters.mergeMap(x => + * Rx.Observable.interval(1000).map(i => x+i) + * ); + * result.subscribe(x => console.log(x)); + * + * // Results in the following: + * // a0 + * // b0 + * // c0 + * // a1 + * // b1 + * // c1 + * // continues to list a,b,c with respective ascending integers + * + * @see {@link concatMap} + * @see {@link exhaustMap} + * @see {@link merge} + * @see {@link mergeAll} + * @see {@link mergeMapTo} + * @see {@link mergeScan} + * @see {@link switchMap} + * + * @param {function(value: T, ?index: number): ObservableInput} project A function + * that, when applied to an item emitted by the source Observable, returns an + * Observable. + * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] + * A function to produce the value on the output Observable based on the values + * and the indices of the source (outer) emission and the inner Observable + * emission. The arguments passed to this function are: + * - `outerValue`: the value that came from the source + * - `innerValue`: the value that came from the projected Observable + * - `outerIndex`: the "index" of the value that came from the source + * - `innerIndex`: the "index" of the value from the projected Observable + * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input + * Observables being subscribed to concurrently. + * @return {Observable} An Observable that emits the result of applying the + * projection function (and the optional `resultSelector`) to each item emitted + * by the source Observable and merging the results of the Observables obtained + * from this transformation. + * @method mergeMap + * @owner Observable + */ +function mergeMap(project, resultSelector, concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + if (typeof resultSelector === 'number') { + concurrent = resultSelector; + resultSelector = null; + } + return this.lift(new MergeMapOperator(project, resultSelector, concurrent)); +} +exports.mergeMap = mergeMap; +var MergeMapOperator = (function () { + function MergeMapOperator(project, resultSelector, concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + this.project = project; + this.resultSelector = resultSelector; + this.concurrent = concurrent; + } + MergeMapOperator.prototype.call = function (observer, source) { + return source.subscribe(new MergeMapSubscriber(observer, this.project, this.resultSelector, this.concurrent)); + }; + return MergeMapOperator; +}()); +exports.MergeMapOperator = MergeMapOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var MergeMapSubscriber = (function (_super) { + __extends(MergeMapSubscriber, _super); + function MergeMapSubscriber(destination, project, resultSelector, concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + _super.call(this, destination); + this.project = project; + this.resultSelector = resultSelector; + this.concurrent = concurrent; + this.hasCompleted = false; + this.buffer = []; + this.active = 0; + this.index = 0; + } + MergeMapSubscriber.prototype._next = function (value) { + if (this.active < this.concurrent) { + this._tryNext(value); + } + else { + this.buffer.push(value); + } + }; + MergeMapSubscriber.prototype._tryNext = function (value) { + var result; + var index = this.index++; + try { + result = this.project(value, index); + } + catch (err) { + this.destination.error(err); + return; + } + this.active++; + this._innerSub(result, value, index); + }; + MergeMapSubscriber.prototype._innerSub = function (ish, value, index) { + this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index)); + }; + MergeMapSubscriber.prototype._complete = function () { + this.hasCompleted = true; + if (this.active === 0 && this.buffer.length === 0) { + this.destination.complete(); + } + }; + MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + if (this.resultSelector) { + this._notifyResultSelector(outerValue, innerValue, outerIndex, innerIndex); + } + else { + this.destination.next(innerValue); + } + }; + MergeMapSubscriber.prototype._notifyResultSelector = function (outerValue, innerValue, outerIndex, innerIndex) { + var result; + try { + result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex); + } + catch (err) { + this.destination.error(err); + return; + } + this.destination.next(result); + }; + MergeMapSubscriber.prototype.notifyComplete = function (innerSub) { + var buffer = this.buffer; + this.remove(innerSub); + this.active--; + if (buffer.length > 0) { + this._next(buffer.shift()); + } + else if (this.active === 0 && this.hasCompleted) { + this.destination.complete(); + } + }; + return MergeMapSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.MergeMapSubscriber = MergeMapSubscriber; +//# sourceMappingURL=mergeMap.js.map + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/* tslint:enable:max-line-length */ +/** + * Projects each source value to the same Observable which is merged multiple + * times in the output Observable. + * + * It's like {@link mergeMap}, but maps each value always + * to the same inner Observable. + * + * + * + * Maps each source value to the given Observable `innerObservable` regardless + * of the source value, and then merges those resulting Observables into one + * single Observable, which is the output Observable. + * + * @example For each click event, start an interval Observable ticking every 1 second + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.mergeMapTo(Rx.Observable.interval(1000)); + * result.subscribe(x => console.log(x)); + * + * @see {@link concatMapTo} + * @see {@link merge} + * @see {@link mergeAll} + * @see {@link mergeMap} + * @see {@link mergeScan} + * @see {@link switchMapTo} + * + * @param {ObservableInput} innerObservable An Observable to replace each value from + * the source Observable. + * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] + * A function to produce the value on the output Observable based on the values + * and the indices of the source (outer) emission and the inner Observable + * emission. The arguments passed to this function are: + * - `outerValue`: the value that came from the source + * - `innerValue`: the value that came from the projected Observable + * - `outerIndex`: the "index" of the value that came from the source + * - `innerIndex`: the "index" of the value from the projected Observable + * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input + * Observables being subscribed to concurrently. + * @return {Observable} An Observable that emits items from the given + * `innerObservable` (and optionally transformed through `resultSelector`) every + * time a value is emitted on the source Observable. + * @method mergeMapTo + * @owner Observable + */ +function mergeMapTo(innerObservable, resultSelector, concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + if (typeof resultSelector === 'number') { + concurrent = resultSelector; + resultSelector = null; + } + return this.lift(new MergeMapToOperator(innerObservable, resultSelector, concurrent)); +} +exports.mergeMapTo = mergeMapTo; +// TODO: Figure out correct signature here: an Operator, R> +// needs to implement call(observer: Subscriber): Subscriber> +var MergeMapToOperator = (function () { + function MergeMapToOperator(ish, resultSelector, concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + this.ish = ish; + this.resultSelector = resultSelector; + this.concurrent = concurrent; + } + MergeMapToOperator.prototype.call = function (observer, source) { + return source.subscribe(new MergeMapToSubscriber(observer, this.ish, this.resultSelector, this.concurrent)); + }; + return MergeMapToOperator; +}()); +exports.MergeMapToOperator = MergeMapToOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var MergeMapToSubscriber = (function (_super) { + __extends(MergeMapToSubscriber, _super); + function MergeMapToSubscriber(destination, ish, resultSelector, concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + _super.call(this, destination); + this.ish = ish; + this.resultSelector = resultSelector; + this.concurrent = concurrent; + this.hasCompleted = false; + this.buffer = []; + this.active = 0; + this.index = 0; + } + MergeMapToSubscriber.prototype._next = function (value) { + if (this.active < this.concurrent) { + var resultSelector = this.resultSelector; + var index = this.index++; + var ish = this.ish; + var destination = this.destination; + this.active++; + this._innerSub(ish, destination, resultSelector, value, index); + } + else { + this.buffer.push(value); + } + }; + MergeMapToSubscriber.prototype._innerSub = function (ish, destination, resultSelector, value, index) { + this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index)); + }; + MergeMapToSubscriber.prototype._complete = function () { + this.hasCompleted = true; + if (this.active === 0 && this.buffer.length === 0) { + this.destination.complete(); + } + }; + MergeMapToSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; + if (resultSelector) { + this.trySelectResult(outerValue, innerValue, outerIndex, innerIndex); + } + else { + destination.next(innerValue); + } + }; + MergeMapToSubscriber.prototype.trySelectResult = function (outerValue, innerValue, outerIndex, innerIndex) { + var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; + var result; + try { + result = resultSelector(outerValue, innerValue, outerIndex, innerIndex); + } + catch (err) { + destination.error(err); + return; + } + destination.next(result); + }; + MergeMapToSubscriber.prototype.notifyError = function (err) { + this.destination.error(err); + }; + MergeMapToSubscriber.prototype.notifyComplete = function (innerSub) { + var buffer = this.buffer; + this.remove(innerSub); + this.active--; + if (buffer.length > 0) { + this._next(buffer.shift()); + } + else if (this.active === 0 && this.hasCompleted) { + this.destination.complete(); + } + }; + return MergeMapToSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.MergeMapToSubscriber = MergeMapToSubscriber; +//# sourceMappingURL=mergeMapTo.js.map + +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +/* 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 A simple example with numbers + * 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 An example using a compare function + * interface Person { + * age: number, + * name: string + * } + * + * Observable.of( + * { 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 this.lift(new DistinctUntilChangedOperator(compare, keySelector)); +} +exports.distinctUntilChanged = 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_1.errorObject) { + return this.destination.error(errorObject_1.errorObject.e); + } + } + var result = false; + if (this.hasKey) { + result = tryCatch_1.tryCatch(this.compare)(this.key, key); + if (result === errorObject_1.errorObject) { + return this.destination.error(errorObject_1.errorObject.e); + } + } + else { + this.hasKey = true; + } + if (Boolean(result) === false) { + this.key = key; + this.destination.next(value); + } + }; + return DistinctUntilChangedSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=distinctUntilChanged.js.map + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/* tslint:enable:max-line-length */ +/** + * Filter items emitted by the source Observable by only emitting those that + * satisfy a specified predicate. + * + * Like + * [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter), + * it only emits a value from the source if it passes a criterion function. + * + * + * + * Similar to the well-known `Array.prototype.filter` method, this operator + * takes values from the source Observable, passes them through a `predicate` + * function and only emits those values that yielded `true`. + * + * @example Emit only click events whose target was a DIV element + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var clicksOnDivs = clicks.filter(ev => ev.target.tagName === 'DIV'); + * clicksOnDivs.subscribe(x => console.log(x)); + * + * @see {@link distinct} + * @see {@link distinctUntilChanged} + * @see {@link distinctUntilKeyChanged} + * @see {@link ignoreElements} + * @see {@link partition} + * @see {@link skip} + * + * @param {function(value: T, index: number): boolean} predicate A function that + * evaluates each value emitted by the source Observable. If it returns `true`, + * the value is emitted, if `false` the value is not passed to the output + * Observable. The `index` parameter is the number `i` for the i-th source + * emission that has happened since the subscription, starting from the number + * `0`. + * @param {any} [thisArg] An optional argument to determine the value of `this` + * in the `predicate` function. + * @return {Observable} An Observable of values from the source that were + * allowed by the `predicate` function. + * @method filter + * @owner Observable + */ +function filter(predicate, thisArg) { + return this.lift(new FilterOperator(predicate, thisArg)); +} +exports.filter = filter; +var FilterOperator = (function () { + function FilterOperator(predicate, thisArg) { + this.predicate = predicate; + this.thisArg = thisArg; + } + FilterOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg)); + }; + return FilterOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var FilterSubscriber = (function (_super) { + __extends(FilterSubscriber, _super); + function FilterSubscriber(destination, predicate, thisArg) { + _super.call(this, destination); + this.predicate = predicate; + this.thisArg = thisArg; + this.count = 0; + } + // the try catch block below is left specifically for + // optimization and perf reasons. a tryCatcher is not necessary here. + FilterSubscriber.prototype._next = function (value) { + var result; + try { + result = this.predicate.call(this.thisArg, value, this.count++); + } + catch (err) { + this.destination.error(err); + return; + } + if (result) { + this.destination.next(value); + } + }; + return FilterSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=filter.js.map + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/* tslint:enable:max-line-length */ +/** + * Emits only the first value emitted by the source Observable that meets some + * condition. + * + * Finds the first value that passes some test and emits + * that. + * + * + * + * `find` searches for the first item in the source Observable that matches the + * specified condition embodied by the `predicate`, and returns the first + * occurrence in the source. Unlike {@link first}, the `predicate` is required + * in `find`, and does not emit an error if a valid value is not found. + * + * @example Find and emit the first click that happens on a DIV element + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.find(ev => ev.target.tagName === 'DIV'); + * result.subscribe(x => console.log(x)); + * + * @see {@link filter} + * @see {@link first} + * @see {@link findIndex} + * @see {@link take} + * + * @param {function(value: T, index: number, source: Observable): boolean} predicate + * A function called with each item to test for condition matching. + * @param {any} [thisArg] An optional argument to determine the value of `this` + * in the `predicate` function. + * @return {Observable} An Observable of the first item that matches the + * condition. + * @method find + * @owner Observable + */ +function find(predicate, thisArg) { + if (typeof predicate !== 'function') { + throw new TypeError('predicate is not a function'); + } + return this.lift(new FindValueOperator(predicate, this, false, thisArg)); +} +exports.find = find; +var FindValueOperator = (function () { + function FindValueOperator(predicate, source, yieldIndex, thisArg) { + this.predicate = predicate; + this.source = source; + this.yieldIndex = yieldIndex; + this.thisArg = thisArg; + } + FindValueOperator.prototype.call = function (observer, source) { + return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg)); + }; + return FindValueOperator; +}()); +exports.FindValueOperator = FindValueOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var FindValueSubscriber = (function (_super) { + __extends(FindValueSubscriber, _super); + function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) { + _super.call(this, destination); + this.predicate = predicate; + this.source = source; + this.yieldIndex = yieldIndex; + this.thisArg = thisArg; + this.index = 0; + } + FindValueSubscriber.prototype.notifyComplete = function (value) { + var destination = this.destination; + destination.next(value); + destination.complete(); + }; + FindValueSubscriber.prototype._next = function (value) { + var _a = this, predicate = _a.predicate, thisArg = _a.thisArg; + var index = this.index++; + try { + var result = predicate.call(thisArg || this, value, index, this.source); + if (result) { + this.notifyComplete(this.yieldIndex ? index : value); + } + } + catch (err) { + this.destination.error(err); + } + }; + FindValueSubscriber.prototype._complete = function () { + this.notifyComplete(this.yieldIndex ? -1 : undefined); + }; + return FindValueSubscriber; +}(Subscriber_1.Subscriber)); +exports.FindValueSubscriber = FindValueSubscriber; +//# sourceMappingURL=find.js.map + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subject_1 = __webpack_require__(5); +var Observable_1 = __webpack_require__(0); +var Subscriber_1 = __webpack_require__(1); +var Subscription_1 = __webpack_require__(4); +/** + * @class ConnectableObservable + */ +var ConnectableObservable = (function (_super) { + __extends(ConnectableObservable, _super); + function ConnectableObservable(source, subjectFactory) { + _super.call(this); + this.source = source; + this.subjectFactory = subjectFactory; + this._refCount = 0; + this._isComplete = false; + } + ConnectableObservable.prototype._subscribe = function (subscriber) { + return this.getSubject().subscribe(subscriber); + }; + ConnectableObservable.prototype.getSubject = function () { + var subject = this._subject; + if (!subject || subject.isStopped) { + this._subject = this.subjectFactory(); + } + return this._subject; + }; + ConnectableObservable.prototype.connect = function () { + var connection = this._connection; + if (!connection) { + this._isComplete = false; + connection = this._connection = new Subscription_1.Subscription(); + connection.add(this.source + .subscribe(new ConnectableSubscriber(this.getSubject(), this))); + if (connection.closed) { + this._connection = null; + connection = Subscription_1.Subscription.EMPTY; + } + else { + this._connection = connection; + } + } + return connection; + }; + ConnectableObservable.prototype.refCount = function () { + return this.lift(new RefCountOperator(this)); + }; + return ConnectableObservable; +}(Observable_1.Observable)); +exports.ConnectableObservable = ConnectableObservable; +var connectableProto = ConnectableObservable.prototype; +exports.connectableObservableDescriptor = { + operator: { value: null }, + _refCount: { value: 0, writable: true }, + _subject: { value: null, writable: true }, + _connection: { value: null, writable: true }, + _subscribe: { value: connectableProto._subscribe }, + _isComplete: { value: connectableProto._isComplete, writable: true }, + getSubject: { value: connectableProto.getSubject }, + connect: { value: connectableProto.connect }, + refCount: { value: connectableProto.refCount } +}; +var ConnectableSubscriber = (function (_super) { + __extends(ConnectableSubscriber, _super); + function ConnectableSubscriber(destination, connectable) { + _super.call(this, destination); + this.connectable = connectable; + } + ConnectableSubscriber.prototype._error = function (err) { + this._unsubscribe(); + _super.prototype._error.call(this, err); + }; + ConnectableSubscriber.prototype._complete = function () { + this.connectable._isComplete = true; + this._unsubscribe(); + _super.prototype._complete.call(this); + }; + ConnectableSubscriber.prototype._unsubscribe = function () { + var connectable = this.connectable; + if (connectable) { + this.connectable = null; + var connection = connectable._connection; + connectable._refCount = 0; + connectable._subject = null; + connectable._connection = null; + if (connection) { + connection.unsubscribe(); + } + } + }; + return ConnectableSubscriber; +}(Subject_1.SubjectSubscriber)); +var RefCountOperator = (function () { + function RefCountOperator(connectable) { + this.connectable = connectable; + } + RefCountOperator.prototype.call = function (subscriber, source) { + var connectable = this.connectable; + connectable._refCount++; + var refCounter = new RefCountSubscriber(subscriber, connectable); + var subscription = source.subscribe(refCounter); + if (!refCounter.closed) { + refCounter.connection = connectable.connect(); + } + return subscription; + }; + return RefCountOperator; +}()); +var RefCountSubscriber = (function (_super) { + __extends(RefCountSubscriber, _super); + function RefCountSubscriber(destination, connectable) { + _super.call(this, destination); + this.connectable = connectable; + } + RefCountSubscriber.prototype._unsubscribe = function () { + var connectable = this.connectable; + if (!connectable) { + this.connection = null; + return; + } + this.connectable = null; + var refCount = connectable._refCount; + if (refCount <= 0) { + this.connection = null; + return; + } + connectable._refCount = refCount - 1; + if (refCount > 1) { + this.connection = null; + return; + } + /// + // Compare the local RefCountSubscriber's connection Subscription to the + // connection Subscription on the shared ConnectableObservable. In cases + // where the ConnectableObservable source synchronously emits values, and + // the RefCountSubscriber's downstream Observers synchronously unsubscribe, + // execution continues to here before the RefCountOperator has a chance to + // supply the RefCountSubscriber with the shared connection Subscription. + // For example: + // ``` + // Observable.range(0, 10) + // .publish() + // .refCount() + // .take(5) + // .subscribe(); + // ``` + // In order to account for this case, RefCountSubscriber should only dispose + // the ConnectableObservable's shared connection Subscription if the + // connection Subscription exists, *and* either: + // a. RefCountSubscriber doesn't have a reference to the shared connection + // Subscription yet, or, + // b. RefCountSubscriber's connection Subscription reference is identical + // to the shared connection Subscription + /// + var connection = this.connection; + var sharedConnection = connectable._connection; + this.connection = null; + if (sharedConnection && (!connection || sharedConnection === connection)) { + sharedConnection.unsubscribe(); + } + }; + return RefCountSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=ConnectableObservable.js.map + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subject_1 = __webpack_require__(5); +var ObjectUnsubscribedError_1 = __webpack_require__(31); +/** + * @class BehaviorSubject + */ +var BehaviorSubject = (function (_super) { + __extends(BehaviorSubject, _super); + function BehaviorSubject(_value) { + _super.call(this); + this._value = _value; + } + Object.defineProperty(BehaviorSubject.prototype, "value", { + get: function () { + return this.getValue(); + }, + enumerable: true, + configurable: true + }); + BehaviorSubject.prototype._subscribe = function (subscriber) { + var subscription = _super.prototype._subscribe.call(this, subscriber); + if (subscription && !subscription.closed) { + subscriber.next(this._value); + } + return subscription; + }; + BehaviorSubject.prototype.getValue = function () { + if (this.hasError) { + throw this.thrownError; + } + else if (this.closed) { + throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); + } + else { + return this._value; + } + }; + BehaviorSubject.prototype.next = function (value) { + _super.prototype.next.call(this, this._value = value); + }; + return BehaviorSubject; +}(Subject_1.Subject)); +exports.BehaviorSubject = BehaviorSubject; +//# sourceMappingURL=BehaviorSubject.js.map + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var AsapAction_1 = __webpack_require__(360); +var AsapScheduler_1 = __webpack_require__(363); +/** + * + * Asap Scheduler + * + * Perform task as fast as it can be performed asynchronously + * + * `asap` scheduler behaves the same as {@link async} scheduler when you use it to delay task + * in time. If however you set delay to `0`, `asap` will wait for current synchronously executing + * code to end and then it will try to execute given task as fast as possible. + * + * `asap` scheduler will do its best to minimize time between end of currently executing code + * and start of scheduled task. This makes it best candidate for performing so called "deferring". + * Traditionally this was achieved by calling `setTimeout(deferredTask, 0)`, but that technique involves + * some (although minimal) unwanted delay. + * + * Note that using `asap` scheduler does not necessarily mean that your task will be first to process + * after currently executing code. In particular, if some task was also scheduled with `asap` before, + * that task will execute first. That being said, if you need to schedule task asynchronously, but + * as soon as possible, `asap` scheduler is your best bet. + * + * @example Compare async and asap scheduler + * + * Rx.Scheduler.async.schedule(() => console.log('async')); // scheduling 'async' first... + * Rx.Scheduler.asap.schedule(() => console.log('asap')); + * + * // Logs: + * // "asap" + * // "async" + * // ... but 'asap' goes first! + * + * @static true + * @name asap + * @owner Scheduler + */ +exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction); +//# sourceMappingURL=asap.js.map + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +var apply = Function.prototype.apply; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { + if (timeout) { + timeout.close(); + } +}; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// setimmediate attaches itself to the global object +__webpack_require__(362); +exports.setImmediate = setImmediate; +exports.clearImmediate = clearImmediate; + + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +exports.defaultThrottleConfig = { + leading: true, + trailing: false +}; +/** + * Emits a value from the source Observable, then ignores subsequent source + * values for a duration determined by another Observable, then repeats this + * process. + * + * It's like {@link throttleTime}, but the silencing + * duration is determined by a second Observable. + * + * + * + * `throttle` emits the source Observable values on the output Observable + * when its internal timer is disabled, and ignores source values when the timer + * is enabled. Initially, the timer is disabled. As soon as the first source + * value arrives, it is forwarded to the output Observable, and then the timer + * is enabled by calling the `durationSelector` function with the source value, + * which returns the "duration" Observable. When the duration Observable emits a + * value or completes, the timer is disabled, and this process repeats for the + * next source value. + * + * @example Emit clicks at a rate of at most one click per second + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.throttle(ev => Rx.Observable.interval(1000)); + * result.subscribe(x => console.log(x)); + * + * @see {@link audit} + * @see {@link debounce} + * @see {@link delayWhen} + * @see {@link sample} + * @see {@link throttleTime} + * + * @param {function(value: T): SubscribableOrPromise} durationSelector A function + * that receives a value from the source Observable, for computing the silencing + * duration for each source value, returned as an Observable or a Promise. + * @param {Object} config a configuration object to define `leading` and `trailing` behavior. Defaults + * to `{ leading: true, trailing: false }`. + * @return {Observable} An Observable that performs the throttle operation to + * limit the rate of emissions from the source. + * @method throttle + * @owner Observable + */ +function throttle(durationSelector, config) { + if (config === void 0) { config = exports.defaultThrottleConfig; } + return this.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); +} +exports.throttle = throttle; +var ThrottleOperator = (function () { + function ThrottleOperator(durationSelector, leading, trailing) { + this.durationSelector = durationSelector; + this.leading = leading; + this.trailing = trailing; + } + ThrottleOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing)); + }; + return ThrottleOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc + * @ignore + * @extends {Ignored} + */ +var ThrottleSubscriber = (function (_super) { + __extends(ThrottleSubscriber, _super); + function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) { + _super.call(this, destination); + this.destination = destination; + this.durationSelector = durationSelector; + this._leading = _leading; + this._trailing = _trailing; + this._hasTrailingValue = false; + } + ThrottleSubscriber.prototype._next = function (value) { + if (this.throttled) { + if (this._trailing) { + this._hasTrailingValue = true; + this._trailingValue = value; + } + } + else { + var duration = this.tryDurationSelector(value); + if (duration) { + this.add(this.throttled = subscribeToResult_1.subscribeToResult(this, duration)); + } + if (this._leading) { + this.destination.next(value); + if (this._trailing) { + this._hasTrailingValue = true; + this._trailingValue = value; + } + } + } + }; + ThrottleSubscriber.prototype.tryDurationSelector = function (value) { + try { + return this.durationSelector(value); + } + catch (err) { + this.destination.error(err); + return null; + } + }; + ThrottleSubscriber.prototype._unsubscribe = function () { + var _a = this, throttled = _a.throttled, _trailingValue = _a._trailingValue, _hasTrailingValue = _a._hasTrailingValue, _trailing = _a._trailing; + this._trailingValue = null; + this._hasTrailingValue = false; + if (throttled) { + this.remove(throttled); + this.throttled = null; + throttled.unsubscribe(); + } + }; + ThrottleSubscriber.prototype._sendTrailing = function () { + var _a = this, destination = _a.destination, throttled = _a.throttled, _trailing = _a._trailing, _trailingValue = _a._trailingValue, _hasTrailingValue = _a._hasTrailingValue; + if (throttled && _trailing && _hasTrailingValue) { + destination.next(_trailingValue); + this._trailingValue = null; + this._hasTrailingValue = false; + } + }; + ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this._sendTrailing(); + this._unsubscribe(); + }; + ThrottleSubscriber.prototype.notifyComplete = function () { + this._sendTrailing(); + this._unsubscribe(); + }; + return ThrottleSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=throttle.js.map + +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var async_1 = __webpack_require__(9); +/** + * @param scheduler + * @return {Observable>|WebSocketSubject|Observable} + * @method timeInterval + * @owner Observable + */ +function timeInterval(scheduler) { + if (scheduler === void 0) { scheduler = async_1.async; } + return this.lift(new TimeIntervalOperator(scheduler)); +} +exports.timeInterval = timeInterval; +var TimeInterval = (function () { + function TimeInterval(value, interval) { + this.value = value; + this.interval = interval; + } + return TimeInterval; +}()); +exports.TimeInterval = TimeInterval; +; +var TimeIntervalOperator = (function () { + function TimeIntervalOperator(scheduler) { + this.scheduler = scheduler; + } + TimeIntervalOperator.prototype.call = function (observer, source) { + return source.subscribe(new TimeIntervalSubscriber(observer, this.scheduler)); + }; + return TimeIntervalOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var TimeIntervalSubscriber = (function (_super) { + __extends(TimeIntervalSubscriber, _super); + function TimeIntervalSubscriber(destination, scheduler) { + _super.call(this, destination); + this.scheduler = scheduler; + this.lastTime = 0; + this.lastTime = scheduler.now(); + } + TimeIntervalSubscriber.prototype._next = function (value) { + var now = this.scheduler.now(); + var span = now - this.lastTime; + this.lastTime = now; + this.destination.next(new TimeInterval(value, span)); + }; + return TimeIntervalSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=timeInterval.js.map + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 duetime elapses. + * + * @see {@link timeout} + * + * @class TimeoutError + */ +var TimeoutError = (function (_super) { + __extends(TimeoutError, _super); + function TimeoutError() { + var err = _super.call(this, 'Timeout has occurred'); + this.name = err.name = 'TimeoutError'; + this.stack = err.stack; + this.message = err.message; + } + return TimeoutError; +}(Error)); +exports.TimeoutError = TimeoutError; +//# sourceMappingURL=TimeoutError.js.map + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var async_1 = __webpack_require__(9); +/** + * @param scheduler + * @return {Observable>|WebSocketSubject|Observable} + * @method timestamp + * @owner Observable + */ +function timestamp(scheduler) { + if (scheduler === void 0) { scheduler = async_1.async; } + return this.lift(new TimestampOperator(scheduler)); +} +exports.timestamp = timestamp; +var Timestamp = (function () { + function Timestamp(value, timestamp) { + this.value = value; + this.timestamp = timestamp; + } + return Timestamp; +}()); +exports.Timestamp = Timestamp; +; +var TimestampOperator = (function () { + function TimestampOperator(scheduler) { + this.scheduler = scheduler; + } + TimestampOperator.prototype.call = function (observer, source) { + return source.subscribe(new TimestampSubscriber(observer, this.scheduler)); + }; + return TimestampOperator; +}()); +var TimestampSubscriber = (function (_super) { + __extends(TimestampSubscriber, _super); + function TimestampSubscriber(destination, scheduler) { + _super.call(this, destination); + this.scheduler = scheduler; + } + TimestampSubscriber.prototype._next = function (value) { + var now = this.scheduler.now(); + this.destination.next(new Timestamp(value, now)); + }; + return TimestampSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=timestamp.js.map + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var SubscriptionLog_1 = __webpack_require__(87); +var SubscriptionLoggable = (function () { + function SubscriptionLoggable() { + this.subscriptions = []; + } + SubscriptionLoggable.prototype.logSubscribedFrame = function () { + this.subscriptions.push(new SubscriptionLog_1.SubscriptionLog(this.scheduler.now())); + return this.subscriptions.length - 1; + }; + SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) { + var subscriptionLogs = this.subscriptions; + var oldSubscriptionLog = subscriptionLogs[index]; + subscriptionLogs[index] = new SubscriptionLog_1.SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now()); + }; + return SubscriptionLoggable; +}()); +exports.SubscriptionLoggable = SubscriptionLoggable; +//# sourceMappingURL=SubscriptionLoggable.js.map + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var SubscriptionLog = (function () { + function SubscriptionLog(subscribedFrame, unsubscribedFrame) { + if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; } + this.subscribedFrame = subscribedFrame; + this.unsubscribedFrame = unsubscribedFrame; + } + return SubscriptionLog; +}()); +exports.SubscriptionLog = SubscriptionLog; +//# sourceMappingURL=SubscriptionLog.js.map + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +function applyMixins(derivedCtor, baseCtors) { + for (var i = 0, len = baseCtors.length; i < len; i++) { + var baseCtor = baseCtors[i]; + var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype); + for (var j = 0, len2 = propertyKeys.length; j < len2; j++) { + var name_1 = propertyKeys[j]; + derivedCtor.prototype[name_1] = baseCtor.prototype[name_1]; + } + } +} +exports.applyMixins = applyMixins; +//# sourceMappingURL=applyMixins.js.map + +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 AsyncAction_1 = __webpack_require__(23); +var AsyncScheduler_1 = __webpack_require__(24); +var VirtualTimeScheduler = (function (_super) { + __extends(VirtualTimeScheduler, _super); + function VirtualTimeScheduler(SchedulerAction, maxFrames) { + var _this = this; + if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; } + if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; } + _super.call(this, SchedulerAction, function () { return _this.frame; }); + this.maxFrames = maxFrames; + this.frame = 0; + this.index = -1; + } + /** + * Prompt the Scheduler to execute all of its queued actions, therefore + * clearing its queue. + * @return {void} + */ + VirtualTimeScheduler.prototype.flush = function () { + var _a = this, actions = _a.actions, maxFrames = _a.maxFrames; + var error, action; + while ((action = actions.shift()) && (this.frame = action.delay) <= maxFrames) { + if (error = action.execute(action.state, action.delay)) { + break; + } + } + if (error) { + while (action = actions.shift()) { + action.unsubscribe(); + } + throw error; + } + }; + VirtualTimeScheduler.frameTimeFactor = 10; + return VirtualTimeScheduler; +}(AsyncScheduler_1.AsyncScheduler)); +exports.VirtualTimeScheduler = VirtualTimeScheduler; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var VirtualAction = (function (_super) { + __extends(VirtualAction, _super); + function VirtualAction(scheduler, work, index) { + if (index === void 0) { index = scheduler.index += 1; } + _super.call(this, scheduler, work); + this.scheduler = scheduler; + this.work = work; + this.index = index; + this.active = true; + this.index = scheduler.index = index; + } + VirtualAction.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + if (!this.id) { + return _super.prototype.schedule.call(this, state, delay); + } + this.active = false; + // If an action is rescheduled, we save allocations by mutating its state, + // pushing it to the end of the scheduler queue, and recycling the action. + // But since the VirtualTimeScheduler is used for testing, VirtualActions + // must be immutable so they can be inspected later. + var action = new VirtualAction(this.scheduler, this.work); + this.add(action); + return action.schedule(state, delay); + }; + VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + this.delay = scheduler.frame + delay; + var actions = scheduler.actions; + actions.push(this); + actions.sort(VirtualAction.sortActions); + return true; + }; + VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + return undefined; + }; + VirtualAction.prototype._execute = function (state, delay) { + if (this.active === true) { + return _super.prototype._execute.call(this, state, delay); + } + }; + VirtualAction.sortActions = function (a, b) { + if (a.delay === b.delay) { + if (a.index === b.index) { + return 0; + } + else if (a.index > b.index) { + return 1; + } + else { + return -1; + } + } + else if (a.delay > b.delay) { + return 1; + } + else { + return -1; + } + }; + return VirtualAction; +}(AsyncAction_1.AsyncAction)); +exports.VirtualAction = VirtualAction; +//# sourceMappingURL=VirtualTimeScheduler.js.map + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { - exports.default = isBrowser; +"use strict"; -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _warning = __webpack_require__(7); - - var _warning2 = _interopRequireDefault(_warning); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var PluginsRegistry = function () { - function PluginsRegistry() { - _classCallCheck(this, PluginsRegistry); - - this.hooks = { - onCreateRule: [], - onProcessRule: [], - onProcessStyle: [], - onProcessSheet: [], - onChangeValue: [] - - /** - * Call `onCreateRule` hooks and return an object if returned by a hook. - */ - }; - } - - _createClass(PluginsRegistry, [{ - key: 'onCreateRule', - value: function onCreateRule(name, decl, options) { - for (var i = 0; i < this.hooks.onCreateRule.length; i++) { - var rule = this.hooks.onCreateRule[i](name, decl, options); - if (rule) return rule; - } - return null; - } - - /** - * Call `onProcessRule` hooks. - */ - - }, { - key: 'onProcessRule', - value: function onProcessRule(rule) { - if (rule.isProcessed) return; - var sheet = rule.options.sheet; - - for (var i = 0; i < this.hooks.onProcessRule.length; i++) { - this.hooks.onProcessRule[i](rule, sheet); - } - - // $FlowFixMe - if (rule.style) this.onProcessStyle(rule.style, rule, sheet); - - rule.isProcessed = true; - } - - /** - * Call `onProcessStyle` hooks. - */ - - }, { - key: 'onProcessStyle', - value: function onProcessStyle(style, rule, sheet) { - var nextStyle = style; - - for (var i = 0; i < this.hooks.onProcessStyle.length; i++) { - nextStyle = this.hooks.onProcessStyle[i](nextStyle, rule, sheet); - // $FlowFixMe - rule.style = nextStyle; - } - } - - /** - * Call `onProcessSheet` hooks. - */ - - }, { - key: 'onProcessSheet', - value: function onProcessSheet(sheet) { - for (var i = 0; i < this.hooks.onProcessSheet.length; i++) { - this.hooks.onProcessSheet[i](sheet); - } - } - - /** - * Call `onChangeValue` hooks. - */ - - }, { - key: 'onChangeValue', - value: function onChangeValue(value, prop, rule) { - var processedValue = value; - for (var i = 0; i < this.hooks.onChangeValue.length; i++) { - processedValue = this.hooks.onChangeValue[i](processedValue, prop, rule); - } - return processedValue; - } - - /** - * Register a plugin. - * If function is passed, it is a shortcut for `{onProcessRule}`. - */ - - }, { - key: 'use', - value: function use(plugin) { - for (var name in plugin) { - if (this.hooks[name]) this.hooks[name].push(plugin[name]);else (0, _warning2['default'])(false, '[JSS] Unknown hook "%s".', name); - } - } - }]); - - return PluginsRegistry; - }(); - - exports['default'] = PluginsRegistry; - -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { - 'use strict'; +__webpack_require__(91); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _scene = __webpack_require__(128); - var _SimpleRule = __webpack_require__(28); +var _scene2 = _interopRequireDefault(_scene); - var _SimpleRule2 = _interopRequireDefault(_SimpleRule); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var _KeyframesRule = __webpack_require__(29); +document.body.appendChild((0, _scene2.default)()); - var _KeyframesRule2 = _interopRequireDefault(_KeyframesRule); +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _jss = __webpack_require__(10); + +var _jss2 = _interopRequireDefault(_jss); + +var _theme = __webpack_require__(12); + +var theme = _interopRequireWildcard(_theme); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var styles = { + '@global': { + body: { + height: '100%', + width: '100%', + margin: 0, + padding: 0, + backgroundColor: theme.colorBg, + overflow: 'hidden' + }, + html: { + height: '100%', + width: '100%', + margin: 0, + padding: 0, + backgroundColor: theme.colorBg, + overflow: 'hidden' + }, + '*': { + boxSizing: 'border-box', + position: 'relative', + '&:before': { + content: '""', + display: 'block', + boxSizing: 'border-box', + position: 'relative' + }, + '&:after': { + content: '""', + display: 'block', + boxSizing: 'border-box', + position: 'relative' + } + } + } +}; + +_jss2.default.createStyleSheet(styles).attach(); + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { - var _ConditionalRule = __webpack_require__(30); +"use strict"; - var _ConditionalRule2 = _interopRequireDefault(_ConditionalRule); - var _FontFaceRule = __webpack_require__(31); +Object.defineProperty(exports, "__esModule", { + value: true +}); - var _FontFaceRule2 = _interopRequireDefault(_FontFaceRule); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - var _ViewportRule = __webpack_require__(32); +/** + * Extracts a styles object with only props that contain function values. + */ +exports['default'] = function (styles) { + // eslint-disable-next-line no-shadow + function extract(styles) { + var to = null; - var _ViewportRule2 = _interopRequireDefault(_ViewportRule); + for (var key in styles) { + var value = styles[key]; + var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + if (type === 'function') { + if (!to) to = {}; + to[key] = value; + } else if (type === 'object' && value !== null && !Array.isArray(value)) { + var extracted = extract(value); + if (extracted) { + if (!to) to = {}; + to[key] = extracted; + } + } + } - var classes = { - '@charset': _SimpleRule2['default'], - '@import': _SimpleRule2['default'], - '@namespace': _SimpleRule2['default'], - '@keyframes': _KeyframesRule2['default'], - '@media': _ConditionalRule2['default'], - '@supports': _ConditionalRule2['default'], - '@font-face': _FontFaceRule2['default'], - '@viewport': _ViewportRule2['default'], - '@-ms-viewport': _ViewportRule2['default'] + return to; + } - /** - * Generate plugins which will register all rules. - */ - }; - exports['default'] = Object.keys(classes).map(function (key) { - // https://jsperf.com/indexof-vs-substr-vs-regex-at-the-beginning-3 - var re = new RegExp('^' + key); - var onCreateRule = function onCreateRule(name, decl, options) { - return re.test(name) ? new classes[key](name, decl, options) : null; - }; - return { onCreateRule: onCreateRule }; - }); + return extract(styles); +}; -/***/ }, -/* 28 */ -/***/ function(module, exports) { +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _warning = __webpack_require__(11); + +var _warning2 = _interopRequireDefault(_warning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * SheetsManager is like a WeakMap which is designed to count StyleSheet + * instances and attach/detach automatically. + */ +var SheetsManager = function () { + function SheetsManager() { + _classCallCheck(this, SheetsManager); + + this.sheets = []; + this.refs = []; + this.keys = []; + } + + _createClass(SheetsManager, [{ + key: 'get', + value: function get(key) { + var index = this.keys.indexOf(key); + return this.sheets[index]; + } + }, { + key: 'add', + value: function add(key, sheet) { + var sheets = this.sheets, + refs = this.refs, + keys = this.keys; + + var index = sheets.indexOf(sheet); + + if (index !== -1) return index; + + sheets.push(sheet); + refs.push(0); + keys.push(key); + + return sheets.length - 1; + } + }, { + key: 'manage', + value: function manage(key) { + var index = this.keys.indexOf(key); + var sheet = this.sheets[index]; + if (this.refs[index] === 0) sheet.attach(); + this.refs[index]++; + if (!this.keys[index]) this.keys.splice(index, 0, key); + return sheet; + } + }, { + key: 'unmanage', + value: function unmanage(key) { + var index = this.keys.indexOf(key); + if (index === -1) { + // eslint-ignore-next-line no-console + (0, _warning2['default'])(false, 'SheetsManager: can\'t find sheet to unmanage'); + return; + } + if (this.refs[index] > 0) { + this.refs[index]--; + if (this.refs[index] === 0) this.sheets[index].detach(); + } + } + }, { + key: 'size', + get: function get() { + return this.keys.length; + } + }]); + + return SheetsManager; +}(); + +exports['default'] = SheetsManager; + +/***/ }), +/* 94 */ +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) {/* global window */ - Object.defineProperty(exports, "__esModule", { - value: true - }); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +module.exports = __webpack_require__(95)(global || window || this); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(27))) - var SimpleRule = function () { - function SimpleRule(key, value, options) { - _classCallCheck(this, SimpleRule); +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { - this.type = 'simple'; - this.isProcessed = false; +"use strict"; - this.key = key; - this.value = value; - this.options = options; - } - /** - * Generates a CSS string. - */ - // eslint-disable-next-line no-unused-vars +module.exports = function symbolObservablePonyfill(root) { + var result; + var Symbol = root.Symbol; + if (typeof Symbol === 'function') { + if (Symbol.observable) { + result = Symbol.observable; + } else { + result = Symbol('observable'); + Symbol.observable = result; + } + } else { + result = '@@observable'; + } - _createClass(SimpleRule, [{ - key: 'toString', - value: function toString(options) { - if (Array.isArray(this.value)) { - var str = ''; - for (var index = 0; index < this.value.length; index++) { - str += this.key + ' ' + this.value[index] + ';'; - if (this.value[index + 1]) str += '\n'; - } - return str; - } + return result; +}; - return this.key + ' ' + this.value + ';'; - } - }]); - return SimpleRule; - }(); +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { - exports['default'] = SimpleRule; +"use strict"; -/***/ }, -/* 29 */ -/***/ function(module, exports, __webpack_require__) { - 'use strict'; +Object.defineProperty(exports, "__esModule", { + value: true +}); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +exports['default'] = cloneStyle; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _isObservable = __webpack_require__(18); - var _RuleList = __webpack_require__(9); +var _isObservable2 = _interopRequireDefault(_isObservable); - var _RuleList2 = _interopRequireDefault(_RuleList); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var isArray = Array.isArray; +function cloneStyle(style) { + // Support empty values in case user ends up with them by accident. + if (style == null) return style; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + // Support string value for SimpleRule. + var typeOfStyle = typeof style === 'undefined' ? 'undefined' : _typeof(style); + if (typeOfStyle === 'string' || typeOfStyle === 'number') return style; - /** - * Rule for @keyframes - */ - var KeyframesRule = function () { - function KeyframesRule(key, frames, options) { - _classCallCheck(this, KeyframesRule); + // Support array for FontFaceRule. + if (isArray(style)) return style.map(cloneStyle); - this.type = 'keyframes'; - this.isProcessed = false; + var newStyle = {}; + for (var name in style) { + var value = style[name]; + if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !(0, _isObservable2['default'])(value)) { + newStyle[name] = cloneStyle(value); + continue; + } + newStyle[name] = value; + } - this.key = key; - this.options = options; - this.rules = new _RuleList2['default'](_extends({}, options, { parent: this })); + return newStyle; +} - for (var name in frames) { - this.rules.add(name, frames[name], _extends({}, this.options, { - parent: this, - selector: name - })); - } +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { - this.rules.process(); - } +"use strict"; - /** - * Generates a CSS string. - */ +Object.defineProperty(exports, "__esModule", { + value: true +}); - _createClass(KeyframesRule, [{ - key: 'toString', - value: function toString() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { indent: 1 }; +exports['default'] = function (rule, data, RuleList) { + if (rule.type === 'style') { + for (var prop in rule.style) { + var value = rule.style[prop]; + if (typeof value === 'function') { + rule.prop(prop, value(data)); + } + } + } else if (rule.rules instanceof RuleList) { + rule.rules.update(data); + } +}; - var inner = this.rules.toString(options); - if (inner) inner += '\n'; - return this.key + ' {\n' + inner + '}'; - } - }]); +/***/ }), +/* 98 */ +/***/ (function(module, exports, __webpack_require__) { - return KeyframesRule; - }(); +"use strict"; - exports['default'] = KeyframesRule; -/***/ }, -/* 30 */ -/***/ function(module, exports, __webpack_require__) { +Object.defineProperty(exports, "__esModule", { + value: true +}); - 'use strict'; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _isInBrowser = __webpack_require__(99); - var _RuleList = __webpack_require__(9); +var _isInBrowser2 = _interopRequireDefault(_isInBrowser); - var _RuleList2 = _interopRequireDefault(_RuleList); +var _StyleSheet = __webpack_require__(57); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _StyleSheet2 = _interopRequireDefault(_StyleSheet); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +var _PluginsRegistry = __webpack_require__(100); - /** - * Conditional rule for @media, @supports - */ - var ConditionalRule = function () { - function ConditionalRule(key, styles, options) { - _classCallCheck(this, ConditionalRule); +var _PluginsRegistry2 = _interopRequireDefault(_PluginsRegistry); - this.type = 'conditional'; - this.isProcessed = false; +var _rules = __webpack_require__(101); - this.key = key; - this.options = options; - this.rules = new _RuleList2['default'](_extends({}, options, { parent: this })); +var _rules2 = _interopRequireDefault(_rules); - for (var name in styles) { - this.rules.add(name, styles[name]); - } +var _observables = __webpack_require__(107); - this.rules.process(); - } +var _observables2 = _interopRequireDefault(_observables); - /** - * Get a rule. - */ +var _sheets = __webpack_require__(40); +var _sheets2 = _interopRequireDefault(_sheets); - _createClass(ConditionalRule, [{ - key: 'getRule', - value: function getRule(name) { - return this.rules.get(name); - } +var _StyleRule = __webpack_require__(19); - /** - * Get index of a rule. - */ +var _StyleRule2 = _interopRequireDefault(_StyleRule); - }, { - key: 'indexOf', - value: function indexOf(rule) { - return this.rules.indexOf(rule); - } +var _createGenerateClassName = __webpack_require__(56); - /** - * Create and register rule, run plugins. - */ +var _createGenerateClassName2 = _interopRequireDefault(_createGenerateClassName); - }, { - key: 'addRule', - value: function addRule(name, style, options) { - var rule = this.rules.add(name, style, options); - this.options.jss.plugins.onProcessRule(rule); - return rule; - } +var _createRule2 = __webpack_require__(52); - /** - * Generates a CSS string. - */ +var _createRule3 = _interopRequireDefault(_createRule2); - }, { - key: 'toString', - value: function toString() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { indent: 1 }; +var _DomRenderer = __webpack_require__(108); - var inner = this.rules.toString(options); - return inner ? this.key + ' {\n' + inner + '\n}' : ''; - } - }]); +var _DomRenderer2 = _interopRequireDefault(_DomRenderer); - return ConditionalRule; - }(); +var _VirtualRenderer = __webpack_require__(109); - exports['default'] = ConditionalRule; +var _VirtualRenderer2 = _interopRequireDefault(_VirtualRenderer); -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - 'use strict'; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - Object.defineProperty(exports, "__esModule", { - value: true - }); +var defaultPlugins = _rules2['default'].concat([_observables2['default']]); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var Jss = function () { + function Jss(options) { + _classCallCheck(this, Jss); - var _toCss = __webpack_require__(12); + this.version = "9.0.0"; + this.plugins = new _PluginsRegistry2['default'](); + this.options = { + createGenerateClassName: _createGenerateClassName2['default'], + Renderer: _isInBrowser2['default'] ? _DomRenderer2['default'] : _VirtualRenderer2['default'], + plugins: [] + }; + this.generateClassName = (0, _createGenerateClassName2['default'])(); - var _toCss2 = _interopRequireDefault(_toCss); + // eslint-disable-next-line prefer-spread + this.use.apply(this, defaultPlugins); + this.setup(options); + } - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + _createClass(Jss, [{ + key: 'setup', + value: function setup() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + if (options.createGenerateClassName) { + this.options.createGenerateClassName = options.createGenerateClassName; + // $FlowFixMe + this.generateClassName = options.createGenerateClassName(); + } - var FontFaceRule = function () { - function FontFaceRule(key, style, options) { - _classCallCheck(this, FontFaceRule); + if (options.insertionPoint != null) this.options.insertionPoint = options.insertionPoint; + if (options.virtual || options.Renderer) { + this.options.Renderer = options.Renderer || (options.virtual ? _VirtualRenderer2['default'] : _DomRenderer2['default']); + } - this.type = 'font-face'; - this.isProcessed = false; + // eslint-disable-next-line prefer-spread + if (options.plugins) this.use.apply(this, options.plugins); - this.key = key; - this.style = style; - this.options = options; - } + return this; + } - /** - * Generates a CSS string. - */ + /** + * Create a Style Sheet. + */ + }, { + key: 'createStyleSheet', + value: function createStyleSheet(styles) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - _createClass(FontFaceRule, [{ - key: 'toString', - value: function toString(options) { - if (Array.isArray(this.style)) { - var str = ''; - for (var index = 0; index < this.style.length; index++) { - str += (0, _toCss2['default'])(this.key, this.style[index]); - if (this.style[index + 1]) str += '\n'; - } - return str; - } + var index = options.index; + if (typeof index !== 'number') { + index = _sheets2['default'].index === 0 ? 0 : _sheets2['default'].index + 1; + } + var sheet = new _StyleSheet2['default'](styles, _extends({}, options, { + jss: this, + generateClassName: options.generateClassName || this.generateClassName, + insertionPoint: this.options.insertionPoint, + Renderer: this.options.Renderer, + index: index + })); + this.plugins.onProcessSheet(sheet); - return (0, _toCss2['default'])(this.key, this.style, options); - } - }]); + return sheet; + } - return FontFaceRule; - }(); + /** + * Detach the Style Sheet and remove it from the registry. + */ - exports['default'] = FontFaceRule; + }, { + key: 'removeStyleSheet', + value: function removeStyleSheet(sheet) { + sheet.detach(); + _sheets2['default'].remove(sheet); + return this; + } + + /** + * Create a rule without a Style Sheet. + */ + + }, { + key: 'createRule', + value: function createRule(name) { + var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + // Enable rule without name for inline styles. + if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { + options = style; + style = name; + name = undefined; + } + + // Cast from RuleFactoryOptions to RuleOptions + // https://stackoverflow.com/questions/41328728/force-casting-in-flow + var ruleOptions = options; + + ruleOptions.jss = this; + ruleOptions.Renderer = this.options.Renderer; + if (!ruleOptions.generateClassName) ruleOptions.generateClassName = this.generateClassName; + if (!ruleOptions.classes) ruleOptions.classes = {}; + var rule = (0, _createRule3['default'])(name, style, ruleOptions); + + if (!ruleOptions.selector && rule instanceof _StyleRule2['default']) { + rule.selector = '.' + ruleOptions.generateClassName(rule); + } + + this.plugins.onProcessRule(rule); + + return rule; + } + + /** + * Register plugin. Passed function will be invoked with a rule instance. + */ + + }, { + key: 'use', + value: function use() { + var _this = this; + + for (var _len = arguments.length, plugins = Array(_len), _key = 0; _key < _len; _key++) { + plugins[_key] = arguments[_key]; + } + + plugins.forEach(function (plugin) { + // Avoids applying same plugin twice, at least based on ref. + if (_this.options.plugins.indexOf(plugin) === -1) { + _this.options.plugins.push(plugin); + _this.plugins.use(plugin); + } + }); + + return this; + } + }]); + + return Jss; +}(); + +exports['default'] = Jss; + +/***/ }), +/* 99 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBrowser", function() { return isBrowser; }); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - 'use strict'; +var isBrowser = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && document.nodeType === 9; - Object.defineProperty(exports, "__esModule", { - value: true - }); +/* harmony default export */ __webpack_exports__["default"] = (isBrowser); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _toCss = __webpack_require__(12); +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _warning = __webpack_require__(11); + +var _warning2 = _interopRequireDefault(_warning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var PluginsRegistry = function () { + function PluginsRegistry() { + _classCallCheck(this, PluginsRegistry); + + this.hooks = { + onCreateRule: [], + onProcessRule: [], + onProcessStyle: [], + onProcessSheet: [], + onChangeValue: [] + + /** + * Call `onCreateRule` hooks and return an object if returned by a hook. + */ + }; + } + + _createClass(PluginsRegistry, [{ + key: 'onCreateRule', + value: function onCreateRule(name, decl, options) { + for (var i = 0; i < this.hooks.onCreateRule.length; i++) { + var rule = this.hooks.onCreateRule[i](name, decl, options); + if (rule) return rule; + } + return null; + } + + /** + * Call `onProcessRule` hooks. + */ + + }, { + key: 'onProcessRule', + value: function onProcessRule(rule) { + if (rule.isProcessed) return; + var sheet = rule.options.sheet; + + for (var i = 0; i < this.hooks.onProcessRule.length; i++) { + this.hooks.onProcessRule[i](rule, sheet); + } + + // $FlowFixMe + if (rule.style) this.onProcessStyle(rule.style, rule, sheet); + + rule.isProcessed = true; + } + + /** + * Call `onProcessStyle` hooks. + */ + + }, { + key: 'onProcessStyle', + value: function onProcessStyle(style, rule, sheet) { + var nextStyle = style; + + for (var i = 0; i < this.hooks.onProcessStyle.length; i++) { + nextStyle = this.hooks.onProcessStyle[i](nextStyle, rule, sheet); + // $FlowFixMe + rule.style = nextStyle; + } + } + + /** + * Call `onProcessSheet` hooks. + */ + + }, { + key: 'onProcessSheet', + value: function onProcessSheet(sheet) { + for (var i = 0; i < this.hooks.onProcessSheet.length; i++) { + this.hooks.onProcessSheet[i](sheet); + } + } + + /** + * Call `onChangeValue` hooks. + */ + + }, { + key: 'onChangeValue', + value: function onChangeValue(value, prop, rule) { + var processedValue = value; + for (var i = 0; i < this.hooks.onChangeValue.length; i++) { + processedValue = this.hooks.onChangeValue[i](processedValue, prop, rule); + } + return processedValue; + } + + /** + * Register a plugin. + * If function is passed, it is a shortcut for `{onProcessRule}`. + */ + + }, { + key: 'use', + value: function use(plugin) { + for (var name in plugin) { + if (this.hooks[name]) this.hooks[name].push(plugin[name]);else (0, _warning2['default'])(false, '[JSS] Unknown hook "%s".', name); + } + } + }]); + + return PluginsRegistry; +}(); + +exports['default'] = PluginsRegistry; + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { - var _toCss2 = _interopRequireDefault(_toCss); +"use strict"; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +Object.defineProperty(exports, "__esModule", { + value: true +}); - var ViewportRule = function () { - function ViewportRule(key, style, options) { - _classCallCheck(this, ViewportRule); +var _SimpleRule = __webpack_require__(102); - this.type = 'viewport'; - this.isProcessed = false; +var _SimpleRule2 = _interopRequireDefault(_SimpleRule); - this.key = key; - this.style = style; - this.options = options; - } +var _KeyframesRule = __webpack_require__(103); - /** - * Generates a CSS string. - */ +var _KeyframesRule2 = _interopRequireDefault(_KeyframesRule); +var _ConditionalRule = __webpack_require__(104); - _createClass(ViewportRule, [{ - key: 'toString', - value: function toString(options) { - return (0, _toCss2['default'])(this.key, this.style, options); - } - }]); +var _ConditionalRule2 = _interopRequireDefault(_ConditionalRule); - return ViewportRule; - }(); +var _FontFaceRule = __webpack_require__(105); - exports['default'] = ViewportRule; +var _FontFaceRule2 = _interopRequireDefault(_FontFaceRule); -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { +var _ViewportRule = __webpack_require__(106); - 'use strict'; +var _ViewportRule2 = _interopRequireDefault(_ViewportRule); - Object.defineProperty(exports, "__esModule", { - value: true - }); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _isObservable = __webpack_require__(15); +var classes = { + '@charset': _SimpleRule2['default'], + '@import': _SimpleRule2['default'], + '@namespace': _SimpleRule2['default'], + '@keyframes': _KeyframesRule2['default'], + '@media': _ConditionalRule2['default'], + '@supports': _ConditionalRule2['default'], + '@font-face': _FontFaceRule2['default'], + '@viewport': _ViewportRule2['default'], + '@-ms-viewport': _ViewportRule2['default'] - var _isObservable2 = _interopRequireDefault(_isObservable); + /** + * Generate plugins which will register all rules. + */ +}; +exports['default'] = Object.keys(classes).map(function (key) { + // https://jsperf.com/indexof-vs-substr-vs-regex-at-the-beginning-3 + var re = new RegExp('^' + key); + var onCreateRule = function onCreateRule(name, decl, options) { + return re.test(name) ? new classes[key](name, decl, options) : null; + }; + return { onCreateRule: onCreateRule }; +}); - var _StyleRule = __webpack_require__(11); +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { - var _StyleRule2 = _interopRequireDefault(_StyleRule); +"use strict"; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - exports['default'] = { - onProcessRule: function onProcessRule(rule) { - if (!(rule instanceof _StyleRule2['default'])) return; - var style = rule.style; +Object.defineProperty(exports, "__esModule", { + value: true +}); - var _loop = function _loop(prop) { - var value = style[prop]; - if (!(0, _isObservable2['default'])(value)) return 'continue'; - value.subscribe({ - next: function next(nextValue) { - // $FlowFixMe - rule.prop(prop, nextValue); - } - }); - }; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - for (var prop in style) { - var _ret = _loop(prop); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - if (_ret === 'continue') continue; - } - } - }; +var SimpleRule = function () { + function SimpleRule(key, value, options) { + _classCallCheck(this, SimpleRule); -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { + this.type = 'simple'; + this.isProcessed = false; - 'use strict'; + this.key = key; + this.value = value; + this.options = options; + } - Object.defineProperty(exports, "__esModule", { - value: true - }); + /** + * Generates a CSS string. + */ + // eslint-disable-next-line no-unused-vars - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _warning = __webpack_require__(7); + _createClass(SimpleRule, [{ + key: 'toString', + value: function toString(options) { + if (Array.isArray(this.value)) { + var str = ''; + for (var index = 0; index < this.value.length; index++) { + str += this.key + ' ' + this.value[index] + ';'; + if (this.value[index + 1]) str += '\n'; + } + return str; + } - var _warning2 = _interopRequireDefault(_warning); + return this.key + ' ' + this.value + ';'; + } + }]); - var _sheets = __webpack_require__(21); + return SimpleRule; +}(); - var _sheets2 = _interopRequireDefault(_sheets); +exports['default'] = SimpleRule; - var _StyleRule = __webpack_require__(11); +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { - var _StyleRule2 = _interopRequireDefault(_StyleRule); +"use strict"; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +Object.defineProperty(exports, "__esModule", { + value: true +}); - /** - * Get a style property. - */ - function getStyle(cssRule, prop) { - try { - return cssRule.style.getPropertyValue(prop); - } catch (err) { - // IE may throw if property is unknown. - return ''; - } - } +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - /** - * Set a style property. - */ - function setStyle(cssRule, prop, value) { - try { - cssRule.style.setProperty(prop, value); - } catch (err) { - // IE may throw if property is unknown. - return false; - } - return true; - } +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var CSSRuleTypes = { - STYLE_RULE: 1, - KEYFRAMES_RULE: 7 - - /** - * Get the CSS Rule key. - */ - - };var getKey = function () { - var extractKey = function extractKey(cssText) { - var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - return cssText.substr(from, cssText.indexOf('{') - 1); - }; - - return function (cssRule) { - if (cssRule.type === CSSRuleTypes.STYLE_RULE) return cssRule.selectorText; - if (cssRule.type === CSSRuleTypes.KEYFRAMES_RULE) { - var name = cssRule.name; - - if (name) return '@keyframes ' + name; - - // There is no rule.name in the following browsers: - // - IE 9 - // - Safari 7.1.8 - // - Mobile Safari 9.0.0 - var cssText = cssRule.cssText; - - return '@' + extractKey(cssText, cssText.indexOf('keyframes')); - } - - // Conditionals. - return extractKey(cssRule.cssText); - }; - }(); - - /** - * Set the selector. - */ - function setSelector(cssRule, selectorText) { - cssRule.selectorText = selectorText; - - // Return false if setter was not successful. - // Currently works in chrome only. - return cssRule.selectorText === selectorText; - } +var _RuleList = __webpack_require__(26); - /** - * Gets the `head` element upon the first call and caches it. - */ - var getHead = function () { - var head = void 0; - return function () { - if (!head) head = document.head || document.getElementsByTagName('head')[0]; - return head; - }; - }(); - - /** - * Gets a map of rule keys, where the property is an unescaped key and value - * is a potentially escaped one. - * It is used to identify CSS rules and the corresponding JSS rules. As an identifier - * for CSSStyleRule we normally use `selectorText`. Though if original selector text - * contains escaped code points e.g. `:not(#\\20)`, CSSOM will compile it to `:not(# )` - * and so CSS rule's `selectorText` won't match JSS rule selector. - * - * https://www.w3.org/International/questions/qa-escapes#cssescapes - */ - var getUnescapedKeysMap = function () { - var style = void 0; - var isAttached = false; - - return function (rules) { - var map = {}; - // https://github.com/facebook/flow/issues/2696 - if (!style) style = document.createElement('style'); - for (var i = 0; i < rules.length; i++) { - var rule = rules[i]; - if (!(rule instanceof _StyleRule2['default'])) continue; - var selector = rule.selector; - // Only unescape selector over CSSOM if it contains a back slash. - - if (selector && selector.indexOf('\\') !== -1) { - // Lazilly attach when needed. - if (!isAttached) { - getHead().appendChild(style); - isAttached = true; - } - style.textContent = selector + ' {}'; - var _style = style, - sheet = _style.sheet; - - if (sheet) { - var cssRules = sheet.cssRules; - - if (cssRules) map[cssRules[0].selectorText] = rule.key; - } - } - } - if (isAttached) { - getHead().removeChild(style); - isAttached = false; - } - return map; - }; - }(); - - /** - * Find attached sheet with an index higher than the passed one. - */ - function findHigherSheet(registry, options) { - for (var i = 0; i < registry.length; i++) { - var sheet = registry[i]; - if (sheet.attached && sheet.options.index > options.index && sheet.options.insertionPoint === options.insertionPoint) { - return sheet; - } - } - return null; - } +var _RuleList2 = _interopRequireDefault(_RuleList); - /** - * Find attached sheet with the highest index. - */ - function findHighestSheet(registry, options) { - for (var i = registry.length - 1; i >= 0; i--) { - var sheet = registry[i]; - if (sheet.attached && sheet.options.insertionPoint === options.insertionPoint) { - return sheet; - } - } - return null; - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - /** - * Find a comment with "jss" inside. - */ - function findCommentNode(text) { - var head = getHead(); - for (var i = 0; i < head.childNodes.length; i++) { - var node = head.childNodes[i]; - if (node.nodeType === 8 && node.nodeValue.trim() === text) { - return node; - } - } - return null; - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - /** - * Find a node before which we can insert the sheet. - */ - function findPrevNode(options) { - var registry = _sheets2['default'].registry; +/** + * Rule for @keyframes + */ +var KeyframesRule = function () { + function KeyframesRule(key, frames, options) { + _classCallCheck(this, KeyframesRule); + this.type = 'keyframes'; + this.isProcessed = false; - if (registry.length > 0) { - // Try to insert before the next higher sheet. - var sheet = findHigherSheet(registry, options); - if (sheet) return sheet.renderer.element; + this.key = key; + this.options = options; + this.rules = new _RuleList2['default'](_extends({}, options, { parent: this })); - // Otherwise insert after the last attached. - sheet = findHighestSheet(registry, options); - if (sheet) return sheet.renderer.element.nextElementSibling; - } + for (var name in frames) { + this.rules.add(name, frames[name], _extends({}, this.options, { + parent: this, + selector: name + })); + } - // Try to find a comment placeholder if registry is empty. - var insertionPoint = options.insertionPoint; + this.rules.process(); + } - if (insertionPoint && typeof insertionPoint === 'string') { - var comment = findCommentNode(insertionPoint); - if (comment) return comment.nextSibling; - // If user specifies an insertion point and it can't be found in the document - - // bad specificity issues may appear. - (0, _warning2['default'])(insertionPoint === 'jss', '[JSS] Insertion point "%s" not found.', insertionPoint); - } + /** + * Generates a CSS string. + */ - return null; - } - /** - * Insert style element into the DOM. - */ - function insertStyle(style, options) { - var insertionPoint = options.insertionPoint; + _createClass(KeyframesRule, [{ + key: 'toString', + value: function toString() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { indent: 1 }; - var prevNode = findPrevNode(options); + var inner = this.rules.toString(options); + if (inner) inner += '\n'; + return this.key + ' {\n' + inner + '}'; + } + }]); - if (prevNode) { - var parentNode = prevNode.parentNode; + return KeyframesRule; +}(); - if (parentNode) parentNode.insertBefore(style, prevNode); - return; - } +exports['default'] = KeyframesRule; - // Works with iframes and any node types. - if (insertionPoint && typeof insertionPoint.nodeType === 'number') { - // https://stackoverflow.com/questions/41328728/force-casting-in-flow - var insertionPointElement = insertionPoint; - var _parentNode = insertionPointElement.parentNode; +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { - if (_parentNode) _parentNode.insertBefore(style, insertionPointElement.nextSibling);else (0, _warning2['default'])(false, '[JSS] Insertion point is not in the DOM.'); - return; - } +"use strict"; - getHead().insertBefore(style, prevNode); - } - var DomRenderer = function () { - function DomRenderer(sheet) { - _classCallCheck(this, DomRenderer); - - this.getStyle = getStyle; - this.setStyle = setStyle; - this.setSelector = setSelector; - this.getKey = getKey; - this.getUnescapedKeysMap = getUnescapedKeysMap; - this.hasInsertedRules = false; - - // There is no sheet when the renderer is used from a standalone StyleRule. - if (sheet) _sheets2['default'].add(sheet); - - this.sheet = sheet; - - var _ref = this.sheet ? this.sheet.options : {}, - media = _ref.media, - meta = _ref.meta, - element = _ref.element; - - this.element = element || document.createElement('style'); - this.element.type = 'text/css'; - this.element.setAttribute('data-jss', ''); - if (media) this.element.setAttribute('media', media); - if (meta) this.element.setAttribute('data-meta', meta); - } - - /** - * Insert style element into render tree. - */ - - - // HTMLStyleElement needs fixing https://github.com/facebook/flow/issues/2696 - - - _createClass(DomRenderer, [{ - key: 'attach', - value: function attach() { - // In the case the element node is external and it is already in the DOM. - if (this.element.parentNode || !this.sheet) return; - - // When rules are inserted using `insertRule` API, after `sheet.detach().attach()` - // browsers remove those rules. - // TODO figure out if its a bug and if it is known. - // Workaround is to redeploy the sheet before attaching as a string. - if (this.hasInsertedRules) { - this.deploy(); - this.hasInsertedRules = false; - } - - insertStyle(this.element, this.sheet.options); - } - - /** - * Remove style element from render tree. - */ - - }, { - key: 'detach', - value: function detach() { - this.element.parentNode.removeChild(this.element); - } - - /** - * Inject CSS string into element. - */ - - }, { - key: 'deploy', - value: function deploy() { - if (!this.sheet) return; - this.element.textContent = '\n' + this.sheet.toString() + '\n'; - } - - /** - * Insert a rule into element. - */ - - }, { - key: 'insertRule', - value: function insertRule(rule, index) { - var sheet = this.element.sheet; - var cssRules = sheet.cssRules; - - var str = rule.toString(); - if (!index) index = cssRules.length; - - if (!str) return false; - - try { - sheet.insertRule(str, index); - } catch (err) { - (0, _warning2['default'])(false, '[JSS] Can not insert an unsupported rule \n\r%s', rule); - return false; - } - this.hasInsertedRules = true; - - return cssRules[index]; - } - - /** - * Delete a rule. - */ - - }, { - key: 'deleteRule', - value: function deleteRule(cssRule) { - var sheet = this.element.sheet; - - var index = this.indexOf(cssRule); - if (index === -1) return false; - sheet.deleteRule(index); - return true; - } - - /** - * Get index of a CSS Rule. - */ - - }, { - key: 'indexOf', - value: function indexOf(cssRule) { - var cssRules = this.element.sheet.cssRules; - - for (var _index = 0; _index < cssRules.length; _index++) { - if (cssRule === cssRules[_index]) return _index; - } - return -1; - } - - /** - * Generate a new CSS rule and replace the existing one. - */ - - }, { - key: 'replaceRule', - value: function replaceRule(cssRule, rule) { - var index = this.indexOf(cssRule); - var newCssRule = this.insertRule(rule, index); - this.element.sheet.deleteRule(index); - return newCssRule; - } - - /** - * Get all rules elements. - */ - - }, { - key: 'getRules', - value: function getRules() { - return this.element.sheet.cssRules; - } - }]); - - return DomRenderer; - }(); - - exports['default'] = DomRenderer; - -/***/ }, -/* 35 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - /* eslint-disable class-methods-use-this */ - - /** - * Rendering backend to do nothing in nodejs. - */ - var VirtualRenderer = function () { - function VirtualRenderer() { - _classCallCheck(this, VirtualRenderer); - } - - _createClass(VirtualRenderer, [{ - key: 'setStyle', - value: function setStyle() { - return true; - } - }, { - key: 'getStyle', - value: function getStyle() { - return ''; - } - }, { - key: 'setSelector', - value: function setSelector() { - return true; - } - }, { - key: 'getKey', - value: function getKey() { - return ''; - } - }, { - key: 'attach', - value: function attach() {} - }, { - key: 'detach', - value: function detach() {} - }, { - key: 'deploy', - value: function deploy() {} - }, { - key: 'insertRule', - value: function insertRule() { - return false; - } - }, { - key: 'deleteRule', - value: function deleteRule() { - return true; - } - }, { - key: 'replaceRule', - value: function replaceRule() { - return false; - } - }, { - key: 'getRules', - value: function getRules() {} - }, { - key: 'indexOf', - value: function indexOf() { - return -1; - } - }]); - - return VirtualRenderer; - }(); - - exports['default'] = VirtualRenderer; - -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { +Object.defineProperty(exports, "__esModule", { + value: true +}); - 'use strict'; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _jssTemplate = __webpack_require__(37); +var _RuleList = __webpack_require__(26); - var _jssTemplate2 = _interopRequireDefault(_jssTemplate); +var _RuleList2 = _interopRequireDefault(_RuleList); - var _jssGlobal = __webpack_require__(39); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _jssGlobal2 = _interopRequireDefault(_jssGlobal); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var _jssExtend = __webpack_require__(40); +/** + * Conditional rule for @media, @supports + */ +var ConditionalRule = function () { + function ConditionalRule(key, styles, options) { + _classCallCheck(this, ConditionalRule); - var _jssExtend2 = _interopRequireDefault(_jssExtend); + this.type = 'conditional'; + this.isProcessed = false; - var _jssNested = __webpack_require__(41); + this.key = key; + this.options = options; + this.rules = new _RuleList2['default'](_extends({}, options, { parent: this })); - var _jssNested2 = _interopRequireDefault(_jssNested); + for (var name in styles) { + this.rules.add(name, styles[name]); + } - var _jssCompose = __webpack_require__(42); + this.rules.process(); + } - var _jssCompose2 = _interopRequireDefault(_jssCompose); + /** + * Get a rule. + */ - var _jssCamelCase = __webpack_require__(43); - var _jssCamelCase2 = _interopRequireDefault(_jssCamelCase); + _createClass(ConditionalRule, [{ + key: 'getRule', + value: function getRule(name) { + return this.rules.get(name); + } - var _jssDefaultUnit = __webpack_require__(44); + /** + * Get index of a rule. + */ - var _jssDefaultUnit2 = _interopRequireDefault(_jssDefaultUnit); + }, { + key: 'indexOf', + value: function indexOf(rule) { + return this.rules.indexOf(rule); + } - var _jssExpand = __webpack_require__(46); + /** + * Create and register rule, run plugins. + */ - var _jssExpand2 = _interopRequireDefault(_jssExpand); + }, { + key: 'addRule', + value: function addRule(name, style, options) { + var rule = this.rules.add(name, style, options); + this.options.jss.plugins.onProcessRule(rule); + return rule; + } - var _jssVendorPrefixer = __webpack_require__(48); + /** + * Generates a CSS string. + */ - var _jssVendorPrefixer2 = _interopRequireDefault(_jssVendorPrefixer); + }, { + key: 'toString', + value: function toString() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { indent: 1 }; - var _jssPropsSort = __webpack_require__(55); + var inner = this.rules.toString(options); + return inner ? this.key + ' {\n' + inner + '\n}' : ''; + } + }]); - var _jssPropsSort2 = _interopRequireDefault(_jssPropsSort); + return ConditionalRule; +}(); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +exports['default'] = ConditionalRule; - exports.default = function () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return { - plugins: [(0, _jssTemplate2.default)(options.template), (0, _jssGlobal2.default)(options.global), (0, _jssExtend2.default)(options.extend), (0, _jssNested2.default)(options.nested), (0, _jssCompose2.default)(options.compose), (0, _jssCamelCase2.default)(options.camelCase), (0, _jssDefaultUnit2.default)(options.defaultUnit), (0, _jssExpand2.default)(options.expand), (0, _jssVendorPrefixer2.default)(options.vendorPrefixer), (0, _jssPropsSort2.default)(options.propsSort)] - }; - }; +/***/ }), +/* 105 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - 'use strict'; - Object.defineProperty(exports, "__esModule", { - value: true - }); +Object.defineProperty(exports, "__esModule", { + value: true +}); - var _parse = __webpack_require__(38); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _parse2 = _interopRequireDefault(_parse); +var _toCss = __webpack_require__(39); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _toCss2 = _interopRequireDefault(_toCss); - var onProcessRule = function onProcessRule(rule) { - if (typeof rule.style === 'string') { - rule.style = (0, _parse2['default'])(rule.style); - } - }; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - exports['default'] = function () { - return { onProcessRule: onProcessRule }; - }; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/***/ }, -/* 38 */ -/***/ function(module, exports, __webpack_require__) { +var FontFaceRule = function () { + function FontFaceRule(key, style, options) { + _classCallCheck(this, FontFaceRule); - 'use strict'; + this.type = 'font-face'; + this.isProcessed = false; - Object.defineProperty(exports, "__esModule", { - value: true - }); + this.key = key; + this.style = style; + this.options = options; + } - var _warning = __webpack_require__(7); + /** + * Generates a CSS string. + */ - var _warning2 = _interopRequireDefault(_warning); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + _createClass(FontFaceRule, [{ + key: 'toString', + value: function toString(options) { + if (Array.isArray(this.style)) { + var str = ''; + for (var index = 0; index < this.style.length; index++) { + str += (0, _toCss2['default'])(this.key, this.style[index]); + if (this.style[index + 1]) str += '\n'; + } + return str; + } - var semiWithNl = /;\n/; + return (0, _toCss2['default'])(this.key, this.style, options); + } + }]); - /** - * Naive CSS parser. - * - Supports only rule body (no selectors) - * - Requires semicolon and new line after the value (except of last line) - * - No nested rules support - */ + return FontFaceRule; +}(); - exports['default'] = function (cssText) { - var style = {}; - var split = cssText.split(semiWithNl); - for (var i = 0; i < split.length; i++) { - var decl = split[i]; +exports['default'] = FontFaceRule; - if (!decl) continue; - var colonIndex = decl.indexOf(':'); - if (colonIndex === -1) { - (0, _warning2['default'])(false, 'Malformed CSS string "%s"', decl); - continue; - } - var prop = decl.substr(0, colonIndex).trim(); - var value = decl.substr(colonIndex + 1).trim(); - style[prop] = value; - } - return style; - }; +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 39 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - 'use strict'; - Object.defineProperty(exports, "__esModule", { - value: true - }); +Object.defineProperty(exports, "__esModule", { + value: true +}); - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _toCss = __webpack_require__(39); - exports['default'] = jssGlobal; +var _toCss2 = _interopRequireDefault(_toCss); - var _jss = __webpack_require__(3); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var propKey = '@global'; - var prefixKey = '@global '; - - var GlobalContainerRule = function () { - function GlobalContainerRule(key, styles, options) { - _classCallCheck(this, GlobalContainerRule); - - this.type = 'global'; - - this.key = key; - this.options = options; - this.rules = new _jss.RuleList(_extends({}, options, { - parent: this - })); - - for (var selector in styles) { - this.rules.add(selector, styles[selector], { selector: selector }); - } - - this.rules.process(); - } - - /** - * Get a rule. - */ - - - _createClass(GlobalContainerRule, [{ - key: 'getRule', - value: function getRule(name) { - return this.rules.get(name); - } - - /** - * Create and register rule, run plugins. - */ - - }, { - key: 'addRule', - value: function addRule(name, style, options) { - var rule = this.rules.add(name, style, options); - this.options.jss.plugins.onProcessRule(rule); - return rule; - } - - /** - * Get index of a rule. - */ - - }, { - key: 'indexOf', - value: function indexOf(rule) { - return this.rules.indexOf(rule); - } - - /** - * Generates a CSS string. - */ - - }, { - key: 'toString', - value: function toString() { - return this.rules.toString(); - } - }]); - - return GlobalContainerRule; - }(); - - var GlobalPrefixedRule = function () { - function GlobalPrefixedRule(name, style, options) { - _classCallCheck(this, GlobalPrefixedRule); - - this.name = name; - this.options = options; - var selector = name.substr(prefixKey.length); - this.rule = options.jss.createRule(selector, style, _extends({}, options, { - parent: this, - selector: selector - })); - } - - _createClass(GlobalPrefixedRule, [{ - key: 'toString', - value: function toString(options) { - return this.rule.toString(options); - } - }]); - - return GlobalPrefixedRule; - }(); - - var separatorRegExp = /\s*,\s*/g; - - function addScope(selector, scope) { - var parts = selector.split(separatorRegExp); - var scoped = ''; - for (var i = 0; i < parts.length; i++) { - scoped += scope + ' ' + parts[i].trim(); - if (parts[i + 1]) scoped += ', '; - } - return scoped; - } +var ViewportRule = function () { + function ViewportRule(key, style, options) { + _classCallCheck(this, ViewportRule); - function handleNestedGlobalContainerRule(rule) { - var options = rule.options, - style = rule.style; + this.type = 'viewport'; + this.isProcessed = false; - var rules = style[propKey]; + this.key = key; + this.style = style; + this.options = options; + } - if (!rules) return; + /** + * Generates a CSS string. + */ - for (var name in rules) { - options.sheet.addRule(name, rules[name], _extends({}, options, { - selector: addScope(name, rule.selector) - })); - } - delete style[propKey]; - } + _createClass(ViewportRule, [{ + key: 'toString', + value: function toString(options) { + return (0, _toCss2['default'])(this.key, this.style, options); + } + }]); - function handlePrefixedGlobalRule(rule) { - var options = rule.options, - style = rule.style; + return ViewportRule; +}(); - for (var prop in style) { - if (prop.substr(0, propKey.length) !== propKey) continue; +exports['default'] = ViewportRule; - var selector = addScope(prop.substr(propKey.length), rule.selector); - options.sheet.addRule(selector, style[prop], _extends({}, options, { - selector: selector - })); - delete style[prop]; - } - } +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { - /** - * Convert nested rules to separate, remove them from original styles. - * - * @param {Rule} rule - * @api public - */ - function jssGlobal() { - function onCreateRule(name, styles, options) { - if (name === propKey) { - return new GlobalContainerRule(name, styles, options); - } +"use strict"; - if (name[0] === '@' && name.substr(0, prefixKey.length) === prefixKey) { - return new GlobalPrefixedRule(name, styles, options); - } - var parent = options.parent; +Object.defineProperty(exports, "__esModule", { + value: true +}); +var _isObservable = __webpack_require__(18); - if (parent) { - if (parent.type === 'global' || parent.options.parent.type === 'global') { - options.global = true; - } - } +var _isObservable2 = _interopRequireDefault(_isObservable); - if (options.global) options.selector = name; +var _StyleRule = __webpack_require__(19); - return null; - } +var _StyleRule2 = _interopRequireDefault(_StyleRule); - function onProcessRule(rule) { - if (rule.type !== 'style') return; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - handleNestedGlobalContainerRule(rule); - handlePrefixedGlobalRule(rule); - } +exports['default'] = { + onProcessRule: function onProcessRule(rule) { + if (!(rule instanceof _StyleRule2['default'])) return; + var style = rule.style; - return { onCreateRule: onCreateRule, onProcessRule: onProcessRule }; - } + var _loop = function _loop(prop) { + var value = style[prop]; + if (!(0, _isObservable2['default'])(value)) return 'continue'; + value.subscribe({ + next: function next(nextValue) { + // $FlowFixMe + rule.prop(prop, nextValue); + } + }); + }; -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - - exports['default'] = jssExtend; - - var _warning = __webpack_require__(7); - - var _warning2 = _interopRequireDefault(_warning); - - var _isObservable = __webpack_require__(15); - - var _isObservable2 = _interopRequireDefault(_isObservable); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var isObject = function isObject(obj) { - return obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && !Array.isArray(obj) && !(0, _isObservable2['default'])(obj); - }; - - /** - * Recursively extend styles. - */ - function extend(style, rule, sheet) { - var newStyle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; - - if (typeof style.extend === 'string') { - if (sheet) { - var refRule = sheet.getRule(style.extend); - if (refRule) { - if (refRule === rule) (0, _warning2['default'])(false, '[JSS] A rule tries to extend itself \r\n%s', rule);else if (refRule.options.parent) { - var originalStyle = refRule.options.parent.rules.raw[style.extend]; - extend(originalStyle, rule, sheet, newStyle); - } - } - } - } else if (Array.isArray(style.extend)) { - for (var index = 0; index < style.extend.length; index++) { - extend(style.extend[index], rule, sheet, newStyle); - } - } else { - for (var prop in style.extend) { - if (prop === 'extend') { - extend(style.extend.extend, rule, sheet, newStyle); - } else if (isObject(style.extend[prop])) { - if (!newStyle[prop]) newStyle[prop] = {}; - extend(style.extend[prop], rule, sheet, newStyle[prop]); - } else { - newStyle[prop] = style.extend[prop]; - } - } - } - // Copy base style. - for (var _prop in style) { - if (_prop === 'extend') continue; - if (isObject(newStyle[_prop]) && isObject(style[_prop])) { - extend(style[_prop], rule, sheet, newStyle[_prop]); - } else if (isObject(style[_prop])) { - newStyle[_prop] = extend(style[_prop], rule, sheet); - } else { - newStyle[_prop] = style[_prop]; - } - } - - return newStyle; - } + for (var prop in style) { + var _ret = _loop(prop); - /** - * Handle `extend` property. - * - * @param {Rule} rule - * @api public - */ - function jssExtend() { - function onProcessStyle(style, rule, sheet) { - return style.extend ? extend(style, rule, sheet) : style; - } - - return { onProcessStyle: onProcessStyle }; - } + if (_ret === 'continue') continue; + } + } +}; -/***/ }, -/* 41 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _warning = __webpack_require__(11); + +var _warning2 = _interopRequireDefault(_warning); + +var _sheets = __webpack_require__(40); + +var _sheets2 = _interopRequireDefault(_sheets); + +var _StyleRule = __webpack_require__(19); + +var _StyleRule2 = _interopRequireDefault(_StyleRule); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Get a style property. + */ +function getStyle(cssRule, prop) { + try { + return cssRule.style.getPropertyValue(prop); + } catch (err) { + // IE may throw if property is unknown. + return ''; + } +} + +/** + * Set a style property. + */ +function setStyle(cssRule, prop, value) { + try { + cssRule.style.setProperty(prop, value); + } catch (err) { + // IE may throw if property is unknown. + return false; + } + return true; +} + +var CSSRuleTypes = { + STYLE_RULE: 1, + KEYFRAMES_RULE: 7 + + /** + * Get the CSS Rule key. + */ + +};var getKey = function () { + var extractKey = function extractKey(cssText) { + var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + return cssText.substr(from, cssText.indexOf('{') - 1); + }; + + return function (cssRule) { + if (cssRule.type === CSSRuleTypes.STYLE_RULE) return cssRule.selectorText; + if (cssRule.type === CSSRuleTypes.KEYFRAMES_RULE) { + var name = cssRule.name; + + if (name) return '@keyframes ' + name; + + // There is no rule.name in the following browsers: + // - IE 9 + // - Safari 7.1.8 + // - Mobile Safari 9.0.0 + var cssText = cssRule.cssText; + + return '@' + extractKey(cssText, cssText.indexOf('keyframes')); + } + + // Conditionals. + return extractKey(cssRule.cssText); + }; +}(); + +/** + * Set the selector. + */ +function setSelector(cssRule, selectorText) { + cssRule.selectorText = selectorText; + + // Return false if setter was not successful. + // Currently works in chrome only. + return cssRule.selectorText === selectorText; +} + +/** + * Gets the `head` element upon the first call and caches it. + */ +var getHead = function () { + var head = void 0; + return function () { + if (!head) head = document.head || document.getElementsByTagName('head')[0]; + return head; + }; +}(); + +/** + * Gets a map of rule keys, where the property is an unescaped key and value + * is a potentially escaped one. + * It is used to identify CSS rules and the corresponding JSS rules. As an identifier + * for CSSStyleRule we normally use `selectorText`. Though if original selector text + * contains escaped code points e.g. `:not(#\\20)`, CSSOM will compile it to `:not(# )` + * and so CSS rule's `selectorText` won't match JSS rule selector. + * + * https://www.w3.org/International/questions/qa-escapes#cssescapes + */ +var getUnescapedKeysMap = function () { + var style = void 0; + var isAttached = false; + + return function (rules) { + var map = {}; + // https://github.com/facebook/flow/issues/2696 + if (!style) style = document.createElement('style'); + for (var i = 0; i < rules.length; i++) { + var rule = rules[i]; + if (!(rule instanceof _StyleRule2['default'])) continue; + var selector = rule.selector; + // Only unescape selector over CSSOM if it contains a back slash. + + if (selector && selector.indexOf('\\') !== -1) { + // Lazilly attach when needed. + if (!isAttached) { + getHead().appendChild(style); + isAttached = true; + } + style.textContent = selector + ' {}'; + var _style = style, + sheet = _style.sheet; + + if (sheet) { + var cssRules = sheet.cssRules; + + if (cssRules) map[cssRules[0].selectorText] = rule.key; + } + } + } + if (isAttached) { + getHead().removeChild(style); + isAttached = false; + } + return map; + }; +}(); + +/** + * Find attached sheet with an index higher than the passed one. + */ +function findHigherSheet(registry, options) { + for (var i = 0; i < registry.length; i++) { + var sheet = registry[i]; + if (sheet.attached && sheet.options.index > options.index && sheet.options.insertionPoint === options.insertionPoint) { + return sheet; + } + } + return null; +} + +/** + * Find attached sheet with the highest index. + */ +function findHighestSheet(registry, options) { + for (var i = registry.length - 1; i >= 0; i--) { + var sheet = registry[i]; + if (sheet.attached && sheet.options.insertionPoint === options.insertionPoint) { + return sheet; + } + } + return null; +} + +/** + * Find a comment with "jss" inside. + */ +function findCommentNode(text) { + var head = getHead(); + for (var i = 0; i < head.childNodes.length; i++) { + var node = head.childNodes[i]; + if (node.nodeType === 8 && node.nodeValue.trim() === text) { + return node; + } + } + return null; +} + +/** + * Find a node before which we can insert the sheet. + */ +function findPrevNode(options) { + var registry = _sheets2['default'].registry; + + + if (registry.length > 0) { + // Try to insert before the next higher sheet. + var sheet = findHigherSheet(registry, options); + if (sheet) return sheet.renderer.element; + + // Otherwise insert after the last attached. + sheet = findHighestSheet(registry, options); + if (sheet) return sheet.renderer.element.nextElementSibling; + } + + // Try to find a comment placeholder if registry is empty. + var insertionPoint = options.insertionPoint; + + if (insertionPoint && typeof insertionPoint === 'string') { + var comment = findCommentNode(insertionPoint); + if (comment) return comment.nextSibling; + // If user specifies an insertion point and it can't be found in the document - + // bad specificity issues may appear. + (0, _warning2['default'])(insertionPoint === 'jss', '[JSS] Insertion point "%s" not found.', insertionPoint); + } + + return null; +} + +/** + * Insert style element into the DOM. + */ +function insertStyle(style, options) { + var insertionPoint = options.insertionPoint; + + var prevNode = findPrevNode(options); + + if (prevNode) { + var parentNode = prevNode.parentNode; + + if (parentNode) parentNode.insertBefore(style, prevNode); + return; + } + + // Works with iframes and any node types. + if (insertionPoint && typeof insertionPoint.nodeType === 'number') { + // https://stackoverflow.com/questions/41328728/force-casting-in-flow + var insertionPointElement = insertionPoint; + var _parentNode = insertionPointElement.parentNode; + + if (_parentNode) _parentNode.insertBefore(style, insertionPointElement.nextSibling);else (0, _warning2['default'])(false, '[JSS] Insertion point is not in the DOM.'); + return; + } + + getHead().insertBefore(style, prevNode); +} + +var DomRenderer = function () { + function DomRenderer(sheet) { + _classCallCheck(this, DomRenderer); + + this.getStyle = getStyle; + this.setStyle = setStyle; + this.setSelector = setSelector; + this.getKey = getKey; + this.getUnescapedKeysMap = getUnescapedKeysMap; + this.hasInsertedRules = false; + + // There is no sheet when the renderer is used from a standalone StyleRule. + if (sheet) _sheets2['default'].add(sheet); + + this.sheet = sheet; + + var _ref = this.sheet ? this.sheet.options : {}, + media = _ref.media, + meta = _ref.meta, + element = _ref.element; + + this.element = element || document.createElement('style'); + this.element.type = 'text/css'; + this.element.setAttribute('data-jss', ''); + if (media) this.element.setAttribute('media', media); + if (meta) this.element.setAttribute('data-meta', meta); + } + + /** + * Insert style element into render tree. + */ + + + // HTMLStyleElement needs fixing https://github.com/facebook/flow/issues/2696 + + + _createClass(DomRenderer, [{ + key: 'attach', + value: function attach() { + // In the case the element node is external and it is already in the DOM. + if (this.element.parentNode || !this.sheet) return; + + // When rules are inserted using `insertRule` API, after `sheet.detach().attach()` + // browsers remove those rules. + // TODO figure out if its a bug and if it is known. + // Workaround is to redeploy the sheet before attaching as a string. + if (this.hasInsertedRules) { + this.deploy(); + this.hasInsertedRules = false; + } + + insertStyle(this.element, this.sheet.options); + } + + /** + * Remove style element from render tree. + */ + + }, { + key: 'detach', + value: function detach() { + this.element.parentNode.removeChild(this.element); + } + + /** + * Inject CSS string into element. + */ + + }, { + key: 'deploy', + value: function deploy() { + if (!this.sheet) return; + this.element.textContent = '\n' + this.sheet.toString() + '\n'; + } + + /** + * Insert a rule into element. + */ + + }, { + key: 'insertRule', + value: function insertRule(rule, index) { + var sheet = this.element.sheet; + var cssRules = sheet.cssRules; + + var str = rule.toString(); + if (!index) index = cssRules.length; + + if (!str) return false; + + try { + sheet.insertRule(str, index); + } catch (err) { + (0, _warning2['default'])(false, '[JSS] Can not insert an unsupported rule \n\r%s', rule); + return false; + } + this.hasInsertedRules = true; + + return cssRules[index]; + } + + /** + * Delete a rule. + */ + + }, { + key: 'deleteRule', + value: function deleteRule(cssRule) { + var sheet = this.element.sheet; + + var index = this.indexOf(cssRule); + if (index === -1) return false; + sheet.deleteRule(index); + return true; + } + + /** + * Get index of a CSS Rule. + */ + + }, { + key: 'indexOf', + value: function indexOf(cssRule) { + var cssRules = this.element.sheet.cssRules; + + for (var _index = 0; _index < cssRules.length; _index++) { + if (cssRule === cssRules[_index]) return _index; + } + return -1; + } + + /** + * Generate a new CSS rule and replace the existing one. + */ + + }, { + key: 'replaceRule', + value: function replaceRule(cssRule, rule) { + var index = this.indexOf(cssRule); + var newCssRule = this.insertRule(rule, index); + this.element.sheet.deleteRule(index); + return newCssRule; + } + + /** + * Get all rules elements. + */ + + }, { + key: 'getRules', + value: function getRules() { + return this.element.sheet.cssRules; + } + }]); + + return DomRenderer; +}(); + +exports['default'] = DomRenderer; + +/***/ }), +/* 109 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/* eslint-disable class-methods-use-this */ + +/** + * Rendering backend to do nothing in nodejs. + */ +var VirtualRenderer = function () { + function VirtualRenderer() { + _classCallCheck(this, VirtualRenderer); + } + + _createClass(VirtualRenderer, [{ + key: 'setStyle', + value: function setStyle() { + return true; + } + }, { + key: 'getStyle', + value: function getStyle() { + return ''; + } + }, { + key: 'setSelector', + value: function setSelector() { + return true; + } + }, { + key: 'getKey', + value: function getKey() { + return ''; + } + }, { + key: 'attach', + value: function attach() {} + }, { + key: 'detach', + value: function detach() {} + }, { + key: 'deploy', + value: function deploy() {} + }, { + key: 'insertRule', + value: function insertRule() { + return false; + } + }, { + key: 'deleteRule', + value: function deleteRule() { + return true; + } + }, { + key: 'replaceRule', + value: function replaceRule() { + return false; + } + }, { + key: 'getRules', + value: function getRules() {} + }, { + key: 'indexOf', + value: function indexOf() { + return -1; + } + }]); + + return VirtualRenderer; +}(); + +exports['default'] = VirtualRenderer; + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { - exports.default = jssNested; +"use strict"; - var _warning = __webpack_require__(7); - var _warning2 = _interopRequireDefault(_warning); +Object.defineProperty(exports, "__esModule", { + value: true +}); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var _jssTemplate = __webpack_require__(111); - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +var _jssTemplate2 = _interopRequireDefault(_jssTemplate); - var separatorRegExp = /\s*,\s*/g; - var parentRegExp = /&/g; - var refRegExp = /\$([\w-]+)/g; +var _jssGlobal = __webpack_require__(113); - /** - * Convert nested rules to separate, remove them from original styles. - * - * @param {Rule} rule - * @api public - */ - function jssNested() { - // Get a function to be used for $ref replacement. - function getReplaceRef(container) { - return function (match, key) { - var rule = container.getRule(key); - if (rule) return rule.selector; - (0, _warning2.default)(false, '[JSS] Could not find the referenced rule %s in %s.', key, container.options.meta || container); - return key; - }; - } +var _jssGlobal2 = _interopRequireDefault(_jssGlobal); - var hasAnd = function hasAnd(str) { - return str.indexOf('&') !== -1; - }; +var _jssExtend = __webpack_require__(114); - function replaceParentRefs(nestedProp, parentProp) { - var parentSelectors = parentProp.split(separatorRegExp); - var nestedSelectors = nestedProp.split(separatorRegExp); +var _jssExtend2 = _interopRequireDefault(_jssExtend); - var result = ''; +var _jssNested = __webpack_require__(115); - for (var i = 0; i < parentSelectors.length; i++) { - var parent = parentSelectors[i]; +var _jssNested2 = _interopRequireDefault(_jssNested); - for (var j = 0; j < nestedSelectors.length; j++) { - var nested = nestedSelectors[j]; - if (result) result += ', '; - // Replace all & by the parent or prefix & with the parent. - result += hasAnd(nested) ? nested.replace(parentRegExp, parent) : parent + ' ' + nested; - } - } +var _jssCompose = __webpack_require__(116); - return result; - } +var _jssCompose2 = _interopRequireDefault(_jssCompose); - function getOptions(rule, container, options) { - // Options has been already created, now we only increase index. - if (options) return _extends({}, options, { index: options.index + 1 }); +var _jssCamelCase = __webpack_require__(117); - var nestingLevel = rule.options.nestingLevel; +var _jssCamelCase2 = _interopRequireDefault(_jssCamelCase); - nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1; +var _jssDefaultUnit = __webpack_require__(118); - return _extends({}, rule.options, { - nestingLevel: nestingLevel, - index: container.indexOf(rule) + 1 - }); - } +var _jssDefaultUnit2 = _interopRequireDefault(_jssDefaultUnit); - function onProcessStyle(style, rule) { - if (rule.type !== 'style') return style; - var container = rule.options.parent; - var options = void 0; - var replaceRef = void 0; - for (var prop in style) { - var isNested = hasAnd(prop); - var isNestedConditional = prop[0] === '@'; +var _jssExpand = __webpack_require__(120); - if (!isNested && !isNestedConditional) continue; +var _jssExpand2 = _interopRequireDefault(_jssExpand); - options = getOptions(rule, container, options); +var _jssVendorPrefixer = __webpack_require__(122); - if (isNested) { - var selector = replaceParentRefs(prop, rule.selector - // Lazily create the ref replacer function just once for - // all nested rules within the sheet. - );if (!replaceRef) replaceRef = getReplaceRef(container - // Replace all $refs. - );selector = selector.replace(refRegExp, replaceRef); +var _jssVendorPrefixer2 = _interopRequireDefault(_jssVendorPrefixer); - container.addRule(selector, style[prop], _extends({}, options, { selector: selector })); - } else if (isNestedConditional) { - // Place conditional right after the parent rule to ensure right ordering. - container.addRule(prop, _defineProperty({}, rule.key, style[prop]), options); - } - - delete style[prop]; - } - - return style; - } - - return { onProcessStyle: onProcessStyle }; - } +var _jssPropsSort = __webpack_require__(127); -/***/ }, -/* 42 */ -/***/ function(module, exports, __webpack_require__) { +var _jssPropsSort2 = _interopRequireDefault(_jssPropsSort); - 'use strict'; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = jssCompose; +exports.default = function () { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return { + plugins: [(0, _jssTemplate2.default)(options.template), (0, _jssGlobal2.default)(options.global), (0, _jssExtend2.default)(options.extend), (0, _jssNested2.default)(options.nested), (0, _jssCompose2.default)(options.compose), (0, _jssCamelCase2.default)(options.camelCase), (0, _jssDefaultUnit2.default)(options.defaultUnit), (0, _jssExpand2.default)(options.expand), (0, _jssVendorPrefixer2.default)(options.vendorPrefixer), (0, _jssPropsSort2.default)(options.propsSort)] + }; +}; - var _warning = __webpack_require__(7); +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { - var _warning2 = _interopRequireDefault(_warning); +"use strict"; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - /** - * Set selector. - * - * @param {Object} original rule - * @param {String} className class string - * @return {Boolean} flag, indicating function was successfull or not - */ - function registerClass(rule, className) { - // Skip falsy values - if (!className) return true; +Object.defineProperty(exports, "__esModule", { + value: true +}); - // Support array of class names `{composes: ['foo', 'bar']}` - if (Array.isArray(className)) { - for (var index = 0; index < className.length; index++) { - var isSetted = registerClass(rule, className[index]); - if (!isSetted) return false; - } +var _parse = __webpack_require__(112); - return true; - } +var _parse2 = _interopRequireDefault(_parse); - // Support space separated class names `{composes: 'foo bar'}` - if (className.indexOf(' ') > -1) { - return registerClass(rule, className.split(' ')); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var parent = rule.options.parent; +var onProcessRule = function onProcessRule(rule) { + if (typeof rule.style === 'string') { + rule.style = (0, _parse2['default'])(rule.style); + } +}; - // It is a ref to a local rule. +exports['default'] = function () { + return { onProcessRule: onProcessRule }; +}; - if (className[0] === '$') { - var refRule = parent.getRule(className.substr(1)); +/***/ }), +/* 112 */ +/***/ (function(module, exports, __webpack_require__) { - if (!refRule) { - (0, _warning2.default)(false, '[JSS] Referenced rule is not defined. \r\n%s', rule); - return false; - } +"use strict"; - if (refRule === rule) { - (0, _warning2.default)(false, '[JSS] Cyclic composition detected. \r\n%s', rule); - return false; - } - parent.classes[rule.key] += ' ' + parent.classes[refRule.key]; +Object.defineProperty(exports, "__esModule", { + value: true +}); - return true; - } +var _warning = __webpack_require__(11); - rule.options.parent.classes[rule.key] += ' ' + className; +var _warning2 = _interopRequireDefault(_warning); - return true; - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - /** - * Convert compose property to additional class, remove property from original styles. - * - * @param {Rule} rule - * @api public - */ - function jssCompose() { - function onProcessStyle(style, rule) { - if (!style.composes) return style; - registerClass(rule, style.composes); - // Remove composes property to prevent infinite loop. - delete style.composes; - return style; - } - return { onProcessStyle: onProcessStyle }; - } +var semiWithNl = /;\n/; -/***/ }, -/* 43 */ -/***/ function(module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports["default"] = camelCase; - var regExp = /([A-Z])/g; - - /** - * Replace a string passed from String#replace. - * @param {String} str - * @return {String} - */ - function replace(str) { - return "-" + str.toLowerCase(); - } +/** + * Naive CSS parser. + * - Supports only rule body (no selectors) + * - Requires semicolon and new line after the value (except of last line) + * - No nested rules support + */ - /** - * Convert camel cased property names to dash separated. - * - * @param {Object} style - * @return {Object} - */ - function convertCase(style) { - var converted = {}; +exports['default'] = function (cssText) { + var style = {}; + var split = cssText.split(semiWithNl); + for (var i = 0; i < split.length; i++) { + var decl = split[i]; - for (var prop in style) { - converted[prop.replace(regExp, replace)] = style[prop]; - } + if (!decl) continue; + var colonIndex = decl.indexOf(':'); + if (colonIndex === -1) { + (0, _warning2['default'])(false, 'Malformed CSS string "%s"', decl); + continue; + } + var prop = decl.substr(0, colonIndex).trim(); + var value = decl.substr(colonIndex + 1).trim(); + style[prop] = value; + } + return style; +}; - if (style.fallbacks) { - if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase);else converted.fallbacks = convertCase(style.fallbacks); - } +/***/ }), +/* 113 */ +/***/ (function(module, exports, __webpack_require__) { - return converted; - } +"use strict"; - /** - * Allow camel cased property names by converting them back to dasherized. - * - * @param {Rule} rule - */ - function camelCase() { - function onProcessStyle(style) { - if (Array.isArray(style)) { - // Handle rules like @font-face, which can have multiple styles in an array - for (var index = 0; index < style.length; index++) { - style[index] = convertCase(style[index]); - } - return style; - } - - return convertCase(style); - } - - return { onProcessStyle: onProcessStyle }; - } -/***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { +Object.defineProperty(exports, "__esModule", { + value: true +}); - 'use strict'; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +exports['default'] = jssGlobal; - exports['default'] = defaultUnit; +var _jss = __webpack_require__(50); - var _isObservable = __webpack_require__(15); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var _isObservable2 = _interopRequireDefault(_isObservable); +var propKey = '@global'; +var prefixKey = '@global '; - var _defaultUnits = __webpack_require__(45); +var GlobalContainerRule = function () { + function GlobalContainerRule(key, styles, options) { + _classCallCheck(this, GlobalContainerRule); - var _defaultUnits2 = _interopRequireDefault(_defaultUnits); + this.type = 'global'; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + this.key = key; + this.options = options; + this.rules = new _jss.RuleList(_extends({}, options, { + parent: this + })); - /** - * Clones the object and adds a camel cased property version. - */ - function addCamelCasedVersion(obj) { - var regExp = /(-[a-z])/g; - var replace = function replace(str) { - return str[1].toUpperCase(); - }; - var newObj = {}; - for (var key in obj) { - newObj[key] = obj[key]; - newObj[key.replace(regExp, replace)] = obj[key]; - } - return newObj; - } + for (var selector in styles) { + this.rules.add(selector, styles[selector], { selector: selector }); + } - var units = addCamelCasedVersion(_defaultUnits2['default']); - - /** - * Recursive deep style passing function - * - * @param {String} current property - * @param {(Object|Array|Number|String)} property value - * @param {Object} options - * @return {(Object|Array|Number|String)} resulting value - */ - function iterate(prop, value, options) { - if (!value) return value; - - var convertedValue = value; - - var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); - if (type === 'object') { - if (Array.isArray(value)) type = 'array'; - if ((0, _isObservable2['default'])(value)) type = 'observable'; - } - - switch (type) { - case 'object': - if (prop === 'fallbacks') { - for (var innerProp in value) { - value[innerProp] = iterate(innerProp, value[innerProp], options); - } - break; - } - for (var _innerProp in value) { - value[_innerProp] = iterate(prop + '-' + _innerProp, value[_innerProp], options); - } - break; - case 'array': - for (var i = 0; i < value.length; i++) { - value[i] = iterate(prop, value[i], options); - } - break; - case 'number': - if (value !== 0) { - convertedValue = value + (options[prop] || units[prop] || ''); - } - break; - default: - break; - } - - return convertedValue; - } + this.rules.process(); + } - /** - * Add unit to numeric values. - */ - function defaultUnit() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + /** + * Get a rule. + */ - var camelCasedOptions = addCamelCasedVersion(options); - function onProcessStyle(style, rule) { - if (rule.type !== 'style') return style; + _createClass(GlobalContainerRule, [{ + key: 'getRule', + value: function getRule(name) { + return this.rules.get(name); + } - for (var prop in style) { - style[prop] = iterate(prop, style[prop], camelCasedOptions); - } + /** + * Create and register rule, run plugins. + */ - return style; - } + }, { + key: 'addRule', + value: function addRule(name, style, options) { + var rule = this.rules.add(name, style, options); + this.options.jss.plugins.onProcessRule(rule); + return rule; + } + + /** + * Get index of a rule. + */ + + }, { + key: 'indexOf', + value: function indexOf(rule) { + return this.rules.indexOf(rule); + } - function onChangeValue(value, prop) { - return iterate(prop, value, camelCasedOptions); - } + /** + * Generates a CSS string. + */ + + }, { + key: 'toString', + value: function toString() { + return this.rules.toString(); + } + }]); - return { onProcessStyle: onProcessStyle, onChangeValue: onChangeValue }; - } + return GlobalContainerRule; +}(); -/***/ }, -/* 45 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - /** - * Generated jss-default-unit CSS property units - * - * @type object - */ - exports['default'] = { - 'animation-delay': 'ms', - 'animation-duration': 'ms', - 'background-position': 'px', - 'background-position-x': 'px', - 'background-position-y': 'px', - 'background-size': 'px', - border: 'px', - 'border-bottom': 'px', - 'border-bottom-left-radius': 'px', - 'border-bottom-right-radius': 'px', - 'border-bottom-width': 'px', - 'border-left': 'px', - 'border-left-width': 'px', - 'border-radius': 'px', - 'border-right': 'px', - 'border-right-width': 'px', - 'border-spacing': 'px', - 'border-top': 'px', - 'border-top-left-radius': 'px', - 'border-top-right-radius': 'px', - 'border-top-width': 'px', - 'border-width': 'px', - 'border-after-width': 'px', - 'border-before-width': 'px', - 'border-end-width': 'px', - 'border-horizontal-spacing': 'px', - 'border-start-width': 'px', - 'border-vertical-spacing': 'px', - bottom: 'px', - 'box-shadow': 'px', - 'column-gap': 'px', - 'column-rule': 'px', - 'column-rule-width': 'px', - 'column-width': 'px', - 'flex-basis': 'px', - 'font-size': 'px', - 'font-size-delta': 'px', - height: 'px', - left: 'px', - 'letter-spacing': 'px', - 'logical-height': 'px', - 'logical-width': 'px', - margin: 'px', - 'margin-after': 'px', - 'margin-before': 'px', - 'margin-bottom': 'px', - 'margin-left': 'px', - 'margin-right': 'px', - 'margin-top': 'px', - 'max-height': 'px', - 'max-width': 'px', - 'margin-end': 'px', - 'margin-start': 'px', - 'mask-position-x': 'px', - 'mask-position-y': 'px', - 'mask-size': 'px', - 'max-logical-height': 'px', - 'max-logical-width': 'px', - 'min-height': 'px', - 'min-width': 'px', - 'min-logical-height': 'px', - 'min-logical-width': 'px', - motion: 'px', - 'motion-offset': 'px', - outline: 'px', - 'outline-offset': 'px', - 'outline-width': 'px', - padding: 'px', - 'padding-bottom': 'px', - 'padding-left': 'px', - 'padding-right': 'px', - 'padding-top': 'px', - 'padding-after': 'px', - 'padding-before': 'px', - 'padding-end': 'px', - 'padding-start': 'px', - 'perspective-origin-x': '%', - 'perspective-origin-y': '%', - perspective: 'px', - right: 'px', - 'shape-margin': 'px', - size: 'px', - 'text-indent': 'px', - 'text-stroke': 'px', - 'text-stroke-width': 'px', - top: 'px', - 'transform-origin': '%', - 'transform-origin-x': '%', - 'transform-origin-y': '%', - 'transform-origin-z': '%', - 'transition-delay': 'ms', - 'transition-duration': 'ms', - 'vertical-align': 'px', - width: 'px', - 'word-spacing': 'px', - // Not existing properties. - // Used to avoid issues with jss-expand intergration. - 'box-shadow-x': 'px', - 'box-shadow-y': 'px', - 'box-shadow-blur': 'px', - 'box-shadow-spread': 'px', - 'font-line-height': 'px', - 'text-shadow-x': 'px', - 'text-shadow-y': 'px', - 'text-shadow-blur': 'px' - }; - -/***/ }, -/* 46 */ -/***/ function(module, exports, __webpack_require__) { +var GlobalPrefixedRule = function () { + function GlobalPrefixedRule(name, style, options) { + _classCallCheck(this, GlobalPrefixedRule); - 'use strict'; + this.name = name; + this.options = options; + var selector = name.substr(prefixKey.length); + this.rule = options.jss.createRule(selector, style, _extends({}, options, { + parent: this, + selector: selector + })); + } - Object.defineProperty(exports, "__esModule", { - value: true - }); + _createClass(GlobalPrefixedRule, [{ + key: 'toString', + value: function toString(options) { + return this.rule.toString(options); + } + }]); + + return GlobalPrefixedRule; +}(); + +var separatorRegExp = /\s*,\s*/g; + +function addScope(selector, scope) { + var parts = selector.split(separatorRegExp); + var scoped = ''; + for (var i = 0; i < parts.length; i++) { + scoped += scope + ' ' + parts[i].trim(); + if (parts[i + 1]) scoped += ', '; + } + return scoped; +} + +function handleNestedGlobalContainerRule(rule) { + var options = rule.options, + style = rule.style; + + var rules = style[propKey]; + + if (!rules) return; + + for (var name in rules) { + options.sheet.addRule(name, rules[name], _extends({}, options, { + selector: addScope(name, rule.selector) + })); + } + + delete style[propKey]; +} + +function handlePrefixedGlobalRule(rule) { + var options = rule.options, + style = rule.style; + + for (var prop in style) { + if (prop.substr(0, propKey.length) !== propKey) continue; + + var selector = addScope(prop.substr(propKey.length), rule.selector); + options.sheet.addRule(selector, style[prop], _extends({}, options, { + selector: selector + })); + delete style[prop]; + } +} + +/** + * Convert nested rules to separate, remove them from original styles. + * + * @param {Rule} rule + * @api public + */ +function jssGlobal() { + function onCreateRule(name, styles, options) { + if (name === propKey) { + return new GlobalContainerRule(name, styles, options); + } + + if (name[0] === '@' && name.substr(0, prefixKey.length) === prefixKey) { + return new GlobalPrefixedRule(name, styles, options); + } + + var parent = options.parent; + + + if (parent) { + if (parent.type === 'global' || parent.options.parent.type === 'global') { + options.global = true; + } + } + + if (options.global) options.selector = name; + + return null; + } + + function onProcessRule(rule) { + if (rule.type !== 'style') return; + + handleNestedGlobalContainerRule(rule); + handlePrefixedGlobalRule(rule); + } + + return { onCreateRule: onCreateRule, onProcessRule: onProcessRule }; +} + +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +exports['default'] = jssExtend; + +var _warning = __webpack_require__(11); + +var _warning2 = _interopRequireDefault(_warning); + +var _isObservable = __webpack_require__(18); + +var _isObservable2 = _interopRequireDefault(_isObservable); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var isObject = function isObject(obj) { + return obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && !Array.isArray(obj) && !(0, _isObservable2['default'])(obj); +}; + +/** + * Recursively extend styles. + */ +function extend(style, rule, sheet) { + var newStyle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; + + if (typeof style.extend === 'string') { + if (sheet) { + var refRule = sheet.getRule(style.extend); + if (refRule) { + if (refRule === rule) (0, _warning2['default'])(false, '[JSS] A rule tries to extend itself \r\n%s', rule);else if (refRule.options.parent) { + var originalStyle = refRule.options.parent.rules.raw[style.extend]; + extend(originalStyle, rule, sheet, newStyle); + } + } + } + } else if (Array.isArray(style.extend)) { + for (var index = 0; index < style.extend.length; index++) { + extend(style.extend[index], rule, sheet, newStyle); + } + } else { + for (var prop in style.extend) { + if (prop === 'extend') { + extend(style.extend.extend, rule, sheet, newStyle); + } else if (isObject(style.extend[prop])) { + if (!newStyle[prop]) newStyle[prop] = {}; + extend(style.extend[prop], rule, sheet, newStyle[prop]); + } else { + newStyle[prop] = style.extend[prop]; + } + } + } + // Copy base style. + for (var _prop in style) { + if (_prop === 'extend') continue; + if (isObject(newStyle[_prop]) && isObject(style[_prop])) { + extend(style[_prop], rule, sheet, newStyle[_prop]); + } else if (isObject(style[_prop])) { + newStyle[_prop] = extend(style[_prop], rule, sheet); + } else { + newStyle[_prop] = style[_prop]; + } + } + + return newStyle; +} + +/** + * Handle `extend` property. + * + * @param {Rule} rule + * @api public + */ +function jssExtend() { + function onProcessStyle(style, rule, sheet) { + return style.extend ? extend(style, rule, sheet) : style; + } + + return { onProcessStyle: onProcessStyle }; +} + +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +"use strict"; - exports.default = jssExpand; - var _isObservable = __webpack_require__(15); +Object.defineProperty(exports, "__esModule", { + value: true +}); - var _isObservable2 = _interopRequireDefault(_isObservable); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - var _props = __webpack_require__(47); +exports.default = jssNested; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var _warning = __webpack_require__(11); - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +var _warning2 = _interopRequireDefault(_warning); - /** - * Map values by given prop. - * - * @param {Array} array of values - * @param {String} original property - * @param {String} original rule - * @return {String} mapped values - */ - function mapValuesByProp(value, prop, rule) { - return value.map(function (item) { - return objectToString(item, prop, rule); - }); - } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - /** - * Convert array to string. - * - * @param {Array} array of values - * @param {String} original property - * @param {Object} sheme, for converting arrays in strings - * @param {Object} original rule - * @return {String} converted string - */ - function arrayToString(value, prop, scheme, rule) { - if (scheme[prop] == null) return value.join(','); - if (value.length === 0) return ''; - if (Array.isArray(value[0])) return arrayToString(value[0], prop, scheme); - if (_typeof(value[0]) === 'object' && !(0, _isObservable2.default)(value[0])) { - return mapValuesByProp(value, prop, rule); - } - return value.join(' '); - } +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - /** - * Convert object to string. - * - * @param {Object} object of values - * @param {String} original property - * @param {Object} original rule - * @param {Boolean} is fallback prop - * @return {String} converted string - */ - function objectToString(value, prop, rule, isFallback) { - if (!(_props.propObj[prop] || _props.customPropObj[prop])) return ''; - - var result = []; - - // Check if exists any non-standart property - if (_props.customPropObj[prop]) { - value = customPropsToStyle(value, rule, _props.customPropObj[prop], isFallback); - } - - // Pass throught all standart props - if (Object.keys(value).length) { - for (var baseProp in _props.propObj[prop]) { - if (value[baseProp]) { - if (Array.isArray(value[baseProp])) { - result.push(arrayToString(value[baseProp], baseProp, _props.propArrayInObj)); - } else result.push(value[baseProp]); - continue; - } - - // Add default value from props config. - if (_props.propObj[prop][baseProp] != null) { - result.push(_props.propObj[prop][baseProp]); - } - } - } - - return result.join(' '); - } +var separatorRegExp = /\s*,\s*/g; +var parentRegExp = /&/g; +var refRegExp = /\$([\w-]+)/g; - /** - * Convert custom properties values to styles adding them to rule directly - * - * @param {Object} object of values - * @param {Object} original rule - * @param {String} property, that contain partial custom properties - * @param {Boolean} is fallback prop - * @return {Object} value without custom properties, that was already added to rule - */ - function customPropsToStyle(value, rule, customProps, isFallback) { - for (var prop in customProps) { - var propName = customProps[prop]; - - // If current property doesn't exist already in rule - add new one - if (typeof value[prop] !== 'undefined' && (isFallback || !rule.prop(propName))) { - var appendedValue = styleDetector(_defineProperty({}, propName, value[prop]), rule)[propName]; - - // Add style directly in rule - if (isFallback) rule.style.fallbacks[propName] = appendedValue;else rule.style[propName] = appendedValue; - } - // Delete converted property to avoid double converting - delete value[prop]; - } - - return value; - } +/** + * Convert nested rules to separate, remove them from original styles. + * + * @param {Rule} rule + * @api public + */ +function jssNested() { + // Get a function to be used for $ref replacement. + function getReplaceRef(container) { + return function (match, key) { + var rule = container.getRule(key); + if (rule) return rule.selector; + (0, _warning2.default)(false, '[JSS] Could not find the referenced rule %s in %s.', key, container.options.meta || container); + return key; + }; + } - /** - * Detect if a style needs to be converted. - * - * @param {Object} style - * @param {Object} rule - * @param {Boolean} is fallback prop - * @return {Object} convertedStyle - */ - function styleDetector(style, rule, isFallback) { - for (var prop in style) { - var value = style[prop]; - - if (Array.isArray(value)) { - // Check double arrays to avoid recursion. - if (!Array.isArray(value[0])) { - if (prop === 'fallbacks') { - for (var index = 0; index < style.fallbacks.length; index++) { - style.fallbacks[index] = styleDetector(style.fallbacks[index], rule, true); - } - continue; - } - - style[prop] = arrayToString(value, prop, _props.propArray); - // Avoid creating properties with empty values - if (!style[prop]) delete style[prop]; - } - } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !(0, _isObservable2.default)(value)) { - if (prop === 'fallbacks') { - style.fallbacks = styleDetector(style.fallbacks, rule, true); - continue; - } - - style[prop] = objectToString(value, prop, rule, isFallback); - // Avoid creating properties with empty values - if (!style[prop]) delete style[prop]; - } - - // Maybe a computed value resulting in an empty string - else if (style[prop] === '') delete style[prop]; - } - - return style; - } + var hasAnd = function hasAnd(str) { + return str.indexOf('&') !== -1; + }; - /** - * Adds possibility to write expanded styles. - * - * @param {Rule} rule - * @api public - */ - function jssExpand() { - function onProcessStyle(style, rule) { - if (!style || rule.type !== 'style') return style; - - if (Array.isArray(style)) { - // Pass rules one by one and reformat them - for (var index = 0; index < style.length; index++) { - style[index] = styleDetector(style[index], rule); - } - return style; - } - - return styleDetector(style, rule); - } - - return { onProcessStyle: onProcessStyle }; - } + function replaceParentRefs(nestedProp, parentProp) { + var parentSelectors = parentProp.split(separatorRegExp); + var nestedSelectors = nestedProp.split(separatorRegExp); -/***/ }, -/* 47 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - /** - * A scheme for converting properties from array to regular style. - * All properties listed below will be transformed to a string separated by space. - */ - var propArray = exports.propArray = { - 'background-size': true, - 'background-position': true, - border: true, - 'border-bottom': true, - 'border-left': true, - 'border-top': true, - 'border-right': true, - 'border-radius': true, - 'box-shadow': true, - flex: true, - margin: true, - padding: true, - outline: true, - 'transform-origin': true, - transform: true, - transition: true - }; - - /** - * A scheme for converting arrays to regular styles inside of objects. - * For e.g.: "{position: [0, 0]}" => "background-position: 0 0;". - */ - var propArrayInObj = exports.propArrayInObj = { - position: true, // background-position - size: true // background-size - }; - - /** - * A scheme for parsing and building correct styles from passed objects. - */ - var propObj = exports.propObj = { - padding: { - top: 0, - right: 0, - bottom: 0, - left: 0 - }, - margin: { - top: 0, - right: 0, - bottom: 0, - left: 0 - }, - background: { - attachment: null, - color: null, - image: null, - position: null, - repeat: null - }, - border: { - width: null, - style: null, - color: null - }, - 'border-top': { - width: null, - style: null, - color: null - }, - 'border-right': { - width: null, - style: null, - color: null - }, - 'border-bottom': { - width: null, - style: null, - color: null - }, - 'border-left': { - width: null, - style: null, - color: null - }, - outline: { - width: null, - style: null, - color: null - }, - 'list-style': { - type: null, - position: null, - image: null - }, - transition: { - property: null, - duration: null, - 'timing-function': null, - timingFunction: null, // Needed for avoiding comilation issues with jss-camel-case - delay: null - }, - animation: { - name: null, - duration: null, - 'timing-function': null, - timingFunction: null, // Needed to avoid compilation issues with jss-camel-case - delay: null, - 'iteration-count': null, - iterationCount: null, // Needed to avoid compilation issues with jss-camel-case - direction: null, - 'fill-mode': null, - fillMode: null, // Needed to avoid compilation issues with jss-camel-case - 'play-state': null, - playState: null // Needed to avoid compilation issues with jss-camel-case - }, - 'box-shadow': { - x: 0, - y: 0, - blur: 0, - spread: 0, - color: null, - inset: null - }, - 'text-shadow': { - x: 0, - y: 0, - blur: null, - color: null - } - }; - - /** - * A scheme for converting non-standart properties inside object. - * For e.g.: include 'border-radius' property inside 'border' object. - */ - var customPropObj = exports.customPropObj = { - border: { - radius: 'border-radius' - }, - background: { - size: 'background-size', - image: 'background-image' - }, - font: { - style: 'font-style', - variant: 'font-variant', - weight: 'font-weight', - stretch: 'font-stretch', - size: 'font-size', - family: 'font-family', - lineHeight: 'line-height', // Needed to avoid compilation issues with jss-camel-case - 'line-height': 'line-height' - }, - flex: { - grow: 'flex-grow', - basis: 'flex-basis', - direction: 'flex-direction', - wrap: 'flex-wrap', - flow: 'flex-flow', - shrink: 'flex-shrink' - }, - align: { - self: 'align-self', - items: 'align-items', - content: 'align-content' - } - }; - -/***/ }, -/* 48 */ -/***/ function(module, exports, __webpack_require__) { + var result = ''; - 'use strict'; + for (var i = 0; i < parentSelectors.length; i++) { + var parent = parentSelectors[i]; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = jssVendorPrefixer; + for (var j = 0; j < nestedSelectors.length; j++) { + var nested = nestedSelectors[j]; + if (result) result += ', '; + // Replace all & by the parent or prefix & with the parent. + result += hasAnd(nested) ? nested.replace(parentRegExp, parent) : parent + ' ' + nested; + } + } - var _cssVendor = __webpack_require__(49); + return result; + } - var vendor = _interopRequireWildcard(_cssVendor); + function getOptions(rule, container, options) { + // Options has been already created, now we only increase index. + if (options) return _extends({}, options, { index: options.index + 1 }); - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } + var nestingLevel = rule.options.nestingLevel; - /** - * Add vendor prefix to a property name when needed. - * - * @param {Rule} rule - * @api public - */ - function jssVendorPrefixer() { - function onProcessRule(rule) { - if (rule.type === 'keyframes') { - rule.key = '@' + vendor.prefix.css + rule.key.substr(1); - } - } + nestingLevel = nestingLevel === undefined ? 1 : nestingLevel + 1; - function onProcessStyle(style, rule) { - if (rule.type !== 'style') return style; + return _extends({}, rule.options, { + nestingLevel: nestingLevel, + index: container.indexOf(rule) + 1 + }); + } - for (var prop in style) { - var value = style[prop]; + function onProcessStyle(style, rule) { + if (rule.type !== 'style') return style; + var container = rule.options.parent; + var options = void 0; + var replaceRef = void 0; + for (var prop in style) { + var isNested = hasAnd(prop); + var isNestedConditional = prop[0] === '@'; - var changeProp = false; - var supportedProp = vendor.supportedProperty(prop); - if (supportedProp && supportedProp !== prop) changeProp = true; + if (!isNested && !isNestedConditional) continue; - var changeValue = false; - var supportedValue = vendor.supportedValue(supportedProp, value); - if (supportedValue && supportedValue !== value) changeValue = true; + options = getOptions(rule, container, options); - if (changeProp || changeValue) { - if (changeProp) delete style[prop]; - style[supportedProp || prop] = supportedValue || value; - } - } + if (isNested) { + var selector = replaceParentRefs(prop, rule.selector + // Lazily create the ref replacer function just once for + // all nested rules within the sheet. + );if (!replaceRef) replaceRef = getReplaceRef(container + // Replace all $refs. + );selector = selector.replace(refRegExp, replaceRef); - return style; - } + container.addRule(selector, style[prop], _extends({}, options, { selector: selector })); + } else if (isNestedConditional) { + // Place conditional right after the parent rule to ensure right ordering. + container.addRule(prop, _defineProperty({}, rule.key, style[prop]), options); + } - function onChangeValue(value, prop) { - return vendor.supportedValue(prop, value); - } + delete style[prop]; + } + + return style; + } + + return { onProcessStyle: onProcessStyle }; +} + +/***/ }), +/* 116 */ +/***/ (function(module, exports, __webpack_require__) { - return { onProcessRule: onProcessRule, onProcessStyle: onProcessStyle, onChangeValue: onChangeValue }; - } +"use strict"; -/***/ }, -/* 49 */ -/***/ function(module, exports, __webpack_require__) { - 'use strict'; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = jssCompose; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.supportedValue = exports.supportedProperty = exports.prefix = undefined; +var _warning = __webpack_require__(11); - var _prefix = __webpack_require__(50); +var _warning2 = _interopRequireDefault(_warning); - var _prefix2 = _interopRequireDefault(_prefix); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var _supportedProperty = __webpack_require__(52); +/** + * Set selector. + * + * @param {Object} original rule + * @param {String} className class string + * @return {Boolean} flag, indicating function was successfull or not + */ +function registerClass(rule, className) { + // Skip falsy values + if (!className) return true; - var _supportedProperty2 = _interopRequireDefault(_supportedProperty); + // Support array of class names `{composes: ['foo', 'bar']}` + if (Array.isArray(className)) { + for (var index = 0; index < className.length; index++) { + var isSetted = registerClass(rule, className[index]); + if (!isSetted) return false; + } - var _supportedValue = __webpack_require__(54); + return true; + } - var _supportedValue2 = _interopRequireDefault(_supportedValue); + // Support space separated class names `{composes: 'foo bar'}` + if (className.indexOf(' ') > -1) { + return registerClass(rule, className.split(' ')); + } - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + var parent = rule.options.parent; - exports['default'] = { - prefix: _prefix2['default'], - supportedProperty: _supportedProperty2['default'], - supportedValue: _supportedValue2['default'] - }; /** - * CSS Vendor prefix detection and property feature testing. - * - * @copyright Oleg Slobodskoi 2015 - * @website https://github.com/jsstyles/css-vendor - * @license MIT - */ + // It is a ref to a local rule. - exports.prefix = _prefix2['default']; - exports.supportedProperty = _supportedProperty2['default']; - exports.supportedValue = _supportedValue2['default']; + if (className[0] === '$') { + var refRule = parent.getRule(className.substr(1)); -/***/ }, -/* 50 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _isInBrowser = __webpack_require__(51); - - var _isInBrowser2 = _interopRequireDefault(_isInBrowser); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var js = ''; /** - * Export javascript style and css style vendor prefixes. - * Based on "transform" support test. - */ - - var css = ''; - - // We should not do anything if required serverside. - if (_isInBrowser2['default']) { - // Order matters. We need to check Webkit the last one because - // other vendors use to add Webkit prefixes to some properties - var jsCssMap = { - Moz: '-moz-', - // IE did it wrong again ... - ms: '-ms-', - O: '-o-', - Webkit: '-webkit-' - }; - var style = document.createElement('p').style; - var testProp = 'Transform'; - - for (var key in jsCssMap) { - if (key + testProp in style) { - js = key; - css = jsCssMap[key]; - break; - } - } - } + if (!refRule) { + (0, _warning2.default)(false, '[JSS] Referenced rule is not defined. \r\n%s', rule); + return false; + } - /** - * Vendor prefix string for the current browser. - * - * @type {{js: String, css: String}} - * @api public - */ - exports['default'] = { js: js, css: css }; + if (refRule === rule) { + (0, _warning2.default)(false, '[JSS] Cyclic composition detected. \r\n%s', rule); + return false; + } -/***/ }, -/* 51 */ -/***/ function(module, exports) { + parent.classes[rule.key] += ' ' + parent.classes[refRule.key]; - "use strict"; + return true; + } - Object.defineProperty(exports, "__esModule", { - value: true - }); + rule.options.parent.classes[rule.key] += ' ' + className; - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + return true; +} - var isBrowser = exports.isBrowser = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && document.nodeType === 9; +/** + * Convert compose property to additional class, remove property from original styles. + * + * @param {Rule} rule + * @api public + */ +function jssCompose() { + function onProcessStyle(style, rule) { + if (!style.composes) return style; + registerClass(rule, style.composes); + // Remove composes property to prevent infinite loop. + delete style.composes; + return style; + } + return { onProcessStyle: onProcessStyle }; +} - exports.default = isBrowser; +/***/ }), +/* 117 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = camelCase; +var regExp = /([A-Z])/g; + +/** + * Replace a string passed from String#replace. + * @param {String} str + * @return {String} + */ +function replace(str) { + return "-" + str.toLowerCase(); +} + +/** + * Convert camel cased property names to dash separated. + * + * @param {Object} style + * @return {Object} + */ +function convertCase(style) { + var converted = {}; + + for (var prop in style) { + converted[prop.replace(regExp, replace)] = style[prop]; + } + + if (style.fallbacks) { + if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase);else converted.fallbacks = convertCase(style.fallbacks); + } + + return converted; +} + +/** + * Allow camel cased property names by converting them back to dasherized. + * + * @param {Rule} rule + */ +function camelCase() { + function onProcessStyle(style) { + if (Array.isArray(style)) { + // Handle rules like @font-face, which can have multiple styles in an array + for (var index = 0; index < style.length; index++) { + style[index] = convertCase(style[index]); + } + return style; + } + + return convertCase(style); + } + + return { onProcessStyle: onProcessStyle }; +} + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +exports['default'] = defaultUnit; + +var _isObservable = __webpack_require__(18); + +var _isObservable2 = _interopRequireDefault(_isObservable); + +var _defaultUnits = __webpack_require__(119); + +var _defaultUnits2 = _interopRequireDefault(_defaultUnits); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +/** + * Clones the object and adds a camel cased property version. + */ +function addCamelCasedVersion(obj) { + var regExp = /(-[a-z])/g; + var replace = function replace(str) { + return str[1].toUpperCase(); + }; + var newObj = {}; + for (var key in obj) { + newObj[key] = obj[key]; + newObj[key.replace(regExp, replace)] = obj[key]; + } + return newObj; +} + +var units = addCamelCasedVersion(_defaultUnits2['default']); + +/** + * Recursive deep style passing function + * + * @param {String} current property + * @param {(Object|Array|Number|String)} property value + * @param {Object} options + * @return {(Object|Array|Number|String)} resulting value + */ +function iterate(prop, value, options) { + if (!value) return value; + + var convertedValue = value; + + var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); + if (type === 'object') { + if (Array.isArray(value)) type = 'array'; + if ((0, _isObservable2['default'])(value)) type = 'observable'; + } + + switch (type) { + case 'object': + if (prop === 'fallbacks') { + for (var innerProp in value) { + value[innerProp] = iterate(innerProp, value[innerProp], options); + } + break; + } + for (var _innerProp in value) { + value[_innerProp] = iterate(prop + '-' + _innerProp, value[_innerProp], options); + } + break; + case 'array': + for (var i = 0; i < value.length; i++) { + value[i] = iterate(prop, value[i], options); + } + break; + case 'number': + if (value !== 0) { + convertedValue = value + (options[prop] || units[prop] || ''); + } + break; + default: + break; + } + + return convertedValue; +} + +/** + * Add unit to numeric values. + */ +function defaultUnit() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var camelCasedOptions = addCamelCasedVersion(options); + + function onProcessStyle(style, rule) { + if (rule.type !== 'style') return style; + + for (var prop in style) { + style[prop] = iterate(prop, style[prop], camelCasedOptions); + } + + return style; + } + + function onChangeValue(value, prop) { + return iterate(prop, value, camelCasedOptions); + } + + return { onProcessStyle: onProcessStyle, onChangeValue: onChangeValue }; +} + +/***/ }), +/* 119 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +/** + * Generated jss-default-unit CSS property units + * + * @type object + */ +exports['default'] = { + 'animation-delay': 'ms', + 'animation-duration': 'ms', + 'background-position': 'px', + 'background-position-x': 'px', + 'background-position-y': 'px', + 'background-size': 'px', + border: 'px', + 'border-bottom': 'px', + 'border-bottom-left-radius': 'px', + 'border-bottom-right-radius': 'px', + 'border-bottom-width': 'px', + 'border-left': 'px', + 'border-left-width': 'px', + 'border-radius': 'px', + 'border-right': 'px', + 'border-right-width': 'px', + 'border-spacing': 'px', + 'border-top': 'px', + 'border-top-left-radius': 'px', + 'border-top-right-radius': 'px', + 'border-top-width': 'px', + 'border-width': 'px', + 'border-after-width': 'px', + 'border-before-width': 'px', + 'border-end-width': 'px', + 'border-horizontal-spacing': 'px', + 'border-start-width': 'px', + 'border-vertical-spacing': 'px', + bottom: 'px', + 'box-shadow': 'px', + 'column-gap': 'px', + 'column-rule': 'px', + 'column-rule-width': 'px', + 'column-width': 'px', + 'flex-basis': 'px', + 'font-size': 'px', + 'font-size-delta': 'px', + height: 'px', + left: 'px', + 'letter-spacing': 'px', + 'logical-height': 'px', + 'logical-width': 'px', + margin: 'px', + 'margin-after': 'px', + 'margin-before': 'px', + 'margin-bottom': 'px', + 'margin-left': 'px', + 'margin-right': 'px', + 'margin-top': 'px', + 'max-height': 'px', + 'max-width': 'px', + 'margin-end': 'px', + 'margin-start': 'px', + 'mask-position-x': 'px', + 'mask-position-y': 'px', + 'mask-size': 'px', + 'max-logical-height': 'px', + 'max-logical-width': 'px', + 'min-height': 'px', + 'min-width': 'px', + 'min-logical-height': 'px', + 'min-logical-width': 'px', + motion: 'px', + 'motion-offset': 'px', + outline: 'px', + 'outline-offset': 'px', + 'outline-width': 'px', + padding: 'px', + 'padding-bottom': 'px', + 'padding-left': 'px', + 'padding-right': 'px', + 'padding-top': 'px', + 'padding-after': 'px', + 'padding-before': 'px', + 'padding-end': 'px', + 'padding-start': 'px', + 'perspective-origin-x': '%', + 'perspective-origin-y': '%', + perspective: 'px', + right: 'px', + 'shape-margin': 'px', + size: 'px', + 'text-indent': 'px', + 'text-stroke': 'px', + 'text-stroke-width': 'px', + top: 'px', + 'transform-origin': '%', + 'transform-origin-x': '%', + 'transform-origin-y': '%', + 'transform-origin-z': '%', + 'transition-delay': 'ms', + 'transition-duration': 'ms', + 'vertical-align': 'px', + width: 'px', + 'word-spacing': 'px', + // Not existing properties. + // Used to avoid issues with jss-expand intergration. + 'box-shadow-x': 'px', + 'box-shadow-y': 'px', + 'box-shadow-blur': 'px', + 'box-shadow-spread': 'px', + 'font-line-height': 'px', + 'text-shadow-x': 'px', + 'text-shadow-y': 'px', + 'text-shadow-blur': 'px' +}; + +/***/ }), +/* 120 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +exports.default = jssExpand; + +var _isObservable = __webpack_require__(18); + +var _isObservable2 = _interopRequireDefault(_isObservable); + +var _props = __webpack_require__(121); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Map values by given prop. + * + * @param {Array} array of values + * @param {String} original property + * @param {String} original rule + * @return {String} mapped values + */ +function mapValuesByProp(value, prop, rule) { + return value.map(function (item) { + return objectToString(item, prop, rule); + }); +} + +/** + * Convert array to string. + * + * @param {Array} array of values + * @param {String} original property + * @param {Object} sheme, for converting arrays in strings + * @param {Object} original rule + * @return {String} converted string + */ +function arrayToString(value, prop, scheme, rule) { + if (scheme[prop] == null) return value.join(','); + if (value.length === 0) return ''; + if (Array.isArray(value[0])) return arrayToString(value[0], prop, scheme); + if (_typeof(value[0]) === 'object' && !(0, _isObservable2.default)(value[0])) { + return mapValuesByProp(value, prop, rule); + } + return value.join(' '); +} + +/** + * Convert object to string. + * + * @param {Object} object of values + * @param {String} original property + * @param {Object} original rule + * @param {Boolean} is fallback prop + * @return {String} converted string + */ +function objectToString(value, prop, rule, isFallback) { + if (!(_props.propObj[prop] || _props.customPropObj[prop])) return ''; + + var result = []; + + // Check if exists any non-standart property + if (_props.customPropObj[prop]) { + value = customPropsToStyle(value, rule, _props.customPropObj[prop], isFallback); + } + + // Pass throught all standart props + if (Object.keys(value).length) { + for (var baseProp in _props.propObj[prop]) { + if (value[baseProp]) { + if (Array.isArray(value[baseProp])) { + result.push(arrayToString(value[baseProp], baseProp, _props.propArrayInObj)); + } else result.push(value[baseProp]); + continue; + } + + // Add default value from props config. + if (_props.propObj[prop][baseProp] != null) { + result.push(_props.propObj[prop][baseProp]); + } + } + } + + return result.join(' '); +} + +/** + * Convert custom properties values to styles adding them to rule directly + * + * @param {Object} object of values + * @param {Object} original rule + * @param {String} property, that contain partial custom properties + * @param {Boolean} is fallback prop + * @return {Object} value without custom properties, that was already added to rule + */ +function customPropsToStyle(value, rule, customProps, isFallback) { + for (var prop in customProps) { + var propName = customProps[prop]; + + // If current property doesn't exist already in rule - add new one + if (typeof value[prop] !== 'undefined' && (isFallback || !rule.prop(propName))) { + var appendedValue = styleDetector(_defineProperty({}, propName, value[prop]), rule)[propName]; + + // Add style directly in rule + if (isFallback) rule.style.fallbacks[propName] = appendedValue;else rule.style[propName] = appendedValue; + } + // Delete converted property to avoid double converting + delete value[prop]; + } + + return value; +} + +/** + * Detect if a style needs to be converted. + * + * @param {Object} style + * @param {Object} rule + * @param {Boolean} is fallback prop + * @return {Object} convertedStyle + */ +function styleDetector(style, rule, isFallback) { + for (var prop in style) { + var value = style[prop]; + + if (Array.isArray(value)) { + // Check double arrays to avoid recursion. + if (!Array.isArray(value[0])) { + if (prop === 'fallbacks') { + for (var index = 0; index < style.fallbacks.length; index++) { + style.fallbacks[index] = styleDetector(style.fallbacks[index], rule, true); + } + continue; + } + + style[prop] = arrayToString(value, prop, _props.propArray); + // Avoid creating properties with empty values + if (!style[prop]) delete style[prop]; + } + } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !(0, _isObservable2.default)(value)) { + if (prop === 'fallbacks') { + style.fallbacks = styleDetector(style.fallbacks, rule, true); + continue; + } + + style[prop] = objectToString(value, prop, rule, isFallback); + // Avoid creating properties with empty values + if (!style[prop]) delete style[prop]; + } + + // Maybe a computed value resulting in an empty string + else if (style[prop] === '') delete style[prop]; + } + + return style; +} + +/** + * Adds possibility to write expanded styles. + * + * @param {Rule} rule + * @api public + */ +function jssExpand() { + function onProcessStyle(style, rule) { + if (!style || rule.type !== 'style') return style; + + if (Array.isArray(style)) { + // Pass rules one by one and reformat them + for (var index = 0; index < style.length; index++) { + style[index] = styleDetector(style[index], rule); + } + return style; + } + + return styleDetector(style, rule); + } + + return { onProcessStyle: onProcessStyle }; +} + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +/** + * A scheme for converting properties from array to regular style. + * All properties listed below will be transformed to a string separated by space. + */ +var propArray = exports.propArray = { + 'background-size': true, + 'background-position': true, + border: true, + 'border-bottom': true, + 'border-left': true, + 'border-top': true, + 'border-right': true, + 'border-radius': true, + 'box-shadow': true, + flex: true, + margin: true, + padding: true, + outline: true, + 'transform-origin': true, + transform: true, + transition: true +}; + +/** + * A scheme for converting arrays to regular styles inside of objects. + * For e.g.: "{position: [0, 0]}" => "background-position: 0 0;". + */ +var propArrayInObj = exports.propArrayInObj = { + position: true, // background-position + size: true // background-size +}; + +/** + * A scheme for parsing and building correct styles from passed objects. + */ +var propObj = exports.propObj = { + padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + margin: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + background: { + attachment: null, + color: null, + image: null, + position: null, + repeat: null + }, + border: { + width: null, + style: null, + color: null + }, + 'border-top': { + width: null, + style: null, + color: null + }, + 'border-right': { + width: null, + style: null, + color: null + }, + 'border-bottom': { + width: null, + style: null, + color: null + }, + 'border-left': { + width: null, + style: null, + color: null + }, + outline: { + width: null, + style: null, + color: null + }, + 'list-style': { + type: null, + position: null, + image: null + }, + transition: { + property: null, + duration: null, + 'timing-function': null, + timingFunction: null, // Needed for avoiding comilation issues with jss-camel-case + delay: null + }, + animation: { + name: null, + duration: null, + 'timing-function': null, + timingFunction: null, // Needed to avoid compilation issues with jss-camel-case + delay: null, + 'iteration-count': null, + iterationCount: null, // Needed to avoid compilation issues with jss-camel-case + direction: null, + 'fill-mode': null, + fillMode: null, // Needed to avoid compilation issues with jss-camel-case + 'play-state': null, + playState: null // Needed to avoid compilation issues with jss-camel-case + }, + 'box-shadow': { + x: 0, + y: 0, + blur: 0, + spread: 0, + color: null, + inset: null + }, + 'text-shadow': { + x: 0, + y: 0, + blur: null, + color: null + } +}; + +/** + * A scheme for converting non-standart properties inside object. + * For e.g.: include 'border-radius' property inside 'border' object. + */ +var customPropObj = exports.customPropObj = { + border: { + radius: 'border-radius' + }, + background: { + size: 'background-size', + image: 'background-image' + }, + font: { + style: 'font-style', + variant: 'font-variant', + weight: 'font-weight', + stretch: 'font-stretch', + size: 'font-size', + family: 'font-family', + lineHeight: 'line-height', // Needed to avoid compilation issues with jss-camel-case + 'line-height': 'line-height' + }, + flex: { + grow: 'flex-grow', + basis: 'flex-basis', + direction: 'flex-direction', + wrap: 'flex-wrap', + flow: 'flex-flow', + shrink: 'flex-shrink' + }, + align: { + self: 'align-self', + items: 'align-items', + content: 'align-content' + } +}; + +/***/ }), +/* 122 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 52 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - 'use strict'; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = supportedProperty; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = jssVendorPrefixer; - var _isInBrowser = __webpack_require__(51); +var _cssVendor = __webpack_require__(123); - var _isInBrowser2 = _interopRequireDefault(_isInBrowser); +var vendor = _interopRequireWildcard(_cssVendor); - var _prefix = __webpack_require__(50); +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } - var _prefix2 = _interopRequireDefault(_prefix); +/** + * Add vendor prefix to a property name when needed. + * + * @param {Rule} rule + * @api public + */ +function jssVendorPrefixer() { + function onProcessRule(rule) { + if (rule.type === 'keyframes') { + rule.key = '@' + vendor.prefix.css + rule.key.substr(1); + } + } - var _camelize = __webpack_require__(53); + function onProcessStyle(style, rule) { + if (rule.type !== 'style') return style; - var _camelize2 = _interopRequireDefault(_camelize); + for (var prop in style) { + var value = style[prop]; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + var changeProp = false; + var supportedProp = vendor.supportedProperty(prop); + if (supportedProp && supportedProp !== prop) changeProp = true; - var el = void 0; - var cache = {}; + var changeValue = false; + var supportedValue = vendor.supportedValue(supportedProp, value); + if (supportedValue && supportedValue !== value) changeValue = true; - if (_isInBrowser2['default']) { - el = document.createElement('p'); + if (changeProp || changeValue) { + if (changeProp) delete style[prop]; + style[supportedProp || prop] = supportedValue || value; + } + } - /** - * We test every property on vendor prefix requirement. - * Once tested, result is cached. It gives us up to 70% perf boost. - * http://jsperf.com/element-style-object-access-vs-plain-object - * - * Prefill cache with known css properties to reduce amount of - * properties we need to feature test at runtime. - * http://davidwalsh.name/vendor-prefix - */ - var computed = window.getComputedStyle(document.documentElement, ''); - for (var key in computed) { - if (!isNaN(key)) cache[computed[key]] = computed[key]; - } - } + return style; + } - /** - * Test if a property is supported, returns supported property with vendor - * prefix if required. Returns `false` if not supported. - * - * @param {String} prop dash separated - * @return {String|Boolean} - * @api public - */ - function supportedProperty(prop) { - // For server-side rendering. - if (!el) return prop; - - // We have not tested this prop yet, lets do the test. - if (cache[prop] != null) return cache[prop]; - - // Camelization is required because we can't test using - // css syntax for e.g. in FF. - // Test if property is supported as it is. - if ((0, _camelize2['default'])(prop) in el.style) { - cache[prop] = prop; - } - // Test if property is supported with vendor prefix. - else if (_prefix2['default'].js + (0, _camelize2['default'])('-' + prop) in el.style) { - cache[prop] = _prefix2['default'].css + prop; - } else { - cache[prop] = false; - } - - return cache[prop]; - } + function onChangeValue(value, prop) { + return vendor.supportedValue(prop, value); + } -/***/ }, -/* 53 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = camelize; - var regExp = /[-\s]+(.)?/g; - - /** - * Convert dash separated strings to camel cased. - * - * @param {String} str - * @return {String} - */ - function camelize(str) { - return str.replace(regExp, toUpper); - } + return { onProcessRule: onProcessRule, onProcessStyle: onProcessStyle, onChangeValue: onChangeValue }; +} - function toUpper(match, c) { - return c ? c.toUpperCase() : ''; - } +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 54 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - 'use strict'; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = supportedValue; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.supportedValue = exports.supportedProperty = exports.prefix = undefined; - var _isInBrowser = __webpack_require__(51); +var _prefix = __webpack_require__(41); - var _isInBrowser2 = _interopRequireDefault(_isInBrowser); +var _prefix2 = _interopRequireDefault(_prefix); - var _prefix = __webpack_require__(50); +var _supportedProperty = __webpack_require__(124); - var _prefix2 = _interopRequireDefault(_prefix); +var _supportedProperty2 = _interopRequireDefault(_supportedProperty); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _supportedValue = __webpack_require__(126); - var cache = {}; - var el = void 0; +var _supportedValue2 = _interopRequireDefault(_supportedValue); - if (_isInBrowser2['default']) el = document.createElement('p'); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - /** - * Returns prefixed value if needed. Returns `false` if value is not supported. - * - * @param {String} property - * @param {String} value - * @return {String|Boolean} - * @api public - */ - function supportedValue(property, value) { - // For server-side rendering. - if (!el) return value; +exports['default'] = { + prefix: _prefix2['default'], + supportedProperty: _supportedProperty2['default'], + supportedValue: _supportedValue2['default'] +}; /** + * CSS Vendor prefix detection and property feature testing. + * + * @copyright Oleg Slobodskoi 2015 + * @website https://github.com/jsstyles/css-vendor + * @license MIT + */ - // It is a string or a number as a string like '1'. - // We want only prefixable values here. - if (typeof value !== 'string' || !isNaN(parseInt(value, 10))) return value; +exports.prefix = _prefix2['default']; +exports.supportedProperty = _supportedProperty2['default']; +exports.supportedValue = _supportedValue2['default']; - var cacheKey = property + value; +/***/ }), +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = supportedProperty; + +var _isInBrowser = __webpack_require__(42); + +var _isInBrowser2 = _interopRequireDefault(_isInBrowser); + +var _prefix = __webpack_require__(41); + +var _prefix2 = _interopRequireDefault(_prefix); + +var _camelize = __webpack_require__(125); + +var _camelize2 = _interopRequireDefault(_camelize); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var el = void 0; +var cache = {}; + +if (_isInBrowser2['default']) { + el = document.createElement('p'); + + /** + * We test every property on vendor prefix requirement. + * Once tested, result is cached. It gives us up to 70% perf boost. + * http://jsperf.com/element-style-object-access-vs-plain-object + * + * Prefill cache with known css properties to reduce amount of + * properties we need to feature test at runtime. + * http://davidwalsh.name/vendor-prefix + */ + var computed = window.getComputedStyle(document.documentElement, ''); + for (var key in computed) { + if (!isNaN(key)) cache[computed[key]] = computed[key]; + } +} + +/** + * Test if a property is supported, returns supported property with vendor + * prefix if required. Returns `false` if not supported. + * + * @param {String} prop dash separated + * @return {String|Boolean} + * @api public + */ +function supportedProperty(prop) { + // For server-side rendering. + if (!el) return prop; + + // We have not tested this prop yet, lets do the test. + if (cache[prop] != null) return cache[prop]; + + // Camelization is required because we can't test using + // css syntax for e.g. in FF. + // Test if property is supported as it is. + if ((0, _camelize2['default'])(prop) in el.style) { + cache[prop] = prop; + } + // Test if property is supported with vendor prefix. + else if (_prefix2['default'].js + (0, _camelize2['default'])('-' + prop) in el.style) { + cache[prop] = _prefix2['default'].css + prop; + } else { + cache[prop] = false; + } + + return cache[prop]; +} + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { - if (cache[cacheKey] != null) return cache[cacheKey]; +"use strict"; - // IE can even throw an error in some cases, for e.g. style.content = 'bar' - try { - // Test value as it is. - el.style[property] = value; - } catch (err) { - cache[cacheKey] = false; - return false; - } - // Value is supported as it is. - if (el.style[property] !== '') { - cache[cacheKey] = value; - } else { - // Test value with vendor prefix. - value = _prefix2['default'].css + value; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = camelize; +var regExp = /[-\s]+(.)?/g; - // Hardcode test to convert "flex" to "-ms-flexbox" for IE10. - if (value === '-ms-flex') value = '-ms-flexbox'; +/** + * Convert dash separated strings to camel cased. + * + * @param {String} str + * @return {String} + */ +function camelize(str) { + return str.replace(regExp, toUpper); +} - el.style[property] = value; +function toUpper(match, c) { + return c ? c.toUpperCase() : ''; +} - // Value is supported with vendor prefix. - if (el.style[property] !== '') cache[cacheKey] = value; - } +/***/ }), +/* 126 */ +/***/ (function(module, exports, __webpack_require__) { - if (!cache[cacheKey]) cache[cacheKey] = false; +"use strict"; - // Reset style value. - el.style[property] = ''; - return cache[cacheKey]; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = supportedValue; -/***/ }, -/* 55 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports['default'] = jssPropsSort; - /** - * Sort props by length. - */ - function jssPropsSort() { - function sort(prop0, prop1) { - return prop0.length - prop1.length; - } - - function onProcessStyle(style, rule) { - if (rule.type !== 'style') return style; - - var newStyle = {}; - var props = Object.keys(style).sort(sort); - for (var prop in props) { - newStyle[props[prop]] = style[props[prop]]; - } - return newStyle; - } - - return { onProcessStyle: onProcessStyle }; - } +var _isInBrowser = __webpack_require__(42); -/***/ }, -/* 56 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - var colorBg = exports.colorBg = '#1F1F3C'; - var colorFurLight = exports.colorFurLight = '#D5E8F8'; - var colorFurDark = exports.colorFurDark = '#8B9BD9'; - var colorFeatures = exports.colorFeatures = '#4B4D75'; - var colorFeaturesLight = exports.colorFeaturesLight = '#9FA2CB'; - var colorYarn = exports.colorYarn = '#DB242A'; - var duration = exports.duration = '7s'; - var durationSeconds = exports.durationSeconds = 7; - var easing = exports.easing = 'cubic-bezier(0.5, 0, 0.5, 1)'; - var offset = exports.offset = '.5s'; - var swings = exports.swings = '5 -10 10 -15 23 -23 15 -10 5'; - var totalSwings = exports.totalSwings = 'length($swings)'; - -/***/ }, -/* 57 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - var _jss = __webpack_require__(2); - - var _jss2 = _interopRequireDefault(_jss); - - var _theme = __webpack_require__(56); - - var theme = _interopRequireWildcard(_theme); - - var _yarn = __webpack_require__(58); - - var _yarn2 = _interopRequireDefault(_yarn); - - var _upperBody = __webpack_require__(59); - - var _upperBody2 = _interopRequireDefault(_upperBody); - - var _lowerBody = __webpack_require__(414); - - var _lowerBody2 = _interopRequireDefault(_lowerBody); - - var _animation = __webpack_require__(61); - - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var styles = { - root: _extends({ - width: '100%', - height: '100%' - }, (0, _animation.bobAnimation)(theme.durationSeconds, 0, theme.easing)), - scene: _extends({ - top: '10rem', - left: 'calc(50% - 2.5rem)', - position: 'absolute', - width: '5rem', - height: '5rem', - transformOrigin: 'center -20rem' - }, (0, _animation.swingAnimation)(theme.durationSeconds, 0, theme.easing), { - '&:before': { - content: '""', - height: '20rem', - width: 2, - backgroundColor: theme.colorYarn, - left: 'calc(50% - 1px)', - bottom: '20rem' - } - }), - catWrap: _extends({ - position: 'absolute', - top: 0, - left: 'calc(50% - 45px)', - width: 90, - height: 130 - }, (0, _animation.reverseSwingAnimation)(theme.durationSeconds, 0, theme.easing), { - transformOrigin: 'top center' - }), - cat: _extends({ - position: 'absolute', - top: 0, - left: 0, - width: '100%', - height: '100%' - }, (0, _animation.swingAnimation)(theme.durationSeconds, 200), { - transformOrigin: 'top center' - }) - }; - - var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles, { link: true }).attach(), - classes = _jss$createStyleSheet.classes; - - exports.default = function () { - var root = document.createElement('div'); - root.className = classes.root; - - root.innerHTML = '\n
\n ' + (0, _yarn2.default)() + '\n
\n
\n ' + (0, _upperBody2.default)() + '\n ' + (0, _lowerBody2.default)() + '\n
\n
\n
\n '; - return root; - }; - -/***/ }, -/* 58 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _jss = __webpack_require__(2); - - var _jss2 = _interopRequireDefault(_jss); - - var _theme = __webpack_require__(56); - - var theme = _interopRequireWildcard(_theme); - - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var styles = { - yarn: { - position: 'absolute', - top: 0, - left: 0, - width: 80, - height: 80, - borderRadius: '50%', - backgroundImage: 'radial-gradient(circle at top left, #e97c7f, ' + theme.colorYarn + ' 50%, #af1d22)', - zIndex: 1, - '&:before': { - content: '""', - left: 'calc(50% + 7px)', - position: 'absolute', - width: 20, - height: 20, - borderRadius: '50%', - backgroundColor: '#fff', - top: -1 - }, - '&:after': { - content: '""', - right: 'calc(50% + 7px)', - position: 'absolute', - width: 20, - height: 20, - borderRadius: '50%', - backgroundColor: '#fff', - top: -1 - } - } - }; - - var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles).attach(), - classes = _jss$createStyleSheet.classes; - - exports.default = function () { - return '
'; - }; - -/***/ }, -/* 59 */ -/***/ function(module, exports, __webpack_require__) { +var _isInBrowser2 = _interopRequireDefault(_isInBrowser); - 'use strict'; +var _prefix = __webpack_require__(41); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _prefix2 = _interopRequireDefault(_prefix); - var _jss = __webpack_require__(2); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _jss2 = _interopRequireDefault(_jss); +var cache = {}; +var el = void 0; - var _theme = __webpack_require__(56); +if (_isInBrowser2['default']) el = document.createElement('p'); - var theme = _interopRequireWildcard(_theme); +/** + * Returns prefixed value if needed. Returns `false` if value is not supported. + * + * @param {String} property + * @param {String} value + * @return {String|Boolean} + * @api public + */ +function supportedValue(property, value) { + // For server-side rendering. + if (!el) return value; - var _face = __webpack_require__(60); + // It is a string or a number as a string like '1'. + // We want only prefixable values here. + if (typeof value !== 'string' || !isNaN(parseInt(value, 10))) return value; - var _face2 = _interopRequireDefault(_face); + var cacheKey = property + value; - var _hand = __webpack_require__(412); + if (cache[cacheKey] != null) return cache[cacheKey]; - var _hand2 = _interopRequireDefault(_hand); + // IE can even throw an error in some cases, for e.g. style.content = 'bar' + try { + // Test value as it is. + el.style[property] = value; + } catch (err) { + cache[cacheKey] = false; + return false; + } - var _ear = __webpack_require__(413); + // Value is supported as it is. + if (el.style[property] !== '') { + cache[cacheKey] = value; + } else { + // Test value with vendor prefix. + value = _prefix2['default'].css + value; - var _ear2 = _interopRequireDefault(_ear); + // Hardcode test to convert "flex" to "-ms-flexbox" for IE10. + if (value === '-ms-flex') value = '-ms-flexbox'; - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + el.style[property] = value; - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + // Value is supported with vendor prefix. + if (el.style[property] !== '') cache[cacheKey] = value; + } - var styles = { - catUpper: { - position: 'absolute', - top: 0, - left: 0, - width: '100%', - height: '100%', - transformOrigin: 'top center', - zIndex: 1 - }, - catHead: { - width: 90, - height: 90, - backgroundImage: 'radial-gradient(circle at 10px 10px, #ffffff, #ffffff 40%, ' + theme.colorFurLight + ' 65%, ' + theme.colorFurDark + ')', - borderRadius: '50%', - top: 'calc(100% - 45px)' - }, - catEars: { - position: 'absolute', - top: 0, - left: 0, - height: '50%', - width: '100%', - zIndex: -1 - } - }; + if (!cache[cacheKey]) cache[cacheKey] = false; - var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles).attach(), - classes = _jss$createStyleSheet.classes; + // Reset style value. + el.style[property] = ''; - exports.default = function () { - return '\n
\n ' + (0, _hand2.default)() + '\n ' + (0, _hand2.default)() + '\n
\n
\n ' + (0, _ear2.default)() + '\n ' + (0, _ear2.default)() + '\n
\n ' + (0, _face2.default)() + '\n
\n
\n'; - }; + return cache[cacheKey]; +} -/***/ }, -/* 60 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - var _jss = __webpack_require__(2); - - var _jss2 = _interopRequireDefault(_jss); - - var _theme = __webpack_require__(56); - - var theme = _interopRequireWildcard(_theme); - - var _animation = __webpack_require__(61); - - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var styles = { - catFace: _extends({ - position: 'absolute', - top: 0, - left: 0, - height: '100%', - width: '100%' - }, (0, _animation.faceAnimation)(theme.durationSeconds, 0, theme.easing), { - transformStyle: 'preserve-3d', - perspective: 100 - }), - catEyes: _extends({ - position: 'absolute', - top: '50%', - width: '100%', - height: 6 - }, (0, _animation.blinkAnimation)(theme.durationSeconds, 0, 'step-end'), { - '&:before': { - content: '""', - left: 20, - position: 'absolute', - height: 6, - width: 6, - borderRadius: '50%', - backgroundColor: theme.colorFeatures - }, - '&:after': { - content: '""', - right: 20, - position: 'absolute', - height: 6, - width: 6, - borderRadius: '50%', - backgroundColor: theme.colorFeatures - } - }), - catMouth: { - position: 'absolute', - width: 12, - height: 8, - backgroundColor: theme.colorFeatures, - top: '60%', - left: 'calc(50% - 6px)', - borderTopLeftRadius: '50% 30%', - borderTopRightRadius: '50% 30%', - borderBottomLeftRadius: '50% 70%', - borderBottomRightRadius: '50% 70%', - transform: 'translateZ(10px)', - '&:before': { - content: '""', - borderLeftColor: 'transparent', - right: 'calc(50% - 1px)', - transformOrigin: 'top right', - transform: 'rotate(10deg)', - position: 'absolute', - width: '90%', - height: '100%', - border: '2px solid ' + theme.colorFeaturesLight, - top: '80%', - borderRadius: 100, - borderTopColor: 'transparent', - zIndex: -1 - }, - '&:after': { - content: '""', - borderRightColor: 'transparent', - left: 'calc(50% - 1px)', - transformOrigin: 'top left', - transform: 'rotate(-10deg)', - position: 'absolute', - width: '90%', - height: '100%', - border: '2px solid ' + theme.colorFeaturesLight, - top: '80%', - borderRadius: 100, - borderTopColor: 'transparent', - zIndex: -1 - } - }, - catWhiskers: { - width: '50%', - height: 8, - position: 'absolute', - bottom: '25%', - left: '25%', - transformStyle: 'preserve-3d', - perspective: 60, - '&:before': { - content: '""', - right: '100%', - transformOrigin: 'right center', - transform: 'rotateY(70deg) rotateZ(-10deg)', - position: 'absolute', - height: '100%', - width: '30%', - border: '2px solid ' + theme.colorFeaturesLight, - borderLeft: 'none', - borderRight: 'none' - }, - '&:after': { - content: '""', - left: '100%', - transformOrigin: 'left center', - transform: 'rotateY(-70deg) rotateZ(10deg)', - position: 'absolute', - height: '100%', - width: '30%', - border: '2px solid ' + theme.colorFeaturesLight, - borderLeft: 'none', - borderRight: 'none' - } - } - }; - - var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles, { link: true }).attach(), - classes = _jss$createStyleSheet.classes; - - exports.default = function () { - return '\n
\n
\n
\n
\n
\n'; - }; - -/***/ }, -/* 61 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 127 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports['default'] = jssPropsSort; +/** + * Sort props by length. + */ +function jssPropsSort() { + function sort(prop0, prop1) { + return prop0.length - prop1.length; + } + + function onProcessStyle(style, rule) { + if (rule.type !== 'style') return style; + + var newStyle = {}; + var props = Object.keys(style).sort(sort); + for (var prop in props) { + newStyle[props[prop]] = style[props[prop]]; + } + return newStyle; + } + + return { onProcessStyle: onProcessStyle }; +} + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +Object.defineProperty(exports, "__esModule", { + value: true +}); - exports.faceAnimation = faceAnimation; - exports.blinkAnimation = blinkAnimation; - exports.swingLegAnimation = swingLegAnimation; - exports.swingTailAnimation = swingTailAnimation; - exports.swingAnimation = swingAnimation; - exports.reverseSwingAnimation = reverseSwingAnimation; - exports.bobAnimation = bobAnimation; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - var _rxjs = __webpack_require__(62); +var _jss = __webpack_require__(10); - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +var _jss2 = _interopRequireDefault(_jss); - /* CONSTATNST */ +var _theme = __webpack_require__(12); - var TRANSFORM = 'transform'; +var theme = _interopRequireWildcard(_theme); - var percents = [100, 87.5, 75, 62.5, 50, 37.5, 25, 12.5, 0]; +var _yarn = __webpack_require__(129); - /* UTILS */ +var _yarn2 = _interopRequireDefault(_yarn); - function createIterations(percents, values) { - return percents.map(function (percent, i) { - return { - percent: percent, - value: values[i] - }; - }); - } - - function createAnimationLoader(duration) { - var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; +var _upperBody = __webpack_require__(130); - return _rxjs.Observable.interval(100).delay(delay).startWith(0).scan(function (x) { - return x > duration * 10 ? 0 : x + 1; - }, 0).map(function (x) { - return x * 10 / duration; - }); - } +var _upperBody2 = _interopRequireDefault(_upperBody); - function getAnimationValue($animationLoader, iterations) { - return $animationLoader.map(function (percent) { - for (var i = 0; i < iterations.length; i++) { - if (percent >= iterations[i].percent) { - return iterations[i].value; - } - } - return iterations[iterations.length - 1].value; - }); - } +var _lowerBody = __webpack_require__(415); - function getTransformTransition() { - var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - var transitionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'linear'; +var _lowerBody2 = _interopRequireDefault(_lowerBody); - return { transition: TRANSFORM + ' ' + time + 's ' + transitionType }; - } +var _animation = __webpack_require__(20); - function createAnimation(duration, delay, transitionType, transionTime, iterations, modifyStyle) { - var $animationLoader = createAnimationLoader(duration, delay); - return _extends(_defineProperty({}, TRANSFORM, getAnimationValue($animationLoader, iterations).map(modifyStyle)), getTransformTransition(transionTime, transitionType)); - } +var _controlledAnimation = __webpack_require__(418); - function createRotateAnimation(duration, delay, transitionType, values) { - var iterations = createIterations(percents, values); - return createAnimation(duration, delay, transitionType, 1, iterations, function (x) { - return 'rotate(' + x + 'deg)'; - }); - } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - /* ANIMATIONS */ +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - function faceAnimation(duration, delay, transitionType) { - var values = [-2.5, 5, -7.5, 11.5, -11.5, 7.5, -5, 5, -2.5]; - var iterations = createIterations(percents, values); - return createAnimation(duration, delay, transitionType, 0.9, iterations, function (x) { - return 'translateX(' + x + 'px)'; - }); - } +var styles = { + root: _extends({ + width: '100%', + height: '100%' + }, (0, _animation.bobAnimation)(theme.durationSeconds, 0, theme.easing)), + scene: _extends({ + top: '10rem', + left: 'calc(50% - 2.5rem)', + position: 'absolute', + width: '5rem', + height: '5rem', + transformOrigin: 'center -' + theme.yarnLength + 'rem' + }, (0, _controlledAnimation.controlledSwingAnimation)(1, theme.easing, theme.yarnLength), { + '&:before': { + content: '""', + height: theme.yarnLength + 'rem', + width: 2, + backgroundColor: theme.colorYarn, + left: 'calc(50% - 1px)', + bottom: theme.yarnLength + 'rem' + } + }), + catWrap: _extends({ + position: 'absolute', + top: 0, + left: 'calc(50% - 45px)', + width: 90, + height: 130 + }, (0, _animation.reverseSwingAnimation)(theme.durationSeconds, 0, theme.easing), { + transformOrigin: 'top center' + }), + cat: _extends({ + position: 'absolute', + top: 0, + left: 0, + width: '100%', + height: '100%' + }, (0, _animation.swingAnimation)(theme.durationSeconds, 200), { + transformOrigin: 'top center' + }) +}; - function blinkAnimation(duration, delay, transitionType) { - var iterations = [{ percent: 80, value: 1 }, { percent: 78, value: 0.1 }, { percent: 25, value: 1 }, { percent: 23, value: 0.1 }, { percent: 10, value: 1 }, { percent: 8, value: 0.1 }]; - return createAnimation(duration, delay, transitionType, 0.6, iterations, function (x) { - return 'scaleY(' + x + ')'; - }); - } +var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles, { link: true }).attach(), + classes = _jss$createStyleSheet.classes; - function swingLegAnimation(duration, delay, transitionType) { - var values = [0.5, -1, 1.5, -2.3, 2.4, -1.5, 1, -1, 0.5]; - return createRotateAnimation(duration, delay, transitionType, values); - } +exports.default = function () { + var root = document.createElement('div'); + root.className = classes.root; - function swingTailAnimation(duration, delay, transitionType) { - var values = [-2, 4, -6, 9.2, -9.2, 6, -4, 4, -2]; - return createRotateAnimation(duration, delay, transitionType, values); - } + root.innerHTML = '\n
\n ' + (0, _yarn2.default)() + '\n
\n
\n ' + (0, _upperBody2.default)() + '\n ' + (0, _lowerBody2.default)() + '\n
\n
\n
\n '; + return root; +}; - function swingAnimation(duration, delay, transitionType) { - var values = [5, -10, 15, -23, 23, -15, 10, -10, 5]; - return createRotateAnimation(duration, delay, transitionType, values); - } +/***/ }), +/* 129 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _jss = __webpack_require__(10); + +var _jss2 = _interopRequireDefault(_jss); + +var _theme = __webpack_require__(12); + +var theme = _interopRequireWildcard(_theme); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var styles = { + yarn: { + position: 'absolute', + top: 0, + left: 0, + width: 80, + height: 80, + borderRadius: '50%', + backgroundImage: 'radial-gradient(circle at top left, #e97c7f, ' + theme.colorYarn + ' 50%, #af1d22)', + zIndex: 1, + '&:before': { + content: '""', + left: 'calc(50% + 7px)', + position: 'absolute', + width: 20, + height: 20, + borderRadius: '50%', + backgroundColor: '#fff', + top: -1 + }, + '&:after': { + content: '""', + right: 'calc(50% + 7px)', + position: 'absolute', + width: 20, + height: 20, + borderRadius: '50%', + backgroundColor: '#fff', + top: -1 + } + } +}; + +var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles).attach(), + classes = _jss$createStyleSheet.classes; + +exports.default = function () { + return '
'; +}; + +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { - function reverseSwingAnimation(duration, delay, transitionType) { - var values = [-5, 10, -15, 23, -23, 15, -10, 10, -5]; - return createRotateAnimation(duration, delay, transitionType, values); - } +"use strict"; - function bobAnimation(duration, delay, transitionType) { - var iterations = [{ percent: 100, value: 0.4 }, { percent: 93.75, value: -0.4 }, { percent: 87.5, value: 0.4 }, { percent: 81.25, value: -0.4 }, { percent: 75, value: 0.4 }, { percent: 68.75, value: -0.4 }, { percent: 62.5, value: 0.4 }, { percent: 56.25, value: -0.4 }, { percent: 50, value: 0.4 }, { percent: 43.75, value: -0.4 }, { percent: 37.5, value: 0.4 }, { percent: 31.25, value: -0.4 }, { percent: 25, value: 0.4 }, { percent: 18.75, value: -0.4 }, { percent: 12.5, value: 0.4 }, { percent: 6.25, value: -0.4 }, { percent: 0, value: 0.4 }]; - return createAnimation(duration, delay, transitionType, 0.3, iterations, function (x) { - return 'translateY(' + x + 'rem)'; - }); - } -/***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - /* tslint:disable:no-unused-variable */ - // Subject imported before Observable to bypass circular dependency issue since - // Subject extends Observable and Observable references Subject in it's - // definition - var Subject_1 = __webpack_require__(63); - exports.Subject = Subject_1.Subject; - exports.AnonymousSubject = Subject_1.AnonymousSubject; - /* tslint:enable:no-unused-variable */ - var Observable_1 = __webpack_require__(64); - exports.Observable = Observable_1.Observable; - // statics - /* tslint:disable:no-use-before-declare */ - __webpack_require__(80); - __webpack_require__(84); - __webpack_require__(87); - __webpack_require__(100); - __webpack_require__(104); - __webpack_require__(107); - __webpack_require__(109); - __webpack_require__(112); - __webpack_require__(120); - __webpack_require__(123); - __webpack_require__(126); - __webpack_require__(128); - __webpack_require__(131); - __webpack_require__(134); - __webpack_require__(143); - __webpack_require__(146); - __webpack_require__(149); - __webpack_require__(153); - __webpack_require__(155); - __webpack_require__(158); - __webpack_require__(161); - __webpack_require__(164); - __webpack_require__(167); - __webpack_require__(170); - __webpack_require__(174); - //dom - __webpack_require__(177); - __webpack_require__(181); - //operators - __webpack_require__(189); - __webpack_require__(191); - __webpack_require__(193); - __webpack_require__(195); - __webpack_require__(197); - __webpack_require__(199); - __webpack_require__(201); - __webpack_require__(203); - __webpack_require__(204); - __webpack_require__(205); - __webpack_require__(207); - __webpack_require__(210); - __webpack_require__(213); - __webpack_require__(215); - __webpack_require__(217); - __webpack_require__(219); - __webpack_require__(221); - __webpack_require__(223); - __webpack_require__(225); - __webpack_require__(227); - __webpack_require__(230); - __webpack_require__(232); - __webpack_require__(234); - __webpack_require__(236); - __webpack_require__(238); - __webpack_require__(240); - __webpack_require__(242); - __webpack_require__(245); - __webpack_require__(247); - __webpack_require__(249); - __webpack_require__(251); - __webpack_require__(253); - __webpack_require__(256); - __webpack_require__(261); - __webpack_require__(263); - __webpack_require__(265); - __webpack_require__(267); - __webpack_require__(269); - __webpack_require__(271); - __webpack_require__(273); - __webpack_require__(275); - __webpack_require__(276); - __webpack_require__(278); - __webpack_require__(280); - __webpack_require__(283); - __webpack_require__(284); - __webpack_require__(285); - __webpack_require__(286); - __webpack_require__(287); - __webpack_require__(289); - __webpack_require__(291); - __webpack_require__(294); - __webpack_require__(295); - __webpack_require__(296); - __webpack_require__(298); - __webpack_require__(301); - __webpack_require__(303); - __webpack_require__(305); - __webpack_require__(308); - __webpack_require__(310); - __webpack_require__(312); - __webpack_require__(313); - __webpack_require__(314); - __webpack_require__(316); - __webpack_require__(318); - __webpack_require__(320); - __webpack_require__(322); - __webpack_require__(324); - __webpack_require__(326); - __webpack_require__(328); - __webpack_require__(330); - __webpack_require__(332); - __webpack_require__(334); - __webpack_require__(336); - __webpack_require__(338); - __webpack_require__(340); - __webpack_require__(342); - __webpack_require__(344); - __webpack_require__(346); - __webpack_require__(355); - __webpack_require__(357); - __webpack_require__(359); - __webpack_require__(361); - __webpack_require__(363); - __webpack_require__(365); - __webpack_require__(367); - __webpack_require__(369); - __webpack_require__(371); - __webpack_require__(373); - __webpack_require__(375); - __webpack_require__(378); - __webpack_require__(380); - __webpack_require__(382); - __webpack_require__(384); - __webpack_require__(386); - __webpack_require__(388); - __webpack_require__(390); - __webpack_require__(392); - __webpack_require__(394); - __webpack_require__(396); - __webpack_require__(398); - __webpack_require__(399); - /* tslint:disable:no-unused-variable */ - var Subscription_1 = __webpack_require__(69); - exports.Subscription = Subscription_1.Subscription; - var Subscriber_1 = __webpack_require__(67); - exports.Subscriber = Subscriber_1.Subscriber; - var AsyncSubject_1 = __webpack_require__(83); - exports.AsyncSubject = AsyncSubject_1.AsyncSubject; - var ReplaySubject_1 = __webpack_require__(184); - exports.ReplaySubject = ReplaySubject_1.ReplaySubject; - var BehaviorSubject_1 = __webpack_require__(307); - exports.BehaviorSubject = BehaviorSubject_1.BehaviorSubject; - var ConnectableObservable_1 = __webpack_require__(293); - exports.ConnectableObservable = ConnectableObservable_1.ConnectableObservable; - var Notification_1 = __webpack_require__(119); - exports.Notification = Notification_1.Notification; - var EmptyError_1 = __webpack_require__(255); - exports.EmptyError = EmptyError_1.EmptyError; - var ArgumentOutOfRangeError_1 = __webpack_require__(244); - exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError_1.ArgumentOutOfRangeError; - var ObjectUnsubscribedError_1 = __webpack_require__(78); - exports.ObjectUnsubscribedError = ObjectUnsubscribedError_1.ObjectUnsubscribedError; - var TimeoutError_1 = __webpack_require__(377); - exports.TimeoutError = TimeoutError_1.TimeoutError; - var UnsubscriptionError_1 = __webpack_require__(74); - exports.UnsubscriptionError = UnsubscriptionError_1.UnsubscriptionError; - var timeInterval_1 = __webpack_require__(374); - exports.TimeInterval = timeInterval_1.TimeInterval; - var timestamp_1 = __webpack_require__(381); - exports.Timestamp = timestamp_1.Timestamp; - var TestScheduler_1 = __webpack_require__(401); - exports.TestScheduler = TestScheduler_1.TestScheduler; - var VirtualTimeScheduler_1 = __webpack_require__(407); - exports.VirtualTimeScheduler = VirtualTimeScheduler_1.VirtualTimeScheduler; - var AjaxObservable_1 = __webpack_require__(179); - exports.AjaxResponse = AjaxObservable_1.AjaxResponse; - exports.AjaxError = AjaxObservable_1.AjaxError; - exports.AjaxTimeoutError = AjaxObservable_1.AjaxTimeoutError; - var asap_1 = __webpack_require__(349); - var async_1 = __webpack_require__(138); - var queue_1 = __webpack_require__(185); - var animationFrame_1 = __webpack_require__(408); - var rxSubscriber_1 = __webpack_require__(76); - var iterator_1 = __webpack_require__(98); - var observable_1 = __webpack_require__(77); - /* tslint:enable:no-unused-variable */ - /** - * @typedef {Object} Rx.Scheduler - * @property {Scheduler} queue Schedules on a queue in the current event frame - * (trampoline scheduler). Use this for iteration operations. - * @property {Scheduler} asap Schedules on the micro task queue, which uses the - * fastest transport mechanism available, either Node.js' `process.nextTick()` - * or Web Worker MessageChannel or setTimeout or others. Use this for - * asynchronous conversions. - * @property {Scheduler} async Schedules work with `setInterval`. Use this for - * time-based operations. - * @property {Scheduler} animationFrame Schedules work with `requestAnimationFrame`. - * Use this for synchronizing with the platform's painting - */ - var Scheduler = { - asap: asap_1.asap, - queue: queue_1.queue, - animationFrame: animationFrame_1.animationFrame, - async: async_1.async - }; - exports.Scheduler = Scheduler; - /** - * @typedef {Object} Rx.Symbol - * @property {Symbol|string} rxSubscriber A symbol to use as a property name to - * retrieve an "Rx safe" Observer from an object. "Rx safety" can be defined as - * an object that has all of the traits of an Rx Subscriber, including the - * ability to add and remove subscriptions to the subscription chain and - * guarantees involving event triggering (can't "next" after unsubscription, - * etc). - * @property {Symbol|string} observable A symbol to use as a property name to - * retrieve an Observable as defined by the [ECMAScript "Observable" spec](https://github.com/zenparsing/es-observable). - * @property {Symbol|string} iterator The ES6 symbol to use as a property name - * to retrieve an iterator from an object. - */ - var Symbol = { - rxSubscriber: rxSubscriber_1.rxSubscriber, - observable: observable_1.observable, - iterator: iterator_1.iterator - }; - exports.Symbol = Symbol; - //# sourceMappingURL=Rx.js.map - -/***/ }, -/* 63 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var Subscriber_1 = __webpack_require__(67); - var Subscription_1 = __webpack_require__(69); - var ObjectUnsubscribedError_1 = __webpack_require__(78); - var SubjectSubscription_1 = __webpack_require__(79); - var rxSubscriber_1 = __webpack_require__(76); - /** - * @class SubjectSubscriber - */ - var SubjectSubscriber = (function (_super) { - __extends(SubjectSubscriber, _super); - function SubjectSubscriber(destination) { - _super.call(this, destination); - this.destination = destination; - } - return SubjectSubscriber; - }(Subscriber_1.Subscriber)); - exports.SubjectSubscriber = SubjectSubscriber; - /** - * @class Subject - */ - var Subject = (function (_super) { - __extends(Subject, _super); - function Subject() { - _super.call(this); - this.observers = []; - this.closed = false; - this.isStopped = false; - this.hasError = false; - this.thrownError = null; - } - Subject.prototype[rxSubscriber_1.rxSubscriber] = function () { - return new SubjectSubscriber(this); - }; - Subject.prototype.lift = function (operator) { - var subject = new AnonymousSubject(this, this); - subject.operator = operator; - return subject; - }; - Subject.prototype.next = function (value) { - if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); - } - if (!this.isStopped) { - var observers = this.observers; - var len = observers.length; - var copy = observers.slice(); - for (var i = 0; i < len; i++) { - copy[i].next(value); - } - } - }; - Subject.prototype.error = function (err) { - if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); - } - this.hasError = true; - this.thrownError = err; - this.isStopped = true; - var observers = this.observers; - var len = observers.length; - var copy = observers.slice(); - for (var i = 0; i < len; i++) { - copy[i].error(err); - } - this.observers.length = 0; - }; - Subject.prototype.complete = function () { - if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); - } - this.isStopped = true; - var observers = this.observers; - var len = observers.length; - var copy = observers.slice(); - for (var i = 0; i < len; i++) { - copy[i].complete(); - } - this.observers.length = 0; - }; - Subject.prototype.unsubscribe = function () { - this.isStopped = true; - this.closed = true; - this.observers = null; - }; - Subject.prototype._trySubscribe = function (subscriber) { - if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); - } - else { - return _super.prototype._trySubscribe.call(this, subscriber); - } - }; - Subject.prototype._subscribe = function (subscriber) { - if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); - } - else if (this.hasError) { - subscriber.error(this.thrownError); - return Subscription_1.Subscription.EMPTY; - } - else if (this.isStopped) { - subscriber.complete(); - return Subscription_1.Subscription.EMPTY; - } - else { - this.observers.push(subscriber); - return new SubjectSubscription_1.SubjectSubscription(this, subscriber); - } - }; - Subject.prototype.asObservable = function () { - var observable = new Observable_1.Observable(); - observable.source = this; - return observable; - }; - Subject.create = function (destination, source) { - return new AnonymousSubject(destination, source); - }; - return Subject; - }(Observable_1.Observable)); - exports.Subject = Subject; - /** - * @class AnonymousSubject - */ - var AnonymousSubject = (function (_super) { - __extends(AnonymousSubject, _super); - function AnonymousSubject(destination, source) { - _super.call(this); - this.destination = destination; - this.source = source; - } - AnonymousSubject.prototype.next = function (value) { - var destination = this.destination; - if (destination && destination.next) { - destination.next(value); - } - }; - AnonymousSubject.prototype.error = function (err) { - var destination = this.destination; - if (destination && destination.error) { - this.destination.error(err); - } - }; - AnonymousSubject.prototype.complete = function () { - var destination = this.destination; - if (destination && destination.complete) { - this.destination.complete(); - } - }; - AnonymousSubject.prototype._subscribe = function (subscriber) { - var source = this.source; - if (source) { - return this.source.subscribe(subscriber); - } - else { - return Subscription_1.Subscription.EMPTY; - } - }; - return AnonymousSubject; - }(Subject)); - exports.AnonymousSubject = AnonymousSubject; - //# sourceMappingURL=Subject.js.map - -/***/ }, -/* 64 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var root_1 = __webpack_require__(65); - var toSubscriber_1 = __webpack_require__(66); - var observable_1 = __webpack_require__(77); - /** - * A representation of any set of values over any amount of time. This is the most basic building block - * of RxJS. - * - * @class Observable - */ - var Observable = (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(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 observable with the Operator applied - */ - Observable.prototype.lift = function (operator) { - var observable = new Observable(); - observable.source = this; - observable.operator = operator; - return observable; - }; - /** - * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit. - * - * Use it when you have all these Observables, but still nothing is happening. - * - * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It - * might be for example a function that you passed to a {@link create} static factory, but most of the time it is - * a library implementation, which defines what and when will be emitted by an Observable. This means that calling - * `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often - * thought. - * - * Apart from starting the execution of an Observable, this method allows you to listen for values - * that an Observable emits, as well as for when it completes or errors. You can achieve this in two - * following ways. - * - * The first way is creating an object that implements {@link Observer} interface. It should have methods - * defined by that interface, but note that it should be just a regular JavaScript object, which you can create - * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular do - * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also - * that your object does not have to implement all methods. If you find yourself creating a method that doesn't - * do anything, you can simply omit it. Note however, that if `error` method is not provided, all errors will - * be left uncaught. - * - * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods. - * This means you can provide three functions as arguments to `subscribe`, where first function is equivalent - * of a `next` method, second of an `error` method and third of a `complete` method. Just as in case of Observer, - * if you do not need to listen for something, you can omit a function, preferably by passing `undefined` or `null`, - * since `subscribe` recognizes these functions by where they were placed in function call. When it comes - * to `error` function, just as before, if not provided, errors emitted by an Observable will be thrown. - * - * Whatever style of calling `subscribe` you use, in both cases it returns a Subscription object. - * This object allows you to call `unsubscribe` on it, which in turn will stop work that an Observable does and will clean - * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback - * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable. - * - * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously. - * It is an Observable itself that decides when these functions will be called. For example {@link of} - * by default emits all its values synchronously. Always check documentation for how given Observable - * will behave when subscribed and if its default behavior can be modified with a {@link Scheduler}. - * - * @example Subscribe with an Observer - * const sumObserver = { - * sum: 0, - * next(value) { - * console.log('Adding: ' + value); - * this.sum = this.sum + value; - * }, - * error() { // We actually could just remove this method, - * }, // since we do not really care about errors right now. - * complete() { - * console.log('Sum equals: ' + this.sum); - * } - * }; - * - * Rx.Observable.of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes. - * .subscribe(sumObserver); - * - * // Logs: - * // "Adding: 1" - * // "Adding: 2" - * // "Adding: 3" - * // "Sum equals: 6" - * - * - * @example Subscribe with functions - * let sum = 0; - * - * Rx.Observable.of(1, 2, 3) - * .subscribe( - * function(value) { - * console.log('Adding: ' + value); - * sum = sum + value; - * }, - * undefined, - * function() { - * console.log('Sum equals: ' + sum); - * } - * ); - * - * // Logs: - * // "Adding: 1" - * // "Adding: 2" - * // "Adding: 3" - * // "Sum equals: 6" - * - * - * @example Cancel a subscription - * const subscription = Rx.Observable.interval(1000).subscribe( - * num => console.log(num), - * undefined, - * () => console.log('completed!') // Will not be called, even - * ); // when cancelling subscription - * - * - * setTimeout(() => { - * subscription.unsubscribe(); - * console.log('unsubscribed!'); - * }, 2500); - * - * // Logs: - * // 0 after 1s - * // 1 after 2s - * // "unsubscribed!" after 2.5s - * - * - * @param {Observer|Function} observerOrNext (optional) Either an observer with methods to be called, - * or the first of three possible handlers, which is the handler for each value emitted from the subscribed - * Observable. - * @param {Function} error (optional) A handler for a terminal event resulting from an error. If no error handler is provided, - * the error will be thrown as unhandled. - * @param {Function} complete (optional) A handler for a terminal event resulting from successful completion. - * @return {ISubscription} a subscription reference to the registered handlers - * @method subscribe - */ - Observable.prototype.subscribe = function (observerOrNext, error, complete) { - var operator = this.operator; - var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete); - if (operator) { - operator.call(sink, this.source); - } - else { - sink.add(this.source ? this._subscribe(sink) : this._trySubscribe(sink)); - } - if (sink.syncErrorThrowable) { - sink.syncErrorThrowable = false; - if (sink.syncErrorThrown) { - throw sink.syncErrorValue; - } - } - return sink; - }; - Observable.prototype._trySubscribe = function (sink) { - try { - return this._subscribe(sink); - } - catch (err) { - sink.syncErrorThrown = true; - sink.syncErrorValue = err; - sink.error(err); - } - }; - /** - * @method forEach - * @param {Function} next a handler for each value emitted by the observable - * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise - * @return {Promise} a promise that either resolves on observable completion or - * rejects with the handled error - */ - Observable.prototype.forEach = function (next, PromiseCtor) { - var _this = this; - if (!PromiseCtor) { - if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) { - PromiseCtor = root_1.root.Rx.config.Promise; - } - else if (root_1.root.Promise) { - PromiseCtor = root_1.root.Promise; - } - } - if (!PromiseCtor) { - throw new Error('no Promise impl found'); - } - return new PromiseCtor(function (resolve, reject) { - // Must be declared in a separate statement to avoid a RefernceError when - // accessing subscription below in the closure due to Temporal Dead Zone. - var subscription; - subscription = _this.subscribe(function (value) { - if (subscription) { - // if there is a subscription, then we can surmise - // the next handling is asynchronous. Any errors thrown - // need to be rejected explicitly and unsubscribe must be - // called manually - try { - next(value); - } - catch (err) { - reject(err); - subscription.unsubscribe(); - } - } - else { - // if there is NO subscription, then we're getting a nexted - // value synchronously during subscription. We can just call it. - // If it errors, Observable's `subscribe` will ensure the - // unsubscription logic is called, then synchronously rethrow the error. - // After that, Promise will trap the error and send it - // down the rejection path. - next(value); - } - }, reject, resolve); - }); - }; - Observable.prototype._subscribe = function (subscriber) { - return this.source.subscribe(subscriber); - }; - /** - * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable - * @method Symbol.observable - * @return {Observable} this instance of the observable - */ - Observable.prototype[observable_1.observable] = function () { - return this; - }; - // HACK: Since TypeScript inherits static properties too, we have to - // fight against TypeScript here so Subject can have a different static create signature - /** - * Creates a new cold Observable by calling the Observable constructor - * @static true - * @owner Observable - * @method create - * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor - * @return {Observable} a new cold observable - */ - Observable.create = function (subscribe) { - return new Observable(subscribe); - }; - return Observable; - }()); - exports.Observable = Observable; - //# sourceMappingURL=Observable.js.map - -/***/ }, -/* 65 */ -/***/ function(module, exports) { - - /* WEBPACK VAR INJECTION */(function(global) {"use strict"; - // 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 global !== 'undefined' && global; - var _root = __window || __global || __self; - exports.root = _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)'); - } - })(); - //# sourceMappingURL=root.js.map - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) - -/***/ }, -/* 66 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Subscriber_1 = __webpack_require__(67); - var rxSubscriber_1 = __webpack_require__(76); - var Observer_1 = __webpack_require__(75); - function toSubscriber(nextOrObserver, error, complete) { - if (nextOrObserver) { - if (nextOrObserver instanceof Subscriber_1.Subscriber) { - return nextOrObserver; - } - if (nextOrObserver[rxSubscriber_1.rxSubscriber]) { - return nextOrObserver[rxSubscriber_1.rxSubscriber](); - } - } - if (!nextOrObserver && !error && !complete) { - return new Subscriber_1.Subscriber(Observer_1.empty); - } - return new Subscriber_1.Subscriber(nextOrObserver, error, complete); - } - exports.toSubscriber = toSubscriber; - //# sourceMappingURL=toSubscriber.js.map +Object.defineProperty(exports, "__esModule", { + value: true +}); -/***/ }, -/* 67 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 isFunction_1 = __webpack_require__(68); - var Subscription_1 = __webpack_require__(69); - var Observer_1 = __webpack_require__(75); - var rxSubscriber_1 = __webpack_require__(76); - /** - * 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 - */ - var Subscriber = (function (_super) { - __extends(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_1.empty; - break; - case 1: - if (!destinationOrNext) { - this.destination = Observer_1.empty; - break; - } - if (typeof destinationOrNext === 'object') { - if (destinationOrNext instanceof Subscriber) { - 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_1.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} 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)); - exports.Subscriber = Subscriber; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SafeSubscriber = (function (_super) { - __extends(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_1.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)); - //# sourceMappingURL=Subscriber.js.map - -/***/ }, -/* 68 */ -/***/ function(module, exports) { +var _jss = __webpack_require__(10); - "use strict"; - function isFunction(x) { - return typeof x === 'function'; - } - exports.isFunction = isFunction; - //# sourceMappingURL=isFunction.js.map +var _jss2 = _interopRequireDefault(_jss); -/***/ }, -/* 69 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var isArray_1 = __webpack_require__(70); - var isObject_1 = __webpack_require__(71); - var isFunction_1 = __webpack_require__(68); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var UnsubscriptionError_1 = __webpack_require__(74); - /** - * 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_1.errorObject) { - hasErrors = true; - errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ? - flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]); - } - } - if (isArray_1.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_1.errorObject) { - hasErrors = true; - errors = errors || []; - var err = errorObject_1.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; - }()); - exports.Subscription = Subscription; - function flattenUnsubscriptionErrors(errors) { - return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []); - } - //# sourceMappingURL=Subscription.js.map +var _theme = __webpack_require__(12); -/***/ }, -/* 70 */ -/***/ function(module, exports) { +var theme = _interopRequireWildcard(_theme); - "use strict"; - exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); - //# sourceMappingURL=isArray.js.map +var _face = __webpack_require__(131); -/***/ }, -/* 71 */ -/***/ function(module, exports) { +var _face2 = _interopRequireDefault(_face); - "use strict"; - function isObject(x) { - return x != null && typeof x === 'object'; - } - exports.isObject = isObject; - //# sourceMappingURL=isObject.js.map +var _hand = __webpack_require__(413); -/***/ }, -/* 72 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var errorObject_1 = __webpack_require__(73); - var tryCatchTarget; - function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } - catch (e) { - errorObject_1.errorObject.e = e; - return errorObject_1.errorObject; - } - } - function tryCatch(fn) { - tryCatchTarget = fn; - return tryCatcher; - } - exports.tryCatch = tryCatch; - ; - //# sourceMappingURL=tryCatch.js.map +var _hand2 = _interopRequireDefault(_hand); -/***/ }, -/* 73 */ -/***/ function(module, exports) { +var _ear = __webpack_require__(414); - "use strict"; - // typeof any so that it we don't have to cast when comparing a result to the error object - exports.errorObject = { e: {} }; - //# sourceMappingURL=errorObject.js.map +var _ear2 = _interopRequireDefault(_ear); -/***/ }, -/* 74 */ -/***/ function(module, exports) { - - "use strict"; - var __extends = (this && this.__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(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)); - exports.UnsubscriptionError = UnsubscriptionError; - //# sourceMappingURL=UnsubscriptionError.js.map - -/***/ }, -/* 75 */ -/***/ function(module, exports) { - - "use strict"; - exports.empty = { - closed: true, - next: function (value) { }, - error: function (err) { throw err; }, - complete: function () { } - }; - //# sourceMappingURL=Observer.js.map - -/***/ }, -/* 76 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var root_1 = __webpack_require__(65); - var Symbol = root_1.root.Symbol; - exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ? - Symbol.for('rxSubscriber') : '@@rxSubscriber'; - /** - * @deprecated use rxSubscriber instead - */ - exports.$$rxSubscriber = exports.rxSubscriber; - //# sourceMappingURL=rxSubscriber.js.map - -/***/ }, -/* 77 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var root_1 = __webpack_require__(65); - 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_1.root); - /** - * @deprecated use observable instead - */ - exports.$$observable = exports.observable; - //# sourceMappingURL=observable.js.map - -/***/ }, -/* 78 */ -/***/ function(module, exports) { - - "use strict"; - var __extends = (this && this.__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 an action is invalid because the object has been - * unsubscribed. - * - * @see {@link Subject} - * @see {@link BehaviorSubject} - * - * @class ObjectUnsubscribedError - */ - var ObjectUnsubscribedError = (function (_super) { - __extends(ObjectUnsubscribedError, _super); - function ObjectUnsubscribedError() { - var err = _super.call(this, 'object unsubscribed'); - this.name = err.name = 'ObjectUnsubscribedError'; - this.stack = err.stack; - this.message = err.message; - } - return ObjectUnsubscribedError; - }(Error)); - exports.ObjectUnsubscribedError = ObjectUnsubscribedError; - //# sourceMappingURL=ObjectUnsubscribedError.js.map - -/***/ }, -/* 79 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscription_1 = __webpack_require__(69); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SubjectSubscription = (function (_super) { - __extends(SubjectSubscription, _super); - function SubjectSubscription(subject, subscriber) { - _super.call(this); - this.subject = subject; - this.subscriber = subscriber; - this.closed = false; - } - SubjectSubscription.prototype.unsubscribe = function () { - if (this.closed) { - return; - } - this.closed = true; - var subject = this.subject; - var observers = subject.observers; - this.subject = null; - if (!observers || observers.length === 0 || subject.isStopped || subject.closed) { - return; - } - var subscriberIndex = observers.indexOf(this.subscriber); - if (subscriberIndex !== -1) { - observers.splice(subscriberIndex, 1); - } - }; - return SubjectSubscription; - }(Subscription_1.Subscription)); - exports.SubjectSubscription = SubjectSubscription; - //# sourceMappingURL=SubjectSubscription.js.map - -/***/ }, -/* 80 */ -/***/ function(module, exports, __webpack_require__) { +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - "use strict"; - var Observable_1 = __webpack_require__(64); - var bindCallback_1 = __webpack_require__(81); - Observable_1.Observable.bindCallback = bindCallback_1.bindCallback; - //# sourceMappingURL=bindCallback.js.map +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/***/ }, -/* 81 */ -/***/ function(module, exports, __webpack_require__) { +var styles = { + catUpper: { + position: 'absolute', + top: 0, + left: 0, + width: '100%', + height: '100%', + transformOrigin: 'top center', + zIndex: 1 + }, + catHead: { + width: 90, + height: 90, + backgroundImage: 'radial-gradient(circle at 10px 10px, #ffffff, #ffffff 40%, ' + theme.colorFurLight + ' 65%, ' + theme.colorFurDark + ')', + borderRadius: '50%', + top: 'calc(100% - 45px)' + }, + catEars: { + position: 'absolute', + top: 0, + left: 0, + height: '50%', + width: '100%', + zIndex: -1 + } +}; - "use strict"; - var BoundCallbackObservable_1 = __webpack_require__(82); - exports.bindCallback = BoundCallbackObservable_1.BoundCallbackObservable.create; - //# sourceMappingURL=bindCallback.js.map +var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles).attach(), + classes = _jss$createStyleSheet.classes; -/***/ }, -/* 82 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var AsyncSubject_1 = __webpack_require__(83); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var BoundCallbackObservable = (function (_super) { - __extends(BoundCallbackObservable, _super); - function BoundCallbackObservable(callbackFunc, selector, args, context, scheduler) { - _super.call(this); - this.callbackFunc = callbackFunc; - this.selector = selector; - this.args = args; - this.context = context; - this.scheduler = scheduler; - } - /* tslint:enable:max-line-length */ - /** - * Converts a callback API to a function that returns an Observable. - * - * Give it a function `f` of type `f(x, callback)` and - * it will return a function `g` that when called as `g(x)` will output an - * Observable. - * - * `bindCallback` is not an operator because its input and output are not - * Observables. The input is a function `func` with some parameters, but the - * last parameter must be a callback function that `func` calls when it is - * done. - * - * The output of `bindCallback` is a function that takes the same parameters - * as `func`, except the last one (the callback). When the output function - * is called with arguments, it will return an Observable. If `func` function - * calls its callback with one argument, the Observable will emit that value. - * If on the other hand callback is called with multiple values, resulting - * Observable will emit an array with these arguments. - * - * It is very important to remember, that input function `func` is not called - * when output function is, but rather when Observable returned by output - * function is subscribed. This means if `func` makes AJAX request, that request - * will be made every time someone subscribes to resulting Observable, but not before. - * - * Optionally, selector function can be passed to `bindObservable`. That function - * takes the same arguments as callback, and returns value - * that will be emitted by Observable instead of callback parameters themselves. - * Even though by default multiple arguments passed to callback appear in the stream as array, - * selector function will be called with arguments directly, just as callback would. - * This means you can imagine default selector (when one is not provided explicitly) - * as function that aggregates all its arguments into array, or simply returns first argument, - * if there is only one. - * - * Last optional parameter - {@link Scheduler} - can be used to control when call - * to `func` happens after someone subscribes to Observable, as well as when results - * passed to callback will be emitted. By default subscription to Observable calls `func` - * synchronously, but using `Scheduler.async` as last parameter will defer call to input function, - * just like wrapping that call in `setTimeout` with time `0` would. So if you use async Scheduler - * and call `subscribe` on output Observable, all function calls that are currently executing, - * will end before `func` is invoked. - * - * When it comes to emitting results passed to callback, by default they are emitted - * immediately after `func` invokes callback. In particular, if callback is called synchronously, - * then subscription to resulting Observable will call `next` function synchronously as well. - * If you want to defer that call, using `Scheduler.async` will, again, do the job. - * This means that by using `Scheduler.async` you can, in a sense, ensure that `func` - * always calls its callback asynchronously, thus avoiding terrifying Zalgo. - * - * Note that Observable created by output function will always emit only one value - * and then complete right after. Even if `func` calls callback multiple times, values from - * second and following calls will never appear in the stream. If you need to - * listen for multiple calls, you probably want to use {@link fromEvent} or - * {@link fromEventPattern} instead. - * - * If `func` depends on some context (`this` property), that context will be set - * to the same context that output function has at call time. In particular, if `func` - * is called as method of some object, in order to preserve proper behaviour, - * it is recommended to set context of output function to that object as well, - * provided `func` is not already bound. - * - * If input function calls its callback in "node style" (i.e. first argument to callback is - * optional error parameter signaling whether call failed or not), {@link bindNodeCallback} - * provides convenient error handling and probably is a better choice. - * `bindCallback` will treat such functions without any difference and error parameter - * (whether passed or not) will always be interpreted as regular callback argument. - * - * - * @example Convert jQuery's getJSON to an Observable API - * // Suppose we have jQuery.getJSON('/my/url', callback) - * var getJSONAsObservable = Rx.Observable.bindCallback(jQuery.getJSON); - * var result = getJSONAsObservable('/my/url'); - * result.subscribe(x => console.log(x), e => console.error(e)); - * - * - * @example Receive array of arguments passed to callback - * someFunction((a, b, c) => { - * console.log(a); // 5 - * console.log(b); // 'some string' - * console.log(c); // {someProperty: 'someValue'} - * }); - * - * const boundSomeFunction = Rx.Observable.bindCallback(someFunction); - * boundSomeFunction().subscribe(values => { - * console.log(values) // [5, 'some string', {someProperty: 'someValue'}] - * }); - * - * - * @example Use bindCallback with selector function - * someFunction((a, b, c) => { - * console.log(a); // 'a' - * console.log(b); // 'b' - * console.log(c); // 'c' - * }); - * - * const boundSomeFunction = Rx.Observable.bindCallback(someFunction, (a, b, c) => a + b + c); - * boundSomeFunction().subscribe(value => { - * console.log(value) // 'abc' - * }); - * - * - * @example Compare behaviour with and without async Scheduler - * function iCallMyCallbackSynchronously(cb) { - * cb(); - * } - * - * const boundSyncFn = Rx.Observable.bindCallback(iCallMyCallbackSynchronously); - * const boundAsyncFn = Rx.Observable.bindCallback(iCallMyCallbackSynchronously, null, Rx.Scheduler.async); - * - * boundSyncFn().subscribe(() => console.log('I was sync!')); - * boundAsyncFn().subscribe(() => console.log('I was async!')); - * console.log('This happened...'); - * - * // Logs: - * // I was sync! - * // This happened... - * // I was async! - * - * - * @example Use bindCallback on object method - * const boundMethod = Rx.Observable.bindCallback(someObject.methodWithCallback); - * boundMethod.call(someObject) // make sure methodWithCallback has access to someObject - * .subscribe(subscriber); - * - * - * @see {@link bindNodeCallback} - * @see {@link from} - * @see {@link fromPromise} - * - * @param {function} func Function with a callback as the last parameter. - * @param {function} [selector] A function which takes the arguments from the - * callback and maps those to a value to emit on the output Observable. - * @param {Scheduler} [scheduler] The scheduler on which to schedule the - * callbacks. - * @return {function(...params: *): Observable} A function which returns the - * Observable that delivers the same values the callback would deliver. - * @static true - * @name bindCallback - * @owner Observable - */ - BoundCallbackObservable.create = function (func, selector, scheduler) { - if (selector === void 0) { selector = undefined; } - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - return new BoundCallbackObservable(func, selector, args, this, scheduler); - }; - }; - BoundCallbackObservable.prototype._subscribe = function (subscriber) { - var callbackFunc = this.callbackFunc; - var args = this.args; - var scheduler = this.scheduler; - var subject = this.subject; - if (!scheduler) { - if (!subject) { - subject = this.subject = new AsyncSubject_1.AsyncSubject(); - var handler = function handlerFn() { - var innerArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - innerArgs[_i - 0] = arguments[_i]; - } - var source = handlerFn.source; - var selector = source.selector, subject = source.subject; - if (selector) { - var result_1 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); - if (result_1 === errorObject_1.errorObject) { - subject.error(errorObject_1.errorObject.e); - } - else { - subject.next(result_1); - subject.complete(); - } - } - else { - subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs); - subject.complete(); - } - }; - // use named function instance to avoid closure. - handler.source = this; - var result = tryCatch_1.tryCatch(callbackFunc).apply(this.context, args.concat(handler)); - if (result === errorObject_1.errorObject) { - subject.error(errorObject_1.errorObject.e); - } - } - return subject.subscribe(subscriber); - } - else { - return scheduler.schedule(BoundCallbackObservable.dispatch, 0, { source: this, subscriber: subscriber, context: this.context }); - } - }; - BoundCallbackObservable.dispatch = function (state) { - var self = this; - var source = state.source, subscriber = state.subscriber, context = state.context; - var callbackFunc = source.callbackFunc, args = source.args, scheduler = source.scheduler; - var subject = source.subject; - if (!subject) { - subject = source.subject = new AsyncSubject_1.AsyncSubject(); - var handler = function handlerFn() { - var innerArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - innerArgs[_i - 0] = arguments[_i]; - } - var source = handlerFn.source; - var selector = source.selector, subject = source.subject; - if (selector) { - var result_2 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); - if (result_2 === errorObject_1.errorObject) { - self.add(scheduler.schedule(dispatchError, 0, { err: errorObject_1.errorObject.e, subject: subject })); - } - else { - self.add(scheduler.schedule(dispatchNext, 0, { value: result_2, subject: subject })); - } - } - else { - var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs; - self.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject })); - } - }; - // use named function to pass values in without closure - handler.source = source; - var result = tryCatch_1.tryCatch(callbackFunc).apply(context, args.concat(handler)); - if (result === errorObject_1.errorObject) { - subject.error(errorObject_1.errorObject.e); - } - } - self.add(subject.subscribe(subscriber)); - }; - return BoundCallbackObservable; - }(Observable_1.Observable)); - exports.BoundCallbackObservable = BoundCallbackObservable; - function dispatchNext(arg) { - var value = arg.value, subject = arg.subject; - subject.next(value); - subject.complete(); - } - function dispatchError(arg) { - var err = arg.err, subject = arg.subject; - subject.error(err); - } - //# sourceMappingURL=BoundCallbackObservable.js.map +exports.default = function () { + return '\n
\n ' + (0, _hand2.default)() + '\n ' + (0, _hand2.default)() + '\n
\n
\n ' + (0, _ear2.default)() + '\n ' + (0, _ear2.default)() + '\n
\n ' + (0, _face2.default)() + '\n
\n
\n'; +}; -/***/ }, -/* 83 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subject_1 = __webpack_require__(63); - var Subscription_1 = __webpack_require__(69); - /** - * @class AsyncSubject - */ - var AsyncSubject = (function (_super) { - __extends(AsyncSubject, _super); - function AsyncSubject() { - _super.apply(this, arguments); - this.value = null; - this.hasNext = false; - this.hasCompleted = false; - } - AsyncSubject.prototype._subscribe = function (subscriber) { - if (this.hasError) { - subscriber.error(this.thrownError); - return Subscription_1.Subscription.EMPTY; - } - else if (this.hasCompleted && this.hasNext) { - subscriber.next(this.value); - subscriber.complete(); - return Subscription_1.Subscription.EMPTY; - } - return _super.prototype._subscribe.call(this, subscriber); - }; - AsyncSubject.prototype.next = function (value) { - if (!this.hasCompleted) { - this.value = value; - this.hasNext = true; - } - }; - AsyncSubject.prototype.error = function (error) { - if (!this.hasCompleted) { - _super.prototype.error.call(this, error); - } - }; - AsyncSubject.prototype.complete = function () { - this.hasCompleted = true; - if (this.hasNext) { - _super.prototype.next.call(this, this.value); - } - _super.prototype.complete.call(this); - }; - return AsyncSubject; - }(Subject_1.Subject)); - exports.AsyncSubject = AsyncSubject; - //# sourceMappingURL=AsyncSubject.js.map - -/***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _jss = __webpack_require__(10); + +var _jss2 = _interopRequireDefault(_jss); + +var _theme = __webpack_require__(12); + +var theme = _interopRequireWildcard(_theme); + +var _animation = __webpack_require__(20); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var styles = { + catFace: _extends({ + position: 'absolute', + top: 0, + left: 0, + height: '100%', + width: '100%' + }, (0, _animation.faceAnimation)(theme.durationSeconds, 0, theme.easing), { + transformStyle: 'preserve-3d', + perspective: 100 + }), + catEyes: _extends({ + position: 'absolute', + top: '50%', + width: '100%', + height: 6 + }, (0, _animation.blinkAnimation)(theme.durationSeconds, 0, 'step-end'), { + '&:before': { + content: '""', + left: 20, + position: 'absolute', + height: 6, + width: 6, + borderRadius: '50%', + backgroundColor: theme.colorFeatures + }, + '&:after': { + content: '""', + right: 20, + position: 'absolute', + height: 6, + width: 6, + borderRadius: '50%', + backgroundColor: theme.colorFeatures + } + }), + catMouth: { + position: 'absolute', + width: 12, + height: 8, + backgroundColor: theme.colorFeatures, + top: '60%', + left: 'calc(50% - 6px)', + borderTopLeftRadius: '50% 30%', + borderTopRightRadius: '50% 30%', + borderBottomLeftRadius: '50% 70%', + borderBottomRightRadius: '50% 70%', + transform: 'translateZ(10px)', + '&:before': { + content: '""', + borderLeftColor: 'transparent', + right: 'calc(50% - 1px)', + transformOrigin: 'top right', + transform: 'rotate(10deg)', + position: 'absolute', + width: '90%', + height: '100%', + border: '2px solid ' + theme.colorFeaturesLight, + top: '80%', + borderRadius: 100, + borderTopColor: 'transparent', + zIndex: -1 + }, + '&:after': { + content: '""', + borderRightColor: 'transparent', + left: 'calc(50% - 1px)', + transformOrigin: 'top left', + transform: 'rotate(-10deg)', + position: 'absolute', + width: '90%', + height: '100%', + border: '2px solid ' + theme.colorFeaturesLight, + top: '80%', + borderRadius: 100, + borderTopColor: 'transparent', + zIndex: -1 + } + }, + catWhiskers: { + width: '50%', + height: 8, + position: 'absolute', + bottom: '25%', + left: '25%', + transformStyle: 'preserve-3d', + perspective: 60, + '&:before': { + content: '""', + right: '100%', + transformOrigin: 'right center', + transform: 'rotateY(70deg) rotateZ(-10deg)', + position: 'absolute', + height: '100%', + width: '30%', + border: '2px solid ' + theme.colorFeaturesLight, + borderLeft: 'none', + borderRight: 'none' + }, + '&:after': { + content: '""', + left: '100%', + transformOrigin: 'left center', + transform: 'rotateY(-70deg) rotateZ(10deg)', + position: 'absolute', + height: '100%', + width: '30%', + border: '2px solid ' + theme.colorFeaturesLight, + borderLeft: 'none', + borderRight: 'none' + } + } +}; + +var _jss$createStyleSheet = _jss2.default.createStyleSheet(styles, { link: true }).attach(), + classes = _jss$createStyleSheet.classes; + +exports.default = function () { + return '\n
\n
\n
\n
\n
\n'; +}; + +/***/ }), +/* 132 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Subscriber_1 = __webpack_require__(1); +var rxSubscriber_1 = __webpack_require__(29); +var Observer_1 = __webpack_require__(61); +function toSubscriber(nextOrObserver, error, complete) { + if (nextOrObserver) { + if (nextOrObserver instanceof Subscriber_1.Subscriber) { + return nextOrObserver; + } + if (nextOrObserver[rxSubscriber_1.rxSubscriber]) { + return nextOrObserver[rxSubscriber_1.rxSubscriber](); + } + } + if (!nextOrObserver && !error && !complete) { + return new Subscriber_1.Subscriber(Observer_1.empty); + } + return new Subscriber_1.Subscriber(nextOrObserver, error, complete); +} +exports.toSubscriber = toSubscriber; +//# sourceMappingURL=toSubscriber.js.map + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var bindNodeCallback_1 = __webpack_require__(85); - Observable_1.Observable.bindNodeCallback = bindNodeCallback_1.bindNodeCallback; - //# sourceMappingURL=bindNodeCallback.js.map +"use strict"; -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { +var Observable_1 = __webpack_require__(0); +var bindCallback_1 = __webpack_require__(134); +Observable_1.Observable.bindCallback = bindCallback_1.bindCallback; +//# sourceMappingURL=bindCallback.js.map - "use strict"; - var BoundNodeCallbackObservable_1 = __webpack_require__(86); - exports.bindNodeCallback = BoundNodeCallbackObservable_1.BoundNodeCallbackObservable.create; - //# sourceMappingURL=bindNodeCallback.js.map +/***/ }), +/* 134 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 86 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var AsyncSubject_1 = __webpack_require__(83); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var BoundNodeCallbackObservable = (function (_super) { - __extends(BoundNodeCallbackObservable, _super); - function BoundNodeCallbackObservable(callbackFunc, selector, args, context, scheduler) { - _super.call(this); - this.callbackFunc = callbackFunc; - this.selector = selector; - this.args = args; - this.context = context; - this.scheduler = scheduler; - } - /* tslint:enable:max-line-length */ - /** - * Converts a Node.js-style callback API to a function that returns an - * Observable. - * - * It's just like {@link bindCallback}, but the - * callback is expected to be of type `callback(error, result)`. - * - * `bindNodeCallback` is not an operator because its input and output are not - * Observables. The input is a function `func` with some parameters, but the - * last parameter must be a callback function that `func` calls when it is - * done. The callback function is expected to follow Node.js conventions, - * where the first argument to the callback is an error object, signaling - * whether call was successful. If that object is passed to callback, it means - * something went wrong. - * - * The output of `bindNodeCallback` is a function that takes the same - * parameters as `func`, except the last one (the callback). When the output - * function is called with arguments, it will return an Observable. - * If `func` calls its callback with error parameter present, Observable will - * error with that value as well. If error parameter is not passed, Observable will emit - * second parameter. If there are more parameters (third and so on), - * Observable will emit an array with all arguments, except first error argument. - * - * Optionally `bindNodeCallback` accepts selector function, which allows you to - * make resulting Observable emit value computed by selector, instead of regular - * callback arguments. It works similarly to {@link bindCallback} selector, but - * Node.js-style error argument will never be passed to that function. - * - * Note that `func` will not be called at the same time output function is, - * but rather whenever resulting Observable is subscribed. By default call to - * `func` will happen synchronously after subscription, but that can be changed - * with proper {@link Scheduler} provided as optional third parameter. Scheduler - * can also control when values from callback will be emitted by Observable. - * To find out more, check out documentation for {@link bindCallback}, where - * Scheduler works exactly the same. - * - * As in {@link bindCallback}, context (`this` property) of input function will be set to context - * of returned function, when it is called. - * - * After Observable emits value, it will complete immediately. This means - * even if `func` calls callback again, values from second and consecutive - * calls will never appear on the stream. If you need to handle functions - * that call callbacks multiple times, check out {@link fromEvent} or - * {@link fromEventPattern} instead. - * - * Note that `bindNodeCallback` can be used in non-Node.js environments as well. - * "Node.js-style" callbacks are just a convention, so if you write for - * browsers or any other environment and API you use implements that callback style, - * `bindNodeCallback` can be safely used on that API functions as well. - * - * Remember that Error object passed to callback does not have to be an instance - * of JavaScript built-in `Error` object. In fact, it does not even have to an object. - * Error parameter of callback function is interpreted as "present", when value - * of that parameter is truthy. It could be, for example, non-zero number, non-empty - * string or boolean `true`. In all of these cases resulting Observable would error - * with that value. This means usually regular style callbacks will fail very often when - * `bindNodeCallback` is used. If your Observable errors much more often then you - * would expect, check if callback really is called in Node.js-style and, if not, - * switch to {@link bindCallback} instead. - * - * Note that even if error parameter is technically present in callback, but its value - * is falsy, it still won't appear in array emitted by Observable or in selector function. - * - * - * @example Read a file from the filesystem and get the data as an Observable - * import * as fs from 'fs'; - * var readFileAsObservable = Rx.Observable.bindNodeCallback(fs.readFile); - * var result = readFileAsObservable('./roadNames.txt', 'utf8'); - * result.subscribe(x => console.log(x), e => console.error(e)); - * - * - * @example Use on function calling callback with multiple arguments - * someFunction((err, a, b) => { - * console.log(err); // null - * console.log(a); // 5 - * console.log(b); // "some string" - * }); - * var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction); - * boundSomeFunction() - * .subscribe(value => { - * console.log(value); // [5, "some string"] - * }); - * - * - * @example Use with selector function - * someFunction((err, a, b) => { - * console.log(err); // undefined - * console.log(a); // "abc" - * console.log(b); // "DEF" - * }); - * var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction, (a, b) => a + b); - * boundSomeFunction() - * .subscribe(value => { - * console.log(value); // "abcDEF" - * }); - * - * - * @example Use on function calling callback in regular style - * someFunction(a => { - * console.log(a); // 5 - * }); - * var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction); - * boundSomeFunction() - * .subscribe( - * value => {} // never gets called - * err => console.log(err) // 5 - *); - * - * - * @see {@link bindCallback} - * @see {@link from} - * @see {@link fromPromise} - * - * @param {function} func Function with a Node.js-style callback as the last parameter. - * @param {function} [selector] A function which takes the arguments from the - * callback and maps those to a value to emit on the output Observable. - * @param {Scheduler} [scheduler] The scheduler on which to schedule the - * callbacks. - * @return {function(...params: *): Observable} A function which returns the - * Observable that delivers the same values the Node.js callback would - * deliver. - * @static true - * @name bindNodeCallback - * @owner Observable - */ - BoundNodeCallbackObservable.create = function (func, selector, scheduler) { - if (selector === void 0) { selector = undefined; } - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - return new BoundNodeCallbackObservable(func, selector, args, this, scheduler); - }; - }; - BoundNodeCallbackObservable.prototype._subscribe = function (subscriber) { - var callbackFunc = this.callbackFunc; - var args = this.args; - var scheduler = this.scheduler; - var subject = this.subject; - if (!scheduler) { - if (!subject) { - subject = this.subject = new AsyncSubject_1.AsyncSubject(); - var handler = function handlerFn() { - var innerArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - innerArgs[_i - 0] = arguments[_i]; - } - var source = handlerFn.source; - var selector = source.selector, subject = source.subject; - var err = innerArgs.shift(); - if (err) { - subject.error(err); - } - else if (selector) { - var result_1 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); - if (result_1 === errorObject_1.errorObject) { - subject.error(errorObject_1.errorObject.e); - } - else { - subject.next(result_1); - subject.complete(); - } - } - else { - subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs); - subject.complete(); - } - }; - // use named function instance to avoid closure. - handler.source = this; - var result = tryCatch_1.tryCatch(callbackFunc).apply(this.context, args.concat(handler)); - if (result === errorObject_1.errorObject) { - subject.error(errorObject_1.errorObject.e); - } - } - return subject.subscribe(subscriber); - } - else { - return scheduler.schedule(dispatch, 0, { source: this, subscriber: subscriber, context: this.context }); - } - }; - return BoundNodeCallbackObservable; - }(Observable_1.Observable)); - exports.BoundNodeCallbackObservable = BoundNodeCallbackObservable; - function dispatch(state) { - var self = this; - var source = state.source, subscriber = state.subscriber, context = state.context; - // XXX: cast to `any` to access to the private field in `source`. - var _a = source, callbackFunc = _a.callbackFunc, args = _a.args, scheduler = _a.scheduler; - var subject = source.subject; - if (!subject) { - subject = source.subject = new AsyncSubject_1.AsyncSubject(); - var handler = function handlerFn() { - var innerArgs = []; - for (var _i = 0; _i < arguments.length; _i++) { - innerArgs[_i - 0] = arguments[_i]; - } - var source = handlerFn.source; - var selector = source.selector, subject = source.subject; - var err = innerArgs.shift(); - if (err) { - self.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject })); - } - else if (selector) { - var result_2 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); - if (result_2 === errorObject_1.errorObject) { - self.add(scheduler.schedule(dispatchError, 0, { err: errorObject_1.errorObject.e, subject: subject })); - } - else { - self.add(scheduler.schedule(dispatchNext, 0, { value: result_2, subject: subject })); - } - } - else { - var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs; - self.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject })); - } - }; - // use named function to pass values in without closure - handler.source = source; - var result = tryCatch_1.tryCatch(callbackFunc).apply(context, args.concat(handler)); - if (result === errorObject_1.errorObject) { - self.add(scheduler.schedule(dispatchError, 0, { err: errorObject_1.errorObject.e, subject: subject })); - } - } - self.add(subject.subscribe(subscriber)); - } - function dispatchNext(arg) { - var value = arg.value, subject = arg.subject; - subject.next(value); - subject.complete(); - } - function dispatchError(arg) { - var err = arg.err, subject = arg.subject; - subject.error(err); - } - //# sourceMappingURL=BoundNodeCallbackObservable.js.map +"use strict"; -/***/ }, -/* 87 */ -/***/ function(module, exports, __webpack_require__) { +var BoundCallbackObservable_1 = __webpack_require__(135); +exports.bindCallback = BoundCallbackObservable_1.BoundCallbackObservable.create; +//# sourceMappingURL=bindCallback.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var combineLatest_1 = __webpack_require__(88); - Observable_1.Observable.combineLatest = combineLatest_1.combineLatest; - //# sourceMappingURL=combineLatest.js.map +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var AsyncSubject_1 = __webpack_require__(32); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var BoundCallbackObservable = (function (_super) { + __extends(BoundCallbackObservable, _super); + function BoundCallbackObservable(callbackFunc, selector, args, context, scheduler) { + _super.call(this); + this.callbackFunc = callbackFunc; + this.selector = selector; + this.args = args; + this.context = context; + this.scheduler = scheduler; + } + /* tslint:enable:max-line-length */ + /** + * Converts a callback API to a function that returns an Observable. + * + * Give it a function `f` of type `f(x, callback)` and + * it will return a function `g` that when called as `g(x)` will output an + * Observable. + * + * `bindCallback` is not an operator because its input and output are not + * Observables. The input is a function `func` with some parameters, but the + * last parameter must be a callback function that `func` calls when it is + * done. + * + * The output of `bindCallback` is a function that takes the same parameters + * as `func`, except the last one (the callback). When the output function + * is called with arguments, it will return an Observable. If `func` function + * calls its callback with one argument, the Observable will emit that value. + * If on the other hand callback is called with multiple values, resulting + * Observable will emit an array with these arguments. + * + * It is very important to remember, that input function `func` is not called + * when output function is, but rather when Observable returned by output + * function is subscribed. This means if `func` makes AJAX request, that request + * will be made every time someone subscribes to resulting Observable, but not before. + * + * Optionally, selector function can be passed to `bindObservable`. That function + * takes the same arguments as callback, and returns value + * that will be emitted by Observable instead of callback parameters themselves. + * Even though by default multiple arguments passed to callback appear in the stream as array, + * selector function will be called with arguments directly, just as callback would. + * This means you can imagine default selector (when one is not provided explicitly) + * as function that aggregates all its arguments into array, or simply returns first argument, + * if there is only one. + * + * Last optional parameter - {@link Scheduler} - can be used to control when call + * to `func` happens after someone subscribes to Observable, as well as when results + * passed to callback will be emitted. By default subscription to Observable calls `func` + * synchronously, but using `Scheduler.async` as last parameter will defer call to input function, + * just like wrapping that call in `setTimeout` with time `0` would. So if you use async Scheduler + * and call `subscribe` on output Observable, all function calls that are currently executing, + * will end before `func` is invoked. + * + * When it comes to emitting results passed to callback, by default they are emitted + * immediately after `func` invokes callback. In particular, if callback is called synchronously, + * then subscription to resulting Observable will call `next` function synchronously as well. + * If you want to defer that call, using `Scheduler.async` will, again, do the job. + * This means that by using `Scheduler.async` you can, in a sense, ensure that `func` + * always calls its callback asynchronously, thus avoiding terrifying Zalgo. + * + * Note that Observable created by output function will always emit only one value + * and then complete right after. Even if `func` calls callback multiple times, values from + * second and following calls will never appear in the stream. If you need to + * listen for multiple calls, you probably want to use {@link fromEvent} or + * {@link fromEventPattern} instead. + * + * If `func` depends on some context (`this` property), that context will be set + * to the same context that output function has at call time. In particular, if `func` + * is called as method of some object, in order to preserve proper behaviour, + * it is recommended to set context of output function to that object as well, + * provided `func` is not already bound. + * + * If input function calls its callback in "node style" (i.e. first argument to callback is + * optional error parameter signaling whether call failed or not), {@link bindNodeCallback} + * provides convenient error handling and probably is a better choice. + * `bindCallback` will treat such functions without any difference and error parameter + * (whether passed or not) will always be interpreted as regular callback argument. + * + * + * @example Convert jQuery's getJSON to an Observable API + * // Suppose we have jQuery.getJSON('/my/url', callback) + * var getJSONAsObservable = Rx.Observable.bindCallback(jQuery.getJSON); + * var result = getJSONAsObservable('/my/url'); + * result.subscribe(x => console.log(x), e => console.error(e)); + * + * + * @example Receive array of arguments passed to callback + * someFunction((a, b, c) => { + * console.log(a); // 5 + * console.log(b); // 'some string' + * console.log(c); // {someProperty: 'someValue'} + * }); + * + * const boundSomeFunction = Rx.Observable.bindCallback(someFunction); + * boundSomeFunction().subscribe(values => { + * console.log(values) // [5, 'some string', {someProperty: 'someValue'}] + * }); + * + * + * @example Use bindCallback with selector function + * someFunction((a, b, c) => { + * console.log(a); // 'a' + * console.log(b); // 'b' + * console.log(c); // 'c' + * }); + * + * const boundSomeFunction = Rx.Observable.bindCallback(someFunction, (a, b, c) => a + b + c); + * boundSomeFunction().subscribe(value => { + * console.log(value) // 'abc' + * }); + * + * + * @example Compare behaviour with and without async Scheduler + * function iCallMyCallbackSynchronously(cb) { + * cb(); + * } + * + * const boundSyncFn = Rx.Observable.bindCallback(iCallMyCallbackSynchronously); + * const boundAsyncFn = Rx.Observable.bindCallback(iCallMyCallbackSynchronously, null, Rx.Scheduler.async); + * + * boundSyncFn().subscribe(() => console.log('I was sync!')); + * boundAsyncFn().subscribe(() => console.log('I was async!')); + * console.log('This happened...'); + * + * // Logs: + * // I was sync! + * // This happened... + * // I was async! + * + * + * @example Use bindCallback on object method + * const boundMethod = Rx.Observable.bindCallback(someObject.methodWithCallback); + * boundMethod.call(someObject) // make sure methodWithCallback has access to someObject + * .subscribe(subscriber); + * + * + * @see {@link bindNodeCallback} + * @see {@link from} + * @see {@link fromPromise} + * + * @param {function} func Function with a callback as the last parameter. + * @param {function} [selector] A function which takes the arguments from the + * callback and maps those to a value to emit on the output Observable. + * @param {Scheduler} [scheduler] The scheduler on which to schedule the + * callbacks. + * @return {function(...params: *): Observable} A function which returns the + * Observable that delivers the same values the callback would deliver. + * @static true + * @name bindCallback + * @owner Observable + */ + BoundCallbackObservable.create = function (func, selector, scheduler) { + if (selector === void 0) { selector = undefined; } + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return new BoundCallbackObservable(func, selector, args, this, scheduler); + }; + }; + BoundCallbackObservable.prototype._subscribe = function (subscriber) { + var callbackFunc = this.callbackFunc; + var args = this.args; + var scheduler = this.scheduler; + var subject = this.subject; + if (!scheduler) { + if (!subject) { + subject = this.subject = new AsyncSubject_1.AsyncSubject(); + var handler = function handlerFn() { + var innerArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + innerArgs[_i - 0] = arguments[_i]; + } + var source = handlerFn.source; + var selector = source.selector, subject = source.subject; + if (selector) { + var result_1 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); + if (result_1 === errorObject_1.errorObject) { + subject.error(errorObject_1.errorObject.e); + } + else { + subject.next(result_1); + subject.complete(); + } + } + else { + subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs); + subject.complete(); + } + }; + // use named function instance to avoid closure. + handler.source = this; + var result = tryCatch_1.tryCatch(callbackFunc).apply(this.context, args.concat(handler)); + if (result === errorObject_1.errorObject) { + subject.error(errorObject_1.errorObject.e); + } + } + return subject.subscribe(subscriber); + } + else { + return scheduler.schedule(BoundCallbackObservable.dispatch, 0, { source: this, subscriber: subscriber, context: this.context }); + } + }; + BoundCallbackObservable.dispatch = function (state) { + var self = this; + var source = state.source, subscriber = state.subscriber, context = state.context; + var callbackFunc = source.callbackFunc, args = source.args, scheduler = source.scheduler; + var subject = source.subject; + if (!subject) { + subject = source.subject = new AsyncSubject_1.AsyncSubject(); + var handler = function handlerFn() { + var innerArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + innerArgs[_i - 0] = arguments[_i]; + } + var source = handlerFn.source; + var selector = source.selector, subject = source.subject; + if (selector) { + var result_2 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); + if (result_2 === errorObject_1.errorObject) { + self.add(scheduler.schedule(dispatchError, 0, { err: errorObject_1.errorObject.e, subject: subject })); + } + else { + self.add(scheduler.schedule(dispatchNext, 0, { value: result_2, subject: subject })); + } + } + else { + var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs; + self.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject })); + } + }; + // use named function to pass values in without closure + handler.source = source; + var result = tryCatch_1.tryCatch(callbackFunc).apply(context, args.concat(handler)); + if (result === errorObject_1.errorObject) { + subject.error(errorObject_1.errorObject.e); + } + } + self.add(subject.subscribe(subscriber)); + }; + return BoundCallbackObservable; +}(Observable_1.Observable)); +exports.BoundCallbackObservable = BoundCallbackObservable; +function dispatchNext(arg) { + var value = arg.value, subject = arg.subject; + subject.next(value); + subject.complete(); +} +function dispatchError(arg) { + var err = arg.err, subject = arg.subject; + subject.error(err); +} +//# sourceMappingURL=BoundCallbackObservable.js.map + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 88 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var isScheduler_1 = __webpack_require__(89); - var isArray_1 = __webpack_require__(70); - var ArrayObservable_1 = __webpack_require__(90); - var combineLatest_1 = __webpack_require__(93); - /* tslint:enable:max-line-length */ - /** - * Combines multiple Observables to create an Observable whose values are - * calculated from the latest values of each of its input Observables. - * - * Whenever any input Observable emits a value, it - * computes a formula using the latest values from all the inputs, then emits - * the output of that formula. - * - * - * - * `combineLatest` combines the values from all the Observables passed as - * arguments. This is done by subscribing to each Observable in order and, - * whenever any Observable emits, collecting an array of the most recent - * values from each Observable. So if you pass `n` Observables to operator, - * returned Observable will always emit an array of `n` values, in order - * corresponding to order of passed Observables (value from the first Observable - * on the first place and so on). - * - * Static version of `combineLatest` accepts either an array of Observables - * or each Observable can be put directly as an argument. Note that array of - * Observables is good choice, if you don't know beforehand how many Observables - * you will combine. Passing empty array will result in Observable that - * completes immediately. - * - * To ensure output array has always the same length, `combineLatest` will - * actually wait for all input Observables to emit at least once, - * before it starts emitting results. This means if some Observable emits - * values before other Observables started emitting, all that values but last - * will be lost. On the other hand, is some Observable does not emit value but - * completes, resulting Observable will complete at the same moment without - * emitting anything, since it will be now impossible to include value from - * completed Observable in resulting array. Also, if some input Observable does - * not emit any value and never completes, `combineLatest` will also never emit - * and never complete, since, again, it will wait for all streams to emit some - * value. - * - * If at least one Observable was passed to `combineLatest` and all passed Observables - * emitted something, resulting Observable will complete when all combined - * streams complete. So even if some Observable completes, result of - * `combineLatest` will still emit values when other Observables do. In case - * of completed Observable, its value from now on will always be the last - * emitted value. On the other hand, if any Observable errors, `combineLatest` - * will error immediately as well, and all other Observables will be unsubscribed. - * - * `combineLatest` accepts as optional parameter `project` function, which takes - * as arguments all values that would normally be emitted by resulting Observable. - * `project` can return any kind of value, which will be then emitted by Observable - * instead of default array. Note that `project` does not take as argument that array - * of values, but values themselves. That means default `project` can be imagined - * as function that takes all its arguments and puts them into an array. - * - * - * @example Combine two timer Observables - * const firstTimer = Rx.Observable.timer(0, 1000); // emit 0, 1, 2... after every second, starting from now - * const secondTimer = Rx.Observable.timer(500, 1000); // emit 0, 1, 2... after every second, starting 0,5s from now - * const combinedTimers = Rx.Observable.combineLatest(firstTimer, secondTimer); - * combinedTimers.subscribe(value => console.log(value)); - * // Logs - * // [0, 0] after 0.5s - * // [1, 0] after 1s - * // [1, 1] after 1.5s - * // [2, 1] after 2s - * - * - * @example Combine an array of Observables - * const observables = [1, 5, 10].map( - * n => Rx.Observable.of(n).delay(n * 1000).startWith(0) // emit 0 and then emit n after n seconds - * ); - * const combined = Rx.Observable.combineLatest(observables); - * combined.subscribe(value => console.log(value)); - * // Logs - * // [0, 0, 0] immediately - * // [1, 0, 0] after 1s - * // [1, 5, 0] after 5s - * // [1, 5, 10] after 10s - * - * - * @example Use project function to dynamically calculate the Body-Mass Index - * var weight = Rx.Observable.of(70, 72, 76, 79, 75); - * var height = Rx.Observable.of(1.76, 1.77, 1.78); - * var bmi = Rx.Observable.combineLatest(weight, height, (w, h) => w / (h * h)); - * bmi.subscribe(x => console.log('BMI is ' + x)); - * - * // With output to console: - * // BMI is 24.212293388429753 - * // BMI is 23.93948099205209 - * // BMI is 23.671253629592222 - * - * - * @see {@link combineAll} - * @see {@link merge} - * @see {@link withLatestFrom} - * - * @param {ObservableInput} observable1 An input Observable to combine with other Observables. - * @param {ObservableInput} observable2 An input Observable to combine with other Observables. - * More than one input Observables may be given as arguments - * or an array of Observables may be given as the first argument. - * @param {function} [project] An optional function to project the values from - * the combined latest values into a new value on the output Observable. - * @param {Scheduler} [scheduler=null] The IScheduler to use for subscribing to - * each input Observable. - * @return {Observable} An Observable of projected values from the most recent - * values from each input Observable, or an array of the most recent values from - * each input Observable. - * @static true - * @name combineLatest - * @owner Observable - */ - function combineLatest() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var project = null; - var scheduler = null; - if (isScheduler_1.isScheduler(observables[observables.length - 1])) { - scheduler = observables.pop(); - } - if (typeof observables[observables.length - 1] === 'function') { - project = observables.pop(); - } - // if the first and only other argument besides the resultSelector is an array - // assume it's been called with `combineLatest([obs1, obs2, obs3], project)` - if (observables.length === 1 && isArray_1.isArray(observables[0])) { - observables = observables[0]; - } - return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new combineLatest_1.CombineLatestOperator(project)); - } - exports.combineLatest = combineLatest; - //# sourceMappingURL=combineLatest.js.map +"use strict"; -/***/ }, -/* 89 */ -/***/ function(module, exports) { +var Observable_1 = __webpack_require__(0); +var bindNodeCallback_1 = __webpack_require__(137); +Observable_1.Observable.bindNodeCallback = bindNodeCallback_1.bindNodeCallback; +//# sourceMappingURL=bindNodeCallback.js.map - "use strict"; - function isScheduler(value) { - return value && typeof value.schedule === 'function'; - } - exports.isScheduler = isScheduler; - //# sourceMappingURL=isScheduler.js.map +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 90 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var ScalarObservable_1 = __webpack_require__(91); - var EmptyObservable_1 = __webpack_require__(92); - var isScheduler_1 = __webpack_require__(89); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var ArrayObservable = (function (_super) { - __extends(ArrayObservable, _super); - function ArrayObservable(array, scheduler) { - _super.call(this); - this.array = array; - this.scheduler = scheduler; - if (!scheduler && array.length === 1) { - this._isScalar = true; - this.value = array[0]; - } - } - ArrayObservable.create = function (array, scheduler) { - return new ArrayObservable(array, scheduler); - }; - /** - * Creates an Observable that emits some values you specify as arguments, - * immediately one after the other, and then emits a complete notification. - * - * Emits the arguments you provide, then completes. - * - * - * - * - * This static operator is useful for creating a simple Observable that only - * emits the arguments given, and the complete notification thereafter. It can - * be used for composing with other Observables, such as with {@link concat}. - * By default, it uses a `null` IScheduler, which means the `next` - * notifications are sent synchronously, although with a different IScheduler - * it is possible to determine when those notifications will be delivered. - * - * @example Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second. - * var numbers = Rx.Observable.of(10, 20, 30); - * var letters = Rx.Observable.of('a', 'b', 'c'); - * var interval = Rx.Observable.interval(1000); - * var result = numbers.concat(letters).concat(interval); - * result.subscribe(x => console.log(x)); - * - * @see {@link create} - * @see {@link empty} - * @see {@link never} - * @see {@link throw} - * - * @param {...T} values Arguments that represent `next` values to be emitted. - * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling - * the emissions of the `next` notifications. - * @return {Observable} An Observable that emits each given input value. - * @static true - * @name of - * @owner Observable - */ - ArrayObservable.of = function () { - var array = []; - for (var _i = 0; _i < arguments.length; _i++) { - array[_i - 0] = arguments[_i]; - } - var scheduler = array[array.length - 1]; - if (isScheduler_1.isScheduler(scheduler)) { - array.pop(); - } - else { - scheduler = null; - } - var len = array.length; - if (len > 1) { - return new ArrayObservable(array, scheduler); - } - else if (len === 1) { - return new ScalarObservable_1.ScalarObservable(array[0], scheduler); - } - else { - return new EmptyObservable_1.EmptyObservable(scheduler); - } - }; - ArrayObservable.dispatch = function (state) { - var array = state.array, index = state.index, count = state.count, subscriber = state.subscriber; - if (index >= count) { - subscriber.complete(); - return; - } - subscriber.next(array[index]); - if (subscriber.closed) { - return; - } - state.index = index + 1; - this.schedule(state); - }; - ArrayObservable.prototype._subscribe = function (subscriber) { - var index = 0; - var array = this.array; - var count = array.length; - var scheduler = this.scheduler; - if (scheduler) { - return scheduler.schedule(ArrayObservable.dispatch, 0, { - array: array, index: index, count: count, subscriber: subscriber - }); - } - else { - for (var i = 0; i < count && !subscriber.closed; i++) { - subscriber.next(array[i]); - } - subscriber.complete(); - } - }; - return ArrayObservable; - }(Observable_1.Observable)); - exports.ArrayObservable = ArrayObservable; - //# sourceMappingURL=ArrayObservable.js.map - -/***/ }, -/* 91 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var ScalarObservable = (function (_super) { - __extends(ScalarObservable, _super); - function ScalarObservable(value, scheduler) { - _super.call(this); - this.value = value; - this.scheduler = scheduler; - this._isScalar = true; - if (scheduler) { - this._isScalar = false; - } - } - ScalarObservable.create = function (value, scheduler) { - return new ScalarObservable(value, scheduler); - }; - ScalarObservable.dispatch = function (state) { - var done = state.done, value = state.value, subscriber = state.subscriber; - if (done) { - subscriber.complete(); - return; - } - subscriber.next(value); - if (subscriber.closed) { - return; - } - state.done = true; - this.schedule(state); - }; - ScalarObservable.prototype._subscribe = function (subscriber) { - var value = this.value; - var scheduler = this.scheduler; - if (scheduler) { - return scheduler.schedule(ScalarObservable.dispatch, 0, { - done: false, value: value, subscriber: subscriber - }); - } - else { - subscriber.next(value); - if (!subscriber.closed) { - subscriber.complete(); - } - } - }; - return ScalarObservable; - }(Observable_1.Observable)); - exports.ScalarObservable = ScalarObservable; - //# sourceMappingURL=ScalarObservable.js.map - -/***/ }, -/* 92 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var EmptyObservable = (function (_super) { - __extends(EmptyObservable, _super); - function EmptyObservable(scheduler) { - _super.call(this); - this.scheduler = scheduler; - } - /** - * Creates an Observable that emits no items to the Observer and immediately - * emits a complete notification. - * - * Just emits 'complete', and nothing else. - * - * - * - * - * This static operator is useful for creating a simple Observable that only - * emits the complete notification. It can be used for composing with other - * Observables, such as in a {@link mergeMap}. - * - * @example Emit the number 7, then complete. - * var result = Rx.Observable.empty().startWith(7); - * result.subscribe(x => console.log(x)); - * - * @example Map and flatten only odd numbers to the sequence 'a', 'b', 'c' - * var interval = Rx.Observable.interval(1000); - * var result = interval.mergeMap(x => - * x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty() - * ); - * result.subscribe(x => console.log(x)); - * - * // Results in the following to the console: - * // x is equal to the count on the interval eg(0,1,2,3,...) - * // x will occur every 1000ms - * // if x % 2 is equal to 1 print abc - * // if x % 2 is not equal to 1 nothing will be output - * - * @see {@link create} - * @see {@link never} - * @see {@link of} - * @see {@link throw} - * - * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling - * the emission of the complete notification. - * @return {Observable} An "empty" Observable: emits only the complete - * notification. - * @static true - * @name empty - * @owner Observable - */ - EmptyObservable.create = function (scheduler) { - return new EmptyObservable(scheduler); - }; - EmptyObservable.dispatch = function (arg) { - var subscriber = arg.subscriber; - subscriber.complete(); - }; - EmptyObservable.prototype._subscribe = function (subscriber) { - var scheduler = this.scheduler; - if (scheduler) { - return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber }); - } - else { - subscriber.complete(); - } - }; - return EmptyObservable; - }(Observable_1.Observable)); - exports.EmptyObservable = EmptyObservable; - //# sourceMappingURL=EmptyObservable.js.map - -/***/ }, -/* 93 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 ArrayObservable_1 = __webpack_require__(90); - var isArray_1 = __webpack_require__(70); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - var none = {}; - /* tslint:enable:max-line-length */ - /** - * Combines multiple Observables to create an Observable whose values are - * calculated from the latest values of each of its input Observables. - * - * Whenever any input Observable emits a value, it - * computes a formula using the latest values from all the inputs, then emits - * the output of that formula. - * - * - * - * `combineLatest` combines the values from this Observable with values from - * Observables passed as arguments. This is done by subscribing to each - * Observable, in order, and collecting an array of each of the most recent - * values any time any of the input Observables emits, then either taking that - * array and passing it as arguments to an optional `project` function and - * emitting the return value of that, or just emitting the array of recent - * values directly if there is no `project` function. - * - * @example Dynamically calculate the Body-Mass Index from an Observable of weight and one for height - * var weight = Rx.Observable.of(70, 72, 76, 79, 75); - * var height = Rx.Observable.of(1.76, 1.77, 1.78); - * var bmi = weight.combineLatest(height, (w, h) => w / (h * h)); - * bmi.subscribe(x => console.log('BMI is ' + x)); - * - * // With output to console: - * // BMI is 24.212293388429753 - * // BMI is 23.93948099205209 - * // BMI is 23.671253629592222 - * - * @see {@link combineAll} - * @see {@link merge} - * @see {@link withLatestFrom} - * - * @param {ObservableInput} other An input Observable to combine with the source - * Observable. More than one input Observables may be given as argument. - * @param {function} [project] An optional function to project the values from - * the combined latest values into a new value on the output Observable. - * @return {Observable} An Observable of projected values from the most recent - * values from each input Observable, or an array of the most recent values from - * each input Observable. - * @method combineLatest - * @owner Observable - */ - function combineLatest() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var project = null; - if (typeof observables[observables.length - 1] === 'function') { - project = observables.pop(); - } - // if the first and only other argument besides the resultSelector is an array - // assume it's been called with `combineLatest([obs1, obs2, obs3], project)` - if (observables.length === 1 && isArray_1.isArray(observables[0])) { - observables = observables[0].slice(); - } - observables.unshift(this); - return this.lift.call(new ArrayObservable_1.ArrayObservable(observables), new CombineLatestOperator(project)); - } - exports.combineLatest = combineLatest; - var CombineLatestOperator = (function () { - function CombineLatestOperator(project) { - this.project = project; - } - CombineLatestOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new CombineLatestSubscriber(subscriber, this.project)); - }; - return CombineLatestOperator; - }()); - exports.CombineLatestOperator = CombineLatestOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var CombineLatestSubscriber = (function (_super) { - __extends(CombineLatestSubscriber, _super); - function CombineLatestSubscriber(destination, project) { - _super.call(this, destination); - this.project = project; - this.active = 0; - this.values = []; - this.observables = []; - } - CombineLatestSubscriber.prototype._next = function (observable) { - this.values.push(none); - this.observables.push(observable); - }; - CombineLatestSubscriber.prototype._complete = function () { - var observables = this.observables; - var len = observables.length; - if (len === 0) { - this.destination.complete(); - } - else { - this.active = len; - this.toRespond = len; - for (var i = 0; i < len; i++) { - var observable = observables[i]; - this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i)); - } - } - }; - CombineLatestSubscriber.prototype.notifyComplete = function (unused) { - if ((this.active -= 1) === 0) { - this.destination.complete(); - } - }; - CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var values = this.values; - var oldVal = values[outerIndex]; - var toRespond = !this.toRespond - ? 0 - : oldVal === none ? --this.toRespond : this.toRespond; - values[outerIndex] = innerValue; - if (toRespond === 0) { - if (this.project) { - this._tryProject(values); - } - else { - this.destination.next(values.slice()); - } - } - }; - CombineLatestSubscriber.prototype._tryProject = function (values) { - var result; - try { - result = this.project.apply(this, values); - } - catch (err) { - this.destination.error(err); - return; - } - this.destination.next(result); - }; - return CombineLatestSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.CombineLatestSubscriber = CombineLatestSubscriber; - //# sourceMappingURL=combineLatest.js.map - -/***/ }, -/* 94 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var OuterSubscriber = (function (_super) { - __extends(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)); - exports.OuterSubscriber = OuterSubscriber; - //# sourceMappingURL=OuterSubscriber.js.map - -/***/ }, -/* 95 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var root_1 = __webpack_require__(65); - var isArrayLike_1 = __webpack_require__(96); - var isPromise_1 = __webpack_require__(97); - var isObject_1 = __webpack_require__(71); - var Observable_1 = __webpack_require__(64); - var iterator_1 = __webpack_require__(98); - var InnerSubscriber_1 = __webpack_require__(99); - var observable_1 = __webpack_require__(77); - function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) { - var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex); - if (destination.closed) { - return null; - } - if (result instanceof Observable_1.Observable) { - if (result._isScalar) { - destination.next(result.value); - destination.complete(); - return null; - } - else { - return result.subscribe(destination); - } - } - else if (isArrayLike_1.isArrayLike(result)) { - for (var i = 0, len = result.length; i < len && !destination.closed; i++) { - destination.next(result[i]); - } - if (!destination.closed) { - destination.complete(); - } - } - else if (isPromise_1.isPromise(result)) { - result.then(function (value) { - if (!destination.closed) { - destination.next(value); - destination.complete(); - } - }, function (err) { return destination.error(err); }) - .then(null, function (err) { - // Escaping the Promise trap: globally throw unhandled errors - root_1.root.setTimeout(function () { throw err; }); - }); - return destination; - } - else if (result && typeof result[iterator_1.iterator] === 'function') { - var iterator = result[iterator_1.iterator](); - do { - var item = iterator.next(); - if (item.done) { - destination.complete(); - break; - } - destination.next(item.value); - if (destination.closed) { - break; - } - } while (true); - } - else if (result && typeof result[observable_1.observable] === 'function') { - var obs = result[observable_1.observable](); - if (typeof obs.subscribe !== 'function') { - destination.error(new TypeError('Provided object does not correctly implement Symbol.observable')); - } - else { - return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex)); - } - } - else { - var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'"; - var msg = ("You provided " + value + " where a stream was expected.") - + ' You can provide an Observable, Promise, Array, or Iterable.'; - destination.error(new TypeError(msg)); - } - return null; - } - exports.subscribeToResult = subscribeToResult; - //# sourceMappingURL=subscribeToResult.js.map +"use strict"; -/***/ }, -/* 96 */ -/***/ function(module, exports) { +var BoundNodeCallbackObservable_1 = __webpack_require__(138); +exports.bindNodeCallback = BoundNodeCallbackObservable_1.BoundNodeCallbackObservable.create; +//# sourceMappingURL=bindNodeCallback.js.map - "use strict"; - exports.isArrayLike = (function (x) { return x && typeof x.length === 'number'; }); - //# sourceMappingURL=isArrayLike.js.map +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var AsyncSubject_1 = __webpack_require__(32); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var BoundNodeCallbackObservable = (function (_super) { + __extends(BoundNodeCallbackObservable, _super); + function BoundNodeCallbackObservable(callbackFunc, selector, args, context, scheduler) { + _super.call(this); + this.callbackFunc = callbackFunc; + this.selector = selector; + this.args = args; + this.context = context; + this.scheduler = scheduler; + } + /* tslint:enable:max-line-length */ + /** + * Converts a Node.js-style callback API to a function that returns an + * Observable. + * + * It's just like {@link bindCallback}, but the + * callback is expected to be of type `callback(error, result)`. + * + * `bindNodeCallback` is not an operator because its input and output are not + * Observables. The input is a function `func` with some parameters, but the + * last parameter must be a callback function that `func` calls when it is + * done. The callback function is expected to follow Node.js conventions, + * where the first argument to the callback is an error object, signaling + * whether call was successful. If that object is passed to callback, it means + * something went wrong. + * + * The output of `bindNodeCallback` is a function that takes the same + * parameters as `func`, except the last one (the callback). When the output + * function is called with arguments, it will return an Observable. + * If `func` calls its callback with error parameter present, Observable will + * error with that value as well. If error parameter is not passed, Observable will emit + * second parameter. If there are more parameters (third and so on), + * Observable will emit an array with all arguments, except first error argument. + * + * Optionally `bindNodeCallback` accepts selector function, which allows you to + * make resulting Observable emit value computed by selector, instead of regular + * callback arguments. It works similarly to {@link bindCallback} selector, but + * Node.js-style error argument will never be passed to that function. + * + * Note that `func` will not be called at the same time output function is, + * but rather whenever resulting Observable is subscribed. By default call to + * `func` will happen synchronously after subscription, but that can be changed + * with proper {@link Scheduler} provided as optional third parameter. Scheduler + * can also control when values from callback will be emitted by Observable. + * To find out more, check out documentation for {@link bindCallback}, where + * Scheduler works exactly the same. + * + * As in {@link bindCallback}, context (`this` property) of input function will be set to context + * of returned function, when it is called. + * + * After Observable emits value, it will complete immediately. This means + * even if `func` calls callback again, values from second and consecutive + * calls will never appear on the stream. If you need to handle functions + * that call callbacks multiple times, check out {@link fromEvent} or + * {@link fromEventPattern} instead. + * + * Note that `bindNodeCallback` can be used in non-Node.js environments as well. + * "Node.js-style" callbacks are just a convention, so if you write for + * browsers or any other environment and API you use implements that callback style, + * `bindNodeCallback` can be safely used on that API functions as well. + * + * Remember that Error object passed to callback does not have to be an instance + * of JavaScript built-in `Error` object. In fact, it does not even have to an object. + * Error parameter of callback function is interpreted as "present", when value + * of that parameter is truthy. It could be, for example, non-zero number, non-empty + * string or boolean `true`. In all of these cases resulting Observable would error + * with that value. This means usually regular style callbacks will fail very often when + * `bindNodeCallback` is used. If your Observable errors much more often then you + * would expect, check if callback really is called in Node.js-style and, if not, + * switch to {@link bindCallback} instead. + * + * Note that even if error parameter is technically present in callback, but its value + * is falsy, it still won't appear in array emitted by Observable or in selector function. + * + * + * @example Read a file from the filesystem and get the data as an Observable + * import * as fs from 'fs'; + * var readFileAsObservable = Rx.Observable.bindNodeCallback(fs.readFile); + * var result = readFileAsObservable('./roadNames.txt', 'utf8'); + * result.subscribe(x => console.log(x), e => console.error(e)); + * + * + * @example Use on function calling callback with multiple arguments + * someFunction((err, a, b) => { + * console.log(err); // null + * console.log(a); // 5 + * console.log(b); // "some string" + * }); + * var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction); + * boundSomeFunction() + * .subscribe(value => { + * console.log(value); // [5, "some string"] + * }); + * + * + * @example Use with selector function + * someFunction((err, a, b) => { + * console.log(err); // undefined + * console.log(a); // "abc" + * console.log(b); // "DEF" + * }); + * var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction, (a, b) => a + b); + * boundSomeFunction() + * .subscribe(value => { + * console.log(value); // "abcDEF" + * }); + * + * + * @example Use on function calling callback in regular style + * someFunction(a => { + * console.log(a); // 5 + * }); + * var boundSomeFunction = Rx.Observable.bindNodeCallback(someFunction); + * boundSomeFunction() + * .subscribe( + * value => {} // never gets called + * err => console.log(err) // 5 + *); + * + * + * @see {@link bindCallback} + * @see {@link from} + * @see {@link fromPromise} + * + * @param {function} func Function with a Node.js-style callback as the last parameter. + * @param {function} [selector] A function which takes the arguments from the + * callback and maps those to a value to emit on the output Observable. + * @param {Scheduler} [scheduler] The scheduler on which to schedule the + * callbacks. + * @return {function(...params: *): Observable} A function which returns the + * Observable that delivers the same values the Node.js callback would + * deliver. + * @static true + * @name bindNodeCallback + * @owner Observable + */ + BoundNodeCallbackObservable.create = function (func, selector, scheduler) { + if (selector === void 0) { selector = undefined; } + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return new BoundNodeCallbackObservable(func, selector, args, this, scheduler); + }; + }; + BoundNodeCallbackObservable.prototype._subscribe = function (subscriber) { + var callbackFunc = this.callbackFunc; + var args = this.args; + var scheduler = this.scheduler; + var subject = this.subject; + if (!scheduler) { + if (!subject) { + subject = this.subject = new AsyncSubject_1.AsyncSubject(); + var handler = function handlerFn() { + var innerArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + innerArgs[_i - 0] = arguments[_i]; + } + var source = handlerFn.source; + var selector = source.selector, subject = source.subject; + var err = innerArgs.shift(); + if (err) { + subject.error(err); + } + else if (selector) { + var result_1 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); + if (result_1 === errorObject_1.errorObject) { + subject.error(errorObject_1.errorObject.e); + } + else { + subject.next(result_1); + subject.complete(); + } + } + else { + subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs); + subject.complete(); + } + }; + // use named function instance to avoid closure. + handler.source = this; + var result = tryCatch_1.tryCatch(callbackFunc).apply(this.context, args.concat(handler)); + if (result === errorObject_1.errorObject) { + subject.error(errorObject_1.errorObject.e); + } + } + return subject.subscribe(subscriber); + } + else { + return scheduler.schedule(dispatch, 0, { source: this, subscriber: subscriber, context: this.context }); + } + }; + return BoundNodeCallbackObservable; +}(Observable_1.Observable)); +exports.BoundNodeCallbackObservable = BoundNodeCallbackObservable; +function dispatch(state) { + var self = this; + var source = state.source, subscriber = state.subscriber, context = state.context; + // XXX: cast to `any` to access to the private field in `source`. + var _a = source, callbackFunc = _a.callbackFunc, args = _a.args, scheduler = _a.scheduler; + var subject = source.subject; + if (!subject) { + subject = source.subject = new AsyncSubject_1.AsyncSubject(); + var handler = function handlerFn() { + var innerArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + innerArgs[_i - 0] = arguments[_i]; + } + var source = handlerFn.source; + var selector = source.selector, subject = source.subject; + var err = innerArgs.shift(); + if (err) { + self.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject })); + } + else if (selector) { + var result_2 = tryCatch_1.tryCatch(selector).apply(this, innerArgs); + if (result_2 === errorObject_1.errorObject) { + self.add(scheduler.schedule(dispatchError, 0, { err: errorObject_1.errorObject.e, subject: subject })); + } + else { + self.add(scheduler.schedule(dispatchNext, 0, { value: result_2, subject: subject })); + } + } + else { + var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs; + self.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject })); + } + }; + // use named function to pass values in without closure + handler.source = source; + var result = tryCatch_1.tryCatch(callbackFunc).apply(context, args.concat(handler)); + if (result === errorObject_1.errorObject) { + self.add(scheduler.schedule(dispatchError, 0, { err: errorObject_1.errorObject.e, subject: subject })); + } + } + self.add(subject.subscribe(subscriber)); +} +function dispatchNext(arg) { + var value = arg.value, subject = arg.subject; + subject.next(value); + subject.complete(); +} +function dispatchError(arg) { + var err = arg.err, subject = arg.subject; + subject.error(err); +} +//# sourceMappingURL=BoundNodeCallbackObservable.js.map + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 97 */ -/***/ function(module, exports) { +"use strict"; - "use strict"; - function isPromise(value) { - return value && typeof value.subscribe !== 'function' && typeof value.then === 'function'; - } - exports.isPromise = isPromise; - //# sourceMappingURL=isPromise.js.map +var Observable_1 = __webpack_require__(0); +var combineLatest_1 = __webpack_require__(140); +Observable_1.Observable.combineLatest = combineLatest_1.combineLatest; +//# sourceMappingURL=combineLatest.js.map -/***/ }, -/* 98 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var root_1 = __webpack_require__(65); - function symbolIteratorPonyfill(root) { - var Symbol = root.Symbol; - if (typeof Symbol === 'function') { - if (!Symbol.iterator) { - Symbol.iterator = Symbol('iterator polyfill'); - } - return Symbol.iterator; - } - else { - // [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC) - var Set_1 = root.Set; - if (Set_1 && typeof new Set_1()['@@iterator'] === 'function') { - return '@@iterator'; - } - var Map_1 = root.Map; - // required for compatability with es6-shim - if (Map_1) { - var keys = Object.getOwnPropertyNames(Map_1.prototype); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - // according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal. - if (key !== 'entries' && key !== 'size' && Map_1.prototype[key] === Map_1.prototype['entries']) { - return key; - } - } - } - return '@@iterator'; - } - } - exports.symbolIteratorPonyfill = symbolIteratorPonyfill; - exports.iterator = symbolIteratorPonyfill(root_1.root); - /** - * @deprecated use iterator instead - */ - exports.$$iterator = exports.iterator; - //# sourceMappingURL=iterator.js.map - -/***/ }, -/* 99 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var InnerSubscriber = (function (_super) { - __extends(InnerSubscriber, _super); - function InnerSubscriber(parent, outerValue, outerIndex) { - _super.call(this); - this.parent = parent; - this.outerValue = outerValue; - this.outerIndex = outerIndex; - this.index = 0; - } - InnerSubscriber.prototype._next = function (value) { - this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this); - }; - InnerSubscriber.prototype._error = function (error) { - this.parent.notifyError(error, this); - this.unsubscribe(); - }; - InnerSubscriber.prototype._complete = function () { - this.parent.notifyComplete(this); - this.unsubscribe(); - }; - return InnerSubscriber; - }(Subscriber_1.Subscriber)); - exports.InnerSubscriber = InnerSubscriber; - //# sourceMappingURL=InnerSubscriber.js.map - -/***/ }, -/* 100 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var isScheduler_1 = __webpack_require__(14); +var isArray_1 = __webpack_require__(13); +var ArrayObservable_1 = __webpack_require__(15); +var combineLatest_1 = __webpack_require__(44); +/* tslint:enable:max-line-length */ +/** + * Combines multiple Observables to create an Observable whose values are + * calculated from the latest values of each of its input Observables. + * + * Whenever any input Observable emits a value, it + * computes a formula using the latest values from all the inputs, then emits + * the output of that formula. + * + * + * + * `combineLatest` combines the values from all the Observables passed as + * arguments. This is done by subscribing to each Observable in order and, + * whenever any Observable emits, collecting an array of the most recent + * values from each Observable. So if you pass `n` Observables to operator, + * returned Observable will always emit an array of `n` values, in order + * corresponding to order of passed Observables (value from the first Observable + * on the first place and so on). + * + * Static version of `combineLatest` accepts either an array of Observables + * or each Observable can be put directly as an argument. Note that array of + * Observables is good choice, if you don't know beforehand how many Observables + * you will combine. Passing empty array will result in Observable that + * completes immediately. + * + * To ensure output array has always the same length, `combineLatest` will + * actually wait for all input Observables to emit at least once, + * before it starts emitting results. This means if some Observable emits + * values before other Observables started emitting, all that values but last + * will be lost. On the other hand, is some Observable does not emit value but + * completes, resulting Observable will complete at the same moment without + * emitting anything, since it will be now impossible to include value from + * completed Observable in resulting array. Also, if some input Observable does + * not emit any value and never completes, `combineLatest` will also never emit + * and never complete, since, again, it will wait for all streams to emit some + * value. + * + * If at least one Observable was passed to `combineLatest` and all passed Observables + * emitted something, resulting Observable will complete when all combined + * streams complete. So even if some Observable completes, result of + * `combineLatest` will still emit values when other Observables do. In case + * of completed Observable, its value from now on will always be the last + * emitted value. On the other hand, if any Observable errors, `combineLatest` + * will error immediately as well, and all other Observables will be unsubscribed. + * + * `combineLatest` accepts as optional parameter `project` function, which takes + * as arguments all values that would normally be emitted by resulting Observable. + * `project` can return any kind of value, which will be then emitted by Observable + * instead of default array. Note that `project` does not take as argument that array + * of values, but values themselves. That means default `project` can be imagined + * as function that takes all its arguments and puts them into an array. + * + * + * @example Combine two timer Observables + * const firstTimer = Rx.Observable.timer(0, 1000); // emit 0, 1, 2... after every second, starting from now + * const secondTimer = Rx.Observable.timer(500, 1000); // emit 0, 1, 2... after every second, starting 0,5s from now + * const combinedTimers = Rx.Observable.combineLatest(firstTimer, secondTimer); + * combinedTimers.subscribe(value => console.log(value)); + * // Logs + * // [0, 0] after 0.5s + * // [1, 0] after 1s + * // [1, 1] after 1.5s + * // [2, 1] after 2s + * + * + * @example Combine an array of Observables + * const observables = [1, 5, 10].map( + * n => Rx.Observable.of(n).delay(n * 1000).startWith(0) // emit 0 and then emit n after n seconds + * ); + * const combined = Rx.Observable.combineLatest(observables); + * combined.subscribe(value => console.log(value)); + * // Logs + * // [0, 0, 0] immediately + * // [1, 0, 0] after 1s + * // [1, 5, 0] after 5s + * // [1, 5, 10] after 10s + * + * + * @example Use project function to dynamically calculate the Body-Mass Index + * var weight = Rx.Observable.of(70, 72, 76, 79, 75); + * var height = Rx.Observable.of(1.76, 1.77, 1.78); + * var bmi = Rx.Observable.combineLatest(weight, height, (w, h) => w / (h * h)); + * bmi.subscribe(x => console.log('BMI is ' + x)); + * + * // With output to console: + * // BMI is 24.212293388429753 + * // BMI is 23.93948099205209 + * // BMI is 23.671253629592222 + * + * + * @see {@link combineAll} + * @see {@link merge} + * @see {@link withLatestFrom} + * + * @param {ObservableInput} observable1 An input Observable to combine with other Observables. + * @param {ObservableInput} observable2 An input Observable to combine with other Observables. + * More than one input Observables may be given as arguments + * or an array of Observables may be given as the first argument. + * @param {function} [project] An optional function to project the values from + * the combined latest values into a new value on the output Observable. + * @param {Scheduler} [scheduler=null] The IScheduler to use for subscribing to + * each input Observable. + * @return {Observable} An Observable of projected values from the most recent + * values from each input Observable, or an array of the most recent values from + * each input Observable. + * @static true + * @name combineLatest + * @owner Observable + */ +function combineLatest() { + var observables = []; + for (var _i = 0; _i < arguments.length; _i++) { + observables[_i - 0] = arguments[_i]; + } + var project = null; + var scheduler = null; + if (isScheduler_1.isScheduler(observables[observables.length - 1])) { + scheduler = observables.pop(); + } + if (typeof observables[observables.length - 1] === 'function') { + project = observables.pop(); + } + // if the first and only other argument besides the resultSelector is an array + // assume it's been called with `combineLatest([obs1, obs2, obs3], project)` + if (observables.length === 1 && isArray_1.isArray(observables[0])) { + observables = observables[0]; + } + return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new combineLatest_1.CombineLatestOperator(project)); +} +exports.combineLatest = combineLatest; +//# sourceMappingURL=combineLatest.js.map + +/***/ }), +/* 141 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var InnerSubscriber = (function (_super) { + __extends(InnerSubscriber, _super); + function InnerSubscriber(parent, outerValue, outerIndex) { + _super.call(this); + this.parent = parent; + this.outerValue = outerValue; + this.outerIndex = outerIndex; + this.index = 0; + } + InnerSubscriber.prototype._next = function (value) { + this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this); + }; + InnerSubscriber.prototype._error = function (error) { + this.parent.notifyError(error, this); + this.unsubscribe(); + }; + InnerSubscriber.prototype._complete = function () { + this.parent.notifyComplete(this); + this.unsubscribe(); + }; + return InnerSubscriber; +}(Subscriber_1.Subscriber)); +exports.InnerSubscriber = InnerSubscriber; +//# sourceMappingURL=InnerSubscriber.js.map + +/***/ }), +/* 142 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var concat_1 = __webpack_require__(101); - Observable_1.Observable.concat = concat_1.concat; - //# sourceMappingURL=concat.js.map +"use strict"; -/***/ }, -/* 101 */ -/***/ function(module, exports, __webpack_require__) { +var Observable_1 = __webpack_require__(0); +var concat_1 = __webpack_require__(143); +Observable_1.Observable.concat = concat_1.concat; +//# sourceMappingURL=concat.js.map - "use strict"; - var concat_1 = __webpack_require__(102); - exports.concat = concat_1.concatStatic; - //# sourceMappingURL=concat.js.map +/***/ }), +/* 143 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 102 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Observable_1 = __webpack_require__(64); - var isScheduler_1 = __webpack_require__(89); - var ArrayObservable_1 = __webpack_require__(90); - var mergeAll_1 = __webpack_require__(103); - /* tslint:enable:max-line-length */ - /** - * Creates an output Observable which sequentially emits all values from every - * given input Observable after the current Observable. - * - * Concatenates multiple Observables together by - * sequentially emitting their values, one Observable after the other. - * - * - * - * Joins this Observable with multiple other Observables by subscribing to them - * one at a time, starting with the source, and merging their results into the - * output Observable. Will wait for each Observable to complete before moving - * on to the next. - * - * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 - * var timer = Rx.Observable.interval(1000).take(4); - * var sequence = Rx.Observable.range(1, 10); - * var result = timer.concat(sequence); - * result.subscribe(x => console.log(x)); - * - * // results in: - * // 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 - * - * @example Concatenate 3 Observables - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var result = timer1.concat(timer2, timer3); - * result.subscribe(x => console.log(x)); - * - * // results in the following: - * // (Prints to console sequentially) - * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 - * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 - * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 - * - * @see {@link concatAll} - * @see {@link concatMap} - * @see {@link concatMapTo} - * - * @param {ObservableInput} other An input Observable to concatenate after the source - * Observable. More than one input Observables may be given as argument. - * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each - * Observable subscription on. - * @return {Observable} All values of each passed Observable merged into a - * single Observable, in order, in serial fashion. - * @method concat - * @owner Observable - */ - function concat() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - return this.lift.call(concatStatic.apply(void 0, [this].concat(observables))); - } - exports.concat = concat; - /* tslint:enable:max-line-length */ - /** - * Creates an output Observable which sequentially emits all values from given - * Observable and then moves on to the next. - * - * Concatenates multiple Observables together by - * sequentially emitting their values, one Observable after the other. - * - * - * - * `concat` joins multiple Observables together, by subscribing to them one at a time and - * merging their results into the output Observable. You can pass either an array of - * Observables, or put them directly as arguments. Passing an empty array will result - * in Observable that completes immediately. - * - * `concat` will subscribe to first input Observable and emit all its values, without - * changing or affecting them in any way. When that Observable completes, it will - * subscribe to then next Observable passed and, again, emit its values. This will be - * repeated, until the operator runs out of Observables. When last input Observable completes, - * `concat` will complete as well. At any given moment only one Observable passed to operator - * emits values. If you would like to emit values from passed Observables concurrently, check out - * {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact, - * `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`. - * - * Note that if some input Observable never completes, `concat` will also never complete - * and Observables following the one that did not complete will never be subscribed. On the other - * hand, if some Observable simply completes immediately after it is subscribed, it will be - * invisible for `concat`, which will just move on to the next Observable. - * - * If any Observable in chain errors, instead of passing control to the next Observable, - * `concat` will error immediately as well. Observables that would be subscribed after - * the one that emitted error, never will. - * - * If you pass to `concat` the same Observable many times, its stream of values - * will be "replayed" on every subscription, which means you can repeat given Observable - * as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious, - * you can always use {@link repeat}. - * - * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 - * var timer = Rx.Observable.interval(1000).take(4); - * var sequence = Rx.Observable.range(1, 10); - * var result = Rx.Observable.concat(timer, sequence); - * result.subscribe(x => console.log(x)); - * - * // results in: - * // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 - * - * - * @example Concatenate an array of 3 Observables - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var result = Rx.Observable.concat([timer1, timer2, timer3]); // note that array is passed - * result.subscribe(x => console.log(x)); - * - * // results in the following: - * // (Prints to console sequentially) - * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 - * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 - * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 - * - * - * @example Concatenate the same Observable to repeat it - * const timer = Rx.Observable.interval(1000).take(2); - * - * Rx.Observable.concat(timer, timer) // concating the same Observable! - * .subscribe( - * value => console.log(value), - * err => {}, - * () => console.log('...and it is done!') - * ); - * - * // Logs: - * // 0 after 1s - * // 1 after 2s - * // 0 after 3s - * // 1 after 4s - * // "...and it is done!" also after 4s - * - * @see {@link concatAll} - * @see {@link concatMap} - * @see {@link concatMapTo} - * - * @param {ObservableInput} input1 An input Observable to concatenate with others. - * @param {ObservableInput} input2 An input Observable to concatenate with others. - * More than one input Observables may be given as argument. - * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each - * Observable subscription on. - * @return {Observable} All values of each passed Observable merged into a - * single Observable, in order, in serial fashion. - * @static true - * @name concat - * @owner Observable - */ - function concatStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var scheduler = null; - var args = observables; - if (isScheduler_1.isScheduler(args[observables.length - 1])) { - scheduler = args.pop(); - } - if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) { - return observables[0]; - } - return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(1)); - } - exports.concatStatic = concatStatic; - //# sourceMappingURL=concat.js.map +"use strict"; -/***/ }, -/* 103 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Converts a higher-order Observable into a first-order Observable which - * concurrently delivers all values that are emitted on the inner Observables. - * - * Flattens an Observable-of-Observables. - * - * - * - * `mergeAll` subscribes to an Observable that emits Observables, also known as - * a higher-order Observable. Each time it observes one of these emitted inner - * Observables, it subscribes to that and delivers all the values from the - * inner Observable on the output Observable. The output Observable only - * completes once all inner Observables have completed. Any error delivered by - * a inner Observable will be immediately emitted on the output Observable. - * - * @example Spawn a new interval Observable for each click event, and blend their outputs as one Observable - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000)); - * var firstOrder = higherOrder.mergeAll(); - * firstOrder.subscribe(x => console.log(x)); - * - * @example Count from 0 to 9 every second for each click, but only allow 2 concurrent timers - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10)); - * var firstOrder = higherOrder.mergeAll(2); - * firstOrder.subscribe(x => console.log(x)); - * - * @see {@link combineAll} - * @see {@link concatAll} - * @see {@link exhaust} - * @see {@link merge} - * @see {@link mergeMap} - * @see {@link mergeMapTo} - * @see {@link mergeScan} - * @see {@link switch} - * @see {@link zipAll} - * - * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner - * Observables being subscribed to concurrently. - * @return {Observable} An Observable that emits values coming from all the - * inner Observables emitted by the source Observable. - * @method mergeAll - * @owner Observable - */ - function mergeAll(concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - return this.lift(new MergeAllOperator(concurrent)); - } - exports.mergeAll = mergeAll; - var MergeAllOperator = (function () { - function MergeAllOperator(concurrent) { - this.concurrent = concurrent; - } - MergeAllOperator.prototype.call = function (observer, source) { - return source.subscribe(new MergeAllSubscriber(observer, this.concurrent)); - }; - return MergeAllOperator; - }()); - exports.MergeAllOperator = MergeAllOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var MergeAllSubscriber = (function (_super) { - __extends(MergeAllSubscriber, _super); - function MergeAllSubscriber(destination, concurrent) { - _super.call(this, destination); - this.concurrent = concurrent; - this.hasCompleted = false; - this.buffer = []; - this.active = 0; - } - MergeAllSubscriber.prototype._next = function (observable) { - if (this.active < this.concurrent) { - this.active++; - this.add(subscribeToResult_1.subscribeToResult(this, observable)); - } - else { - this.buffer.push(observable); - } - }; - MergeAllSubscriber.prototype._complete = function () { - this.hasCompleted = true; - if (this.active === 0 && this.buffer.length === 0) { - this.destination.complete(); - } - }; - MergeAllSubscriber.prototype.notifyComplete = function (innerSub) { - var buffer = this.buffer; - this.remove(innerSub); - this.active--; - if (buffer.length > 0) { - this._next(buffer.shift()); - } - else if (this.active === 0 && this.hasCompleted) { - this.destination.complete(); - } - }; - return MergeAllSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.MergeAllSubscriber = MergeAllSubscriber; - //# sourceMappingURL=mergeAll.js.map - -/***/ }, -/* 104 */ -/***/ function(module, exports, __webpack_require__) { +var concat_1 = __webpack_require__(45); +exports.concat = concat_1.concatStatic; +//# sourceMappingURL=concat.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var defer_1 = __webpack_require__(105); - Observable_1.Observable.defer = defer_1.defer; - //# sourceMappingURL=defer.js.map +/***/ }), +/* 144 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 105 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var DeferObservable_1 = __webpack_require__(106); - exports.defer = DeferObservable_1.DeferObservable.create; - //# sourceMappingURL=defer.js.map +var Observable_1 = __webpack_require__(0); +var defer_1 = __webpack_require__(145); +Observable_1.Observable.defer = defer_1.defer; +//# sourceMappingURL=defer.js.map -/***/ }, -/* 106 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var subscribeToResult_1 = __webpack_require__(95); - var OuterSubscriber_1 = __webpack_require__(94); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var DeferObservable = (function (_super) { - __extends(DeferObservable, _super); - function DeferObservable(observableFactory) { - _super.call(this); - this.observableFactory = observableFactory; - } - /** - * Creates an Observable that, on subscribe, calls an Observable factory to - * make an Observable for each new Observer. - * - * Creates the Observable lazily, that is, only when it - * is subscribed. - * - * - * - * - * `defer` allows you to create the Observable only when the Observer - * subscribes, and create a fresh Observable for each Observer. It waits until - * an Observer subscribes to it, and then it generates an Observable, - * typically with an Observable factory function. It does this afresh for each - * subscriber, so although each subscriber may think it is subscribing to the - * same Observable, in fact each subscriber gets its own individual - * Observable. - * - * @example Subscribe to either an Observable of clicks or an Observable of interval, at random - * var clicksOrInterval = Rx.Observable.defer(function () { - * if (Math.random() > 0.5) { - * return Rx.Observable.fromEvent(document, 'click'); - * } else { - * return Rx.Observable.interval(1000); - * } - * }); - * clicksOrInterval.subscribe(x => console.log(x)); - * - * // Results in the following behavior: - * // If the result of Math.random() is greater than 0.5 it will listen - * // for clicks anywhere on the "document"; when document is clicked it - * // will log a MouseEvent object to the console. If the result is less - * // than 0.5 it will emit ascending numbers, one every second(1000ms). - * - * @see {@link create} - * - * @param {function(): SubscribableOrPromise} observableFactory The Observable - * factory function to invoke for each Observer that subscribes to the output - * Observable. May also return a Promise, which will be converted on the fly - * to an Observable. - * @return {Observable} An Observable whose Observers' subscriptions trigger - * an invocation of the given Observable factory function. - * @static true - * @name defer - * @owner Observable - */ - DeferObservable.create = function (observableFactory) { - return new DeferObservable(observableFactory); - }; - DeferObservable.prototype._subscribe = function (subscriber) { - return new DeferSubscriber(subscriber, this.observableFactory); - }; - return DeferObservable; - }(Observable_1.Observable)); - exports.DeferObservable = DeferObservable; - var DeferSubscriber = (function (_super) { - __extends(DeferSubscriber, _super); - function DeferSubscriber(destination, factory) { - _super.call(this, destination); - this.factory = factory; - this.tryDefer(); - } - DeferSubscriber.prototype.tryDefer = function () { - try { - this._callFactory(); - } - catch (err) { - this._error(err); - } - }; - DeferSubscriber.prototype._callFactory = function () { - var result = this.factory(); - if (result) { - this.add(subscribeToResult_1.subscribeToResult(this, result)); - } - }; - return DeferSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=DeferObservable.js.map - -/***/ }, -/* 107 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 145 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var empty_1 = __webpack_require__(108); - Observable_1.Observable.empty = empty_1.empty; - //# sourceMappingURL=empty.js.map +"use strict"; -/***/ }, -/* 108 */ -/***/ function(module, exports, __webpack_require__) { +var DeferObservable_1 = __webpack_require__(146); +exports.defer = DeferObservable_1.DeferObservable.create; +//# sourceMappingURL=defer.js.map - "use strict"; - var EmptyObservable_1 = __webpack_require__(92); - exports.empty = EmptyObservable_1.EmptyObservable.create; - //# sourceMappingURL=empty.js.map +/***/ }), +/* 146 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var subscribeToResult_1 = __webpack_require__(3); +var OuterSubscriber_1 = __webpack_require__(2); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var DeferObservable = (function (_super) { + __extends(DeferObservable, _super); + function DeferObservable(observableFactory) { + _super.call(this); + this.observableFactory = observableFactory; + } + /** + * Creates an Observable that, on subscribe, calls an Observable factory to + * make an Observable for each new Observer. + * + * Creates the Observable lazily, that is, only when it + * is subscribed. + * + * + * + * + * `defer` allows you to create the Observable only when the Observer + * subscribes, and create a fresh Observable for each Observer. It waits until + * an Observer subscribes to it, and then it generates an Observable, + * typically with an Observable factory function. It does this afresh for each + * subscriber, so although each subscriber may think it is subscribing to the + * same Observable, in fact each subscriber gets its own individual + * Observable. + * + * @example Subscribe to either an Observable of clicks or an Observable of interval, at random + * var clicksOrInterval = Rx.Observable.defer(function () { + * if (Math.random() > 0.5) { + * return Rx.Observable.fromEvent(document, 'click'); + * } else { + * return Rx.Observable.interval(1000); + * } + * }); + * clicksOrInterval.subscribe(x => console.log(x)); + * + * // Results in the following behavior: + * // If the result of Math.random() is greater than 0.5 it will listen + * // for clicks anywhere on the "document"; when document is clicked it + * // will log a MouseEvent object to the console. If the result is less + * // than 0.5 it will emit ascending numbers, one every second(1000ms). + * + * @see {@link create} + * + * @param {function(): SubscribableOrPromise} observableFactory The Observable + * factory function to invoke for each Observer that subscribes to the output + * Observable. May also return a Promise, which will be converted on the fly + * to an Observable. + * @return {Observable} An Observable whose Observers' subscriptions trigger + * an invocation of the given Observable factory function. + * @static true + * @name defer + * @owner Observable + */ + DeferObservable.create = function (observableFactory) { + return new DeferObservable(observableFactory); + }; + DeferObservable.prototype._subscribe = function (subscriber) { + return new DeferSubscriber(subscriber, this.observableFactory); + }; + return DeferObservable; +}(Observable_1.Observable)); +exports.DeferObservable = DeferObservable; +var DeferSubscriber = (function (_super) { + __extends(DeferSubscriber, _super); + function DeferSubscriber(destination, factory) { + _super.call(this, destination); + this.factory = factory; + this.tryDefer(); + } + DeferSubscriber.prototype.tryDefer = function () { + try { + this._callFactory(); + } + catch (err) { + this._error(err); + } + }; + DeferSubscriber.prototype._callFactory = function () { + var result = this.factory(); + if (result) { + this.add(subscribeToResult_1.subscribeToResult(this, result)); + } + }; + return DeferSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=DeferObservable.js.map + +/***/ }), +/* 147 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 109 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var forkJoin_1 = __webpack_require__(110); - Observable_1.Observable.forkJoin = forkJoin_1.forkJoin; - //# sourceMappingURL=forkJoin.js.map +var Observable_1 = __webpack_require__(0); +var empty_1 = __webpack_require__(148); +Observable_1.Observable.empty = empty_1.empty; +//# sourceMappingURL=empty.js.map -/***/ }, -/* 110 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 148 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var ForkJoinObservable_1 = __webpack_require__(111); - exports.forkJoin = ForkJoinObservable_1.ForkJoinObservable.create; - //# sourceMappingURL=forkJoin.js.map +"use strict"; -/***/ }, -/* 111 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var EmptyObservable_1 = __webpack_require__(92); - var isArray_1 = __webpack_require__(70); - var subscribeToResult_1 = __webpack_require__(95); - var OuterSubscriber_1 = __webpack_require__(94); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var ForkJoinObservable = (function (_super) { - __extends(ForkJoinObservable, _super); - function ForkJoinObservable(sources, resultSelector) { - _super.call(this); - this.sources = sources; - this.resultSelector = resultSelector; - } - /* tslint:enable:max-line-length */ - /** - * @param sources - * @return {any} - * @static true - * @name forkJoin - * @owner Observable - */ - ForkJoinObservable.create = function () { - var sources = []; - for (var _i = 0; _i < arguments.length; _i++) { - sources[_i - 0] = arguments[_i]; - } - if (sources === null || arguments.length === 0) { - return new EmptyObservable_1.EmptyObservable(); - } - var resultSelector = null; - if (typeof sources[sources.length - 1] === 'function') { - resultSelector = sources.pop(); - } - // if the first and only other argument besides the resultSelector is an array - // assume it's been called with `forkJoin([obs1, obs2, obs3], resultSelector)` - if (sources.length === 1 && isArray_1.isArray(sources[0])) { - sources = sources[0]; - } - if (sources.length === 0) { - return new EmptyObservable_1.EmptyObservable(); - } - return new ForkJoinObservable(sources, resultSelector); - }; - ForkJoinObservable.prototype._subscribe = function (subscriber) { - return new ForkJoinSubscriber(subscriber, this.sources, this.resultSelector); - }; - return ForkJoinObservable; - }(Observable_1.Observable)); - exports.ForkJoinObservable = ForkJoinObservable; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ForkJoinSubscriber = (function (_super) { - __extends(ForkJoinSubscriber, _super); - function ForkJoinSubscriber(destination, sources, resultSelector) { - _super.call(this, destination); - this.sources = sources; - this.resultSelector = resultSelector; - this.completed = 0; - this.haveValues = 0; - var len = sources.length; - this.total = len; - this.values = new Array(len); - for (var i = 0; i < len; i++) { - var source = sources[i]; - var innerSubscription = subscribeToResult_1.subscribeToResult(this, source, null, i); - if (innerSubscription) { - innerSubscription.outerIndex = i; - this.add(innerSubscription); - } - } - } - ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.values[outerIndex] = innerValue; - if (!innerSub._hasValue) { - innerSub._hasValue = true; - this.haveValues++; - } - }; - ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) { - var destination = this.destination; - var _a = this, haveValues = _a.haveValues, resultSelector = _a.resultSelector, values = _a.values; - var len = values.length; - if (!innerSub._hasValue) { - destination.complete(); - return; - } - this.completed++; - if (this.completed !== len) { - return; - } - if (haveValues === len) { - var value = resultSelector ? resultSelector.apply(this, values) : values; - destination.next(value); - } - destination.complete(); - }; - return ForkJoinSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=ForkJoinObservable.js.map - -/***/ }, -/* 112 */ -/***/ function(module, exports, __webpack_require__) { +var EmptyObservable_1 = __webpack_require__(16); +exports.empty = EmptyObservable_1.EmptyObservable.create; +//# sourceMappingURL=empty.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var from_1 = __webpack_require__(113); - Observable_1.Observable.from = from_1.from; - //# sourceMappingURL=from.js.map +/***/ }), +/* 149 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 113 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var FromObservable_1 = __webpack_require__(114); - exports.from = FromObservable_1.FromObservable.create; - //# sourceMappingURL=from.js.map +var Observable_1 = __webpack_require__(0); +var forkJoin_1 = __webpack_require__(150); +Observable_1.Observable.forkJoin = forkJoin_1.forkJoin; +//# sourceMappingURL=forkJoin.js.map -/***/ }, -/* 114 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 isArray_1 = __webpack_require__(70); - var isArrayLike_1 = __webpack_require__(96); - var isPromise_1 = __webpack_require__(97); - var PromiseObservable_1 = __webpack_require__(115); - var IteratorObservable_1 = __webpack_require__(116); - var ArrayObservable_1 = __webpack_require__(90); - var ArrayLikeObservable_1 = __webpack_require__(117); - var iterator_1 = __webpack_require__(98); - var Observable_1 = __webpack_require__(64); - var observeOn_1 = __webpack_require__(118); - var observable_1 = __webpack_require__(77); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var FromObservable = (function (_super) { - __extends(FromObservable, _super); - function FromObservable(ish, scheduler) { - _super.call(this, null); - this.ish = ish; - this.scheduler = scheduler; - } - /** - * Creates an Observable from an Array, an array-like object, a Promise, an - * iterable object, or an Observable-like object. - * - * Converts almost anything to an Observable. - * - * - * - * Convert various other objects and data types into Observables. `from` - * converts a Promise or an array-like or an - * [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable) - * object into an Observable that emits the items in that promise or array or - * iterable. A String, in this context, is treated as an array of characters. - * Observable-like objects (contains a function named with the ES2015 Symbol - * for Observable) can also be converted through this operator. - * - * @example Converts an array to an Observable - * var array = [10, 20, 30]; - * var result = Rx.Observable.from(array); - * result.subscribe(x => console.log(x)); - * - * // Results in the following: - * // 10 20 30 - * - * @example Convert an infinite iterable (from a generator) to an Observable - * function* generateDoubles(seed) { - * var i = seed; - * while (true) { - * yield i; - * i = 2 * i; // double it - * } - * } - * - * var iterator = generateDoubles(3); - * var result = Rx.Observable.from(iterator).take(10); - * result.subscribe(x => console.log(x)); - * - * // Results in the following: - * // 3 6 12 24 48 96 192 384 768 1536 - * - * @see {@link create} - * @see {@link fromEvent} - * @see {@link fromEventPattern} - * @see {@link fromPromise} - * - * @param {ObservableInput} ish A subscribable object, a Promise, an - * Observable-like, an Array, an iterable or an array-like object to be - * converted. - * @param {Scheduler} [scheduler] The scheduler on which to schedule the - * emissions of values. - * @return {Observable} The Observable whose values are originally from the - * input object that was converted. - * @static true - * @name from - * @owner Observable - */ - FromObservable.create = function (ish, scheduler) { - if (ish != null) { - if (typeof ish[observable_1.observable] === 'function') { - if (ish instanceof Observable_1.Observable && !scheduler) { - return ish; - } - return new FromObservable(ish, scheduler); - } - else if (isArray_1.isArray(ish)) { - return new ArrayObservable_1.ArrayObservable(ish, scheduler); - } - else if (isPromise_1.isPromise(ish)) { - return new PromiseObservable_1.PromiseObservable(ish, scheduler); - } - else if (typeof ish[iterator_1.iterator] === 'function' || typeof ish === 'string') { - return new IteratorObservable_1.IteratorObservable(ish, scheduler); - } - else if (isArrayLike_1.isArrayLike(ish)) { - return new ArrayLikeObservable_1.ArrayLikeObservable(ish, scheduler); - } - } - throw new TypeError((ish !== null && typeof ish || ish) + ' is not observable'); - }; - FromObservable.prototype._subscribe = function (subscriber) { - var ish = this.ish; - var scheduler = this.scheduler; - if (scheduler == null) { - return ish[observable_1.observable]().subscribe(subscriber); - } - else { - return ish[observable_1.observable]().subscribe(new observeOn_1.ObserveOnSubscriber(subscriber, scheduler, 0)); - } - }; - return FromObservable; - }(Observable_1.Observable)); - exports.FromObservable = FromObservable; - //# sourceMappingURL=FromObservable.js.map - -/***/ }, -/* 115 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 root_1 = __webpack_require__(65); - var Observable_1 = __webpack_require__(64); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var PromiseObservable = (function (_super) { - __extends(PromiseObservable, _super); - function PromiseObservable(promise, scheduler) { - _super.call(this); - this.promise = promise; - this.scheduler = scheduler; - } - /** - * Converts a Promise to an Observable. - * - * Returns an Observable that just emits the Promise's - * resolved value, then completes. - * - * Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an - * Observable. If the Promise resolves with a value, the output Observable - * emits that resolved value as a `next`, and then completes. If the Promise - * is rejected, then the output Observable emits the corresponding Error. - * - * @example Convert the Promise returned by Fetch to an Observable - * var result = Rx.Observable.fromPromise(fetch('http://myserver.com/')); - * result.subscribe(x => console.log(x), e => console.error(e)); - * - * @see {@link bindCallback} - * @see {@link from} - * - * @param {PromiseLike} promise The promise to be converted. - * @param {Scheduler} [scheduler] An optional IScheduler to use for scheduling - * the delivery of the resolved value (or the rejection). - * @return {Observable} An Observable which wraps the Promise. - * @static true - * @name fromPromise - * @owner Observable - */ - PromiseObservable.create = function (promise, scheduler) { - return new PromiseObservable(promise, scheduler); - }; - PromiseObservable.prototype._subscribe = function (subscriber) { - var _this = this; - var promise = this.promise; - var scheduler = this.scheduler; - if (scheduler == null) { - if (this._isScalar) { - if (!subscriber.closed) { - subscriber.next(this.value); - subscriber.complete(); - } - } - else { - promise.then(function (value) { - _this.value = value; - _this._isScalar = true; - if (!subscriber.closed) { - subscriber.next(value); - subscriber.complete(); - } - }, function (err) { - if (!subscriber.closed) { - subscriber.error(err); - } - }) - .then(null, function (err) { - // escape the promise trap, throw unhandled errors - root_1.root.setTimeout(function () { throw err; }); - }); - } - } - else { - if (this._isScalar) { - if (!subscriber.closed) { - return scheduler.schedule(dispatchNext, 0, { value: this.value, subscriber: subscriber }); - } - } - else { - promise.then(function (value) { - _this.value = value; - _this._isScalar = true; - if (!subscriber.closed) { - subscriber.add(scheduler.schedule(dispatchNext, 0, { value: value, subscriber: subscriber })); - } - }, function (err) { - if (!subscriber.closed) { - subscriber.add(scheduler.schedule(dispatchError, 0, { err: err, subscriber: subscriber })); - } - }) - .then(null, function (err) { - // escape the promise trap, throw unhandled errors - root_1.root.setTimeout(function () { throw err; }); - }); - } - } - }; - return PromiseObservable; - }(Observable_1.Observable)); - exports.PromiseObservable = PromiseObservable; - function dispatchNext(arg) { - var value = arg.value, subscriber = arg.subscriber; - if (!subscriber.closed) { - subscriber.next(value); - subscriber.complete(); - } - } - function dispatchError(arg) { - var err = arg.err, subscriber = arg.subscriber; - if (!subscriber.closed) { - subscriber.error(err); - } - } - //# sourceMappingURL=PromiseObservable.js.map +/***/ }), +/* 150 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 116 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 root_1 = __webpack_require__(65); - var Observable_1 = __webpack_require__(64); - var iterator_1 = __webpack_require__(98); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var IteratorObservable = (function (_super) { - __extends(IteratorObservable, _super); - function IteratorObservable(iterator, scheduler) { - _super.call(this); - this.scheduler = scheduler; - if (iterator == null) { - throw new Error('iterator cannot be null.'); - } - this.iterator = getIterator(iterator); - } - IteratorObservable.create = function (iterator, scheduler) { - return new IteratorObservable(iterator, scheduler); - }; - IteratorObservable.dispatch = function (state) { - var index = state.index, hasError = state.hasError, iterator = state.iterator, subscriber = state.subscriber; - if (hasError) { - subscriber.error(state.error); - return; - } - var result = iterator.next(); - if (result.done) { - subscriber.complete(); - return; - } - subscriber.next(result.value); - state.index = index + 1; - if (subscriber.closed) { - if (typeof iterator.return === 'function') { - iterator.return(); - } - return; - } - this.schedule(state); - }; - IteratorObservable.prototype._subscribe = function (subscriber) { - var index = 0; - var _a = this, iterator = _a.iterator, scheduler = _a.scheduler; - if (scheduler) { - return scheduler.schedule(IteratorObservable.dispatch, 0, { - index: index, iterator: iterator, subscriber: subscriber - }); - } - else { - do { - var result = iterator.next(); - if (result.done) { - subscriber.complete(); - break; - } - else { - subscriber.next(result.value); - } - if (subscriber.closed) { - if (typeof iterator.return === 'function') { - iterator.return(); - } - break; - } - } while (true); - } - }; - return IteratorObservable; - }(Observable_1.Observable)); - exports.IteratorObservable = IteratorObservable; - var StringIterator = (function () { - function StringIterator(str, idx, len) { - if (idx === void 0) { idx = 0; } - if (len === void 0) { len = str.length; } - this.str = str; - this.idx = idx; - this.len = len; - } - StringIterator.prototype[iterator_1.iterator] = function () { return (this); }; - StringIterator.prototype.next = function () { - return this.idx < this.len ? { - done: false, - value: this.str.charAt(this.idx++) - } : { - done: true, - value: undefined - }; - }; - return StringIterator; - }()); - var ArrayIterator = (function () { - function ArrayIterator(arr, idx, len) { - if (idx === void 0) { idx = 0; } - if (len === void 0) { len = toLength(arr); } - this.arr = arr; - this.idx = idx; - this.len = len; - } - ArrayIterator.prototype[iterator_1.iterator] = function () { return this; }; - ArrayIterator.prototype.next = function () { - return this.idx < this.len ? { - done: false, - value: this.arr[this.idx++] - } : { - done: true, - value: undefined - }; - }; - return ArrayIterator; - }()); - function getIterator(obj) { - var i = obj[iterator_1.iterator]; - if (!i && typeof obj === 'string') { - return new StringIterator(obj); - } - if (!i && obj.length !== undefined) { - return new ArrayIterator(obj); - } - if (!i) { - throw new TypeError('object is not iterable'); - } - return obj[iterator_1.iterator](); - } - var maxSafeInteger = Math.pow(2, 53) - 1; - function toLength(o) { - var len = +o.length; - if (isNaN(len)) { - return 0; - } - if (len === 0 || !numberIsFinite(len)) { - return len; - } - len = sign(len) * Math.floor(Math.abs(len)); - if (len <= 0) { - return 0; - } - if (len > maxSafeInteger) { - return maxSafeInteger; - } - return len; - } - function numberIsFinite(value) { - return typeof value === 'number' && root_1.root.isFinite(value); - } - function sign(value) { - var valueAsNumber = +value; - if (valueAsNumber === 0) { - return valueAsNumber; - } - if (isNaN(valueAsNumber)) { - return valueAsNumber; - } - return valueAsNumber < 0 ? -1 : 1; - } - //# sourceMappingURL=IteratorObservable.js.map +"use strict"; -/***/ }, -/* 117 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var ScalarObservable_1 = __webpack_require__(91); - var EmptyObservable_1 = __webpack_require__(92); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var ArrayLikeObservable = (function (_super) { - __extends(ArrayLikeObservable, _super); - function ArrayLikeObservable(arrayLike, scheduler) { - _super.call(this); - this.arrayLike = arrayLike; - this.scheduler = scheduler; - if (!scheduler && arrayLike.length === 1) { - this._isScalar = true; - this.value = arrayLike[0]; - } - } - ArrayLikeObservable.create = function (arrayLike, scheduler) { - var length = arrayLike.length; - if (length === 0) { - return new EmptyObservable_1.EmptyObservable(); - } - else if (length === 1) { - return new ScalarObservable_1.ScalarObservable(arrayLike[0], scheduler); - } - else { - return new ArrayLikeObservable(arrayLike, scheduler); - } - }; - ArrayLikeObservable.dispatch = function (state) { - var arrayLike = state.arrayLike, index = state.index, length = state.length, subscriber = state.subscriber; - if (subscriber.closed) { - return; - } - if (index >= length) { - subscriber.complete(); - return; - } - subscriber.next(arrayLike[index]); - state.index = index + 1; - this.schedule(state); - }; - ArrayLikeObservable.prototype._subscribe = function (subscriber) { - var index = 0; - var _a = this, arrayLike = _a.arrayLike, scheduler = _a.scheduler; - var length = arrayLike.length; - if (scheduler) { - return scheduler.schedule(ArrayLikeObservable.dispatch, 0, { - arrayLike: arrayLike, index: index, length: length, subscriber: subscriber - }); - } - else { - for (var i = 0; i < length && !subscriber.closed; i++) { - subscriber.next(arrayLike[i]); - } - subscriber.complete(); - } - }; - return ArrayLikeObservable; - }(Observable_1.Observable)); - exports.ArrayLikeObservable = ArrayLikeObservable; - //# sourceMappingURL=ArrayLikeObservable.js.map - -/***/ }, -/* 118 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var Notification_1 = __webpack_require__(119); - /** - * - * Re-emits all notifications from source Observable with specified scheduler. - * - * Ensure a specific scheduler is used, from outside of an Observable. - * - * `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule - * notifications emitted by the source Observable. It might be useful, if you do not have control over - * internal scheduler of a given Observable, but want to control when its values are emitted nevertheless. - * - * Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable, - * but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal - * scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits - * notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`. - * An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split - * that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source - * Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a - * little bit more, to ensure that they are emitted at expected moments. - * - * As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications - * will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn` - * will delay all notifications - including error notifications - while `delay` will pass through error - * from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator - * for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used - * for notification emissions in general. - * - * @example Ensure values in subscribe are called just before browser repaint. - * const intervals = Rx.Observable.interval(10); // Intervals are scheduled - * // with async scheduler by default... - * - * intervals - * .observeOn(Rx.Scheduler.animationFrame) // ...but we will observe on animationFrame - * .subscribe(val => { // scheduler to ensure smooth animation. - * someDiv.style.height = val + 'px'; - * }); - * - * @see {@link delay} - * - * @param {IScheduler} scheduler Scheduler that will be used to reschedule notifications from source Observable. - * @param {number} [delay] Number of milliseconds that states with what delay every notification should be rescheduled. - * @return {Observable} Observable that emits the same notifications as the source Observable, - * but with provided scheduler. - * - * @method observeOn - * @owner Observable - */ - function observeOn(scheduler, delay) { - if (delay === void 0) { delay = 0; } - return this.lift(new ObserveOnOperator(scheduler, delay)); - } - exports.observeOn = observeOn; - var ObserveOnOperator = (function () { - function ObserveOnOperator(scheduler, delay) { - if (delay === void 0) { delay = 0; } - this.scheduler = scheduler; - this.delay = delay; - } - ObserveOnOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay)); - }; - return ObserveOnOperator; - }()); - exports.ObserveOnOperator = ObserveOnOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ObserveOnSubscriber = (function (_super) { - __extends(ObserveOnSubscriber, _super); - function ObserveOnSubscriber(destination, scheduler, delay) { - if (delay === void 0) { delay = 0; } - _super.call(this, destination); - this.scheduler = scheduler; - this.delay = delay; - } - ObserveOnSubscriber.dispatch = function (arg) { - var notification = arg.notification, destination = arg.destination; - notification.observe(destination); - this.unsubscribe(); - }; - ObserveOnSubscriber.prototype.scheduleMessage = function (notification) { - this.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination))); - }; - ObserveOnSubscriber.prototype._next = function (value) { - this.scheduleMessage(Notification_1.Notification.createNext(value)); - }; - ObserveOnSubscriber.prototype._error = function (err) { - this.scheduleMessage(Notification_1.Notification.createError(err)); - }; - ObserveOnSubscriber.prototype._complete = function () { - this.scheduleMessage(Notification_1.Notification.createComplete()); - }; - return ObserveOnSubscriber; - }(Subscriber_1.Subscriber)); - exports.ObserveOnSubscriber = ObserveOnSubscriber; - var ObserveOnMessage = (function () { - function ObserveOnMessage(notification, destination) { - this.notification = notification; - this.destination = destination; - } - return ObserveOnMessage; - }()); - exports.ObserveOnMessage = ObserveOnMessage; - //# sourceMappingURL=observeOn.js.map - -/***/ }, -/* 119 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Observable_1 = __webpack_require__(64); - /** - * Represents a push-based event or value that an {@link Observable} can emit. - * This class is particularly useful for operators that manage notifications, - * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and - * others. Besides wrapping the actual delivered value, it also annotates it - * with metadata of, for instance, what type of push message it is (`next`, - * `error`, or `complete`). - * - * @see {@link materialize} - * @see {@link dematerialize} - * @see {@link observeOn} - * - * @class Notification - */ - var Notification = (function () { - function Notification(kind, value, error) { - this.kind = kind; - this.value = value; - this.error = error; - this.hasValue = kind === 'N'; - } - /** - * Delivers to the given `observer` the value wrapped by this Notification. - * @param {Observer} observer - * @return - */ - Notification.prototype.observe = function (observer) { - switch (this.kind) { - case 'N': - return observer.next && observer.next(this.value); - case 'E': - return observer.error && observer.error(this.error); - case 'C': - return observer.complete && observer.complete(); - } - }; - /** - * Given some {@link Observer} callbacks, deliver the value represented by the - * current Notification to the correctly corresponding callback. - * @param {function(value: T): void} next An Observer `next` callback. - * @param {function(err: any): void} [error] An Observer `error` callback. - * @param {function(): void} [complete] An Observer `complete` callback. - * @return {any} - */ - Notification.prototype.do = function (next, error, complete) { - var kind = this.kind; - switch (kind) { - case 'N': - return next && next(this.value); - case 'E': - return error && error(this.error); - case 'C': - return complete && complete(); - } - }; - /** - * Takes an Observer or its individual callback functions, and calls `observe` - * or `do` methods accordingly. - * @param {Observer|function(value: T): void} nextOrObserver An Observer or - * the `next` callback. - * @param {function(err: any): void} [error] An Observer `error` callback. - * @param {function(): void} [complete] An Observer `complete` callback. - * @return {any} - */ - Notification.prototype.accept = function (nextOrObserver, error, complete) { - if (nextOrObserver && typeof nextOrObserver.next === 'function') { - return this.observe(nextOrObserver); - } - else { - return this.do(nextOrObserver, error, complete); - } - }; - /** - * Returns a simple Observable that just delivers the notification represented - * by this Notification instance. - * @return {any} - */ - Notification.prototype.toObservable = function () { - var kind = this.kind; - switch (kind) { - case 'N': - return Observable_1.Observable.of(this.value); - case 'E': - return Observable_1.Observable.throw(this.error); - case 'C': - return Observable_1.Observable.empty(); - } - throw new Error('unexpected notification kind value'); - }; - /** - * A shortcut to create a Notification instance of the type `next` from a - * given value. - * @param {T} value The `next` value. - * @return {Notification} The "next" Notification representing the - * argument. - */ - Notification.createNext = function (value) { - if (typeof value !== 'undefined') { - return new Notification('N', value); - } - return Notification.undefinedValueNotification; - }; - /** - * A shortcut to create a Notification instance of the type `error` from a - * given error. - * @param {any} [err] The `error` error. - * @return {Notification} The "error" Notification representing the - * argument. - */ - Notification.createError = function (err) { - return new Notification('E', undefined, err); - }; - /** - * A shortcut to create a Notification instance of the type `complete`. - * @return {Notification} The valueless "complete" Notification. - */ - Notification.createComplete = function () { - return Notification.completeNotification; - }; - Notification.completeNotification = new Notification('C'); - Notification.undefinedValueNotification = new Notification('N', undefined); - return Notification; - }()); - exports.Notification = Notification; - //# sourceMappingURL=Notification.js.map - -/***/ }, -/* 120 */ -/***/ function(module, exports, __webpack_require__) { +var ForkJoinObservable_1 = __webpack_require__(151); +exports.forkJoin = ForkJoinObservable_1.ForkJoinObservable.create; +//# sourceMappingURL=forkJoin.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var fromEvent_1 = __webpack_require__(121); - Observable_1.Observable.fromEvent = fromEvent_1.fromEvent; - //# sourceMappingURL=fromEvent.js.map +/***/ }), +/* 151 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var EmptyObservable_1 = __webpack_require__(16); +var isArray_1 = __webpack_require__(13); +var subscribeToResult_1 = __webpack_require__(3); +var OuterSubscriber_1 = __webpack_require__(2); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var ForkJoinObservable = (function (_super) { + __extends(ForkJoinObservable, _super); + function ForkJoinObservable(sources, resultSelector) { + _super.call(this); + this.sources = sources; + this.resultSelector = resultSelector; + } + /* tslint:enable:max-line-length */ + /** + * @param sources + * @return {any} + * @static true + * @name forkJoin + * @owner Observable + */ + ForkJoinObservable.create = function () { + var sources = []; + for (var _i = 0; _i < arguments.length; _i++) { + sources[_i - 0] = arguments[_i]; + } + if (sources === null || arguments.length === 0) { + return new EmptyObservable_1.EmptyObservable(); + } + var resultSelector = null; + if (typeof sources[sources.length - 1] === 'function') { + resultSelector = sources.pop(); + } + // if the first and only other argument besides the resultSelector is an array + // assume it's been called with `forkJoin([obs1, obs2, obs3], resultSelector)` + if (sources.length === 1 && isArray_1.isArray(sources[0])) { + sources = sources[0]; + } + if (sources.length === 0) { + return new EmptyObservable_1.EmptyObservable(); + } + return new ForkJoinObservable(sources, resultSelector); + }; + ForkJoinObservable.prototype._subscribe = function (subscriber) { + return new ForkJoinSubscriber(subscriber, this.sources, this.resultSelector); + }; + return ForkJoinObservable; +}(Observable_1.Observable)); +exports.ForkJoinObservable = ForkJoinObservable; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ForkJoinSubscriber = (function (_super) { + __extends(ForkJoinSubscriber, _super); + function ForkJoinSubscriber(destination, sources, resultSelector) { + _super.call(this, destination); + this.sources = sources; + this.resultSelector = resultSelector; + this.completed = 0; + this.haveValues = 0; + var len = sources.length; + this.total = len; + this.values = new Array(len); + for (var i = 0; i < len; i++) { + var source = sources[i]; + var innerSubscription = subscribeToResult_1.subscribeToResult(this, source, null, i); + if (innerSubscription) { + innerSubscription.outerIndex = i; + this.add(innerSubscription); + } + } + } + ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.values[outerIndex] = innerValue; + if (!innerSub._hasValue) { + innerSub._hasValue = true; + this.haveValues++; + } + }; + ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) { + var destination = this.destination; + var _a = this, haveValues = _a.haveValues, resultSelector = _a.resultSelector, values = _a.values; + var len = values.length; + if (!innerSub._hasValue) { + destination.complete(); + return; + } + this.completed++; + if (this.completed !== len) { + return; + } + if (haveValues === len) { + var value = resultSelector ? resultSelector.apply(this, values) : values; + destination.next(value); + } + destination.complete(); + }; + return ForkJoinSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=ForkJoinObservable.js.map + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 121 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var FromEventObservable_1 = __webpack_require__(122); - exports.fromEvent = FromEventObservable_1.FromEventObservable.create; - //# sourceMappingURL=fromEvent.js.map +var Observable_1 = __webpack_require__(0); +var from_1 = __webpack_require__(153); +Observable_1.Observable.from = from_1.from; +//# sourceMappingURL=from.js.map -/***/ }, -/* 122 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var tryCatch_1 = __webpack_require__(72); - var isFunction_1 = __webpack_require__(68); - var errorObject_1 = __webpack_require__(73); - var Subscription_1 = __webpack_require__(69); - var toString = Object.prototype.toString; - function isNodeStyleEventEmitter(sourceObj) { - return !!sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function'; - } - function isJQueryStyleEventEmitter(sourceObj) { - return !!sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function'; - } - function isNodeList(sourceObj) { - return !!sourceObj && toString.call(sourceObj) === '[object NodeList]'; - } - function isHTMLCollection(sourceObj) { - return !!sourceObj && toString.call(sourceObj) === '[object HTMLCollection]'; - } - function isEventTarget(sourceObj) { - return !!sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function'; - } - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var FromEventObservable = (function (_super) { - __extends(FromEventObservable, _super); - function FromEventObservable(sourceObj, eventName, selector, options) { - _super.call(this); - this.sourceObj = sourceObj; - this.eventName = eventName; - this.selector = selector; - this.options = options; - } - /* tslint:enable:max-line-length */ - /** - * Creates an Observable that emits events of a specific type coming from the - * given event target. - * - * Creates an Observable from DOM events, or Node - * EventEmitter events or others. - * - * - * - * Creates an Observable by attaching an event listener to an "event target", - * which may be an object with `addEventListener` and `removeEventListener`, - * a Node.js EventEmitter, a jQuery style EventEmitter, a NodeList from the - * DOM, or an HTMLCollection from the DOM. The event handler is attached when - * the output Observable is subscribed, and removed when the Subscription is - * unsubscribed. - * - * @example Emits clicks happening on the DOM document - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * clicks.subscribe(x => console.log(x)); - * - * // Results in: - * // MouseEvent object logged to console everytime a click - * // occurs on the document. - * - * @see {@link from} - * @see {@link fromEventPattern} - * - * @param {EventTargetLike} target The DOMElement, event target, Node.js - * EventEmitter, NodeList or HTMLCollection to attach the event handler to. - * @param {string} eventName The event name of interest, being emitted by the - * `target`. - * @param {EventListenerOptions} [options] Options to pass through to addEventListener - * @param {SelectorMethodSignature} [selector] An optional function to - * post-process results. It takes the arguments from the event handler and - * should return a single value. - * @return {Observable} - * @static true - * @name fromEvent - * @owner Observable - */ - FromEventObservable.create = function (target, eventName, options, selector) { - if (isFunction_1.isFunction(options)) { - selector = options; - options = undefined; - } - return new FromEventObservable(target, eventName, selector, options); - }; - FromEventObservable.setupSubscription = function (sourceObj, eventName, handler, subscriber, options) { - var unsubscribe; - if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { - for (var i = 0, len = sourceObj.length; i < len; i++) { - FromEventObservable.setupSubscription(sourceObj[i], eventName, handler, subscriber, options); - } - } - else if (isEventTarget(sourceObj)) { - var source_1 = sourceObj; - sourceObj.addEventListener(eventName, handler, options); - unsubscribe = function () { return source_1.removeEventListener(eventName, handler); }; - } - else if (isJQueryStyleEventEmitter(sourceObj)) { - var source_2 = sourceObj; - sourceObj.on(eventName, handler); - unsubscribe = function () { return source_2.off(eventName, handler); }; - } - else if (isNodeStyleEventEmitter(sourceObj)) { - var source_3 = sourceObj; - sourceObj.addListener(eventName, handler); - unsubscribe = function () { return source_3.removeListener(eventName, handler); }; - } - else { - throw new TypeError('Invalid event target'); - } - subscriber.add(new Subscription_1.Subscription(unsubscribe)); - }; - FromEventObservable.prototype._subscribe = function (subscriber) { - var sourceObj = this.sourceObj; - var eventName = this.eventName; - var options = this.options; - var selector = this.selector; - var handler = selector ? function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - var result = tryCatch_1.tryCatch(selector).apply(void 0, args); - if (result === errorObject_1.errorObject) { - subscriber.error(errorObject_1.errorObject.e); - } - else { - subscriber.next(result); - } - } : function (e) { return subscriber.next(e); }; - FromEventObservable.setupSubscription(sourceObj, eventName, handler, subscriber, options); - }; - return FromEventObservable; - }(Observable_1.Observable)); - exports.FromEventObservable = FromEventObservable; - //# sourceMappingURL=FromEventObservable.js.map - -/***/ }, -/* 123 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 153 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var fromEventPattern_1 = __webpack_require__(124); - Observable_1.Observable.fromEventPattern = fromEventPattern_1.fromEventPattern; - //# sourceMappingURL=fromEventPattern.js.map +"use strict"; -/***/ }, -/* 124 */ -/***/ function(module, exports, __webpack_require__) { +var FromObservable_1 = __webpack_require__(65); +exports.from = FromObservable_1.FromObservable.create; +//# sourceMappingURL=from.js.map - "use strict"; - var FromEventPatternObservable_1 = __webpack_require__(125); - exports.fromEventPattern = FromEventPatternObservable_1.FromEventPatternObservable.create; - //# sourceMappingURL=fromEventPattern.js.map +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 root_1 = __webpack_require__(7); +var Observable_1 = __webpack_require__(0); +var iterator_1 = __webpack_require__(21); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var IteratorObservable = (function (_super) { + __extends(IteratorObservable, _super); + function IteratorObservable(iterator, scheduler) { + _super.call(this); + this.scheduler = scheduler; + if (iterator == null) { + throw new Error('iterator cannot be null.'); + } + this.iterator = getIterator(iterator); + } + IteratorObservable.create = function (iterator, scheduler) { + return new IteratorObservable(iterator, scheduler); + }; + IteratorObservable.dispatch = function (state) { + var index = state.index, hasError = state.hasError, iterator = state.iterator, subscriber = state.subscriber; + if (hasError) { + subscriber.error(state.error); + return; + } + var result = iterator.next(); + if (result.done) { + subscriber.complete(); + return; + } + subscriber.next(result.value); + state.index = index + 1; + if (subscriber.closed) { + if (typeof iterator.return === 'function') { + iterator.return(); + } + return; + } + this.schedule(state); + }; + IteratorObservable.prototype._subscribe = function (subscriber) { + var index = 0; + var _a = this, iterator = _a.iterator, scheduler = _a.scheduler; + if (scheduler) { + return scheduler.schedule(IteratorObservable.dispatch, 0, { + index: index, iterator: iterator, subscriber: subscriber + }); + } + else { + do { + var result = iterator.next(); + if (result.done) { + subscriber.complete(); + break; + } + else { + subscriber.next(result.value); + } + if (subscriber.closed) { + if (typeof iterator.return === 'function') { + iterator.return(); + } + break; + } + } while (true); + } + }; + return IteratorObservable; +}(Observable_1.Observable)); +exports.IteratorObservable = IteratorObservable; +var StringIterator = (function () { + function StringIterator(str, idx, len) { + if (idx === void 0) { idx = 0; } + if (len === void 0) { len = str.length; } + this.str = str; + this.idx = idx; + this.len = len; + } + StringIterator.prototype[iterator_1.iterator] = function () { return (this); }; + StringIterator.prototype.next = function () { + return this.idx < this.len ? { + done: false, + value: this.str.charAt(this.idx++) + } : { + done: true, + value: undefined + }; + }; + return StringIterator; +}()); +var ArrayIterator = (function () { + function ArrayIterator(arr, idx, len) { + if (idx === void 0) { idx = 0; } + if (len === void 0) { len = toLength(arr); } + this.arr = arr; + this.idx = idx; + this.len = len; + } + ArrayIterator.prototype[iterator_1.iterator] = function () { return this; }; + ArrayIterator.prototype.next = function () { + return this.idx < this.len ? { + done: false, + value: this.arr[this.idx++] + } : { + done: true, + value: undefined + }; + }; + return ArrayIterator; +}()); +function getIterator(obj) { + var i = obj[iterator_1.iterator]; + if (!i && typeof obj === 'string') { + return new StringIterator(obj); + } + if (!i && obj.length !== undefined) { + return new ArrayIterator(obj); + } + if (!i) { + throw new TypeError('object is not iterable'); + } + return obj[iterator_1.iterator](); +} +var maxSafeInteger = Math.pow(2, 53) - 1; +function toLength(o) { + var len = +o.length; + if (isNaN(len)) { + return 0; + } + if (len === 0 || !numberIsFinite(len)) { + return len; + } + len = sign(len) * Math.floor(Math.abs(len)); + if (len <= 0) { + return 0; + } + if (len > maxSafeInteger) { + return maxSafeInteger; + } + return len; +} +function numberIsFinite(value) { + return typeof value === 'number' && root_1.root.isFinite(value); +} +function sign(value) { + var valueAsNumber = +value; + if (valueAsNumber === 0) { + return valueAsNumber; + } + if (isNaN(valueAsNumber)) { + return valueAsNumber; + } + return valueAsNumber < 0 ? -1 : 1; +} +//# sourceMappingURL=IteratorObservable.js.map + +/***/ }), +/* 155 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var ScalarObservable_1 = __webpack_require__(43); +var EmptyObservable_1 = __webpack_require__(16); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var ArrayLikeObservable = (function (_super) { + __extends(ArrayLikeObservable, _super); + function ArrayLikeObservable(arrayLike, scheduler) { + _super.call(this); + this.arrayLike = arrayLike; + this.scheduler = scheduler; + if (!scheduler && arrayLike.length === 1) { + this._isScalar = true; + this.value = arrayLike[0]; + } + } + ArrayLikeObservable.create = function (arrayLike, scheduler) { + var length = arrayLike.length; + if (length === 0) { + return new EmptyObservable_1.EmptyObservable(); + } + else if (length === 1) { + return new ScalarObservable_1.ScalarObservable(arrayLike[0], scheduler); + } + else { + return new ArrayLikeObservable(arrayLike, scheduler); + } + }; + ArrayLikeObservable.dispatch = function (state) { + var arrayLike = state.arrayLike, index = state.index, length = state.length, subscriber = state.subscriber; + if (subscriber.closed) { + return; + } + if (index >= length) { + subscriber.complete(); + return; + } + subscriber.next(arrayLike[index]); + state.index = index + 1; + this.schedule(state); + }; + ArrayLikeObservable.prototype._subscribe = function (subscriber) { + var index = 0; + var _a = this, arrayLike = _a.arrayLike, scheduler = _a.scheduler; + var length = arrayLike.length; + if (scheduler) { + return scheduler.schedule(ArrayLikeObservable.dispatch, 0, { + arrayLike: arrayLike, index: index, length: length, subscriber: subscriber + }); + } + else { + for (var i = 0; i < length && !subscriber.closed; i++) { + subscriber.next(arrayLike[i]); + } + subscriber.complete(); + } + }; + return ArrayLikeObservable; +}(Observable_1.Observable)); +exports.ArrayLikeObservable = ArrayLikeObservable; +//# sourceMappingURL=ArrayLikeObservable.js.map + +/***/ }), +/* 156 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 125 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 isFunction_1 = __webpack_require__(68); - var Observable_1 = __webpack_require__(64); - var Subscription_1 = __webpack_require__(69); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var FromEventPatternObservable = (function (_super) { - __extends(FromEventPatternObservable, _super); - function FromEventPatternObservable(addHandler, removeHandler, selector) { - _super.call(this); - this.addHandler = addHandler; - this.removeHandler = removeHandler; - this.selector = selector; - } - /** - * Creates an Observable from an API based on addHandler/removeHandler - * functions. - * - * Converts any addHandler/removeHandler API to an - * Observable. - * - * - * - * Creates an Observable by using the `addHandler` and `removeHandler` - * functions to add and remove the handlers, with an optional selector - * function to project the event arguments to a result. The `addHandler` is - * called when the output Observable is subscribed, and `removeHandler` is - * called when the Subscription is unsubscribed. - * - * @example Emits clicks happening on the DOM document - * function addClickHandler(handler) { - * document.addEventListener('click', handler); - * } - * - * function removeClickHandler(handler) { - * document.removeEventListener('click', handler); - * } - * - * var clicks = Rx.Observable.fromEventPattern( - * addClickHandler, - * removeClickHandler - * ); - * clicks.subscribe(x => console.log(x)); - * - * @see {@link from} - * @see {@link fromEvent} - * - * @param {function(handler: Function): any} addHandler A function that takes - * a `handler` function as argument and attaches it somehow to the actual - * source of events. - * @param {function(handler: Function, signal?: any): void} [removeHandler] An optional function that - * takes a `handler` function as argument and removes it in case it was - * previously attached using `addHandler`. if addHandler returns signal to teardown when remove, - * removeHandler function will forward it. - * @param {function(...args: any): T} [selector] An optional function to - * post-process results. It takes the arguments from the event handler and - * should return a single value. - * @return {Observable} - * @static true - * @name fromEventPattern - * @owner Observable - */ - FromEventPatternObservable.create = function (addHandler, removeHandler, selector) { - return new FromEventPatternObservable(addHandler, removeHandler, selector); - }; - FromEventPatternObservable.prototype._subscribe = function (subscriber) { - var _this = this; - var removeHandler = this.removeHandler; - var handler = !!this.selector ? function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - _this._callSelector(subscriber, args); - } : function (e) { subscriber.next(e); }; - var retValue = this._callAddHandler(handler, subscriber); - if (!isFunction_1.isFunction(removeHandler)) { - return; - } - subscriber.add(new Subscription_1.Subscription(function () { - //TODO: determine whether or not to forward to error handler - removeHandler(handler, retValue); - })); - }; - FromEventPatternObservable.prototype._callSelector = function (subscriber, args) { - try { - var result = this.selector.apply(this, args); - subscriber.next(result); - } - catch (e) { - subscriber.error(e); - } - }; - FromEventPatternObservable.prototype._callAddHandler = function (handler, errorSubscriber) { - try { - return this.addHandler(handler) || null; - } - catch (e) { - errorSubscriber.error(e); - } - }; - return FromEventPatternObservable; - }(Observable_1.Observable)); - exports.FromEventPatternObservable = FromEventPatternObservable; - //# sourceMappingURL=FromEventPatternObservable.js.map - -/***/ }, -/* 126 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var fromPromise_1 = __webpack_require__(127); - Observable_1.Observable.fromPromise = fromPromise_1.fromPromise; - //# sourceMappingURL=fromPromise.js.map +var Observable_1 = __webpack_require__(0); +var fromEvent_1 = __webpack_require__(157); +Observable_1.Observable.fromEvent = fromEvent_1.fromEvent; +//# sourceMappingURL=fromEvent.js.map -/***/ }, -/* 127 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 157 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var PromiseObservable_1 = __webpack_require__(115); - exports.fromPromise = PromiseObservable_1.PromiseObservable.create; - //# sourceMappingURL=fromPromise.js.map +"use strict"; -/***/ }, -/* 128 */ -/***/ function(module, exports, __webpack_require__) { +var FromEventObservable_1 = __webpack_require__(158); +exports.fromEvent = FromEventObservable_1.FromEventObservable.create; +//# sourceMappingURL=fromEvent.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var generate_1 = __webpack_require__(129); - Observable_1.Observable.generate = generate_1.generate; - //# sourceMappingURL=generate.js.map +/***/ }), +/* 158 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var tryCatch_1 = __webpack_require__(8); +var isFunction_1 = __webpack_require__(28); +var errorObject_1 = __webpack_require__(6); +var Subscription_1 = __webpack_require__(4); +var toString = Object.prototype.toString; +function isNodeStyleEventEmitter(sourceObj) { + return !!sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function'; +} +function isJQueryStyleEventEmitter(sourceObj) { + return !!sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function'; +} +function isNodeList(sourceObj) { + return !!sourceObj && toString.call(sourceObj) === '[object NodeList]'; +} +function isHTMLCollection(sourceObj) { + return !!sourceObj && toString.call(sourceObj) === '[object HTMLCollection]'; +} +function isEventTarget(sourceObj) { + return !!sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function'; +} +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var FromEventObservable = (function (_super) { + __extends(FromEventObservable, _super); + function FromEventObservable(sourceObj, eventName, selector, options) { + _super.call(this); + this.sourceObj = sourceObj; + this.eventName = eventName; + this.selector = selector; + this.options = options; + } + /* tslint:enable:max-line-length */ + /** + * Creates an Observable that emits events of a specific type coming from the + * given event target. + * + * Creates an Observable from DOM events, or Node + * EventEmitter events or others. + * + * + * + * Creates an Observable by attaching an event listener to an "event target", + * which may be an object with `addEventListener` and `removeEventListener`, + * a Node.js EventEmitter, a jQuery style EventEmitter, a NodeList from the + * DOM, or an HTMLCollection from the DOM. The event handler is attached when + * the output Observable is subscribed, and removed when the Subscription is + * unsubscribed. + * + * @example Emits clicks happening on the DOM document + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * clicks.subscribe(x => console.log(x)); + * + * // Results in: + * // MouseEvent object logged to console everytime a click + * // occurs on the document. + * + * @see {@link from} + * @see {@link fromEventPattern} + * + * @param {EventTargetLike} target The DOMElement, event target, Node.js + * EventEmitter, NodeList or HTMLCollection to attach the event handler to. + * @param {string} eventName The event name of interest, being emitted by the + * `target`. + * @param {EventListenerOptions} [options] Options to pass through to addEventListener + * @param {SelectorMethodSignature} [selector] An optional function to + * post-process results. It takes the arguments from the event handler and + * should return a single value. + * @return {Observable} + * @static true + * @name fromEvent + * @owner Observable + */ + FromEventObservable.create = function (target, eventName, options, selector) { + if (isFunction_1.isFunction(options)) { + selector = options; + options = undefined; + } + return new FromEventObservable(target, eventName, selector, options); + }; + FromEventObservable.setupSubscription = function (sourceObj, eventName, handler, subscriber, options) { + var unsubscribe; + if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { + for (var i = 0, len = sourceObj.length; i < len; i++) { + FromEventObservable.setupSubscription(sourceObj[i], eventName, handler, subscriber, options); + } + } + else if (isEventTarget(sourceObj)) { + var source_1 = sourceObj; + sourceObj.addEventListener(eventName, handler, options); + unsubscribe = function () { return source_1.removeEventListener(eventName, handler); }; + } + else if (isJQueryStyleEventEmitter(sourceObj)) { + var source_2 = sourceObj; + sourceObj.on(eventName, handler); + unsubscribe = function () { return source_2.off(eventName, handler); }; + } + else if (isNodeStyleEventEmitter(sourceObj)) { + var source_3 = sourceObj; + sourceObj.addListener(eventName, handler); + unsubscribe = function () { return source_3.removeListener(eventName, handler); }; + } + else { + throw new TypeError('Invalid event target'); + } + subscriber.add(new Subscription_1.Subscription(unsubscribe)); + }; + FromEventObservable.prototype._subscribe = function (subscriber) { + var sourceObj = this.sourceObj; + var eventName = this.eventName; + var options = this.options; + var selector = this.selector; + var handler = selector ? function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + var result = tryCatch_1.tryCatch(selector).apply(void 0, args); + if (result === errorObject_1.errorObject) { + subscriber.error(errorObject_1.errorObject.e); + } + else { + subscriber.next(result); + } + } : function (e) { return subscriber.next(e); }; + FromEventObservable.setupSubscription(sourceObj, eventName, handler, subscriber, options); + }; + return FromEventObservable; +}(Observable_1.Observable)); +exports.FromEventObservable = FromEventObservable; +//# sourceMappingURL=FromEventObservable.js.map + +/***/ }), +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 129 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var GenerateObservable_1 = __webpack_require__(130); - exports.generate = GenerateObservable_1.GenerateObservable.create; - //# sourceMappingURL=generate.js.map +var Observable_1 = __webpack_require__(0); +var fromEventPattern_1 = __webpack_require__(160); +Observable_1.Observable.fromEventPattern = fromEventPattern_1.fromEventPattern; +//# sourceMappingURL=fromEventPattern.js.map -/***/ }, -/* 130 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var isScheduler_1 = __webpack_require__(89); - var selfSelector = function (value) { return value; }; - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var GenerateObservable = (function (_super) { - __extends(GenerateObservable, _super); - function GenerateObservable(initialState, condition, iterate, resultSelector, scheduler) { - _super.call(this); - this.initialState = initialState; - this.condition = condition; - this.iterate = iterate; - this.resultSelector = resultSelector; - this.scheduler = scheduler; - } - GenerateObservable.create = function (initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) { - if (arguments.length == 1) { - return new GenerateObservable(initialStateOrOptions.initialState, initialStateOrOptions.condition, initialStateOrOptions.iterate, initialStateOrOptions.resultSelector || selfSelector, initialStateOrOptions.scheduler); - } - if (resultSelectorOrObservable === undefined || isScheduler_1.isScheduler(resultSelectorOrObservable)) { - return new GenerateObservable(initialStateOrOptions, condition, iterate, selfSelector, resultSelectorOrObservable); - } - return new GenerateObservable(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler); - }; - GenerateObservable.prototype._subscribe = function (subscriber) { - var state = this.initialState; - if (this.scheduler) { - return this.scheduler.schedule(GenerateObservable.dispatch, 0, { - subscriber: subscriber, - iterate: this.iterate, - condition: this.condition, - resultSelector: this.resultSelector, - state: state }); - } - var _a = this, condition = _a.condition, resultSelector = _a.resultSelector, iterate = _a.iterate; - do { - if (condition) { - var conditionResult = void 0; - try { - conditionResult = condition(state); - } - catch (err) { - subscriber.error(err); - return; - } - if (!conditionResult) { - subscriber.complete(); - break; - } - } - var value = void 0; - try { - value = resultSelector(state); - } - catch (err) { - subscriber.error(err); - return; - } - subscriber.next(value); - if (subscriber.closed) { - break; - } - try { - state = iterate(state); - } - catch (err) { - subscriber.error(err); - return; - } - } while (true); - }; - GenerateObservable.dispatch = function (state) { - var subscriber = state.subscriber, condition = state.condition; - if (subscriber.closed) { - return; - } - if (state.needIterate) { - try { - state.state = state.iterate(state.state); - } - catch (err) { - subscriber.error(err); - return; - } - } - else { - state.needIterate = true; - } - if (condition) { - var conditionResult = void 0; - try { - conditionResult = condition(state.state); - } - catch (err) { - subscriber.error(err); - return; - } - if (!conditionResult) { - subscriber.complete(); - return; - } - if (subscriber.closed) { - return; - } - } - var value; - try { - value = state.resultSelector(state.state); - } - catch (err) { - subscriber.error(err); - return; - } - if (subscriber.closed) { - return; - } - subscriber.next(value); - if (subscriber.closed) { - return; - } - return this.schedule(state); - }; - return GenerateObservable; - }(Observable_1.Observable)); - exports.GenerateObservable = GenerateObservable; - //# sourceMappingURL=GenerateObservable.js.map - -/***/ }, -/* 131 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 160 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var if_1 = __webpack_require__(132); - Observable_1.Observable.if = if_1._if; - //# sourceMappingURL=if.js.map +"use strict"; -/***/ }, -/* 132 */ -/***/ function(module, exports, __webpack_require__) { +var FromEventPatternObservable_1 = __webpack_require__(161); +exports.fromEventPattern = FromEventPatternObservable_1.FromEventPatternObservable.create; +//# sourceMappingURL=fromEventPattern.js.map - "use strict"; - var IfObservable_1 = __webpack_require__(133); - exports._if = IfObservable_1.IfObservable.create; - //# sourceMappingURL=if.js.map +/***/ }), +/* 161 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 isFunction_1 = __webpack_require__(28); +var Observable_1 = __webpack_require__(0); +var Subscription_1 = __webpack_require__(4); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var FromEventPatternObservable = (function (_super) { + __extends(FromEventPatternObservable, _super); + function FromEventPatternObservable(addHandler, removeHandler, selector) { + _super.call(this); + this.addHandler = addHandler; + this.removeHandler = removeHandler; + this.selector = selector; + } + /** + * Creates an Observable from an API based on addHandler/removeHandler + * functions. + * + * Converts any addHandler/removeHandler API to an + * Observable. + * + * + * + * Creates an Observable by using the `addHandler` and `removeHandler` + * functions to add and remove the handlers, with an optional selector + * function to project the event arguments to a result. The `addHandler` is + * called when the output Observable is subscribed, and `removeHandler` is + * called when the Subscription is unsubscribed. + * + * @example Emits clicks happening on the DOM document + * function addClickHandler(handler) { + * document.addEventListener('click', handler); + * } + * + * function removeClickHandler(handler) { + * document.removeEventListener('click', handler); + * } + * + * var clicks = Rx.Observable.fromEventPattern( + * addClickHandler, + * removeClickHandler + * ); + * clicks.subscribe(x => console.log(x)); + * + * @see {@link from} + * @see {@link fromEvent} + * + * @param {function(handler: Function): any} addHandler A function that takes + * a `handler` function as argument and attaches it somehow to the actual + * source of events. + * @param {function(handler: Function, signal?: any): void} [removeHandler] An optional function that + * takes a `handler` function as argument and removes it in case it was + * previously attached using `addHandler`. if addHandler returns signal to teardown when remove, + * removeHandler function will forward it. + * @param {function(...args: any): T} [selector] An optional function to + * post-process results. It takes the arguments from the event handler and + * should return a single value. + * @return {Observable} + * @static true + * @name fromEventPattern + * @owner Observable + */ + FromEventPatternObservable.create = function (addHandler, removeHandler, selector) { + return new FromEventPatternObservable(addHandler, removeHandler, selector); + }; + FromEventPatternObservable.prototype._subscribe = function (subscriber) { + var _this = this; + var removeHandler = this.removeHandler; + var handler = !!this.selector ? function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + _this._callSelector(subscriber, args); + } : function (e) { subscriber.next(e); }; + var retValue = this._callAddHandler(handler, subscriber); + if (!isFunction_1.isFunction(removeHandler)) { + return; + } + subscriber.add(new Subscription_1.Subscription(function () { + //TODO: determine whether or not to forward to error handler + removeHandler(handler, retValue); + })); + }; + FromEventPatternObservable.prototype._callSelector = function (subscriber, args) { + try { + var result = this.selector.apply(this, args); + subscriber.next(result); + } + catch (e) { + subscriber.error(e); + } + }; + FromEventPatternObservable.prototype._callAddHandler = function (handler, errorSubscriber) { + try { + return this.addHandler(handler) || null; + } + catch (e) { + errorSubscriber.error(e); + } + }; + return FromEventPatternObservable; +}(Observable_1.Observable)); +exports.FromEventPatternObservable = FromEventPatternObservable; +//# sourceMappingURL=FromEventPatternObservable.js.map + +/***/ }), +/* 162 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 133 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var subscribeToResult_1 = __webpack_require__(95); - var OuterSubscriber_1 = __webpack_require__(94); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var IfObservable = (function (_super) { - __extends(IfObservable, _super); - function IfObservable(condition, thenSource, elseSource) { - _super.call(this); - this.condition = condition; - this.thenSource = thenSource; - this.elseSource = elseSource; - } - IfObservable.create = function (condition, thenSource, elseSource) { - return new IfObservable(condition, thenSource, elseSource); - }; - IfObservable.prototype._subscribe = function (subscriber) { - var _a = this, condition = _a.condition, thenSource = _a.thenSource, elseSource = _a.elseSource; - return new IfSubscriber(subscriber, condition, thenSource, elseSource); - }; - return IfObservable; - }(Observable_1.Observable)); - exports.IfObservable = IfObservable; - var IfSubscriber = (function (_super) { - __extends(IfSubscriber, _super); - function IfSubscriber(destination, condition, thenSource, elseSource) { - _super.call(this, destination); - this.condition = condition; - this.thenSource = thenSource; - this.elseSource = elseSource; - this.tryIf(); - } - IfSubscriber.prototype.tryIf = function () { - var _a = this, condition = _a.condition, thenSource = _a.thenSource, elseSource = _a.elseSource; - var result; - try { - result = condition(); - var source = result ? thenSource : elseSource; - if (source) { - this.add(subscribeToResult_1.subscribeToResult(this, source)); - } - else { - this._complete(); - } - } - catch (err) { - this._error(err); - } - }; - return IfSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=IfObservable.js.map - -/***/ }, -/* 134 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var interval_1 = __webpack_require__(135); - Observable_1.Observable.interval = interval_1.interval; - //# sourceMappingURL=interval.js.map +var Observable_1 = __webpack_require__(0); +var fromPromise_1 = __webpack_require__(163); +Observable_1.Observable.fromPromise = fromPromise_1.fromPromise; +//# sourceMappingURL=fromPromise.js.map -/***/ }, -/* 135 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 163 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var IntervalObservable_1 = __webpack_require__(136); - exports.interval = IntervalObservable_1.IntervalObservable.create; - //# sourceMappingURL=interval.js.map +"use strict"; -/***/ }, -/* 136 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 isNumeric_1 = __webpack_require__(137); - var Observable_1 = __webpack_require__(64); - var async_1 = __webpack_require__(138); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var IntervalObservable = (function (_super) { - __extends(IntervalObservable, _super); - function IntervalObservable(period, scheduler) { - if (period === void 0) { period = 0; } - if (scheduler === void 0) { scheduler = async_1.async; } - _super.call(this); - this.period = period; - this.scheduler = scheduler; - if (!isNumeric_1.isNumeric(period) || period < 0) { - this.period = 0; - } - if (!scheduler || typeof scheduler.schedule !== 'function') { - this.scheduler = async_1.async; - } - } - /** - * Creates an Observable that emits sequential numbers every specified - * interval of time, on a specified IScheduler. - * - * Emits incremental numbers periodically in time. - * - * - * - * - * `interval` returns an Observable that emits an infinite sequence of - * ascending integers, with a constant interval of time of your choosing - * between those emissions. The first emission is not sent immediately, but - * only after the first period has passed. By default, this operator uses the - * `async` IScheduler to provide a notion of time, but you may pass any - * IScheduler to it. - * - * @example Emits ascending numbers, one every second (1000ms) - * var numbers = Rx.Observable.interval(1000); - * numbers.subscribe(x => console.log(x)); - * - * @see {@link timer} - * @see {@link delay} - * - * @param {number} [period=0] The interval size in milliseconds (by default) - * or the time unit determined by the scheduler's clock. - * @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling - * the emission of values, and providing a notion of "time". - * @return {Observable} An Observable that emits a sequential number each time - * interval. - * @static true - * @name interval - * @owner Observable - */ - IntervalObservable.create = function (period, scheduler) { - if (period === void 0) { period = 0; } - if (scheduler === void 0) { scheduler = async_1.async; } - return new IntervalObservable(period, scheduler); - }; - IntervalObservable.dispatch = function (state) { - var index = state.index, subscriber = state.subscriber, period = state.period; - subscriber.next(index); - if (subscriber.closed) { - return; - } - state.index += 1; - this.schedule(state, period); - }; - IntervalObservable.prototype._subscribe = function (subscriber) { - var index = 0; - var period = this.period; - var scheduler = this.scheduler; - subscriber.add(scheduler.schedule(IntervalObservable.dispatch, period, { - index: index, subscriber: subscriber, period: period - })); - }; - return IntervalObservable; - }(Observable_1.Observable)); - exports.IntervalObservable = IntervalObservable; - //# sourceMappingURL=IntervalObservable.js.map - -/***/ }, -/* 137 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var isArray_1 = __webpack_require__(70); - function isNumeric(val) { - // parseFloat NaNs numeric-cast false positives (null|true|false|"") - // ...but misinterprets leading-number strings, particularly hex literals ("0x...") - // subtraction forces infinities to NaN - // adding 1 corrects loss of precision from parseFloat (#15100) - return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0; - } - exports.isNumeric = isNumeric; - ; - //# sourceMappingURL=isNumeric.js.map +var PromiseObservable_1 = __webpack_require__(66); +exports.fromPromise = PromiseObservable_1.PromiseObservable.create; +//# sourceMappingURL=fromPromise.js.map -/***/ }, -/* 138 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var AsyncAction_1 = __webpack_require__(139); - var AsyncScheduler_1 = __webpack_require__(141); - /** - * - * Async Scheduler - * - * Schedule task as if you used setTimeout(task, duration) - * - * `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 Use async scheduler to delay task - * const task = () => console.log('it works!'); - * - * Rx.Scheduler.async.schedule(task, 2000); - * - * // After 2 seconds logs: - * // "it works!" - * - * - * @example Use async scheduler to repeat task in intervals - * 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 - */ - exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); - //# sourceMappingURL=async.js.map - -/***/ }, -/* 139 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 root_1 = __webpack_require__(65); - var Action_1 = __webpack_require__(140); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var AsyncAction = (function (_super) { - __extends(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, delay) { - if (delay === void 0) { delay = 0; } - if (this.closed) { - return this; - } - // Always replace the current state with the new state. - this.state = state; - // 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_1.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_1.root.clearInterval(id) && undefined || undefined; - }; - /** - * Immediately executes this action and the `work` it contains. - * @return {any} - */ - AsyncAction.prototype.execute = function (state, delay) { - if (this.closed) { - return new Error('executing a cancelled action'); - } - this.pending = false; - var error = this._execute(state, 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, delay) { - var errored = false; - var errorValue = undefined; - try { - this.work(state); - } - 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)); - exports.AsyncAction = AsyncAction; - //# sourceMappingURL=AsyncAction.js.map - -/***/ }, -/* 140 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscription_1 = __webpack_require__(69); - /** - * 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 extends Subscription { - * new (scheduler: Scheduler, work: (state?: T) => void); - * schedule(state?: T, delay: number = 0): Subscription; - * } - * ``` - * - * @class Action - */ - var Action = (function (_super) { - __extends(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, delay) { - if (delay === void 0) { delay = 0; } - return this; - }; - return Action; - }(Subscription_1.Subscription)); - exports.Action = Action; - //# sourceMappingURL=Action.js.map - -/***/ }, -/* 141 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Scheduler_1 = __webpack_require__(142); - var AsyncScheduler = (function (_super) { - __extends(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)); - exports.AsyncScheduler = AsyncScheduler; - //# sourceMappingURL=AsyncScheduler.js.map - -/***/ }, -/* 142 */ -/***/ function(module, exports) { - - "use strict"; - /** - * 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) { - if (delay === void 0) { delay = 0; } - return new this.SchedulerAction(this, work).schedule(state, delay); - }; - Scheduler.now = Date.now ? Date.now : function () { return +new Date(); }; - return Scheduler; - }()); - exports.Scheduler = Scheduler; - //# sourceMappingURL=Scheduler.js.map - -/***/ }, -/* 143 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 164 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var merge_1 = __webpack_require__(144); - Observable_1.Observable.merge = merge_1.merge; - //# sourceMappingURL=merge.js.map +"use strict"; -/***/ }, -/* 144 */ -/***/ function(module, exports, __webpack_require__) { +var Observable_1 = __webpack_require__(0); +var generate_1 = __webpack_require__(165); +Observable_1.Observable.generate = generate_1.generate; +//# sourceMappingURL=generate.js.map - "use strict"; - var merge_1 = __webpack_require__(145); - exports.merge = merge_1.mergeStatic; - //# sourceMappingURL=merge.js.map +/***/ }), +/* 165 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 145 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Observable_1 = __webpack_require__(64); - var ArrayObservable_1 = __webpack_require__(90); - var mergeAll_1 = __webpack_require__(103); - var isScheduler_1 = __webpack_require__(89); - /* tslint:enable:max-line-length */ - /** - * Creates an output Observable which concurrently emits all values from every - * given input Observable. - * - * Flattens multiple Observables together by blending - * their values into one Observable. - * - * - * - * `merge` subscribes to each given input Observable (either the source or an - * Observable given as argument), and simply forwards (without doing any - * transformation) all the values from all the input Observables to the output - * Observable. The output Observable only completes once all input Observables - * have completed. Any error delivered by an input Observable will be immediately - * emitted on the output Observable. - * - * @example Merge together two Observables: 1s interval and clicks - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var timer = Rx.Observable.interval(1000); - * var clicksOrTimer = clicks.merge(timer); - * clicksOrTimer.subscribe(x => console.log(x)); - * - * @example Merge together 3 Observables, but only 2 run concurrently - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var concurrent = 2; // the argument - * var merged = timer1.merge(timer2, timer3, concurrent); - * merged.subscribe(x => console.log(x)); - * - * @see {@link mergeAll} - * @see {@link mergeMap} - * @see {@link mergeMapTo} - * @see {@link mergeScan} - * - * @param {ObservableInput} other An input Observable to merge with the source - * Observable. More than one input Observables may be given as argument. - * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input - * Observables being subscribed to concurrently. - * @param {Scheduler} [scheduler=null] The IScheduler to use for managing - * concurrency of input Observables. - * @return {Observable} An Observable that emits items that are the result of - * every input Observable. - * @method merge - * @owner Observable - */ - function merge() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - return this.lift.call(mergeStatic.apply(void 0, [this].concat(observables))); - } - exports.merge = merge; - /* tslint:enable:max-line-length */ - /** - * Creates an output Observable which concurrently emits all values from every - * given input Observable. - * - * Flattens multiple Observables together by blending - * their values into one Observable. - * - * - * - * `merge` subscribes to each given input Observable (as arguments), and simply - * forwards (without doing any transformation) all the values from all the input - * Observables to the output Observable. The output Observable only completes - * once all input Observables have completed. Any error delivered by an input - * Observable will be immediately emitted on the output Observable. - * - * @example Merge together two Observables: 1s interval and clicks - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var timer = Rx.Observable.interval(1000); - * var clicksOrTimer = Rx.Observable.merge(clicks, timer); - * clicksOrTimer.subscribe(x => console.log(x)); - * - * // Results in the following: - * // timer will emit ascending values, one every second(1000ms) to console - * // clicks logs MouseEvents to console everytime the "document" is clicked - * // Since the two streams are merged you see these happening - * // as they occur. - * - * @example Merge together 3 Observables, but only 2 run concurrently - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var concurrent = 2; // the argument - * var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent); - * merged.subscribe(x => console.log(x)); - * - * // Results in the following: - * // - First timer1 and timer2 will run concurrently - * // - timer1 will emit a value every 1000ms for 10 iterations - * // - timer2 will emit a value every 2000ms for 6 iterations - * // - after timer1 hits it's max iteration, timer2 will - * // continue, and timer3 will start to run concurrently with timer2 - * // - when timer2 hits it's max iteration it terminates, and - * // timer3 will continue to emit a value every 500ms until it is complete - * - * @see {@link mergeAll} - * @see {@link mergeMap} - * @see {@link mergeMapTo} - * @see {@link mergeScan} - * - * @param {...ObservableInput} observables Input Observables to merge together. - * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input - * Observables being subscribed to concurrently. - * @param {Scheduler} [scheduler=null] The IScheduler to use for managing - * concurrency of input Observables. - * @return {Observable} an Observable that emits items that are the result of - * every input Observable. - * @static true - * @name merge - * @owner Observable - */ - function mergeStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var concurrent = Number.POSITIVE_INFINITY; - var scheduler = null; - var last = observables[observables.length - 1]; - if (isScheduler_1.isScheduler(last)) { - scheduler = observables.pop(); - if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') { - concurrent = observables.pop(); - } - } - else if (typeof last === 'number') { - concurrent = observables.pop(); - } - if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) { - return observables[0]; - } - return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(concurrent)); - } - exports.mergeStatic = mergeStatic; - //# sourceMappingURL=merge.js.map +"use strict"; -/***/ }, -/* 146 */ -/***/ function(module, exports, __webpack_require__) { +var GenerateObservable_1 = __webpack_require__(166); +exports.generate = GenerateObservable_1.GenerateObservable.create; +//# sourceMappingURL=generate.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var race_1 = __webpack_require__(147); - Observable_1.Observable.race = race_1.race; - //# sourceMappingURL=race.js.map +/***/ }), +/* 166 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var isScheduler_1 = __webpack_require__(14); +var selfSelector = function (value) { return value; }; +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var GenerateObservable = (function (_super) { + __extends(GenerateObservable, _super); + function GenerateObservable(initialState, condition, iterate, resultSelector, scheduler) { + _super.call(this); + this.initialState = initialState; + this.condition = condition; + this.iterate = iterate; + this.resultSelector = resultSelector; + this.scheduler = scheduler; + } + GenerateObservable.create = function (initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) { + if (arguments.length == 1) { + return new GenerateObservable(initialStateOrOptions.initialState, initialStateOrOptions.condition, initialStateOrOptions.iterate, initialStateOrOptions.resultSelector || selfSelector, initialStateOrOptions.scheduler); + } + if (resultSelectorOrObservable === undefined || isScheduler_1.isScheduler(resultSelectorOrObservable)) { + return new GenerateObservable(initialStateOrOptions, condition, iterate, selfSelector, resultSelectorOrObservable); + } + return new GenerateObservable(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler); + }; + GenerateObservable.prototype._subscribe = function (subscriber) { + var state = this.initialState; + if (this.scheduler) { + return this.scheduler.schedule(GenerateObservable.dispatch, 0, { + subscriber: subscriber, + iterate: this.iterate, + condition: this.condition, + resultSelector: this.resultSelector, + state: state }); + } + var _a = this, condition = _a.condition, resultSelector = _a.resultSelector, iterate = _a.iterate; + do { + if (condition) { + var conditionResult = void 0; + try { + conditionResult = condition(state); + } + catch (err) { + subscriber.error(err); + return; + } + if (!conditionResult) { + subscriber.complete(); + break; + } + } + var value = void 0; + try { + value = resultSelector(state); + } + catch (err) { + subscriber.error(err); + return; + } + subscriber.next(value); + if (subscriber.closed) { + break; + } + try { + state = iterate(state); + } + catch (err) { + subscriber.error(err); + return; + } + } while (true); + }; + GenerateObservable.dispatch = function (state) { + var subscriber = state.subscriber, condition = state.condition; + if (subscriber.closed) { + return; + } + if (state.needIterate) { + try { + state.state = state.iterate(state.state); + } + catch (err) { + subscriber.error(err); + return; + } + } + else { + state.needIterate = true; + } + if (condition) { + var conditionResult = void 0; + try { + conditionResult = condition(state.state); + } + catch (err) { + subscriber.error(err); + return; + } + if (!conditionResult) { + subscriber.complete(); + return; + } + if (subscriber.closed) { + return; + } + } + var value; + try { + value = state.resultSelector(state.state); + } + catch (err) { + subscriber.error(err); + return; + } + if (subscriber.closed) { + return; + } + subscriber.next(value); + if (subscriber.closed) { + return; + } + return this.schedule(state); + }; + return GenerateObservable; +}(Observable_1.Observable)); +exports.GenerateObservable = GenerateObservable; +//# sourceMappingURL=GenerateObservable.js.map + +/***/ }), +/* 167 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 147 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var race_1 = __webpack_require__(148); - exports.race = race_1.raceStatic; - //# sourceMappingURL=race.js.map +var Observable_1 = __webpack_require__(0); +var if_1 = __webpack_require__(168); +Observable_1.Observable.if = if_1._if; +//# sourceMappingURL=if.js.map -/***/ }, -/* 148 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 isArray_1 = __webpack_require__(70); - var ArrayObservable_1 = __webpack_require__(90); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /* tslint:enable:max-line-length */ - /** - * Returns an Observable that mirrors the first source Observable to emit an item - * from the combination of this Observable and supplied Observables. - * @param {...Observables} ...observables Sources used to race for which Observable emits first. - * @return {Observable} An Observable that mirrors the output of the first Observable to emit an item. - * @method race - * @owner Observable - */ - function race() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - // if the only argument is an array, it was most likely called with - // `pair([obs1, obs2, ...])` - if (observables.length === 1 && isArray_1.isArray(observables[0])) { - observables = observables[0]; - } - return this.lift.call(raceStatic.apply(void 0, [this].concat(observables))); - } - exports.race = race; - function raceStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - // if the only argument is an array, it was most likely called with - // `race([obs1, obs2, ...])` - if (observables.length === 1) { - if (isArray_1.isArray(observables[0])) { - observables = observables[0]; - } - else { - return observables[0]; - } - } - return new ArrayObservable_1.ArrayObservable(observables).lift(new RaceOperator()); - } - exports.raceStatic = raceStatic; - var RaceOperator = (function () { - function RaceOperator() { - } - RaceOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new RaceSubscriber(subscriber)); - }; - return RaceOperator; - }()); - exports.RaceOperator = RaceOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var RaceSubscriber = (function (_super) { - __extends(RaceSubscriber, _super); - function RaceSubscriber(destination) { - _super.call(this, destination); - this.hasFirst = false; - this.observables = []; - this.subscriptions = []; - } - RaceSubscriber.prototype._next = function (observable) { - this.observables.push(observable); - }; - RaceSubscriber.prototype._complete = function () { - var observables = this.observables; - var len = observables.length; - if (len === 0) { - this.destination.complete(); - } - else { - for (var i = 0; i < len && !this.hasFirst; i++) { - var observable = observables[i]; - var subscription = subscribeToResult_1.subscribeToResult(this, observable, observable, i); - if (this.subscriptions) { - this.subscriptions.push(subscription); - } - this.add(subscription); - } - this.observables = null; - } - }; - RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - if (!this.hasFirst) { - this.hasFirst = true; - for (var i = 0; i < this.subscriptions.length; i++) { - if (i !== outerIndex) { - var subscription = this.subscriptions[i]; - subscription.unsubscribe(); - this.remove(subscription); - } - } - this.subscriptions = null; - } - this.destination.next(innerValue); - }; - return RaceSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.RaceSubscriber = RaceSubscriber; - //# sourceMappingURL=race.js.map - -/***/ }, -/* 149 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var never_1 = __webpack_require__(150); - Observable_1.Observable.never = never_1.never; - //# sourceMappingURL=never.js.map +"use strict"; -/***/ }, -/* 150 */ -/***/ function(module, exports, __webpack_require__) { +var IfObservable_1 = __webpack_require__(169); +exports._if = IfObservable_1.IfObservable.create; +//# sourceMappingURL=if.js.map - "use strict"; - var NeverObservable_1 = __webpack_require__(151); - exports.never = NeverObservable_1.NeverObservable.create; - //# sourceMappingURL=never.js.map +/***/ }), +/* 169 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var subscribeToResult_1 = __webpack_require__(3); +var OuterSubscriber_1 = __webpack_require__(2); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var IfObservable = (function (_super) { + __extends(IfObservable, _super); + function IfObservable(condition, thenSource, elseSource) { + _super.call(this); + this.condition = condition; + this.thenSource = thenSource; + this.elseSource = elseSource; + } + IfObservable.create = function (condition, thenSource, elseSource) { + return new IfObservable(condition, thenSource, elseSource); + }; + IfObservable.prototype._subscribe = function (subscriber) { + var _a = this, condition = _a.condition, thenSource = _a.thenSource, elseSource = _a.elseSource; + return new IfSubscriber(subscriber, condition, thenSource, elseSource); + }; + return IfObservable; +}(Observable_1.Observable)); +exports.IfObservable = IfObservable; +var IfSubscriber = (function (_super) { + __extends(IfSubscriber, _super); + function IfSubscriber(destination, condition, thenSource, elseSource) { + _super.call(this, destination); + this.condition = condition; + this.thenSource = thenSource; + this.elseSource = elseSource; + this.tryIf(); + } + IfSubscriber.prototype.tryIf = function () { + var _a = this, condition = _a.condition, thenSource = _a.thenSource, elseSource = _a.elseSource; + var result; + try { + result = condition(); + var source = result ? thenSource : elseSource; + if (source) { + this.add(subscribeToResult_1.subscribeToResult(this, source)); + } + else { + this._complete(); + } + } + catch (err) { + this._error(err); + } + }; + return IfSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=IfObservable.js.map + +/***/ }), +/* 170 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 151 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var noop_1 = __webpack_require__(152); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var NeverObservable = (function (_super) { - __extends(NeverObservable, _super); - function NeverObservable() { - _super.call(this); - } - /** - * Creates an Observable that emits no items to the Observer. - * - * An Observable that never emits anything. - * - * - * - * This static operator is useful for creating a simple Observable that emits - * neither values nor errors nor the completion notification. It can be used - * for testing purposes or for composing with other Observables. Please note - * that by never emitting a complete notification, this Observable keeps the - * subscription from being disposed automatically. Subscriptions need to be - * manually disposed. - * - * @example Emit the number 7, then never emit anything else (not even complete). - * function info() { - * console.log('Will not be called'); - * } - * var result = Rx.Observable.never().startWith(7); - * result.subscribe(x => console.log(x), info, info); - * - * @see {@link create} - * @see {@link empty} - * @see {@link of} - * @see {@link throw} - * - * @return {Observable} A "never" Observable: never emits anything. - * @static true - * @name never - * @owner Observable - */ - NeverObservable.create = function () { - return new NeverObservable(); - }; - NeverObservable.prototype._subscribe = function (subscriber) { - noop_1.noop(); - }; - return NeverObservable; - }(Observable_1.Observable)); - exports.NeverObservable = NeverObservable; - //# sourceMappingURL=NeverObservable.js.map - -/***/ }, -/* 152 */ -/***/ function(module, exports) { +"use strict"; - "use strict"; - /* tslint:disable:no-empty */ - function noop() { } - exports.noop = noop; - //# sourceMappingURL=noop.js.map +var Observable_1 = __webpack_require__(0); +var interval_1 = __webpack_require__(171); +Observable_1.Observable.interval = interval_1.interval; +//# sourceMappingURL=interval.js.map -/***/ }, -/* 153 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 171 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var of_1 = __webpack_require__(154); - Observable_1.Observable.of = of_1.of; - //# sourceMappingURL=of.js.map +"use strict"; -/***/ }, -/* 154 */ -/***/ function(module, exports, __webpack_require__) { +var IntervalObservable_1 = __webpack_require__(172); +exports.interval = IntervalObservable_1.IntervalObservable.create; +//# sourceMappingURL=interval.js.map - "use strict"; - var ArrayObservable_1 = __webpack_require__(90); - exports.of = ArrayObservable_1.ArrayObservable.of; - //# sourceMappingURL=of.js.map +/***/ }), +/* 172 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 isNumeric_1 = __webpack_require__(34); +var Observable_1 = __webpack_require__(0); +var async_1 = __webpack_require__(9); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var IntervalObservable = (function (_super) { + __extends(IntervalObservable, _super); + function IntervalObservable(period, scheduler) { + if (period === void 0) { period = 0; } + if (scheduler === void 0) { scheduler = async_1.async; } + _super.call(this); + this.period = period; + this.scheduler = scheduler; + if (!isNumeric_1.isNumeric(period) || period < 0) { + this.period = 0; + } + if (!scheduler || typeof scheduler.schedule !== 'function') { + this.scheduler = async_1.async; + } + } + /** + * Creates an Observable that emits sequential numbers every specified + * interval of time, on a specified IScheduler. + * + * Emits incremental numbers periodically in time. + * + * + * + * + * `interval` returns an Observable that emits an infinite sequence of + * ascending integers, with a constant interval of time of your choosing + * between those emissions. The first emission is not sent immediately, but + * only after the first period has passed. By default, this operator uses the + * `async` IScheduler to provide a notion of time, but you may pass any + * IScheduler to it. + * + * @example Emits ascending numbers, one every second (1000ms) + * var numbers = Rx.Observable.interval(1000); + * numbers.subscribe(x => console.log(x)); + * + * @see {@link timer} + * @see {@link delay} + * + * @param {number} [period=0] The interval size in milliseconds (by default) + * or the time unit determined by the scheduler's clock. + * @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling + * the emission of values, and providing a notion of "time". + * @return {Observable} An Observable that emits a sequential number each time + * interval. + * @static true + * @name interval + * @owner Observable + */ + IntervalObservable.create = function (period, scheduler) { + if (period === void 0) { period = 0; } + if (scheduler === void 0) { scheduler = async_1.async; } + return new IntervalObservable(period, scheduler); + }; + IntervalObservable.dispatch = function (state) { + var index = state.index, subscriber = state.subscriber, period = state.period; + subscriber.next(index); + if (subscriber.closed) { + return; + } + state.index += 1; + this.schedule(state, period); + }; + IntervalObservable.prototype._subscribe = function (subscriber) { + var index = 0; + var period = this.period; + var scheduler = this.scheduler; + subscriber.add(scheduler.schedule(IntervalObservable.dispatch, period, { + index: index, subscriber: subscriber, period: period + })); + }; + return IntervalObservable; +}(Observable_1.Observable)); +exports.IntervalObservable = IntervalObservable; +//# sourceMappingURL=IntervalObservable.js.map + +/***/ }), +/* 173 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscription_1 = __webpack_require__(4); +/** + * 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 extends Subscription { + * new (scheduler: Scheduler, work: (state?: T) => void); + * schedule(state?: T, delay: number = 0): Subscription; + * } + * ``` + * + * @class Action + */ +var Action = (function (_super) { + __extends(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, delay) { + if (delay === void 0) { delay = 0; } + return this; + }; + return Action; +}(Subscription_1.Subscription)); +exports.Action = Action; +//# sourceMappingURL=Action.js.map + +/***/ }), +/* 174 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +/** + * 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) { + if (delay === void 0) { delay = 0; } + return new this.SchedulerAction(this, work).schedule(state, delay); + }; + Scheduler.now = Date.now ? Date.now : function () { return +new Date(); }; + return Scheduler; +}()); +exports.Scheduler = Scheduler; +//# sourceMappingURL=Scheduler.js.map + +/***/ }), +/* 175 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 155 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var onErrorResumeNext_1 = __webpack_require__(156); - Observable_1.Observable.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext; - //# sourceMappingURL=onErrorResumeNext.js.map +var Observable_1 = __webpack_require__(0); +var merge_1 = __webpack_require__(176); +Observable_1.Observable.merge = merge_1.merge; +//# sourceMappingURL=merge.js.map -/***/ }, -/* 156 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 176 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var onErrorResumeNext_1 = __webpack_require__(157); - exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNextStatic; - //# sourceMappingURL=onErrorResumeNext.js.map +"use strict"; -/***/ }, -/* 157 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 FromObservable_1 = __webpack_require__(114); - var isArray_1 = __webpack_require__(70); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /* tslint:enable:max-line-length */ - /** - * When any of the provided Observable emits an complete or error notification, it immediately subscribes to the next one - * that was passed. - * - * Execute series of Observables no matter what, even if it means swallowing errors. - * - * - * - * `onErrorResumeNext` is an operator that accepts a series of Observables, provided either directly as - * arguments or as an array. If no single Observable is provided, returned Observable will simply behave the same - * as the source. - * - * `onErrorResumeNext` returns an Observable that starts by subscribing and re-emitting values from the source Observable. - * When its stream of values ends - no matter if Observable completed or emitted an error - `onErrorResumeNext` - * will subscribe to the first Observable that was passed as an argument to the method. It will start re-emitting - * its values as well and - again - when that stream ends, `onErrorResumeNext` will proceed to subscribing yet another - * Observable in provided series, no matter if previous Observable completed or ended with an error. This will - * be happening until there is no more Observables left in the series, at which point returned Observable will - * complete - even if the last subscribed stream ended with an error. - * - * `onErrorResumeNext` can be therefore thought of as version of {@link concat} operator, which is more permissive - * when it comes to the errors emitted by its input Observables. While `concat` subscribes to the next Observable - * in series only if previous one successfully completed, `onErrorResumeNext` subscribes even if it ended with - * an error. - * - * Note that you do not get any access to errors emitted by the Observables. In particular do not - * expect these errors to appear in error callback passed to {@link subscribe}. If you want to take - * specific actions based on what error was emitted by an Observable, you should try out {@link catch} instead. - * - * - * @example Subscribe to the next Observable after map fails - * Rx.Observable.of(1, 2, 3, 0) - * .map(x => { - * if (x === 0) { throw Error(); } - return 10 / x; - * }) - * .onErrorResumeNext(Rx.Observable.of(1, 2, 3)) - * .subscribe( - * val => console.log(val), - * err => console.log(err), // Will never be called. - * () => console.log('that\'s it!') - * ); - * - * // Logs: - * // 10 - * // 5 - * // 3.3333333333333335 - * // 1 - * // 2 - * // 3 - * // "that's it!" - * - * @see {@link concat} - * @see {@link catch} - * - * @param {...ObservableInput} observables Observables passed either directly or as an array. - * @return {Observable} An Observable that emits values from source Observable, but - if it errors - subscribes - * to the next passed Observable and so on, until it completes or runs out of Observables. - * @method onErrorResumeNext - * @owner Observable - */ - function onErrorResumeNext() { - var nextSources = []; - for (var _i = 0; _i < arguments.length; _i++) { - nextSources[_i - 0] = arguments[_i]; - } - if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) { - nextSources = nextSources[0]; - } - return this.lift(new OnErrorResumeNextOperator(nextSources)); - } - exports.onErrorResumeNext = onErrorResumeNext; - /* tslint:enable:max-line-length */ - function onErrorResumeNextStatic() { - var nextSources = []; - for (var _i = 0; _i < arguments.length; _i++) { - nextSources[_i - 0] = arguments[_i]; - } - var source = null; - if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) { - nextSources = nextSources[0]; - } - source = nextSources.shift(); - return new FromObservable_1.FromObservable(source, null).lift(new OnErrorResumeNextOperator(nextSources)); - } - exports.onErrorResumeNextStatic = onErrorResumeNextStatic; - var OnErrorResumeNextOperator = (function () { - function OnErrorResumeNextOperator(nextSources) { - this.nextSources = nextSources; - } - OnErrorResumeNextOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources)); - }; - return OnErrorResumeNextOperator; - }()); - var OnErrorResumeNextSubscriber = (function (_super) { - __extends(OnErrorResumeNextSubscriber, _super); - function OnErrorResumeNextSubscriber(destination, nextSources) { - _super.call(this, destination); - this.destination = destination; - this.nextSources = nextSources; - } - OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) { - this.subscribeToNextSource(); - }; - OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) { - this.subscribeToNextSource(); - }; - OnErrorResumeNextSubscriber.prototype._error = function (err) { - this.subscribeToNextSource(); - }; - OnErrorResumeNextSubscriber.prototype._complete = function () { - this.subscribeToNextSource(); - }; - OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () { - var next = this.nextSources.shift(); - if (next) { - this.add(subscribeToResult_1.subscribeToResult(this, next)); - } - else { - this.destination.complete(); - } - }; - return OnErrorResumeNextSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=onErrorResumeNext.js.map - -/***/ }, -/* 158 */ -/***/ function(module, exports, __webpack_require__) { +var merge_1 = __webpack_require__(67); +exports.merge = merge_1.mergeStatic; +//# sourceMappingURL=merge.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var pairs_1 = __webpack_require__(159); - Observable_1.Observable.pairs = pairs_1.pairs; - //# sourceMappingURL=pairs.js.map +/***/ }), +/* 177 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 159 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var PairsObservable_1 = __webpack_require__(160); - exports.pairs = PairsObservable_1.PairsObservable.create; - //# sourceMappingURL=pairs.js.map +var Observable_1 = __webpack_require__(0); +var race_1 = __webpack_require__(178); +Observable_1.Observable.race = race_1.race; +//# sourceMappingURL=race.js.map -/***/ }, -/* 160 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - function dispatch(state) { - var obj = state.obj, keys = state.keys, length = state.length, index = state.index, subscriber = state.subscriber; - if (index === length) { - subscriber.complete(); - return; - } - var key = keys[index]; - subscriber.next([key, obj[key]]); - state.index = index + 1; - this.schedule(state); - } - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var PairsObservable = (function (_super) { - __extends(PairsObservable, _super); - function PairsObservable(obj, scheduler) { - _super.call(this); - this.obj = obj; - this.scheduler = scheduler; - this.keys = Object.keys(obj); - } - /** - * Convert an object into an observable sequence of [key, value] pairs - * using an optional IScheduler to enumerate the object. - * - * @example Converts a javascript object to an Observable - * var obj = { - * foo: 42, - * bar: 56, - * baz: 78 - * }; - * - * var source = Rx.Observable.pairs(obj); - * - * var subscription = source.subscribe( - * function (x) { - * console.log('Next: %s', x); - * }, - * function (err) { - * console.log('Error: %s', err); - * }, - * function () { - * console.log('Completed'); - * }); - * - * @param {Object} obj The object to inspect and turn into an - * Observable sequence. - * @param {Scheduler} [scheduler] An optional IScheduler to run the - * enumeration of the input sequence on. - * @returns {(Observable>)} An observable sequence of - * [key, value] pairs from the object. - */ - PairsObservable.create = function (obj, scheduler) { - return new PairsObservable(obj, scheduler); - }; - PairsObservable.prototype._subscribe = function (subscriber) { - var _a = this, keys = _a.keys, scheduler = _a.scheduler; - var length = keys.length; - if (scheduler) { - return scheduler.schedule(dispatch, 0, { - obj: this.obj, keys: keys, length: length, index: 0, subscriber: subscriber - }); - } - else { - for (var idx = 0; idx < length; idx++) { - var key = keys[idx]; - subscriber.next([key, this.obj[key]]); - } - subscriber.complete(); - } - }; - return PairsObservable; - }(Observable_1.Observable)); - exports.PairsObservable = PairsObservable; - //# sourceMappingURL=PairsObservable.js.map - -/***/ }, -/* 161 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 178 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var range_1 = __webpack_require__(162); - Observable_1.Observable.range = range_1.range; - //# sourceMappingURL=range.js.map +"use strict"; -/***/ }, -/* 162 */ -/***/ function(module, exports, __webpack_require__) { +var race_1 = __webpack_require__(68); +exports.race = race_1.raceStatic; +//# sourceMappingURL=race.js.map - "use strict"; - var RangeObservable_1 = __webpack_require__(163); - exports.range = RangeObservable_1.RangeObservable.create; - //# sourceMappingURL=range.js.map +/***/ }), +/* 179 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 163 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var RangeObservable = (function (_super) { - __extends(RangeObservable, _super); - function RangeObservable(start, count, scheduler) { - _super.call(this); - this.start = start; - this._count = count; - this.scheduler = scheduler; - } - /** - * Creates an Observable that emits a sequence of numbers within a specified - * range. - * - * Emits a sequence of numbers in a range. - * - * - * - * `range` operator emits a range of sequential integers, in order, where you - * select the `start` of the range and its `length`. By default, uses no - * IScheduler and just delivers the notifications synchronously, but may use - * an optional IScheduler to regulate those deliveries. - * - * @example Emits the numbers 1 to 10 - * var numbers = Rx.Observable.range(1, 10); - * numbers.subscribe(x => console.log(x)); - * - * @see {@link timer} - * @see {@link interval} - * - * @param {number} [start=0] The value of the first integer in the sequence. - * @param {number} [count=0] The number of sequential integers to generate. - * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling - * the emissions of the notifications. - * @return {Observable} An Observable of numbers that emits a finite range of - * sequential integers. - * @static true - * @name range - * @owner Observable - */ - RangeObservable.create = function (start, count, scheduler) { - if (start === void 0) { start = 0; } - if (count === void 0) { count = 0; } - return new RangeObservable(start, count, scheduler); - }; - RangeObservable.dispatch = function (state) { - var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber; - if (index >= count) { - subscriber.complete(); - return; - } - subscriber.next(start); - if (subscriber.closed) { - return; - } - state.index = index + 1; - state.start = start + 1; - this.schedule(state); - }; - RangeObservable.prototype._subscribe = function (subscriber) { - var index = 0; - var start = this.start; - var count = this._count; - var scheduler = this.scheduler; - if (scheduler) { - return scheduler.schedule(RangeObservable.dispatch, 0, { - index: index, count: count, start: start, subscriber: subscriber - }); - } - else { - do { - if (index++ >= count) { - subscriber.complete(); - break; - } - subscriber.next(start++); - if (subscriber.closed) { - break; - } - } while (true); - } - }; - return RangeObservable; - }(Observable_1.Observable)); - exports.RangeObservable = RangeObservable; - //# sourceMappingURL=RangeObservable.js.map - -/***/ }, -/* 164 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var using_1 = __webpack_require__(165); - Observable_1.Observable.using = using_1.using; - //# sourceMappingURL=using.js.map +var Observable_1 = __webpack_require__(0); +var never_1 = __webpack_require__(180); +Observable_1.Observable.never = never_1.never; +//# sourceMappingURL=never.js.map -/***/ }, -/* 165 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 180 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var UsingObservable_1 = __webpack_require__(166); - exports.using = UsingObservable_1.UsingObservable.create; - //# sourceMappingURL=using.js.map +"use strict"; -/***/ }, -/* 166 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var subscribeToResult_1 = __webpack_require__(95); - var OuterSubscriber_1 = __webpack_require__(94); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var UsingObservable = (function (_super) { - __extends(UsingObservable, _super); - function UsingObservable(resourceFactory, observableFactory) { - _super.call(this); - this.resourceFactory = resourceFactory; - this.observableFactory = observableFactory; - } - UsingObservable.create = function (resourceFactory, observableFactory) { - return new UsingObservable(resourceFactory, observableFactory); - }; - UsingObservable.prototype._subscribe = function (subscriber) { - var _a = this, resourceFactory = _a.resourceFactory, observableFactory = _a.observableFactory; - var resource; - try { - resource = resourceFactory(); - return new UsingSubscriber(subscriber, resource, observableFactory); - } - catch (err) { - subscriber.error(err); - } - }; - return UsingObservable; - }(Observable_1.Observable)); - exports.UsingObservable = UsingObservable; - var UsingSubscriber = (function (_super) { - __extends(UsingSubscriber, _super); - function UsingSubscriber(destination, resource, observableFactory) { - _super.call(this, destination); - this.resource = resource; - this.observableFactory = observableFactory; - destination.add(resource); - this.tryUse(); - } - UsingSubscriber.prototype.tryUse = function () { - try { - var source = this.observableFactory.call(this, this.resource); - if (source) { - this.add(subscribeToResult_1.subscribeToResult(this, source)); - } - } - catch (err) { - this._error(err); - } - }; - return UsingSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=UsingObservable.js.map - -/***/ }, -/* 167 */ -/***/ function(module, exports, __webpack_require__) { +var NeverObservable_1 = __webpack_require__(181); +exports.never = NeverObservable_1.NeverObservable.create; +//# sourceMappingURL=never.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var throw_1 = __webpack_require__(168); - Observable_1.Observable.throw = throw_1._throw; - //# sourceMappingURL=throw.js.map +/***/ }), +/* 181 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var noop_1 = __webpack_require__(69); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var NeverObservable = (function (_super) { + __extends(NeverObservable, _super); + function NeverObservable() { + _super.call(this); + } + /** + * Creates an Observable that emits no items to the Observer. + * + * An Observable that never emits anything. + * + * + * + * This static operator is useful for creating a simple Observable that emits + * neither values nor errors nor the completion notification. It can be used + * for testing purposes or for composing with other Observables. Please note + * that by never emitting a complete notification, this Observable keeps the + * subscription from being disposed automatically. Subscriptions need to be + * manually disposed. + * + * @example Emit the number 7, then never emit anything else (not even complete). + * function info() { + * console.log('Will not be called'); + * } + * var result = Rx.Observable.never().startWith(7); + * result.subscribe(x => console.log(x), info, info); + * + * @see {@link create} + * @see {@link empty} + * @see {@link of} + * @see {@link throw} + * + * @return {Observable} A "never" Observable: never emits anything. + * @static true + * @name never + * @owner Observable + */ + NeverObservable.create = function () { + return new NeverObservable(); + }; + NeverObservable.prototype._subscribe = function (subscriber) { + noop_1.noop(); + }; + return NeverObservable; +}(Observable_1.Observable)); +exports.NeverObservable = NeverObservable; +//# sourceMappingURL=NeverObservable.js.map + +/***/ }), +/* 182 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 168 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var ErrorObservable_1 = __webpack_require__(169); - exports._throw = ErrorObservable_1.ErrorObservable.create; - //# sourceMappingURL=throw.js.map +var Observable_1 = __webpack_require__(0); +var of_1 = __webpack_require__(183); +Observable_1.Observable.of = of_1.of; +//# sourceMappingURL=of.js.map -/***/ }, -/* 169 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var ErrorObservable = (function (_super) { - __extends(ErrorObservable, _super); - function ErrorObservable(error, scheduler) { - _super.call(this); - this.error = error; - this.scheduler = scheduler; - } - /** - * Creates an Observable that emits no items to the Observer and immediately - * emits an error notification. - * - * Just emits 'error', and nothing else. - * - * - * - * - * This static operator is useful for creating a simple Observable that only - * emits the error notification. It can be used for composing with other - * Observables, such as in a {@link mergeMap}. - * - * @example Emit the number 7, then emit an error. - * var result = Rx.Observable.throw(new Error('oops!')).startWith(7); - * result.subscribe(x => console.log(x), e => console.error(e)); - * - * @example Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for 13 - * var interval = Rx.Observable.interval(1000); - * var result = interval.mergeMap(x => - * x === 13 ? - * Rx.Observable.throw('Thirteens are bad') : - * Rx.Observable.of('a', 'b', 'c') - * ); - * result.subscribe(x => console.log(x), e => console.error(e)); - * - * @see {@link create} - * @see {@link empty} - * @see {@link never} - * @see {@link of} - * - * @param {any} error The particular Error to pass to the error notification. - * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling - * the emission of the error notification. - * @return {Observable} An error Observable: emits only the error notification - * using the given error argument. - * @static true - * @name throw - * @owner Observable - */ - ErrorObservable.create = function (error, scheduler) { - return new ErrorObservable(error, scheduler); - }; - ErrorObservable.dispatch = function (arg) { - var error = arg.error, subscriber = arg.subscriber; - subscriber.error(error); - }; - ErrorObservable.prototype._subscribe = function (subscriber) { - var error = this.error; - var scheduler = this.scheduler; - subscriber.syncErrorThrowable = true; - if (scheduler) { - return scheduler.schedule(ErrorObservable.dispatch, 0, { - error: error, subscriber: subscriber - }); - } - else { - subscriber.error(error); - } - }; - return ErrorObservable; - }(Observable_1.Observable)); - exports.ErrorObservable = ErrorObservable; - //# sourceMappingURL=ErrorObservable.js.map - -/***/ }, -/* 170 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 183 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var timer_1 = __webpack_require__(171); - Observable_1.Observable.timer = timer_1.timer; - //# sourceMappingURL=timer.js.map +"use strict"; -/***/ }, -/* 171 */ -/***/ function(module, exports, __webpack_require__) { +var ArrayObservable_1 = __webpack_require__(15); +exports.of = ArrayObservable_1.ArrayObservable.of; +//# sourceMappingURL=of.js.map - "use strict"; - var TimerObservable_1 = __webpack_require__(172); - exports.timer = TimerObservable_1.TimerObservable.create; - //# sourceMappingURL=timer.js.map +/***/ }), +/* 184 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 172 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 isNumeric_1 = __webpack_require__(137); - var Observable_1 = __webpack_require__(64); - var async_1 = __webpack_require__(138); - var isScheduler_1 = __webpack_require__(89); - var isDate_1 = __webpack_require__(173); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var TimerObservable = (function (_super) { - __extends(TimerObservable, _super); - function TimerObservable(dueTime, period, scheduler) { - if (dueTime === void 0) { dueTime = 0; } - _super.call(this); - this.period = -1; - this.dueTime = 0; - if (isNumeric_1.isNumeric(period)) { - this.period = Number(period) < 1 && 1 || Number(period); - } - else if (isScheduler_1.isScheduler(period)) { - scheduler = period; - } - if (!isScheduler_1.isScheduler(scheduler)) { - scheduler = async_1.async; - } - this.scheduler = scheduler; - this.dueTime = isDate_1.isDate(dueTime) ? - (+dueTime - this.scheduler.now()) : - dueTime; - } - /** - * Creates an Observable that starts emitting after an `initialDelay` and - * emits ever increasing numbers after each `period` of time thereafter. - * - * Its like {@link interval}, but you can specify when - * should the emissions start. - * - * - * - * `timer` returns an Observable that emits an infinite sequence of ascending - * integers, with a constant interval of time, `period` of your choosing - * between those emissions. The first emission happens after the specified - * `initialDelay`. The initial delay may be a {@link Date}. By default, this - * operator uses the `async` IScheduler to provide a notion of time, but you - * may pass any IScheduler to it. If `period` is not specified, the output - * Observable emits only one value, `0`. Otherwise, it emits an infinite - * sequence. - * - * @example Emits ascending numbers, one every second (1000ms), starting after 3 seconds - * var numbers = Rx.Observable.timer(3000, 1000); - * numbers.subscribe(x => console.log(x)); - * - * @example Emits one number after five seconds - * var numbers = Rx.Observable.timer(5000); - * numbers.subscribe(x => console.log(x)); - * - * @see {@link interval} - * @see {@link delay} - * - * @param {number|Date} initialDelay The initial delay time to wait before - * emitting the first value of `0`. - * @param {number} [period] The period of time between emissions of the - * subsequent numbers. - * @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling - * the emission of values, and providing a notion of "time". - * @return {Observable} An Observable that emits a `0` after the - * `initialDelay` and ever increasing numbers after each `period` of time - * thereafter. - * @static true - * @name timer - * @owner Observable - */ - TimerObservable.create = function (initialDelay, period, scheduler) { - if (initialDelay === void 0) { initialDelay = 0; } - return new TimerObservable(initialDelay, period, scheduler); - }; - TimerObservable.dispatch = function (state) { - var index = state.index, period = state.period, subscriber = state.subscriber; - var action = this; - subscriber.next(index); - if (subscriber.closed) { - return; - } - else if (period === -1) { - return subscriber.complete(); - } - state.index = index + 1; - action.schedule(state, period); - }; - TimerObservable.prototype._subscribe = function (subscriber) { - var index = 0; - var _a = this, period = _a.period, dueTime = _a.dueTime, scheduler = _a.scheduler; - return scheduler.schedule(TimerObservable.dispatch, dueTime, { - index: index, period: period, subscriber: subscriber - }); - }; - return TimerObservable; - }(Observable_1.Observable)); - exports.TimerObservable = TimerObservable; - //# sourceMappingURL=TimerObservable.js.map - -/***/ }, -/* 173 */ -/***/ function(module, exports) { +"use strict"; - "use strict"; - function isDate(value) { - return value instanceof Date && !isNaN(+value); - } - exports.isDate = isDate; - //# sourceMappingURL=isDate.js.map +var Observable_1 = __webpack_require__(0); +var onErrorResumeNext_1 = __webpack_require__(185); +Observable_1.Observable.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext; +//# sourceMappingURL=onErrorResumeNext.js.map -/***/ }, -/* 174 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 185 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var zip_1 = __webpack_require__(175); - Observable_1.Observable.zip = zip_1.zip; - //# sourceMappingURL=zip.js.map +"use strict"; -/***/ }, -/* 175 */ -/***/ function(module, exports, __webpack_require__) { +var onErrorResumeNext_1 = __webpack_require__(70); +exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNextStatic; +//# sourceMappingURL=onErrorResumeNext.js.map - "use strict"; - var zip_1 = __webpack_require__(176); - exports.zip = zip_1.zipStatic; - //# sourceMappingURL=zip.js.map +/***/ }), +/* 186 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 176 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 ArrayObservable_1 = __webpack_require__(90); - var isArray_1 = __webpack_require__(70); - var Subscriber_1 = __webpack_require__(67); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - var iterator_1 = __webpack_require__(98); - /* tslint:enable:max-line-length */ - /** - * @param observables - * @return {Observable} - * @method zip - * @owner Observable - */ - function zipProto() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - return this.lift.call(zipStatic.apply(void 0, [this].concat(observables))); - } - exports.zipProto = zipProto; - /* tslint:enable:max-line-length */ - /** - * Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each - * of its input Observables. - * - * If the latest parameter is a function, this function is used to compute the created value from the input values. - * Otherwise, an array of the input values is returned. - * - * @example Combine age and name from different sources - * - * let age$ = Observable.of(27, 25, 29); - * let name$ = Observable.of('Foo', 'Bar', 'Beer'); - * let isDev$ = Observable.of(true, true, false); - * - * Observable - * .zip(age$, - * name$, - * isDev$, - * (age: number, name: string, isDev: boolean) => ({ age, name, isDev })) - * .subscribe(x => console.log(x)); - * - * // outputs - * // { age: 27, name: 'Foo', isDev: true } - * // { age: 25, name: 'Bar', isDev: true } - * // { age: 29, name: 'Beer', isDev: false } - * - * @param observables - * @return {Observable} - * @static true - * @name zip - * @owner Observable - */ - function zipStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var project = observables[observables.length - 1]; - if (typeof project === 'function') { - observables.pop(); - } - return new ArrayObservable_1.ArrayObservable(observables).lift(new ZipOperator(project)); - } - exports.zipStatic = zipStatic; - var ZipOperator = (function () { - function ZipOperator(project) { - this.project = project; - } - ZipOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ZipSubscriber(subscriber, this.project)); - }; - return ZipOperator; - }()); - exports.ZipOperator = ZipOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ZipSubscriber = (function (_super) { - __extends(ZipSubscriber, _super); - function ZipSubscriber(destination, project, values) { - if (values === void 0) { values = Object.create(null); } - _super.call(this, destination); - this.iterators = []; - this.active = 0; - this.project = (typeof project === 'function') ? project : null; - this.values = values; - } - ZipSubscriber.prototype._next = function (value) { - var iterators = this.iterators; - if (isArray_1.isArray(value)) { - iterators.push(new StaticArrayIterator(value)); - } - else if (typeof value[iterator_1.iterator] === 'function') { - iterators.push(new StaticIterator(value[iterator_1.iterator]())); - } - else { - iterators.push(new ZipBufferIterator(this.destination, this, value)); - } - }; - ZipSubscriber.prototype._complete = function () { - var iterators = this.iterators; - var len = iterators.length; - if (len === 0) { - this.destination.complete(); - return; - } - this.active = len; - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - if (iterator.stillUnsubscribed) { - this.add(iterator.subscribe(iterator, i)); - } - else { - this.active--; // not an observable - } - } - }; - ZipSubscriber.prototype.notifyInactive = function () { - this.active--; - if (this.active === 0) { - this.destination.complete(); - } - }; - ZipSubscriber.prototype.checkIterators = function () { - var iterators = this.iterators; - var len = iterators.length; - var destination = this.destination; - // abort if not all of them have values - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) { - return; - } - } - var shouldComplete = false; - var args = []; - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - var result = iterator.next(); - // check to see if it's completed now that you've gotten - // the next value. - if (iterator.hasCompleted()) { - shouldComplete = true; - } - if (result.done) { - destination.complete(); - return; - } - args.push(result.value); - } - if (this.project) { - this._tryProject(args); - } - else { - destination.next(args); - } - if (shouldComplete) { - destination.complete(); - } - }; - ZipSubscriber.prototype._tryProject = function (args) { - var result; - try { - result = this.project.apply(this, args); - } - catch (err) { - this.destination.error(err); - return; - } - this.destination.next(result); - }; - return ZipSubscriber; - }(Subscriber_1.Subscriber)); - exports.ZipSubscriber = ZipSubscriber; - var StaticIterator = (function () { - function StaticIterator(iterator) { - this.iterator = iterator; - this.nextResult = iterator.next(); - } - StaticIterator.prototype.hasValue = function () { - return true; - }; - StaticIterator.prototype.next = function () { - var result = this.nextResult; - this.nextResult = this.iterator.next(); - return result; - }; - StaticIterator.prototype.hasCompleted = function () { - var nextResult = this.nextResult; - return nextResult && nextResult.done; - }; - return StaticIterator; - }()); - var StaticArrayIterator = (function () { - function StaticArrayIterator(array) { - this.array = array; - this.index = 0; - this.length = 0; - this.length = array.length; - } - StaticArrayIterator.prototype[iterator_1.iterator] = function () { - return this; - }; - StaticArrayIterator.prototype.next = function (value) { - var i = this.index++; - var array = this.array; - return i < this.length ? { value: array[i], done: false } : { value: null, done: true }; - }; - StaticArrayIterator.prototype.hasValue = function () { - return this.array.length > this.index; - }; - StaticArrayIterator.prototype.hasCompleted = function () { - return this.array.length === this.index; - }; - return StaticArrayIterator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ZipBufferIterator = (function (_super) { - __extends(ZipBufferIterator, _super); - function ZipBufferIterator(destination, parent, observable) { - _super.call(this, destination); - this.parent = parent; - this.observable = observable; - this.stillUnsubscribed = true; - this.buffer = []; - this.isComplete = false; - } - ZipBufferIterator.prototype[iterator_1.iterator] = function () { - return this; - }; - // NOTE: there is actually a name collision here with Subscriber.next and Iterator.next - // this is legit because `next()` will never be called by a subscription in this case. - ZipBufferIterator.prototype.next = function () { - var buffer = this.buffer; - if (buffer.length === 0 && this.isComplete) { - return { value: null, done: true }; - } - else { - return { value: buffer.shift(), done: false }; - } - }; - ZipBufferIterator.prototype.hasValue = function () { - return this.buffer.length > 0; - }; - ZipBufferIterator.prototype.hasCompleted = function () { - return this.buffer.length === 0 && this.isComplete; - }; - ZipBufferIterator.prototype.notifyComplete = function () { - if (this.buffer.length > 0) { - this.isComplete = true; - this.parent.notifyInactive(); - } - else { - this.destination.complete(); - } - }; - ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.buffer.push(innerValue); - this.parent.checkIterators(); - }; - ZipBufferIterator.prototype.subscribe = function (value, index) { - return subscribeToResult_1.subscribeToResult(this, this.observable, this, index); - }; - return ZipBufferIterator; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=zip.js.map - -/***/ }, -/* 177 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var ajax_1 = __webpack_require__(178); - Observable_1.Observable.ajax = ajax_1.ajax; - //# sourceMappingURL=ajax.js.map +var Observable_1 = __webpack_require__(0); +var pairs_1 = __webpack_require__(187); +Observable_1.Observable.pairs = pairs_1.pairs; +//# sourceMappingURL=pairs.js.map -/***/ }, -/* 178 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 187 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var AjaxObservable_1 = __webpack_require__(179); - exports.ajax = AjaxObservable_1.AjaxObservable.create; - //# sourceMappingURL=ajax.js.map +"use strict"; -/***/ }, -/* 179 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 root_1 = __webpack_require__(65); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var Observable_1 = __webpack_require__(64); - var Subscriber_1 = __webpack_require__(67); - var map_1 = __webpack_require__(180); - function getCORSRequest() { - if (root_1.root.XMLHttpRequest) { - return new root_1.root.XMLHttpRequest(); - } - else if (!!root_1.root.XDomainRequest) { - return new root_1.root.XDomainRequest(); - } - else { - throw new Error('CORS is not supported by your browser'); - } - } - function getXMLHttpRequest() { - if (root_1.root.XMLHttpRequest) { - return new root_1.root.XMLHttpRequest(); - } - else { - var progId = void 0; - try { - var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; - for (var i = 0; i < 3; i++) { - try { - progId = progIds[i]; - if (new root_1.root.ActiveXObject(progId)) { - break; - } - } - catch (e) { - } - } - return new root_1.root.ActiveXObject(progId); - } - catch (e) { - throw new Error('XMLHttpRequest is not supported by your browser'); - } - } - } - function ajaxGet(url, headers) { - if (headers === void 0) { headers = null; } - return new AjaxObservable({ method: 'GET', url: url, headers: headers }); - } - exports.ajaxGet = ajaxGet; - ; - function ajaxPost(url, body, headers) { - return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers }); - } - exports.ajaxPost = ajaxPost; - ; - function ajaxDelete(url, headers) { - return new AjaxObservable({ method: 'DELETE', url: url, headers: headers }); - } - exports.ajaxDelete = ajaxDelete; - ; - function ajaxPut(url, body, headers) { - return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers }); - } - exports.ajaxPut = ajaxPut; - ; - function ajaxPatch(url, body, headers) { - return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers }); - } - exports.ajaxPatch = ajaxPatch; - ; - function ajaxGetJSON(url, headers) { - return new AjaxObservable({ method: 'GET', url: url, responseType: 'json', headers: headers }) - .lift(new map_1.MapOperator(function (x, index) { return x.response; }, null)); - } - exports.ajaxGetJSON = ajaxGetJSON; - ; - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var AjaxObservable = (function (_super) { - __extends(AjaxObservable, _super); - function AjaxObservable(urlOrRequest) { - _super.call(this); - var request = { - async: true, - createXHR: function () { - return this.crossDomain ? getCORSRequest.call(this) : getXMLHttpRequest(); - }, - crossDomain: false, - withCredentials: false, - headers: {}, - method: 'GET', - responseType: 'json', - timeout: 0 - }; - if (typeof urlOrRequest === 'string') { - request.url = urlOrRequest; - } - else { - for (var prop in urlOrRequest) { - if (urlOrRequest.hasOwnProperty(prop)) { - request[prop] = urlOrRequest[prop]; - } - } - } - this.request = request; - } - AjaxObservable.prototype._subscribe = function (subscriber) { - return new AjaxSubscriber(subscriber, this.request); - }; - /** - * Creates an observable for an Ajax request with either a request object with - * url, headers, etc or a string for a URL. - * - * @example - * source = Rx.Observable.ajax('/products'); - * source = Rx.Observable.ajax({ url: 'products', method: 'GET' }); - * - * @param {string|Object} request Can be one of the following: - * A string of the URL to make the Ajax call. - * An object with the following properties - * - url: URL of the request - * - body: The body of the request - * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE - * - async: Whether the request is async - * - headers: Optional headers - * - crossDomain: true if a cross domain request, else false - * - createXHR: a function to override if you need to use an alternate - * XMLHttpRequest implementation. - * - resultSelector: a function to use to alter the output value type of - * the Observable. Gets {@link AjaxResponse} as an argument. - * @return {Observable} An observable sequence containing the XMLHttpRequest. - * @static true - * @name ajax - * @owner Observable - */ - AjaxObservable.create = (function () { - var create = function (urlOrRequest) { - return new AjaxObservable(urlOrRequest); - }; - create.get = ajaxGet; - create.post = ajaxPost; - create.delete = ajaxDelete; - create.put = ajaxPut; - create.patch = ajaxPatch; - create.getJSON = ajaxGetJSON; - return create; - })(); - return AjaxObservable; - }(Observable_1.Observable)); - exports.AjaxObservable = AjaxObservable; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var AjaxSubscriber = (function (_super) { - __extends(AjaxSubscriber, _super); - function AjaxSubscriber(destination, request) { - _super.call(this, destination); - this.request = request; - this.done = false; - var headers = request.headers = request.headers || {}; - // force CORS if requested - if (!request.crossDomain && !headers['X-Requested-With']) { - headers['X-Requested-With'] = 'XMLHttpRequest'; - } - // ensure content type is set - if (!('Content-Type' in headers) && !(root_1.root.FormData && request.body instanceof root_1.root.FormData) && typeof request.body !== 'undefined') { - headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - } - // properly serialize body - request.body = this.serializeBody(request.body, request.headers['Content-Type']); - this.send(); - } - AjaxSubscriber.prototype.next = function (e) { - this.done = true; - var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination; - var response = new AjaxResponse(e, xhr, request); - destination.next(response); - }; - AjaxSubscriber.prototype.send = function () { - var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body; - var createXHR = request.createXHR; - var xhr = tryCatch_1.tryCatch(createXHR).call(request); - if (xhr === errorObject_1.errorObject) { - this.error(errorObject_1.errorObject.e); - } - else { - this.xhr = xhr; - // set up the events before open XHR - // https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest - // You need to add the event listeners before calling open() on the request. - // Otherwise the progress events will not fire. - this.setupEvents(xhr, request); - // open XHR - var result = void 0; - if (user) { - result = tryCatch_1.tryCatch(xhr.open).call(xhr, method, url, async, user, password); - } - else { - result = tryCatch_1.tryCatch(xhr.open).call(xhr, method, url, async); - } - if (result === errorObject_1.errorObject) { - this.error(errorObject_1.errorObject.e); - return null; - } - // timeout, responseType and withCredentials can be set once the XHR is open - if (async) { - xhr.timeout = request.timeout; - xhr.responseType = request.responseType; - } - if ('withCredentials' in xhr) { - xhr.withCredentials = !!request.withCredentials; - } - // set headers - this.setHeaders(xhr, headers); - // finally send the request - result = body ? tryCatch_1.tryCatch(xhr.send).call(xhr, body) : tryCatch_1.tryCatch(xhr.send).call(xhr); - if (result === errorObject_1.errorObject) { - this.error(errorObject_1.errorObject.e); - return null; - } - } - return xhr; - }; - AjaxSubscriber.prototype.serializeBody = function (body, contentType) { - if (!body || typeof body === 'string') { - return body; - } - else if (root_1.root.FormData && body instanceof root_1.root.FormData) { - return body; - } - if (contentType) { - var splitIndex = contentType.indexOf(';'); - if (splitIndex !== -1) { - contentType = contentType.substring(0, splitIndex); - } - } - switch (contentType) { - case 'application/x-www-form-urlencoded': - return Object.keys(body).map(function (key) { return (encodeURI(key) + "=" + encodeURI(body[key])); }).join('&'); - case 'application/json': - return JSON.stringify(body); - default: - return body; - } - }; - AjaxSubscriber.prototype.setHeaders = function (xhr, headers) { - for (var key in headers) { - if (headers.hasOwnProperty(key)) { - xhr.setRequestHeader(key, headers[key]); - } - } - }; - AjaxSubscriber.prototype.setupEvents = function (xhr, request) { - var progressSubscriber = request.progressSubscriber; - function xhrTimeout(e) { - var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request; - if (progressSubscriber) { - progressSubscriber.error(e); - } - subscriber.error(new AjaxTimeoutError(this, request)); //TODO: Make betterer. - } - ; - xhr.ontimeout = xhrTimeout; - xhrTimeout.request = request; - xhrTimeout.subscriber = this; - xhrTimeout.progressSubscriber = progressSubscriber; - if (xhr.upload && 'withCredentials' in xhr) { - if (progressSubscriber) { - var xhrProgress_1; - xhrProgress_1 = function (e) { - var progressSubscriber = xhrProgress_1.progressSubscriber; - progressSubscriber.next(e); - }; - if (root_1.root.XDomainRequest) { - xhr.onprogress = xhrProgress_1; - } - else { - xhr.upload.onprogress = xhrProgress_1; - } - xhrProgress_1.progressSubscriber = progressSubscriber; - } - var xhrError_1; - xhrError_1 = function (e) { - var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request; - if (progressSubscriber) { - progressSubscriber.error(e); - } - subscriber.error(new AjaxError('ajax error', this, request)); - }; - xhr.onerror = xhrError_1; - xhrError_1.request = request; - xhrError_1.subscriber = this; - xhrError_1.progressSubscriber = progressSubscriber; - } - function xhrReadyStateChange(e) { - var _a = xhrReadyStateChange, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request; - if (this.readyState === 4) { - // normalize IE9 bug (http://bugs.jquery.com/ticket/1450) - var status_1 = this.status === 1223 ? 204 : this.status; - var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response); - // fix status code when it is 0 (0 status is undocumented). - // Occurs when accessing file resources or on Android 4.1 stock browser - // while retrieving files from application cache. - if (status_1 === 0) { - status_1 = response ? 200 : 0; - } - if (200 <= status_1 && status_1 < 300) { - if (progressSubscriber) { - progressSubscriber.complete(); - } - subscriber.next(e); - subscriber.complete(); - } - else { - if (progressSubscriber) { - progressSubscriber.error(e); - } - subscriber.error(new AjaxError('ajax error ' + status_1, this, request)); - } - } - } - ; - xhr.onreadystatechange = xhrReadyStateChange; - xhrReadyStateChange.subscriber = this; - xhrReadyStateChange.progressSubscriber = progressSubscriber; - xhrReadyStateChange.request = request; - }; - AjaxSubscriber.prototype.unsubscribe = function () { - var _a = this, done = _a.done, xhr = _a.xhr; - if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') { - xhr.abort(); - } - _super.prototype.unsubscribe.call(this); - }; - return AjaxSubscriber; - }(Subscriber_1.Subscriber)); - exports.AjaxSubscriber = AjaxSubscriber; - /** - * A normalized AJAX response. - * - * @see {@link ajax} - * - * @class AjaxResponse - */ - var AjaxResponse = (function () { - function AjaxResponse(originalEvent, xhr, request) { - this.originalEvent = originalEvent; - this.xhr = xhr; - this.request = request; - this.status = xhr.status; - this.responseType = xhr.responseType || request.responseType; - switch (this.responseType) { - case 'json': - if ('response' in xhr) { - //IE does not support json as responseType, parse it internally - this.response = xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null'); - } - else { - this.response = JSON.parse(xhr.responseText || 'null'); - } - break; - case 'xml': - this.response = xhr.responseXML; - break; - case 'text': - default: - this.response = ('response' in xhr) ? xhr.response : xhr.responseText; - break; - } - } - return AjaxResponse; - }()); - exports.AjaxResponse = AjaxResponse; - /** - * A normalized AJAX error. - * - * @see {@link ajax} - * - * @class AjaxError - */ - var AjaxError = (function (_super) { - __extends(AjaxError, _super); - function AjaxError(message, xhr, request) { - _super.call(this, message); - this.message = message; - this.xhr = xhr; - this.request = request; - this.status = xhr.status; - } - return AjaxError; - }(Error)); - exports.AjaxError = AjaxError; - /** - * @see {@link ajax} - * - * @class AjaxTimeoutError - */ - var AjaxTimeoutError = (function (_super) { - __extends(AjaxTimeoutError, _super); - function AjaxTimeoutError(xhr, request) { - _super.call(this, 'ajax timeout', xhr, request); - } - return AjaxTimeoutError; - }(AjaxError)); - exports.AjaxTimeoutError = AjaxTimeoutError; - //# sourceMappingURL=AjaxObservable.js.map - -/***/ }, -/* 180 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Applies a given `project` function to each value emitted by the source - * Observable, and emits the resulting values as an Observable. - * - * Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map), - * it passes each source value through a transformation function to get - * corresponding output values. - * - * - * - * Similar to the well known `Array.prototype.map` function, this operator - * applies a projection to each value and emits that projection in the output - * Observable. - * - * @example Map every click to the clientX position of that click - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var positions = clicks.map(ev => ev.clientX); - * positions.subscribe(x => console.log(x)); - * - * @see {@link mapTo} - * @see {@link pluck} - * - * @param {function(value: T, index: number): R} project The function to apply - * to each `value` emitted by the source Observable. The `index` parameter is - * the number `i` for the i-th emission that has happened since the - * subscription, starting from the number `0`. - * @param {any} [thisArg] An optional argument to define what `this` is in the - * `project` function. - * @return {Observable} An Observable that emits the values from the source - * Observable transformed by the given `project` function. - * @method map - * @owner Observable - */ - function map(project, thisArg) { - if (typeof project !== 'function') { - throw new TypeError('argument is not a function. Are you looking for `mapTo()`?'); - } - return this.lift(new MapOperator(project, thisArg)); - } - exports.map = map; - var MapOperator = (function () { - function MapOperator(project, thisArg) { - this.project = project; - this.thisArg = thisArg; - } - MapOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg)); - }; - return MapOperator; - }()); - exports.MapOperator = MapOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var MapSubscriber = (function (_super) { - __extends(MapSubscriber, _super); - function MapSubscriber(destination, project, thisArg) { - _super.call(this, destination); - this.project = project; - this.count = 0; - this.thisArg = thisArg || this; - } - // NOTE: This looks unoptimized, but it's actually purposefully NOT - // using try/catch optimizations. - MapSubscriber.prototype._next = function (value) { - var result; - try { - result = this.project.call(this.thisArg, value, this.count++); - } - catch (err) { - this.destination.error(err); - return; - } - this.destination.next(result); - }; - return MapSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=map.js.map - -/***/ }, -/* 181 */ -/***/ function(module, exports, __webpack_require__) { +var PairsObservable_1 = __webpack_require__(188); +exports.pairs = PairsObservable_1.PairsObservable.create; +//# sourceMappingURL=pairs.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var webSocket_1 = __webpack_require__(182); - Observable_1.Observable.webSocket = webSocket_1.webSocket; - //# sourceMappingURL=webSocket.js.map +/***/ }), +/* 188 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +function dispatch(state) { + var obj = state.obj, keys = state.keys, length = state.length, index = state.index, subscriber = state.subscriber; + if (index === length) { + subscriber.complete(); + return; + } + var key = keys[index]; + subscriber.next([key, obj[key]]); + state.index = index + 1; + this.schedule(state); +} +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var PairsObservable = (function (_super) { + __extends(PairsObservable, _super); + function PairsObservable(obj, scheduler) { + _super.call(this); + this.obj = obj; + this.scheduler = scheduler; + this.keys = Object.keys(obj); + } + /** + * Convert an object into an observable sequence of [key, value] pairs + * using an optional IScheduler to enumerate the object. + * + * @example Converts a javascript object to an Observable + * var obj = { + * foo: 42, + * bar: 56, + * baz: 78 + * }; + * + * var source = Rx.Observable.pairs(obj); + * + * var subscription = source.subscribe( + * function (x) { + * console.log('Next: %s', x); + * }, + * function (err) { + * console.log('Error: %s', err); + * }, + * function () { + * console.log('Completed'); + * }); + * + * @param {Object} obj The object to inspect and turn into an + * Observable sequence. + * @param {Scheduler} [scheduler] An optional IScheduler to run the + * enumeration of the input sequence on. + * @returns {(Observable>)} An observable sequence of + * [key, value] pairs from the object. + */ + PairsObservable.create = function (obj, scheduler) { + return new PairsObservable(obj, scheduler); + }; + PairsObservable.prototype._subscribe = function (subscriber) { + var _a = this, keys = _a.keys, scheduler = _a.scheduler; + var length = keys.length; + if (scheduler) { + return scheduler.schedule(dispatch, 0, { + obj: this.obj, keys: keys, length: length, index: 0, subscriber: subscriber + }); + } + else { + for (var idx = 0; idx < length; idx++) { + var key = keys[idx]; + subscriber.next([key, this.obj[key]]); + } + subscriber.complete(); + } + }; + return PairsObservable; +}(Observable_1.Observable)); +exports.PairsObservable = PairsObservable; +//# sourceMappingURL=PairsObservable.js.map + +/***/ }), +/* 189 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 182 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var WebSocketSubject_1 = __webpack_require__(183); - exports.webSocket = WebSocketSubject_1.WebSocketSubject.create; - //# sourceMappingURL=webSocket.js.map +var Observable_1 = __webpack_require__(0); +var range_1 = __webpack_require__(190); +Observable_1.Observable.range = range_1.range; +//# sourceMappingURL=range.js.map -/***/ }, -/* 183 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subject_1 = __webpack_require__(63); - var Subscriber_1 = __webpack_require__(67); - var Observable_1 = __webpack_require__(64); - var Subscription_1 = __webpack_require__(69); - var root_1 = __webpack_require__(65); - var ReplaySubject_1 = __webpack_require__(184); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var assign_1 = __webpack_require__(188); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var WebSocketSubject = (function (_super) { - __extends(WebSocketSubject, _super); - function WebSocketSubject(urlConfigOrSource, destination) { - if (urlConfigOrSource instanceof Observable_1.Observable) { - _super.call(this, destination, urlConfigOrSource); - } - else { - _super.call(this); - this.WebSocketCtor = root_1.root.WebSocket; - this._output = new Subject_1.Subject(); - if (typeof urlConfigOrSource === 'string') { - this.url = urlConfigOrSource; - } - else { - // WARNING: config object could override important members here. - assign_1.assign(this, urlConfigOrSource); - } - if (!this.WebSocketCtor) { - throw new Error('no WebSocket constructor can be found'); - } - this.destination = new ReplaySubject_1.ReplaySubject(); - } - } - WebSocketSubject.prototype.resultSelector = function (e) { - return JSON.parse(e.data); - }; - /** - * Wrapper around the w3c-compatible WebSocket object provided by the browser. - * - * @example Wraps browser WebSocket - * - * let socket$ = Observable.webSocket('ws://localhost:8081'); - * - * socket$.subscribe( - * (msg) => console.log('message received: ' + msg), - * (err) => console.log(err), - * () => console.log('complete') - * ); - * - * socket$.next(JSON.stringify({ op: 'hello' })); - * - * @example Wraps WebSocket from nodejs-websocket (using node.js) - * - * import { w3cwebsocket } from 'websocket'; - * - * let socket$ = Observable.webSocket({ - * url: 'ws://localhost:8081', - * WebSocketCtor: w3cwebsocket - * }); - * - * socket$.subscribe( - * (msg) => console.log('message received: ' + msg), - * (err) => console.log(err), - * () => console.log('complete') - * ); - * - * socket$.next(JSON.stringify({ op: 'hello' })); - * - * @param {string | WebSocketSubjectConfig} urlConfigOrSource the source of the websocket as an url or a structure defining the websocket object - * @return {WebSocketSubject} - * @static true - * @name webSocket - * @owner Observable - */ - WebSocketSubject.create = function (urlConfigOrSource) { - return new WebSocketSubject(urlConfigOrSource); - }; - WebSocketSubject.prototype.lift = function (operator) { - var sock = new WebSocketSubject(this, this.destination); - sock.operator = operator; - return sock; - }; - WebSocketSubject.prototype._resetState = function () { - this.socket = null; - if (!this.source) { - this.destination = new ReplaySubject_1.ReplaySubject(); - } - this._output = new Subject_1.Subject(); - }; - // TODO: factor this out to be a proper Operator/Subscriber implementation and eliminate closures - WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) { - var self = this; - return new Observable_1.Observable(function (observer) { - var result = tryCatch_1.tryCatch(subMsg)(); - if (result === errorObject_1.errorObject) { - observer.error(errorObject_1.errorObject.e); - } - else { - self.next(result); - } - var subscription = self.subscribe(function (x) { - var result = tryCatch_1.tryCatch(messageFilter)(x); - if (result === errorObject_1.errorObject) { - observer.error(errorObject_1.errorObject.e); - } - else if (result) { - observer.next(x); - } - }, function (err) { return observer.error(err); }, function () { return observer.complete(); }); - return function () { - var result = tryCatch_1.tryCatch(unsubMsg)(); - if (result === errorObject_1.errorObject) { - observer.error(errorObject_1.errorObject.e); - } - else { - self.next(result); - } - subscription.unsubscribe(); - }; - }); - }; - WebSocketSubject.prototype._connectSocket = function () { - var _this = this; - var WebSocketCtor = this.WebSocketCtor; - var observer = this._output; - var socket = null; - try { - socket = this.protocol ? - new WebSocketCtor(this.url, this.protocol) : - new WebSocketCtor(this.url); - this.socket = socket; - if (this.binaryType) { - this.socket.binaryType = this.binaryType; - } - } - catch (e) { - observer.error(e); - return; - } - var subscription = new Subscription_1.Subscription(function () { - _this.socket = null; - if (socket && socket.readyState === 1) { - socket.close(); - } - }); - socket.onopen = function (e) { - var openObserver = _this.openObserver; - if (openObserver) { - openObserver.next(e); - } - var queue = _this.destination; - _this.destination = Subscriber_1.Subscriber.create(function (x) { return socket.readyState === 1 && socket.send(x); }, function (e) { - var closingObserver = _this.closingObserver; - if (closingObserver) { - closingObserver.next(undefined); - } - if (e && e.code) { - socket.close(e.code, e.reason); - } - else { - observer.error(new TypeError('WebSocketSubject.error must be called with an object with an error code, ' + - 'and an optional reason: { code: number, reason: string }')); - } - _this._resetState(); - }, function () { - var closingObserver = _this.closingObserver; - if (closingObserver) { - closingObserver.next(undefined); - } - socket.close(); - _this._resetState(); - }); - if (queue && queue instanceof ReplaySubject_1.ReplaySubject) { - subscription.add(queue.subscribe(_this.destination)); - } - }; - socket.onerror = function (e) { - _this._resetState(); - observer.error(e); - }; - socket.onclose = function (e) { - _this._resetState(); - var closeObserver = _this.closeObserver; - if (closeObserver) { - closeObserver.next(e); - } - if (e.wasClean) { - observer.complete(); - } - else { - observer.error(e); - } - }; - socket.onmessage = function (e) { - var result = tryCatch_1.tryCatch(_this.resultSelector)(e); - if (result === errorObject_1.errorObject) { - observer.error(errorObject_1.errorObject.e); - } - else { - observer.next(result); - } - }; - }; - WebSocketSubject.prototype._subscribe = function (subscriber) { - var _this = this; - var source = this.source; - if (source) { - return source.subscribe(subscriber); - } - if (!this.socket) { - this._connectSocket(); - } - var subscription = new Subscription_1.Subscription(); - subscription.add(this._output.subscribe(subscriber)); - subscription.add(function () { - var socket = _this.socket; - if (_this._output.observers.length === 0) { - if (socket && socket.readyState === 1) { - socket.close(); - } - _this._resetState(); - } - }); - return subscription; - }; - WebSocketSubject.prototype.unsubscribe = function () { - var _a = this, source = _a.source, socket = _a.socket; - if (socket && socket.readyState === 1) { - socket.close(); - this._resetState(); - } - _super.prototype.unsubscribe.call(this); - if (!source) { - this.destination = new ReplaySubject_1.ReplaySubject(); - } - }; - return WebSocketSubject; - }(Subject_1.AnonymousSubject)); - exports.WebSocketSubject = WebSocketSubject; - //# sourceMappingURL=WebSocketSubject.js.map - -/***/ }, -/* 184 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subject_1 = __webpack_require__(63); - var queue_1 = __webpack_require__(185); - var Subscription_1 = __webpack_require__(69); - var observeOn_1 = __webpack_require__(118); - var ObjectUnsubscribedError_1 = __webpack_require__(78); - var SubjectSubscription_1 = __webpack_require__(79); - /** - * @class ReplaySubject - */ - var ReplaySubject = (function (_super) { - __extends(ReplaySubject, _super); - function ReplaySubject(bufferSize, windowTime, scheduler) { - if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; } - if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; } - _super.call(this); - this.scheduler = scheduler; - this._events = []; - this._bufferSize = bufferSize < 1 ? 1 : bufferSize; - this._windowTime = windowTime < 1 ? 1 : windowTime; - } - ReplaySubject.prototype.next = function (value) { - var now = this._getNow(); - this._events.push(new ReplayEvent(now, value)); - this._trimBufferThenGetEvents(); - _super.prototype.next.call(this, value); - }; - ReplaySubject.prototype._subscribe = function (subscriber) { - var _events = this._trimBufferThenGetEvents(); - var scheduler = this.scheduler; - var subscription; - if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); - } - else if (this.hasError) { - subscription = Subscription_1.Subscription.EMPTY; - } - else if (this.isStopped) { - subscription = Subscription_1.Subscription.EMPTY; - } - else { - this.observers.push(subscriber); - subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber); - } - if (scheduler) { - subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler)); - } - var len = _events.length; - for (var i = 0; i < len && !subscriber.closed; i++) { - subscriber.next(_events[i].value); - } - if (this.hasError) { - subscriber.error(this.thrownError); - } - else if (this.isStopped) { - subscriber.complete(); - } - return subscription; - }; - ReplaySubject.prototype._getNow = function () { - return (this.scheduler || queue_1.queue).now(); - }; - ReplaySubject.prototype._trimBufferThenGetEvents = function () { - var now = this._getNow(); - var _bufferSize = this._bufferSize; - var _windowTime = this._windowTime; - var _events = this._events; - var eventsCount = _events.length; - var spliceCount = 0; - // Trim events that fall out of the time window. - // Start at the front of the list. Break early once - // we encounter an event that falls within the window. - while (spliceCount < eventsCount) { - if ((now - _events[spliceCount].time) < _windowTime) { - break; - } - spliceCount++; - } - if (eventsCount > _bufferSize) { - spliceCount = Math.max(spliceCount, eventsCount - _bufferSize); - } - if (spliceCount > 0) { - _events.splice(0, spliceCount); - } - return _events; - }; - return ReplaySubject; - }(Subject_1.Subject)); - exports.ReplaySubject = ReplaySubject; - var ReplayEvent = (function () { - function ReplayEvent(time, value) { - this.time = time; - this.value = value; - } - return ReplayEvent; - }()); - //# sourceMappingURL=ReplaySubject.js.map - -/***/ }, -/* 185 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var QueueAction_1 = __webpack_require__(186); - var QueueScheduler_1 = __webpack_require__(187); - /** - * - * Queue Scheduler - * - * Put every next task on a queue, instead of executing it immediately - * - * `queue` scheduler, when used with delay, behaves the same as {@link async} scheduler. - * - * When used without delay, it schedules given task synchronously - executes it right when - * it is scheduled. However when called recursively, that is when inside the scheduled task, - * another task is scheduled with queue scheduler, instead of executing immediately as well, - * that task will be put on a queue and wait for current one to finish. - * - * This means that when you execute task with `queue` scheduler, you are sure it will end - * before any other task scheduled with that scheduler will start. - * - * @examples Schedule recursively first, then do something - * - * Rx.Scheduler.queue.schedule(() => { - * Rx.Scheduler.queue.schedule(() => console.log('second')); // will not happen now, but will be put on a queue - * - * console.log('first'); - * }); - * - * // Logs: - * // "first" - * // "second" - * - * - * @example Reschedule itself recursively - * - * Rx.Scheduler.queue.schedule(function(state) { - * if (state !== 0) { - * console.log('before', state); - * this.schedule(state - 1); // `this` references currently executing Action, - * // which we reschedule with new state - * console.log('after', state); - * } - * }, 0, 3); - * - * // In scheduler that runs recursively, you would expect: - * // "before", 3 - * // "before", 2 - * // "before", 1 - * // "after", 1 - * // "after", 2 - * // "after", 3 - * - * // But with queue it logs: - * // "before", 3 - * // "after", 3 - * // "before", 2 - * // "after", 2 - * // "before", 1 - * // "after", 1 - * - * - * @static true - * @name queue - * @owner Scheduler - */ - exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction); - //# sourceMappingURL=queue.js.map - -/***/ }, -/* 186 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 AsyncAction_1 = __webpack_require__(139); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var QueueAction = (function (_super) { - __extends(QueueAction, _super); - function QueueAction(scheduler, work) { - _super.call(this, scheduler, work); - this.scheduler = scheduler; - this.work = work; - } - QueueAction.prototype.schedule = function (state, delay) { - if (delay === void 0) { delay = 0; } - if (delay > 0) { - return _super.prototype.schedule.call(this, state, delay); - } - this.delay = delay; - this.state = state; - this.scheduler.flush(this); - return this; - }; - QueueAction.prototype.execute = function (state, delay) { - return (delay > 0 || this.closed) ? - _super.prototype.execute.call(this, state, delay) : - this._execute(state, delay); - }; - QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) { - if (delay === void 0) { delay = 0; } - // If delay exists and is greater than 0, or if the delay is null (the - // action wasn't rescheduled) but was originally scheduled as an async - // action, then recycle as an async action. - if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { - return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); - } - // Otherwise flush the scheduler starting with this action. - return scheduler.flush(this); - }; - return QueueAction; - }(AsyncAction_1.AsyncAction)); - exports.QueueAction = QueueAction; - //# sourceMappingURL=QueueAction.js.map - -/***/ }, -/* 187 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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_1 = __webpack_require__(141); - var QueueScheduler = (function (_super) { - __extends(QueueScheduler, _super); - function QueueScheduler() { - _super.apply(this, arguments); - } - return QueueScheduler; - }(AsyncScheduler_1.AsyncScheduler)); - exports.QueueScheduler = QueueScheduler; - //# sourceMappingURL=QueueScheduler.js.map - -/***/ }, -/* 188 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var root_1 = __webpack_require__(65); - function assignImpl(target) { - var sources = []; - for (var _i = 1; _i < arguments.length; _i++) { - sources[_i - 1] = arguments[_i]; - } - var len = sources.length; - for (var i = 0; i < len; i++) { - var source = sources[i]; - for (var k in source) { - if (source.hasOwnProperty(k)) { - target[k] = source[k]; - } - } - } - return target; - } - exports.assignImpl = assignImpl; - ; - function getAssign(root) { - return root.Object.assign || assignImpl; - } - exports.getAssign = getAssign; - exports.assign = getAssign(root_1.root); - //# sourceMappingURL=assign.js.map +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 189 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var buffer_1 = __webpack_require__(190); - Observable_1.Observable.prototype.buffer = buffer_1.buffer; - //# sourceMappingURL=buffer.js.map +var RangeObservable_1 = __webpack_require__(191); +exports.range = RangeObservable_1.RangeObservable.create; +//# sourceMappingURL=range.js.map -/***/ }, -/* 190 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Buffers the source Observable values until `closingNotifier` emits. - * - * Collects values from the past as an array, and emits - * that array only when another Observable emits. - * - * - * - * Buffers the incoming Observable values until the given `closingNotifier` - * Observable emits a value, at which point it emits the buffer on the output - * Observable and starts a new buffer internally, awaiting the next time - * `closingNotifier` emits. - * - * @example On every click, emit array of most recent interval events - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var interval = Rx.Observable.interval(1000); - * var buffered = interval.buffer(clicks); - * buffered.subscribe(x => console.log(x)); - * - * @see {@link bufferCount} - * @see {@link bufferTime} - * @see {@link bufferToggle} - * @see {@link bufferWhen} - * @see {@link window} - * - * @param {Observable} closingNotifier An Observable that signals the - * buffer to be emitted on the output Observable. - * @return {Observable} An Observable of buffers, which are arrays of - * values. - * @method buffer - * @owner Observable - */ - function buffer(closingNotifier) { - return this.lift(new BufferOperator(closingNotifier)); - } - exports.buffer = buffer; - var BufferOperator = (function () { - function BufferOperator(closingNotifier) { - this.closingNotifier = closingNotifier; - } - BufferOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier)); - }; - return BufferOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var BufferSubscriber = (function (_super) { - __extends(BufferSubscriber, _super); - function BufferSubscriber(destination, closingNotifier) { - _super.call(this, destination); - this.buffer = []; - this.add(subscribeToResult_1.subscribeToResult(this, closingNotifier)); - } - BufferSubscriber.prototype._next = function (value) { - this.buffer.push(value); - }; - BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var buffer = this.buffer; - this.buffer = []; - this.destination.next(buffer); - }; - return BufferSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=buffer.js.map - -/***/ }, +/***/ }), /* 191 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var RangeObservable = (function (_super) { + __extends(RangeObservable, _super); + function RangeObservable(start, count, scheduler) { + _super.call(this); + this.start = start; + this._count = count; + this.scheduler = scheduler; + } + /** + * Creates an Observable that emits a sequence of numbers within a specified + * range. + * + * Emits a sequence of numbers in a range. + * + * + * + * `range` operator emits a range of sequential integers, in order, where you + * select the `start` of the range and its `length`. By default, uses no + * IScheduler and just delivers the notifications synchronously, but may use + * an optional IScheduler to regulate those deliveries. + * + * @example Emits the numbers 1 to 10 + * var numbers = Rx.Observable.range(1, 10); + * numbers.subscribe(x => console.log(x)); + * + * @see {@link timer} + * @see {@link interval} + * + * @param {number} [start=0] The value of the first integer in the sequence. + * @param {number} [count=0] The number of sequential integers to generate. + * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling + * the emissions of the notifications. + * @return {Observable} An Observable of numbers that emits a finite range of + * sequential integers. + * @static true + * @name range + * @owner Observable + */ + RangeObservable.create = function (start, count, scheduler) { + if (start === void 0) { start = 0; } + if (count === void 0) { count = 0; } + return new RangeObservable(start, count, scheduler); + }; + RangeObservable.dispatch = function (state) { + var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber; + if (index >= count) { + subscriber.complete(); + return; + } + subscriber.next(start); + if (subscriber.closed) { + return; + } + state.index = index + 1; + state.start = start + 1; + this.schedule(state); + }; + RangeObservable.prototype._subscribe = function (subscriber) { + var index = 0; + var start = this.start; + var count = this._count; + var scheduler = this.scheduler; + if (scheduler) { + return scheduler.schedule(RangeObservable.dispatch, 0, { + index: index, count: count, start: start, subscriber: subscriber + }); + } + else { + do { + if (index++ >= count) { + subscriber.complete(); + break; + } + subscriber.next(start++); + if (subscriber.closed) { + break; + } + } while (true); + } + }; + return RangeObservable; +}(Observable_1.Observable)); +exports.RangeObservable = RangeObservable; +//# sourceMappingURL=RangeObservable.js.map + +/***/ }), +/* 192 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var bufferCount_1 = __webpack_require__(192); - Observable_1.Observable.prototype.bufferCount = bufferCount_1.bufferCount; - //# sourceMappingURL=bufferCount.js.map +"use strict"; -/***/ }, -/* 192 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Buffers the source Observable values until the size hits the maximum - * `bufferSize` given. - * - * Collects values from the past as an array, and emits - * that array only when its size reaches `bufferSize`. - * - * - * - * Buffers a number of values from the source Observable by `bufferSize` then - * emits the buffer and clears it, and starts a new buffer each - * `startBufferEvery` values. If `startBufferEvery` is not provided or is - * `null`, then new buffers are started immediately at the start of the source - * and when each buffer closes and is emitted. - * - * @example Emit the last two click events as an array - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var buffered = clicks.bufferCount(2); - * buffered.subscribe(x => console.log(x)); - * - * @example On every click, emit the last two click events as an array - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var buffered = clicks.bufferCount(2, 1); - * buffered.subscribe(x => console.log(x)); - * - * @see {@link buffer} - * @see {@link bufferTime} - * @see {@link bufferToggle} - * @see {@link bufferWhen} - * @see {@link pairwise} - * @see {@link windowCount} - * - * @param {number} bufferSize The maximum size of the buffer emitted. - * @param {number} [startBufferEvery] Interval at which to start a new buffer. - * For example if `startBufferEvery` is `2`, then a new buffer will be started - * on every other value from the source. A new buffer is started at the - * beginning of the source by default. - * @return {Observable} An Observable of arrays of buffered values. - * @method bufferCount - * @owner Observable - */ - function bufferCount(bufferSize, startBufferEvery) { - if (startBufferEvery === void 0) { startBufferEvery = null; } - return this.lift(new BufferCountOperator(bufferSize, startBufferEvery)); - } - exports.bufferCount = bufferCount; - var BufferCountOperator = (function () { - function BufferCountOperator(bufferSize, startBufferEvery) { - this.bufferSize = bufferSize; - this.startBufferEvery = startBufferEvery; - if (!startBufferEvery || bufferSize === startBufferEvery) { - this.subscriberClass = BufferCountSubscriber; - } - else { - this.subscriberClass = BufferSkipCountSubscriber; - } - } - BufferCountOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery)); - }; - return BufferCountOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var BufferCountSubscriber = (function (_super) { - __extends(BufferCountSubscriber, _super); - function BufferCountSubscriber(destination, bufferSize) { - _super.call(this, destination); - this.bufferSize = bufferSize; - this.buffer = []; - } - BufferCountSubscriber.prototype._next = function (value) { - var buffer = this.buffer; - buffer.push(value); - if (buffer.length == this.bufferSize) { - this.destination.next(buffer); - this.buffer = []; - } - }; - BufferCountSubscriber.prototype._complete = function () { - var buffer = this.buffer; - if (buffer.length > 0) { - this.destination.next(buffer); - } - _super.prototype._complete.call(this); - }; - return BufferCountSubscriber; - }(Subscriber_1.Subscriber)); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var BufferSkipCountSubscriber = (function (_super) { - __extends(BufferSkipCountSubscriber, _super); - function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) { - _super.call(this, destination); - this.bufferSize = bufferSize; - this.startBufferEvery = startBufferEvery; - this.buffers = []; - this.count = 0; - } - BufferSkipCountSubscriber.prototype._next = function (value) { - var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count; - this.count++; - if (count % startBufferEvery === 0) { - buffers.push([]); - } - for (var i = buffers.length; i--;) { - var buffer = buffers[i]; - buffer.push(value); - if (buffer.length === bufferSize) { - buffers.splice(i, 1); - this.destination.next(buffer); - } - } - }; - BufferSkipCountSubscriber.prototype._complete = function () { - var _a = this, buffers = _a.buffers, destination = _a.destination; - while (buffers.length > 0) { - var buffer = buffers.shift(); - if (buffer.length > 0) { - destination.next(buffer); - } - } - _super.prototype._complete.call(this); - }; - return BufferSkipCountSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=bufferCount.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var using_1 = __webpack_require__(193); +Observable_1.Observable.using = using_1.using; +//# sourceMappingURL=using.js.map + +/***/ }), /* 193 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var bufferTime_1 = __webpack_require__(194); - Observable_1.Observable.prototype.bufferTime = bufferTime_1.bufferTime; - //# sourceMappingURL=bufferTime.js.map +"use strict"; -/***/ }, -/* 194 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 async_1 = __webpack_require__(138); - var Subscriber_1 = __webpack_require__(67); - var isScheduler_1 = __webpack_require__(89); - /* tslint:enable:max-line-length */ - /** - * Buffers the source Observable values for a specific time period. - * - * Collects values from the past as an array, and emits - * those arrays periodically in time. - * - * - * - * Buffers values from the source for a specific time duration `bufferTimeSpan`. - * Unless the optional argument `bufferCreationInterval` is given, it emits and - * resets the buffer every `bufferTimeSpan` milliseconds. If - * `bufferCreationInterval` is given, this operator opens the buffer every - * `bufferCreationInterval` milliseconds and closes (emits and resets) the - * buffer every `bufferTimeSpan` milliseconds. When the optional argument - * `maxBufferSize` is specified, the buffer will be closed either after - * `bufferTimeSpan` milliseconds or when it contains `maxBufferSize` elements. - * - * @example Every second, emit an array of the recent click events - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var buffered = clicks.bufferTime(1000); - * buffered.subscribe(x => console.log(x)); - * - * @example Every 5 seconds, emit the click events from the next 2 seconds - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var buffered = clicks.bufferTime(2000, 5000); - * buffered.subscribe(x => console.log(x)); - * - * @see {@link buffer} - * @see {@link bufferCount} - * @see {@link bufferToggle} - * @see {@link bufferWhen} - * @see {@link windowTime} - * - * @param {number} bufferTimeSpan The amount of time to fill each buffer array. - * @param {number} [bufferCreationInterval] The interval at which to start new - * buffers. - * @param {number} [maxBufferSize] The maximum buffer size. - * @param {Scheduler} [scheduler=async] The scheduler on which to schedule the - * intervals that determine buffer boundaries. - * @return {Observable} An observable of arrays of buffered values. - * @method bufferTime - * @owner Observable - */ - function bufferTime(bufferTimeSpan) { - var length = arguments.length; - var scheduler = async_1.async; - if (isScheduler_1.isScheduler(arguments[arguments.length - 1])) { - scheduler = arguments[arguments.length - 1]; - length--; - } - var bufferCreationInterval = null; - if (length >= 2) { - bufferCreationInterval = arguments[1]; - } - var maxBufferSize = Number.POSITIVE_INFINITY; - if (length >= 3) { - maxBufferSize = arguments[2]; - } - return this.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler)); - } - exports.bufferTime = bufferTime; - var BufferTimeOperator = (function () { - function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) { - this.bufferTimeSpan = bufferTimeSpan; - this.bufferCreationInterval = bufferCreationInterval; - this.maxBufferSize = maxBufferSize; - this.scheduler = scheduler; - } - BufferTimeOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler)); - }; - return BufferTimeOperator; - }()); - var Context = (function () { - function Context() { - this.buffer = []; - } - return Context; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var BufferTimeSubscriber = (function (_super) { - __extends(BufferTimeSubscriber, _super); - function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) { - _super.call(this, destination); - this.bufferTimeSpan = bufferTimeSpan; - this.bufferCreationInterval = bufferCreationInterval; - this.maxBufferSize = maxBufferSize; - this.scheduler = scheduler; - this.contexts = []; - var context = this.openContext(); - this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0; - if (this.timespanOnly) { - var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan }; - this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState)); - } - else { - var closeState = { subscriber: this, context: context }; - var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: this, scheduler: scheduler }; - this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState)); - this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState)); - } - } - BufferTimeSubscriber.prototype._next = function (value) { - var contexts = this.contexts; - var len = contexts.length; - var filledBufferContext; - for (var i = 0; i < len; i++) { - var context = contexts[i]; - var buffer = context.buffer; - buffer.push(value); - if (buffer.length == this.maxBufferSize) { - filledBufferContext = context; - } - } - if (filledBufferContext) { - this.onBufferFull(filledBufferContext); - } - }; - BufferTimeSubscriber.prototype._error = function (err) { - this.contexts.length = 0; - _super.prototype._error.call(this, err); - }; - BufferTimeSubscriber.prototype._complete = function () { - var _a = this, contexts = _a.contexts, destination = _a.destination; - while (contexts.length > 0) { - var context = contexts.shift(); - destination.next(context.buffer); - } - _super.prototype._complete.call(this); - }; - BufferTimeSubscriber.prototype._unsubscribe = function () { - this.contexts = null; - }; - BufferTimeSubscriber.prototype.onBufferFull = function (context) { - this.closeContext(context); - var closeAction = context.closeAction; - closeAction.unsubscribe(); - this.remove(closeAction); - if (!this.closed && this.timespanOnly) { - context = this.openContext(); - var bufferTimeSpan = this.bufferTimeSpan; - var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan }; - this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState)); - } - }; - BufferTimeSubscriber.prototype.openContext = function () { - var context = new Context(); - this.contexts.push(context); - return context; - }; - BufferTimeSubscriber.prototype.closeContext = function (context) { - this.destination.next(context.buffer); - var contexts = this.contexts; - var spliceIndex = contexts ? contexts.indexOf(context) : -1; - if (spliceIndex >= 0) { - contexts.splice(contexts.indexOf(context), 1); - } - }; - return BufferTimeSubscriber; - }(Subscriber_1.Subscriber)); - function dispatchBufferTimeSpanOnly(state) { - var subscriber = state.subscriber; - var prevContext = state.context; - if (prevContext) { - subscriber.closeContext(prevContext); - } - if (!subscriber.closed) { - state.context = subscriber.openContext(); - state.context.closeAction = this.schedule(state, state.bufferTimeSpan); - } - } - function dispatchBufferCreation(state) { - var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler; - var context = subscriber.openContext(); - var action = this; - if (!subscriber.closed) { - subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context })); - action.schedule(state, bufferCreationInterval); - } - } - function dispatchBufferClose(arg) { - var subscriber = arg.subscriber, context = arg.context; - subscriber.closeContext(context); - } - //# sourceMappingURL=bufferTime.js.map +var UsingObservable_1 = __webpack_require__(194); +exports.using = UsingObservable_1.UsingObservable.create; +//# sourceMappingURL=using.js.map -/***/ }, +/***/ }), +/* 194 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +var subscribeToResult_1 = __webpack_require__(3); +var OuterSubscriber_1 = __webpack_require__(2); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var UsingObservable = (function (_super) { + __extends(UsingObservable, _super); + function UsingObservable(resourceFactory, observableFactory) { + _super.call(this); + this.resourceFactory = resourceFactory; + this.observableFactory = observableFactory; + } + UsingObservable.create = function (resourceFactory, observableFactory) { + return new UsingObservable(resourceFactory, observableFactory); + }; + UsingObservable.prototype._subscribe = function (subscriber) { + var _a = this, resourceFactory = _a.resourceFactory, observableFactory = _a.observableFactory; + var resource; + try { + resource = resourceFactory(); + return new UsingSubscriber(subscriber, resource, observableFactory); + } + catch (err) { + subscriber.error(err); + } + }; + return UsingObservable; +}(Observable_1.Observable)); +exports.UsingObservable = UsingObservable; +var UsingSubscriber = (function (_super) { + __extends(UsingSubscriber, _super); + function UsingSubscriber(destination, resource, observableFactory) { + _super.call(this, destination); + this.resource = resource; + this.observableFactory = observableFactory; + destination.add(resource); + this.tryUse(); + } + UsingSubscriber.prototype.tryUse = function () { + try { + var source = this.observableFactory.call(this, this.resource); + if (source) { + this.add(subscribeToResult_1.subscribeToResult(this, source)); + } + } + catch (err) { + this._error(err); + } + }; + return UsingSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=UsingObservable.js.map + +/***/ }), /* 195 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var bufferToggle_1 = __webpack_require__(196); - Observable_1.Observable.prototype.bufferToggle = bufferToggle_1.bufferToggle; - //# sourceMappingURL=bufferToggle.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var throw_1 = __webpack_require__(196); +Observable_1.Observable.throw = throw_1._throw; +//# sourceMappingURL=throw.js.map + +/***/ }), /* 196 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscription_1 = __webpack_require__(69); - var subscribeToResult_1 = __webpack_require__(95); - var OuterSubscriber_1 = __webpack_require__(94); - /** - * Buffers the source Observable values starting from an emission from - * `openings` and ending when the output of `closingSelector` emits. - * - * Collects values from the past as an array. Starts - * collecting only when `opening` emits, and calls the `closingSelector` - * function to get an Observable that tells when to close the buffer. - * - * - * - * Buffers values from the source by opening the buffer via signals from an - * Observable provided to `openings`, and closing and sending the buffers when - * a Subscribable or Promise returned by the `closingSelector` function emits. - * - * @example Every other second, emit the click events from the next 500ms - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var openings = Rx.Observable.interval(1000); - * var buffered = clicks.bufferToggle(openings, i => - * i % 2 ? Rx.Observable.interval(500) : Rx.Observable.empty() - * ); - * buffered.subscribe(x => console.log(x)); - * - * @see {@link buffer} - * @see {@link bufferCount} - * @see {@link bufferTime} - * @see {@link bufferWhen} - * @see {@link windowToggle} - * - * @param {SubscribableOrPromise} openings A Subscribable or Promise of notifications to start new - * buffers. - * @param {function(value: O): SubscribableOrPromise} closingSelector A function that takes - * the value emitted by the `openings` observable and returns a Subscribable or Promise, - * which, when it emits, signals that the associated buffer should be emitted - * and cleared. - * @return {Observable} An observable of arrays of buffered values. - * @method bufferToggle - * @owner Observable - */ - function bufferToggle(openings, closingSelector) { - return this.lift(new BufferToggleOperator(openings, closingSelector)); - } - exports.bufferToggle = bufferToggle; - var BufferToggleOperator = (function () { - function BufferToggleOperator(openings, closingSelector) { - this.openings = openings; - this.closingSelector = closingSelector; - } - BufferToggleOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector)); - }; - return BufferToggleOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var BufferToggleSubscriber = (function (_super) { - __extends(BufferToggleSubscriber, _super); - function BufferToggleSubscriber(destination, openings, closingSelector) { - _super.call(this, destination); - this.openings = openings; - this.closingSelector = closingSelector; - this.contexts = []; - this.add(subscribeToResult_1.subscribeToResult(this, openings)); - } - BufferToggleSubscriber.prototype._next = function (value) { - var contexts = this.contexts; - var len = contexts.length; - for (var i = 0; i < len; i++) { - contexts[i].buffer.push(value); - } - }; - BufferToggleSubscriber.prototype._error = function (err) { - var contexts = this.contexts; - while (contexts.length > 0) { - var context = contexts.shift(); - context.subscription.unsubscribe(); - context.buffer = null; - context.subscription = null; - } - this.contexts = null; - _super.prototype._error.call(this, err); - }; - BufferToggleSubscriber.prototype._complete = function () { - var contexts = this.contexts; - while (contexts.length > 0) { - var context = contexts.shift(); - this.destination.next(context.buffer); - context.subscription.unsubscribe(); - context.buffer = null; - context.subscription = null; - } - this.contexts = null; - _super.prototype._complete.call(this); - }; - BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue); - }; - BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) { - this.closeBuffer(innerSub.context); - }; - BufferToggleSubscriber.prototype.openBuffer = function (value) { - try { - var closingSelector = this.closingSelector; - var closingNotifier = closingSelector.call(this, value); - if (closingNotifier) { - this.trySubscribe(closingNotifier); - } - } - catch (err) { - this._error(err); - } - }; - BufferToggleSubscriber.prototype.closeBuffer = function (context) { - var contexts = this.contexts; - if (contexts && context) { - var buffer = context.buffer, subscription = context.subscription; - this.destination.next(buffer); - contexts.splice(contexts.indexOf(context), 1); - this.remove(subscription); - subscription.unsubscribe(); - } - }; - BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) { - var contexts = this.contexts; - var buffer = []; - var subscription = new Subscription_1.Subscription(); - var context = { buffer: buffer, subscription: subscription }; - contexts.push(context); - var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context); - if (!innerSubscription || innerSubscription.closed) { - this.closeBuffer(context); - } - else { - innerSubscription.context = context; - this.add(innerSubscription); - subscription.add(innerSubscription); - } - }; - return BufferToggleSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=bufferToggle.js.map - -/***/ }, -/* 197 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var bufferWhen_1 = __webpack_require__(198); - Observable_1.Observable.prototype.bufferWhen = bufferWhen_1.bufferWhen; - //# sourceMappingURL=bufferWhen.js.map +"use strict"; -/***/ }, +var ErrorObservable_1 = __webpack_require__(197); +exports._throw = ErrorObservable_1.ErrorObservable.create; +//# sourceMappingURL=throw.js.map + +/***/ }), +/* 197 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Observable_1 = __webpack_require__(0); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var ErrorObservable = (function (_super) { + __extends(ErrorObservable, _super); + function ErrorObservable(error, scheduler) { + _super.call(this); + this.error = error; + this.scheduler = scheduler; + } + /** + * Creates an Observable that emits no items to the Observer and immediately + * emits an error notification. + * + * Just emits 'error', and nothing else. + * + * + * + * + * This static operator is useful for creating a simple Observable that only + * emits the error notification. It can be used for composing with other + * Observables, such as in a {@link mergeMap}. + * + * @example Emit the number 7, then emit an error. + * var result = Rx.Observable.throw(new Error('oops!')).startWith(7); + * result.subscribe(x => console.log(x), e => console.error(e)); + * + * @example Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for 13 + * var interval = Rx.Observable.interval(1000); + * var result = interval.mergeMap(x => + * x === 13 ? + * Rx.Observable.throw('Thirteens are bad') : + * Rx.Observable.of('a', 'b', 'c') + * ); + * result.subscribe(x => console.log(x), e => console.error(e)); + * + * @see {@link create} + * @see {@link empty} + * @see {@link never} + * @see {@link of} + * + * @param {any} error The particular Error to pass to the error notification. + * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling + * the emission of the error notification. + * @return {Observable} An error Observable: emits only the error notification + * using the given error argument. + * @static true + * @name throw + * @owner Observable + */ + ErrorObservable.create = function (error, scheduler) { + return new ErrorObservable(error, scheduler); + }; + ErrorObservable.dispatch = function (arg) { + var error = arg.error, subscriber = arg.subscriber; + subscriber.error(error); + }; + ErrorObservable.prototype._subscribe = function (subscriber) { + var error = this.error; + var scheduler = this.scheduler; + subscriber.syncErrorThrowable = true; + if (scheduler) { + return scheduler.schedule(ErrorObservable.dispatch, 0, { + error: error, subscriber: subscriber + }); + } + else { + subscriber.error(error); + } + }; + return ErrorObservable; +}(Observable_1.Observable)); +exports.ErrorObservable = ErrorObservable; +//# sourceMappingURL=ErrorObservable.js.map + +/***/ }), /* 198 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscription_1 = __webpack_require__(69); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Buffers the source Observable values, using a factory function of closing - * Observables to determine when to close, emit, and reset the buffer. - * - * Collects values from the past as an array. When it - * starts collecting values, it calls a function that returns an Observable that - * tells when to close the buffer and restart collecting. - * - * - * - * Opens a buffer immediately, then closes the buffer when the observable - * returned by calling `closingSelector` function emits a value. When it closes - * the buffer, it immediately opens a new buffer and repeats the process. - * - * @example Emit an array of the last clicks every [1-5] random seconds - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var buffered = clicks.bufferWhen(() => - * Rx.Observable.interval(1000 + Math.random() * 4000) - * ); - * buffered.subscribe(x => console.log(x)); - * - * @see {@link buffer} - * @see {@link bufferCount} - * @see {@link bufferTime} - * @see {@link bufferToggle} - * @see {@link windowWhen} - * - * @param {function(): Observable} closingSelector A function that takes no - * arguments and returns an Observable that signals buffer closure. - * @return {Observable} An observable of arrays of buffered values. - * @method bufferWhen - * @owner Observable - */ - function bufferWhen(closingSelector) { - return this.lift(new BufferWhenOperator(closingSelector)); - } - exports.bufferWhen = bufferWhen; - var BufferWhenOperator = (function () { - function BufferWhenOperator(closingSelector) { - this.closingSelector = closingSelector; - } - BufferWhenOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector)); - }; - return BufferWhenOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var BufferWhenSubscriber = (function (_super) { - __extends(BufferWhenSubscriber, _super); - function BufferWhenSubscriber(destination, closingSelector) { - _super.call(this, destination); - this.closingSelector = closingSelector; - this.subscribing = false; - this.openBuffer(); - } - BufferWhenSubscriber.prototype._next = function (value) { - this.buffer.push(value); - }; - BufferWhenSubscriber.prototype._complete = function () { - var buffer = this.buffer; - if (buffer) { - this.destination.next(buffer); - } - _super.prototype._complete.call(this); - }; - BufferWhenSubscriber.prototype._unsubscribe = function () { - this.buffer = null; - this.subscribing = false; - }; - BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.openBuffer(); - }; - BufferWhenSubscriber.prototype.notifyComplete = function () { - if (this.subscribing) { - this.complete(); - } - else { - this.openBuffer(); - } - }; - BufferWhenSubscriber.prototype.openBuffer = function () { - var closingSubscription = this.closingSubscription; - if (closingSubscription) { - this.remove(closingSubscription); - closingSubscription.unsubscribe(); - } - var buffer = this.buffer; - if (this.buffer) { - this.destination.next(buffer); - } - this.buffer = []; - var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)(); - if (closingNotifier === errorObject_1.errorObject) { - this.error(errorObject_1.errorObject.e); - } - else { - closingSubscription = new Subscription_1.Subscription(); - this.closingSubscription = closingSubscription; - this.add(closingSubscription); - this.subscribing = true; - closingSubscription.add(subscribeToResult_1.subscribeToResult(this, closingNotifier)); - this.subscribing = false; - } - }; - return BufferWhenSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=bufferWhen.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var timer_1 = __webpack_require__(199); +Observable_1.Observable.timer = timer_1.timer; +//# sourceMappingURL=timer.js.map + +/***/ }), /* 199 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var catch_1 = __webpack_require__(200); - Observable_1.Observable.prototype.catch = catch_1._catch; - Observable_1.Observable.prototype._catch = catch_1._catch; - //# sourceMappingURL=catch.js.map +"use strict"; -/***/ }, +var TimerObservable_1 = __webpack_require__(200); +exports.timer = TimerObservable_1.TimerObservable.create; +//# sourceMappingURL=timer.js.map + +/***/ }), /* 200 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Catches errors on the observable to be handled by returning a new observable or throwing an error. - * - * - * - * @example Continues with a different Observable when there's an error - * - * Observable.of(1, 2, 3, 4, 5) - * .map(n => { - * if (n == 4) { - * throw 'four!'; - * } - * return n; - * }) - * .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V')) - * .subscribe(x => console.log(x)); - * // 1, 2, 3, I, II, III, IV, V - * - * @example Retries the caught source Observable again in case of error, similar to retry() operator - * - * Observable.of(1, 2, 3, 4, 5) - * .map(n => { - * if (n === 4) { - * throw 'four!'; - * } - * return n; - * }) - * .catch((err, caught) => caught) - * .take(30) - * .subscribe(x => console.log(x)); - * // 1, 2, 3, 1, 2, 3, ... - * - * @example Throws a new error when the source Observable throws an error - * - * Observable.of(1, 2, 3, 4, 5) - * .map(n => { - * if (n == 4) { - * throw 'four!'; - * } - * return n; - * }) - * .catch(err => { - * throw 'error in source. Details: ' + err; - * }) - * .subscribe( - * x => console.log(x), - * err => console.log(err) - * ); - * // 1, 2, 3, error in source. Details: four! - * - * @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which - * is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable - * is returned by the `selector` will be used to continue the observable chain. - * @return {Observable} An observable that originates from either the source or the observable returned by the - * catch `selector` function. - * @method catch - * @name catch - * @owner Observable - */ - function _catch(selector) { - var operator = new CatchOperator(selector); - var caught = this.lift(operator); - return (operator.caught = caught); - } - exports._catch = _catch; - var CatchOperator = (function () { - function CatchOperator(selector) { - this.selector = selector; - } - CatchOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught)); - }; - return CatchOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var CatchSubscriber = (function (_super) { - __extends(CatchSubscriber, _super); - function CatchSubscriber(destination, selector, caught) { - _super.call(this, destination); - this.selector = selector; - this.caught = caught; - } - // NOTE: overriding `error` instead of `_error` because we don't want - // to have this flag this subscriber as `isStopped`. We can mimic the - // behavior of the RetrySubscriber (from the `retry` operator), where - // we unsubscribe from our source chain, reset our Subscriber flags, - // then subscribe to the selector result. - CatchSubscriber.prototype.error = function (err) { - if (!this.isStopped) { - var result = void 0; - try { - result = this.selector(err, this.caught); - } - catch (err2) { - _super.prototype.error.call(this, err2); - return; - } - this._unsubscribeAndRecycle(); - this.add(subscribeToResult_1.subscribeToResult(this, result)); - } - }; - return CatchSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=catch.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 isNumeric_1 = __webpack_require__(34); +var Observable_1 = __webpack_require__(0); +var async_1 = __webpack_require__(9); +var isScheduler_1 = __webpack_require__(14); +var isDate_1 = __webpack_require__(35); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var TimerObservable = (function (_super) { + __extends(TimerObservable, _super); + function TimerObservable(dueTime, period, scheduler) { + if (dueTime === void 0) { dueTime = 0; } + _super.call(this); + this.period = -1; + this.dueTime = 0; + if (isNumeric_1.isNumeric(period)) { + this.period = Number(period) < 1 && 1 || Number(period); + } + else if (isScheduler_1.isScheduler(period)) { + scheduler = period; + } + if (!isScheduler_1.isScheduler(scheduler)) { + scheduler = async_1.async; + } + this.scheduler = scheduler; + this.dueTime = isDate_1.isDate(dueTime) ? + (+dueTime - this.scheduler.now()) : + dueTime; + } + /** + * Creates an Observable that starts emitting after an `initialDelay` and + * emits ever increasing numbers after each `period` of time thereafter. + * + * Its like {@link interval}, but you can specify when + * should the emissions start. + * + * + * + * `timer` returns an Observable that emits an infinite sequence of ascending + * integers, with a constant interval of time, `period` of your choosing + * between those emissions. The first emission happens after the specified + * `initialDelay`. The initial delay may be a {@link Date}. By default, this + * operator uses the `async` IScheduler to provide a notion of time, but you + * may pass any IScheduler to it. If `period` is not specified, the output + * Observable emits only one value, `0`. Otherwise, it emits an infinite + * sequence. + * + * @example Emits ascending numbers, one every second (1000ms), starting after 3 seconds + * var numbers = Rx.Observable.timer(3000, 1000); + * numbers.subscribe(x => console.log(x)); + * + * @example Emits one number after five seconds + * var numbers = Rx.Observable.timer(5000); + * numbers.subscribe(x => console.log(x)); + * + * @see {@link interval} + * @see {@link delay} + * + * @param {number|Date} initialDelay The initial delay time to wait before + * emitting the first value of `0`. + * @param {number} [period] The period of time between emissions of the + * subsequent numbers. + * @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling + * the emission of values, and providing a notion of "time". + * @return {Observable} An Observable that emits a `0` after the + * `initialDelay` and ever increasing numbers after each `period` of time + * thereafter. + * @static true + * @name timer + * @owner Observable + */ + TimerObservable.create = function (initialDelay, period, scheduler) { + if (initialDelay === void 0) { initialDelay = 0; } + return new TimerObservable(initialDelay, period, scheduler); + }; + TimerObservable.dispatch = function (state) { + var index = state.index, period = state.period, subscriber = state.subscriber; + var action = this; + subscriber.next(index); + if (subscriber.closed) { + return; + } + else if (period === -1) { + return subscriber.complete(); + } + state.index = index + 1; + action.schedule(state, period); + }; + TimerObservable.prototype._subscribe = function (subscriber) { + var index = 0; + var _a = this, period = _a.period, dueTime = _a.dueTime, scheduler = _a.scheduler; + return scheduler.schedule(TimerObservable.dispatch, dueTime, { + index: index, period: period, subscriber: subscriber + }); + }; + return TimerObservable; +}(Observable_1.Observable)); +exports.TimerObservable = TimerObservable; +//# sourceMappingURL=TimerObservable.js.map + +/***/ }), /* 201 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var combineAll_1 = __webpack_require__(202); - Observable_1.Observable.prototype.combineAll = combineAll_1.combineAll; - //# sourceMappingURL=combineAll.js.map +var Observable_1 = __webpack_require__(0); +var zip_1 = __webpack_require__(202); +Observable_1.Observable.zip = zip_1.zip; +//# sourceMappingURL=zip.js.map -/***/ }, +/***/ }), /* 202 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var combineLatest_1 = __webpack_require__(93); - /** - * Converts a higher-order Observable into a first-order Observable by waiting - * for the outer Observable to complete, then applying {@link combineLatest}. - * - * Flattens an Observable-of-Observables by applying - * {@link combineLatest} when the Observable-of-Observables completes. - * - * - * - * Takes an Observable of Observables, and collects all Observables from it. - * Once the outer Observable completes, it subscribes to all collected - * Observables and combines their values using the {@link combineLatest} - * strategy, such that: - * - Every time an inner Observable emits, the output Observable emits. - * - When the returned observable emits, it emits all of the latest values by: - * - If a `project` function is provided, it is called with each recent value - * from each inner Observable in whatever order they arrived, and the result - * of the `project` function is what is emitted by the output Observable. - * - If there is no `project` function, an array of all of the most recent - * values is emitted by the output Observable. - * - * @example Map two click events to a finite interval Observable, then apply combineAll - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var higherOrder = clicks.map(ev => - * Rx.Observable.interval(Math.random()*2000).take(3) - * ).take(2); - * var result = higherOrder.combineAll(); - * result.subscribe(x => console.log(x)); - * - * @see {@link combineLatest} - * @see {@link mergeAll} - * - * @param {function} [project] An optional function to map the most recent - * values from each inner Observable into a new result. Takes each of the most - * recent values from each collected inner Observable as arguments, in order. - * @return {Observable} An Observable of projected results or arrays of recent - * values. - * @method combineAll - * @owner Observable - */ - function combineAll(project) { - return this.lift(new combineLatest_1.CombineLatestOperator(project)); - } - exports.combineAll = combineAll; - //# sourceMappingURL=combineAll.js.map +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; -/***/ }, +var zip_1 = __webpack_require__(47); +exports.zip = zip_1.zipStatic; +//# sourceMappingURL=zip.js.map + +/***/ }), /* 203 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var combineLatest_1 = __webpack_require__(93); - Observable_1.Observable.prototype.combineLatest = combineLatest_1.combineLatest; - //# sourceMappingURL=combineLatest.js.map +var Observable_1 = __webpack_require__(0); +var ajax_1 = __webpack_require__(204); +Observable_1.Observable.ajax = ajax_1.ajax; +//# sourceMappingURL=ajax.js.map -/***/ }, +/***/ }), /* 204 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var concat_1 = __webpack_require__(102); - Observable_1.Observable.prototype.concat = concat_1.concat; - //# sourceMappingURL=concat.js.map +var AjaxObservable_1 = __webpack_require__(71); +exports.ajax = AjaxObservable_1.AjaxObservable.create; +//# sourceMappingURL=ajax.js.map -/***/ }, +/***/ }), /* 205 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var concatAll_1 = __webpack_require__(206); - Observable_1.Observable.prototype.concatAll = concatAll_1.concatAll; - //# sourceMappingURL=concatAll.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var webSocket_1 = __webpack_require__(206); +Observable_1.Observable.webSocket = webSocket_1.webSocket; +//# sourceMappingURL=webSocket.js.map + +/***/ }), /* 206 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var mergeAll_1 = __webpack_require__(103); - /* tslint:enable:max-line-length */ - /** - * Converts a higher-order Observable into a first-order Observable by - * concatenating the inner Observables in order. - * - * Flattens an Observable-of-Observables by putting one - * inner Observable after the other. - * - * - * - * Joins every Observable emitted by the source (a higher-order Observable), in - * a serial fashion. It subscribes to each inner Observable only after the - * previous inner Observable has completed, and merges all of their values into - * the returned observable. - * - * __Warning:__ If the source Observable emits Observables quickly and - * endlessly, and the inner Observables it emits generally complete slower than - * the source emits, you can run into memory issues as the incoming Observables - * collect in an unbounded buffer. - * - * Note: `concatAll` is equivalent to `mergeAll` with concurrency parameter set - * to `1`. - * - * @example For each click event, tick every second from 0 to 3, with no concurrency - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var higherOrder = clicks.map(ev => Rx.Observable.interval(1000).take(4)); - * var firstOrder = higherOrder.concatAll(); - * firstOrder.subscribe(x => console.log(x)); - * - * // Results in the following: - * // (results are not concurrent) - * // For every click on the "document" it will emit values 0 to 3 spaced - * // on a 1000ms interval - * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 - * - * @see {@link combineAll} - * @see {@link concat} - * @see {@link concatMap} - * @see {@link concatMapTo} - * @see {@link exhaust} - * @see {@link mergeAll} - * @see {@link switch} - * @see {@link zipAll} - * - * @return {Observable} An Observable emitting values from all the inner - * Observables concatenated. - * @method concatAll - * @owner Observable - */ - function concatAll() { - return this.lift(new mergeAll_1.MergeAllOperator(1)); - } - exports.concatAll = concatAll; - //# sourceMappingURL=concatAll.js.map +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 207 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var concatMap_1 = __webpack_require__(208); - Observable_1.Observable.prototype.concatMap = concatMap_1.concatMap; - //# sourceMappingURL=concatMap.js.map +var WebSocketSubject_1 = __webpack_require__(207); +exports.webSocket = WebSocketSubject_1.WebSocketSubject.create; +//# sourceMappingURL=webSocket.js.map -/***/ }, +/***/ }), +/* 207 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subject_1 = __webpack_require__(5); +var Subscriber_1 = __webpack_require__(1); +var Observable_1 = __webpack_require__(0); +var Subscription_1 = __webpack_require__(4); +var root_1 = __webpack_require__(7); +var ReplaySubject_1 = __webpack_require__(36); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var assign_1 = __webpack_require__(210); +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +var WebSocketSubject = (function (_super) { + __extends(WebSocketSubject, _super); + function WebSocketSubject(urlConfigOrSource, destination) { + if (urlConfigOrSource instanceof Observable_1.Observable) { + _super.call(this, destination, urlConfigOrSource); + } + else { + _super.call(this); + this.WebSocketCtor = root_1.root.WebSocket; + this._output = new Subject_1.Subject(); + if (typeof urlConfigOrSource === 'string') { + this.url = urlConfigOrSource; + } + else { + // WARNING: config object could override important members here. + assign_1.assign(this, urlConfigOrSource); + } + if (!this.WebSocketCtor) { + throw new Error('no WebSocket constructor can be found'); + } + this.destination = new ReplaySubject_1.ReplaySubject(); + } + } + WebSocketSubject.prototype.resultSelector = function (e) { + return JSON.parse(e.data); + }; + /** + * Wrapper around the w3c-compatible WebSocket object provided by the browser. + * + * @example Wraps browser WebSocket + * + * let socket$ = Observable.webSocket('ws://localhost:8081'); + * + * socket$.subscribe( + * (msg) => console.log('message received: ' + msg), + * (err) => console.log(err), + * () => console.log('complete') + * ); + * + * socket$.next(JSON.stringify({ op: 'hello' })); + * + * @example Wraps WebSocket from nodejs-websocket (using node.js) + * + * import { w3cwebsocket } from 'websocket'; + * + * let socket$ = Observable.webSocket({ + * url: 'ws://localhost:8081', + * WebSocketCtor: w3cwebsocket + * }); + * + * socket$.subscribe( + * (msg) => console.log('message received: ' + msg), + * (err) => console.log(err), + * () => console.log('complete') + * ); + * + * socket$.next(JSON.stringify({ op: 'hello' })); + * + * @param {string | WebSocketSubjectConfig} urlConfigOrSource the source of the websocket as an url or a structure defining the websocket object + * @return {WebSocketSubject} + * @static true + * @name webSocket + * @owner Observable + */ + WebSocketSubject.create = function (urlConfigOrSource) { + return new WebSocketSubject(urlConfigOrSource); + }; + WebSocketSubject.prototype.lift = function (operator) { + var sock = new WebSocketSubject(this, this.destination); + sock.operator = operator; + return sock; + }; + WebSocketSubject.prototype._resetState = function () { + this.socket = null; + if (!this.source) { + this.destination = new ReplaySubject_1.ReplaySubject(); + } + this._output = new Subject_1.Subject(); + }; + // TODO: factor this out to be a proper Operator/Subscriber implementation and eliminate closures + WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) { + var self = this; + return new Observable_1.Observable(function (observer) { + var result = tryCatch_1.tryCatch(subMsg)(); + if (result === errorObject_1.errorObject) { + observer.error(errorObject_1.errorObject.e); + } + else { + self.next(result); + } + var subscription = self.subscribe(function (x) { + var result = tryCatch_1.tryCatch(messageFilter)(x); + if (result === errorObject_1.errorObject) { + observer.error(errorObject_1.errorObject.e); + } + else if (result) { + observer.next(x); + } + }, function (err) { return observer.error(err); }, function () { return observer.complete(); }); + return function () { + var result = tryCatch_1.tryCatch(unsubMsg)(); + if (result === errorObject_1.errorObject) { + observer.error(errorObject_1.errorObject.e); + } + else { + self.next(result); + } + subscription.unsubscribe(); + }; + }); + }; + WebSocketSubject.prototype._connectSocket = function () { + var _this = this; + var WebSocketCtor = this.WebSocketCtor; + var observer = this._output; + var socket = null; + try { + socket = this.protocol ? + new WebSocketCtor(this.url, this.protocol) : + new WebSocketCtor(this.url); + this.socket = socket; + if (this.binaryType) { + this.socket.binaryType = this.binaryType; + } + } + catch (e) { + observer.error(e); + return; + } + var subscription = new Subscription_1.Subscription(function () { + _this.socket = null; + if (socket && socket.readyState === 1) { + socket.close(); + } + }); + socket.onopen = function (e) { + var openObserver = _this.openObserver; + if (openObserver) { + openObserver.next(e); + } + var queue = _this.destination; + _this.destination = Subscriber_1.Subscriber.create(function (x) { return socket.readyState === 1 && socket.send(x); }, function (e) { + var closingObserver = _this.closingObserver; + if (closingObserver) { + closingObserver.next(undefined); + } + if (e && e.code) { + socket.close(e.code, e.reason); + } + else { + observer.error(new TypeError('WebSocketSubject.error must be called with an object with an error code, ' + + 'and an optional reason: { code: number, reason: string }')); + } + _this._resetState(); + }, function () { + var closingObserver = _this.closingObserver; + if (closingObserver) { + closingObserver.next(undefined); + } + socket.close(); + _this._resetState(); + }); + if (queue && queue instanceof ReplaySubject_1.ReplaySubject) { + subscription.add(queue.subscribe(_this.destination)); + } + }; + socket.onerror = function (e) { + _this._resetState(); + observer.error(e); + }; + socket.onclose = function (e) { + _this._resetState(); + var closeObserver = _this.closeObserver; + if (closeObserver) { + closeObserver.next(e); + } + if (e.wasClean) { + observer.complete(); + } + else { + observer.error(e); + } + }; + socket.onmessage = function (e) { + var result = tryCatch_1.tryCatch(_this.resultSelector)(e); + if (result === errorObject_1.errorObject) { + observer.error(errorObject_1.errorObject.e); + } + else { + observer.next(result); + } + }; + }; + WebSocketSubject.prototype._subscribe = function (subscriber) { + var _this = this; + var source = this.source; + if (source) { + return source.subscribe(subscriber); + } + if (!this.socket) { + this._connectSocket(); + } + var subscription = new Subscription_1.Subscription(); + subscription.add(this._output.subscribe(subscriber)); + subscription.add(function () { + var socket = _this.socket; + if (_this._output.observers.length === 0) { + if (socket && socket.readyState === 1) { + socket.close(); + } + _this._resetState(); + } + }); + return subscription; + }; + WebSocketSubject.prototype.unsubscribe = function () { + var _a = this, source = _a.source, socket = _a.socket; + if (socket && socket.readyState === 1) { + socket.close(); + this._resetState(); + } + _super.prototype.unsubscribe.call(this); + if (!source) { + this.destination = new ReplaySubject_1.ReplaySubject(); + } + }; + return WebSocketSubject; +}(Subject_1.AnonymousSubject)); +exports.WebSocketSubject = WebSocketSubject; +//# sourceMappingURL=WebSocketSubject.js.map + +/***/ }), /* 208 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var mergeMap_1 = __webpack_require__(209); - /* tslint:enable:max-line-length */ - /** - * Projects each source value to an Observable which is merged in the output - * Observable, in a serialized fashion waiting for each one to complete before - * merging the next. - * - * Maps each value to an Observable, then flattens all of - * these inner Observables using {@link concatAll}. - * - * - * - * Returns an Observable that emits items based on applying a function that you - * supply to each item emitted by the source Observable, where that function - * returns an (so-called "inner") Observable. Each new inner Observable is - * concatenated with the previous inner Observable. - * - * __Warning:__ if source values arrive endlessly and faster than their - * corresponding inner Observables can complete, it will result in memory issues - * as inner Observables amass in an unbounded buffer waiting for their turn to - * be subscribed to. - * - * Note: `concatMap` is equivalent to `mergeMap` with concurrency parameter set - * to `1`. - * - * @example For each click event, tick every second from 0 to 3, with no concurrency - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.concatMap(ev => Rx.Observable.interval(1000).take(4)); - * result.subscribe(x => console.log(x)); - * - * // Results in the following: - * // (results are not concurrent) - * // For every click on the "document" it will emit values 0 to 3 spaced - * // on a 1000ms interval - * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 - * - * @see {@link concat} - * @see {@link concatAll} - * @see {@link concatMapTo} - * @see {@link exhaustMap} - * @see {@link mergeMap} - * @see {@link switchMap} - * - * @param {function(value: T, ?index: number): ObservableInput} project A function - * that, when applied to an item emitted by the source Observable, returns an - * Observable. - * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] - * A function to produce the value on the output Observable based on the values - * and the indices of the source (outer) emission and the inner Observable - * emission. The arguments passed to this function are: - * - `outerValue`: the value that came from the source - * - `innerValue`: the value that came from the projected Observable - * - `outerIndex`: the "index" of the value that came from the source - * - `innerIndex`: the "index" of the value from the projected Observable - * @return {Observable} An Observable that emits the result of applying the - * projection function (and the optional `resultSelector`) to each item emitted - * by the source Observable and taking values from each projected inner - * Observable sequentially. - * @method concatMap - * @owner Observable - */ - function concatMap(project, resultSelector) { - return this.lift(new mergeMap_1.MergeMapOperator(project, resultSelector, 1)); - } - exports.concatMap = concatMap; - //# sourceMappingURL=concatMap.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 AsyncAction_1 = __webpack_require__(23); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var QueueAction = (function (_super) { + __extends(QueueAction, _super); + function QueueAction(scheduler, work) { + _super.call(this, scheduler, work); + this.scheduler = scheduler; + this.work = work; + } + QueueAction.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + if (delay > 0) { + return _super.prototype.schedule.call(this, state, delay); + } + this.delay = delay; + this.state = state; + this.scheduler.flush(this); + return this; + }; + QueueAction.prototype.execute = function (state, delay) { + return (delay > 0 || this.closed) ? + _super.prototype.execute.call(this, state, delay) : + this._execute(state, delay); + }; + QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + // If delay exists and is greater than 0, or if the delay is null (the + // action wasn't rescheduled) but was originally scheduled as an async + // action, then recycle as an async action. + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); + } + // Otherwise flush the scheduler starting with this action. + return scheduler.flush(this); + }; + return QueueAction; +}(AsyncAction_1.AsyncAction)); +exports.QueueAction = QueueAction; +//# sourceMappingURL=QueueAction.js.map + +/***/ }), /* 209 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 subscribeToResult_1 = __webpack_require__(95); - var OuterSubscriber_1 = __webpack_require__(94); - /* tslint:enable:max-line-length */ - /** - * Projects each source value to an Observable which is merged in the output - * Observable. - * - * Maps each value to an Observable, then flattens all of - * these inner Observables using {@link mergeAll}. - * - * - * - * Returns an Observable that emits items based on applying a function that you - * supply to each item emitted by the source Observable, where that function - * returns an Observable, and then merging those resulting Observables and - * emitting the results of this merger. - * - * @example Map and flatten each letter to an Observable ticking every 1 second - * var letters = Rx.Observable.of('a', 'b', 'c'); - * var result = letters.mergeMap(x => - * Rx.Observable.interval(1000).map(i => x+i) - * ); - * result.subscribe(x => console.log(x)); - * - * // Results in the following: - * // a0 - * // b0 - * // c0 - * // a1 - * // b1 - * // c1 - * // continues to list a,b,c with respective ascending integers - * - * @see {@link concatMap} - * @see {@link exhaustMap} - * @see {@link merge} - * @see {@link mergeAll} - * @see {@link mergeMapTo} - * @see {@link mergeScan} - * @see {@link switchMap} - * - * @param {function(value: T, ?index: number): ObservableInput} project A function - * that, when applied to an item emitted by the source Observable, returns an - * Observable. - * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] - * A function to produce the value on the output Observable based on the values - * and the indices of the source (outer) emission and the inner Observable - * emission. The arguments passed to this function are: - * - `outerValue`: the value that came from the source - * - `innerValue`: the value that came from the projected Observable - * - `outerIndex`: the "index" of the value that came from the source - * - `innerIndex`: the "index" of the value from the projected Observable - * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input - * Observables being subscribed to concurrently. - * @return {Observable} An Observable that emits the result of applying the - * projection function (and the optional `resultSelector`) to each item emitted - * by the source Observable and merging the results of the Observables obtained - * from this transformation. - * @method mergeMap - * @owner Observable - */ - function mergeMap(project, resultSelector, concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - if (typeof resultSelector === 'number') { - concurrent = resultSelector; - resultSelector = null; - } - return this.lift(new MergeMapOperator(project, resultSelector, concurrent)); - } - exports.mergeMap = mergeMap; - var MergeMapOperator = (function () { - function MergeMapOperator(project, resultSelector, concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - this.project = project; - this.resultSelector = resultSelector; - this.concurrent = concurrent; - } - MergeMapOperator.prototype.call = function (observer, source) { - return source.subscribe(new MergeMapSubscriber(observer, this.project, this.resultSelector, this.concurrent)); - }; - return MergeMapOperator; - }()); - exports.MergeMapOperator = MergeMapOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var MergeMapSubscriber = (function (_super) { - __extends(MergeMapSubscriber, _super); - function MergeMapSubscriber(destination, project, resultSelector, concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - _super.call(this, destination); - this.project = project; - this.resultSelector = resultSelector; - this.concurrent = concurrent; - this.hasCompleted = false; - this.buffer = []; - this.active = 0; - this.index = 0; - } - MergeMapSubscriber.prototype._next = function (value) { - if (this.active < this.concurrent) { - this._tryNext(value); - } - else { - this.buffer.push(value); - } - }; - MergeMapSubscriber.prototype._tryNext = function (value) { - var result; - var index = this.index++; - try { - result = this.project(value, index); - } - catch (err) { - this.destination.error(err); - return; - } - this.active++; - this._innerSub(result, value, index); - }; - MergeMapSubscriber.prototype._innerSub = function (ish, value, index) { - this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index)); - }; - MergeMapSubscriber.prototype._complete = function () { - this.hasCompleted = true; - if (this.active === 0 && this.buffer.length === 0) { - this.destination.complete(); - } - }; - MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - if (this.resultSelector) { - this._notifyResultSelector(outerValue, innerValue, outerIndex, innerIndex); - } - else { - this.destination.next(innerValue); - } - }; - MergeMapSubscriber.prototype._notifyResultSelector = function (outerValue, innerValue, outerIndex, innerIndex) { - var result; - try { - result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex); - } - catch (err) { - this.destination.error(err); - return; - } - this.destination.next(result); - }; - MergeMapSubscriber.prototype.notifyComplete = function (innerSub) { - var buffer = this.buffer; - this.remove(innerSub); - this.active--; - if (buffer.length > 0) { - this._next(buffer.shift()); - } - else if (this.active === 0 && this.hasCompleted) { - this.destination.complete(); - } - }; - return MergeMapSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.MergeMapSubscriber = MergeMapSubscriber; - //# sourceMappingURL=mergeMap.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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_1 = __webpack_require__(24); +var QueueScheduler = (function (_super) { + __extends(QueueScheduler, _super); + function QueueScheduler() { + _super.apply(this, arguments); + } + return QueueScheduler; +}(AsyncScheduler_1.AsyncScheduler)); +exports.QueueScheduler = QueueScheduler; +//# sourceMappingURL=QueueScheduler.js.map + +/***/ }), /* 210 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var root_1 = __webpack_require__(7); +function assignImpl(target) { + var sources = []; + for (var _i = 1; _i < arguments.length; _i++) { + sources[_i - 1] = arguments[_i]; + } + var len = sources.length; + for (var i = 0; i < len; i++) { + var source = sources[i]; + for (var k in source) { + if (source.hasOwnProperty(k)) { + target[k] = source[k]; + } + } + } + return target; +} +exports.assignImpl = assignImpl; +; +function getAssign(root) { + return root.Object.assign || assignImpl; +} +exports.getAssign = getAssign; +exports.assign = getAssign(root_1.root); +//# sourceMappingURL=assign.js.map + +/***/ }), +/* 211 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var concatMapTo_1 = __webpack_require__(211); - Observable_1.Observable.prototype.concatMapTo = concatMapTo_1.concatMapTo; - //# sourceMappingURL=concatMapTo.js.map +"use strict"; -/***/ }, -/* 211 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var mergeMapTo_1 = __webpack_require__(212); - /* tslint:enable:max-line-length */ - /** - * Projects each source value to the same Observable which is merged multiple - * times in a serialized fashion on the output Observable. - * - * It's like {@link concatMap}, but maps each value - * always to the same inner Observable. - * - * - * - * Maps each source value to the given Observable `innerObservable` regardless - * of the source value, and then flattens those resulting Observables into one - * single Observable, which is the output Observable. Each new `innerObservable` - * instance emitted on the output Observable is concatenated with the previous - * `innerObservable` instance. - * - * __Warning:__ if source values arrive endlessly and faster than their - * corresponding inner Observables can complete, it will result in memory issues - * as inner Observables amass in an unbounded buffer waiting for their turn to - * be subscribed to. - * - * Note: `concatMapTo` is equivalent to `mergeMapTo` with concurrency parameter - * set to `1`. - * - * @example For each click event, tick every second from 0 to 3, with no concurrency - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.concatMapTo(Rx.Observable.interval(1000).take(4)); - * result.subscribe(x => console.log(x)); - * - * // Results in the following: - * // (results are not concurrent) - * // For every click on the "document" it will emit values 0 to 3 spaced - * // on a 1000ms interval - * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 - * - * @see {@link concat} - * @see {@link concatAll} - * @see {@link concatMap} - * @see {@link mergeMapTo} - * @see {@link switchMapTo} - * - * @param {ObservableInput} innerObservable An Observable to replace each value from - * the source Observable. - * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] - * A function to produce the value on the output Observable based on the values - * and the indices of the source (outer) emission and the inner Observable - * emission. The arguments passed to this function are: - * - `outerValue`: the value that came from the source - * - `innerValue`: the value that came from the projected Observable - * - `outerIndex`: the "index" of the value that came from the source - * - `innerIndex`: the "index" of the value from the projected Observable - * @return {Observable} An observable of values merged together by joining the - * passed observable with itself, one after the other, for each value emitted - * from the source. - * @method concatMapTo - * @owner Observable - */ - function concatMapTo(innerObservable, resultSelector) { - return this.lift(new mergeMapTo_1.MergeMapToOperator(innerObservable, resultSelector, 1)); - } - exports.concatMapTo = concatMapTo; - //# sourceMappingURL=concatMapTo.js.map +var Observable_1 = __webpack_require__(0); +var buffer_1 = __webpack_require__(212); +Observable_1.Observable.prototype.buffer = buffer_1.buffer; +//# sourceMappingURL=buffer.js.map -/***/ }, +/***/ }), /* 212 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /* tslint:enable:max-line-length */ - /** - * Projects each source value to the same Observable which is merged multiple - * times in the output Observable. - * - * It's like {@link mergeMap}, but maps each value always - * to the same inner Observable. - * - * - * - * Maps each source value to the given Observable `innerObservable` regardless - * of the source value, and then merges those resulting Observables into one - * single Observable, which is the output Observable. - * - * @example For each click event, start an interval Observable ticking every 1 second - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.mergeMapTo(Rx.Observable.interval(1000)); - * result.subscribe(x => console.log(x)); - * - * @see {@link concatMapTo} - * @see {@link merge} - * @see {@link mergeAll} - * @see {@link mergeMap} - * @see {@link mergeScan} - * @see {@link switchMapTo} - * - * @param {ObservableInput} innerObservable An Observable to replace each value from - * the source Observable. - * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] - * A function to produce the value on the output Observable based on the values - * and the indices of the source (outer) emission and the inner Observable - * emission. The arguments passed to this function are: - * - `outerValue`: the value that came from the source - * - `innerValue`: the value that came from the projected Observable - * - `outerIndex`: the "index" of the value that came from the source - * - `innerIndex`: the "index" of the value from the projected Observable - * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input - * Observables being subscribed to concurrently. - * @return {Observable} An Observable that emits items from the given - * `innerObservable` (and optionally transformed through `resultSelector`) every - * time a value is emitted on the source Observable. - * @method mergeMapTo - * @owner Observable - */ - function mergeMapTo(innerObservable, resultSelector, concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - if (typeof resultSelector === 'number') { - concurrent = resultSelector; - resultSelector = null; - } - return this.lift(new MergeMapToOperator(innerObservable, resultSelector, concurrent)); - } - exports.mergeMapTo = mergeMapTo; - // TODO: Figure out correct signature here: an Operator, R> - // needs to implement call(observer: Subscriber): Subscriber> - var MergeMapToOperator = (function () { - function MergeMapToOperator(ish, resultSelector, concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - this.ish = ish; - this.resultSelector = resultSelector; - this.concurrent = concurrent; - } - MergeMapToOperator.prototype.call = function (observer, source) { - return source.subscribe(new MergeMapToSubscriber(observer, this.ish, this.resultSelector, this.concurrent)); - }; - return MergeMapToOperator; - }()); - exports.MergeMapToOperator = MergeMapToOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var MergeMapToSubscriber = (function (_super) { - __extends(MergeMapToSubscriber, _super); - function MergeMapToSubscriber(destination, ish, resultSelector, concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - _super.call(this, destination); - this.ish = ish; - this.resultSelector = resultSelector; - this.concurrent = concurrent; - this.hasCompleted = false; - this.buffer = []; - this.active = 0; - this.index = 0; - } - MergeMapToSubscriber.prototype._next = function (value) { - if (this.active < this.concurrent) { - var resultSelector = this.resultSelector; - var index = this.index++; - var ish = this.ish; - var destination = this.destination; - this.active++; - this._innerSub(ish, destination, resultSelector, value, index); - } - else { - this.buffer.push(value); - } - }; - MergeMapToSubscriber.prototype._innerSub = function (ish, destination, resultSelector, value, index) { - this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index)); - }; - MergeMapToSubscriber.prototype._complete = function () { - this.hasCompleted = true; - if (this.active === 0 && this.buffer.length === 0) { - this.destination.complete(); - } - }; - MergeMapToSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; - if (resultSelector) { - this.trySelectResult(outerValue, innerValue, outerIndex, innerIndex); - } - else { - destination.next(innerValue); - } - }; - MergeMapToSubscriber.prototype.trySelectResult = function (outerValue, innerValue, outerIndex, innerIndex) { - var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; - var result; - try { - result = resultSelector(outerValue, innerValue, outerIndex, innerIndex); - } - catch (err) { - destination.error(err); - return; - } - destination.next(result); - }; - MergeMapToSubscriber.prototype.notifyError = function (err) { - this.destination.error(err); - }; - MergeMapToSubscriber.prototype.notifyComplete = function (innerSub) { - var buffer = this.buffer; - this.remove(innerSub); - this.active--; - if (buffer.length > 0) { - this._next(buffer.shift()); - } - else if (this.active === 0 && this.hasCompleted) { - this.destination.complete(); - } - }; - return MergeMapToSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.MergeMapToSubscriber = MergeMapToSubscriber; - //# sourceMappingURL=mergeMapTo.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Buffers the source Observable values until `closingNotifier` emits. + * + * Collects values from the past as an array, and emits + * that array only when another Observable emits. + * + * + * + * Buffers the incoming Observable values until the given `closingNotifier` + * Observable emits a value, at which point it emits the buffer on the output + * Observable and starts a new buffer internally, awaiting the next time + * `closingNotifier` emits. + * + * @example On every click, emit array of most recent interval events + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var interval = Rx.Observable.interval(1000); + * var buffered = interval.buffer(clicks); + * buffered.subscribe(x => console.log(x)); + * + * @see {@link bufferCount} + * @see {@link bufferTime} + * @see {@link bufferToggle} + * @see {@link bufferWhen} + * @see {@link window} + * + * @param {Observable} closingNotifier An Observable that signals the + * buffer to be emitted on the output Observable. + * @return {Observable} An Observable of buffers, which are arrays of + * values. + * @method buffer + * @owner Observable + */ +function buffer(closingNotifier) { + return this.lift(new BufferOperator(closingNotifier)); +} +exports.buffer = buffer; +var BufferOperator = (function () { + function BufferOperator(closingNotifier) { + this.closingNotifier = closingNotifier; + } + BufferOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier)); + }; + return BufferOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var BufferSubscriber = (function (_super) { + __extends(BufferSubscriber, _super); + function BufferSubscriber(destination, closingNotifier) { + _super.call(this, destination); + this.buffer = []; + this.add(subscribeToResult_1.subscribeToResult(this, closingNotifier)); + } + BufferSubscriber.prototype._next = function (value) { + this.buffer.push(value); + }; + BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + var buffer = this.buffer; + this.buffer = []; + this.destination.next(buffer); + }; + return BufferSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=buffer.js.map + +/***/ }), /* 213 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var count_1 = __webpack_require__(214); - Observable_1.Observable.prototype.count = count_1.count; - //# sourceMappingURL=count.js.map +var Observable_1 = __webpack_require__(0); +var bufferCount_1 = __webpack_require__(214); +Observable_1.Observable.prototype.bufferCount = bufferCount_1.bufferCount; +//# sourceMappingURL=bufferCount.js.map -/***/ }, +/***/ }), /* 214 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Counts the number of emissions on the source and emits that number when the - * source completes. - * - * Tells how many values were emitted, when the source - * completes. - * - * - * - * `count` transforms an Observable that emits values into an Observable that - * emits a single value that represents the number of values emitted by the - * source Observable. If the source Observable terminates with an error, `count` - * will pass this error notification along without emitting a value first. If - * the source Observable does not terminate at all, `count` will neither emit - * a value nor terminate. This operator takes an optional `predicate` function - * as argument, in which case the output emission will represent the number of - * source values that matched `true` with the `predicate`. - * - * @example Counts how many seconds have passed before the first click happened - * var seconds = Rx.Observable.interval(1000); - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var secondsBeforeClick = seconds.takeUntil(clicks); - * var result = secondsBeforeClick.count(); - * result.subscribe(x => console.log(x)); - * - * @example Counts how many odd numbers are there between 1 and 7 - * var numbers = Rx.Observable.range(1, 7); - * var result = numbers.count(i => i % 2 === 1); - * result.subscribe(x => console.log(x)); - * - * // Results in: - * // 4 - * - * @see {@link max} - * @see {@link min} - * @see {@link reduce} - * - * @param {function(value: T, i: number, source: Observable): boolean} [predicate] A - * boolean function to select what values are to be counted. It is provided with - * arguments of: - * - `value`: the value from the source Observable. - * - `index`: the (zero-based) "index" of the value from the source Observable. - * - `source`: the source Observable instance itself. - * @return {Observable} An Observable of one number that represents the count as - * described above. - * @method count - * @owner Observable - */ - function count(predicate) { - return this.lift(new CountOperator(predicate, this)); - } - exports.count = count; - var CountOperator = (function () { - function CountOperator(predicate, source) { - this.predicate = predicate; - this.source = source; - } - CountOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source)); - }; - return CountOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var CountSubscriber = (function (_super) { - __extends(CountSubscriber, _super); - function CountSubscriber(destination, predicate, source) { - _super.call(this, destination); - this.predicate = predicate; - this.source = source; - this.count = 0; - this.index = 0; - } - CountSubscriber.prototype._next = function (value) { - if (this.predicate) { - this._tryPredicate(value); - } - else { - this.count++; - } - }; - CountSubscriber.prototype._tryPredicate = function (value) { - var result; - try { - result = this.predicate(value, this.index++, this.source); - } - catch (err) { - this.destination.error(err); - return; - } - if (result) { - this.count++; - } - }; - CountSubscriber.prototype._complete = function () { - this.destination.next(this.count); - this.destination.complete(); - }; - return CountSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=count.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Buffers the source Observable values until the size hits the maximum + * `bufferSize` given. + * + * Collects values from the past as an array, and emits + * that array only when its size reaches `bufferSize`. + * + * + * + * Buffers a number of values from the source Observable by `bufferSize` then + * emits the buffer and clears it, and starts a new buffer each + * `startBufferEvery` values. If `startBufferEvery` is not provided or is + * `null`, then new buffers are started immediately at the start of the source + * and when each buffer closes and is emitted. + * + * @example Emit the last two click events as an array + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var buffered = clicks.bufferCount(2); + * buffered.subscribe(x => console.log(x)); + * + * @example On every click, emit the last two click events as an array + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var buffered = clicks.bufferCount(2, 1); + * buffered.subscribe(x => console.log(x)); + * + * @see {@link buffer} + * @see {@link bufferTime} + * @see {@link bufferToggle} + * @see {@link bufferWhen} + * @see {@link pairwise} + * @see {@link windowCount} + * + * @param {number} bufferSize The maximum size of the buffer emitted. + * @param {number} [startBufferEvery] Interval at which to start a new buffer. + * For example if `startBufferEvery` is `2`, then a new buffer will be started + * on every other value from the source. A new buffer is started at the + * beginning of the source by default. + * @return {Observable} An Observable of arrays of buffered values. + * @method bufferCount + * @owner Observable + */ +function bufferCount(bufferSize, startBufferEvery) { + if (startBufferEvery === void 0) { startBufferEvery = null; } + return this.lift(new BufferCountOperator(bufferSize, startBufferEvery)); +} +exports.bufferCount = bufferCount; +var BufferCountOperator = (function () { + function BufferCountOperator(bufferSize, startBufferEvery) { + this.bufferSize = bufferSize; + this.startBufferEvery = startBufferEvery; + if (!startBufferEvery || bufferSize === startBufferEvery) { + this.subscriberClass = BufferCountSubscriber; + } + else { + this.subscriberClass = BufferSkipCountSubscriber; + } + } + BufferCountOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery)); + }; + return BufferCountOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var BufferCountSubscriber = (function (_super) { + __extends(BufferCountSubscriber, _super); + function BufferCountSubscriber(destination, bufferSize) { + _super.call(this, destination); + this.bufferSize = bufferSize; + this.buffer = []; + } + BufferCountSubscriber.prototype._next = function (value) { + var buffer = this.buffer; + buffer.push(value); + if (buffer.length == this.bufferSize) { + this.destination.next(buffer); + this.buffer = []; + } + }; + BufferCountSubscriber.prototype._complete = function () { + var buffer = this.buffer; + if (buffer.length > 0) { + this.destination.next(buffer); + } + _super.prototype._complete.call(this); + }; + return BufferCountSubscriber; +}(Subscriber_1.Subscriber)); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var BufferSkipCountSubscriber = (function (_super) { + __extends(BufferSkipCountSubscriber, _super); + function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) { + _super.call(this, destination); + this.bufferSize = bufferSize; + this.startBufferEvery = startBufferEvery; + this.buffers = []; + this.count = 0; + } + BufferSkipCountSubscriber.prototype._next = function (value) { + var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count; + this.count++; + if (count % startBufferEvery === 0) { + buffers.push([]); + } + for (var i = buffers.length; i--;) { + var buffer = buffers[i]; + buffer.push(value); + if (buffer.length === bufferSize) { + buffers.splice(i, 1); + this.destination.next(buffer); + } + } + }; + BufferSkipCountSubscriber.prototype._complete = function () { + var _a = this, buffers = _a.buffers, destination = _a.destination; + while (buffers.length > 0) { + var buffer = buffers.shift(); + if (buffer.length > 0) { + destination.next(buffer); + } + } + _super.prototype._complete.call(this); + }; + return BufferSkipCountSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=bufferCount.js.map + +/***/ }), /* 215 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var dematerialize_1 = __webpack_require__(216); - Observable_1.Observable.prototype.dematerialize = dematerialize_1.dematerialize; - //# sourceMappingURL=dematerialize.js.map +var Observable_1 = __webpack_require__(0); +var bufferTime_1 = __webpack_require__(216); +Observable_1.Observable.prototype.bufferTime = bufferTime_1.bufferTime; +//# sourceMappingURL=bufferTime.js.map -/***/ }, +/***/ }), /* 216 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Converts an Observable of {@link Notification} objects into the emissions - * that they represent. - * - * Unwraps {@link Notification} objects as actual `next`, - * `error` and `complete` emissions. The opposite of {@link materialize}. - * - * - * - * `dematerialize` is assumed to operate an Observable that only emits - * {@link Notification} objects as `next` emissions, and does not emit any - * `error`. Such Observable is the output of a `materialize` operation. Those - * notifications are then unwrapped using the metadata they contain, and emitted - * as `next`, `error`, and `complete` on the output Observable. - * - * Use this operator in conjunction with {@link materialize}. - * - * @example Convert an Observable of Notifications to an actual Observable - * var notifA = new Rx.Notification('N', 'A'); - * var notifB = new Rx.Notification('N', 'B'); - * var notifE = new Rx.Notification('E', void 0, - * new TypeError('x.toUpperCase is not a function') - * ); - * var materialized = Rx.Observable.of(notifA, notifB, notifE); - * var upperCase = materialized.dematerialize(); - * upperCase.subscribe(x => console.log(x), e => console.error(e)); - * - * // Results in: - * // A - * // B - * // TypeError: x.toUpperCase is not a function - * - * @see {@link Notification} - * @see {@link materialize} - * - * @return {Observable} An Observable that emits items and notifications - * embedded in Notification objects emitted by the source Observable. - * @method dematerialize - * @owner Observable - */ - function dematerialize() { - return this.lift(new DeMaterializeOperator()); - } - exports.dematerialize = dematerialize; - var DeMaterializeOperator = (function () { - function DeMaterializeOperator() { - } - DeMaterializeOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DeMaterializeSubscriber(subscriber)); - }; - return DeMaterializeOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DeMaterializeSubscriber = (function (_super) { - __extends(DeMaterializeSubscriber, _super); - function DeMaterializeSubscriber(destination) { - _super.call(this, destination); - } - DeMaterializeSubscriber.prototype._next = function (value) { - value.observe(this.destination); - }; - return DeMaterializeSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=dematerialize.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 async_1 = __webpack_require__(9); +var Subscriber_1 = __webpack_require__(1); +var isScheduler_1 = __webpack_require__(14); +/* tslint:enable:max-line-length */ +/** + * Buffers the source Observable values for a specific time period. + * + * Collects values from the past as an array, and emits + * those arrays periodically in time. + * + * + * + * Buffers values from the source for a specific time duration `bufferTimeSpan`. + * Unless the optional argument `bufferCreationInterval` is given, it emits and + * resets the buffer every `bufferTimeSpan` milliseconds. If + * `bufferCreationInterval` is given, this operator opens the buffer every + * `bufferCreationInterval` milliseconds and closes (emits and resets) the + * buffer every `bufferTimeSpan` milliseconds. When the optional argument + * `maxBufferSize` is specified, the buffer will be closed either after + * `bufferTimeSpan` milliseconds or when it contains `maxBufferSize` elements. + * + * @example Every second, emit an array of the recent click events + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var buffered = clicks.bufferTime(1000); + * buffered.subscribe(x => console.log(x)); + * + * @example Every 5 seconds, emit the click events from the next 2 seconds + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var buffered = clicks.bufferTime(2000, 5000); + * buffered.subscribe(x => console.log(x)); + * + * @see {@link buffer} + * @see {@link bufferCount} + * @see {@link bufferToggle} + * @see {@link bufferWhen} + * @see {@link windowTime} + * + * @param {number} bufferTimeSpan The amount of time to fill each buffer array. + * @param {number} [bufferCreationInterval] The interval at which to start new + * buffers. + * @param {number} [maxBufferSize] The maximum buffer size. + * @param {Scheduler} [scheduler=async] The scheduler on which to schedule the + * intervals that determine buffer boundaries. + * @return {Observable} An observable of arrays of buffered values. + * @method bufferTime + * @owner Observable + */ +function bufferTime(bufferTimeSpan) { + var length = arguments.length; + var scheduler = async_1.async; + if (isScheduler_1.isScheduler(arguments[arguments.length - 1])) { + scheduler = arguments[arguments.length - 1]; + length--; + } + var bufferCreationInterval = null; + if (length >= 2) { + bufferCreationInterval = arguments[1]; + } + var maxBufferSize = Number.POSITIVE_INFINITY; + if (length >= 3) { + maxBufferSize = arguments[2]; + } + return this.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler)); +} +exports.bufferTime = bufferTime; +var BufferTimeOperator = (function () { + function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) { + this.bufferTimeSpan = bufferTimeSpan; + this.bufferCreationInterval = bufferCreationInterval; + this.maxBufferSize = maxBufferSize; + this.scheduler = scheduler; + } + BufferTimeOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler)); + }; + return BufferTimeOperator; +}()); +var Context = (function () { + function Context() { + this.buffer = []; + } + return Context; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var BufferTimeSubscriber = (function (_super) { + __extends(BufferTimeSubscriber, _super); + function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) { + _super.call(this, destination); + this.bufferTimeSpan = bufferTimeSpan; + this.bufferCreationInterval = bufferCreationInterval; + this.maxBufferSize = maxBufferSize; + this.scheduler = scheduler; + this.contexts = []; + var context = this.openContext(); + this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0; + if (this.timespanOnly) { + var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan }; + this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState)); + } + else { + var closeState = { subscriber: this, context: context }; + var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: this, scheduler: scheduler }; + this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState)); + this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState)); + } + } + BufferTimeSubscriber.prototype._next = function (value) { + var contexts = this.contexts; + var len = contexts.length; + var filledBufferContext; + for (var i = 0; i < len; i++) { + var context = contexts[i]; + var buffer = context.buffer; + buffer.push(value); + if (buffer.length == this.maxBufferSize) { + filledBufferContext = context; + } + } + if (filledBufferContext) { + this.onBufferFull(filledBufferContext); + } + }; + BufferTimeSubscriber.prototype._error = function (err) { + this.contexts.length = 0; + _super.prototype._error.call(this, err); + }; + BufferTimeSubscriber.prototype._complete = function () { + var _a = this, contexts = _a.contexts, destination = _a.destination; + while (contexts.length > 0) { + var context = contexts.shift(); + destination.next(context.buffer); + } + _super.prototype._complete.call(this); + }; + BufferTimeSubscriber.prototype._unsubscribe = function () { + this.contexts = null; + }; + BufferTimeSubscriber.prototype.onBufferFull = function (context) { + this.closeContext(context); + var closeAction = context.closeAction; + closeAction.unsubscribe(); + this.remove(closeAction); + if (!this.closed && this.timespanOnly) { + context = this.openContext(); + var bufferTimeSpan = this.bufferTimeSpan; + var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan }; + this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState)); + } + }; + BufferTimeSubscriber.prototype.openContext = function () { + var context = new Context(); + this.contexts.push(context); + return context; + }; + BufferTimeSubscriber.prototype.closeContext = function (context) { + this.destination.next(context.buffer); + var contexts = this.contexts; + var spliceIndex = contexts ? contexts.indexOf(context) : -1; + if (spliceIndex >= 0) { + contexts.splice(contexts.indexOf(context), 1); + } + }; + return BufferTimeSubscriber; +}(Subscriber_1.Subscriber)); +function dispatchBufferTimeSpanOnly(state) { + var subscriber = state.subscriber; + var prevContext = state.context; + if (prevContext) { + subscriber.closeContext(prevContext); + } + if (!subscriber.closed) { + state.context = subscriber.openContext(); + state.context.closeAction = this.schedule(state, state.bufferTimeSpan); + } +} +function dispatchBufferCreation(state) { + var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler; + var context = subscriber.openContext(); + var action = this; + if (!subscriber.closed) { + subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context })); + action.schedule(state, bufferCreationInterval); + } +} +function dispatchBufferClose(arg) { + var subscriber = arg.subscriber, context = arg.context; + subscriber.closeContext(context); +} +//# sourceMappingURL=bufferTime.js.map + +/***/ }), /* 217 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var debounce_1 = __webpack_require__(218); - Observable_1.Observable.prototype.debounce = debounce_1.debounce; - //# sourceMappingURL=debounce.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var bufferToggle_1 = __webpack_require__(218); +Observable_1.Observable.prototype.bufferToggle = bufferToggle_1.bufferToggle; +//# sourceMappingURL=bufferToggle.js.map + +/***/ }), /* 218 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Emits a value from the source Observable only after a particular time span - * determined by another Observable has passed without another source emission. - * - * It's like {@link debounceTime}, but the time span of - * emission silence is determined by a second Observable. - * - * - * - * `debounce` delays values emitted by the source Observable, but drops previous - * pending delayed emissions if a new value arrives on the source Observable. - * This operator keeps track of the most recent value from the source - * Observable, and spawns a duration Observable by calling the - * `durationSelector` function. The value is emitted only when the duration - * Observable emits a value or completes, and if no other value was emitted on - * the source Observable since the duration Observable was spawned. If a new - * value appears before the duration Observable emits, the previous value will - * be dropped and will not be emitted on the output Observable. - * - * Like {@link debounceTime}, this is a rate-limiting operator, and also a - * delay-like operator since output emissions do not necessarily occur at the - * same time as they did on the source Observable. - * - * @example Emit the most recent click after a burst of clicks - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.debounce(() => Rx.Observable.interval(1000)); - * result.subscribe(x => console.log(x)); - * - * @see {@link audit} - * @see {@link debounceTime} - * @see {@link delayWhen} - * @see {@link throttle} - * - * @param {function(value: T): SubscribableOrPromise} durationSelector A function - * that receives a value from the source Observable, for computing the timeout - * duration for each source value, returned as an Observable or a Promise. - * @return {Observable} An Observable that delays the emissions of the source - * Observable by the specified duration Observable returned by - * `durationSelector`, and may drop some values if they occur too frequently. - * @method debounce - * @owner Observable - */ - function debounce(durationSelector) { - return this.lift(new DebounceOperator(durationSelector)); - } - exports.debounce = debounce; - var DebounceOperator = (function () { - function DebounceOperator(durationSelector) { - this.durationSelector = durationSelector; - } - DebounceOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector)); - }; - return DebounceOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DebounceSubscriber = (function (_super) { - __extends(DebounceSubscriber, _super); - function DebounceSubscriber(destination, durationSelector) { - _super.call(this, destination); - this.durationSelector = durationSelector; - this.hasValue = false; - this.durationSubscription = null; - } - DebounceSubscriber.prototype._next = function (value) { - try { - var result = this.durationSelector.call(this, value); - if (result) { - this._tryNext(value, result); - } - } - catch (err) { - this.destination.error(err); - } - }; - DebounceSubscriber.prototype._complete = function () { - this.emitValue(); - this.destination.complete(); - }; - DebounceSubscriber.prototype._tryNext = function (value, duration) { - var subscription = this.durationSubscription; - this.value = value; - this.hasValue = true; - if (subscription) { - subscription.unsubscribe(); - this.remove(subscription); - } - subscription = subscribeToResult_1.subscribeToResult(this, duration); - if (!subscription.closed) { - this.add(this.durationSubscription = subscription); - } - }; - DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.emitValue(); - }; - DebounceSubscriber.prototype.notifyComplete = function () { - this.emitValue(); - }; - DebounceSubscriber.prototype.emitValue = function () { - if (this.hasValue) { - var value = this.value; - var subscription = this.durationSubscription; - if (subscription) { - this.durationSubscription = null; - subscription.unsubscribe(); - this.remove(subscription); - } - this.value = null; - this.hasValue = false; - _super.prototype._next.call(this, value); - } - }; - return DebounceSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=debounce.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscription_1 = __webpack_require__(4); +var subscribeToResult_1 = __webpack_require__(3); +var OuterSubscriber_1 = __webpack_require__(2); +/** + * Buffers the source Observable values starting from an emission from + * `openings` and ending when the output of `closingSelector` emits. + * + * Collects values from the past as an array. Starts + * collecting only when `opening` emits, and calls the `closingSelector` + * function to get an Observable that tells when to close the buffer. + * + * + * + * Buffers values from the source by opening the buffer via signals from an + * Observable provided to `openings`, and closing and sending the buffers when + * a Subscribable or Promise returned by the `closingSelector` function emits. + * + * @example Every other second, emit the click events from the next 500ms + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var openings = Rx.Observable.interval(1000); + * var buffered = clicks.bufferToggle(openings, i => + * i % 2 ? Rx.Observable.interval(500) : Rx.Observable.empty() + * ); + * buffered.subscribe(x => console.log(x)); + * + * @see {@link buffer} + * @see {@link bufferCount} + * @see {@link bufferTime} + * @see {@link bufferWhen} + * @see {@link windowToggle} + * + * @param {SubscribableOrPromise} openings A Subscribable or Promise of notifications to start new + * buffers. + * @param {function(value: O): SubscribableOrPromise} closingSelector A function that takes + * the value emitted by the `openings` observable and returns a Subscribable or Promise, + * which, when it emits, signals that the associated buffer should be emitted + * and cleared. + * @return {Observable} An observable of arrays of buffered values. + * @method bufferToggle + * @owner Observable + */ +function bufferToggle(openings, closingSelector) { + return this.lift(new BufferToggleOperator(openings, closingSelector)); +} +exports.bufferToggle = bufferToggle; +var BufferToggleOperator = (function () { + function BufferToggleOperator(openings, closingSelector) { + this.openings = openings; + this.closingSelector = closingSelector; + } + BufferToggleOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector)); + }; + return BufferToggleOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var BufferToggleSubscriber = (function (_super) { + __extends(BufferToggleSubscriber, _super); + function BufferToggleSubscriber(destination, openings, closingSelector) { + _super.call(this, destination); + this.openings = openings; + this.closingSelector = closingSelector; + this.contexts = []; + this.add(subscribeToResult_1.subscribeToResult(this, openings)); + } + BufferToggleSubscriber.prototype._next = function (value) { + var contexts = this.contexts; + var len = contexts.length; + for (var i = 0; i < len; i++) { + contexts[i].buffer.push(value); + } + }; + BufferToggleSubscriber.prototype._error = function (err) { + var contexts = this.contexts; + while (contexts.length > 0) { + var context = contexts.shift(); + context.subscription.unsubscribe(); + context.buffer = null; + context.subscription = null; + } + this.contexts = null; + _super.prototype._error.call(this, err); + }; + BufferToggleSubscriber.prototype._complete = function () { + var contexts = this.contexts; + while (contexts.length > 0) { + var context = contexts.shift(); + this.destination.next(context.buffer); + context.subscription.unsubscribe(); + context.buffer = null; + context.subscription = null; + } + this.contexts = null; + _super.prototype._complete.call(this); + }; + BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue); + }; + BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) { + this.closeBuffer(innerSub.context); + }; + BufferToggleSubscriber.prototype.openBuffer = function (value) { + try { + var closingSelector = this.closingSelector; + var closingNotifier = closingSelector.call(this, value); + if (closingNotifier) { + this.trySubscribe(closingNotifier); + } + } + catch (err) { + this._error(err); + } + }; + BufferToggleSubscriber.prototype.closeBuffer = function (context) { + var contexts = this.contexts; + if (contexts && context) { + var buffer = context.buffer, subscription = context.subscription; + this.destination.next(buffer); + contexts.splice(contexts.indexOf(context), 1); + this.remove(subscription); + subscription.unsubscribe(); + } + }; + BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) { + var contexts = this.contexts; + var buffer = []; + var subscription = new Subscription_1.Subscription(); + var context = { buffer: buffer, subscription: subscription }; + contexts.push(context); + var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context); + if (!innerSubscription || innerSubscription.closed) { + this.closeBuffer(context); + } + else { + innerSubscription.context = context; + this.add(innerSubscription); + subscription.add(innerSubscription); + } + }; + return BufferToggleSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=bufferToggle.js.map + +/***/ }), /* 219 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var debounceTime_1 = __webpack_require__(220); - Observable_1.Observable.prototype.debounceTime = debounceTime_1.debounceTime; - //# sourceMappingURL=debounceTime.js.map +"use strict"; -/***/ }, -/* 220 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var async_1 = __webpack_require__(138); - /** - * Emits a value from the source Observable only after a particular time span - * has passed without another source emission. - * - * It's like {@link delay}, but passes only the most - * recent value from each burst of emissions. - * - * - * - * `debounceTime` delays values emitted by the source Observable, but drops - * previous pending delayed emissions if a new value arrives on the source - * Observable. This operator keeps track of the most recent value from the - * source Observable, and emits that only when `dueTime` enough time has passed - * without any other value appearing on the source Observable. If a new value - * appears before `dueTime` silence occurs, the previous value will be dropped - * and will not be emitted on the output Observable. - * - * This is a rate-limiting operator, because it is impossible for more than one - * value to be emitted in any time window of duration `dueTime`, but it is also - * a delay-like operator since output emissions do not occur at the same time as - * they did on the source Observable. Optionally takes a {@link IScheduler} for - * managing timers. - * - * @example Emit the most recent click after a burst of clicks - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.debounceTime(1000); - * result.subscribe(x => console.log(x)); - * - * @see {@link auditTime} - * @see {@link debounce} - * @see {@link delay} - * @see {@link sampleTime} - * @see {@link throttleTime} - * - * @param {number} dueTime The timeout duration in milliseconds (or the time - * unit determined internally by the optional `scheduler`) for the window of - * time required to wait for emission silence before emitting the most recent - * source value. - * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for - * managing the timers that handle the timeout for each value. - * @return {Observable} An Observable that delays the emissions of the source - * Observable by the specified `dueTime`, and may drop some values if they occur - * too frequently. - * @method debounceTime - * @owner Observable - */ - function debounceTime(dueTime, scheduler) { - if (scheduler === void 0) { scheduler = async_1.async; } - return this.lift(new DebounceTimeOperator(dueTime, scheduler)); - } - exports.debounceTime = debounceTime; - var DebounceTimeOperator = (function () { - function DebounceTimeOperator(dueTime, scheduler) { - this.dueTime = dueTime; - this.scheduler = scheduler; - } - DebounceTimeOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler)); - }; - return DebounceTimeOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DebounceTimeSubscriber = (function (_super) { - __extends(DebounceTimeSubscriber, _super); - function DebounceTimeSubscriber(destination, dueTime, scheduler) { - _super.call(this, destination); - this.dueTime = dueTime; - this.scheduler = scheduler; - this.debouncedSubscription = null; - this.lastValue = null; - this.hasValue = false; - } - DebounceTimeSubscriber.prototype._next = function (value) { - this.clearDebounce(); - this.lastValue = value; - this.hasValue = true; - this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this)); - }; - DebounceTimeSubscriber.prototype._complete = function () { - this.debouncedNext(); - this.destination.complete(); - }; - DebounceTimeSubscriber.prototype.debouncedNext = function () { - this.clearDebounce(); - if (this.hasValue) { - this.destination.next(this.lastValue); - this.lastValue = null; - this.hasValue = false; - } - }; - DebounceTimeSubscriber.prototype.clearDebounce = function () { - var debouncedSubscription = this.debouncedSubscription; - if (debouncedSubscription !== null) { - this.remove(debouncedSubscription); - debouncedSubscription.unsubscribe(); - this.debouncedSubscription = null; - } - }; - return DebounceTimeSubscriber; - }(Subscriber_1.Subscriber)); - function dispatchNext(subscriber) { - subscriber.debouncedNext(); - } - //# sourceMappingURL=debounceTime.js.map +var Observable_1 = __webpack_require__(0); +var bufferWhen_1 = __webpack_require__(220); +Observable_1.Observable.prototype.bufferWhen = bufferWhen_1.bufferWhen; +//# sourceMappingURL=bufferWhen.js.map -/***/ }, +/***/ }), +/* 220 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscription_1 = __webpack_require__(4); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Buffers the source Observable values, using a factory function of closing + * Observables to determine when to close, emit, and reset the buffer. + * + * Collects values from the past as an array. When it + * starts collecting values, it calls a function that returns an Observable that + * tells when to close the buffer and restart collecting. + * + * + * + * Opens a buffer immediately, then closes the buffer when the observable + * returned by calling `closingSelector` function emits a value. When it closes + * the buffer, it immediately opens a new buffer and repeats the process. + * + * @example Emit an array of the last clicks every [1-5] random seconds + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var buffered = clicks.bufferWhen(() => + * Rx.Observable.interval(1000 + Math.random() * 4000) + * ); + * buffered.subscribe(x => console.log(x)); + * + * @see {@link buffer} + * @see {@link bufferCount} + * @see {@link bufferTime} + * @see {@link bufferToggle} + * @see {@link windowWhen} + * + * @param {function(): Observable} closingSelector A function that takes no + * arguments and returns an Observable that signals buffer closure. + * @return {Observable} An observable of arrays of buffered values. + * @method bufferWhen + * @owner Observable + */ +function bufferWhen(closingSelector) { + return this.lift(new BufferWhenOperator(closingSelector)); +} +exports.bufferWhen = bufferWhen; +var BufferWhenOperator = (function () { + function BufferWhenOperator(closingSelector) { + this.closingSelector = closingSelector; + } + BufferWhenOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector)); + }; + return BufferWhenOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var BufferWhenSubscriber = (function (_super) { + __extends(BufferWhenSubscriber, _super); + function BufferWhenSubscriber(destination, closingSelector) { + _super.call(this, destination); + this.closingSelector = closingSelector; + this.subscribing = false; + this.openBuffer(); + } + BufferWhenSubscriber.prototype._next = function (value) { + this.buffer.push(value); + }; + BufferWhenSubscriber.prototype._complete = function () { + var buffer = this.buffer; + if (buffer) { + this.destination.next(buffer); + } + _super.prototype._complete.call(this); + }; + BufferWhenSubscriber.prototype._unsubscribe = function () { + this.buffer = null; + this.subscribing = false; + }; + BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.openBuffer(); + }; + BufferWhenSubscriber.prototype.notifyComplete = function () { + if (this.subscribing) { + this.complete(); + } + else { + this.openBuffer(); + } + }; + BufferWhenSubscriber.prototype.openBuffer = function () { + var closingSubscription = this.closingSubscription; + if (closingSubscription) { + this.remove(closingSubscription); + closingSubscription.unsubscribe(); + } + var buffer = this.buffer; + if (this.buffer) { + this.destination.next(buffer); + } + this.buffer = []; + var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)(); + if (closingNotifier === errorObject_1.errorObject) { + this.error(errorObject_1.errorObject.e); + } + else { + closingSubscription = new Subscription_1.Subscription(); + this.closingSubscription = closingSubscription; + this.add(closingSubscription); + this.subscribing = true; + closingSubscription.add(subscribeToResult_1.subscribeToResult(this, closingNotifier)); + this.subscribing = false; + } + }; + return BufferWhenSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=bufferWhen.js.map + +/***/ }), /* 221 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var defaultIfEmpty_1 = __webpack_require__(222); - Observable_1.Observable.prototype.defaultIfEmpty = defaultIfEmpty_1.defaultIfEmpty; - //# sourceMappingURL=defaultIfEmpty.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var catch_1 = __webpack_require__(222); +Observable_1.Observable.prototype.catch = catch_1._catch; +Observable_1.Observable.prototype._catch = catch_1._catch; +//# sourceMappingURL=catch.js.map + +/***/ }), /* 222 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /* tslint:enable:max-line-length */ - /** - * Emits a given value if the source Observable completes without emitting any - * `next` value, otherwise mirrors the source Observable. - * - * If the source Observable turns out to be empty, then - * this operator will emit a default value. - * - * - * - * `defaultIfEmpty` emits the values emitted by the source Observable or a - * specified default value if the source Observable is empty (completes without - * having emitted any `next` value). - * - * @example If no clicks happen in 5 seconds, then emit "no clicks" - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000)); - * var result = clicksBeforeFive.defaultIfEmpty('no clicks'); - * result.subscribe(x => console.log(x)); - * - * @see {@link empty} - * @see {@link last} - * - * @param {any} [defaultValue=null] The default value used if the source - * Observable is empty. - * @return {Observable} An Observable that emits either the specified - * `defaultValue` if the source Observable emits no items, or the values emitted - * by the source Observable. - * @method defaultIfEmpty - * @owner Observable - */ - function defaultIfEmpty(defaultValue) { - if (defaultValue === void 0) { defaultValue = null; } - return this.lift(new DefaultIfEmptyOperator(defaultValue)); - } - exports.defaultIfEmpty = defaultIfEmpty; - var DefaultIfEmptyOperator = (function () { - function DefaultIfEmptyOperator(defaultValue) { - this.defaultValue = defaultValue; - } - DefaultIfEmptyOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue)); - }; - return DefaultIfEmptyOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DefaultIfEmptySubscriber = (function (_super) { - __extends(DefaultIfEmptySubscriber, _super); - function DefaultIfEmptySubscriber(destination, defaultValue) { - _super.call(this, destination); - this.defaultValue = defaultValue; - this.isEmpty = true; - } - DefaultIfEmptySubscriber.prototype._next = function (value) { - this.isEmpty = false; - this.destination.next(value); - }; - DefaultIfEmptySubscriber.prototype._complete = function () { - if (this.isEmpty) { - this.destination.next(this.defaultValue); - } - this.destination.complete(); - }; - return DefaultIfEmptySubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=defaultIfEmpty.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Catches errors on the observable to be handled by returning a new observable or throwing an error. + * + * + * + * @example Continues with a different Observable when there's an error + * + * Observable.of(1, 2, 3, 4, 5) + * .map(n => { + * if (n == 4) { + * throw 'four!'; + * } + * return n; + * }) + * .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V')) + * .subscribe(x => console.log(x)); + * // 1, 2, 3, I, II, III, IV, V + * + * @example Retries the caught source Observable again in case of error, similar to retry() operator + * + * Observable.of(1, 2, 3, 4, 5) + * .map(n => { + * if (n === 4) { + * throw 'four!'; + * } + * return n; + * }) + * .catch((err, caught) => caught) + * .take(30) + * .subscribe(x => console.log(x)); + * // 1, 2, 3, 1, 2, 3, ... + * + * @example Throws a new error when the source Observable throws an error + * + * Observable.of(1, 2, 3, 4, 5) + * .map(n => { + * if (n == 4) { + * throw 'four!'; + * } + * return n; + * }) + * .catch(err => { + * throw 'error in source. Details: ' + err; + * }) + * .subscribe( + * x => console.log(x), + * err => console.log(err) + * ); + * // 1, 2, 3, error in source. Details: four! + * + * @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which + * is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable + * is returned by the `selector` will be used to continue the observable chain. + * @return {Observable} An observable that originates from either the source or the observable returned by the + * catch `selector` function. + * @method catch + * @name catch + * @owner Observable + */ +function _catch(selector) { + var operator = new CatchOperator(selector); + var caught = this.lift(operator); + return (operator.caught = caught); +} +exports._catch = _catch; +var CatchOperator = (function () { + function CatchOperator(selector) { + this.selector = selector; + } + CatchOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught)); + }; + return CatchOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var CatchSubscriber = (function (_super) { + __extends(CatchSubscriber, _super); + function CatchSubscriber(destination, selector, caught) { + _super.call(this, destination); + this.selector = selector; + this.caught = caught; + } + // NOTE: overriding `error` instead of `_error` because we don't want + // to have this flag this subscriber as `isStopped`. We can mimic the + // behavior of the RetrySubscriber (from the `retry` operator), where + // we unsubscribe from our source chain, reset our Subscriber flags, + // then subscribe to the selector result. + CatchSubscriber.prototype.error = function (err) { + if (!this.isStopped) { + var result = void 0; + try { + result = this.selector(err, this.caught); + } + catch (err2) { + _super.prototype.error.call(this, err2); + return; + } + this._unsubscribeAndRecycle(); + this.add(subscribeToResult_1.subscribeToResult(this, result)); + } + }; + return CatchSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=catch.js.map + +/***/ }), /* 223 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var delay_1 = __webpack_require__(224); - Observable_1.Observable.prototype.delay = delay_1.delay; - //# sourceMappingURL=delay.js.map +var Observable_1 = __webpack_require__(0); +var combineAll_1 = __webpack_require__(224); +Observable_1.Observable.prototype.combineAll = combineAll_1.combineAll; +//# sourceMappingURL=combineAll.js.map -/***/ }, +/***/ }), /* 224 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 async_1 = __webpack_require__(138); - var isDate_1 = __webpack_require__(173); - var Subscriber_1 = __webpack_require__(67); - var Notification_1 = __webpack_require__(119); - /** - * Delays the emission of items from the source Observable by a given timeout or - * until a given Date. - * - * Time shifts each item by some specified amount of - * milliseconds. - * - * - * - * If the delay argument is a Number, this operator time shifts the source - * Observable by that amount of time expressed in milliseconds. The relative - * time intervals between the values are preserved. - * - * If the delay argument is a Date, this operator time shifts the start of the - * Observable execution until the given date occurs. - * - * @example Delay each click by one second - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var delayedClicks = clicks.delay(1000); // each click emitted after 1 second - * delayedClicks.subscribe(x => console.log(x)); - * - * @example Delay all clicks until a future date happens - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var date = new Date('March 15, 2050 12:00:00'); // in the future - * var delayedClicks = clicks.delay(date); // click emitted only after that date - * delayedClicks.subscribe(x => console.log(x)); - * - * @see {@link debounceTime} - * @see {@link delayWhen} - * - * @param {number|Date} delay The delay duration in milliseconds (a `number`) or - * a `Date` until which the emission of the source items is delayed. - * @param {Scheduler} [scheduler=async] The IScheduler to use for - * managing the timers that handle the time-shift for each item. - * @return {Observable} An Observable that delays the emissions of the source - * Observable by the specified timeout or Date. - * @method delay - * @owner Observable - */ - function delay(delay, scheduler) { - if (scheduler === void 0) { scheduler = async_1.async; } - var absoluteDelay = isDate_1.isDate(delay); - var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay); - return this.lift(new DelayOperator(delayFor, scheduler)); - } - exports.delay = delay; - var DelayOperator = (function () { - function DelayOperator(delay, scheduler) { - this.delay = delay; - this.scheduler = scheduler; - } - DelayOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler)); - }; - return DelayOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DelaySubscriber = (function (_super) { - __extends(DelaySubscriber, _super); - function DelaySubscriber(destination, delay, scheduler) { - _super.call(this, destination); - this.delay = delay; - this.scheduler = scheduler; - this.queue = []; - this.active = false; - this.errored = false; - } - DelaySubscriber.dispatch = function (state) { - var source = state.source; - var queue = source.queue; - var scheduler = state.scheduler; - var destination = state.destination; - while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) { - queue.shift().notification.observe(destination); - } - if (queue.length > 0) { - var delay_1 = Math.max(0, queue[0].time - scheduler.now()); - this.schedule(state, delay_1); - } - else { - source.active = false; - } - }; - DelaySubscriber.prototype._schedule = function (scheduler) { - this.active = true; - this.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, { - source: this, destination: this.destination, scheduler: scheduler - })); - }; - DelaySubscriber.prototype.scheduleNotification = function (notification) { - if (this.errored === true) { - return; - } - var scheduler = this.scheduler; - var message = new DelayMessage(scheduler.now() + this.delay, notification); - this.queue.push(message); - if (this.active === false) { - this._schedule(scheduler); - } - }; - DelaySubscriber.prototype._next = function (value) { - this.scheduleNotification(Notification_1.Notification.createNext(value)); - }; - DelaySubscriber.prototype._error = function (err) { - this.errored = true; - this.queue = []; - this.destination.error(err); - }; - DelaySubscriber.prototype._complete = function () { - this.scheduleNotification(Notification_1.Notification.createComplete()); - }; - return DelaySubscriber; - }(Subscriber_1.Subscriber)); - var DelayMessage = (function () { - function DelayMessage(time, notification) { - this.time = time; - this.notification = notification; - } - return DelayMessage; - }()); - //# sourceMappingURL=delay.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var combineLatest_1 = __webpack_require__(44); +/** + * Converts a higher-order Observable into a first-order Observable by waiting + * for the outer Observable to complete, then applying {@link combineLatest}. + * + * Flattens an Observable-of-Observables by applying + * {@link combineLatest} when the Observable-of-Observables completes. + * + * + * + * Takes an Observable of Observables, and collects all Observables from it. + * Once the outer Observable completes, it subscribes to all collected + * Observables and combines their values using the {@link combineLatest} + * strategy, such that: + * - Every time an inner Observable emits, the output Observable emits. + * - When the returned observable emits, it emits all of the latest values by: + * - If a `project` function is provided, it is called with each recent value + * from each inner Observable in whatever order they arrived, and the result + * of the `project` function is what is emitted by the output Observable. + * - If there is no `project` function, an array of all of the most recent + * values is emitted by the output Observable. + * + * @example Map two click events to a finite interval Observable, then apply combineAll + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var higherOrder = clicks.map(ev => + * Rx.Observable.interval(Math.random()*2000).take(3) + * ).take(2); + * var result = higherOrder.combineAll(); + * result.subscribe(x => console.log(x)); + * + * @see {@link combineLatest} + * @see {@link mergeAll} + * + * @param {function} [project] An optional function to map the most recent + * values from each inner Observable into a new result. Takes each of the most + * recent values from each collected inner Observable as arguments, in order. + * @return {Observable} An Observable of projected results or arrays of recent + * values. + * @method combineAll + * @owner Observable + */ +function combineAll(project) { + return this.lift(new combineLatest_1.CombineLatestOperator(project)); +} +exports.combineAll = combineAll; +//# sourceMappingURL=combineAll.js.map + +/***/ }), /* 225 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var delayWhen_1 = __webpack_require__(226); - Observable_1.Observable.prototype.delayWhen = delayWhen_1.delayWhen; - //# sourceMappingURL=delayWhen.js.map +var Observable_1 = __webpack_require__(0); +var combineLatest_1 = __webpack_require__(44); +Observable_1.Observable.prototype.combineLatest = combineLatest_1.combineLatest; +//# sourceMappingURL=combineLatest.js.map -/***/ }, +/***/ }), /* 226 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var Observable_1 = __webpack_require__(64); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Delays the emission of items from the source Observable by a given time span - * determined by the emissions of another Observable. - * - * It's like {@link delay}, but the time span of the - * delay duration is determined by a second Observable. - * - * - * - * `delayWhen` time shifts each emitted value from the source Observable by a - * time span determined by another Observable. When the source emits a value, - * the `delayDurationSelector` function is called with the source value as - * argument, and should return an Observable, called the "duration" Observable. - * The source value is emitted on the output Observable only when the duration - * Observable emits a value or completes. - * - * Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which - * is an Observable. When `subscriptionDelay` emits its first value or - * completes, the source Observable is subscribed to and starts behaving like - * described in the previous paragraph. If `subscriptionDelay` is not provided, - * `delayWhen` will subscribe to the source Observable as soon as the output - * Observable is subscribed. - * - * @example Delay each click by a random amount of time, between 0 and 5 seconds - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var delayedClicks = clicks.delayWhen(event => - * Rx.Observable.interval(Math.random() * 5000) - * ); - * delayedClicks.subscribe(x => console.log(x)); - * - * @see {@link debounce} - * @see {@link delay} - * - * @param {function(value: T): Observable} delayDurationSelector A function that - * returns an Observable for each value emitted by the source Observable, which - * is then used to delay the emission of that item on the output Observable - * until the Observable returned from this function emits a value. - * @param {Observable} subscriptionDelay An Observable that triggers the - * subscription to the source Observable once it emits any value. - * @return {Observable} An Observable that delays the emissions of the source - * Observable by an amount of time specified by the Observable returned by - * `delayDurationSelector`. - * @method delayWhen - * @owner Observable - */ - function delayWhen(delayDurationSelector, subscriptionDelay) { - if (subscriptionDelay) { - return new SubscriptionDelayObservable(this, subscriptionDelay) - .lift(new DelayWhenOperator(delayDurationSelector)); - } - return this.lift(new DelayWhenOperator(delayDurationSelector)); - } - exports.delayWhen = delayWhen; - var DelayWhenOperator = (function () { - function DelayWhenOperator(delayDurationSelector) { - this.delayDurationSelector = delayDurationSelector; - } - DelayWhenOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector)); - }; - return DelayWhenOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DelayWhenSubscriber = (function (_super) { - __extends(DelayWhenSubscriber, _super); - function DelayWhenSubscriber(destination, delayDurationSelector) { - _super.call(this, destination); - this.delayDurationSelector = delayDurationSelector; - this.completed = false; - this.delayNotifierSubscriptions = []; - this.values = []; - } - DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.destination.next(outerValue); - this.removeSubscription(innerSub); - this.tryComplete(); - }; - DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) { - this._error(error); - }; - DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) { - var value = this.removeSubscription(innerSub); - if (value) { - this.destination.next(value); - } - this.tryComplete(); - }; - DelayWhenSubscriber.prototype._next = function (value) { - try { - var delayNotifier = this.delayDurationSelector(value); - if (delayNotifier) { - this.tryDelay(delayNotifier, value); - } - } - catch (err) { - this.destination.error(err); - } - }; - DelayWhenSubscriber.prototype._complete = function () { - this.completed = true; - this.tryComplete(); - }; - DelayWhenSubscriber.prototype.removeSubscription = function (subscription) { - subscription.unsubscribe(); - var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription); - var value = null; - if (subscriptionIdx !== -1) { - value = this.values[subscriptionIdx]; - this.delayNotifierSubscriptions.splice(subscriptionIdx, 1); - this.values.splice(subscriptionIdx, 1); - } - return value; - }; - DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) { - var notifierSubscription = subscribeToResult_1.subscribeToResult(this, delayNotifier, value); - if (notifierSubscription && !notifierSubscription.closed) { - this.add(notifierSubscription); - this.delayNotifierSubscriptions.push(notifierSubscription); - } - this.values.push(value); - }; - DelayWhenSubscriber.prototype.tryComplete = function () { - if (this.completed && this.delayNotifierSubscriptions.length === 0) { - this.destination.complete(); - } - }; - return DelayWhenSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SubscriptionDelayObservable = (function (_super) { - __extends(SubscriptionDelayObservable, _super); - function SubscriptionDelayObservable(source, subscriptionDelay) { - _super.call(this); - this.source = source; - this.subscriptionDelay = subscriptionDelay; - } - SubscriptionDelayObservable.prototype._subscribe = function (subscriber) { - this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source)); - }; - return SubscriptionDelayObservable; - }(Observable_1.Observable)); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SubscriptionDelaySubscriber = (function (_super) { - __extends(SubscriptionDelaySubscriber, _super); - function SubscriptionDelaySubscriber(parent, source) { - _super.call(this); - this.parent = parent; - this.source = source; - this.sourceSubscribed = false; - } - SubscriptionDelaySubscriber.prototype._next = function (unused) { - this.subscribeToSource(); - }; - SubscriptionDelaySubscriber.prototype._error = function (err) { - this.unsubscribe(); - this.parent.error(err); - }; - SubscriptionDelaySubscriber.prototype._complete = function () { - this.subscribeToSource(); - }; - SubscriptionDelaySubscriber.prototype.subscribeToSource = function () { - if (!this.sourceSubscribed) { - this.sourceSubscribed = true; - this.unsubscribe(); - this.source.subscribe(this.parent); - } - }; - return SubscriptionDelaySubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=delayWhen.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var concat_1 = __webpack_require__(45); +Observable_1.Observable.prototype.concat = concat_1.concat; +//# sourceMappingURL=concat.js.map + +/***/ }), /* 227 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var distinct_1 = __webpack_require__(228); - Observable_1.Observable.prototype.distinct = distinct_1.distinct; - //# sourceMappingURL=distinct.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var concatAll_1 = __webpack_require__(228); +Observable_1.Observable.prototype.concatAll = concatAll_1.concatAll; +//# sourceMappingURL=concatAll.js.map + +/***/ }), /* 228 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - var Set_1 = __webpack_require__(229); - /** - * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from previous items. - * - * If a keySelector function is provided, then it will project each value from the source observable into a new value that it will - * check for equality with previously projected values. If a keySelector function is not provided, it will use each value from the - * source observable directly with an equality check against previous values. - * - * In JavaScript runtimes that support `Set`, this operator will use a `Set` to improve performance of the distinct value checking. - * - * In other runtimes, this operator will use a minimal implementation of `Set` that relies on an `Array` and `indexOf` under the - * hood, so performance will degrade as more values are checked for distinction. Even in newer browsers, a long-running `distinct` - * use might result in memory leaks. To help alleviate this in some scenarios, an optional `flushes` parameter is also provided so - * that the internal `Set` can be "flushed", basically clearing it of values. - * - * @example A simple example with numbers - * Observable.of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1) - * .distinct() - * .subscribe(x => console.log(x)); // 1, 2, 3, 4 - * - * @example An example using a keySelector function - * interface Person { - * age: number, - * name: string - * } - * - * Observable.of( - * { age: 4, name: 'Foo'}, - * { age: 7, name: 'Bar'}, - * { age: 5, name: 'Foo'}) - * .distinct((p: Person) => p.name) - * .subscribe(x => console.log(x)); - * - * // displays: - * // { age: 4, name: 'Foo' } - * // { age: 7, name: 'Bar' } - * - * @see {@link distinctUntilChanged} - * @see {@link distinctUntilKeyChanged} - * - * @param {function} [keySelector] Optional function to select which value you want to check as distinct. - * @param {Observable} [flushes] Optional Observable for flushing the internal HashSet of the operator. - * @return {Observable} An Observable that emits items from the source Observable with distinct values. - * @method distinct - * @owner Observable - */ - function distinct(keySelector, flushes) { - return this.lift(new DistinctOperator(keySelector, flushes)); - } - exports.distinct = distinct; - var DistinctOperator = (function () { - function DistinctOperator(keySelector, flushes) { - this.keySelector = keySelector; - this.flushes = flushes; - } - DistinctOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes)); - }; - return DistinctOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DistinctSubscriber = (function (_super) { - __extends(DistinctSubscriber, _super); - function DistinctSubscriber(destination, keySelector, flushes) { - _super.call(this, destination); - this.keySelector = keySelector; - this.values = new Set_1.Set(); - if (flushes) { - this.add(subscribeToResult_1.subscribeToResult(this, flushes)); - } - } - DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.values.clear(); - }; - DistinctSubscriber.prototype.notifyError = function (error, innerSub) { - this._error(error); - }; - DistinctSubscriber.prototype._next = function (value) { - if (this.keySelector) { - this._useKeySelector(value); - } - else { - this._finalizeNext(value, value); - } - }; - DistinctSubscriber.prototype._useKeySelector = function (value) { - var key; - var destination = this.destination; - try { - key = this.keySelector(value); - } - catch (err) { - destination.error(err); - return; - } - this._finalizeNext(key, value); - }; - DistinctSubscriber.prototype._finalizeNext = function (key, value) { - var values = this.values; - if (!values.has(key)) { - values.add(key); - this.destination.next(value); - } - }; - return DistinctSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.DistinctSubscriber = DistinctSubscriber; - //# sourceMappingURL=distinct.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var mergeAll_1 = __webpack_require__(33); +/* tslint:enable:max-line-length */ +/** + * Converts a higher-order Observable into a first-order Observable by + * concatenating the inner Observables in order. + * + * Flattens an Observable-of-Observables by putting one + * inner Observable after the other. + * + * + * + * Joins every Observable emitted by the source (a higher-order Observable), in + * a serial fashion. It subscribes to each inner Observable only after the + * previous inner Observable has completed, and merges all of their values into + * the returned observable. + * + * __Warning:__ If the source Observable emits Observables quickly and + * endlessly, and the inner Observables it emits generally complete slower than + * the source emits, you can run into memory issues as the incoming Observables + * collect in an unbounded buffer. + * + * Note: `concatAll` is equivalent to `mergeAll` with concurrency parameter set + * to `1`. + * + * @example For each click event, tick every second from 0 to 3, with no concurrency + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var higherOrder = clicks.map(ev => Rx.Observable.interval(1000).take(4)); + * var firstOrder = higherOrder.concatAll(); + * firstOrder.subscribe(x => console.log(x)); + * + * // Results in the following: + * // (results are not concurrent) + * // For every click on the "document" it will emit values 0 to 3 spaced + * // on a 1000ms interval + * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 + * + * @see {@link combineAll} + * @see {@link concat} + * @see {@link concatMap} + * @see {@link concatMapTo} + * @see {@link exhaust} + * @see {@link mergeAll} + * @see {@link switch} + * @see {@link zipAll} + * + * @return {Observable} An Observable emitting values from all the inner + * Observables concatenated. + * @method concatAll + * @owner Observable + */ +function concatAll() { + return this.lift(new mergeAll_1.MergeAllOperator(1)); +} +exports.concatAll = concatAll; +//# sourceMappingURL=concatAll.js.map + +/***/ }), /* 229 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var root_1 = __webpack_require__(65); - function minimalSetImpl() { - // THIS IS NOT a full impl of Set, this is just the minimum - // bits of functionality we need for this library. - return (function () { - function MinimalSet() { - this._values = []; - } - MinimalSet.prototype.add = function (value) { - if (!this.has(value)) { - this._values.push(value); - } - }; - MinimalSet.prototype.has = function (value) { - return this._values.indexOf(value) !== -1; - }; - Object.defineProperty(MinimalSet.prototype, "size", { - get: function () { - return this._values.length; - }, - enumerable: true, - configurable: true - }); - MinimalSet.prototype.clear = function () { - this._values.length = 0; - }; - return MinimalSet; - }()); - } - exports.minimalSetImpl = minimalSetImpl; - exports.Set = root_1.root.Set || minimalSetImpl(); - //# sourceMappingURL=Set.js.map +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 230 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var distinctUntilChanged_1 = __webpack_require__(231); - Observable_1.Observable.prototype.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged; - //# sourceMappingURL=distinctUntilChanged.js.map +var Observable_1 = __webpack_require__(0); +var concatMap_1 = __webpack_require__(230); +Observable_1.Observable.prototype.concatMap = concatMap_1.concatMap; +//# sourceMappingURL=concatMap.js.map -/***/ }, +/***/ }), +/* 230 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var mergeMap_1 = __webpack_require__(73); +/* tslint:enable:max-line-length */ +/** + * Projects each source value to an Observable which is merged in the output + * Observable, in a serialized fashion waiting for each one to complete before + * merging the next. + * + * Maps each value to an Observable, then flattens all of + * these inner Observables using {@link concatAll}. + * + * + * + * Returns an Observable that emits items based on applying a function that you + * supply to each item emitted by the source Observable, where that function + * returns an (so-called "inner") Observable. Each new inner Observable is + * concatenated with the previous inner Observable. + * + * __Warning:__ if source values arrive endlessly and faster than their + * corresponding inner Observables can complete, it will result in memory issues + * as inner Observables amass in an unbounded buffer waiting for their turn to + * be subscribed to. + * + * Note: `concatMap` is equivalent to `mergeMap` with concurrency parameter set + * to `1`. + * + * @example For each click event, tick every second from 0 to 3, with no concurrency + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.concatMap(ev => Rx.Observable.interval(1000).take(4)); + * result.subscribe(x => console.log(x)); + * + * // Results in the following: + * // (results are not concurrent) + * // For every click on the "document" it will emit values 0 to 3 spaced + * // on a 1000ms interval + * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 + * + * @see {@link concat} + * @see {@link concatAll} + * @see {@link concatMapTo} + * @see {@link exhaustMap} + * @see {@link mergeMap} + * @see {@link switchMap} + * + * @param {function(value: T, ?index: number): ObservableInput} project A function + * that, when applied to an item emitted by the source Observable, returns an + * Observable. + * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] + * A function to produce the value on the output Observable based on the values + * and the indices of the source (outer) emission and the inner Observable + * emission. The arguments passed to this function are: + * - `outerValue`: the value that came from the source + * - `innerValue`: the value that came from the projected Observable + * - `outerIndex`: the "index" of the value that came from the source + * - `innerIndex`: the "index" of the value from the projected Observable + * @return {Observable} An Observable that emits the result of applying the + * projection function (and the optional `resultSelector`) to each item emitted + * by the source Observable and taking values from each projected inner + * Observable sequentially. + * @method concatMap + * @owner Observable + */ +function concatMap(project, resultSelector) { + return this.lift(new mergeMap_1.MergeMapOperator(project, resultSelector, 1)); +} +exports.concatMap = concatMap; +//# sourceMappingURL=concatMap.js.map + +/***/ }), /* 231 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - /* 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 A simple example with numbers - * 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 An example using a compare function - * interface Person { - * age: number, - * name: string - * } - * - * Observable.of( - * { 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 this.lift(new DistinctUntilChangedOperator(compare, keySelector)); - } - exports.distinctUntilChanged = 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_1.errorObject) { - return this.destination.error(errorObject_1.errorObject.e); - } - } - var result = false; - if (this.hasKey) { - result = tryCatch_1.tryCatch(this.compare)(this.key, key); - if (result === errorObject_1.errorObject) { - return this.destination.error(errorObject_1.errorObject.e); - } - } - else { - this.hasKey = true; - } - if (Boolean(result) === false) { - this.key = key; - this.destination.next(value); - } - }; - return DistinctUntilChangedSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=distinctUntilChanged.js.map - -/***/ }, -/* 232 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var distinctUntilKeyChanged_1 = __webpack_require__(233); - Observable_1.Observable.prototype.distinctUntilKeyChanged = distinctUntilKeyChanged_1.distinctUntilKeyChanged; - //# sourceMappingURL=distinctUntilKeyChanged.js.map +var Observable_1 = __webpack_require__(0); +var concatMapTo_1 = __webpack_require__(232); +Observable_1.Observable.prototype.concatMapTo = concatMapTo_1.concatMapTo; +//# sourceMappingURL=concatMapTo.js.map -/***/ }, +/***/ }), +/* 232 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var mergeMapTo_1 = __webpack_require__(74); +/* tslint:enable:max-line-length */ +/** + * Projects each source value to the same Observable which is merged multiple + * times in a serialized fashion on the output Observable. + * + * It's like {@link concatMap}, but maps each value + * always to the same inner Observable. + * + * + * + * Maps each source value to the given Observable `innerObservable` regardless + * of the source value, and then flattens those resulting Observables into one + * single Observable, which is the output Observable. Each new `innerObservable` + * instance emitted on the output Observable is concatenated with the previous + * `innerObservable` instance. + * + * __Warning:__ if source values arrive endlessly and faster than their + * corresponding inner Observables can complete, it will result in memory issues + * as inner Observables amass in an unbounded buffer waiting for their turn to + * be subscribed to. + * + * Note: `concatMapTo` is equivalent to `mergeMapTo` with concurrency parameter + * set to `1`. + * + * @example For each click event, tick every second from 0 to 3, with no concurrency + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.concatMapTo(Rx.Observable.interval(1000).take(4)); + * result.subscribe(x => console.log(x)); + * + * // Results in the following: + * // (results are not concurrent) + * // For every click on the "document" it will emit values 0 to 3 spaced + * // on a 1000ms interval + * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 + * + * @see {@link concat} + * @see {@link concatAll} + * @see {@link concatMap} + * @see {@link mergeMapTo} + * @see {@link switchMapTo} + * + * @param {ObservableInput} innerObservable An Observable to replace each value from + * the source Observable. + * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] + * A function to produce the value on the output Observable based on the values + * and the indices of the source (outer) emission and the inner Observable + * emission. The arguments passed to this function are: + * - `outerValue`: the value that came from the source + * - `innerValue`: the value that came from the projected Observable + * - `outerIndex`: the "index" of the value that came from the source + * - `innerIndex`: the "index" of the value from the projected Observable + * @return {Observable} An observable of values merged together by joining the + * passed observable with itself, one after the other, for each value emitted + * from the source. + * @method concatMapTo + * @owner Observable + */ +function concatMapTo(innerObservable, resultSelector) { + return this.lift(new mergeMapTo_1.MergeMapToOperator(innerObservable, resultSelector, 1)); +} +exports.concatMapTo = concatMapTo; +//# sourceMappingURL=concatMapTo.js.map + +/***/ }), /* 233 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var distinctUntilChanged_1 = __webpack_require__(231); - /* 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, - * using a property accessed by using the key provided to check if the two items are distinct. - * - * 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 An example comparing the name of persons - * - * interface Person { - * age: number, - * name: string - * } - * - * Observable.of( - * { age: 4, name: 'Foo'}, - * { age: 7, name: 'Bar'}, - * { age: 5, name: 'Foo'}, - * { age: 6, name: 'Foo'}) - * .distinctUntilKeyChanged('name') - * .subscribe(x => console.log(x)); - * - * // displays: - * // { age: 4, name: 'Foo' } - * // { age: 7, name: 'Bar' } - * // { age: 5, name: 'Foo' } - * - * @example An example comparing the first letters of the name - * - * interface Person { - * age: number, - * name: string - * } - * - * Observable.of( - * { age: 4, name: 'Foo1'}, - * { age: 7, name: 'Bar'}, - * { age: 5, name: 'Foo2'}, - * { age: 6, name: 'Foo3'}) - * .distinctUntilKeyChanged('name', (x: string, y: string) => x.substring(0, 3) === y.substring(0, 3)) - * .subscribe(x => console.log(x)); - * - * // displays: - * // { age: 4, name: 'Foo1' } - * // { age: 7, name: 'Bar' } - * // { age: 5, name: 'Foo2' } - * - * @see {@link distinct} - * @see {@link distinctUntilChanged} - * - * @param {string} key String key for object property lookup on each item. - * @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 based on the key specified. - * @method distinctUntilKeyChanged - * @owner Observable - */ - function distinctUntilKeyChanged(key, compare) { - return distinctUntilChanged_1.distinctUntilChanged.call(this, function (x, y) { - if (compare) { - return compare(x[key], y[key]); - } - return x[key] === y[key]; - }); - } - exports.distinctUntilKeyChanged = distinctUntilKeyChanged; - //# sourceMappingURL=distinctUntilKeyChanged.js.map +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 234 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var do_1 = __webpack_require__(235); - Observable_1.Observable.prototype.do = do_1._do; - Observable_1.Observable.prototype._do = do_1._do; - //# sourceMappingURL=do.js.map +var Observable_1 = __webpack_require__(0); +var count_1 = __webpack_require__(234); +Observable_1.Observable.prototype.count = count_1.count; +//# sourceMappingURL=count.js.map -/***/ }, +/***/ }), +/* 234 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Counts the number of emissions on the source and emits that number when the + * source completes. + * + * Tells how many values were emitted, when the source + * completes. + * + * + * + * `count` transforms an Observable that emits values into an Observable that + * emits a single value that represents the number of values emitted by the + * source Observable. If the source Observable terminates with an error, `count` + * will pass this error notification along without emitting a value first. If + * the source Observable does not terminate at all, `count` will neither emit + * a value nor terminate. This operator takes an optional `predicate` function + * as argument, in which case the output emission will represent the number of + * source values that matched `true` with the `predicate`. + * + * @example Counts how many seconds have passed before the first click happened + * var seconds = Rx.Observable.interval(1000); + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var secondsBeforeClick = seconds.takeUntil(clicks); + * var result = secondsBeforeClick.count(); + * result.subscribe(x => console.log(x)); + * + * @example Counts how many odd numbers are there between 1 and 7 + * var numbers = Rx.Observable.range(1, 7); + * var result = numbers.count(i => i % 2 === 1); + * result.subscribe(x => console.log(x)); + * + * // Results in: + * // 4 + * + * @see {@link max} + * @see {@link min} + * @see {@link reduce} + * + * @param {function(value: T, i: number, source: Observable): boolean} [predicate] A + * boolean function to select what values are to be counted. It is provided with + * arguments of: + * - `value`: the value from the source Observable. + * - `index`: the (zero-based) "index" of the value from the source Observable. + * - `source`: the source Observable instance itself. + * @return {Observable} An Observable of one number that represents the count as + * described above. + * @method count + * @owner Observable + */ +function count(predicate) { + return this.lift(new CountOperator(predicate, this)); +} +exports.count = count; +var CountOperator = (function () { + function CountOperator(predicate, source) { + this.predicate = predicate; + this.source = source; + } + CountOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source)); + }; + return CountOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var CountSubscriber = (function (_super) { + __extends(CountSubscriber, _super); + function CountSubscriber(destination, predicate, source) { + _super.call(this, destination); + this.predicate = predicate; + this.source = source; + this.count = 0; + this.index = 0; + } + CountSubscriber.prototype._next = function (value) { + if (this.predicate) { + this._tryPredicate(value); + } + else { + this.count++; + } + }; + CountSubscriber.prototype._tryPredicate = function (value) { + var result; + try { + result = this.predicate(value, this.index++, this.source); + } + catch (err) { + this.destination.error(err); + return; + } + if (result) { + this.count++; + } + }; + CountSubscriber.prototype._complete = function () { + this.destination.next(this.count); + this.destination.complete(); + }; + return CountSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=count.js.map + +/***/ }), /* 235 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /* tslint:enable:max-line-length */ - /** - * Perform a side effect for every emission on the source Observable, but return - * an Observable that is identical to the source. - * - * Intercepts each emission on the source and runs a - * function, but returns an output which is identical to the source as long as errors don't occur. - * - * - * - * Returns a mirrored Observable of the source Observable, but modified so that - * the provided Observer is called to perform a side effect for every value, - * error, and completion emitted by the source. Any errors that are thrown in - * the aforementioned Observer or handlers are safely sent down the error path - * of the output Observable. - * - * This operator is useful for debugging your Observables for the correct values - * or performing other side effects. - * - * Note: this is different to a `subscribe` on the Observable. If the Observable - * returned by `do` is not subscribed, the side effects specified by the - * Observer will never happen. `do` therefore simply spies on existing - * execution, it does not trigger an execution to happen like `subscribe` does. - * - * @example Map every click to the clientX position of that click, while also logging the click event - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var positions = clicks - * .do(ev => console.log(ev)) - * .map(ev => ev.clientX); - * positions.subscribe(x => console.log(x)); - * - * @see {@link map} - * @see {@link subscribe} - * - * @param {Observer|function} [nextOrObserver] A normal Observer object or a - * callback for `next`. - * @param {function} [error] Callback for errors in the source. - * @param {function} [complete] Callback for the completion of the source. - * @return {Observable} An Observable identical to the source, but runs the - * specified Observer or callback(s) for each item. - * @method do - * @name do - * @owner Observable - */ - function _do(nextOrObserver, error, complete) { - return this.lift(new DoOperator(nextOrObserver, error, complete)); - } - exports._do = _do; - var DoOperator = (function () { - function DoOperator(nextOrObserver, error, complete) { - this.nextOrObserver = nextOrObserver; - this.error = error; - this.complete = complete; - } - DoOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new DoSubscriber(subscriber, this.nextOrObserver, this.error, this.complete)); - }; - return DoOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var DoSubscriber = (function (_super) { - __extends(DoSubscriber, _super); - function DoSubscriber(destination, nextOrObserver, error, complete) { - _super.call(this, destination); - var safeSubscriber = new Subscriber_1.Subscriber(nextOrObserver, error, complete); - safeSubscriber.syncErrorThrowable = true; - this.add(safeSubscriber); - this.safeSubscriber = safeSubscriber; - } - DoSubscriber.prototype._next = function (value) { - var safeSubscriber = this.safeSubscriber; - safeSubscriber.next(value); - if (safeSubscriber.syncErrorThrown) { - this.destination.error(safeSubscriber.syncErrorValue); - } - else { - this.destination.next(value); - } - }; - DoSubscriber.prototype._error = function (err) { - var safeSubscriber = this.safeSubscriber; - safeSubscriber.error(err); - if (safeSubscriber.syncErrorThrown) { - this.destination.error(safeSubscriber.syncErrorValue); - } - else { - this.destination.error(err); - } - }; - DoSubscriber.prototype._complete = function () { - var safeSubscriber = this.safeSubscriber; - safeSubscriber.complete(); - if (safeSubscriber.syncErrorThrown) { - this.destination.error(safeSubscriber.syncErrorValue); - } - else { - this.destination.complete(); - } - }; - return DoSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=do.js.map - -/***/ }, -/* 236 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var exhaust_1 = __webpack_require__(237); - Observable_1.Observable.prototype.exhaust = exhaust_1.exhaust; - //# sourceMappingURL=exhaust.js.map +var Observable_1 = __webpack_require__(0); +var dematerialize_1 = __webpack_require__(236); +Observable_1.Observable.prototype.dematerialize = dematerialize_1.dematerialize; +//# sourceMappingURL=dematerialize.js.map -/***/ }, +/***/ }), +/* 236 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Converts an Observable of {@link Notification} objects into the emissions + * that they represent. + * + * Unwraps {@link Notification} objects as actual `next`, + * `error` and `complete` emissions. The opposite of {@link materialize}. + * + * + * + * `dematerialize` is assumed to operate an Observable that only emits + * {@link Notification} objects as `next` emissions, and does not emit any + * `error`. Such Observable is the output of a `materialize` operation. Those + * notifications are then unwrapped using the metadata they contain, and emitted + * as `next`, `error`, and `complete` on the output Observable. + * + * Use this operator in conjunction with {@link materialize}. + * + * @example Convert an Observable of Notifications to an actual Observable + * var notifA = new Rx.Notification('N', 'A'); + * var notifB = new Rx.Notification('N', 'B'); + * var notifE = new Rx.Notification('E', void 0, + * new TypeError('x.toUpperCase is not a function') + * ); + * var materialized = Rx.Observable.of(notifA, notifB, notifE); + * var upperCase = materialized.dematerialize(); + * upperCase.subscribe(x => console.log(x), e => console.error(e)); + * + * // Results in: + * // A + * // B + * // TypeError: x.toUpperCase is not a function + * + * @see {@link Notification} + * @see {@link materialize} + * + * @return {Observable} An Observable that emits items and notifications + * embedded in Notification objects emitted by the source Observable. + * @method dematerialize + * @owner Observable + */ +function dematerialize() { + return this.lift(new DeMaterializeOperator()); +} +exports.dematerialize = dematerialize; +var DeMaterializeOperator = (function () { + function DeMaterializeOperator() { + } + DeMaterializeOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DeMaterializeSubscriber(subscriber)); + }; + return DeMaterializeOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DeMaterializeSubscriber = (function (_super) { + __extends(DeMaterializeSubscriber, _super); + function DeMaterializeSubscriber(destination) { + _super.call(this, destination); + } + DeMaterializeSubscriber.prototype._next = function (value) { + value.observe(this.destination); + }; + return DeMaterializeSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=dematerialize.js.map + +/***/ }), /* 237 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Converts a higher-order Observable into a first-order Observable by dropping - * inner Observables while the previous inner Observable has not yet completed. - * - * Flattens an Observable-of-Observables by dropping the - * next inner Observables while the current inner is still executing. - * - * - * - * `exhaust` subscribes to an Observable that emits Observables, also known as a - * higher-order Observable. Each time it observes one of these emitted inner - * Observables, the output Observable begins emitting the items emitted by that - * inner Observable. So far, it behaves like {@link mergeAll}. However, - * `exhaust` ignores every new inner Observable if the previous Observable has - * not yet completed. Once that one completes, it will accept and flatten the - * next inner Observable and repeat this process. - * - * @example Run a finite timer for each click, only if there is no currently active timer - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(5)); - * var result = higherOrder.exhaust(); - * result.subscribe(x => console.log(x)); - * - * @see {@link combineAll} - * @see {@link concatAll} - * @see {@link switch} - * @see {@link mergeAll} - * @see {@link exhaustMap} - * @see {@link zipAll} - * - * @return {Observable} An Observable that takes a source of Observables and propagates the first observable - * exclusively until it completes before subscribing to the next. - * @method exhaust - * @owner Observable - */ - function exhaust() { - return this.lift(new SwitchFirstOperator()); - } - exports.exhaust = exhaust; - var SwitchFirstOperator = (function () { - function SwitchFirstOperator() { - } - SwitchFirstOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SwitchFirstSubscriber(subscriber)); - }; - return SwitchFirstOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SwitchFirstSubscriber = (function (_super) { - __extends(SwitchFirstSubscriber, _super); - function SwitchFirstSubscriber(destination) { - _super.call(this, destination); - this.hasCompleted = false; - this.hasSubscription = false; - } - SwitchFirstSubscriber.prototype._next = function (value) { - if (!this.hasSubscription) { - this.hasSubscription = true; - this.add(subscribeToResult_1.subscribeToResult(this, value)); - } - }; - SwitchFirstSubscriber.prototype._complete = function () { - this.hasCompleted = true; - if (!this.hasSubscription) { - this.destination.complete(); - } - }; - SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) { - this.remove(innerSub); - this.hasSubscription = false; - if (this.hasCompleted) { - this.destination.complete(); - } - }; - return SwitchFirstSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=exhaust.js.map - -/***/ }, -/* 238 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var exhaustMap_1 = __webpack_require__(239); - Observable_1.Observable.prototype.exhaustMap = exhaustMap_1.exhaustMap; - //# sourceMappingURL=exhaustMap.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var debounce_1 = __webpack_require__(238); +Observable_1.Observable.prototype.debounce = debounce_1.debounce; +//# sourceMappingURL=debounce.js.map + +/***/ }), +/* 238 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Emits a value from the source Observable only after a particular time span + * determined by another Observable has passed without another source emission. + * + * It's like {@link debounceTime}, but the time span of + * emission silence is determined by a second Observable. + * + * + * + * `debounce` delays values emitted by the source Observable, but drops previous + * pending delayed emissions if a new value arrives on the source Observable. + * This operator keeps track of the most recent value from the source + * Observable, and spawns a duration Observable by calling the + * `durationSelector` function. The value is emitted only when the duration + * Observable emits a value or completes, and if no other value was emitted on + * the source Observable since the duration Observable was spawned. If a new + * value appears before the duration Observable emits, the previous value will + * be dropped and will not be emitted on the output Observable. + * + * Like {@link debounceTime}, this is a rate-limiting operator, and also a + * delay-like operator since output emissions do not necessarily occur at the + * same time as they did on the source Observable. + * + * @example Emit the most recent click after a burst of clicks + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.debounce(() => Rx.Observable.interval(1000)); + * result.subscribe(x => console.log(x)); + * + * @see {@link audit} + * @see {@link debounceTime} + * @see {@link delayWhen} + * @see {@link throttle} + * + * @param {function(value: T): SubscribableOrPromise} durationSelector A function + * that receives a value from the source Observable, for computing the timeout + * duration for each source value, returned as an Observable or a Promise. + * @return {Observable} An Observable that delays the emissions of the source + * Observable by the specified duration Observable returned by + * `durationSelector`, and may drop some values if they occur too frequently. + * @method debounce + * @owner Observable + */ +function debounce(durationSelector) { + return this.lift(new DebounceOperator(durationSelector)); +} +exports.debounce = debounce; +var DebounceOperator = (function () { + function DebounceOperator(durationSelector) { + this.durationSelector = durationSelector; + } + DebounceOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector)); + }; + return DebounceOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DebounceSubscriber = (function (_super) { + __extends(DebounceSubscriber, _super); + function DebounceSubscriber(destination, durationSelector) { + _super.call(this, destination); + this.durationSelector = durationSelector; + this.hasValue = false; + this.durationSubscription = null; + } + DebounceSubscriber.prototype._next = function (value) { + try { + var result = this.durationSelector.call(this, value); + if (result) { + this._tryNext(value, result); + } + } + catch (err) { + this.destination.error(err); + } + }; + DebounceSubscriber.prototype._complete = function () { + this.emitValue(); + this.destination.complete(); + }; + DebounceSubscriber.prototype._tryNext = function (value, duration) { + var subscription = this.durationSubscription; + this.value = value; + this.hasValue = true; + if (subscription) { + subscription.unsubscribe(); + this.remove(subscription); + } + subscription = subscribeToResult_1.subscribeToResult(this, duration); + if (!subscription.closed) { + this.add(this.durationSubscription = subscription); + } + }; + DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.emitValue(); + }; + DebounceSubscriber.prototype.notifyComplete = function () { + this.emitValue(); + }; + DebounceSubscriber.prototype.emitValue = function () { + if (this.hasValue) { + var value = this.value; + var subscription = this.durationSubscription; + if (subscription) { + this.durationSubscription = null; + subscription.unsubscribe(); + this.remove(subscription); + } + this.value = null; + this.hasValue = false; + _super.prototype._next.call(this, value); + } + }; + return DebounceSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=debounce.js.map + +/***/ }), /* 239 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /* tslint:enable:max-line-length */ - /** - * Projects each source value to an Observable which is merged in the output - * Observable only if the previous projected Observable has completed. - * - * Maps each value to an Observable, then flattens all of - * these inner Observables using {@link exhaust}. - * - * - * - * Returns an Observable that emits items based on applying a function that you - * supply to each item emitted by the source Observable, where that function - * returns an (so-called "inner") Observable. When it projects a source value to - * an Observable, the output Observable begins emitting the items emitted by - * that projected Observable. However, `exhaustMap` ignores every new projected - * Observable if the previous projected Observable has not yet completed. Once - * that one completes, it will accept and flatten the next projected Observable - * and repeat this process. - * - * @example Run a finite timer for each click, only if there is no currently active timer - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.exhaustMap((ev) => Rx.Observable.interval(1000).take(5)); - * result.subscribe(x => console.log(x)); - * - * @see {@link concatMap} - * @see {@link exhaust} - * @see {@link mergeMap} - * @see {@link switchMap} - * - * @param {function(value: T, ?index: number): ObservableInput} project A function - * that, when applied to an item emitted by the source Observable, returns an - * Observable. - * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] - * A function to produce the value on the output Observable based on the values - * and the indices of the source (outer) emission and the inner Observable - * emission. The arguments passed to this function are: - * - `outerValue`: the value that came from the source - * - `innerValue`: the value that came from the projected Observable - * - `outerIndex`: the "index" of the value that came from the source - * - `innerIndex`: the "index" of the value from the projected Observable - * @return {Observable} An Observable containing projected Observables - * of each item of the source, ignoring projected Observables that start before - * their preceding Observable has completed. - * @method exhaustMap - * @owner Observable - */ - function exhaustMap(project, resultSelector) { - return this.lift(new SwitchFirstMapOperator(project, resultSelector)); - } - exports.exhaustMap = exhaustMap; - var SwitchFirstMapOperator = (function () { - function SwitchFirstMapOperator(project, resultSelector) { - this.project = project; - this.resultSelector = resultSelector; - } - SwitchFirstMapOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SwitchFirstMapSubscriber(subscriber, this.project, this.resultSelector)); - }; - return SwitchFirstMapOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SwitchFirstMapSubscriber = (function (_super) { - __extends(SwitchFirstMapSubscriber, _super); - function SwitchFirstMapSubscriber(destination, project, resultSelector) { - _super.call(this, destination); - this.project = project; - this.resultSelector = resultSelector; - this.hasSubscription = false; - this.hasCompleted = false; - this.index = 0; - } - SwitchFirstMapSubscriber.prototype._next = function (value) { - if (!this.hasSubscription) { - this.tryNext(value); - } - }; - SwitchFirstMapSubscriber.prototype.tryNext = function (value) { - var index = this.index++; - var destination = this.destination; - try { - var result = this.project(value, index); - this.hasSubscription = true; - this.add(subscribeToResult_1.subscribeToResult(this, result, value, index)); - } - catch (err) { - destination.error(err); - } - }; - SwitchFirstMapSubscriber.prototype._complete = function () { - this.hasCompleted = true; - if (!this.hasSubscription) { - this.destination.complete(); - } - }; - SwitchFirstMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; - if (resultSelector) { - this.trySelectResult(outerValue, innerValue, outerIndex, innerIndex); - } - else { - destination.next(innerValue); - } - }; - SwitchFirstMapSubscriber.prototype.trySelectResult = function (outerValue, innerValue, outerIndex, innerIndex) { - var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; - try { - var result = resultSelector(outerValue, innerValue, outerIndex, innerIndex); - destination.next(result); - } - catch (err) { - destination.error(err); - } - }; - SwitchFirstMapSubscriber.prototype.notifyError = function (err) { - this.destination.error(err); - }; - SwitchFirstMapSubscriber.prototype.notifyComplete = function (innerSub) { - this.remove(innerSub); - this.hasSubscription = false; - if (this.hasCompleted) { - this.destination.complete(); - } - }; - return SwitchFirstMapSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=exhaustMap.js.map - -/***/ }, -/* 240 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var expand_1 = __webpack_require__(241); - Observable_1.Observable.prototype.expand = expand_1.expand; - //# sourceMappingURL=expand.js.map +var Observable_1 = __webpack_require__(0); +var debounceTime_1 = __webpack_require__(240); +Observable_1.Observable.prototype.debounceTime = debounceTime_1.debounceTime; +//# sourceMappingURL=debounceTime.js.map -/***/ }, +/***/ }), +/* 240 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var async_1 = __webpack_require__(9); +/** + * Emits a value from the source Observable only after a particular time span + * has passed without another source emission. + * + * It's like {@link delay}, but passes only the most + * recent value from each burst of emissions. + * + * + * + * `debounceTime` delays values emitted by the source Observable, but drops + * previous pending delayed emissions if a new value arrives on the source + * Observable. This operator keeps track of the most recent value from the + * source Observable, and emits that only when `dueTime` enough time has passed + * without any other value appearing on the source Observable. If a new value + * appears before `dueTime` silence occurs, the previous value will be dropped + * and will not be emitted on the output Observable. + * + * This is a rate-limiting operator, because it is impossible for more than one + * value to be emitted in any time window of duration `dueTime`, but it is also + * a delay-like operator since output emissions do not occur at the same time as + * they did on the source Observable. Optionally takes a {@link IScheduler} for + * managing timers. + * + * @example Emit the most recent click after a burst of clicks + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.debounceTime(1000); + * result.subscribe(x => console.log(x)); + * + * @see {@link auditTime} + * @see {@link debounce} + * @see {@link delay} + * @see {@link sampleTime} + * @see {@link throttleTime} + * + * @param {number} dueTime The timeout duration in milliseconds (or the time + * unit determined internally by the optional `scheduler`) for the window of + * time required to wait for emission silence before emitting the most recent + * source value. + * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for + * managing the timers that handle the timeout for each value. + * @return {Observable} An Observable that delays the emissions of the source + * Observable by the specified `dueTime`, and may drop some values if they occur + * too frequently. + * @method debounceTime + * @owner Observable + */ +function debounceTime(dueTime, scheduler) { + if (scheduler === void 0) { scheduler = async_1.async; } + return this.lift(new DebounceTimeOperator(dueTime, scheduler)); +} +exports.debounceTime = debounceTime; +var DebounceTimeOperator = (function () { + function DebounceTimeOperator(dueTime, scheduler) { + this.dueTime = dueTime; + this.scheduler = scheduler; + } + DebounceTimeOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler)); + }; + return DebounceTimeOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DebounceTimeSubscriber = (function (_super) { + __extends(DebounceTimeSubscriber, _super); + function DebounceTimeSubscriber(destination, dueTime, scheduler) { + _super.call(this, destination); + this.dueTime = dueTime; + this.scheduler = scheduler; + this.debouncedSubscription = null; + this.lastValue = null; + this.hasValue = false; + } + DebounceTimeSubscriber.prototype._next = function (value) { + this.clearDebounce(); + this.lastValue = value; + this.hasValue = true; + this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this)); + }; + DebounceTimeSubscriber.prototype._complete = function () { + this.debouncedNext(); + this.destination.complete(); + }; + DebounceTimeSubscriber.prototype.debouncedNext = function () { + this.clearDebounce(); + if (this.hasValue) { + this.destination.next(this.lastValue); + this.lastValue = null; + this.hasValue = false; + } + }; + DebounceTimeSubscriber.prototype.clearDebounce = function () { + var debouncedSubscription = this.debouncedSubscription; + if (debouncedSubscription !== null) { + this.remove(debouncedSubscription); + debouncedSubscription.unsubscribe(); + this.debouncedSubscription = null; + } + }; + return DebounceTimeSubscriber; +}(Subscriber_1.Subscriber)); +function dispatchNext(subscriber) { + subscriber.debouncedNext(); +} +//# sourceMappingURL=debounceTime.js.map + +/***/ }), /* 241 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /* tslint:enable:max-line-length */ - /** - * Recursively projects each source value to an Observable which is merged in - * the output Observable. - * - * It's similar to {@link mergeMap}, but applies the - * projection function to every source value as well as every output value. - * It's recursive. - * - * - * - * Returns an Observable that emits items based on applying a function that you - * supply to each item emitted by the source Observable, where that function - * returns an Observable, and then merging those resulting Observables and - * emitting the results of this merger. *Expand* will re-emit on the output - * Observable every source value. Then, each output value is given to the - * `project` function which returns an inner Observable to be merged on the - * output Observable. Those output values resulting from the projection are also - * given to the `project` function to produce new output values. This is how - * *expand* behaves recursively. - * - * @example Start emitting the powers of two on every click, at most 10 of them - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var powersOfTwo = clicks - * .mapTo(1) - * .expand(x => Rx.Observable.of(2 * x).delay(1000)) - * .take(10); - * powersOfTwo.subscribe(x => console.log(x)); - * - * @see {@link mergeMap} - * @see {@link mergeScan} - * - * @param {function(value: T, index: number) => Observable} project A function - * that, when applied to an item emitted by the source or the output Observable, - * returns an Observable. - * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input - * Observables being subscribed to concurrently. - * @param {Scheduler} [scheduler=null] The IScheduler to use for subscribing to - * each projected inner Observable. - * @return {Observable} An Observable that emits the source values and also - * result of applying the projection function to each value emitted on the - * output Observable and and merging the results of the Observables obtained - * from this transformation. - * @method expand - * @owner Observable - */ - function expand(project, concurrent, scheduler) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - if (scheduler === void 0) { scheduler = undefined; } - concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent; - return this.lift(new ExpandOperator(project, concurrent, scheduler)); - } - exports.expand = expand; - var ExpandOperator = (function () { - function ExpandOperator(project, concurrent, scheduler) { - this.project = project; - this.concurrent = concurrent; - this.scheduler = scheduler; - } - ExpandOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler)); - }; - return ExpandOperator; - }()); - exports.ExpandOperator = ExpandOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ExpandSubscriber = (function (_super) { - __extends(ExpandSubscriber, _super); - function ExpandSubscriber(destination, project, concurrent, scheduler) { - _super.call(this, destination); - this.project = project; - this.concurrent = concurrent; - this.scheduler = scheduler; - this.index = 0; - this.active = 0; - this.hasCompleted = false; - if (concurrent < Number.POSITIVE_INFINITY) { - this.buffer = []; - } - } - ExpandSubscriber.dispatch = function (arg) { - var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index; - subscriber.subscribeToProjection(result, value, index); - }; - ExpandSubscriber.prototype._next = function (value) { - var destination = this.destination; - if (destination.closed) { - this._complete(); - return; - } - var index = this.index++; - if (this.active < this.concurrent) { - destination.next(value); - var result = tryCatch_1.tryCatch(this.project)(value, index); - if (result === errorObject_1.errorObject) { - destination.error(errorObject_1.errorObject.e); - } - else if (!this.scheduler) { - this.subscribeToProjection(result, value, index); - } - else { - var state = { subscriber: this, result: result, value: value, index: index }; - this.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state)); - } - } - else { - this.buffer.push(value); - } - }; - ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) { - this.active++; - this.add(subscribeToResult_1.subscribeToResult(this, result, value, index)); - }; - ExpandSubscriber.prototype._complete = function () { - this.hasCompleted = true; - if (this.hasCompleted && this.active === 0) { - this.destination.complete(); - } - }; - ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this._next(innerValue); - }; - ExpandSubscriber.prototype.notifyComplete = function (innerSub) { - var buffer = this.buffer; - this.remove(innerSub); - this.active--; - if (buffer && buffer.length > 0) { - this._next(buffer.shift()); - } - if (this.hasCompleted && this.active === 0) { - this.destination.complete(); - } - }; - return ExpandSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.ExpandSubscriber = ExpandSubscriber; - //# sourceMappingURL=expand.js.map - -/***/ }, -/* 242 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var elementAt_1 = __webpack_require__(243); - Observable_1.Observable.prototype.elementAt = elementAt_1.elementAt; - //# sourceMappingURL=elementAt.js.map +var Observable_1 = __webpack_require__(0); +var defaultIfEmpty_1 = __webpack_require__(242); +Observable_1.Observable.prototype.defaultIfEmpty = defaultIfEmpty_1.defaultIfEmpty; +//# sourceMappingURL=defaultIfEmpty.js.map -/***/ }, +/***/ }), +/* 242 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/* tslint:enable:max-line-length */ +/** + * Emits a given value if the source Observable completes without emitting any + * `next` value, otherwise mirrors the source Observable. + * + * If the source Observable turns out to be empty, then + * this operator will emit a default value. + * + * + * + * `defaultIfEmpty` emits the values emitted by the source Observable or a + * specified default value if the source Observable is empty (completes without + * having emitted any `next` value). + * + * @example If no clicks happen in 5 seconds, then emit "no clicks" + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var clicksBeforeFive = clicks.takeUntil(Rx.Observable.interval(5000)); + * var result = clicksBeforeFive.defaultIfEmpty('no clicks'); + * result.subscribe(x => console.log(x)); + * + * @see {@link empty} + * @see {@link last} + * + * @param {any} [defaultValue=null] The default value used if the source + * Observable is empty. + * @return {Observable} An Observable that emits either the specified + * `defaultValue` if the source Observable emits no items, or the values emitted + * by the source Observable. + * @method defaultIfEmpty + * @owner Observable + */ +function defaultIfEmpty(defaultValue) { + if (defaultValue === void 0) { defaultValue = null; } + return this.lift(new DefaultIfEmptyOperator(defaultValue)); +} +exports.defaultIfEmpty = defaultIfEmpty; +var DefaultIfEmptyOperator = (function () { + function DefaultIfEmptyOperator(defaultValue) { + this.defaultValue = defaultValue; + } + DefaultIfEmptyOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue)); + }; + return DefaultIfEmptyOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DefaultIfEmptySubscriber = (function (_super) { + __extends(DefaultIfEmptySubscriber, _super); + function DefaultIfEmptySubscriber(destination, defaultValue) { + _super.call(this, destination); + this.defaultValue = defaultValue; + this.isEmpty = true; + } + DefaultIfEmptySubscriber.prototype._next = function (value) { + this.isEmpty = false; + this.destination.next(value); + }; + DefaultIfEmptySubscriber.prototype._complete = function () { + if (this.isEmpty) { + this.destination.next(this.defaultValue); + } + this.destination.complete(); + }; + return DefaultIfEmptySubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=defaultIfEmpty.js.map + +/***/ }), /* 243 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var ArgumentOutOfRangeError_1 = __webpack_require__(244); - /** - * Emits the single value at the specified `index` in a sequence of emissions - * from the source Observable. - * - * Emits only the i-th value, then completes. - * - * - * - * `elementAt` returns an Observable that emits the item at the specified - * `index` in the source Observable, or a default value if that `index` is out - * of range and the `default` argument is provided. If the `default` argument is - * not given and the `index` is out of range, the output Observable will emit an - * `ArgumentOutOfRangeError` error. - * - * @example Emit only the third click event - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.elementAt(2); - * result.subscribe(x => console.log(x)); - * - * // Results in: - * // click 1 = nothing - * // click 2 = nothing - * // click 3 = MouseEvent object logged to console - * - * @see {@link first} - * @see {@link last} - * @see {@link skip} - * @see {@link single} - * @see {@link take} - * - * @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an - * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the - * Observable has completed before emitting the i-th `next` notification. - * - * @param {number} index Is the number `i` for the i-th source emission that has - * happened since the subscription, starting from the number `0`. - * @param {T} [defaultValue] The default value returned for missing indices. - * @return {Observable} An Observable that emits a single item, if it is found. - * Otherwise, will emit the default value if given. If not, then emits an error. - * @method elementAt - * @owner Observable - */ - function elementAt(index, defaultValue) { - return this.lift(new ElementAtOperator(index, defaultValue)); - } - exports.elementAt = elementAt; - var ElementAtOperator = (function () { - function ElementAtOperator(index, defaultValue) { - this.index = index; - this.defaultValue = defaultValue; - if (index < 0) { - throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError; - } - } - ElementAtOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ElementAtSubscriber(subscriber, this.index, this.defaultValue)); - }; - return ElementAtOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ElementAtSubscriber = (function (_super) { - __extends(ElementAtSubscriber, _super); - function ElementAtSubscriber(destination, index, defaultValue) { - _super.call(this, destination); - this.index = index; - this.defaultValue = defaultValue; - } - ElementAtSubscriber.prototype._next = function (x) { - if (this.index-- === 0) { - this.destination.next(x); - this.destination.complete(); - } - }; - ElementAtSubscriber.prototype._complete = function () { - var destination = this.destination; - if (this.index >= 0) { - if (typeof this.defaultValue !== 'undefined') { - destination.next(this.defaultValue); - } - else { - destination.error(new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError); - } - } - destination.complete(); - }; - return ElementAtSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=elementAt.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var delay_1 = __webpack_require__(244); +Observable_1.Observable.prototype.delay = delay_1.delay; +//# sourceMappingURL=delay.js.map + +/***/ }), /* 244 */ -/***/ function(module, exports) { - - "use strict"; - var __extends = (this && this.__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 an element was queried at a certain index of an - * Observable, but no such index or position exists in that sequence. - * - * @see {@link elementAt} - * @see {@link take} - * @see {@link takeLast} - * - * @class ArgumentOutOfRangeError - */ - var ArgumentOutOfRangeError = (function (_super) { - __extends(ArgumentOutOfRangeError, _super); - function ArgumentOutOfRangeError() { - var err = _super.call(this, 'argument out of range'); - this.name = err.name = 'ArgumentOutOfRangeError'; - this.stack = err.stack; - this.message = err.message; - } - return ArgumentOutOfRangeError; - }(Error)); - exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError; - //# sourceMappingURL=ArgumentOutOfRangeError.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 async_1 = __webpack_require__(9); +var isDate_1 = __webpack_require__(35); +var Subscriber_1 = __webpack_require__(1); +var Notification_1 = __webpack_require__(22); +/** + * Delays the emission of items from the source Observable by a given timeout or + * until a given Date. + * + * Time shifts each item by some specified amount of + * milliseconds. + * + * + * + * If the delay argument is a Number, this operator time shifts the source + * Observable by that amount of time expressed in milliseconds. The relative + * time intervals between the values are preserved. + * + * If the delay argument is a Date, this operator time shifts the start of the + * Observable execution until the given date occurs. + * + * @example Delay each click by one second + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var delayedClicks = clicks.delay(1000); // each click emitted after 1 second + * delayedClicks.subscribe(x => console.log(x)); + * + * @example Delay all clicks until a future date happens + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var date = new Date('March 15, 2050 12:00:00'); // in the future + * var delayedClicks = clicks.delay(date); // click emitted only after that date + * delayedClicks.subscribe(x => console.log(x)); + * + * @see {@link debounceTime} + * @see {@link delayWhen} + * + * @param {number|Date} delay The delay duration in milliseconds (a `number`) or + * a `Date` until which the emission of the source items is delayed. + * @param {Scheduler} [scheduler=async] The IScheduler to use for + * managing the timers that handle the time-shift for each item. + * @return {Observable} An Observable that delays the emissions of the source + * Observable by the specified timeout or Date. + * @method delay + * @owner Observable + */ +function delay(delay, scheduler) { + if (scheduler === void 0) { scheduler = async_1.async; } + var absoluteDelay = isDate_1.isDate(delay); + var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay); + return this.lift(new DelayOperator(delayFor, scheduler)); +} +exports.delay = delay; +var DelayOperator = (function () { + function DelayOperator(delay, scheduler) { + this.delay = delay; + this.scheduler = scheduler; + } + DelayOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler)); + }; + return DelayOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DelaySubscriber = (function (_super) { + __extends(DelaySubscriber, _super); + function DelaySubscriber(destination, delay, scheduler) { + _super.call(this, destination); + this.delay = delay; + this.scheduler = scheduler; + this.queue = []; + this.active = false; + this.errored = false; + } + DelaySubscriber.dispatch = function (state) { + var source = state.source; + var queue = source.queue; + var scheduler = state.scheduler; + var destination = state.destination; + while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) { + queue.shift().notification.observe(destination); + } + if (queue.length > 0) { + var delay_1 = Math.max(0, queue[0].time - scheduler.now()); + this.schedule(state, delay_1); + } + else { + source.active = false; + } + }; + DelaySubscriber.prototype._schedule = function (scheduler) { + this.active = true; + this.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, { + source: this, destination: this.destination, scheduler: scheduler + })); + }; + DelaySubscriber.prototype.scheduleNotification = function (notification) { + if (this.errored === true) { + return; + } + var scheduler = this.scheduler; + var message = new DelayMessage(scheduler.now() + this.delay, notification); + this.queue.push(message); + if (this.active === false) { + this._schedule(scheduler); + } + }; + DelaySubscriber.prototype._next = function (value) { + this.scheduleNotification(Notification_1.Notification.createNext(value)); + }; + DelaySubscriber.prototype._error = function (err) { + this.errored = true; + this.queue = []; + this.destination.error(err); + }; + DelaySubscriber.prototype._complete = function () { + this.scheduleNotification(Notification_1.Notification.createComplete()); + }; + return DelaySubscriber; +}(Subscriber_1.Subscriber)); +var DelayMessage = (function () { + function DelayMessage(time, notification) { + this.time = time; + this.notification = notification; + } + return DelayMessage; +}()); +//# sourceMappingURL=delay.js.map + +/***/ }), /* 245 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var filter_1 = __webpack_require__(246); - Observable_1.Observable.prototype.filter = filter_1.filter; - //# sourceMappingURL=filter.js.map +var Observable_1 = __webpack_require__(0); +var delayWhen_1 = __webpack_require__(246); +Observable_1.Observable.prototype.delayWhen = delayWhen_1.delayWhen; +//# sourceMappingURL=delayWhen.js.map -/***/ }, +/***/ }), /* 246 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /* tslint:enable:max-line-length */ - /** - * Filter items emitted by the source Observable by only emitting those that - * satisfy a specified predicate. - * - * Like - * [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter), - * it only emits a value from the source if it passes a criterion function. - * - * - * - * Similar to the well-known `Array.prototype.filter` method, this operator - * takes values from the source Observable, passes them through a `predicate` - * function and only emits those values that yielded `true`. - * - * @example Emit only click events whose target was a DIV element - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var clicksOnDivs = clicks.filter(ev => ev.target.tagName === 'DIV'); - * clicksOnDivs.subscribe(x => console.log(x)); - * - * @see {@link distinct} - * @see {@link distinctUntilChanged} - * @see {@link distinctUntilKeyChanged} - * @see {@link ignoreElements} - * @see {@link partition} - * @see {@link skip} - * - * @param {function(value: T, index: number): boolean} predicate A function that - * evaluates each value emitted by the source Observable. If it returns `true`, - * the value is emitted, if `false` the value is not passed to the output - * Observable. The `index` parameter is the number `i` for the i-th source - * emission that has happened since the subscription, starting from the number - * `0`. - * @param {any} [thisArg] An optional argument to determine the value of `this` - * in the `predicate` function. - * @return {Observable} An Observable of values from the source that were - * allowed by the `predicate` function. - * @method filter - * @owner Observable - */ - function filter(predicate, thisArg) { - return this.lift(new FilterOperator(predicate, thisArg)); - } - exports.filter = filter; - var FilterOperator = (function () { - function FilterOperator(predicate, thisArg) { - this.predicate = predicate; - this.thisArg = thisArg; - } - FilterOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg)); - }; - return FilterOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var FilterSubscriber = (function (_super) { - __extends(FilterSubscriber, _super); - function FilterSubscriber(destination, predicate, thisArg) { - _super.call(this, destination); - this.predicate = predicate; - this.thisArg = thisArg; - this.count = 0; - } - // the try catch block below is left specifically for - // optimization and perf reasons. a tryCatcher is not necessary here. - FilterSubscriber.prototype._next = function (value) { - var result; - try { - result = this.predicate.call(this.thisArg, value, this.count++); - } - catch (err) { - this.destination.error(err); - return; - } - if (result) { - this.destination.next(value); - } - }; - return FilterSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=filter.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var Observable_1 = __webpack_require__(0); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Delays the emission of items from the source Observable by a given time span + * determined by the emissions of another Observable. + * + * It's like {@link delay}, but the time span of the + * delay duration is determined by a second Observable. + * + * + * + * `delayWhen` time shifts each emitted value from the source Observable by a + * time span determined by another Observable. When the source emits a value, + * the `delayDurationSelector` function is called with the source value as + * argument, and should return an Observable, called the "duration" Observable. + * The source value is emitted on the output Observable only when the duration + * Observable emits a value or completes. + * + * Optionally, `delayWhen` takes a second argument, `subscriptionDelay`, which + * is an Observable. When `subscriptionDelay` emits its first value or + * completes, the source Observable is subscribed to and starts behaving like + * described in the previous paragraph. If `subscriptionDelay` is not provided, + * `delayWhen` will subscribe to the source Observable as soon as the output + * Observable is subscribed. + * + * @example Delay each click by a random amount of time, between 0 and 5 seconds + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var delayedClicks = clicks.delayWhen(event => + * Rx.Observable.interval(Math.random() * 5000) + * ); + * delayedClicks.subscribe(x => console.log(x)); + * + * @see {@link debounce} + * @see {@link delay} + * + * @param {function(value: T): Observable} delayDurationSelector A function that + * returns an Observable for each value emitted by the source Observable, which + * is then used to delay the emission of that item on the output Observable + * until the Observable returned from this function emits a value. + * @param {Observable} subscriptionDelay An Observable that triggers the + * subscription to the source Observable once it emits any value. + * @return {Observable} An Observable that delays the emissions of the source + * Observable by an amount of time specified by the Observable returned by + * `delayDurationSelector`. + * @method delayWhen + * @owner Observable + */ +function delayWhen(delayDurationSelector, subscriptionDelay) { + if (subscriptionDelay) { + return new SubscriptionDelayObservable(this, subscriptionDelay) + .lift(new DelayWhenOperator(delayDurationSelector)); + } + return this.lift(new DelayWhenOperator(delayDurationSelector)); +} +exports.delayWhen = delayWhen; +var DelayWhenOperator = (function () { + function DelayWhenOperator(delayDurationSelector) { + this.delayDurationSelector = delayDurationSelector; + } + DelayWhenOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector)); + }; + return DelayWhenOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DelayWhenSubscriber = (function (_super) { + __extends(DelayWhenSubscriber, _super); + function DelayWhenSubscriber(destination, delayDurationSelector) { + _super.call(this, destination); + this.delayDurationSelector = delayDurationSelector; + this.completed = false; + this.delayNotifierSubscriptions = []; + this.values = []; + } + DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.destination.next(outerValue); + this.removeSubscription(innerSub); + this.tryComplete(); + }; + DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) { + this._error(error); + }; + DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) { + var value = this.removeSubscription(innerSub); + if (value) { + this.destination.next(value); + } + this.tryComplete(); + }; + DelayWhenSubscriber.prototype._next = function (value) { + try { + var delayNotifier = this.delayDurationSelector(value); + if (delayNotifier) { + this.tryDelay(delayNotifier, value); + } + } + catch (err) { + this.destination.error(err); + } + }; + DelayWhenSubscriber.prototype._complete = function () { + this.completed = true; + this.tryComplete(); + }; + DelayWhenSubscriber.prototype.removeSubscription = function (subscription) { + subscription.unsubscribe(); + var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription); + var value = null; + if (subscriptionIdx !== -1) { + value = this.values[subscriptionIdx]; + this.delayNotifierSubscriptions.splice(subscriptionIdx, 1); + this.values.splice(subscriptionIdx, 1); + } + return value; + }; + DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) { + var notifierSubscription = subscribeToResult_1.subscribeToResult(this, delayNotifier, value); + if (notifierSubscription && !notifierSubscription.closed) { + this.add(notifierSubscription); + this.delayNotifierSubscriptions.push(notifierSubscription); + } + this.values.push(value); + }; + DelayWhenSubscriber.prototype.tryComplete = function () { + if (this.completed && this.delayNotifierSubscriptions.length === 0) { + this.destination.complete(); + } + }; + return DelayWhenSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SubscriptionDelayObservable = (function (_super) { + __extends(SubscriptionDelayObservable, _super); + function SubscriptionDelayObservable(source, subscriptionDelay) { + _super.call(this); + this.source = source; + this.subscriptionDelay = subscriptionDelay; + } + SubscriptionDelayObservable.prototype._subscribe = function (subscriber) { + this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source)); + }; + return SubscriptionDelayObservable; +}(Observable_1.Observable)); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SubscriptionDelaySubscriber = (function (_super) { + __extends(SubscriptionDelaySubscriber, _super); + function SubscriptionDelaySubscriber(parent, source) { + _super.call(this); + this.parent = parent; + this.source = source; + this.sourceSubscribed = false; + } + SubscriptionDelaySubscriber.prototype._next = function (unused) { + this.subscribeToSource(); + }; + SubscriptionDelaySubscriber.prototype._error = function (err) { + this.unsubscribe(); + this.parent.error(err); + }; + SubscriptionDelaySubscriber.prototype._complete = function () { + this.subscribeToSource(); + }; + SubscriptionDelaySubscriber.prototype.subscribeToSource = function () { + if (!this.sourceSubscribed) { + this.sourceSubscribed = true; + this.unsubscribe(); + this.source.subscribe(this.parent); + } + }; + return SubscriptionDelaySubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=delayWhen.js.map + +/***/ }), /* 247 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var finally_1 = __webpack_require__(248); - Observable_1.Observable.prototype.finally = finally_1._finally; - Observable_1.Observable.prototype._finally = finally_1._finally; - //# sourceMappingURL=finally.js.map +var Observable_1 = __webpack_require__(0); +var distinct_1 = __webpack_require__(248); +Observable_1.Observable.prototype.distinct = distinct_1.distinct; +//# sourceMappingURL=distinct.js.map -/***/ }, +/***/ }), /* 248 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var Subscription_1 = __webpack_require__(69); - /** - * Returns an Observable that mirrors the source Observable, but will call a specified function when - * the source terminates on complete or error. - * @param {function} callback Function to be called when source terminates. - * @return {Observable} An Observable that mirrors the source, but will call the specified function on termination. - * @method finally - * @owner Observable - */ - function _finally(callback) { - return this.lift(new FinallyOperator(callback)); - } - exports._finally = _finally; - var FinallyOperator = (function () { - function FinallyOperator(callback) { - this.callback = callback; - } - FinallyOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new FinallySubscriber(subscriber, this.callback)); - }; - return FinallyOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var FinallySubscriber = (function (_super) { - __extends(FinallySubscriber, _super); - function FinallySubscriber(destination, callback) { - _super.call(this, destination); - this.add(new Subscription_1.Subscription(callback)); - } - return FinallySubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=finally.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +var Set_1 = __webpack_require__(249); +/** + * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from previous items. + * + * If a keySelector function is provided, then it will project each value from the source observable into a new value that it will + * check for equality with previously projected values. If a keySelector function is not provided, it will use each value from the + * source observable directly with an equality check against previous values. + * + * In JavaScript runtimes that support `Set`, this operator will use a `Set` to improve performance of the distinct value checking. + * + * In other runtimes, this operator will use a minimal implementation of `Set` that relies on an `Array` and `indexOf` under the + * hood, so performance will degrade as more values are checked for distinction. Even in newer browsers, a long-running `distinct` + * use might result in memory leaks. To help alleviate this in some scenarios, an optional `flushes` parameter is also provided so + * that the internal `Set` can be "flushed", basically clearing it of values. + * + * @example A simple example with numbers + * Observable.of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1) + * .distinct() + * .subscribe(x => console.log(x)); // 1, 2, 3, 4 + * + * @example An example using a keySelector function + * interface Person { + * age: number, + * name: string + * } + * + * Observable.of( + * { age: 4, name: 'Foo'}, + * { age: 7, name: 'Bar'}, + * { age: 5, name: 'Foo'}) + * .distinct((p: Person) => p.name) + * .subscribe(x => console.log(x)); + * + * // displays: + * // { age: 4, name: 'Foo' } + * // { age: 7, name: 'Bar' } + * + * @see {@link distinctUntilChanged} + * @see {@link distinctUntilKeyChanged} + * + * @param {function} [keySelector] Optional function to select which value you want to check as distinct. + * @param {Observable} [flushes] Optional Observable for flushing the internal HashSet of the operator. + * @return {Observable} An Observable that emits items from the source Observable with distinct values. + * @method distinct + * @owner Observable + */ +function distinct(keySelector, flushes) { + return this.lift(new DistinctOperator(keySelector, flushes)); +} +exports.distinct = distinct; +var DistinctOperator = (function () { + function DistinctOperator(keySelector, flushes) { + this.keySelector = keySelector; + this.flushes = flushes; + } + DistinctOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes)); + }; + return DistinctOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DistinctSubscriber = (function (_super) { + __extends(DistinctSubscriber, _super); + function DistinctSubscriber(destination, keySelector, flushes) { + _super.call(this, destination); + this.keySelector = keySelector; + this.values = new Set_1.Set(); + if (flushes) { + this.add(subscribeToResult_1.subscribeToResult(this, flushes)); + } + } + DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.values.clear(); + }; + DistinctSubscriber.prototype.notifyError = function (error, innerSub) { + this._error(error); + }; + DistinctSubscriber.prototype._next = function (value) { + if (this.keySelector) { + this._useKeySelector(value); + } + else { + this._finalizeNext(value, value); + } + }; + DistinctSubscriber.prototype._useKeySelector = function (value) { + var key; + var destination = this.destination; + try { + key = this.keySelector(value); + } + catch (err) { + destination.error(err); + return; + } + this._finalizeNext(key, value); + }; + DistinctSubscriber.prototype._finalizeNext = function (key, value) { + var values = this.values; + if (!values.has(key)) { + values.add(key); + this.destination.next(value); + } + }; + return DistinctSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.DistinctSubscriber = DistinctSubscriber; +//# sourceMappingURL=distinct.js.map + +/***/ }), /* 249 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var root_1 = __webpack_require__(7); +function minimalSetImpl() { + // THIS IS NOT a full impl of Set, this is just the minimum + // bits of functionality we need for this library. + return (function () { + function MinimalSet() { + this._values = []; + } + MinimalSet.prototype.add = function (value) { + if (!this.has(value)) { + this._values.push(value); + } + }; + MinimalSet.prototype.has = function (value) { + return this._values.indexOf(value) !== -1; + }; + Object.defineProperty(MinimalSet.prototype, "size", { + get: function () { + return this._values.length; + }, + enumerable: true, + configurable: true + }); + MinimalSet.prototype.clear = function () { + this._values.length = 0; + }; + return MinimalSet; + }()); +} +exports.minimalSetImpl = minimalSetImpl; +exports.Set = root_1.root.Set || minimalSetImpl(); +//# sourceMappingURL=Set.js.map + +/***/ }), +/* 250 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var find_1 = __webpack_require__(250); - Observable_1.Observable.prototype.find = find_1.find; - //# sourceMappingURL=find.js.map +"use strict"; -/***/ }, -/* 250 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /* tslint:enable:max-line-length */ - /** - * Emits only the first value emitted by the source Observable that meets some - * condition. - * - * Finds the first value that passes some test and emits - * that. - * - * - * - * `find` searches for the first item in the source Observable that matches the - * specified condition embodied by the `predicate`, and returns the first - * occurrence in the source. Unlike {@link first}, the `predicate` is required - * in `find`, and does not emit an error if a valid value is not found. - * - * @example Find and emit the first click that happens on a DIV element - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.find(ev => ev.target.tagName === 'DIV'); - * result.subscribe(x => console.log(x)); - * - * @see {@link filter} - * @see {@link first} - * @see {@link findIndex} - * @see {@link take} - * - * @param {function(value: T, index: number, source: Observable): boolean} predicate - * A function called with each item to test for condition matching. - * @param {any} [thisArg] An optional argument to determine the value of `this` - * in the `predicate` function. - * @return {Observable} An Observable of the first item that matches the - * condition. - * @method find - * @owner Observable - */ - function find(predicate, thisArg) { - if (typeof predicate !== 'function') { - throw new TypeError('predicate is not a function'); - } - return this.lift(new FindValueOperator(predicate, this, false, thisArg)); - } - exports.find = find; - var FindValueOperator = (function () { - function FindValueOperator(predicate, source, yieldIndex, thisArg) { - this.predicate = predicate; - this.source = source; - this.yieldIndex = yieldIndex; - this.thisArg = thisArg; - } - FindValueOperator.prototype.call = function (observer, source) { - return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg)); - }; - return FindValueOperator; - }()); - exports.FindValueOperator = FindValueOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var FindValueSubscriber = (function (_super) { - __extends(FindValueSubscriber, _super); - function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) { - _super.call(this, destination); - this.predicate = predicate; - this.source = source; - this.yieldIndex = yieldIndex; - this.thisArg = thisArg; - this.index = 0; - } - FindValueSubscriber.prototype.notifyComplete = function (value) { - var destination = this.destination; - destination.next(value); - destination.complete(); - }; - FindValueSubscriber.prototype._next = function (value) { - var _a = this, predicate = _a.predicate, thisArg = _a.thisArg; - var index = this.index++; - try { - var result = predicate.call(thisArg || this, value, index, this.source); - if (result) { - this.notifyComplete(this.yieldIndex ? index : value); - } - } - catch (err) { - this.destination.error(err); - } - }; - FindValueSubscriber.prototype._complete = function () { - this.notifyComplete(this.yieldIndex ? -1 : undefined); - }; - return FindValueSubscriber; - }(Subscriber_1.Subscriber)); - exports.FindValueSubscriber = FindValueSubscriber; - //# sourceMappingURL=find.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var distinctUntilChanged_1 = __webpack_require__(75); +Observable_1.Observable.prototype.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged; +//# sourceMappingURL=distinctUntilChanged.js.map + +/***/ }), /* 251 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var findIndex_1 = __webpack_require__(252); - Observable_1.Observable.prototype.findIndex = findIndex_1.findIndex; - //# sourceMappingURL=findIndex.js.map +"use strict"; -/***/ }, -/* 252 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var find_1 = __webpack_require__(250); - /** - * Emits only the index of the first value emitted by the source Observable that - * meets some condition. - * - * It's like {@link find}, but emits the index of the - * found value, not the value itself. - * - * - * - * `findIndex` searches for the first item in the source Observable that matches - * the specified condition embodied by the `predicate`, and returns the - * (zero-based) index of the first occurrence in the source. Unlike - * {@link first}, the `predicate` is required in `findIndex`, and does not emit - * an error if a valid value is not found. - * - * @example Emit the index of first click that happens on a DIV element - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.findIndex(ev => ev.target.tagName === 'DIV'); - * result.subscribe(x => console.log(x)); - * - * @see {@link filter} - * @see {@link find} - * @see {@link first} - * @see {@link take} - * - * @param {function(value: T, index: number, source: Observable): boolean} predicate - * A function called with each item to test for condition matching. - * @param {any} [thisArg] An optional argument to determine the value of `this` - * in the `predicate` function. - * @return {Observable} An Observable of the index of the first item that - * matches the condition. - * @method find - * @owner Observable - */ - function findIndex(predicate, thisArg) { - return this.lift(new find_1.FindValueOperator(predicate, this, true, thisArg)); - } - exports.findIndex = findIndex; - //# sourceMappingURL=findIndex.js.map +var Observable_1 = __webpack_require__(0); +var distinctUntilKeyChanged_1 = __webpack_require__(252); +Observable_1.Observable.prototype.distinctUntilKeyChanged = distinctUntilKeyChanged_1.distinctUntilKeyChanged; +//# sourceMappingURL=distinctUntilKeyChanged.js.map -/***/ }, +/***/ }), +/* 252 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var distinctUntilChanged_1 = __webpack_require__(75); +/* 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, + * using a property accessed by using the key provided to check if the two items are distinct. + * + * 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 An example comparing the name of persons + * + * interface Person { + * age: number, + * name: string + * } + * + * Observable.of( + * { age: 4, name: 'Foo'}, + * { age: 7, name: 'Bar'}, + * { age: 5, name: 'Foo'}, + * { age: 6, name: 'Foo'}) + * .distinctUntilKeyChanged('name') + * .subscribe(x => console.log(x)); + * + * // displays: + * // { age: 4, name: 'Foo' } + * // { age: 7, name: 'Bar' } + * // { age: 5, name: 'Foo' } + * + * @example An example comparing the first letters of the name + * + * interface Person { + * age: number, + * name: string + * } + * + * Observable.of( + * { age: 4, name: 'Foo1'}, + * { age: 7, name: 'Bar'}, + * { age: 5, name: 'Foo2'}, + * { age: 6, name: 'Foo3'}) + * .distinctUntilKeyChanged('name', (x: string, y: string) => x.substring(0, 3) === y.substring(0, 3)) + * .subscribe(x => console.log(x)); + * + * // displays: + * // { age: 4, name: 'Foo1' } + * // { age: 7, name: 'Bar' } + * // { age: 5, name: 'Foo2' } + * + * @see {@link distinct} + * @see {@link distinctUntilChanged} + * + * @param {string} key String key for object property lookup on each item. + * @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 based on the key specified. + * @method distinctUntilKeyChanged + * @owner Observable + */ +function distinctUntilKeyChanged(key, compare) { + return distinctUntilChanged_1.distinctUntilChanged.call(this, function (x, y) { + if (compare) { + return compare(x[key], y[key]); + } + return x[key] === y[key]; + }); +} +exports.distinctUntilKeyChanged = distinctUntilKeyChanged; +//# sourceMappingURL=distinctUntilKeyChanged.js.map + +/***/ }), /* 253 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var first_1 = __webpack_require__(254); - Observable_1.Observable.prototype.first = first_1.first; - //# sourceMappingURL=first.js.map +var Observable_1 = __webpack_require__(0); +var do_1 = __webpack_require__(254); +Observable_1.Observable.prototype.do = do_1._do; +Observable_1.Observable.prototype._do = do_1._do; +//# sourceMappingURL=do.js.map -/***/ }, +/***/ }), /* 254 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var EmptyError_1 = __webpack_require__(255); - /** - * Emits only the first value (or the first value that meets some condition) - * emitted by the source Observable. - * - * Emits only the first value. Or emits only the first - * value that passes some test. - * - * - * - * If called with no arguments, `first` emits the first value of the source - * Observable, then completes. If called with a `predicate` function, `first` - * emits the first value of the source that matches the specified condition. It - * may also take a `resultSelector` function to produce the output value from - * the input value, and a `defaultValue` to emit in case the source completes - * before it is able to emit a valid value. Throws an error if `defaultValue` - * was not provided and a matching element is not found. - * - * @example Emit only the first click that happens on the DOM - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.first(); - * result.subscribe(x => console.log(x)); - * - * @example Emits the first click that happens on a DIV - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.first(ev => ev.target.tagName === 'DIV'); - * result.subscribe(x => console.log(x)); - * - * @see {@link filter} - * @see {@link find} - * @see {@link take} - * - * @throws {EmptyError} Delivers an EmptyError to the Observer's `error` - * callback if the Observable completes before any `next` notification was sent. - * - * @param {function(value: T, index: number, source: Observable): boolean} [predicate] - * An optional function called with each item to test for condition matching. - * @param {function(value: T, index: number): R} [resultSelector] A function to - * produce the value on the output Observable based on the values - * and the indices of the source Observable. The arguments passed to this - * function are: - * - `value`: the value that was emitted on the source. - * - `index`: the "index" of the value from the source. - * @param {R} [defaultValue] The default value emitted in case no valid value - * was found on the source. - * @return {Observable} An Observable of the first item that matches the - * condition. - * @method first - * @owner Observable - */ - function first(predicate, resultSelector, defaultValue) { - return this.lift(new FirstOperator(predicate, resultSelector, defaultValue, this)); - } - exports.first = first; - var FirstOperator = (function () { - function FirstOperator(predicate, resultSelector, defaultValue, source) { - this.predicate = predicate; - this.resultSelector = resultSelector; - this.defaultValue = defaultValue; - this.source = source; - } - FirstOperator.prototype.call = function (observer, source) { - return source.subscribe(new FirstSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source)); - }; - return FirstOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var FirstSubscriber = (function (_super) { - __extends(FirstSubscriber, _super); - function FirstSubscriber(destination, predicate, resultSelector, defaultValue, source) { - _super.call(this, destination); - this.predicate = predicate; - this.resultSelector = resultSelector; - this.defaultValue = defaultValue; - this.source = source; - this.index = 0; - this.hasCompleted = false; - this._emitted = false; - } - FirstSubscriber.prototype._next = function (value) { - var index = this.index++; - if (this.predicate) { - this._tryPredicate(value, index); - } - else { - this._emit(value, index); - } - }; - FirstSubscriber.prototype._tryPredicate = function (value, index) { - var result; - try { - result = this.predicate(value, index, this.source); - } - catch (err) { - this.destination.error(err); - return; - } - if (result) { - this._emit(value, index); - } - }; - FirstSubscriber.prototype._emit = function (value, index) { - if (this.resultSelector) { - this._tryResultSelector(value, index); - return; - } - this._emitFinal(value); - }; - FirstSubscriber.prototype._tryResultSelector = function (value, index) { - var result; - try { - result = this.resultSelector(value, index); - } - catch (err) { - this.destination.error(err); - return; - } - this._emitFinal(result); - }; - FirstSubscriber.prototype._emitFinal = function (value) { - var destination = this.destination; - if (!this._emitted) { - this._emitted = true; - destination.next(value); - destination.complete(); - this.hasCompleted = true; - } - }; - FirstSubscriber.prototype._complete = function () { - var destination = this.destination; - if (!this.hasCompleted && typeof this.defaultValue !== 'undefined') { - destination.next(this.defaultValue); - destination.complete(); - } - else if (!this.hasCompleted) { - destination.error(new EmptyError_1.EmptyError); - } - }; - return FirstSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=first.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/* tslint:enable:max-line-length */ +/** + * Perform a side effect for every emission on the source Observable, but return + * an Observable that is identical to the source. + * + * Intercepts each emission on the source and runs a + * function, but returns an output which is identical to the source as long as errors don't occur. + * + * + * + * Returns a mirrored Observable of the source Observable, but modified so that + * the provided Observer is called to perform a side effect for every value, + * error, and completion emitted by the source. Any errors that are thrown in + * the aforementioned Observer or handlers are safely sent down the error path + * of the output Observable. + * + * This operator is useful for debugging your Observables for the correct values + * or performing other side effects. + * + * Note: this is different to a `subscribe` on the Observable. If the Observable + * returned by `do` is not subscribed, the side effects specified by the + * Observer will never happen. `do` therefore simply spies on existing + * execution, it does not trigger an execution to happen like `subscribe` does. + * + * @example Map every click to the clientX position of that click, while also logging the click event + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var positions = clicks + * .do(ev => console.log(ev)) + * .map(ev => ev.clientX); + * positions.subscribe(x => console.log(x)); + * + * @see {@link map} + * @see {@link subscribe} + * + * @param {Observer|function} [nextOrObserver] A normal Observer object or a + * callback for `next`. + * @param {function} [error] Callback for errors in the source. + * @param {function} [complete] Callback for the completion of the source. + * @return {Observable} An Observable identical to the source, but runs the + * specified Observer or callback(s) for each item. + * @method do + * @name do + * @owner Observable + */ +function _do(nextOrObserver, error, complete) { + return this.lift(new DoOperator(nextOrObserver, error, complete)); +} +exports._do = _do; +var DoOperator = (function () { + function DoOperator(nextOrObserver, error, complete) { + this.nextOrObserver = nextOrObserver; + this.error = error; + this.complete = complete; + } + DoOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new DoSubscriber(subscriber, this.nextOrObserver, this.error, this.complete)); + }; + return DoOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var DoSubscriber = (function (_super) { + __extends(DoSubscriber, _super); + function DoSubscriber(destination, nextOrObserver, error, complete) { + _super.call(this, destination); + var safeSubscriber = new Subscriber_1.Subscriber(nextOrObserver, error, complete); + safeSubscriber.syncErrorThrowable = true; + this.add(safeSubscriber); + this.safeSubscriber = safeSubscriber; + } + DoSubscriber.prototype._next = function (value) { + var safeSubscriber = this.safeSubscriber; + safeSubscriber.next(value); + if (safeSubscriber.syncErrorThrown) { + this.destination.error(safeSubscriber.syncErrorValue); + } + else { + this.destination.next(value); + } + }; + DoSubscriber.prototype._error = function (err) { + var safeSubscriber = this.safeSubscriber; + safeSubscriber.error(err); + if (safeSubscriber.syncErrorThrown) { + this.destination.error(safeSubscriber.syncErrorValue); + } + else { + this.destination.error(err); + } + }; + DoSubscriber.prototype._complete = function () { + var safeSubscriber = this.safeSubscriber; + safeSubscriber.complete(); + if (safeSubscriber.syncErrorThrown) { + this.destination.error(safeSubscriber.syncErrorValue); + } + else { + this.destination.complete(); + } + }; + return DoSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=do.js.map + +/***/ }), /* 255 */ -/***/ function(module, exports) { - - "use strict"; - var __extends = (this && this.__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 an Observable or a sequence was queried but has no - * elements. - * - * @see {@link first} - * @see {@link last} - * @see {@link single} - * - * @class EmptyError - */ - var EmptyError = (function (_super) { - __extends(EmptyError, _super); - function EmptyError() { - var err = _super.call(this, 'no elements in sequence'); - this.name = err.name = 'EmptyError'; - this.stack = err.stack; - this.message = err.message; - } - return EmptyError; - }(Error)); - exports.EmptyError = EmptyError; - //# sourceMappingURL=EmptyError.js.map - -/***/ }, -/* 256 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var groupBy_1 = __webpack_require__(257); - Observable_1.Observable.prototype.groupBy = groupBy_1.groupBy; - //# sourceMappingURL=groupBy.js.map +var Observable_1 = __webpack_require__(0); +var exhaust_1 = __webpack_require__(256); +Observable_1.Observable.prototype.exhaust = exhaust_1.exhaust; +//# sourceMappingURL=exhaust.js.map -/***/ }, +/***/ }), +/* 256 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Converts a higher-order Observable into a first-order Observable by dropping + * inner Observables while the previous inner Observable has not yet completed. + * + * Flattens an Observable-of-Observables by dropping the + * next inner Observables while the current inner is still executing. + * + * + * + * `exhaust` subscribes to an Observable that emits Observables, also known as a + * higher-order Observable. Each time it observes one of these emitted inner + * Observables, the output Observable begins emitting the items emitted by that + * inner Observable. So far, it behaves like {@link mergeAll}. However, + * `exhaust` ignores every new inner Observable if the previous Observable has + * not yet completed. Once that one completes, it will accept and flatten the + * next inner Observable and repeat this process. + * + * @example Run a finite timer for each click, only if there is no currently active timer + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(5)); + * var result = higherOrder.exhaust(); + * result.subscribe(x => console.log(x)); + * + * @see {@link combineAll} + * @see {@link concatAll} + * @see {@link switch} + * @see {@link mergeAll} + * @see {@link exhaustMap} + * @see {@link zipAll} + * + * @return {Observable} An Observable that takes a source of Observables and propagates the first observable + * exclusively until it completes before subscribing to the next. + * @method exhaust + * @owner Observable + */ +function exhaust() { + return this.lift(new SwitchFirstOperator()); +} +exports.exhaust = exhaust; +var SwitchFirstOperator = (function () { + function SwitchFirstOperator() { + } + SwitchFirstOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new SwitchFirstSubscriber(subscriber)); + }; + return SwitchFirstOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SwitchFirstSubscriber = (function (_super) { + __extends(SwitchFirstSubscriber, _super); + function SwitchFirstSubscriber(destination) { + _super.call(this, destination); + this.hasCompleted = false; + this.hasSubscription = false; + } + SwitchFirstSubscriber.prototype._next = function (value) { + if (!this.hasSubscription) { + this.hasSubscription = true; + this.add(subscribeToResult_1.subscribeToResult(this, value)); + } + }; + SwitchFirstSubscriber.prototype._complete = function () { + this.hasCompleted = true; + if (!this.hasSubscription) { + this.destination.complete(); + } + }; + SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) { + this.remove(innerSub); + this.hasSubscription = false; + if (this.hasCompleted) { + this.destination.complete(); + } + }; + return SwitchFirstSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=exhaust.js.map + +/***/ }), /* 257 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var Subscription_1 = __webpack_require__(69); - var Observable_1 = __webpack_require__(64); - var Subject_1 = __webpack_require__(63); - var Map_1 = __webpack_require__(258); - var FastMap_1 = __webpack_require__(260); - /* tslint:enable:max-line-length */ - /** - * Groups the items emitted by an Observable according to a specified criterion, - * and emits these grouped items as `GroupedObservables`, one - * {@link GroupedObservable} per group. - * - * - * - * @example Group objects by id and return as array - * Observable.of({id: 1, name: 'aze1'}, - * {id: 2, name: 'sf2'}, - * {id: 2, name: 'dg2'}, - * {id: 1, name: 'erg1'}, - * {id: 1, name: 'df1'}, - * {id: 2, name: 'sfqfb2'}, - * {id: 3, name: 'qfs3'}, - * {id: 2, name: 'qsgqsfg2'} - * ) - * .groupBy(p => p.id) - * .flatMap( (group$) => group$.reduce((acc, cur) => [...acc, cur], [])) - * .subscribe(p => console.log(p)); - * - * // displays: - * // [ { id: 1, name: 'aze1' }, - * // { id: 1, name: 'erg1' }, - * // { id: 1, name: 'df1' } ] - * // - * // [ { id: 2, name: 'sf2' }, - * // { id: 2, name: 'dg2' }, - * // { id: 2, name: 'sfqfb2' }, - * // { id: 2, name: 'qsgqsfg2' } ] - * // - * // [ { id: 3, name: 'qfs3' } ] - * - * @example Pivot data on the id field - * Observable.of({id: 1, name: 'aze1'}, - * {id: 2, name: 'sf2'}, - * {id: 2, name: 'dg2'}, - * {id: 1, name: 'erg1'}, - * {id: 1, name: 'df1'}, - * {id: 2, name: 'sfqfb2'}, - * {id: 3, name: 'qfs1'}, - * {id: 2, name: 'qsgqsfg2'} - * ) - * .groupBy(p => p.id, p => p.name) - * .flatMap( (group$) => group$.reduce((acc, cur) => [...acc, cur], ["" + group$.key])) - * .map(arr => ({'id': parseInt(arr[0]), 'values': arr.slice(1)})) - * .subscribe(p => console.log(p)); - * - * // displays: - * // { id: 1, values: [ 'aze1', 'erg1', 'df1' ] } - * // { id: 2, values: [ 'sf2', 'dg2', 'sfqfb2', 'qsgqsfg2' ] } - * // { id: 3, values: [ 'qfs1' ] } - * - * @param {function(value: T): K} keySelector A function that extracts the key - * for each item. - * @param {function(value: T): R} [elementSelector] A function that extracts the - * return element for each item. - * @param {function(grouped: GroupedObservable): Observable} [durationSelector] - * A function that returns an Observable to determine how long each group should - * exist. - * @return {Observable>} An Observable that emits - * GroupedObservables, each of which corresponds to a unique key value and each - * of which emits those items from the source Observable that share that key - * value. - * @method groupBy - * @owner Observable - */ - function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) { - return this.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector)); - } - exports.groupBy = groupBy; - var GroupByOperator = (function () { - function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) { - this.keySelector = keySelector; - this.elementSelector = elementSelector; - this.durationSelector = durationSelector; - this.subjectSelector = subjectSelector; - } - GroupByOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector)); - }; - return GroupByOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var GroupBySubscriber = (function (_super) { - __extends(GroupBySubscriber, _super); - function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) { - _super.call(this, destination); - this.keySelector = keySelector; - this.elementSelector = elementSelector; - this.durationSelector = durationSelector; - this.subjectSelector = subjectSelector; - this.groups = null; - this.attemptedToUnsubscribe = false; - this.count = 0; - } - GroupBySubscriber.prototype._next = function (value) { - var key; - try { - key = this.keySelector(value); - } - catch (err) { - this.error(err); - return; - } - this._group(value, key); - }; - GroupBySubscriber.prototype._group = function (value, key) { - var groups = this.groups; - if (!groups) { - groups = this.groups = typeof key === 'string' ? new FastMap_1.FastMap() : new Map_1.Map(); - } - var group = groups.get(key); - var element; - if (this.elementSelector) { - try { - element = this.elementSelector(value); - } - catch (err) { - this.error(err); - } - } - else { - element = value; - } - if (!group) { - group = this.subjectSelector ? this.subjectSelector() : new Subject_1.Subject(); - groups.set(key, group); - var groupedObservable = new GroupedObservable(key, group, this); - this.destination.next(groupedObservable); - if (this.durationSelector) { - var duration = void 0; - try { - duration = this.durationSelector(new GroupedObservable(key, group)); - } - catch (err) { - this.error(err); - return; - } - this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this))); - } - } - if (!group.closed) { - group.next(element); - } - }; - GroupBySubscriber.prototype._error = function (err) { - var groups = this.groups; - if (groups) { - groups.forEach(function (group, key) { - group.error(err); - }); - groups.clear(); - } - this.destination.error(err); - }; - GroupBySubscriber.prototype._complete = function () { - var groups = this.groups; - if (groups) { - groups.forEach(function (group, key) { - group.complete(); - }); - groups.clear(); - } - this.destination.complete(); - }; - GroupBySubscriber.prototype.removeGroup = function (key) { - this.groups.delete(key); - }; - GroupBySubscriber.prototype.unsubscribe = function () { - if (!this.closed) { - this.attemptedToUnsubscribe = true; - if (this.count === 0) { - _super.prototype.unsubscribe.call(this); - } - } - }; - return GroupBySubscriber; - }(Subscriber_1.Subscriber)); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var GroupDurationSubscriber = (function (_super) { - __extends(GroupDurationSubscriber, _super); - function GroupDurationSubscriber(key, group, parent) { - _super.call(this, group); - this.key = key; - this.group = group; - this.parent = parent; - } - GroupDurationSubscriber.prototype._next = function (value) { - this.complete(); - }; - GroupDurationSubscriber.prototype._unsubscribe = function () { - var _a = this, parent = _a.parent, key = _a.key; - this.key = this.parent = null; - if (parent) { - parent.removeGroup(key); - } - }; - return GroupDurationSubscriber; - }(Subscriber_1.Subscriber)); - /** - * An Observable representing values belonging to the same group represented by - * a common key. The values emitted by a GroupedObservable come from the source - * Observable. The common key is available as the field `key` on a - * GroupedObservable instance. - * - * @class GroupedObservable - */ - var GroupedObservable = (function (_super) { - __extends(GroupedObservable, _super); - function GroupedObservable(key, groupSubject, refCountSubscription) { - _super.call(this); - this.key = key; - this.groupSubject = groupSubject; - this.refCountSubscription = refCountSubscription; - } - GroupedObservable.prototype._subscribe = function (subscriber) { - var subscription = new Subscription_1.Subscription(); - var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject; - if (refCountSubscription && !refCountSubscription.closed) { - subscription.add(new InnerRefCountSubscription(refCountSubscription)); - } - subscription.add(groupSubject.subscribe(subscriber)); - return subscription; - }; - return GroupedObservable; - }(Observable_1.Observable)); - exports.GroupedObservable = GroupedObservable; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var InnerRefCountSubscription = (function (_super) { - __extends(InnerRefCountSubscription, _super); - function InnerRefCountSubscription(parent) { - _super.call(this); - this.parent = parent; - parent.count++; - } - InnerRefCountSubscription.prototype.unsubscribe = function () { - var parent = this.parent; - if (!parent.closed && !this.closed) { - _super.prototype.unsubscribe.call(this); - parent.count -= 1; - if (parent.count === 0 && parent.attemptedToUnsubscribe) { - parent.unsubscribe(); - } - } - }; - return InnerRefCountSubscription; - }(Subscription_1.Subscription)); - //# sourceMappingURL=groupBy.js.map - -/***/ }, -/* 258 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var root_1 = __webpack_require__(65); - var MapPolyfill_1 = __webpack_require__(259); - exports.Map = root_1.root.Map || (function () { return MapPolyfill_1.MapPolyfill; })(); - //# sourceMappingURL=Map.js.map +var Observable_1 = __webpack_require__(0); +var exhaustMap_1 = __webpack_require__(258); +Observable_1.Observable.prototype.exhaustMap = exhaustMap_1.exhaustMap; +//# sourceMappingURL=exhaustMap.js.map -/***/ }, +/***/ }), +/* 258 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/* tslint:enable:max-line-length */ +/** + * Projects each source value to an Observable which is merged in the output + * Observable only if the previous projected Observable has completed. + * + * Maps each value to an Observable, then flattens all of + * these inner Observables using {@link exhaust}. + * + * + * + * Returns an Observable that emits items based on applying a function that you + * supply to each item emitted by the source Observable, where that function + * returns an (so-called "inner") Observable. When it projects a source value to + * an Observable, the output Observable begins emitting the items emitted by + * that projected Observable. However, `exhaustMap` ignores every new projected + * Observable if the previous projected Observable has not yet completed. Once + * that one completes, it will accept and flatten the next projected Observable + * and repeat this process. + * + * @example Run a finite timer for each click, only if there is no currently active timer + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.exhaustMap((ev) => Rx.Observable.interval(1000).take(5)); + * result.subscribe(x => console.log(x)); + * + * @see {@link concatMap} + * @see {@link exhaust} + * @see {@link mergeMap} + * @see {@link switchMap} + * + * @param {function(value: T, ?index: number): ObservableInput} project A function + * that, when applied to an item emitted by the source Observable, returns an + * Observable. + * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector] + * A function to produce the value on the output Observable based on the values + * and the indices of the source (outer) emission and the inner Observable + * emission. The arguments passed to this function are: + * - `outerValue`: the value that came from the source + * - `innerValue`: the value that came from the projected Observable + * - `outerIndex`: the "index" of the value that came from the source + * - `innerIndex`: the "index" of the value from the projected Observable + * @return {Observable} An Observable containing projected Observables + * of each item of the source, ignoring projected Observables that start before + * their preceding Observable has completed. + * @method exhaustMap + * @owner Observable + */ +function exhaustMap(project, resultSelector) { + return this.lift(new SwitchFirstMapOperator(project, resultSelector)); +} +exports.exhaustMap = exhaustMap; +var SwitchFirstMapOperator = (function () { + function SwitchFirstMapOperator(project, resultSelector) { + this.project = project; + this.resultSelector = resultSelector; + } + SwitchFirstMapOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new SwitchFirstMapSubscriber(subscriber, this.project, this.resultSelector)); + }; + return SwitchFirstMapOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SwitchFirstMapSubscriber = (function (_super) { + __extends(SwitchFirstMapSubscriber, _super); + function SwitchFirstMapSubscriber(destination, project, resultSelector) { + _super.call(this, destination); + this.project = project; + this.resultSelector = resultSelector; + this.hasSubscription = false; + this.hasCompleted = false; + this.index = 0; + } + SwitchFirstMapSubscriber.prototype._next = function (value) { + if (!this.hasSubscription) { + this.tryNext(value); + } + }; + SwitchFirstMapSubscriber.prototype.tryNext = function (value) { + var index = this.index++; + var destination = this.destination; + try { + var result = this.project(value, index); + this.hasSubscription = true; + this.add(subscribeToResult_1.subscribeToResult(this, result, value, index)); + } + catch (err) { + destination.error(err); + } + }; + SwitchFirstMapSubscriber.prototype._complete = function () { + this.hasCompleted = true; + if (!this.hasSubscription) { + this.destination.complete(); + } + }; + SwitchFirstMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; + if (resultSelector) { + this.trySelectResult(outerValue, innerValue, outerIndex, innerIndex); + } + else { + destination.next(innerValue); + } + }; + SwitchFirstMapSubscriber.prototype.trySelectResult = function (outerValue, innerValue, outerIndex, innerIndex) { + var _a = this, resultSelector = _a.resultSelector, destination = _a.destination; + try { + var result = resultSelector(outerValue, innerValue, outerIndex, innerIndex); + destination.next(result); + } + catch (err) { + destination.error(err); + } + }; + SwitchFirstMapSubscriber.prototype.notifyError = function (err) { + this.destination.error(err); + }; + SwitchFirstMapSubscriber.prototype.notifyComplete = function (innerSub) { + this.remove(innerSub); + this.hasSubscription = false; + if (this.hasCompleted) { + this.destination.complete(); + } + }; + return SwitchFirstMapSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=exhaustMap.js.map + +/***/ }), /* 259 */ -/***/ function(module, exports) { - - "use strict"; - var MapPolyfill = (function () { - function MapPolyfill() { - this.size = 0; - this._values = []; - this._keys = []; - } - MapPolyfill.prototype.get = function (key) { - var i = this._keys.indexOf(key); - return i === -1 ? undefined : this._values[i]; - }; - MapPolyfill.prototype.set = function (key, value) { - var i = this._keys.indexOf(key); - if (i === -1) { - this._keys.push(key); - this._values.push(value); - this.size++; - } - else { - this._values[i] = value; - } - return this; - }; - MapPolyfill.prototype.delete = function (key) { - var i = this._keys.indexOf(key); - if (i === -1) { - return false; - } - this._values.splice(i, 1); - this._keys.splice(i, 1); - this.size--; - return true; - }; - MapPolyfill.prototype.clear = function () { - this._keys.length = 0; - this._values.length = 0; - this.size = 0; - }; - MapPolyfill.prototype.forEach = function (cb, thisArg) { - for (var i = 0; i < this.size; i++) { - cb.call(thisArg, this._values[i], this._keys[i]); - } - }; - return MapPolyfill; - }()); - exports.MapPolyfill = MapPolyfill; - //# sourceMappingURL=MapPolyfill.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var expand_1 = __webpack_require__(260); +Observable_1.Observable.prototype.expand = expand_1.expand; +//# sourceMappingURL=expand.js.map + +/***/ }), /* 260 */ -/***/ function(module, exports) { - - "use strict"; - var FastMap = (function () { - function FastMap() { - this.values = {}; - } - FastMap.prototype.delete = function (key) { - this.values[key] = null; - return true; - }; - FastMap.prototype.set = function (key, value) { - this.values[key] = value; - return this; - }; - FastMap.prototype.get = function (key) { - return this.values[key]; - }; - FastMap.prototype.forEach = function (cb, thisArg) { - var values = this.values; - for (var key in values) { - if (values.hasOwnProperty(key) && values[key] !== null) { - cb.call(thisArg, values[key], key); - } - } - }; - FastMap.prototype.clear = function () { - this.values = {}; - }; - return FastMap; - }()); - exports.FastMap = FastMap; - //# sourceMappingURL=FastMap.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/* tslint:enable:max-line-length */ +/** + * Recursively projects each source value to an Observable which is merged in + * the output Observable. + * + * It's similar to {@link mergeMap}, but applies the + * projection function to every source value as well as every output value. + * It's recursive. + * + * + * + * Returns an Observable that emits items based on applying a function that you + * supply to each item emitted by the source Observable, where that function + * returns an Observable, and then merging those resulting Observables and + * emitting the results of this merger. *Expand* will re-emit on the output + * Observable every source value. Then, each output value is given to the + * `project` function which returns an inner Observable to be merged on the + * output Observable. Those output values resulting from the projection are also + * given to the `project` function to produce new output values. This is how + * *expand* behaves recursively. + * + * @example Start emitting the powers of two on every click, at most 10 of them + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var powersOfTwo = clicks + * .mapTo(1) + * .expand(x => Rx.Observable.of(2 * x).delay(1000)) + * .take(10); + * powersOfTwo.subscribe(x => console.log(x)); + * + * @see {@link mergeMap} + * @see {@link mergeScan} + * + * @param {function(value: T, index: number) => Observable} project A function + * that, when applied to an item emitted by the source or the output Observable, + * returns an Observable. + * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input + * Observables being subscribed to concurrently. + * @param {Scheduler} [scheduler=null] The IScheduler to use for subscribing to + * each projected inner Observable. + * @return {Observable} An Observable that emits the source values and also + * result of applying the projection function to each value emitted on the + * output Observable and and merging the results of the Observables obtained + * from this transformation. + * @method expand + * @owner Observable + */ +function expand(project, concurrent, scheduler) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + if (scheduler === void 0) { scheduler = undefined; } + concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent; + return this.lift(new ExpandOperator(project, concurrent, scheduler)); +} +exports.expand = expand; +var ExpandOperator = (function () { + function ExpandOperator(project, concurrent, scheduler) { + this.project = project; + this.concurrent = concurrent; + this.scheduler = scheduler; + } + ExpandOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler)); + }; + return ExpandOperator; +}()); +exports.ExpandOperator = ExpandOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ExpandSubscriber = (function (_super) { + __extends(ExpandSubscriber, _super); + function ExpandSubscriber(destination, project, concurrent, scheduler) { + _super.call(this, destination); + this.project = project; + this.concurrent = concurrent; + this.scheduler = scheduler; + this.index = 0; + this.active = 0; + this.hasCompleted = false; + if (concurrent < Number.POSITIVE_INFINITY) { + this.buffer = []; + } + } + ExpandSubscriber.dispatch = function (arg) { + var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index; + subscriber.subscribeToProjection(result, value, index); + }; + ExpandSubscriber.prototype._next = function (value) { + var destination = this.destination; + if (destination.closed) { + this._complete(); + return; + } + var index = this.index++; + if (this.active < this.concurrent) { + destination.next(value); + var result = tryCatch_1.tryCatch(this.project)(value, index); + if (result === errorObject_1.errorObject) { + destination.error(errorObject_1.errorObject.e); + } + else if (!this.scheduler) { + this.subscribeToProjection(result, value, index); + } + else { + var state = { subscriber: this, result: result, value: value, index: index }; + this.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state)); + } + } + else { + this.buffer.push(value); + } + }; + ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) { + this.active++; + this.add(subscribeToResult_1.subscribeToResult(this, result, value, index)); + }; + ExpandSubscriber.prototype._complete = function () { + this.hasCompleted = true; + if (this.hasCompleted && this.active === 0) { + this.destination.complete(); + } + }; + ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this._next(innerValue); + }; + ExpandSubscriber.prototype.notifyComplete = function (innerSub) { + var buffer = this.buffer; + this.remove(innerSub); + this.active--; + if (buffer && buffer.length > 0) { + this._next(buffer.shift()); + } + if (this.hasCompleted && this.active === 0) { + this.destination.complete(); + } + }; + return ExpandSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.ExpandSubscriber = ExpandSubscriber; +//# sourceMappingURL=expand.js.map + +/***/ }), /* 261 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var ignoreElements_1 = __webpack_require__(262); - Observable_1.Observable.prototype.ignoreElements = ignoreElements_1.ignoreElements; - //# sourceMappingURL=ignoreElements.js.map +var Observable_1 = __webpack_require__(0); +var elementAt_1 = __webpack_require__(262); +Observable_1.Observable.prototype.elementAt = elementAt_1.elementAt; +//# sourceMappingURL=elementAt.js.map -/***/ }, +/***/ }), /* 262 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var noop_1 = __webpack_require__(152); - /** - * Ignores all items emitted by the source Observable and only passes calls of `complete` or `error`. - * - * - * - * @return {Observable} An empty Observable that only calls `complete` - * or `error`, based on which one is called by the source Observable. - * @method ignoreElements - * @owner Observable - */ - function ignoreElements() { - return this.lift(new IgnoreElementsOperator()); - } - exports.ignoreElements = ignoreElements; - ; - var IgnoreElementsOperator = (function () { - function IgnoreElementsOperator() { - } - IgnoreElementsOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new IgnoreElementsSubscriber(subscriber)); - }; - return IgnoreElementsOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var IgnoreElementsSubscriber = (function (_super) { - __extends(IgnoreElementsSubscriber, _super); - function IgnoreElementsSubscriber() { - _super.apply(this, arguments); - } - IgnoreElementsSubscriber.prototype._next = function (unused) { - noop_1.noop(); - }; - return IgnoreElementsSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=ignoreElements.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var ArgumentOutOfRangeError_1 = __webpack_require__(25); +/** + * Emits the single value at the specified `index` in a sequence of emissions + * from the source Observable. + * + * Emits only the i-th value, then completes. + * + * + * + * `elementAt` returns an Observable that emits the item at the specified + * `index` in the source Observable, or a default value if that `index` is out + * of range and the `default` argument is provided. If the `default` argument is + * not given and the `index` is out of range, the output Observable will emit an + * `ArgumentOutOfRangeError` error. + * + * @example Emit only the third click event + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.elementAt(2); + * result.subscribe(x => console.log(x)); + * + * // Results in: + * // click 1 = nothing + * // click 2 = nothing + * // click 3 = MouseEvent object logged to console + * + * @see {@link first} + * @see {@link last} + * @see {@link skip} + * @see {@link single} + * @see {@link take} + * + * @throws {ArgumentOutOfRangeError} When using `elementAt(i)`, it delivers an + * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0` or the + * Observable has completed before emitting the i-th `next` notification. + * + * @param {number} index Is the number `i` for the i-th source emission that has + * happened since the subscription, starting from the number `0`. + * @param {T} [defaultValue] The default value returned for missing indices. + * @return {Observable} An Observable that emits a single item, if it is found. + * Otherwise, will emit the default value if given. If not, then emits an error. + * @method elementAt + * @owner Observable + */ +function elementAt(index, defaultValue) { + return this.lift(new ElementAtOperator(index, defaultValue)); +} +exports.elementAt = elementAt; +var ElementAtOperator = (function () { + function ElementAtOperator(index, defaultValue) { + this.index = index; + this.defaultValue = defaultValue; + if (index < 0) { + throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError; + } + } + ElementAtOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ElementAtSubscriber(subscriber, this.index, this.defaultValue)); + }; + return ElementAtOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ElementAtSubscriber = (function (_super) { + __extends(ElementAtSubscriber, _super); + function ElementAtSubscriber(destination, index, defaultValue) { + _super.call(this, destination); + this.index = index; + this.defaultValue = defaultValue; + } + ElementAtSubscriber.prototype._next = function (x) { + if (this.index-- === 0) { + this.destination.next(x); + this.destination.complete(); + } + }; + ElementAtSubscriber.prototype._complete = function () { + var destination = this.destination; + if (this.index >= 0) { + if (typeof this.defaultValue !== 'undefined') { + destination.next(this.defaultValue); + } + else { + destination.error(new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError); + } + } + destination.complete(); + }; + return ElementAtSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=elementAt.js.map + +/***/ }), /* 263 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var isEmpty_1 = __webpack_require__(264); - Observable_1.Observable.prototype.isEmpty = isEmpty_1.isEmpty; - //# sourceMappingURL=isEmpty.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var filter_1 = __webpack_require__(76); +Observable_1.Observable.prototype.filter = filter_1.filter; +//# sourceMappingURL=filter.js.map + +/***/ }), /* 264 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * If the source Observable is empty it returns an Observable that emits true, otherwise it emits false. - * - * - * - * @return {Observable} An Observable that emits a Boolean. - * @method isEmpty - * @owner Observable - */ - function isEmpty() { - return this.lift(new IsEmptyOperator()); - } - exports.isEmpty = isEmpty; - var IsEmptyOperator = (function () { - function IsEmptyOperator() { - } - IsEmptyOperator.prototype.call = function (observer, source) { - return source.subscribe(new IsEmptySubscriber(observer)); - }; - return IsEmptyOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var IsEmptySubscriber = (function (_super) { - __extends(IsEmptySubscriber, _super); - function IsEmptySubscriber(destination) { - _super.call(this, destination); - } - IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) { - var destination = this.destination; - destination.next(isEmpty); - destination.complete(); - }; - IsEmptySubscriber.prototype._next = function (value) { - this.notifyComplete(false); - }; - IsEmptySubscriber.prototype._complete = function () { - this.notifyComplete(true); - }; - return IsEmptySubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=isEmpty.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var finally_1 = __webpack_require__(265); +Observable_1.Observable.prototype.finally = finally_1._finally; +Observable_1.Observable.prototype._finally = finally_1._finally; +//# sourceMappingURL=finally.js.map + +/***/ }), /* 265 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var Subscription_1 = __webpack_require__(4); +/** + * Returns an Observable that mirrors the source Observable, but will call a specified function when + * the source terminates on complete or error. + * @param {function} callback Function to be called when source terminates. + * @return {Observable} An Observable that mirrors the source, but will call the specified function on termination. + * @method finally + * @owner Observable + */ +function _finally(callback) { + return this.lift(new FinallyOperator(callback)); +} +exports._finally = _finally; +var FinallyOperator = (function () { + function FinallyOperator(callback) { + this.callback = callback; + } + FinallyOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new FinallySubscriber(subscriber, this.callback)); + }; + return FinallyOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var FinallySubscriber = (function (_super) { + __extends(FinallySubscriber, _super); + function FinallySubscriber(destination, callback) { + _super.call(this, destination); + this.add(new Subscription_1.Subscription(callback)); + } + return FinallySubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=finally.js.map + +/***/ }), +/* 266 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var audit_1 = __webpack_require__(266); - Observable_1.Observable.prototype.audit = audit_1.audit; - //# sourceMappingURL=audit.js.map +"use strict"; -/***/ }, -/* 266 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Ignores source values for a duration determined by another Observable, then - * emits the most recent value from the source Observable, then repeats this - * process. - * - * It's like {@link auditTime}, but the silencing - * duration is determined by a second Observable. - * - * - * - * `audit` is similar to `throttle`, but emits the last value from the silenced - * time window, instead of the first value. `audit` emits the most recent value - * from the source Observable on the output Observable as soon as its internal - * timer becomes disabled, and ignores source values while the timer is enabled. - * Initially, the timer is disabled. As soon as the first source value arrives, - * the timer is enabled by calling the `durationSelector` function with the - * source value, which returns the "duration" Observable. When the duration - * Observable emits a value or completes, the timer is disabled, then the most - * recent source value is emitted on the output Observable, and this process - * repeats for the next source value. - * - * @example Emit clicks at a rate of at most one click per second - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.audit(ev => Rx.Observable.interval(1000)); - * result.subscribe(x => console.log(x)); - * - * @see {@link auditTime} - * @see {@link debounce} - * @see {@link delayWhen} - * @see {@link sample} - * @see {@link throttle} - * - * @param {function(value: T): SubscribableOrPromise} durationSelector A function - * that receives a value from the source Observable, for computing the silencing - * duration, returned as an Observable or a Promise. - * @return {Observable} An Observable that performs rate-limiting of - * emissions from the source Observable. - * @method audit - * @owner Observable - */ - function audit(durationSelector) { - return this.lift(new AuditOperator(durationSelector)); - } - exports.audit = audit; - var AuditOperator = (function () { - function AuditOperator(durationSelector) { - this.durationSelector = durationSelector; - } - AuditOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector)); - }; - return AuditOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var AuditSubscriber = (function (_super) { - __extends(AuditSubscriber, _super); - function AuditSubscriber(destination, durationSelector) { - _super.call(this, destination); - this.durationSelector = durationSelector; - this.hasValue = false; - } - AuditSubscriber.prototype._next = function (value) { - this.value = value; - this.hasValue = true; - if (!this.throttled) { - var duration = tryCatch_1.tryCatch(this.durationSelector)(value); - if (duration === errorObject_1.errorObject) { - this.destination.error(errorObject_1.errorObject.e); - } - else { - var innerSubscription = subscribeToResult_1.subscribeToResult(this, duration); - if (innerSubscription.closed) { - this.clearThrottle(); - } - else { - this.add(this.throttled = innerSubscription); - } - } - } - }; - AuditSubscriber.prototype.clearThrottle = function () { - var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled; - if (throttled) { - this.remove(throttled); - this.throttled = null; - throttled.unsubscribe(); - } - if (hasValue) { - this.value = null; - this.hasValue = false; - this.destination.next(value); - } - }; - AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) { - this.clearThrottle(); - }; - AuditSubscriber.prototype.notifyComplete = function () { - this.clearThrottle(); - }; - return AuditSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=audit.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var find_1 = __webpack_require__(77); +Observable_1.Observable.prototype.find = find_1.find; +//# sourceMappingURL=find.js.map + +/***/ }), /* 267 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var auditTime_1 = __webpack_require__(268); - Observable_1.Observable.prototype.auditTime = auditTime_1.auditTime; - //# sourceMappingURL=auditTime.js.map +"use strict"; -/***/ }, -/* 268 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 async_1 = __webpack_require__(138); - var Subscriber_1 = __webpack_require__(67); - /** - * Ignores source values for `duration` milliseconds, then emits the most recent - * value from the source Observable, then repeats this process. - * - * When it sees a source values, it ignores that plus - * the next ones for `duration` milliseconds, and then it emits the most recent - * value from the source. - * - * - * - * `auditTime` is similar to `throttleTime`, but emits the last value from the - * silenced time window, instead of the first value. `auditTime` emits the most - * recent value from the source Observable on the output Observable as soon as - * its internal timer becomes disabled, and ignores source values while the - * timer is enabled. Initially, the timer is disabled. As soon as the first - * source value arrives, the timer is enabled. After `duration` milliseconds (or - * the time unit determined internally by the optional `scheduler`) has passed, - * the timer is disabled, then the most recent source value is emitted on the - * output Observable, and this process repeats for the next source value. - * Optionally takes a {@link IScheduler} for managing timers. - * - * @example Emit clicks at a rate of at most one click per second - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.auditTime(1000); - * result.subscribe(x => console.log(x)); - * - * @see {@link audit} - * @see {@link debounceTime} - * @see {@link delay} - * @see {@link sampleTime} - * @see {@link throttleTime} - * - * @param {number} duration Time to wait before emitting the most recent source - * value, measured in milliseconds or the time unit determined internally - * by the optional `scheduler`. - * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for - * managing the timers that handle the rate-limiting behavior. - * @return {Observable} An Observable that performs rate-limiting of - * emissions from the source Observable. - * @method auditTime - * @owner Observable - */ - function auditTime(duration, scheduler) { - if (scheduler === void 0) { scheduler = async_1.async; } - return this.lift(new AuditTimeOperator(duration, scheduler)); - } - exports.auditTime = auditTime; - var AuditTimeOperator = (function () { - function AuditTimeOperator(duration, scheduler) { - this.duration = duration; - this.scheduler = scheduler; - } - AuditTimeOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new AuditTimeSubscriber(subscriber, this.duration, this.scheduler)); - }; - return AuditTimeOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var AuditTimeSubscriber = (function (_super) { - __extends(AuditTimeSubscriber, _super); - function AuditTimeSubscriber(destination, duration, scheduler) { - _super.call(this, destination); - this.duration = duration; - this.scheduler = scheduler; - this.hasValue = false; - } - AuditTimeSubscriber.prototype._next = function (value) { - this.value = value; - this.hasValue = true; - if (!this.throttled) { - this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, this)); - } - }; - AuditTimeSubscriber.prototype.clearThrottle = function () { - var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled; - if (throttled) { - this.remove(throttled); - this.throttled = null; - throttled.unsubscribe(); - } - if (hasValue) { - this.value = null; - this.hasValue = false; - this.destination.next(value); - } - }; - return AuditTimeSubscriber; - }(Subscriber_1.Subscriber)); - function dispatchNext(subscriber) { - subscriber.clearThrottle(); - } - //# sourceMappingURL=auditTime.js.map +var Observable_1 = __webpack_require__(0); +var findIndex_1 = __webpack_require__(268); +Observable_1.Observable.prototype.findIndex = findIndex_1.findIndex; +//# sourceMappingURL=findIndex.js.map -/***/ }, +/***/ }), +/* 268 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var find_1 = __webpack_require__(77); +/** + * Emits only the index of the first value emitted by the source Observable that + * meets some condition. + * + * It's like {@link find}, but emits the index of the + * found value, not the value itself. + * + * + * + * `findIndex` searches for the first item in the source Observable that matches + * the specified condition embodied by the `predicate`, and returns the + * (zero-based) index of the first occurrence in the source. Unlike + * {@link first}, the `predicate` is required in `findIndex`, and does not emit + * an error if a valid value is not found. + * + * @example Emit the index of first click that happens on a DIV element + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.findIndex(ev => ev.target.tagName === 'DIV'); + * result.subscribe(x => console.log(x)); + * + * @see {@link filter} + * @see {@link find} + * @see {@link first} + * @see {@link take} + * + * @param {function(value: T, index: number, source: Observable): boolean} predicate + * A function called with each item to test for condition matching. + * @param {any} [thisArg] An optional argument to determine the value of `this` + * in the `predicate` function. + * @return {Observable} An Observable of the index of the first item that + * matches the condition. + * @method find + * @owner Observable + */ +function findIndex(predicate, thisArg) { + return this.lift(new find_1.FindValueOperator(predicate, this, true, thisArg)); +} +exports.findIndex = findIndex; +//# sourceMappingURL=findIndex.js.map + +/***/ }), /* 269 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var last_1 = __webpack_require__(270); - Observable_1.Observable.prototype.last = last_1.last; - //# sourceMappingURL=last.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var first_1 = __webpack_require__(270); +Observable_1.Observable.prototype.first = first_1.first; +//# sourceMappingURL=first.js.map + +/***/ }), /* 270 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var EmptyError_1 = __webpack_require__(255); - /* tslint:enable:max-line-length */ - /** - * Returns an Observable that emits only the last item emitted by the source Observable. - * It optionally takes a predicate function as a parameter, in which case, rather than emitting - * the last item from the source Observable, the resulting Observable will emit the last item - * from the source Observable that satisfies the predicate. - * - * - * - * @throws {EmptyError} Delivers an EmptyError to the Observer's `error` - * callback if the Observable completes before any `next` notification was sent. - * @param {function} predicate - The condition any source emitted item has to satisfy. - * @return {Observable} An Observable that emits only the last item satisfying the given condition - * from the source, or an NoSuchElementException if no such items are emitted. - * @throws - Throws if no items that match the predicate are emitted by the source Observable. - * @method last - * @owner Observable - */ - function last(predicate, resultSelector, defaultValue) { - return this.lift(new LastOperator(predicate, resultSelector, defaultValue, this)); - } - exports.last = last; - var LastOperator = (function () { - function LastOperator(predicate, resultSelector, defaultValue, source) { - this.predicate = predicate; - this.resultSelector = resultSelector; - this.defaultValue = defaultValue; - this.source = source; - } - LastOperator.prototype.call = function (observer, source) { - return source.subscribe(new LastSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source)); - }; - return LastOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var LastSubscriber = (function (_super) { - __extends(LastSubscriber, _super); - function LastSubscriber(destination, predicate, resultSelector, defaultValue, source) { - _super.call(this, destination); - this.predicate = predicate; - this.resultSelector = resultSelector; - this.defaultValue = defaultValue; - this.source = source; - this.hasValue = false; - this.index = 0; - if (typeof defaultValue !== 'undefined') { - this.lastValue = defaultValue; - this.hasValue = true; - } - } - LastSubscriber.prototype._next = function (value) { - var index = this.index++; - if (this.predicate) { - this._tryPredicate(value, index); - } - else { - if (this.resultSelector) { - this._tryResultSelector(value, index); - return; - } - this.lastValue = value; - this.hasValue = true; - } - }; - LastSubscriber.prototype._tryPredicate = function (value, index) { - var result; - try { - result = this.predicate(value, index, this.source); - } - catch (err) { - this.destination.error(err); - return; - } - if (result) { - if (this.resultSelector) { - this._tryResultSelector(value, index); - return; - } - this.lastValue = value; - this.hasValue = true; - } - }; - LastSubscriber.prototype._tryResultSelector = function (value, index) { - var result; - try { - result = this.resultSelector(value, index); - } - catch (err) { - this.destination.error(err); - return; - } - this.lastValue = result; - this.hasValue = true; - }; - LastSubscriber.prototype._complete = function () { - var destination = this.destination; - if (this.hasValue) { - destination.next(this.lastValue); - destination.complete(); - } - else { - destination.error(new EmptyError_1.EmptyError); - } - }; - return LastSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=last.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var EmptyError_1 = __webpack_require__(37); +/** + * Emits only the first value (or the first value that meets some condition) + * emitted by the source Observable. + * + * Emits only the first value. Or emits only the first + * value that passes some test. + * + * + * + * If called with no arguments, `first` emits the first value of the source + * Observable, then completes. If called with a `predicate` function, `first` + * emits the first value of the source that matches the specified condition. It + * may also take a `resultSelector` function to produce the output value from + * the input value, and a `defaultValue` to emit in case the source completes + * before it is able to emit a valid value. Throws an error if `defaultValue` + * was not provided and a matching element is not found. + * + * @example Emit only the first click that happens on the DOM + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.first(); + * result.subscribe(x => console.log(x)); + * + * @example Emits the first click that happens on a DIV + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.first(ev => ev.target.tagName === 'DIV'); + * result.subscribe(x => console.log(x)); + * + * @see {@link filter} + * @see {@link find} + * @see {@link take} + * + * @throws {EmptyError} Delivers an EmptyError to the Observer's `error` + * callback if the Observable completes before any `next` notification was sent. + * + * @param {function(value: T, index: number, source: Observable): boolean} [predicate] + * An optional function called with each item to test for condition matching. + * @param {function(value: T, index: number): R} [resultSelector] A function to + * produce the value on the output Observable based on the values + * and the indices of the source Observable. The arguments passed to this + * function are: + * - `value`: the value that was emitted on the source. + * - `index`: the "index" of the value from the source. + * @param {R} [defaultValue] The default value emitted in case no valid value + * was found on the source. + * @return {Observable} An Observable of the first item that matches the + * condition. + * @method first + * @owner Observable + */ +function first(predicate, resultSelector, defaultValue) { + return this.lift(new FirstOperator(predicate, resultSelector, defaultValue, this)); +} +exports.first = first; +var FirstOperator = (function () { + function FirstOperator(predicate, resultSelector, defaultValue, source) { + this.predicate = predicate; + this.resultSelector = resultSelector; + this.defaultValue = defaultValue; + this.source = source; + } + FirstOperator.prototype.call = function (observer, source) { + return source.subscribe(new FirstSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source)); + }; + return FirstOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var FirstSubscriber = (function (_super) { + __extends(FirstSubscriber, _super); + function FirstSubscriber(destination, predicate, resultSelector, defaultValue, source) { + _super.call(this, destination); + this.predicate = predicate; + this.resultSelector = resultSelector; + this.defaultValue = defaultValue; + this.source = source; + this.index = 0; + this.hasCompleted = false; + this._emitted = false; + } + FirstSubscriber.prototype._next = function (value) { + var index = this.index++; + if (this.predicate) { + this._tryPredicate(value, index); + } + else { + this._emit(value, index); + } + }; + FirstSubscriber.prototype._tryPredicate = function (value, index) { + var result; + try { + result = this.predicate(value, index, this.source); + } + catch (err) { + this.destination.error(err); + return; + } + if (result) { + this._emit(value, index); + } + }; + FirstSubscriber.prototype._emit = function (value, index) { + if (this.resultSelector) { + this._tryResultSelector(value, index); + return; + } + this._emitFinal(value); + }; + FirstSubscriber.prototype._tryResultSelector = function (value, index) { + var result; + try { + result = this.resultSelector(value, index); + } + catch (err) { + this.destination.error(err); + return; + } + this._emitFinal(result); + }; + FirstSubscriber.prototype._emitFinal = function (value) { + var destination = this.destination; + if (!this._emitted) { + this._emitted = true; + destination.next(value); + destination.complete(); + this.hasCompleted = true; + } + }; + FirstSubscriber.prototype._complete = function () { + var destination = this.destination; + if (!this.hasCompleted && typeof this.defaultValue !== 'undefined') { + destination.next(this.defaultValue); + destination.complete(); + } + else if (!this.hasCompleted) { + destination.error(new EmptyError_1.EmptyError); + } + }; + return FirstSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=first.js.map + +/***/ }), /* 271 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var let_1 = __webpack_require__(272); - Observable_1.Observable.prototype.let = let_1.letProto; - Observable_1.Observable.prototype.letBind = let_1.letProto; - //# sourceMappingURL=let.js.map +"use strict"; -/***/ }, -/* 272 */ -/***/ function(module, exports) { - - "use strict"; - /** - * @param func - * @return {Observable} - * @method let - * @owner Observable - */ - function letProto(func) { - return func(this); - } - exports.letProto = letProto; - //# sourceMappingURL=let.js.map +var Observable_1 = __webpack_require__(0); +var groupBy_1 = __webpack_require__(272); +Observable_1.Observable.prototype.groupBy = groupBy_1.groupBy; +//# sourceMappingURL=groupBy.js.map -/***/ }, +/***/ }), +/* 272 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var Subscription_1 = __webpack_require__(4); +var Observable_1 = __webpack_require__(0); +var Subject_1 = __webpack_require__(5); +var Map_1 = __webpack_require__(273); +var FastMap_1 = __webpack_require__(275); +/* tslint:enable:max-line-length */ +/** + * Groups the items emitted by an Observable according to a specified criterion, + * and emits these grouped items as `GroupedObservables`, one + * {@link GroupedObservable} per group. + * + * + * + * @example Group objects by id and return as array + * Observable.of({id: 1, name: 'aze1'}, + * {id: 2, name: 'sf2'}, + * {id: 2, name: 'dg2'}, + * {id: 1, name: 'erg1'}, + * {id: 1, name: 'df1'}, + * {id: 2, name: 'sfqfb2'}, + * {id: 3, name: 'qfs3'}, + * {id: 2, name: 'qsgqsfg2'} + * ) + * .groupBy(p => p.id) + * .flatMap( (group$) => group$.reduce((acc, cur) => [...acc, cur], [])) + * .subscribe(p => console.log(p)); + * + * // displays: + * // [ { id: 1, name: 'aze1' }, + * // { id: 1, name: 'erg1' }, + * // { id: 1, name: 'df1' } ] + * // + * // [ { id: 2, name: 'sf2' }, + * // { id: 2, name: 'dg2' }, + * // { id: 2, name: 'sfqfb2' }, + * // { id: 2, name: 'qsgqsfg2' } ] + * // + * // [ { id: 3, name: 'qfs3' } ] + * + * @example Pivot data on the id field + * Observable.of({id: 1, name: 'aze1'}, + * {id: 2, name: 'sf2'}, + * {id: 2, name: 'dg2'}, + * {id: 1, name: 'erg1'}, + * {id: 1, name: 'df1'}, + * {id: 2, name: 'sfqfb2'}, + * {id: 3, name: 'qfs1'}, + * {id: 2, name: 'qsgqsfg2'} + * ) + * .groupBy(p => p.id, p => p.name) + * .flatMap( (group$) => group$.reduce((acc, cur) => [...acc, cur], ["" + group$.key])) + * .map(arr => ({'id': parseInt(arr[0]), 'values': arr.slice(1)})) + * .subscribe(p => console.log(p)); + * + * // displays: + * // { id: 1, values: [ 'aze1', 'erg1', 'df1' ] } + * // { id: 2, values: [ 'sf2', 'dg2', 'sfqfb2', 'qsgqsfg2' ] } + * // { id: 3, values: [ 'qfs1' ] } + * + * @param {function(value: T): K} keySelector A function that extracts the key + * for each item. + * @param {function(value: T): R} [elementSelector] A function that extracts the + * return element for each item. + * @param {function(grouped: GroupedObservable): Observable} [durationSelector] + * A function that returns an Observable to determine how long each group should + * exist. + * @return {Observable>} An Observable that emits + * GroupedObservables, each of which corresponds to a unique key value and each + * of which emits those items from the source Observable that share that key + * value. + * @method groupBy + * @owner Observable + */ +function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) { + return this.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector)); +} +exports.groupBy = groupBy; +var GroupByOperator = (function () { + function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) { + this.keySelector = keySelector; + this.elementSelector = elementSelector; + this.durationSelector = durationSelector; + this.subjectSelector = subjectSelector; + } + GroupByOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector)); + }; + return GroupByOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var GroupBySubscriber = (function (_super) { + __extends(GroupBySubscriber, _super); + function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) { + _super.call(this, destination); + this.keySelector = keySelector; + this.elementSelector = elementSelector; + this.durationSelector = durationSelector; + this.subjectSelector = subjectSelector; + this.groups = null; + this.attemptedToUnsubscribe = false; + this.count = 0; + } + GroupBySubscriber.prototype._next = function (value) { + var key; + try { + key = this.keySelector(value); + } + catch (err) { + this.error(err); + return; + } + this._group(value, key); + }; + GroupBySubscriber.prototype._group = function (value, key) { + var groups = this.groups; + if (!groups) { + groups = this.groups = typeof key === 'string' ? new FastMap_1.FastMap() : new Map_1.Map(); + } + var group = groups.get(key); + var element; + if (this.elementSelector) { + try { + element = this.elementSelector(value); + } + catch (err) { + this.error(err); + } + } + else { + element = value; + } + if (!group) { + group = this.subjectSelector ? this.subjectSelector() : new Subject_1.Subject(); + groups.set(key, group); + var groupedObservable = new GroupedObservable(key, group, this); + this.destination.next(groupedObservable); + if (this.durationSelector) { + var duration = void 0; + try { + duration = this.durationSelector(new GroupedObservable(key, group)); + } + catch (err) { + this.error(err); + return; + } + this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this))); + } + } + if (!group.closed) { + group.next(element); + } + }; + GroupBySubscriber.prototype._error = function (err) { + var groups = this.groups; + if (groups) { + groups.forEach(function (group, key) { + group.error(err); + }); + groups.clear(); + } + this.destination.error(err); + }; + GroupBySubscriber.prototype._complete = function () { + var groups = this.groups; + if (groups) { + groups.forEach(function (group, key) { + group.complete(); + }); + groups.clear(); + } + this.destination.complete(); + }; + GroupBySubscriber.prototype.removeGroup = function (key) { + this.groups.delete(key); + }; + GroupBySubscriber.prototype.unsubscribe = function () { + if (!this.closed) { + this.attemptedToUnsubscribe = true; + if (this.count === 0) { + _super.prototype.unsubscribe.call(this); + } + } + }; + return GroupBySubscriber; +}(Subscriber_1.Subscriber)); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var GroupDurationSubscriber = (function (_super) { + __extends(GroupDurationSubscriber, _super); + function GroupDurationSubscriber(key, group, parent) { + _super.call(this, group); + this.key = key; + this.group = group; + this.parent = parent; + } + GroupDurationSubscriber.prototype._next = function (value) { + this.complete(); + }; + GroupDurationSubscriber.prototype._unsubscribe = function () { + var _a = this, parent = _a.parent, key = _a.key; + this.key = this.parent = null; + if (parent) { + parent.removeGroup(key); + } + }; + return GroupDurationSubscriber; +}(Subscriber_1.Subscriber)); +/** + * An Observable representing values belonging to the same group represented by + * a common key. The values emitted by a GroupedObservable come from the source + * Observable. The common key is available as the field `key` on a + * GroupedObservable instance. + * + * @class GroupedObservable + */ +var GroupedObservable = (function (_super) { + __extends(GroupedObservable, _super); + function GroupedObservable(key, groupSubject, refCountSubscription) { + _super.call(this); + this.key = key; + this.groupSubject = groupSubject; + this.refCountSubscription = refCountSubscription; + } + GroupedObservable.prototype._subscribe = function (subscriber) { + var subscription = new Subscription_1.Subscription(); + var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject; + if (refCountSubscription && !refCountSubscription.closed) { + subscription.add(new InnerRefCountSubscription(refCountSubscription)); + } + subscription.add(groupSubject.subscribe(subscriber)); + return subscription; + }; + return GroupedObservable; +}(Observable_1.Observable)); +exports.GroupedObservable = GroupedObservable; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var InnerRefCountSubscription = (function (_super) { + __extends(InnerRefCountSubscription, _super); + function InnerRefCountSubscription(parent) { + _super.call(this); + this.parent = parent; + parent.count++; + } + InnerRefCountSubscription.prototype.unsubscribe = function () { + var parent = this.parent; + if (!parent.closed && !this.closed) { + _super.prototype.unsubscribe.call(this); + parent.count -= 1; + if (parent.count === 0 && parent.attemptedToUnsubscribe) { + parent.unsubscribe(); + } + } + }; + return InnerRefCountSubscription; +}(Subscription_1.Subscription)); +//# sourceMappingURL=groupBy.js.map + +/***/ }), /* 273 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var every_1 = __webpack_require__(274); - Observable_1.Observable.prototype.every = every_1.every; - //# sourceMappingURL=every.js.map +var root_1 = __webpack_require__(7); +var MapPolyfill_1 = __webpack_require__(274); +exports.Map = root_1.root.Map || (function () { return MapPolyfill_1.MapPolyfill; })(); +//# sourceMappingURL=Map.js.map -/***/ }, +/***/ }), /* 274 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Returns an Observable that emits whether or not every item of the source satisfies the condition specified. - * - * @example A simple example emitting true if all elements are less than 5, false otherwise - * Observable.of(1, 2, 3, 4, 5, 6) - * .every(x => x < 5) - * .subscribe(x => console.log(x)); // -> false - * - * @param {function} predicate A function for determining if an item meets a specified condition. - * @param {any} [thisArg] Optional object to use for `this` in the callback. - * @return {Observable} An Observable of booleans that determines if all items of the source Observable meet the condition specified. - * @method every - * @owner Observable - */ - function every(predicate, thisArg) { - return this.lift(new EveryOperator(predicate, thisArg, this)); - } - exports.every = every; - var EveryOperator = (function () { - function EveryOperator(predicate, thisArg, source) { - this.predicate = predicate; - this.thisArg = thisArg; - this.source = source; - } - EveryOperator.prototype.call = function (observer, source) { - return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source)); - }; - return EveryOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var EverySubscriber = (function (_super) { - __extends(EverySubscriber, _super); - function EverySubscriber(destination, predicate, thisArg, source) { - _super.call(this, destination); - this.predicate = predicate; - this.thisArg = thisArg; - this.source = source; - this.index = 0; - this.thisArg = thisArg || this; - } - EverySubscriber.prototype.notifyComplete = function (everyValueMatch) { - this.destination.next(everyValueMatch); - this.destination.complete(); - }; - EverySubscriber.prototype._next = function (value) { - var result = false; - try { - result = this.predicate.call(this.thisArg, value, this.index++, this.source); - } - catch (err) { - this.destination.error(err); - return; - } - if (!result) { - this.notifyComplete(false); - } - }; - EverySubscriber.prototype._complete = function () { - this.notifyComplete(true); - }; - return EverySubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=every.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var MapPolyfill = (function () { + function MapPolyfill() { + this.size = 0; + this._values = []; + this._keys = []; + } + MapPolyfill.prototype.get = function (key) { + var i = this._keys.indexOf(key); + return i === -1 ? undefined : this._values[i]; + }; + MapPolyfill.prototype.set = function (key, value) { + var i = this._keys.indexOf(key); + if (i === -1) { + this._keys.push(key); + this._values.push(value); + this.size++; + } + else { + this._values[i] = value; + } + return this; + }; + MapPolyfill.prototype.delete = function (key) { + var i = this._keys.indexOf(key); + if (i === -1) { + return false; + } + this._values.splice(i, 1); + this._keys.splice(i, 1); + this.size--; + return true; + }; + MapPolyfill.prototype.clear = function () { + this._keys.length = 0; + this._values.length = 0; + this.size = 0; + }; + MapPolyfill.prototype.forEach = function (cb, thisArg) { + for (var i = 0; i < this.size; i++) { + cb.call(thisArg, this._values[i], this._keys[i]); + } + }; + return MapPolyfill; +}()); +exports.MapPolyfill = MapPolyfill; +//# sourceMappingURL=MapPolyfill.js.map + +/***/ }), /* 275 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Observable_1 = __webpack_require__(64); - var map_1 = __webpack_require__(180); - Observable_1.Observable.prototype.map = map_1.map; - //# sourceMappingURL=map.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var FastMap = (function () { + function FastMap() { + this.values = {}; + } + FastMap.prototype.delete = function (key) { + this.values[key] = null; + return true; + }; + FastMap.prototype.set = function (key, value) { + this.values[key] = value; + return this; + }; + FastMap.prototype.get = function (key) { + return this.values[key]; + }; + FastMap.prototype.forEach = function (cb, thisArg) { + var values = this.values; + for (var key in values) { + if (values.hasOwnProperty(key) && values[key] !== null) { + cb.call(thisArg, values[key], key); + } + } + }; + FastMap.prototype.clear = function () { + this.values = {}; + }; + return FastMap; +}()); +exports.FastMap = FastMap; +//# sourceMappingURL=FastMap.js.map + +/***/ }), /* 276 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var mapTo_1 = __webpack_require__(277); - Observable_1.Observable.prototype.mapTo = mapTo_1.mapTo; - //# sourceMappingURL=mapTo.js.map +var Observable_1 = __webpack_require__(0); +var ignoreElements_1 = __webpack_require__(277); +Observable_1.Observable.prototype.ignoreElements = ignoreElements_1.ignoreElements; +//# sourceMappingURL=ignoreElements.js.map -/***/ }, +/***/ }), /* 277 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Emits the given constant value on the output Observable every time the source - * Observable emits a value. - * - * Like {@link map}, but it maps every source value to - * the same output value every time. - * - * - * - * Takes a constant `value` as argument, and emits that whenever the source - * Observable emits a value. In other words, ignores the actual source value, - * and simply uses the emission moment to know when to emit the given `value`. - * - * @example Map every click to the string 'Hi' - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var greetings = clicks.mapTo('Hi'); - * greetings.subscribe(x => console.log(x)); - * - * @see {@link map} - * - * @param {any} value The value to map each source value to. - * @return {Observable} An Observable that emits the given `value` every time - * the source Observable emits something. - * @method mapTo - * @owner Observable - */ - function mapTo(value) { - return this.lift(new MapToOperator(value)); - } - exports.mapTo = mapTo; - var MapToOperator = (function () { - function MapToOperator(value) { - this.value = value; - } - MapToOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new MapToSubscriber(subscriber, this.value)); - }; - return MapToOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var MapToSubscriber = (function (_super) { - __extends(MapToSubscriber, _super); - function MapToSubscriber(destination, value) { - _super.call(this, destination); - this.value = value; - } - MapToSubscriber.prototype._next = function (x) { - this.destination.next(this.value); - }; - return MapToSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=mapTo.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var noop_1 = __webpack_require__(69); +/** + * Ignores all items emitted by the source Observable and only passes calls of `complete` or `error`. + * + * + * + * @return {Observable} An empty Observable that only calls `complete` + * or `error`, based on which one is called by the source Observable. + * @method ignoreElements + * @owner Observable + */ +function ignoreElements() { + return this.lift(new IgnoreElementsOperator()); +} +exports.ignoreElements = ignoreElements; +; +var IgnoreElementsOperator = (function () { + function IgnoreElementsOperator() { + } + IgnoreElementsOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new IgnoreElementsSubscriber(subscriber)); + }; + return IgnoreElementsOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var IgnoreElementsSubscriber = (function (_super) { + __extends(IgnoreElementsSubscriber, _super); + function IgnoreElementsSubscriber() { + _super.apply(this, arguments); + } + IgnoreElementsSubscriber.prototype._next = function (unused) { + noop_1.noop(); + }; + return IgnoreElementsSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=ignoreElements.js.map + +/***/ }), /* 278 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var materialize_1 = __webpack_require__(279); - Observable_1.Observable.prototype.materialize = materialize_1.materialize; - //# sourceMappingURL=materialize.js.map +var Observable_1 = __webpack_require__(0); +var isEmpty_1 = __webpack_require__(279); +Observable_1.Observable.prototype.isEmpty = isEmpty_1.isEmpty; +//# sourceMappingURL=isEmpty.js.map -/***/ }, +/***/ }), /* 279 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var Notification_1 = __webpack_require__(119); - /** - * Represents all of the notifications from the source Observable as `next` - * emissions marked with their original types within {@link Notification} - * objects. - * - * Wraps `next`, `error` and `complete` emissions in - * {@link Notification} objects, emitted as `next` on the output Observable. - * - * - * - * - * `materialize` returns an Observable that emits a `next` notification for each - * `next`, `error`, or `complete` emission of the source Observable. When the - * source Observable emits `complete`, the output Observable will emit `next` as - * a Notification of type "complete", and then it will emit `complete` as well. - * When the source Observable emits `error`, the output will emit `next` as a - * Notification of type "error", and then `complete`. - * - * This operator is useful for producing metadata of the source Observable, to - * be consumed as `next` emissions. Use it in conjunction with - * {@link dematerialize}. - * - * @example Convert a faulty Observable to an Observable of Notifications - * var letters = Rx.Observable.of('a', 'b', 13, 'd'); - * var upperCase = letters.map(x => x.toUpperCase()); - * var materialized = upperCase.materialize(); - * materialized.subscribe(x => console.log(x)); - * - * // Results in the following: - * // - Notification {kind: "N", value: "A", error: undefined, hasValue: true} - * // - Notification {kind: "N", value: "B", error: undefined, hasValue: true} - * // - Notification {kind: "E", value: undefined, error: TypeError: - * // x.toUpperCase is not a function at MapSubscriber.letters.map.x - * // [as project] (http://1…, hasValue: false} - * - * @see {@link Notification} - * @see {@link dematerialize} - * - * @return {Observable>} An Observable that emits - * {@link Notification} objects that wrap the original emissions from the source - * Observable with metadata. - * @method materialize - * @owner Observable - */ - function materialize() { - return this.lift(new MaterializeOperator()); - } - exports.materialize = materialize; - var MaterializeOperator = (function () { - function MaterializeOperator() { - } - MaterializeOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new MaterializeSubscriber(subscriber)); - }; - return MaterializeOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var MaterializeSubscriber = (function (_super) { - __extends(MaterializeSubscriber, _super); - function MaterializeSubscriber(destination) { - _super.call(this, destination); - } - MaterializeSubscriber.prototype._next = function (value) { - this.destination.next(Notification_1.Notification.createNext(value)); - }; - MaterializeSubscriber.prototype._error = function (err) { - var destination = this.destination; - destination.next(Notification_1.Notification.createError(err)); - destination.complete(); - }; - MaterializeSubscriber.prototype._complete = function () { - var destination = this.destination; - destination.next(Notification_1.Notification.createComplete()); - destination.complete(); - }; - return MaterializeSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=materialize.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * If the source Observable is empty it returns an Observable that emits true, otherwise it emits false. + * + * + * + * @return {Observable} An Observable that emits a Boolean. + * @method isEmpty + * @owner Observable + */ +function isEmpty() { + return this.lift(new IsEmptyOperator()); +} +exports.isEmpty = isEmpty; +var IsEmptyOperator = (function () { + function IsEmptyOperator() { + } + IsEmptyOperator.prototype.call = function (observer, source) { + return source.subscribe(new IsEmptySubscriber(observer)); + }; + return IsEmptyOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var IsEmptySubscriber = (function (_super) { + __extends(IsEmptySubscriber, _super); + function IsEmptySubscriber(destination) { + _super.call(this, destination); + } + IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) { + var destination = this.destination; + destination.next(isEmpty); + destination.complete(); + }; + IsEmptySubscriber.prototype._next = function (value) { + this.notifyComplete(false); + }; + IsEmptySubscriber.prototype._complete = function () { + this.notifyComplete(true); + }; + return IsEmptySubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=isEmpty.js.map + +/***/ }), /* 280 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var max_1 = __webpack_require__(281); - Observable_1.Observable.prototype.max = max_1.max; - //# sourceMappingURL=max.js.map +"use strict"; -/***/ }, -/* 281 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var reduce_1 = __webpack_require__(282); - /** - * The Max operator operates on an Observable that emits numbers (or items that can be compared with a provided function), - * and when source Observable completes it emits a single item: the item with the largest value. - * - * - * - * @example Get the maximal value of a series of numbers - * Rx.Observable.of(5, 4, 7, 2, 8) - * .max() - * .subscribe(x => console.log(x)); // -> 8 - * - * @example Use a comparer function to get the maximal item - * interface Person { - * age: number, - * name: string - * } - * Observable.of({age: 7, name: 'Foo'}, - * {age: 5, name: 'Bar'}, - * {age: 9, name: 'Beer'}) - * .max((a: Person, b: Person) => a.age < b.age ? -1 : 1) - * .subscribe((x: Person) => console.log(x.name)); // -> 'Beer' - * } - * - * @see {@link min} - * - * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the - * value of two items. - * @return {Observable} An Observable that emits item with the largest value. - * @method max - * @owner Observable - */ - function max(comparer) { - var max = (typeof comparer === 'function') - ? function (x, y) { return comparer(x, y) > 0 ? x : y; } - : function (x, y) { return x > y ? x : y; }; - return this.lift(new reduce_1.ReduceOperator(max)); - } - exports.max = max; - //# sourceMappingURL=max.js.map +var Observable_1 = __webpack_require__(0); +var audit_1 = __webpack_require__(281); +Observable_1.Observable.prototype.audit = audit_1.audit; +//# sourceMappingURL=audit.js.map -/***/ }, +/***/ }), +/* 281 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Ignores source values for a duration determined by another Observable, then + * emits the most recent value from the source Observable, then repeats this + * process. + * + * It's like {@link auditTime}, but the silencing + * duration is determined by a second Observable. + * + * + * + * `audit` is similar to `throttle`, but emits the last value from the silenced + * time window, instead of the first value. `audit` emits the most recent value + * from the source Observable on the output Observable as soon as its internal + * timer becomes disabled, and ignores source values while the timer is enabled. + * Initially, the timer is disabled. As soon as the first source value arrives, + * the timer is enabled by calling the `durationSelector` function with the + * source value, which returns the "duration" Observable. When the duration + * Observable emits a value or completes, the timer is disabled, then the most + * recent source value is emitted on the output Observable, and this process + * repeats for the next source value. + * + * @example Emit clicks at a rate of at most one click per second + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.audit(ev => Rx.Observable.interval(1000)); + * result.subscribe(x => console.log(x)); + * + * @see {@link auditTime} + * @see {@link debounce} + * @see {@link delayWhen} + * @see {@link sample} + * @see {@link throttle} + * + * @param {function(value: T): SubscribableOrPromise} durationSelector A function + * that receives a value from the source Observable, for computing the silencing + * duration, returned as an Observable or a Promise. + * @return {Observable} An Observable that performs rate-limiting of + * emissions from the source Observable. + * @method audit + * @owner Observable + */ +function audit(durationSelector) { + return this.lift(new AuditOperator(durationSelector)); +} +exports.audit = audit; +var AuditOperator = (function () { + function AuditOperator(durationSelector) { + this.durationSelector = durationSelector; + } + AuditOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector)); + }; + return AuditOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var AuditSubscriber = (function (_super) { + __extends(AuditSubscriber, _super); + function AuditSubscriber(destination, durationSelector) { + _super.call(this, destination); + this.durationSelector = durationSelector; + this.hasValue = false; + } + AuditSubscriber.prototype._next = function (value) { + this.value = value; + this.hasValue = true; + if (!this.throttled) { + var duration = tryCatch_1.tryCatch(this.durationSelector)(value); + if (duration === errorObject_1.errorObject) { + this.destination.error(errorObject_1.errorObject.e); + } + else { + var innerSubscription = subscribeToResult_1.subscribeToResult(this, duration); + if (innerSubscription.closed) { + this.clearThrottle(); + } + else { + this.add(this.throttled = innerSubscription); + } + } + } + }; + AuditSubscriber.prototype.clearThrottle = function () { + var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled; + if (throttled) { + this.remove(throttled); + this.throttled = null; + throttled.unsubscribe(); + } + if (hasValue) { + this.value = null; + this.hasValue = false; + this.destination.next(value); + } + }; + AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) { + this.clearThrottle(); + }; + AuditSubscriber.prototype.notifyComplete = function () { + this.clearThrottle(); + }; + return AuditSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=audit.js.map + +/***/ }), /* 282 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /* tslint:enable:max-line-length */ - /** - * Applies an accumulator function over the source Observable, and returns the - * accumulated result when the source completes, given an optional seed value. - * - * Combines together all values emitted on the source, - * using an accumulator function that knows how to join a new source value into - * the accumulation from the past. - * - * - * - * Like - * [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce), - * `reduce` applies an `accumulator` function against an accumulation and each - * value of the source Observable (from the past) to reduce it to a single - * value, emitted on the output Observable. Note that `reduce` will only emit - * one value, only when the source Observable completes. It is equivalent to - * applying operator {@link scan} followed by operator {@link last}. - * - * Returns an Observable that applies a specified `accumulator` function to each - * item emitted by the source Observable. If a `seed` value is specified, then - * that value will be used as the initial value for the accumulator. If no seed - * value is specified, the first item of the source is used as the seed. - * - * @example Count the number of click events that happened in 5 seconds - * var clicksInFiveSeconds = Rx.Observable.fromEvent(document, 'click') - * .takeUntil(Rx.Observable.interval(5000)); - * var ones = clicksInFiveSeconds.mapTo(1); - * var seed = 0; - * var count = ones.reduce((acc, one) => acc + one, seed); - * count.subscribe(x => console.log(x)); - * - * @see {@link count} - * @see {@link expand} - * @see {@link mergeScan} - * @see {@link scan} - * - * @param {function(acc: R, value: T, index: number): R} accumulator The accumulator function - * called on each source value. - * @param {R} [seed] The initial accumulation value. - * @return {Observable} An Observable that emits a single value that is the - * result of accumulating the values emitted by the source Observable. - * @method reduce - * @owner Observable - */ - function reduce(accumulator, seed) { - var hasSeed = false; - // providing a seed of `undefined` *should* be valid and trigger - // hasSeed! so don't use `seed !== undefined` checks! - // For this reason, we have to check it here at the original call site - // otherwise inside Operator/Subscriber we won't know if `undefined` - // means they didn't provide anything or if they literally provided `undefined` - if (arguments.length >= 2) { - hasSeed = true; - } - return this.lift(new ReduceOperator(accumulator, seed, hasSeed)); - } - exports.reduce = reduce; - var ReduceOperator = (function () { - function ReduceOperator(accumulator, seed, hasSeed) { - if (hasSeed === void 0) { hasSeed = false; } - this.accumulator = accumulator; - this.seed = seed; - this.hasSeed = hasSeed; - } - ReduceOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ReduceSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed)); - }; - return ReduceOperator; - }()); - exports.ReduceOperator = ReduceOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ReduceSubscriber = (function (_super) { - __extends(ReduceSubscriber, _super); - function ReduceSubscriber(destination, accumulator, seed, hasSeed) { - _super.call(this, destination); - this.accumulator = accumulator; - this.hasSeed = hasSeed; - this.index = 0; - this.hasValue = false; - this.acc = seed; - if (!this.hasSeed) { - this.index++; - } - } - ReduceSubscriber.prototype._next = function (value) { - if (this.hasValue || (this.hasValue = this.hasSeed)) { - this._tryReduce(value); - } - else { - this.acc = value; - this.hasValue = true; - } - }; - ReduceSubscriber.prototype._tryReduce = function (value) { - var result; - try { - result = this.accumulator(this.acc, value, this.index++); - } - catch (err) { - this.destination.error(err); - return; - } - this.acc = result; - }; - ReduceSubscriber.prototype._complete = function () { - if (this.hasValue || this.hasSeed) { - this.destination.next(this.acc); - } - this.destination.complete(); - }; - return ReduceSubscriber; - }(Subscriber_1.Subscriber)); - exports.ReduceSubscriber = ReduceSubscriber; - //# sourceMappingURL=reduce.js.map - -/***/ }, -/* 283 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var merge_1 = __webpack_require__(145); - Observable_1.Observable.prototype.merge = merge_1.merge; - //# sourceMappingURL=merge.js.map +"use strict"; -/***/ }, -/* 284 */ -/***/ function(module, exports, __webpack_require__) { +var Observable_1 = __webpack_require__(0); +var auditTime_1 = __webpack_require__(283); +Observable_1.Observable.prototype.auditTime = auditTime_1.auditTime; +//# sourceMappingURL=auditTime.js.map - "use strict"; - var Observable_1 = __webpack_require__(64); - var mergeAll_1 = __webpack_require__(103); - Observable_1.Observable.prototype.mergeAll = mergeAll_1.mergeAll; - //# sourceMappingURL=mergeAll.js.map +/***/ }), +/* 283 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 async_1 = __webpack_require__(9); +var Subscriber_1 = __webpack_require__(1); +/** + * Ignores source values for `duration` milliseconds, then emits the most recent + * value from the source Observable, then repeats this process. + * + * When it sees a source values, it ignores that plus + * the next ones for `duration` milliseconds, and then it emits the most recent + * value from the source. + * + * + * + * `auditTime` is similar to `throttleTime`, but emits the last value from the + * silenced time window, instead of the first value. `auditTime` emits the most + * recent value from the source Observable on the output Observable as soon as + * its internal timer becomes disabled, and ignores source values while the + * timer is enabled. Initially, the timer is disabled. As soon as the first + * source value arrives, the timer is enabled. After `duration` milliseconds (or + * the time unit determined internally by the optional `scheduler`) has passed, + * the timer is disabled, then the most recent source value is emitted on the + * output Observable, and this process repeats for the next source value. + * Optionally takes a {@link IScheduler} for managing timers. + * + * @example Emit clicks at a rate of at most one click per second + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.auditTime(1000); + * result.subscribe(x => console.log(x)); + * + * @see {@link audit} + * @see {@link debounceTime} + * @see {@link delay} + * @see {@link sampleTime} + * @see {@link throttleTime} + * + * @param {number} duration Time to wait before emitting the most recent source + * value, measured in milliseconds or the time unit determined internally + * by the optional `scheduler`. + * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for + * managing the timers that handle the rate-limiting behavior. + * @return {Observable} An Observable that performs rate-limiting of + * emissions from the source Observable. + * @method auditTime + * @owner Observable + */ +function auditTime(duration, scheduler) { + if (scheduler === void 0) { scheduler = async_1.async; } + return this.lift(new AuditTimeOperator(duration, scheduler)); +} +exports.auditTime = auditTime; +var AuditTimeOperator = (function () { + function AuditTimeOperator(duration, scheduler) { + this.duration = duration; + this.scheduler = scheduler; + } + AuditTimeOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new AuditTimeSubscriber(subscriber, this.duration, this.scheduler)); + }; + return AuditTimeOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var AuditTimeSubscriber = (function (_super) { + __extends(AuditTimeSubscriber, _super); + function AuditTimeSubscriber(destination, duration, scheduler) { + _super.call(this, destination); + this.duration = duration; + this.scheduler = scheduler; + this.hasValue = false; + } + AuditTimeSubscriber.prototype._next = function (value) { + this.value = value; + this.hasValue = true; + if (!this.throttled) { + this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, this)); + } + }; + AuditTimeSubscriber.prototype.clearThrottle = function () { + var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled; + if (throttled) { + this.remove(throttled); + this.throttled = null; + throttled.unsubscribe(); + } + if (hasValue) { + this.value = null; + this.hasValue = false; + this.destination.next(value); + } + }; + return AuditTimeSubscriber; +}(Subscriber_1.Subscriber)); +function dispatchNext(subscriber) { + subscriber.clearThrottle(); +} +//# sourceMappingURL=auditTime.js.map + +/***/ }), +/* 284 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 285 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var mergeMap_1 = __webpack_require__(209); - Observable_1.Observable.prototype.mergeMap = mergeMap_1.mergeMap; - Observable_1.Observable.prototype.flatMap = mergeMap_1.mergeMap; - //# sourceMappingURL=mergeMap.js.map +var Observable_1 = __webpack_require__(0); +var last_1 = __webpack_require__(285); +Observable_1.Observable.prototype.last = last_1.last; +//# sourceMappingURL=last.js.map -/***/ }, +/***/ }), +/* 285 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var EmptyError_1 = __webpack_require__(37); +/* tslint:enable:max-line-length */ +/** + * Returns an Observable that emits only the last item emitted by the source Observable. + * It optionally takes a predicate function as a parameter, in which case, rather than emitting + * the last item from the source Observable, the resulting Observable will emit the last item + * from the source Observable that satisfies the predicate. + * + * + * + * @throws {EmptyError} Delivers an EmptyError to the Observer's `error` + * callback if the Observable completes before any `next` notification was sent. + * @param {function} predicate - The condition any source emitted item has to satisfy. + * @return {Observable} An Observable that emits only the last item satisfying the given condition + * from the source, or an NoSuchElementException if no such items are emitted. + * @throws - Throws if no items that match the predicate are emitted by the source Observable. + * @method last + * @owner Observable + */ +function last(predicate, resultSelector, defaultValue) { + return this.lift(new LastOperator(predicate, resultSelector, defaultValue, this)); +} +exports.last = last; +var LastOperator = (function () { + function LastOperator(predicate, resultSelector, defaultValue, source) { + this.predicate = predicate; + this.resultSelector = resultSelector; + this.defaultValue = defaultValue; + this.source = source; + } + LastOperator.prototype.call = function (observer, source) { + return source.subscribe(new LastSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source)); + }; + return LastOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var LastSubscriber = (function (_super) { + __extends(LastSubscriber, _super); + function LastSubscriber(destination, predicate, resultSelector, defaultValue, source) { + _super.call(this, destination); + this.predicate = predicate; + this.resultSelector = resultSelector; + this.defaultValue = defaultValue; + this.source = source; + this.hasValue = false; + this.index = 0; + if (typeof defaultValue !== 'undefined') { + this.lastValue = defaultValue; + this.hasValue = true; + } + } + LastSubscriber.prototype._next = function (value) { + var index = this.index++; + if (this.predicate) { + this._tryPredicate(value, index); + } + else { + if (this.resultSelector) { + this._tryResultSelector(value, index); + return; + } + this.lastValue = value; + this.hasValue = true; + } + }; + LastSubscriber.prototype._tryPredicate = function (value, index) { + var result; + try { + result = this.predicate(value, index, this.source); + } + catch (err) { + this.destination.error(err); + return; + } + if (result) { + if (this.resultSelector) { + this._tryResultSelector(value, index); + return; + } + this.lastValue = value; + this.hasValue = true; + } + }; + LastSubscriber.prototype._tryResultSelector = function (value, index) { + var result; + try { + result = this.resultSelector(value, index); + } + catch (err) { + this.destination.error(err); + return; + } + this.lastValue = result; + this.hasValue = true; + }; + LastSubscriber.prototype._complete = function () { + var destination = this.destination; + if (this.hasValue) { + destination.next(this.lastValue); + destination.complete(); + } + else { + destination.error(new EmptyError_1.EmptyError); + } + }; + return LastSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=last.js.map + +/***/ }), /* 286 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var mergeMapTo_1 = __webpack_require__(212); - Observable_1.Observable.prototype.flatMapTo = mergeMapTo_1.mergeMapTo; - Observable_1.Observable.prototype.mergeMapTo = mergeMapTo_1.mergeMapTo; - //# sourceMappingURL=mergeMapTo.js.map +var Observable_1 = __webpack_require__(0); +var let_1 = __webpack_require__(287); +Observable_1.Observable.prototype.let = let_1.letProto; +Observable_1.Observable.prototype.letBind = let_1.letProto; +//# sourceMappingURL=let.js.map -/***/ }, +/***/ }), /* 287 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +/** + * @param func + * @return {Observable} + * @method let + * @owner Observable + */ +function letProto(func) { + return func(this); +} +exports.letProto = letProto; +//# sourceMappingURL=let.js.map + +/***/ }), +/* 288 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var mergeScan_1 = __webpack_require__(288); - Observable_1.Observable.prototype.mergeScan = mergeScan_1.mergeScan; - //# sourceMappingURL=mergeScan.js.map +"use strict"; -/***/ }, -/* 288 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var subscribeToResult_1 = __webpack_require__(95); - var OuterSubscriber_1 = __webpack_require__(94); - /** - * Applies an accumulator function over the source Observable where the - * accumulator function itself returns an Observable, then each intermediate - * Observable returned is merged into the output Observable. - * - * It's like {@link scan}, but the Observables returned - * by the accumulator are merged into the outer Observable. - * - * @example Count the number of click events - * const click$ = Rx.Observable.fromEvent(document, 'click'); - * const one$ = click$.mapTo(1); - * const seed = 0; - * const count$ = one$.mergeScan((acc, one) => Rx.Observable.of(acc + one), seed); - * count$.subscribe(x => console.log(x)); - * - * // Results: - * 1 - * 2 - * 3 - * 4 - * // ...and so on for each click - * - * @param {function(acc: R, value: T): Observable} accumulator - * The accumulator function called on each source value. - * @param seed The initial accumulation value. - * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of - * input Observables being subscribed to concurrently. - * @return {Observable} An observable of the accumulated values. - * @method mergeScan - * @owner Observable - */ - function mergeScan(accumulator, seed, concurrent) { - if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } - return this.lift(new MergeScanOperator(accumulator, seed, concurrent)); - } - exports.mergeScan = mergeScan; - var MergeScanOperator = (function () { - function MergeScanOperator(accumulator, seed, concurrent) { - this.accumulator = accumulator; - this.seed = seed; - this.concurrent = concurrent; - } - MergeScanOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent)); - }; - return MergeScanOperator; - }()); - exports.MergeScanOperator = MergeScanOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var MergeScanSubscriber = (function (_super) { - __extends(MergeScanSubscriber, _super); - function MergeScanSubscriber(destination, accumulator, acc, concurrent) { - _super.call(this, destination); - this.accumulator = accumulator; - this.acc = acc; - this.concurrent = concurrent; - this.hasValue = false; - this.hasCompleted = false; - this.buffer = []; - this.active = 0; - this.index = 0; - } - MergeScanSubscriber.prototype._next = function (value) { - if (this.active < this.concurrent) { - var index = this.index++; - var ish = tryCatch_1.tryCatch(this.accumulator)(this.acc, value); - var destination = this.destination; - if (ish === errorObject_1.errorObject) { - destination.error(errorObject_1.errorObject.e); - } - else { - this.active++; - this._innerSub(ish, value, index); - } - } - else { - this.buffer.push(value); - } - }; - MergeScanSubscriber.prototype._innerSub = function (ish, value, index) { - this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index)); - }; - MergeScanSubscriber.prototype._complete = function () { - this.hasCompleted = true; - if (this.active === 0 && this.buffer.length === 0) { - if (this.hasValue === false) { - this.destination.next(this.acc); - } - this.destination.complete(); - } - }; - MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var destination = this.destination; - this.acc = innerValue; - this.hasValue = true; - destination.next(innerValue); - }; - MergeScanSubscriber.prototype.notifyComplete = function (innerSub) { - var buffer = this.buffer; - this.remove(innerSub); - this.active--; - if (buffer.length > 0) { - this._next(buffer.shift()); - } - else if (this.active === 0 && this.hasCompleted) { - if (this.hasValue === false) { - this.destination.next(this.acc); - } - this.destination.complete(); - } - }; - return MergeScanSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - exports.MergeScanSubscriber = MergeScanSubscriber; - //# sourceMappingURL=mergeScan.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var every_1 = __webpack_require__(289); +Observable_1.Observable.prototype.every = every_1.every; +//# sourceMappingURL=every.js.map + +/***/ }), /* 289 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Returns an Observable that emits whether or not every item of the source satisfies the condition specified. + * + * @example A simple example emitting true if all elements are less than 5, false otherwise + * Observable.of(1, 2, 3, 4, 5, 6) + * .every(x => x < 5) + * .subscribe(x => console.log(x)); // -> false + * + * @param {function} predicate A function for determining if an item meets a specified condition. + * @param {any} [thisArg] Optional object to use for `this` in the callback. + * @return {Observable} An Observable of booleans that determines if all items of the source Observable meet the condition specified. + * @method every + * @owner Observable + */ +function every(predicate, thisArg) { + return this.lift(new EveryOperator(predicate, thisArg, this)); +} +exports.every = every; +var EveryOperator = (function () { + function EveryOperator(predicate, thisArg, source) { + this.predicate = predicate; + this.thisArg = thisArg; + this.source = source; + } + EveryOperator.prototype.call = function (observer, source) { + return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source)); + }; + return EveryOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var EverySubscriber = (function (_super) { + __extends(EverySubscriber, _super); + function EverySubscriber(destination, predicate, thisArg, source) { + _super.call(this, destination); + this.predicate = predicate; + this.thisArg = thisArg; + this.source = source; + this.index = 0; + this.thisArg = thisArg || this; + } + EverySubscriber.prototype.notifyComplete = function (everyValueMatch) { + this.destination.next(everyValueMatch); + this.destination.complete(); + }; + EverySubscriber.prototype._next = function (value) { + var result = false; + try { + result = this.predicate.call(this.thisArg, value, this.index++, this.source); + } + catch (err) { + this.destination.error(err); + return; + } + if (!result) { + this.notifyComplete(false); + } + }; + EverySubscriber.prototype._complete = function () { + this.notifyComplete(true); + }; + return EverySubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=every.js.map + +/***/ }), +/* 290 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var min_1 = __webpack_require__(290); - Observable_1.Observable.prototype.min = min_1.min; - //# sourceMappingURL=min.js.map +"use strict"; -/***/ }, -/* 290 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var reduce_1 = __webpack_require__(282); - /** - * The Min operator operates on an Observable that emits numbers (or items that can be compared with a provided function), - * and when source Observable completes it emits a single item: the item with the smallest value. - * - * - * - * @example Get the minimal value of a series of numbers - * Rx.Observable.of(5, 4, 7, 2, 8) - * .min() - * .subscribe(x => console.log(x)); // -> 2 - * - * @example Use a comparer function to get the minimal item - * interface Person { - * age: number, - * name: string - * } - * Observable.of({age: 7, name: 'Foo'}, - * {age: 5, name: 'Bar'}, - * {age: 9, name: 'Beer'}) - * .min( (a: Person, b: Person) => a.age < b.age ? -1 : 1) - * .subscribe((x: Person) => console.log(x.name)); // -> 'Bar' - * } - * - * @see {@link max} - * - * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the - * value of two items. - * @return {Observable} An Observable that emits item with the smallest value. - * @method min - * @owner Observable - */ - function min(comparer) { - var min = (typeof comparer === 'function') - ? function (x, y) { return comparer(x, y) < 0 ? x : y; } - : function (x, y) { return x < y ? x : y; }; - return this.lift(new reduce_1.ReduceOperator(min)); - } - exports.min = min; - //# sourceMappingURL=min.js.map +var Observable_1 = __webpack_require__(0); +var map_1 = __webpack_require__(48); +Observable_1.Observable.prototype.map = map_1.map; +//# sourceMappingURL=map.js.map -/***/ }, +/***/ }), /* 291 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var multicast_1 = __webpack_require__(292); - Observable_1.Observable.prototype.multicast = multicast_1.multicast; - //# sourceMappingURL=multicast.js.map +var Observable_1 = __webpack_require__(0); +var mapTo_1 = __webpack_require__(292); +Observable_1.Observable.prototype.mapTo = mapTo_1.mapTo; +//# sourceMappingURL=mapTo.js.map -/***/ }, +/***/ }), /* 292 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var ConnectableObservable_1 = __webpack_require__(293); - /* tslint:enable:max-line-length */ - /** - * Returns an Observable that emits the results of invoking a specified selector on items - * emitted by a ConnectableObservable that shares a single subscription to the underlying stream. - * - * - * - * @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through - * which the source sequence's elements will be multicast to the selector function - * or Subject to push source elements into. - * @param {Function} [selector] - Optional selector function that can use the multicasted source stream - * as many times as needed, without causing multiple subscriptions to the source stream. - * Subscribers to the given source will receive all notifications of the source from the - * time of the subscription forward. - * @return {Observable} An Observable that emits the results of invoking the selector - * on the items emitted by a `ConnectableObservable` that shares a single subscription to - * the underlying stream. - * @method multicast - * @owner Observable - */ - function multicast(subjectOrSubjectFactory, selector) { - var subjectFactory; - if (typeof subjectOrSubjectFactory === 'function') { - subjectFactory = subjectOrSubjectFactory; - } - else { - subjectFactory = function subjectFactory() { - return subjectOrSubjectFactory; - }; - } - if (typeof selector === 'function') { - return this.lift(new MulticastOperator(subjectFactory, selector)); - } - var connectable = Object.create(this, ConnectableObservable_1.connectableObservableDescriptor); - connectable.source = this; - connectable.subjectFactory = subjectFactory; - return connectable; - } - exports.multicast = multicast; - var MulticastOperator = (function () { - function MulticastOperator(subjectFactory, selector) { - this.subjectFactory = subjectFactory; - this.selector = selector; - } - MulticastOperator.prototype.call = function (subscriber, source) { - var selector = this.selector; - var subject = this.subjectFactory(); - var subscription = selector(subject).subscribe(subscriber); - subscription.add(source.subscribe(subject)); - return subscription; - }; - return MulticastOperator; - }()); - exports.MulticastOperator = MulticastOperator; - //# sourceMappingURL=multicast.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Emits the given constant value on the output Observable every time the source + * Observable emits a value. + * + * Like {@link map}, but it maps every source value to + * the same output value every time. + * + * + * + * Takes a constant `value` as argument, and emits that whenever the source + * Observable emits a value. In other words, ignores the actual source value, + * and simply uses the emission moment to know when to emit the given `value`. + * + * @example Map every click to the string 'Hi' + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var greetings = clicks.mapTo('Hi'); + * greetings.subscribe(x => console.log(x)); + * + * @see {@link map} + * + * @param {any} value The value to map each source value to. + * @return {Observable} An Observable that emits the given `value` every time + * the source Observable emits something. + * @method mapTo + * @owner Observable + */ +function mapTo(value) { + return this.lift(new MapToOperator(value)); +} +exports.mapTo = mapTo; +var MapToOperator = (function () { + function MapToOperator(value) { + this.value = value; + } + MapToOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new MapToSubscriber(subscriber, this.value)); + }; + return MapToOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var MapToSubscriber = (function (_super) { + __extends(MapToSubscriber, _super); + function MapToSubscriber(destination, value) { + _super.call(this, destination); + this.value = value; + } + MapToSubscriber.prototype._next = function (x) { + this.destination.next(this.value); + }; + return MapToSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=mapTo.js.map + +/***/ }), /* 293 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subject_1 = __webpack_require__(63); - var Observable_1 = __webpack_require__(64); - var Subscriber_1 = __webpack_require__(67); - var Subscription_1 = __webpack_require__(69); - /** - * @class ConnectableObservable - */ - var ConnectableObservable = (function (_super) { - __extends(ConnectableObservable, _super); - function ConnectableObservable(source, subjectFactory) { - _super.call(this); - this.source = source; - this.subjectFactory = subjectFactory; - this._refCount = 0; - this._isComplete = false; - } - ConnectableObservable.prototype._subscribe = function (subscriber) { - return this.getSubject().subscribe(subscriber); - }; - ConnectableObservable.prototype.getSubject = function () { - var subject = this._subject; - if (!subject || subject.isStopped) { - this._subject = this.subjectFactory(); - } - return this._subject; - }; - ConnectableObservable.prototype.connect = function () { - var connection = this._connection; - if (!connection) { - this._isComplete = false; - connection = this._connection = new Subscription_1.Subscription(); - connection.add(this.source - .subscribe(new ConnectableSubscriber(this.getSubject(), this))); - if (connection.closed) { - this._connection = null; - connection = Subscription_1.Subscription.EMPTY; - } - else { - this._connection = connection; - } - } - return connection; - }; - ConnectableObservable.prototype.refCount = function () { - return this.lift(new RefCountOperator(this)); - }; - return ConnectableObservable; - }(Observable_1.Observable)); - exports.ConnectableObservable = ConnectableObservable; - var connectableProto = ConnectableObservable.prototype; - exports.connectableObservableDescriptor = { - operator: { value: null }, - _refCount: { value: 0, writable: true }, - _subject: { value: null, writable: true }, - _connection: { value: null, writable: true }, - _subscribe: { value: connectableProto._subscribe }, - _isComplete: { value: connectableProto._isComplete, writable: true }, - getSubject: { value: connectableProto.getSubject }, - connect: { value: connectableProto.connect }, - refCount: { value: connectableProto.refCount } - }; - var ConnectableSubscriber = (function (_super) { - __extends(ConnectableSubscriber, _super); - function ConnectableSubscriber(destination, connectable) { - _super.call(this, destination); - this.connectable = connectable; - } - ConnectableSubscriber.prototype._error = function (err) { - this._unsubscribe(); - _super.prototype._error.call(this, err); - }; - ConnectableSubscriber.prototype._complete = function () { - this.connectable._isComplete = true; - this._unsubscribe(); - _super.prototype._complete.call(this); - }; - ConnectableSubscriber.prototype._unsubscribe = function () { - var connectable = this.connectable; - if (connectable) { - this.connectable = null; - var connection = connectable._connection; - connectable._refCount = 0; - connectable._subject = null; - connectable._connection = null; - if (connection) { - connection.unsubscribe(); - } - } - }; - return ConnectableSubscriber; - }(Subject_1.SubjectSubscriber)); - var RefCountOperator = (function () { - function RefCountOperator(connectable) { - this.connectable = connectable; - } - RefCountOperator.prototype.call = function (subscriber, source) { - var connectable = this.connectable; - connectable._refCount++; - var refCounter = new RefCountSubscriber(subscriber, connectable); - var subscription = source.subscribe(refCounter); - if (!refCounter.closed) { - refCounter.connection = connectable.connect(); - } - return subscription; - }; - return RefCountOperator; - }()); - var RefCountSubscriber = (function (_super) { - __extends(RefCountSubscriber, _super); - function RefCountSubscriber(destination, connectable) { - _super.call(this, destination); - this.connectable = connectable; - } - RefCountSubscriber.prototype._unsubscribe = function () { - var connectable = this.connectable; - if (!connectable) { - this.connection = null; - return; - } - this.connectable = null; - var refCount = connectable._refCount; - if (refCount <= 0) { - this.connection = null; - return; - } - connectable._refCount = refCount - 1; - if (refCount > 1) { - this.connection = null; - return; - } - /// - // Compare the local RefCountSubscriber's connection Subscription to the - // connection Subscription on the shared ConnectableObservable. In cases - // where the ConnectableObservable source synchronously emits values, and - // the RefCountSubscriber's downstream Observers synchronously unsubscribe, - // execution continues to here before the RefCountOperator has a chance to - // supply the RefCountSubscriber with the shared connection Subscription. - // For example: - // ``` - // Observable.range(0, 10) - // .publish() - // .refCount() - // .take(5) - // .subscribe(); - // ``` - // In order to account for this case, RefCountSubscriber should only dispose - // the ConnectableObservable's shared connection Subscription if the - // connection Subscription exists, *and* either: - // a. RefCountSubscriber doesn't have a reference to the shared connection - // Subscription yet, or, - // b. RefCountSubscriber's connection Subscription reference is identical - // to the shared connection Subscription - /// - var connection = this.connection; - var sharedConnection = connectable._connection; - this.connection = null; - if (sharedConnection && (!connection || sharedConnection === connection)) { - sharedConnection.unsubscribe(); - } - }; - return RefCountSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=ConnectableObservable.js.map - -/***/ }, -/* 294 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var observeOn_1 = __webpack_require__(118); - Observable_1.Observable.prototype.observeOn = observeOn_1.observeOn; - //# sourceMappingURL=observeOn.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var materialize_1 = __webpack_require__(294); +Observable_1.Observable.prototype.materialize = materialize_1.materialize; +//# sourceMappingURL=materialize.js.map + +/***/ }), +/* 294 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var Notification_1 = __webpack_require__(22); +/** + * Represents all of the notifications from the source Observable as `next` + * emissions marked with their original types within {@link Notification} + * objects. + * + * Wraps `next`, `error` and `complete` emissions in + * {@link Notification} objects, emitted as `next` on the output Observable. + * + * + * + * + * `materialize` returns an Observable that emits a `next` notification for each + * `next`, `error`, or `complete` emission of the source Observable. When the + * source Observable emits `complete`, the output Observable will emit `next` as + * a Notification of type "complete", and then it will emit `complete` as well. + * When the source Observable emits `error`, the output will emit `next` as a + * Notification of type "error", and then `complete`. + * + * This operator is useful for producing metadata of the source Observable, to + * be consumed as `next` emissions. Use it in conjunction with + * {@link dematerialize}. + * + * @example Convert a faulty Observable to an Observable of Notifications + * var letters = Rx.Observable.of('a', 'b', 13, 'd'); + * var upperCase = letters.map(x => x.toUpperCase()); + * var materialized = upperCase.materialize(); + * materialized.subscribe(x => console.log(x)); + * + * // Results in the following: + * // - Notification {kind: "N", value: "A", error: undefined, hasValue: true} + * // - Notification {kind: "N", value: "B", error: undefined, hasValue: true} + * // - Notification {kind: "E", value: undefined, error: TypeError: + * // x.toUpperCase is not a function at MapSubscriber.letters.map.x + * // [as project] (http://1…, hasValue: false} + * + * @see {@link Notification} + * @see {@link dematerialize} + * + * @return {Observable>} An Observable that emits + * {@link Notification} objects that wrap the original emissions from the source + * Observable with metadata. + * @method materialize + * @owner Observable + */ +function materialize() { + return this.lift(new MaterializeOperator()); +} +exports.materialize = materialize; +var MaterializeOperator = (function () { + function MaterializeOperator() { + } + MaterializeOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new MaterializeSubscriber(subscriber)); + }; + return MaterializeOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var MaterializeSubscriber = (function (_super) { + __extends(MaterializeSubscriber, _super); + function MaterializeSubscriber(destination) { + _super.call(this, destination); + } + MaterializeSubscriber.prototype._next = function (value) { + this.destination.next(Notification_1.Notification.createNext(value)); + }; + MaterializeSubscriber.prototype._error = function (err) { + var destination = this.destination; + destination.next(Notification_1.Notification.createError(err)); + destination.complete(); + }; + MaterializeSubscriber.prototype._complete = function () { + var destination = this.destination; + destination.next(Notification_1.Notification.createComplete()); + destination.complete(); + }; + return MaterializeSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=materialize.js.map + +/***/ }), /* 295 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var onErrorResumeNext_1 = __webpack_require__(157); - Observable_1.Observable.prototype.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext; - //# sourceMappingURL=onErrorResumeNext.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var max_1 = __webpack_require__(296); +Observable_1.Observable.prototype.max = max_1.max; +//# sourceMappingURL=max.js.map + +/***/ }), /* 296 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var reduce_1 = __webpack_require__(49); +/** + * The Max operator operates on an Observable that emits numbers (or items that can be compared with a provided function), + * and when source Observable completes it emits a single item: the item with the largest value. + * + * + * + * @example Get the maximal value of a series of numbers + * Rx.Observable.of(5, 4, 7, 2, 8) + * .max() + * .subscribe(x => console.log(x)); // -> 8 + * + * @example Use a comparer function to get the maximal item + * interface Person { + * age: number, + * name: string + * } + * Observable.of({age: 7, name: 'Foo'}, + * {age: 5, name: 'Bar'}, + * {age: 9, name: 'Beer'}) + * .max((a: Person, b: Person) => a.age < b.age ? -1 : 1) + * .subscribe((x: Person) => console.log(x.name)); // -> 'Beer' + * } + * + * @see {@link min} + * + * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the + * value of two items. + * @return {Observable} An Observable that emits item with the largest value. + * @method max + * @owner Observable + */ +function max(comparer) { + var max = (typeof comparer === 'function') + ? function (x, y) { return comparer(x, y) > 0 ? x : y; } + : function (x, y) { return x > y ? x : y; }; + return this.lift(new reduce_1.ReduceOperator(max)); +} +exports.max = max; +//# sourceMappingURL=max.js.map + +/***/ }), +/* 297 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var pairwise_1 = __webpack_require__(297); - Observable_1.Observable.prototype.pairwise = pairwise_1.pairwise; - //# sourceMappingURL=pairwise.js.map +"use strict"; -/***/ }, -/* 297 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Groups pairs of consecutive emissions together and emits them as an array of - * two values. - * - * Puts the current value and previous value together as - * an array, and emits that. - * - * - * - * The Nth emission from the source Observable will cause the output Observable - * to emit an array [(N-1)th, Nth] of the previous and the current value, as a - * pair. For this reason, `pairwise` emits on the second and subsequent - * emissions from the source Observable, but not on the first emission, because - * there is no previous value in that case. - * - * @example On every click (starting from the second), emit the relative distance to the previous click - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var pairs = clicks.pairwise(); - * var distance = pairs.map(pair => { - * var x0 = pair[0].clientX; - * var y0 = pair[0].clientY; - * var x1 = pair[1].clientX; - * var y1 = pair[1].clientY; - * return Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2)); - * }); - * distance.subscribe(x => console.log(x)); - * - * @see {@link buffer} - * @see {@link bufferCount} - * - * @return {Observable>} An Observable of pairs (as arrays) of - * consecutive values from the source Observable. - * @method pairwise - * @owner Observable - */ - function pairwise() { - return this.lift(new PairwiseOperator()); - } - exports.pairwise = pairwise; - var PairwiseOperator = (function () { - function PairwiseOperator() { - } - PairwiseOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new PairwiseSubscriber(subscriber)); - }; - return PairwiseOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var PairwiseSubscriber = (function (_super) { - __extends(PairwiseSubscriber, _super); - function PairwiseSubscriber(destination) { - _super.call(this, destination); - this.hasPrev = false; - } - PairwiseSubscriber.prototype._next = function (value) { - if (this.hasPrev) { - this.destination.next([this.prev, value]); - } - else { - this.hasPrev = true; - } - this.prev = value; - }; - return PairwiseSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=pairwise.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var merge_1 = __webpack_require__(67); +Observable_1.Observable.prototype.merge = merge_1.merge; +//# sourceMappingURL=merge.js.map + +/***/ }), /* 298 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var partition_1 = __webpack_require__(299); - Observable_1.Observable.prototype.partition = partition_1.partition; - //# sourceMappingURL=partition.js.map +var Observable_1 = __webpack_require__(0); +var mergeAll_1 = __webpack_require__(33); +Observable_1.Observable.prototype.mergeAll = mergeAll_1.mergeAll; +//# sourceMappingURL=mergeAll.js.map -/***/ }, +/***/ }), /* 299 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var not_1 = __webpack_require__(300); - var filter_1 = __webpack_require__(246); - /** - * Splits the source Observable into two, one with values that satisfy a - * predicate, and another with values that don't satisfy the predicate. - * - * It's like {@link filter}, but returns two Observables: - * one like the output of {@link filter}, and the other with values that did not - * pass the condition. - * - * - * - * `partition` outputs an array with two Observables that partition the values - * from the source Observable through the given `predicate` function. The first - * Observable in that array emits source values for which the predicate argument - * returns true. The second Observable emits source values for which the - * predicate returns false. The first behaves like {@link filter} and the second - * behaves like {@link filter} with the predicate negated. - * - * @example Partition click events into those on DIV elements and those elsewhere - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var parts = clicks.partition(ev => ev.target.tagName === 'DIV'); - * var clicksOnDivs = parts[0]; - * var clicksElsewhere = parts[1]; - * clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x)); - * clicksElsewhere.subscribe(x => console.log('Other clicked: ', x)); - * - * @see {@link filter} - * - * @param {function(value: T, index: number): boolean} predicate A function that - * evaluates each value emitted by the source Observable. If it returns `true`, - * the value is emitted on the first Observable in the returned array, if - * `false` the value is emitted on the second Observable in the array. The - * `index` parameter is the number `i` for the i-th source emission that has - * happened since the subscription, starting from the number `0`. - * @param {any} [thisArg] An optional argument to determine the value of `this` - * in the `predicate` function. - * @return {[Observable, Observable]} An array with two Observables: one - * with values that passed the predicate, and another with values that did not - * pass the predicate. - * @method partition - * @owner Observable - */ - function partition(predicate, thisArg) { - return [ - filter_1.filter.call(this, predicate, thisArg), - filter_1.filter.call(this, not_1.not(predicate, thisArg)) - ]; - } - exports.partition = partition; - //# sourceMappingURL=partition.js.map +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var mergeMap_1 = __webpack_require__(73); +Observable_1.Observable.prototype.mergeMap = mergeMap_1.mergeMap; +Observable_1.Observable.prototype.flatMap = mergeMap_1.mergeMap; +//# sourceMappingURL=mergeMap.js.map + +/***/ }), /* 300 */ -/***/ function(module, exports) { - - "use strict"; - function not(pred, thisArg) { - function notPred() { - return !(notPred.pred.apply(notPred.thisArg, arguments)); - } - notPred.pred = pred; - notPred.thisArg = thisArg; - return notPred; - } - exports.not = not; - //# sourceMappingURL=not.js.map +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var mergeMapTo_1 = __webpack_require__(74); +Observable_1.Observable.prototype.flatMapTo = mergeMapTo_1.mergeMapTo; +Observable_1.Observable.prototype.mergeMapTo = mergeMapTo_1.mergeMapTo; +//# sourceMappingURL=mergeMapTo.js.map -/***/ }, +/***/ }), /* 301 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var pluck_1 = __webpack_require__(302); - Observable_1.Observable.prototype.pluck = pluck_1.pluck; - //# sourceMappingURL=pluck.js.map +"use strict"; -/***/ }, -/* 302 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var map_1 = __webpack_require__(180); - /** - * Maps each source value (an object) to its specified nested property. - * - * Like {@link map}, but meant only for picking one of - * the nested properties of every emitted object. - * - * - * - * Given a list of strings describing a path to an object property, retrieves - * the value of a specified nested property from all values in the source - * Observable. If a property can't be resolved, it will return `undefined` for - * that value. - * - * @example Map every click to the tagName of the clicked target element - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var tagNames = clicks.pluck('target', 'tagName'); - * tagNames.subscribe(x => console.log(x)); - * - * @see {@link map} - * - * @param {...string} properties The nested properties to pluck from each source - * value (an object). - * @return {Observable} A new Observable of property values from the source values. - * @method pluck - * @owner Observable - */ - function pluck() { - var properties = []; - for (var _i = 0; _i < arguments.length; _i++) { - properties[_i - 0] = arguments[_i]; - } - var length = properties.length; - if (length === 0) { - throw new Error('list of properties cannot be empty.'); - } - return map_1.map.call(this, plucker(properties, length)); - } - exports.pluck = pluck; - function plucker(props, length) { - var mapper = function (x) { - var currentProp = x; - for (var i = 0; i < length; i++) { - var p = currentProp[props[i]]; - if (typeof p !== 'undefined') { - currentProp = p; - } - else { - return undefined; - } - } - return currentProp; - }; - return mapper; - } - //# sourceMappingURL=pluck.js.map +var Observable_1 = __webpack_require__(0); +var mergeScan_1 = __webpack_require__(302); +Observable_1.Observable.prototype.mergeScan = mergeScan_1.mergeScan; +//# sourceMappingURL=mergeScan.js.map -/***/ }, +/***/ }), +/* 302 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var subscribeToResult_1 = __webpack_require__(3); +var OuterSubscriber_1 = __webpack_require__(2); +/** + * Applies an accumulator function over the source Observable where the + * accumulator function itself returns an Observable, then each intermediate + * Observable returned is merged into the output Observable. + * + * It's like {@link scan}, but the Observables returned + * by the accumulator are merged into the outer Observable. + * + * @example Count the number of click events + * const click$ = Rx.Observable.fromEvent(document, 'click'); + * const one$ = click$.mapTo(1); + * const seed = 0; + * const count$ = one$.mergeScan((acc, one) => Rx.Observable.of(acc + one), seed); + * count$.subscribe(x => console.log(x)); + * + * // Results: + * 1 + * 2 + * 3 + * 4 + * // ...and so on for each click + * + * @param {function(acc: R, value: T): Observable} accumulator + * The accumulator function called on each source value. + * @param seed The initial accumulation value. + * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of + * input Observables being subscribed to concurrently. + * @return {Observable} An observable of the accumulated values. + * @method mergeScan + * @owner Observable + */ +function mergeScan(accumulator, seed, concurrent) { + if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; } + return this.lift(new MergeScanOperator(accumulator, seed, concurrent)); +} +exports.mergeScan = mergeScan; +var MergeScanOperator = (function () { + function MergeScanOperator(accumulator, seed, concurrent) { + this.accumulator = accumulator; + this.seed = seed; + this.concurrent = concurrent; + } + MergeScanOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent)); + }; + return MergeScanOperator; +}()); +exports.MergeScanOperator = MergeScanOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var MergeScanSubscriber = (function (_super) { + __extends(MergeScanSubscriber, _super); + function MergeScanSubscriber(destination, accumulator, acc, concurrent) { + _super.call(this, destination); + this.accumulator = accumulator; + this.acc = acc; + this.concurrent = concurrent; + this.hasValue = false; + this.hasCompleted = false; + this.buffer = []; + this.active = 0; + this.index = 0; + } + MergeScanSubscriber.prototype._next = function (value) { + if (this.active < this.concurrent) { + var index = this.index++; + var ish = tryCatch_1.tryCatch(this.accumulator)(this.acc, value); + var destination = this.destination; + if (ish === errorObject_1.errorObject) { + destination.error(errorObject_1.errorObject.e); + } + else { + this.active++; + this._innerSub(ish, value, index); + } + } + else { + this.buffer.push(value); + } + }; + MergeScanSubscriber.prototype._innerSub = function (ish, value, index) { + this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index)); + }; + MergeScanSubscriber.prototype._complete = function () { + this.hasCompleted = true; + if (this.active === 0 && this.buffer.length === 0) { + if (this.hasValue === false) { + this.destination.next(this.acc); + } + this.destination.complete(); + } + }; + MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + var destination = this.destination; + this.acc = innerValue; + this.hasValue = true; + destination.next(innerValue); + }; + MergeScanSubscriber.prototype.notifyComplete = function (innerSub) { + var buffer = this.buffer; + this.remove(innerSub); + this.active--; + if (buffer.length > 0) { + this._next(buffer.shift()); + } + else if (this.active === 0 && this.hasCompleted) { + if (this.hasValue === false) { + this.destination.next(this.acc); + } + this.destination.complete(); + } + }; + return MergeScanSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +exports.MergeScanSubscriber = MergeScanSubscriber; +//# sourceMappingURL=mergeScan.js.map + +/***/ }), /* 303 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var publish_1 = __webpack_require__(304); - Observable_1.Observable.prototype.publish = publish_1.publish; - //# sourceMappingURL=publish.js.map +"use strict"; -/***/ }, -/* 304 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Subject_1 = __webpack_require__(63); - var multicast_1 = __webpack_require__(292); - /* tslint:enable:max-line-length */ - /** - * Returns a ConnectableObservable, which is a variety of Observable that waits until its connect method is called - * before it begins emitting items to those Observers that have subscribed to it. - * - * - * - * @param {Function} [selector] - Optional selector function which can use the multicasted source sequence as many times - * as needed, without causing multiple subscriptions to the source sequence. - * Subscribers to the given source will receive all notifications of the source from the time of the subscription on. - * @return A ConnectableObservable that upon connection causes the source Observable to emit items to its Observers. - * @method publish - * @owner Observable - */ - function publish(selector) { - return selector ? multicast_1.multicast.call(this, function () { return new Subject_1.Subject(); }, selector) : - multicast_1.multicast.call(this, new Subject_1.Subject()); - } - exports.publish = publish; - //# sourceMappingURL=publish.js.map +var Observable_1 = __webpack_require__(0); +var min_1 = __webpack_require__(304); +Observable_1.Observable.prototype.min = min_1.min; +//# sourceMappingURL=min.js.map -/***/ }, +/***/ }), +/* 304 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var reduce_1 = __webpack_require__(49); +/** + * The Min operator operates on an Observable that emits numbers (or items that can be compared with a provided function), + * and when source Observable completes it emits a single item: the item with the smallest value. + * + * + * + * @example Get the minimal value of a series of numbers + * Rx.Observable.of(5, 4, 7, 2, 8) + * .min() + * .subscribe(x => console.log(x)); // -> 2 + * + * @example Use a comparer function to get the minimal item + * interface Person { + * age: number, + * name: string + * } + * Observable.of({age: 7, name: 'Foo'}, + * {age: 5, name: 'Bar'}, + * {age: 9, name: 'Beer'}) + * .min( (a: Person, b: Person) => a.age < b.age ? -1 : 1) + * .subscribe((x: Person) => console.log(x.name)); // -> 'Bar' + * } + * + * @see {@link max} + * + * @param {Function} [comparer] - Optional comparer function that it will use instead of its default to compare the + * value of two items. + * @return {Observable} An Observable that emits item with the smallest value. + * @method min + * @owner Observable + */ +function min(comparer) { + var min = (typeof comparer === 'function') + ? function (x, y) { return comparer(x, y) < 0 ? x : y; } + : function (x, y) { return x < y ? x : y; }; + return this.lift(new reduce_1.ReduceOperator(min)); +} +exports.min = min; +//# sourceMappingURL=min.js.map + +/***/ }), /* 305 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var publishBehavior_1 = __webpack_require__(306); - Observable_1.Observable.prototype.publishBehavior = publishBehavior_1.publishBehavior; - //# sourceMappingURL=publishBehavior.js.map +var Observable_1 = __webpack_require__(0); +var multicast_1 = __webpack_require__(17); +Observable_1.Observable.prototype.multicast = multicast_1.multicast; +//# sourceMappingURL=multicast.js.map -/***/ }, +/***/ }), /* 306 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var BehaviorSubject_1 = __webpack_require__(307); - var multicast_1 = __webpack_require__(292); - /** - * @param value - * @return {ConnectableObservable} - * @method publishBehavior - * @owner Observable - */ - function publishBehavior(value) { - return multicast_1.multicast.call(this, new BehaviorSubject_1.BehaviorSubject(value)); - } - exports.publishBehavior = publishBehavior; - //# sourceMappingURL=publishBehavior.js.map +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var observeOn_1 = __webpack_require__(46); +Observable_1.Observable.prototype.observeOn = observeOn_1.observeOn; +//# sourceMappingURL=observeOn.js.map + +/***/ }), /* 307 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subject_1 = __webpack_require__(63); - var ObjectUnsubscribedError_1 = __webpack_require__(78); - /** - * @class BehaviorSubject - */ - var BehaviorSubject = (function (_super) { - __extends(BehaviorSubject, _super); - function BehaviorSubject(_value) { - _super.call(this); - this._value = _value; - } - Object.defineProperty(BehaviorSubject.prototype, "value", { - get: function () { - return this.getValue(); - }, - enumerable: true, - configurable: true - }); - BehaviorSubject.prototype._subscribe = function (subscriber) { - var subscription = _super.prototype._subscribe.call(this, subscriber); - if (subscription && !subscription.closed) { - subscriber.next(this._value); - } - return subscription; - }; - BehaviorSubject.prototype.getValue = function () { - if (this.hasError) { - throw this.thrownError; - } - else if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); - } - else { - return this._value; - } - }; - BehaviorSubject.prototype.next = function (value) { - _super.prototype.next.call(this, this._value = value); - }; - return BehaviorSubject; - }(Subject_1.Subject)); - exports.BehaviorSubject = BehaviorSubject; - //# sourceMappingURL=BehaviorSubject.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var onErrorResumeNext_1 = __webpack_require__(70); +Observable_1.Observable.prototype.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext; +//# sourceMappingURL=onErrorResumeNext.js.map + +/***/ }), /* 308 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var publishReplay_1 = __webpack_require__(309); - Observable_1.Observable.prototype.publishReplay = publishReplay_1.publishReplay; - //# sourceMappingURL=publishReplay.js.map +"use strict"; -/***/ }, -/* 309 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var ReplaySubject_1 = __webpack_require__(184); - var multicast_1 = __webpack_require__(292); - /** - * @param bufferSize - * @param windowTime - * @param scheduler - * @return {ConnectableObservable} - * @method publishReplay - * @owner Observable - */ - function publishReplay(bufferSize, windowTime, scheduler) { - if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; } - if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; } - return multicast_1.multicast.call(this, new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler)); - } - exports.publishReplay = publishReplay; - //# sourceMappingURL=publishReplay.js.map +var Observable_1 = __webpack_require__(0); +var pairwise_1 = __webpack_require__(309); +Observable_1.Observable.prototype.pairwise = pairwise_1.pairwise; +//# sourceMappingURL=pairwise.js.map -/***/ }, +/***/ }), +/* 309 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Groups pairs of consecutive emissions together and emits them as an array of + * two values. + * + * Puts the current value and previous value together as + * an array, and emits that. + * + * + * + * The Nth emission from the source Observable will cause the output Observable + * to emit an array [(N-1)th, Nth] of the previous and the current value, as a + * pair. For this reason, `pairwise` emits on the second and subsequent + * emissions from the source Observable, but not on the first emission, because + * there is no previous value in that case. + * + * @example On every click (starting from the second), emit the relative distance to the previous click + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var pairs = clicks.pairwise(); + * var distance = pairs.map(pair => { + * var x0 = pair[0].clientX; + * var y0 = pair[0].clientY; + * var x1 = pair[1].clientX; + * var y1 = pair[1].clientY; + * return Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2)); + * }); + * distance.subscribe(x => console.log(x)); + * + * @see {@link buffer} + * @see {@link bufferCount} + * + * @return {Observable>} An Observable of pairs (as arrays) of + * consecutive values from the source Observable. + * @method pairwise + * @owner Observable + */ +function pairwise() { + return this.lift(new PairwiseOperator()); +} +exports.pairwise = pairwise; +var PairwiseOperator = (function () { + function PairwiseOperator() { + } + PairwiseOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new PairwiseSubscriber(subscriber)); + }; + return PairwiseOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var PairwiseSubscriber = (function (_super) { + __extends(PairwiseSubscriber, _super); + function PairwiseSubscriber(destination) { + _super.call(this, destination); + this.hasPrev = false; + } + PairwiseSubscriber.prototype._next = function (value) { + if (this.hasPrev) { + this.destination.next([this.prev, value]); + } + else { + this.hasPrev = true; + } + this.prev = value; + }; + return PairwiseSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=pairwise.js.map + +/***/ }), /* 310 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var publishLast_1 = __webpack_require__(311); - Observable_1.Observable.prototype.publishLast = publishLast_1.publishLast; - //# sourceMappingURL=publishLast.js.map +"use strict"; -/***/ }, -/* 311 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var AsyncSubject_1 = __webpack_require__(83); - var multicast_1 = __webpack_require__(292); - /** - * @return {ConnectableObservable} - * @method publishLast - * @owner Observable - */ - function publishLast() { - return multicast_1.multicast.call(this, new AsyncSubject_1.AsyncSubject()); - } - exports.publishLast = publishLast; - //# sourceMappingURL=publishLast.js.map +var Observable_1 = __webpack_require__(0); +var partition_1 = __webpack_require__(311); +Observable_1.Observable.prototype.partition = partition_1.partition; +//# sourceMappingURL=partition.js.map -/***/ }, +/***/ }), +/* 311 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var not_1 = __webpack_require__(312); +var filter_1 = __webpack_require__(76); +/** + * Splits the source Observable into two, one with values that satisfy a + * predicate, and another with values that don't satisfy the predicate. + * + * It's like {@link filter}, but returns two Observables: + * one like the output of {@link filter}, and the other with values that did not + * pass the condition. + * + * + * + * `partition` outputs an array with two Observables that partition the values + * from the source Observable through the given `predicate` function. The first + * Observable in that array emits source values for which the predicate argument + * returns true. The second Observable emits source values for which the + * predicate returns false. The first behaves like {@link filter} and the second + * behaves like {@link filter} with the predicate negated. + * + * @example Partition click events into those on DIV elements and those elsewhere + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var parts = clicks.partition(ev => ev.target.tagName === 'DIV'); + * var clicksOnDivs = parts[0]; + * var clicksElsewhere = parts[1]; + * clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x)); + * clicksElsewhere.subscribe(x => console.log('Other clicked: ', x)); + * + * @see {@link filter} + * + * @param {function(value: T, index: number): boolean} predicate A function that + * evaluates each value emitted by the source Observable. If it returns `true`, + * the value is emitted on the first Observable in the returned array, if + * `false` the value is emitted on the second Observable in the array. The + * `index` parameter is the number `i` for the i-th source emission that has + * happened since the subscription, starting from the number `0`. + * @param {any} [thisArg] An optional argument to determine the value of `this` + * in the `predicate` function. + * @return {[Observable, Observable]} An array with two Observables: one + * with values that passed the predicate, and another with values that did not + * pass the predicate. + * @method partition + * @owner Observable + */ +function partition(predicate, thisArg) { + return [ + filter_1.filter.call(this, predicate, thisArg), + filter_1.filter.call(this, not_1.not(predicate, thisArg)) + ]; +} +exports.partition = partition; +//# sourceMappingURL=partition.js.map + +/***/ }), /* 312 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var Observable_1 = __webpack_require__(64); - var race_1 = __webpack_require__(148); - Observable_1.Observable.prototype.race = race_1.race; - //# sourceMappingURL=race.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +function not(pred, thisArg) { + function notPred() { + return !(notPred.pred.apply(notPred.thisArg, arguments)); + } + notPred.pred = pred; + notPred.thisArg = thisArg; + return notPred; +} +exports.not = not; +//# sourceMappingURL=not.js.map + +/***/ }), /* 313 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var reduce_1 = __webpack_require__(282); - Observable_1.Observable.prototype.reduce = reduce_1.reduce; - //# sourceMappingURL=reduce.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var pluck_1 = __webpack_require__(314); +Observable_1.Observable.prototype.pluck = pluck_1.pluck; +//# sourceMappingURL=pluck.js.map + +/***/ }), /* 314 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var map_1 = __webpack_require__(48); +/** + * Maps each source value (an object) to its specified nested property. + * + * Like {@link map}, but meant only for picking one of + * the nested properties of every emitted object. + * + * + * + * Given a list of strings describing a path to an object property, retrieves + * the value of a specified nested property from all values in the source + * Observable. If a property can't be resolved, it will return `undefined` for + * that value. + * + * @example Map every click to the tagName of the clicked target element + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var tagNames = clicks.pluck('target', 'tagName'); + * tagNames.subscribe(x => console.log(x)); + * + * @see {@link map} + * + * @param {...string} properties The nested properties to pluck from each source + * value (an object). + * @return {Observable} A new Observable of property values from the source values. + * @method pluck + * @owner Observable + */ +function pluck() { + var properties = []; + for (var _i = 0; _i < arguments.length; _i++) { + properties[_i - 0] = arguments[_i]; + } + var length = properties.length; + if (length === 0) { + throw new Error('list of properties cannot be empty.'); + } + return map_1.map.call(this, plucker(properties, length)); +} +exports.pluck = pluck; +function plucker(props, length) { + var mapper = function (x) { + var currentProp = x; + for (var i = 0; i < length; i++) { + var p = currentProp[props[i]]; + if (typeof p !== 'undefined') { + currentProp = p; + } + else { + return undefined; + } + } + return currentProp; + }; + return mapper; +} +//# sourceMappingURL=pluck.js.map + +/***/ }), +/* 315 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var repeat_1 = __webpack_require__(315); - Observable_1.Observable.prototype.repeat = repeat_1.repeat; - //# sourceMappingURL=repeat.js.map +"use strict"; -/***/ }, -/* 315 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var EmptyObservable_1 = __webpack_require__(92); - /** - * Returns an Observable that repeats the stream of items emitted by the source Observable at most count times. - * - * - * - * @param {number} [count] The number of times the source Observable items are repeated, a count of 0 will yield - * an empty Observable. - * @return {Observable} An Observable that repeats the stream of items emitted by the source Observable at most - * count times. - * @method repeat - * @owner Observable - */ - function repeat(count) { - if (count === void 0) { count = -1; } - if (count === 0) { - return new EmptyObservable_1.EmptyObservable(); - } - else if (count < 0) { - return this.lift(new RepeatOperator(-1, this)); - } - else { - return this.lift(new RepeatOperator(count - 1, this)); - } - } - exports.repeat = repeat; - var RepeatOperator = (function () { - function RepeatOperator(count, source) { - this.count = count; - this.source = source; - } - RepeatOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source)); - }; - return RepeatOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var RepeatSubscriber = (function (_super) { - __extends(RepeatSubscriber, _super); - function RepeatSubscriber(destination, count, source) { - _super.call(this, destination); - this.count = count; - this.source = source; - } - RepeatSubscriber.prototype.complete = function () { - if (!this.isStopped) { - var _a = this, source = _a.source, count = _a.count; - if (count === 0) { - return _super.prototype.complete.call(this); - } - else if (count > -1) { - this.count = count - 1; - } - source.subscribe(this._unsubscribeAndRecycle()); - } - }; - return RepeatSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=repeat.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var publish_1 = __webpack_require__(316); +Observable_1.Observable.prototype.publish = publish_1.publish; +//# sourceMappingURL=publish.js.map + +/***/ }), /* 316 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Subject_1 = __webpack_require__(5); +var multicast_1 = __webpack_require__(17); +/* tslint:enable:max-line-length */ +/** + * Returns a ConnectableObservable, which is a variety of Observable that waits until its connect method is called + * before it begins emitting items to those Observers that have subscribed to it. + * + * + * + * @param {Function} [selector] - Optional selector function which can use the multicasted source sequence as many times + * as needed, without causing multiple subscriptions to the source sequence. + * Subscribers to the given source will receive all notifications of the source from the time of the subscription on. + * @return A ConnectableObservable that upon connection causes the source Observable to emit items to its Observers. + * @method publish + * @owner Observable + */ +function publish(selector) { + return selector ? multicast_1.multicast.call(this, function () { return new Subject_1.Subject(); }, selector) : + multicast_1.multicast.call(this, new Subject_1.Subject()); +} +exports.publish = publish; +//# sourceMappingURL=publish.js.map + +/***/ }), +/* 317 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var repeatWhen_1 = __webpack_require__(317); - Observable_1.Observable.prototype.repeatWhen = repeatWhen_1.repeatWhen; - //# sourceMappingURL=repeatWhen.js.map +"use strict"; -/***/ }, -/* 317 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subject_1 = __webpack_require__(63); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Returns an Observable that mirrors the source Observable with the exception of a `complete`. If the source - * Observable calls `complete`, this method will emit to the Observable returned from `notifier`. If that Observable - * calls `complete` or `error`, then this method will call `complete` or `error` on the child subscription. Otherwise - * this method will resubscribe to the source Observable. - * - * - * - * @param {function(notifications: Observable): Observable} notifier - Receives an Observable of notifications with - * which a user can `complete` or `error`, aborting the repetition. - * @return {Observable} The source Observable modified with repeat logic. - * @method repeatWhen - * @owner Observable - */ - function repeatWhen(notifier) { - return this.lift(new RepeatWhenOperator(notifier)); - } - exports.repeatWhen = repeatWhen; - var RepeatWhenOperator = (function () { - function RepeatWhenOperator(notifier) { - this.notifier = notifier; - } - RepeatWhenOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source)); - }; - return RepeatWhenOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var RepeatWhenSubscriber = (function (_super) { - __extends(RepeatWhenSubscriber, _super); - function RepeatWhenSubscriber(destination, notifier, source) { - _super.call(this, destination); - this.notifier = notifier; - this.source = source; - this.sourceIsBeingSubscribedTo = true; - } - RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.sourceIsBeingSubscribedTo = true; - this.source.subscribe(this); - }; - RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) { - if (this.sourceIsBeingSubscribedTo === false) { - return _super.prototype.complete.call(this); - } - }; - RepeatWhenSubscriber.prototype.complete = function () { - this.sourceIsBeingSubscribedTo = false; - if (!this.isStopped) { - if (!this.retries) { - this.subscribeToRetries(); - } - else if (this.retriesSubscription.closed) { - return _super.prototype.complete.call(this); - } - this._unsubscribeAndRecycle(); - this.notifications.next(); - } - }; - RepeatWhenSubscriber.prototype._unsubscribe = function () { - var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription; - if (notifications) { - notifications.unsubscribe(); - this.notifications = null; - } - if (retriesSubscription) { - retriesSubscription.unsubscribe(); - this.retriesSubscription = null; - } - this.retries = null; - }; - RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () { - var _a = this, notifications = _a.notifications, retries = _a.retries, retriesSubscription = _a.retriesSubscription; - this.notifications = null; - this.retries = null; - this.retriesSubscription = null; - _super.prototype._unsubscribeAndRecycle.call(this); - this.notifications = notifications; - this.retries = retries; - this.retriesSubscription = retriesSubscription; - return this; - }; - RepeatWhenSubscriber.prototype.subscribeToRetries = function () { - this.notifications = new Subject_1.Subject(); - var retries = tryCatch_1.tryCatch(this.notifier)(this.notifications); - if (retries === errorObject_1.errorObject) { - return _super.prototype.complete.call(this); - } - this.retries = retries; - this.retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries); - }; - return RepeatWhenSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=repeatWhen.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var publishBehavior_1 = __webpack_require__(318); +Observable_1.Observable.prototype.publishBehavior = publishBehavior_1.publishBehavior; +//# sourceMappingURL=publishBehavior.js.map + +/***/ }), /* 318 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var BehaviorSubject_1 = __webpack_require__(79); +var multicast_1 = __webpack_require__(17); +/** + * @param value + * @return {ConnectableObservable} + * @method publishBehavior + * @owner Observable + */ +function publishBehavior(value) { + return multicast_1.multicast.call(this, new BehaviorSubject_1.BehaviorSubject(value)); +} +exports.publishBehavior = publishBehavior; +//# sourceMappingURL=publishBehavior.js.map + +/***/ }), +/* 319 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var retry_1 = __webpack_require__(319); - Observable_1.Observable.prototype.retry = retry_1.retry; - //# sourceMappingURL=retry.js.map +"use strict"; -/***/ }, -/* 319 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable - * calls `error`, this method will resubscribe to the source Observable for a maximum of `count` resubscriptions (given - * as a number parameter) rather than propagating the `error` call. - * - * - * - * Any and all items emitted by the source Observable will be emitted by the resulting Observable, even those emitted - * during failed subscriptions. For example, if an Observable fails at first but emits [1, 2] then succeeds the second - * time and emits: [1, 2, 3, 4, 5] then the complete stream of emissions and notifications - * would be: [1, 2, 1, 2, 3, 4, 5, `complete`]. - * @param {number} count - Number of retry attempts before failing. - * @return {Observable} The source Observable modified with the retry logic. - * @method retry - * @owner Observable - */ - function retry(count) { - if (count === void 0) { count = -1; } - return this.lift(new RetryOperator(count, this)); - } - exports.retry = retry; - var RetryOperator = (function () { - function RetryOperator(count, source) { - this.count = count; - this.source = source; - } - RetryOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source)); - }; - return RetryOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var RetrySubscriber = (function (_super) { - __extends(RetrySubscriber, _super); - function RetrySubscriber(destination, count, source) { - _super.call(this, destination); - this.count = count; - this.source = source; - } - RetrySubscriber.prototype.error = function (err) { - if (!this.isStopped) { - var _a = this, source = _a.source, count = _a.count; - if (count === 0) { - return _super.prototype.error.call(this, err); - } - else if (count > -1) { - this.count = count - 1; - } - source.subscribe(this._unsubscribeAndRecycle()); - } - }; - return RetrySubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=retry.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var publishReplay_1 = __webpack_require__(320); +Observable_1.Observable.prototype.publishReplay = publishReplay_1.publishReplay; +//# sourceMappingURL=publishReplay.js.map + +/***/ }), /* 320 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var ReplaySubject_1 = __webpack_require__(36); +var multicast_1 = __webpack_require__(17); +/** + * @param bufferSize + * @param windowTime + * @param scheduler + * @return {ConnectableObservable} + * @method publishReplay + * @owner Observable + */ +function publishReplay(bufferSize, windowTime, scheduler) { + if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; } + if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; } + return multicast_1.multicast.call(this, new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler)); +} +exports.publishReplay = publishReplay; +//# sourceMappingURL=publishReplay.js.map + +/***/ }), +/* 321 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var retryWhen_1 = __webpack_require__(321); - Observable_1.Observable.prototype.retryWhen = retryWhen_1.retryWhen; - //# sourceMappingURL=retryWhen.js.map +"use strict"; -/***/ }, -/* 321 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subject_1 = __webpack_require__(63); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - var OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable - * calls `error`, this method will emit the Throwable that caused the error to the Observable returned from `notifier`. - * If that Observable calls `complete` or `error` then this method will call `complete` or `error` on the child - * subscription. Otherwise this method will resubscribe to the source Observable. - * - * - * - * @param {function(errors: Observable): Observable} notifier - Receives an Observable of notifications with which a - * user can `complete` or `error`, aborting the retry. - * @return {Observable} The source Observable modified with retry logic. - * @method retryWhen - * @owner Observable - */ - function retryWhen(notifier) { - return this.lift(new RetryWhenOperator(notifier, this)); - } - exports.retryWhen = retryWhen; - var RetryWhenOperator = (function () { - function RetryWhenOperator(notifier, source) { - this.notifier = notifier; - this.source = source; - } - RetryWhenOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source)); - }; - return RetryWhenOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var RetryWhenSubscriber = (function (_super) { - __extends(RetryWhenSubscriber, _super); - function RetryWhenSubscriber(destination, notifier, source) { - _super.call(this, destination); - this.notifier = notifier; - this.source = source; - } - RetryWhenSubscriber.prototype.error = function (err) { - if (!this.isStopped) { - var errors = this.errors; - var retries = this.retries; - var retriesSubscription = this.retriesSubscription; - if (!retries) { - errors = new Subject_1.Subject(); - retries = tryCatch_1.tryCatch(this.notifier)(errors); - if (retries === errorObject_1.errorObject) { - return _super.prototype.error.call(this, errorObject_1.errorObject.e); - } - retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries); - } - else { - this.errors = null; - this.retriesSubscription = null; - } - this._unsubscribeAndRecycle(); - this.errors = errors; - this.retries = retries; - this.retriesSubscription = retriesSubscription; - errors.next(err); - } - }; - RetryWhenSubscriber.prototype._unsubscribe = function () { - var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription; - if (errors) { - errors.unsubscribe(); - this.errors = null; - } - if (retriesSubscription) { - retriesSubscription.unsubscribe(); - this.retriesSubscription = null; - } - this.retries = null; - }; - RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var _a = this, errors = _a.errors, retries = _a.retries, retriesSubscription = _a.retriesSubscription; - this.errors = null; - this.retries = null; - this.retriesSubscription = null; - this._unsubscribeAndRecycle(); - this.errors = errors; - this.retries = retries; - this.retriesSubscription = retriesSubscription; - this.source.subscribe(this); - }; - return RetryWhenSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=retryWhen.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var publishLast_1 = __webpack_require__(322); +Observable_1.Observable.prototype.publishLast = publishLast_1.publishLast; +//# sourceMappingURL=publishLast.js.map + +/***/ }), /* 322 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var AsyncSubject_1 = __webpack_require__(32); +var multicast_1 = __webpack_require__(17); +/** + * @return {ConnectableObservable} + * @method publishLast + * @owner Observable + */ +function publishLast() { + return multicast_1.multicast.call(this, new AsyncSubject_1.AsyncSubject()); +} +exports.publishLast = publishLast; +//# sourceMappingURL=publishLast.js.map + +/***/ }), +/* 323 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var sample_1 = __webpack_require__(323); - Observable_1.Observable.prototype.sample = sample_1.sample; - //# sourceMappingURL=sample.js.map +"use strict"; -/***/ }, -/* 323 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Emits the most recently emitted value from the source Observable whenever - * another Observable, the `notifier`, emits. - * - * It's like {@link sampleTime}, but samples whenever - * the `notifier` Observable emits something. - * - * - * - * Whenever the `notifier` Observable emits a value or completes, `sample` - * looks at the source Observable and emits whichever value it has most recently - * emitted since the previous sampling, unless the source has not emitted - * anything since the previous sampling. The `notifier` is subscribed to as soon - * as the output Observable is subscribed. - * - * @example On every click, sample the most recent "seconds" timer - * var seconds = Rx.Observable.interval(1000); - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = seconds.sample(clicks); - * result.subscribe(x => console.log(x)); - * - * @see {@link audit} - * @see {@link debounce} - * @see {@link sampleTime} - * @see {@link throttle} - * - * @param {Observable} notifier The Observable to use for sampling the - * source Observable. - * @return {Observable} An Observable that emits the results of sampling the - * values emitted by the source Observable whenever the notifier Observable - * emits value or completes. - * @method sample - * @owner Observable - */ - function sample(notifier) { - return this.lift(new SampleOperator(notifier)); - } - exports.sample = sample; - var SampleOperator = (function () { - function SampleOperator(notifier) { - this.notifier = notifier; - } - SampleOperator.prototype.call = function (subscriber, source) { - var sampleSubscriber = new SampleSubscriber(subscriber); - var subscription = source.subscribe(sampleSubscriber); - subscription.add(subscribeToResult_1.subscribeToResult(sampleSubscriber, this.notifier)); - return subscription; - }; - return SampleOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SampleSubscriber = (function (_super) { - __extends(SampleSubscriber, _super); - function SampleSubscriber() { - _super.apply(this, arguments); - this.hasValue = false; - } - SampleSubscriber.prototype._next = function (value) { - this.value = value; - this.hasValue = true; - }; - SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.emitValue(); - }; - SampleSubscriber.prototype.notifyComplete = function () { - this.emitValue(); - }; - SampleSubscriber.prototype.emitValue = function () { - if (this.hasValue) { - this.hasValue = false; - this.destination.next(this.value); - } - }; - return SampleSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=sample.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var race_1 = __webpack_require__(68); +Observable_1.Observable.prototype.race = race_1.race; +//# sourceMappingURL=race.js.map + +/***/ }), /* 324 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var sampleTime_1 = __webpack_require__(325); - Observable_1.Observable.prototype.sampleTime = sampleTime_1.sampleTime; - //# sourceMappingURL=sampleTime.js.map +var Observable_1 = __webpack_require__(0); +var reduce_1 = __webpack_require__(49); +Observable_1.Observable.prototype.reduce = reduce_1.reduce; +//# sourceMappingURL=reduce.js.map -/***/ }, +/***/ }), /* 325 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var async_1 = __webpack_require__(138); - /** - * Emits the most recently emitted value from the source Observable within - * periodic time intervals. - * - * Samples the source Observable at periodic time - * intervals, emitting what it samples. - * - * - * - * `sampleTime` periodically looks at the source Observable and emits whichever - * value it has most recently emitted since the previous sampling, unless the - * source has not emitted anything since the previous sampling. The sampling - * happens periodically in time every `period` milliseconds (or the time unit - * defined by the optional `scheduler` argument). The sampling starts as soon as - * the output Observable is subscribed. - * - * @example Every second, emit the most recent click at most once - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var result = clicks.sampleTime(1000); - * result.subscribe(x => console.log(x)); - * - * @see {@link auditTime} - * @see {@link debounceTime} - * @see {@link delay} - * @see {@link sample} - * @see {@link throttleTime} - * - * @param {number} period The sampling period expressed in milliseconds or the - * time unit determined internally by the optional `scheduler`. - * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for - * managing the timers that handle the sampling. - * @return {Observable} An Observable that emits the results of sampling the - * values emitted by the source Observable at the specified time interval. - * @method sampleTime - * @owner Observable - */ - function sampleTime(period, scheduler) { - if (scheduler === void 0) { scheduler = async_1.async; } - return this.lift(new SampleTimeOperator(period, scheduler)); - } - exports.sampleTime = sampleTime; - var SampleTimeOperator = (function () { - function SampleTimeOperator(period, scheduler) { - this.period = period; - this.scheduler = scheduler; - } - SampleTimeOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler)); - }; - return SampleTimeOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SampleTimeSubscriber = (function (_super) { - __extends(SampleTimeSubscriber, _super); - function SampleTimeSubscriber(destination, period, scheduler) { - _super.call(this, destination); - this.period = period; - this.scheduler = scheduler; - this.hasValue = false; - this.add(scheduler.schedule(dispatchNotification, period, { subscriber: this, period: period })); - } - SampleTimeSubscriber.prototype._next = function (value) { - this.lastValue = value; - this.hasValue = true; - }; - SampleTimeSubscriber.prototype.notifyNext = function () { - if (this.hasValue) { - this.hasValue = false; - this.destination.next(this.lastValue); - } - }; - return SampleTimeSubscriber; - }(Subscriber_1.Subscriber)); - function dispatchNotification(state) { - var subscriber = state.subscriber, period = state.period; - subscriber.notifyNext(); - this.schedule(state, period); - } - //# sourceMappingURL=sampleTime.js.map +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 326 */ -/***/ function(module, exports, __webpack_require__) { +"use strict"; - "use strict"; - var Observable_1 = __webpack_require__(64); - var scan_1 = __webpack_require__(327); - Observable_1.Observable.prototype.scan = scan_1.scan; - //# sourceMappingURL=scan.js.map +var Observable_1 = __webpack_require__(0); +var repeat_1 = __webpack_require__(326); +Observable_1.Observable.prototype.repeat = repeat_1.repeat; +//# sourceMappingURL=repeat.js.map -/***/ }, +/***/ }), +/* 326 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var EmptyObservable_1 = __webpack_require__(16); +/** + * Returns an Observable that repeats the stream of items emitted by the source Observable at most count times. + * + * + * + * @param {number} [count] The number of times the source Observable items are repeated, a count of 0 will yield + * an empty Observable. + * @return {Observable} An Observable that repeats the stream of items emitted by the source Observable at most + * count times. + * @method repeat + * @owner Observable + */ +function repeat(count) { + if (count === void 0) { count = -1; } + if (count === 0) { + return new EmptyObservable_1.EmptyObservable(); + } + else if (count < 0) { + return this.lift(new RepeatOperator(-1, this)); + } + else { + return this.lift(new RepeatOperator(count - 1, this)); + } +} +exports.repeat = repeat; +var RepeatOperator = (function () { + function RepeatOperator(count, source) { + this.count = count; + this.source = source; + } + RepeatOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source)); + }; + return RepeatOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var RepeatSubscriber = (function (_super) { + __extends(RepeatSubscriber, _super); + function RepeatSubscriber(destination, count, source) { + _super.call(this, destination); + this.count = count; + this.source = source; + } + RepeatSubscriber.prototype.complete = function () { + if (!this.isStopped) { + var _a = this, source = _a.source, count = _a.count; + if (count === 0) { + return _super.prototype.complete.call(this); + } + else if (count > -1) { + this.count = count - 1; + } + source.subscribe(this._unsubscribeAndRecycle()); + } + }; + return RepeatSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=repeat.js.map + +/***/ }), /* 327 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /* tslint:enable:max-line-length */ - /** - * Applies an accumulator function over the source Observable, and returns each - * intermediate result, with an optional seed value. - * - * It's like {@link reduce}, but emits the current - * accumulation whenever the source emits a value. - * - * - * - * Combines together all values emitted on the source, using an accumulator - * function that knows how to join a new source value into the accumulation from - * the past. Is similar to {@link reduce}, but emits the intermediate - * accumulations. - * - * Returns an Observable that applies a specified `accumulator` function to each - * item emitted by the source Observable. If a `seed` value is specified, then - * that value will be used as the initial value for the accumulator. If no seed - * value is specified, the first item of the source is used as the seed. - * - * @example Count the number of click events - * var clicks = Rx.Observable.fromEvent(document, 'click'); - * var ones = clicks.mapTo(1); - * var seed = 0; - * var count = ones.scan((acc, one) => acc + one, seed); - * count.subscribe(x => console.log(x)); - * - * @see {@link expand} - * @see {@link mergeScan} - * @see {@link reduce} - * - * @param {function(acc: R, value: T, index: number): R} accumulator - * The accumulator function called on each source value. - * @param {T|R} [seed] The initial accumulation value. - * @return {Observable} An observable of the accumulated values. - * @method scan - * @owner Observable - */ - function scan(accumulator, seed) { - var hasSeed = false; - // providing a seed of `undefined` *should* be valid and trigger - // hasSeed! so don't use `seed !== undefined` checks! - // For this reason, we have to check it here at the original call site - // otherwise inside Operator/Subscriber we won't know if `undefined` - // means they didn't provide anything or if they literally provided `undefined` - if (arguments.length >= 2) { - hasSeed = true; - } - return this.lift(new ScanOperator(accumulator, seed, hasSeed)); - } - exports.scan = scan; - var ScanOperator = (function () { - function ScanOperator(accumulator, seed, hasSeed) { - if (hasSeed === void 0) { hasSeed = false; } - this.accumulator = accumulator; - this.seed = seed; - this.hasSeed = hasSeed; - } - ScanOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed)); - }; - return ScanOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var ScanSubscriber = (function (_super) { - __extends(ScanSubscriber, _super); - function ScanSubscriber(destination, accumulator, _seed, hasSeed) { - _super.call(this, destination); - this.accumulator = accumulator; - this._seed = _seed; - this.hasSeed = hasSeed; - this.index = 0; - } - Object.defineProperty(ScanSubscriber.prototype, "seed", { - get: function () { - return this._seed; - }, - set: function (value) { - this.hasSeed = true; - this._seed = value; - }, - enumerable: true, - configurable: true - }); - ScanSubscriber.prototype._next = function (value) { - if (!this.hasSeed) { - this.seed = value; - this.destination.next(value); - } - else { - return this._tryNext(value); - } - }; - ScanSubscriber.prototype._tryNext = function (value) { - var index = this.index++; - var result; - try { - result = this.accumulator(this.seed, value, index); - } - catch (err) { - this.destination.error(err); - } - this.seed = result; - this.destination.next(result); - }; - return ScanSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=scan.js.map - -/***/ }, -/* 328 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var sequenceEqual_1 = __webpack_require__(329); - Observable_1.Observable.prototype.sequenceEqual = sequenceEqual_1.sequenceEqual; - //# sourceMappingURL=sequenceEqual.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var repeatWhen_1 = __webpack_require__(328); +Observable_1.Observable.prototype.repeatWhen = repeatWhen_1.repeatWhen; +//# sourceMappingURL=repeatWhen.js.map + +/***/ }), +/* 328 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subject_1 = __webpack_require__(5); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Returns an Observable that mirrors the source Observable with the exception of a `complete`. If the source + * Observable calls `complete`, this method will emit to the Observable returned from `notifier`. If that Observable + * calls `complete` or `error`, then this method will call `complete` or `error` on the child subscription. Otherwise + * this method will resubscribe to the source Observable. + * + * + * + * @param {function(notifications: Observable): Observable} notifier - Receives an Observable of notifications with + * which a user can `complete` or `error`, aborting the repetition. + * @return {Observable} The source Observable modified with repeat logic. + * @method repeatWhen + * @owner Observable + */ +function repeatWhen(notifier) { + return this.lift(new RepeatWhenOperator(notifier)); +} +exports.repeatWhen = repeatWhen; +var RepeatWhenOperator = (function () { + function RepeatWhenOperator(notifier) { + this.notifier = notifier; + } + RepeatWhenOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source)); + }; + return RepeatWhenOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var RepeatWhenSubscriber = (function (_super) { + __extends(RepeatWhenSubscriber, _super); + function RepeatWhenSubscriber(destination, notifier, source) { + _super.call(this, destination); + this.notifier = notifier; + this.source = source; + this.sourceIsBeingSubscribedTo = true; + } + RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.sourceIsBeingSubscribedTo = true; + this.source.subscribe(this); + }; + RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) { + if (this.sourceIsBeingSubscribedTo === false) { + return _super.prototype.complete.call(this); + } + }; + RepeatWhenSubscriber.prototype.complete = function () { + this.sourceIsBeingSubscribedTo = false; + if (!this.isStopped) { + if (!this.retries) { + this.subscribeToRetries(); + } + else if (this.retriesSubscription.closed) { + return _super.prototype.complete.call(this); + } + this._unsubscribeAndRecycle(); + this.notifications.next(); + } + }; + RepeatWhenSubscriber.prototype._unsubscribe = function () { + var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription; + if (notifications) { + notifications.unsubscribe(); + this.notifications = null; + } + if (retriesSubscription) { + retriesSubscription.unsubscribe(); + this.retriesSubscription = null; + } + this.retries = null; + }; + RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () { + var _a = this, notifications = _a.notifications, retries = _a.retries, retriesSubscription = _a.retriesSubscription; + this.notifications = null; + this.retries = null; + this.retriesSubscription = null; + _super.prototype._unsubscribeAndRecycle.call(this); + this.notifications = notifications; + this.retries = retries; + this.retriesSubscription = retriesSubscription; + return this; + }; + RepeatWhenSubscriber.prototype.subscribeToRetries = function () { + this.notifications = new Subject_1.Subject(); + var retries = tryCatch_1.tryCatch(this.notifier)(this.notifications); + if (retries === errorObject_1.errorObject) { + return _super.prototype.complete.call(this); + } + this.retries = retries; + this.retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries); + }; + return RepeatWhenSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=repeatWhen.js.map + +/***/ }), /* 329 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var tryCatch_1 = __webpack_require__(72); - var errorObject_1 = __webpack_require__(73); - /** - * Compares all values of two observables in sequence using an optional comparor function - * and returns an observable of a single boolean value representing whether or not the two sequences - * are equal. - * - * Checks to see of all values emitted by both observables are equal, in order. - * - * - * - * `sequenceEqual` subscribes to two observables and buffers incoming values from each observable. Whenever either - * observable emits a value, the value is buffered and the buffers are shifted and compared from the bottom - * up; If any value pair doesn't match, the returned observable will emit `false` and complete. If one of the - * observables completes, the operator will wait for the other observable to complete; If the other - * observable emits before completing, the returned observable will emit `false` and complete. If one observable never - * completes or emits after the other complets, the returned observable will never complete. - * - * @example figure out if the Konami code matches - * var code = Rx.Observable.from([ - * "ArrowUp", - * "ArrowUp", - * "ArrowDown", - * "ArrowDown", - * "ArrowLeft", - * "ArrowRight", - * "ArrowLeft", - * "ArrowRight", - * "KeyB", - * "KeyA", - * "Enter" // no start key, clearly. - * ]); - * - * var keys = Rx.Observable.fromEvent(document, 'keyup') - * .map(e => e.code); - * var matches = keys.bufferCount(11, 1) - * .mergeMap( - * last11 => - * Rx.Observable.from(last11) - * .sequenceEqual(code) - * ); - * matches.subscribe(matched => console.log('Successful cheat at Contra? ', matched)); - * - * @see {@link combineLatest} - * @see {@link zip} - * @see {@link withLatestFrom} - * - * @param {Observable} compareTo The observable sequence to compare the source sequence to. - * @param {function} [comparor] An optional function to compare each value pair - * @return {Observable} An Observable of a single boolean value representing whether or not - * the values emitted by both observables were equal in sequence. - * @method sequenceEqual - * @owner Observable - */ - function sequenceEqual(compareTo, comparor) { - return this.lift(new SequenceEqualOperator(compareTo, comparor)); - } - exports.sequenceEqual = sequenceEqual; - var SequenceEqualOperator = (function () { - function SequenceEqualOperator(compareTo, comparor) { - this.compareTo = compareTo; - this.comparor = comparor; - } - SequenceEqualOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor)); - }; - return SequenceEqualOperator; - }()); - exports.SequenceEqualOperator = SequenceEqualOperator; - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SequenceEqualSubscriber = (function (_super) { - __extends(SequenceEqualSubscriber, _super); - function SequenceEqualSubscriber(destination, compareTo, comparor) { - _super.call(this, destination); - this.compareTo = compareTo; - this.comparor = comparor; - this._a = []; - this._b = []; - this._oneComplete = false; - this.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, this))); - } - SequenceEqualSubscriber.prototype._next = function (value) { - if (this._oneComplete && this._b.length === 0) { - this.emit(false); - } - else { - this._a.push(value); - this.checkValues(); - } - }; - SequenceEqualSubscriber.prototype._complete = function () { - if (this._oneComplete) { - this.emit(this._a.length === 0 && this._b.length === 0); - } - else { - this._oneComplete = true; - } - }; - SequenceEqualSubscriber.prototype.checkValues = function () { - var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor; - while (_a.length > 0 && _b.length > 0) { - var a = _a.shift(); - var b = _b.shift(); - var areEqual = false; - if (comparor) { - areEqual = tryCatch_1.tryCatch(comparor)(a, b); - if (areEqual === errorObject_1.errorObject) { - this.destination.error(errorObject_1.errorObject.e); - } - } - else { - areEqual = a === b; - } - if (!areEqual) { - this.emit(false); - } - } - }; - SequenceEqualSubscriber.prototype.emit = function (value) { - var destination = this.destination; - destination.next(value); - destination.complete(); - }; - SequenceEqualSubscriber.prototype.nextB = function (value) { - if (this._oneComplete && this._a.length === 0) { - this.emit(false); - } - else { - this._b.push(value); - this.checkValues(); - } - }; - return SequenceEqualSubscriber; - }(Subscriber_1.Subscriber)); - exports.SequenceEqualSubscriber = SequenceEqualSubscriber; - var SequenceEqualCompareToSubscriber = (function (_super) { - __extends(SequenceEqualCompareToSubscriber, _super); - function SequenceEqualCompareToSubscriber(destination, parent) { - _super.call(this, destination); - this.parent = parent; - } - SequenceEqualCompareToSubscriber.prototype._next = function (value) { - this.parent.nextB(value); - }; - SequenceEqualCompareToSubscriber.prototype._error = function (err) { - this.parent.error(err); - }; - SequenceEqualCompareToSubscriber.prototype._complete = function () { - this.parent._complete(); - }; - return SequenceEqualCompareToSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=sequenceEqual.js.map - -/***/ }, -/* 330 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var share_1 = __webpack_require__(331); - Observable_1.Observable.prototype.share = share_1.share; - //# sourceMappingURL=share.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var retry_1 = __webpack_require__(330); +Observable_1.Observable.prototype.retry = retry_1.retry; +//# sourceMappingURL=retry.js.map + +/***/ }), +/* 330 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable + * calls `error`, this method will resubscribe to the source Observable for a maximum of `count` resubscriptions (given + * as a number parameter) rather than propagating the `error` call. + * + * + * + * Any and all items emitted by the source Observable will be emitted by the resulting Observable, even those emitted + * during failed subscriptions. For example, if an Observable fails at first but emits [1, 2] then succeeds the second + * time and emits: [1, 2, 3, 4, 5] then the complete stream of emissions and notifications + * would be: [1, 2, 1, 2, 3, 4, 5, `complete`]. + * @param {number} count - Number of retry attempts before failing. + * @return {Observable} The source Observable modified with the retry logic. + * @method retry + * @owner Observable + */ +function retry(count) { + if (count === void 0) { count = -1; } + return this.lift(new RetryOperator(count, this)); +} +exports.retry = retry; +var RetryOperator = (function () { + function RetryOperator(count, source) { + this.count = count; + this.source = source; + } + RetryOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source)); + }; + return RetryOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var RetrySubscriber = (function (_super) { + __extends(RetrySubscriber, _super); + function RetrySubscriber(destination, count, source) { + _super.call(this, destination); + this.count = count; + this.source = source; + } + RetrySubscriber.prototype.error = function (err) { + if (!this.isStopped) { + var _a = this, source = _a.source, count = _a.count; + if (count === 0) { + return _super.prototype.error.call(this, err); + } + else if (count > -1) { + this.count = count - 1; + } + source.subscribe(this._unsubscribeAndRecycle()); + } + }; + return RetrySubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=retry.js.map + +/***/ }), /* 331 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var multicast_1 = __webpack_require__(292); - var Subject_1 = __webpack_require__(63); - function shareSubjectFactory() { - return new Subject_1.Subject(); - } - /** - * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one - * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will - * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`. - * This is an alias for .publish().refCount(). - * - * - * - * @return {Observable} An Observable that upon connection causes the source Observable to emit items to its Observers. - * @method share - * @owner Observable - */ - function share() { - return multicast_1.multicast.call(this, shareSubjectFactory).refCount(); - } - exports.share = share; - ; - //# sourceMappingURL=share.js.map +"use strict"; -/***/ }, +var Observable_1 = __webpack_require__(0); +var retryWhen_1 = __webpack_require__(332); +Observable_1.Observable.prototype.retryWhen = retryWhen_1.retryWhen; +//# sourceMappingURL=retryWhen.js.map + +/***/ }), /* 332 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subject_1 = __webpack_require__(5); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +var OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable + * calls `error`, this method will emit the Throwable that caused the error to the Observable returned from `notifier`. + * If that Observable calls `complete` or `error` then this method will call `complete` or `error` on the child + * subscription. Otherwise this method will resubscribe to the source Observable. + * + * + * + * @param {function(errors: Observable): Observable} notifier - Receives an Observable of notifications with which a + * user can `complete` or `error`, aborting the retry. + * @return {Observable} The source Observable modified with retry logic. + * @method retryWhen + * @owner Observable + */ +function retryWhen(notifier) { + return this.lift(new RetryWhenOperator(notifier, this)); +} +exports.retryWhen = retryWhen; +var RetryWhenOperator = (function () { + function RetryWhenOperator(notifier, source) { + this.notifier = notifier; + this.source = source; + } + RetryWhenOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source)); + }; + return RetryWhenOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var RetryWhenSubscriber = (function (_super) { + __extends(RetryWhenSubscriber, _super); + function RetryWhenSubscriber(destination, notifier, source) { + _super.call(this, destination); + this.notifier = notifier; + this.source = source; + } + RetryWhenSubscriber.prototype.error = function (err) { + if (!this.isStopped) { + var errors = this.errors; + var retries = this.retries; + var retriesSubscription = this.retriesSubscription; + if (!retries) { + errors = new Subject_1.Subject(); + retries = tryCatch_1.tryCatch(this.notifier)(errors); + if (retries === errorObject_1.errorObject) { + return _super.prototype.error.call(this, errorObject_1.errorObject.e); + } + retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries); + } + else { + this.errors = null; + this.retriesSubscription = null; + } + this._unsubscribeAndRecycle(); + this.errors = errors; + this.retries = retries; + this.retriesSubscription = retriesSubscription; + errors.next(err); + } + }; + RetryWhenSubscriber.prototype._unsubscribe = function () { + var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription; + if (errors) { + errors.unsubscribe(); + this.errors = null; + } + if (retriesSubscription) { + retriesSubscription.unsubscribe(); + this.retriesSubscription = null; + } + this.retries = null; + }; + RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + var _a = this, errors = _a.errors, retries = _a.retries, retriesSubscription = _a.retriesSubscription; + this.errors = null; + this.retries = null; + this.retriesSubscription = null; + this._unsubscribeAndRecycle(); + this.errors = errors; + this.retries = retries; + this.retriesSubscription = retriesSubscription; + this.source.subscribe(this); + }; + return RetryWhenSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=retryWhen.js.map + +/***/ }), +/* 333 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var shareReplay_1 = __webpack_require__(333); - Observable_1.Observable.prototype.shareReplay = shareReplay_1.shareReplay; - //# sourceMappingURL=shareReplay.js.map +"use strict"; -/***/ }, -/* 333 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var multicast_1 = __webpack_require__(292); - var ReplaySubject_1 = __webpack_require__(184); - /** - * @method shareReplay - * @owner Observable - */ - function shareReplay(bufferSize, windowTime, scheduler) { - var subject; - var connectable = multicast_1.multicast.call(this, function shareReplaySubjectFactory() { - if (this._isComplete) { - return subject; - } - else { - return (subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler)); - } - }); - return connectable.refCount(); - } - exports.shareReplay = shareReplay; - ; - //# sourceMappingURL=shareReplay.js.map +var Observable_1 = __webpack_require__(0); +var sample_1 = __webpack_require__(334); +Observable_1.Observable.prototype.sample = sample_1.sample; +//# sourceMappingURL=sample.js.map -/***/ }, +/***/ }), /* 334 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(2); +var subscribeToResult_1 = __webpack_require__(3); +/** + * Emits the most recently emitted value from the source Observable whenever + * another Observable, the `notifier`, emits. + * + * It's like {@link sampleTime}, but samples whenever + * the `notifier` Observable emits something. + * + * + * + * Whenever the `notifier` Observable emits a value or completes, `sample` + * looks at the source Observable and emits whichever value it has most recently + * emitted since the previous sampling, unless the source has not emitted + * anything since the previous sampling. The `notifier` is subscribed to as soon + * as the output Observable is subscribed. + * + * @example On every click, sample the most recent "seconds" timer + * var seconds = Rx.Observable.interval(1000); + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = seconds.sample(clicks); + * result.subscribe(x => console.log(x)); + * + * @see {@link audit} + * @see {@link debounce} + * @see {@link sampleTime} + * @see {@link throttle} + * + * @param {Observable} notifier The Observable to use for sampling the + * source Observable. + * @return {Observable} An Observable that emits the results of sampling the + * values emitted by the source Observable whenever the notifier Observable + * emits value or completes. + * @method sample + * @owner Observable + */ +function sample(notifier) { + return this.lift(new SampleOperator(notifier)); +} +exports.sample = sample; +var SampleOperator = (function () { + function SampleOperator(notifier) { + this.notifier = notifier; + } + SampleOperator.prototype.call = function (subscriber, source) { + var sampleSubscriber = new SampleSubscriber(subscriber); + var subscription = source.subscribe(sampleSubscriber); + subscription.add(subscribeToResult_1.subscribeToResult(sampleSubscriber, this.notifier)); + return subscription; + }; + return SampleOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SampleSubscriber = (function (_super) { + __extends(SampleSubscriber, _super); + function SampleSubscriber() { + _super.apply(this, arguments); + this.hasValue = false; + } + SampleSubscriber.prototype._next = function (value) { + this.value = value; + this.hasValue = true; + }; + SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { + this.emitValue(); + }; + SampleSubscriber.prototype.notifyComplete = function () { + this.emitValue(); + }; + SampleSubscriber.prototype.emitValue = function () { + if (this.hasValue) { + this.hasValue = false; + this.destination.next(this.value); + } + }; + return SampleSubscriber; +}(OuterSubscriber_1.OuterSubscriber)); +//# sourceMappingURL=sample.js.map + +/***/ }), +/* 335 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var single_1 = __webpack_require__(335); - Observable_1.Observable.prototype.single = single_1.single; - //# sourceMappingURL=single.js.map +"use strict"; -/***/ }, -/* 335 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var EmptyError_1 = __webpack_require__(255); - /** - * Returns an Observable that emits the single item emitted by the source Observable that matches a specified - * predicate, if that Observable emits one such item. If the source Observable emits more than one such item or no - * such items, notify of an IllegalArgumentException or NoSuchElementException respectively. - * - * - * - * @throws {EmptyError} Delivers an EmptyError to the Observer's `error` - * callback if the Observable completes before any `next` notification was sent. - * @param {Function} predicate - A predicate function to evaluate items emitted by the source Observable. - * @return {Observable} An Observable that emits the single item emitted by the source Observable that matches - * the predicate. - . - * @method single - * @owner Observable - */ - function single(predicate) { - return this.lift(new SingleOperator(predicate, this)); - } - exports.single = single; - var SingleOperator = (function () { - function SingleOperator(predicate, source) { - this.predicate = predicate; - this.source = source; - } - SingleOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source)); - }; - return SingleOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SingleSubscriber = (function (_super) { - __extends(SingleSubscriber, _super); - function SingleSubscriber(destination, predicate, source) { - _super.call(this, destination); - this.predicate = predicate; - this.source = source; - this.seenValue = false; - this.index = 0; - } - SingleSubscriber.prototype.applySingleValue = function (value) { - if (this.seenValue) { - this.destination.error('Sequence contains more than one element'); - } - else { - this.seenValue = true; - this.singleValue = value; - } - }; - SingleSubscriber.prototype._next = function (value) { - var index = this.index++; - if (this.predicate) { - this.tryNext(value, index); - } - else { - this.applySingleValue(value); - } - }; - SingleSubscriber.prototype.tryNext = function (value, index) { - try { - if (this.predicate(value, index, this.source)) { - this.applySingleValue(value); - } - } - catch (err) { - this.destination.error(err); - } - }; - SingleSubscriber.prototype._complete = function () { - var destination = this.destination; - if (this.index > 0) { - destination.next(this.seenValue ? this.singleValue : undefined); - destination.complete(); - } - else { - destination.error(new EmptyError_1.EmptyError); - } - }; - return SingleSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=single.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var sampleTime_1 = __webpack_require__(336); +Observable_1.Observable.prototype.sampleTime = sampleTime_1.sampleTime; +//# sourceMappingURL=sampleTime.js.map + +/***/ }), /* 336 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var async_1 = __webpack_require__(9); +/** + * Emits the most recently emitted value from the source Observable within + * periodic time intervals. + * + * Samples the source Observable at periodic time + * intervals, emitting what it samples. + * + * + * + * `sampleTime` periodically looks at the source Observable and emits whichever + * value it has most recently emitted since the previous sampling, unless the + * source has not emitted anything since the previous sampling. The sampling + * happens periodically in time every `period` milliseconds (or the time unit + * defined by the optional `scheduler` argument). The sampling starts as soon as + * the output Observable is subscribed. + * + * @example Every second, emit the most recent click at most once + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var result = clicks.sampleTime(1000); + * result.subscribe(x => console.log(x)); + * + * @see {@link auditTime} + * @see {@link debounceTime} + * @see {@link delay} + * @see {@link sample} + * @see {@link throttleTime} + * + * @param {number} period The sampling period expressed in milliseconds or the + * time unit determined internally by the optional `scheduler`. + * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for + * managing the timers that handle the sampling. + * @return {Observable} An Observable that emits the results of sampling the + * values emitted by the source Observable at the specified time interval. + * @method sampleTime + * @owner Observable + */ +function sampleTime(period, scheduler) { + if (scheduler === void 0) { scheduler = async_1.async; } + return this.lift(new SampleTimeOperator(period, scheduler)); +} +exports.sampleTime = sampleTime; +var SampleTimeOperator = (function () { + function SampleTimeOperator(period, scheduler) { + this.period = period; + this.scheduler = scheduler; + } + SampleTimeOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler)); + }; + return SampleTimeOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SampleTimeSubscriber = (function (_super) { + __extends(SampleTimeSubscriber, _super); + function SampleTimeSubscriber(destination, period, scheduler) { + _super.call(this, destination); + this.period = period; + this.scheduler = scheduler; + this.hasValue = false; + this.add(scheduler.schedule(dispatchNotification, period, { subscriber: this, period: period })); + } + SampleTimeSubscriber.prototype._next = function (value) { + this.lastValue = value; + this.hasValue = true; + }; + SampleTimeSubscriber.prototype.notifyNext = function () { + if (this.hasValue) { + this.hasValue = false; + this.destination.next(this.lastValue); + } + }; + return SampleTimeSubscriber; +}(Subscriber_1.Subscriber)); +function dispatchNotification(state) { + var subscriber = state.subscriber, period = state.period; + subscriber.notifyNext(); + this.schedule(state, period); +} +//# sourceMappingURL=sampleTime.js.map + +/***/ }), +/* 337 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var skip_1 = __webpack_require__(337); - Observable_1.Observable.prototype.skip = skip_1.skip; - //# sourceMappingURL=skip.js.map +"use strict"; -/***/ }, -/* 337 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Returns an Observable that skips the first `count` items emitted by the source Observable. - * - * - * - * @param {Number} count - The number of times, items emitted by source Observable should be skipped. - * @return {Observable} An Observable that skips values emitted by the source Observable. - * - * @method skip - * @owner Observable - */ - function skip(count) { - return this.lift(new SkipOperator(count)); - } - exports.skip = skip; - var SkipOperator = (function () { - function SkipOperator(total) { - this.total = total; - } - SkipOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SkipSubscriber(subscriber, this.total)); - }; - return SkipOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SkipSubscriber = (function (_super) { - __extends(SkipSubscriber, _super); - function SkipSubscriber(destination, total) { - _super.call(this, destination); - this.total = total; - this.count = 0; - } - SkipSubscriber.prototype._next = function (x) { - if (++this.count > this.total) { - this.destination.next(x); - } - }; - return SkipSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=skip.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var scan_1 = __webpack_require__(338); +Observable_1.Observable.prototype.scan = scan_1.scan; +//# sourceMappingURL=scan.js.map + +/***/ }), /* 338 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/* tslint:enable:max-line-length */ +/** + * Applies an accumulator function over the source Observable, and returns each + * intermediate result, with an optional seed value. + * + * It's like {@link reduce}, but emits the current + * accumulation whenever the source emits a value. + * + * + * + * Combines together all values emitted on the source, using an accumulator + * function that knows how to join a new source value into the accumulation from + * the past. Is similar to {@link reduce}, but emits the intermediate + * accumulations. + * + * Returns an Observable that applies a specified `accumulator` function to each + * item emitted by the source Observable. If a `seed` value is specified, then + * that value will be used as the initial value for the accumulator. If no seed + * value is specified, the first item of the source is used as the seed. + * + * @example Count the number of click events + * var clicks = Rx.Observable.fromEvent(document, 'click'); + * var ones = clicks.mapTo(1); + * var seed = 0; + * var count = ones.scan((acc, one) => acc + one, seed); + * count.subscribe(x => console.log(x)); + * + * @see {@link expand} + * @see {@link mergeScan} + * @see {@link reduce} + * + * @param {function(acc: R, value: T, index: number): R} accumulator + * The accumulator function called on each source value. + * @param {T|R} [seed] The initial accumulation value. + * @return {Observable} An observable of the accumulated values. + * @method scan + * @owner Observable + */ +function scan(accumulator, seed) { + var hasSeed = false; + // providing a seed of `undefined` *should* be valid and trigger + // hasSeed! so don't use `seed !== undefined` checks! + // For this reason, we have to check it here at the original call site + // otherwise inside Operator/Subscriber we won't know if `undefined` + // means they didn't provide anything or if they literally provided `undefined` + if (arguments.length >= 2) { + hasSeed = true; + } + return this.lift(new ScanOperator(accumulator, seed, hasSeed)); +} +exports.scan = scan; +var ScanOperator = (function () { + function ScanOperator(accumulator, seed, hasSeed) { + if (hasSeed === void 0) { hasSeed = false; } + this.accumulator = accumulator; + this.seed = seed; + this.hasSeed = hasSeed; + } + ScanOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed)); + }; + return ScanOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var ScanSubscriber = (function (_super) { + __extends(ScanSubscriber, _super); + function ScanSubscriber(destination, accumulator, _seed, hasSeed) { + _super.call(this, destination); + this.accumulator = accumulator; + this._seed = _seed; + this.hasSeed = hasSeed; + this.index = 0; + } + Object.defineProperty(ScanSubscriber.prototype, "seed", { + get: function () { + return this._seed; + }, + set: function (value) { + this.hasSeed = true; + this._seed = value; + }, + enumerable: true, + configurable: true + }); + ScanSubscriber.prototype._next = function (value) { + if (!this.hasSeed) { + this.seed = value; + this.destination.next(value); + } + else { + return this._tryNext(value); + } + }; + ScanSubscriber.prototype._tryNext = function (value) { + var index = this.index++; + var result; + try { + result = this.accumulator(this.seed, value, index); + } + catch (err) { + this.destination.error(err); + } + this.seed = result; + this.destination.next(result); + }; + return ScanSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=scan.js.map + +/***/ }), +/* 339 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var skipLast_1 = __webpack_require__(339); - Observable_1.Observable.prototype.skipLast = skipLast_1.skipLast; - //# sourceMappingURL=skipLast.js.map +"use strict"; -/***/ }, -/* 339 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - var ArgumentOutOfRangeError_1 = __webpack_require__(244); - /** - * Skip the last `count` values emitted by the source Observable. - * - * - * - * `skipLast` returns an Observable that accumulates a queue with a length - * enough to store the first `count` values. As more values are received, - * values are taken from the front of the queue and produced on the result - * sequence. This causes values to be delayed. - * - * @example Skip the last 2 values of an Observable with many values - * var many = Rx.Observable.range(1, 5); - * var skipLastTwo = many.skipLast(2); - * skipLastTwo.subscribe(x => console.log(x)); - * - * // Results in: - * // 1 2 3 - * - * @see {@link skip} - * @see {@link skipUntil} - * @see {@link skipWhile} - * @see {@link take} - * - * @throws {ArgumentOutOfRangeError} When using `skipLast(i)`, it throws - * ArgumentOutOrRangeError if `i < 0`. - * - * @param {number} count Number of elements to skip from the end of the source Observable. - * @returns {Observable} An Observable that skips the last count values - * emitted by the source Observable. - * @method skipLast - * @owner Observable - */ - function skipLast(count) { - return this.lift(new SkipLastOperator(count)); - } - exports.skipLast = skipLast; - var SkipLastOperator = (function () { - function SkipLastOperator(_skipCount) { - this._skipCount = _skipCount; - if (this._skipCount < 0) { - throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError; - } - } - SkipLastOperator.prototype.call = function (subscriber, source) { - if (this._skipCount === 0) { - // If we don't want to skip any values then just subscribe - // to Subscriber without any further logic. - return source.subscribe(new Subscriber_1.Subscriber(subscriber)); - } - else { - return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount)); - } - }; - return SkipLastOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SkipLastSubscriber = (function (_super) { - __extends(SkipLastSubscriber, _super); - function SkipLastSubscriber(destination, _skipCount) { - _super.call(this, destination); - this._skipCount = _skipCount; - this._count = 0; - this._ring = new Array(_skipCount); - } - SkipLastSubscriber.prototype._next = function (value) { - var skipCount = this._skipCount; - var count = this._count++; - if (count < skipCount) { - this._ring[count] = value; - } - else { - var currentIndex = count % skipCount; - var ring = this._ring; - var oldValue = ring[currentIndex]; - ring[currentIndex] = value; - this.destination.next(oldValue); - } - }; - return SkipLastSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=skipLast.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var sequenceEqual_1 = __webpack_require__(340); +Observable_1.Observable.prototype.sequenceEqual = sequenceEqual_1.sequenceEqual; +//# sourceMappingURL=sequenceEqual.js.map + +/***/ }), /* 340 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var tryCatch_1 = __webpack_require__(8); +var errorObject_1 = __webpack_require__(6); +/** + * Compares all values of two observables in sequence using an optional comparor function + * and returns an observable of a single boolean value representing whether or not the two sequences + * are equal. + * + * Checks to see of all values emitted by both observables are equal, in order. + * + * + * + * `sequenceEqual` subscribes to two observables and buffers incoming values from each observable. Whenever either + * observable emits a value, the value is buffered and the buffers are shifted and compared from the bottom + * up; If any value pair doesn't match, the returned observable will emit `false` and complete. If one of the + * observables completes, the operator will wait for the other observable to complete; If the other + * observable emits before completing, the returned observable will emit `false` and complete. If one observable never + * completes or emits after the other complets, the returned observable will never complete. + * + * @example figure out if the Konami code matches + * var code = Rx.Observable.from([ + * "ArrowUp", + * "ArrowUp", + * "ArrowDown", + * "ArrowDown", + * "ArrowLeft", + * "ArrowRight", + * "ArrowLeft", + * "ArrowRight", + * "KeyB", + * "KeyA", + * "Enter" // no start key, clearly. + * ]); + * + * var keys = Rx.Observable.fromEvent(document, 'keyup') + * .map(e => e.code); + * var matches = keys.bufferCount(11, 1) + * .mergeMap( + * last11 => + * Rx.Observable.from(last11) + * .sequenceEqual(code) + * ); + * matches.subscribe(matched => console.log('Successful cheat at Contra? ', matched)); + * + * @see {@link combineLatest} + * @see {@link zip} + * @see {@link withLatestFrom} + * + * @param {Observable} compareTo The observable sequence to compare the source sequence to. + * @param {function} [comparor] An optional function to compare each value pair + * @return {Observable} An Observable of a single boolean value representing whether or not + * the values emitted by both observables were equal in sequence. + * @method sequenceEqual + * @owner Observable + */ +function sequenceEqual(compareTo, comparor) { + return this.lift(new SequenceEqualOperator(compareTo, comparor)); +} +exports.sequenceEqual = sequenceEqual; +var SequenceEqualOperator = (function () { + function SequenceEqualOperator(compareTo, comparor) { + this.compareTo = compareTo; + this.comparor = comparor; + } + SequenceEqualOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor)); + }; + return SequenceEqualOperator; +}()); +exports.SequenceEqualOperator = SequenceEqualOperator; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SequenceEqualSubscriber = (function (_super) { + __extends(SequenceEqualSubscriber, _super); + function SequenceEqualSubscriber(destination, compareTo, comparor) { + _super.call(this, destination); + this.compareTo = compareTo; + this.comparor = comparor; + this._a = []; + this._b = []; + this._oneComplete = false; + this.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, this))); + } + SequenceEqualSubscriber.prototype._next = function (value) { + if (this._oneComplete && this._b.length === 0) { + this.emit(false); + } + else { + this._a.push(value); + this.checkValues(); + } + }; + SequenceEqualSubscriber.prototype._complete = function () { + if (this._oneComplete) { + this.emit(this._a.length === 0 && this._b.length === 0); + } + else { + this._oneComplete = true; + } + }; + SequenceEqualSubscriber.prototype.checkValues = function () { + var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor; + while (_a.length > 0 && _b.length > 0) { + var a = _a.shift(); + var b = _b.shift(); + var areEqual = false; + if (comparor) { + areEqual = tryCatch_1.tryCatch(comparor)(a, b); + if (areEqual === errorObject_1.errorObject) { + this.destination.error(errorObject_1.errorObject.e); + } + } + else { + areEqual = a === b; + } + if (!areEqual) { + this.emit(false); + } + } + }; + SequenceEqualSubscriber.prototype.emit = function (value) { + var destination = this.destination; + destination.next(value); + destination.complete(); + }; + SequenceEqualSubscriber.prototype.nextB = function (value) { + if (this._oneComplete && this._a.length === 0) { + this.emit(false); + } + else { + this._b.push(value); + this.checkValues(); + } + }; + return SequenceEqualSubscriber; +}(Subscriber_1.Subscriber)); +exports.SequenceEqualSubscriber = SequenceEqualSubscriber; +var SequenceEqualCompareToSubscriber = (function (_super) { + __extends(SequenceEqualCompareToSubscriber, _super); + function SequenceEqualCompareToSubscriber(destination, parent) { + _super.call(this, destination); + this.parent = parent; + } + SequenceEqualCompareToSubscriber.prototype._next = function (value) { + this.parent.nextB(value); + }; + SequenceEqualCompareToSubscriber.prototype._error = function (err) { + this.parent.error(err); + }; + SequenceEqualCompareToSubscriber.prototype._complete = function () { + this.parent._complete(); + }; + return SequenceEqualCompareToSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=sequenceEqual.js.map + +/***/ }), +/* 341 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var skipUntil_1 = __webpack_require__(341); - Observable_1.Observable.prototype.skipUntil = skipUntil_1.skipUntil; - //# sourceMappingURL=skipUntil.js.map +"use strict"; -/***/ }, -/* 341 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 OuterSubscriber_1 = __webpack_require__(94); - var subscribeToResult_1 = __webpack_require__(95); - /** - * Returns an Observable that skips items emitted by the source Observable until a second Observable emits an item. - * - * - * - * @param {Observable} notifier - The second Observable that has to emit an item before the source Observable's elements begin to - * be mirrored by the resulting Observable. - * @return {Observable} An Observable that skips items from the source Observable until the second Observable emits - * an item, then emits the remaining items. - * @method skipUntil - * @owner Observable - */ - function skipUntil(notifier) { - return this.lift(new SkipUntilOperator(notifier)); - } - exports.skipUntil = skipUntil; - var SkipUntilOperator = (function () { - function SkipUntilOperator(notifier) { - this.notifier = notifier; - } - SkipUntilOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SkipUntilSubscriber(subscriber, this.notifier)); - }; - return SkipUntilOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SkipUntilSubscriber = (function (_super) { - __extends(SkipUntilSubscriber, _super); - function SkipUntilSubscriber(destination, notifier) { - _super.call(this, destination); - this.hasValue = false; - this.isInnerStopped = false; - this.add(subscribeToResult_1.subscribeToResult(this, notifier)); - } - SkipUntilSubscriber.prototype._next = function (value) { - if (this.hasValue) { - _super.prototype._next.call(this, value); - } - }; - SkipUntilSubscriber.prototype._complete = function () { - if (this.isInnerStopped) { - _super.prototype._complete.call(this); - } - else { - this.unsubscribe(); - } - }; - SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.hasValue = true; - }; - SkipUntilSubscriber.prototype.notifyComplete = function () { - this.isInnerStopped = true; - if (this.isStopped) { - _super.prototype._complete.call(this); - } - }; - return SkipUntilSubscriber; - }(OuterSubscriber_1.OuterSubscriber)); - //# sourceMappingURL=skipUntil.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var share_1 = __webpack_require__(342); +Observable_1.Observable.prototype.share = share_1.share; +//# sourceMappingURL=share.js.map + +/***/ }), /* 342 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var multicast_1 = __webpack_require__(17); +var Subject_1 = __webpack_require__(5); +function shareSubjectFactory() { + return new Subject_1.Subject(); +} +/** + * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one + * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will + * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`. + * This is an alias for .publish().refCount(). + * + * + * + * @return {Observable} An Observable that upon connection causes the source Observable to emit items to its Observers. + * @method share + * @owner Observable + */ +function share() { + return multicast_1.multicast.call(this, shareSubjectFactory).refCount(); +} +exports.share = share; +; +//# sourceMappingURL=share.js.map + +/***/ }), +/* 343 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var skipWhile_1 = __webpack_require__(343); - Observable_1.Observable.prototype.skipWhile = skipWhile_1.skipWhile; - //# sourceMappingURL=skipWhile.js.map +"use strict"; -/***/ }, -/* 343 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(67); - /** - * Returns an Observable that skips all items emitted by the source Observable as long as a specified condition holds - * true, but emits all further source items as soon as the condition becomes false. - * - * - * - * @param {Function} predicate - A function to test each item emitted from the source Observable. - * @return {Observable} An Observable that begins emitting items emitted by the source Observable when the - * specified predicate becomes false. - * @method skipWhile - * @owner Observable - */ - function skipWhile(predicate) { - return this.lift(new SkipWhileOperator(predicate)); - } - exports.skipWhile = skipWhile; - var SkipWhileOperator = (function () { - function SkipWhileOperator(predicate) { - this.predicate = predicate; - } - SkipWhileOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate)); - }; - return SkipWhileOperator; - }()); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var SkipWhileSubscriber = (function (_super) { - __extends(SkipWhileSubscriber, _super); - function SkipWhileSubscriber(destination, predicate) { - _super.call(this, destination); - this.predicate = predicate; - this.skipping = true; - this.index = 0; - } - SkipWhileSubscriber.prototype._next = function (value) { - var destination = this.destination; - if (this.skipping) { - this.tryCallPredicate(value); - } - if (!this.skipping) { - destination.next(value); - } - }; - SkipWhileSubscriber.prototype.tryCallPredicate = function (value) { - try { - var result = this.predicate(value, this.index++); - this.skipping = Boolean(result); - } - catch (err) { - this.destination.error(err); - } - }; - return SkipWhileSubscriber; - }(Subscriber_1.Subscriber)); - //# sourceMappingURL=skipWhile.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var shareReplay_1 = __webpack_require__(344); +Observable_1.Observable.prototype.shareReplay = shareReplay_1.shareReplay; +//# sourceMappingURL=shareReplay.js.map + +/***/ }), /* 344 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var multicast_1 = __webpack_require__(17); +var ReplaySubject_1 = __webpack_require__(36); +/** + * @method shareReplay + * @owner Observable + */ +function shareReplay(bufferSize, windowTime, scheduler) { + var subject; + var connectable = multicast_1.multicast.call(this, function shareReplaySubjectFactory() { + if (this._isComplete) { + return subject; + } + else { + return (subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler)); + } + }); + return connectable.refCount(); +} +exports.shareReplay = shareReplay; +; +//# sourceMappingURL=shareReplay.js.map + +/***/ }), +/* 345 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var startWith_1 = __webpack_require__(345); - Observable_1.Observable.prototype.startWith = startWith_1.startWith; - //# sourceMappingURL=startWith.js.map +"use strict"; -/***/ }, -/* 345 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var ArrayObservable_1 = __webpack_require__(90); - var ScalarObservable_1 = __webpack_require__(91); - var EmptyObservable_1 = __webpack_require__(92); - var concat_1 = __webpack_require__(102); - var isScheduler_1 = __webpack_require__(89); - /* tslint:enable:max-line-length */ - /** - * Returns an Observable that emits the items you specify as arguments before it begins to emit - * items emitted by the source Observable. - * - * - * - * @param {...T} values - Items you want the modified Observable to emit first. - * @param {Scheduler} [scheduler] - A {@link IScheduler} to use for scheduling - * the emissions of the `next` notifications. - * @return {Observable} An Observable that emits the items in the specified Iterable and then emits the items - * emitted by the source Observable. - * @method startWith - * @owner Observable - */ - function startWith() { - var array = []; - for (var _i = 0; _i < arguments.length; _i++) { - array[_i - 0] = arguments[_i]; - } - var scheduler = array[array.length - 1]; - if (isScheduler_1.isScheduler(scheduler)) { - array.pop(); - } - else { - scheduler = null; - } - var len = array.length; - if (len === 1) { - return concat_1.concatStatic(new ScalarObservable_1.ScalarObservable(array[0], scheduler), this); - } - else if (len > 1) { - return concat_1.concatStatic(new ArrayObservable_1.ArrayObservable(array, scheduler), this); - } - else { - return concat_1.concatStatic(new EmptyObservable_1.EmptyObservable(scheduler), this); - } - } - exports.startWith = startWith; - //# sourceMappingURL=startWith.js.map +var Observable_1 = __webpack_require__(0); +var single_1 = __webpack_require__(346); +Observable_1.Observable.prototype.single = single_1.single; +//# sourceMappingURL=single.js.map -/***/ }, +/***/ }), /* 346 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var EmptyError_1 = __webpack_require__(37); +/** + * Returns an Observable that emits the single item emitted by the source Observable that matches a specified + * predicate, if that Observable emits one such item. If the source Observable emits more than one such item or no + * such items, notify of an IllegalArgumentException or NoSuchElementException respectively. + * + * + * + * @throws {EmptyError} Delivers an EmptyError to the Observer's `error` + * callback if the Observable completes before any `next` notification was sent. + * @param {Function} predicate - A predicate function to evaluate items emitted by the source Observable. + * @return {Observable} An Observable that emits the single item emitted by the source Observable that matches + * the predicate. + . + * @method single + * @owner Observable + */ +function single(predicate) { + return this.lift(new SingleOperator(predicate, this)); +} +exports.single = single; +var SingleOperator = (function () { + function SingleOperator(predicate, source) { + this.predicate = predicate; + this.source = source; + } + SingleOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source)); + }; + return SingleOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SingleSubscriber = (function (_super) { + __extends(SingleSubscriber, _super); + function SingleSubscriber(destination, predicate, source) { + _super.call(this, destination); + this.predicate = predicate; + this.source = source; + this.seenValue = false; + this.index = 0; + } + SingleSubscriber.prototype.applySingleValue = function (value) { + if (this.seenValue) { + this.destination.error('Sequence contains more than one element'); + } + else { + this.seenValue = true; + this.singleValue = value; + } + }; + SingleSubscriber.prototype._next = function (value) { + var index = this.index++; + if (this.predicate) { + this.tryNext(value, index); + } + else { + this.applySingleValue(value); + } + }; + SingleSubscriber.prototype.tryNext = function (value, index) { + try { + if (this.predicate(value, index, this.source)) { + this.applySingleValue(value); + } + } + catch (err) { + this.destination.error(err); + } + }; + SingleSubscriber.prototype._complete = function () { + var destination = this.destination; + if (this.index > 0) { + destination.next(this.seenValue ? this.singleValue : undefined); + destination.complete(); + } + else { + destination.error(new EmptyError_1.EmptyError); + } + }; + return SingleSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=single.js.map + +/***/ }), +/* 347 */ +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - var Observable_1 = __webpack_require__(64); - var subscribeOn_1 = __webpack_require__(347); - Observable_1.Observable.prototype.subscribeOn = subscribeOn_1.subscribeOn; - //# sourceMappingURL=subscribeOn.js.map +"use strict"; -/***/ }, -/* 347 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var SubscribeOnObservable_1 = __webpack_require__(348); - /** - * Asynchronously subscribes Observers to this Observable on the specified IScheduler. - * - * - * - * @param {Scheduler} scheduler - The IScheduler to perform subscription actions on. - * @return {Observable} The source Observable modified so that its subscriptions happen on the specified IScheduler. - . - * @method subscribeOn - * @owner Observable - */ - function subscribeOn(scheduler, delay) { - if (delay === void 0) { delay = 0; } - return this.lift(new SubscribeOnOperator(scheduler, delay)); - } - exports.subscribeOn = subscribeOn; - var SubscribeOnOperator = (function () { - function SubscribeOnOperator(scheduler, delay) { - this.scheduler = scheduler; - this.delay = delay; - } - SubscribeOnOperator.prototype.call = function (subscriber, source) { - return new SubscribeOnObservable_1.SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber); - }; - return SubscribeOnOperator; - }()); - //# sourceMappingURL=subscribeOn.js.map - -/***/ }, +var Observable_1 = __webpack_require__(0); +var skip_1 = __webpack_require__(348); +Observable_1.Observable.prototype.skip = skip_1.skip; +//# sourceMappingURL=skip.js.map + +/***/ }), /* 348 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Observable_1 = __webpack_require__(64); - var asap_1 = __webpack_require__(349); - var isNumeric_1 = __webpack_require__(137); - /** - * We need this JSDoc comment for affecting ESDoc. - * @extends {Ignored} - * @hide true - */ - var SubscribeOnObservable = (function (_super) { - __extends(SubscribeOnObservable, _super); - function SubscribeOnObservable(source, delayTime, scheduler) { - if (delayTime === void 0) { delayTime = 0; } - if (scheduler === void 0) { scheduler = asap_1.asap; } - _super.call(this); - this.source = source; - this.delayTime = delayTime; - this.scheduler = scheduler; - if (!isNumeric_1.isNumeric(delayTime) || delayTime < 0) { - this.delayTime = 0; - } - if (!scheduler || typeof scheduler.schedule !== 'function') { - this.scheduler = asap_1.asap; - } - } - SubscribeOnObservable.create = function (source, delay, scheduler) { - if (delay === void 0) { delay = 0; } - if (scheduler === void 0) { scheduler = asap_1.asap; } - return new SubscribeOnObservable(source, delay, scheduler); - }; - SubscribeOnObservable.dispatch = function (arg) { - var source = arg.source, subscriber = arg.subscriber; - return this.add(source.subscribe(subscriber)); - }; - SubscribeOnObservable.prototype._subscribe = function (subscriber) { - var delay = this.delayTime; - var source = this.source; - var scheduler = this.scheduler; - return scheduler.schedule(SubscribeOnObservable.dispatch, delay, { - source: source, subscriber: subscriber - }); - }; - return SubscribeOnObservable; - }(Observable_1.Observable)); - exports.SubscribeOnObservable = SubscribeOnObservable; - //# sourceMappingURL=SubscribeOnObservable.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +/** + * Returns an Observable that skips the first `count` items emitted by the source Observable. + * + * + * + * @param {Number} count - The number of times, items emitted by source Observable should be skipped. + * @return {Observable} An Observable that skips values emitted by the source Observable. + * + * @method skip + * @owner Observable + */ +function skip(count) { + return this.lift(new SkipOperator(count)); +} +exports.skip = skip; +var SkipOperator = (function () { + function SkipOperator(total) { + this.total = total; + } + SkipOperator.prototype.call = function (subscriber, source) { + return source.subscribe(new SkipSubscriber(subscriber, this.total)); + }; + return SkipOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SkipSubscriber = (function (_super) { + __extends(SkipSubscriber, _super); + function SkipSubscriber(destination, total) { + _super.call(this, destination); + this.total = total; + this.count = 0; + } + SkipSubscriber.prototype._next = function (x) { + if (++this.count > this.total) { + this.destination.next(x); + } + }; + return SkipSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=skip.js.map + +/***/ }), /* 349 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var AsapAction_1 = __webpack_require__(350); - var AsapScheduler_1 = __webpack_require__(354); - /** - * - * Asap Scheduler - * - * Perform task as fast as it can be performed asynchronously - * - * `asap` scheduler behaves the same as {@link async} scheduler when you use it to delay task - * in time. If however you set delay to `0`, `asap` will wait for current synchronously executing - * code to end and then it will try to execute given task as fast as possible. - * - * `asap` scheduler will do its best to minimize time between end of currently executing code - * and start of scheduled task. This makes it best candidate for performing so called "deferring". - * Traditionally this was achieved by calling `setTimeout(deferredTask, 0)`, but that technique involves - * some (although minimal) unwanted delay. - * - * Note that using `asap` scheduler does not necessarily mean that your task will be first to process - * after currently executing code. In particular, if some task was also scheduled with `asap` before, - * that task will execute first. That being said, if you need to schedule task asynchronously, but - * as soon as possible, `asap` scheduler is your best bet. - * - * @example Compare async and asap scheduler - * - * Rx.Scheduler.async.schedule(() => console.log('async')); // scheduling 'async' first... - * Rx.Scheduler.asap.schedule(() => console.log('asap')); - * - * // Logs: - * // "asap" - * // "async" - * // ... but 'asap' goes first! - * - * @static true - * @name asap - * @owner Scheduler - */ - exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction); - //# sourceMappingURL=asap.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var Observable_1 = __webpack_require__(0); +var skipLast_1 = __webpack_require__(350); +Observable_1.Observable.prototype.skipLast = skipLast_1.skipLast; +//# sourceMappingURL=skipLast.js.map + +/***/ }), /* 350 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - var __extends = (this && this.__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 Immediate_1 = __webpack_require__(351); - var AsyncAction_1 = __webpack_require__(139); - /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ - var AsapAction = (function (_super) { - __extends(AsapAction, _super); - function AsapAction(scheduler, work) { - _super.call(this, scheduler, work); - this.scheduler = scheduler; - this.work = work; - } - AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) { - if (delay === void 0) { delay = 0; } - // If delay is greater than 0, request as an async action. - if (delay !== null && delay > 0) { - return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); - } - // Push the action to the end of the scheduler queue. - scheduler.actions.push(this); - // If a microtask has already been scheduled, don't schedule another - // one. If a microtask hasn't been scheduled yet, schedule one now. Return - // the current scheduled microtask id. - return scheduler.scheduled || (scheduler.scheduled = Immediate_1.Immediate.setImmediate(scheduler.flush.bind(scheduler, null))); - }; - AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) { - if (delay === void 0) { delay = 0; } - // If delay exists and is greater than 0, or if the delay is null (the - // action wasn't rescheduled) but was originally scheduled as an async - // action, then recycle as an async action. - if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { - return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); - } - // If the scheduler queue is empty, cancel the requested microtask and - // set the scheduled flag to undefined so the next AsapAction will schedule - // its own. - if (scheduler.actions.length === 0) { - Immediate_1.Immediate.clearImmediate(id); - scheduler.scheduled = undefined; - } - // Return undefined so the action knows to request a new async id if it's rescheduled. - return undefined; - }; - return AsapAction; - }(AsyncAction_1.AsyncAction)); - exports.AsapAction = AsapAction; - //# sourceMappingURL=AsapAction.js.map - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__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 Subscriber_1 = __webpack_require__(1); +var ArgumentOutOfRangeError_1 = __webpack_require__(25); +/** + * Skip the last `count` values emitted by the source Observable. + * + * + * + * `skipLast` returns an Observable that accumulates a queue with a length + * enough to store the first `count` values. As more values are received, + * values are taken from the front of the queue and produced on the result + * sequence. This causes values to be delayed. + * + * @example Skip the last 2 values of an Observable with many values + * var many = Rx.Observable.range(1, 5); + * var skipLastTwo = many.skipLast(2); + * skipLastTwo.subscribe(x => console.log(x)); + * + * // Results in: + * // 1 2 3 + * + * @see {@link skip} + * @see {@link skipUntil} + * @see {@link skipWhile} + * @see {@link take} + * + * @throws {ArgumentOutOfRangeError} When using `skipLast(i)`, it throws + * ArgumentOutOrRangeError if `i < 0`. + * + * @param {number} count Number of elements to skip from the end of the source Observable. + * @returns {Observable} An Observable that skips the last count values + * emitted by the source Observable. + * @method skipLast + * @owner Observable + */ +function skipLast(count) { + return this.lift(new SkipLastOperator(count)); +} +exports.skipLast = skipLast; +var SkipLastOperator = (function () { + function SkipLastOperator(_skipCount) { + this._skipCount = _skipCount; + if (this._skipCount < 0) { + throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError; + } + } + SkipLastOperator.prototype.call = function (subscriber, source) { + if (this._skipCount === 0) { + // If we don't want to skip any values then just subscribe + // to Subscriber without any further logic. + return source.subscribe(new Subscriber_1.Subscriber(subscriber)); + } + else { + return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount)); + } + }; + return SkipLastOperator; +}()); +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +var SkipLastSubscriber = (function (_super) { + __extends(SkipLastSubscriber, _super); + function SkipLastSubscriber(destination, _skipCount) { + _super.call(this, destination); + this._skipCount = _skipCount; + this._count = 0; + this._ring = new Array(_skipCount); + } + SkipLastSubscriber.prototype._next = function (value) { + var skipCount = this._skipCount; + var count = this._count++; + if (count < skipCount) { + this._ring[count] = value; + } + else { + var currentIndex = count % skipCount; + var ring = this._ring; + var oldValue = ring[currentIndex]; + ring[currentIndex] = value; + this.destination.next(oldValue); + } + }; + return SkipLastSubscriber; +}(Subscriber_1.Subscriber)); +//# sourceMappingURL=skipLast.js.map + +/***/ }), /* 351 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(clearImmediate, setImmediate) {/** - Some credit for this helper goes to http://github.com/YuzuJS/setImmediate - */ - "use strict"; - var root_1 = __webpack_require__(65); - var ImmediateDefinition = (function () { - function ImmediateDefinition(root) { - this.root = root; - if (root.setImmediate && typeof root.setImmediate === 'function') { - this.setImmediate = root.setImmediate.bind(root); - this.clearImmediate = root.clearImmediate.bind(root); - } - else { - this.nextHandle = 1; - this.tasksByHandle = {}; - this.currentlyRunningATask = false; - // Don't get fooled by e.g. browserify environments. - if (this.canUseProcessNextTick()) { - // For Node.js before 0.9 - this.setImmediate = this.createProcessNextTickSetImmediate(); - } - else if (this.canUsePostMessage()) { - // For non-IE10 modern browsers - this.setImmediate = this.createPostMessageSetImmediate(); - } - else if (this.canUseMessageChannel()) { - // For web workers, where supported - this.setImmediate = this.createMessageChannelSetImmediate(); - } - else if (this.canUseReadyStateChange()) { - // For IE 6–8 - this.setImmediate = this.createReadyStateChangeSetImmediate(); - } - else { - // For older browsers - this.setImmediate = this.createSetTimeoutSetImmediate(); - } - var ci = function clearImmediate(handle) { - delete clearImmediate.instance.tasksByHandle[handle]; - }; - ci.instance = this; - this.clearImmediate = ci; - } - } - ImmediateDefinition.prototype.identify = function (o) { - return this.root.Object.prototype.toString.call(o); - }; - ImmediateDefinition.prototype.canUseProcessNextTick = function () { - return this.identify(this.root.process) === '[object process]'; - }; - ImmediateDefinition.prototype.canUseMessageChannel = function () { - return Boolean(this.root.MessageChannel); - }; - ImmediateDefinition.prototype.canUseReadyStateChange = function () { - var document = this.root.document; - return Boolean(document && 'onreadystatechange' in document.createElement('script')); - }; - ImmediateDefinition.prototype.canUsePostMessage = function () { - var root = this.root; - // The test against `importScripts` prevents this implementation from being installed inside a web worker, - // where `root.postMessage` means something completely different and can't be used for this purpose. - if (root.postMessage && !root.importScripts) { - var postMessageIsAsynchronous_1 = true; - var oldOnMessage = root.onmessage; - root.onmessage = function () { - postMessageIsAsynchronous_1 = false; - }; - root.postMessage('', '*'); - root.onmessage = oldOnMessage; - return postMessageIsAsynchronous_1; - } - return false; - }; - // This function accepts the same arguments as setImmediate, but - // returns a function that requires no arguments. - ImmediateDefinition.prototype.partiallyApplied = function (handler) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var fn = function result() { - var _a = result, handler = _a.handler, args = _a.args; - if (typeof handler === 'function') { - handler.apply(undefined, args); - } - else { - (new Function('' + handler))(); - } - }; - fn.handler = handler; - fn.args = args; - return fn; - }; - ImmediateDefinition.prototype.addFromSetImmediateArguments = function (args) { - this.tasksByHandle[this.nextHandle] = this.partiallyApplied.apply(undefined, args); - return this.nextHandle++; - }; - ImmediateDefinition.prototype.createProcessNextTickSetImmediate = function () { - var fn = function setImmediate() { - var instance = setImmediate.instance; - var handle = instance.addFromSetImmediateArguments(arguments); - instance.root.process.nextTick(instance.partiallyApplied(instance.runIfPresent, handle)); - return handle; - }; - fn.instance = this; - return fn; - }; - ImmediateDefinition.prototype.createPostMessageSetImmediate = function () { - // Installs an event handler on `global` for the `message` event: see - // * https://developer.mozilla.org/en/DOM/window.postMessage - // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages - var root = this.root; - var messagePrefix = 'setImmediate$' + root.Math.random() + '$'; - var onGlobalMessage = function globalMessageHandler(event) { - var instance = globalMessageHandler.instance; - if (event.source === root && - typeof event.data === 'string' && - event.data.indexOf(messagePrefix) === 0) { - instance.runIfPresent(+event.data.slice(messagePrefix.length)); - } - }; - onGlobalMessage.instance = this; - root.addEventListener('message', onGlobalMessage, false); - var fn = function setImmediate() { - var _a = setImmediate, messagePrefix = _a.messagePrefix, instance = _a.instance; - var handle = instance.addFromSetImmediateArguments(arguments); - instance.root.postMessage(messagePrefix + handle, '*'); - return handle; - }; - fn.instance = this; - fn.messagePrefix = messagePrefix; - return fn; - }; - ImmediateDefinition.prototype.runIfPresent = function (handle) { - // From the spec: 'Wait until any invocations of this algorithm started before this one have completed.' - // So if we're currently running a task, we'll need to delay this invocation. - if (this.currentlyRunningATask) { - // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a - // 'too much recursion' error. - this.root.setTimeout(this.partiallyApplied(this.runIfPresent, handle), 0); - } - else { - var task = this.tasksByHandle[handle]; - if (task) { - this.currentlyRunningATask = true; - try { - task(); - } - finally { - this.clearImmediate(handle); - this.currentlyRunningATask = false; - } - } - } - }; - ImmediateDefinition.prototype.createMessageChannelSetImmediate = function () { - var _this = this; - var channel = new this.root.MessageChannel(); - channel.port1.onmessage = function (event) { - var handle = event.data; - _this.runIfPresent(handle); - }; - var fn = function setImmediate() { - var _a = setImmediate, channel = _a.channel, instance = _a.instance; - var handle = instance.addFromSetImmediateArguments(arguments); - channel.port2.postMessage(handle); - return handle; - }; - fn.channel = channel; - fn.instance = this; - return fn; - }; - ImmediateDefinition.prototype.createReadyStateChangeSetImmediate = function () { - var fn = function setImmediate() { - var instance = setImmediate.instance; - var root = instance.root; - var doc = root.document; - var html = doc.documentElement; - var handle = instance.addFromSetImmediateArguments(arguments); - // Create a