Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

18986 строки
556 KiB

  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, {
  40. /******/ configurable: false,
  41. /******/ enumerable: true,
  42. /******/ get: getter
  43. /******/ });
  44. /******/ }
  45. /******/ };
  46. /******/
  47. /******/ // getDefaultExport function for compatibility with non-harmony modules
  48. /******/ __webpack_require__.n = function(module) {
  49. /******/ var getter = module && module.__esModule ?
  50. /******/ function getDefault() { return module['default']; } :
  51. /******/ function getModuleExports() { return module; };
  52. /******/ __webpack_require__.d(getter, 'a', getter);
  53. /******/ return getter;
  54. /******/ };
  55. /******/
  56. /******/ // Object.prototype.hasOwnProperty.call
  57. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  58. /******/
  59. /******/ // __webpack_public_path__
  60. /******/ __webpack_require__.p = "";
  61. /******/
  62. /******/ // Load entry module and return exports
  63. /******/ return __webpack_require__(__webpack_require__.s = 99);
  64. /******/ })
  65. /************************************************************************/
  66. /******/ ([
  67. /* 0 */
  68. /***/ (function(module, exports, __webpack_require__) {
  69. "use strict";
  70. var __extends = (this && this.__extends) || function (d, b) {
  71. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  72. function __() { this.constructor = d; }
  73. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  74. };
  75. var OuterSubscriber_1 = __webpack_require__(29);
  76. var subscribeToResult_1 = __webpack_require__(30);
  77. /* tslint:enable:max-line-length */
  78. /**
  79. * Combines the source Observable with other Observables to create an Observable
  80. * whose values are calculated from the latest values of each, only when the
  81. * source emits.
  82. *
  83. * <span class="informal">Whenever the source Observable emits a value, it
  84. * computes a formula using that value plus the latest values from other input
  85. * Observables, then emits the output of that formula.</span>
  86. *
  87. * <img src="./img/withLatestFrom.png" width="100%">
  88. *
  89. * `withLatestFrom` combines each value from the source Observable (the
  90. * instance) with the latest values from the other input Observables only when
  91. * the source emits a value, optionally using a `project` function to determine
  92. * the value to be emitted on the output Observable. All input Observables must
  93. * emit at least one value before the output Observable will emit a value.
  94. *
  95. * @example <caption>On every click event, emit an array with the latest timer event plus the click event</caption>
  96. * var clicks = Rx.Observable.fromEvent(document, 'click');
  97. * var timer = Rx.Observable.interval(1000);
  98. * var result = clicks.withLatestFrom(timer);
  99. * result.subscribe(x => console.log(x));
  100. *
  101. * @see {@link combineLatest}
  102. *
  103. * @param {ObservableInput} other An input Observable to combine with the source
  104. * Observable. More than one input Observables may be given as argument.
  105. * @param {Function} [project] Projection function for combining values
  106. * together. Receives all values in order of the Observables passed, where the
  107. * first parameter is a value from the source Observable. (e.g.
  108. * `a.withLatestFrom(b, c, (a1, b1, c1) => a1 + b1 + c1)`). If this is not
  109. * passed, arrays will be emitted on the output Observable.
  110. * @return {Observable} An Observable of projected values from the most recent
  111. * values from each input Observable, or an array of the most recent values from
  112. * each input Observable.
  113. * @method withLatestFrom
  114. * @owner Observable
  115. */
  116. function withLatestFrom() {
  117. var args = [];
  118. for (var _i = 0; _i < arguments.length; _i++) {
  119. args[_i - 0] = arguments[_i];
  120. }
  121. return function (source) {
  122. var project;
  123. if (typeof args[args.length - 1] === 'function') {
  124. project = args.pop();
  125. }
  126. var observables = args;
  127. return source.lift(new WithLatestFromOperator(observables, project));
  128. };
  129. }
  130. exports.withLatestFrom = withLatestFrom;
  131. var WithLatestFromOperator = (function () {
  132. function WithLatestFromOperator(observables, project) {
  133. this.observables = observables;
  134. this.project = project;
  135. }
  136. WithLatestFromOperator.prototype.call = function (subscriber, source) {
  137. return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
  138. };
  139. return WithLatestFromOperator;
  140. }());
  141. /**
  142. * We need this JSDoc comment for affecting ESDoc.
  143. * @ignore
  144. * @extends {Ignored}
  145. */
  146. var WithLatestFromSubscriber = (function (_super) {
  147. __extends(WithLatestFromSubscriber, _super);
  148. function WithLatestFromSubscriber(destination, observables, project) {
  149. _super.call(this, destination);
  150. this.observables = observables;
  151. this.project = project;
  152. this.toRespond = [];
  153. var len = observables.length;
  154. this.values = new Array(len);
  155. for (var i = 0; i < len; i++) {
  156. this.toRespond.push(i);
  157. }
  158. for (var i = 0; i < len; i++) {
  159. var observable = observables[i];
  160. this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i));
  161. }
  162. }
  163. WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  164. this.values[outerIndex] = innerValue;
  165. var toRespond = this.toRespond;
  166. if (toRespond.length > 0) {
  167. var found = toRespond.indexOf(outerIndex);
  168. if (found !== -1) {
  169. toRespond.splice(found, 1);
  170. }
  171. }
  172. };
  173. WithLatestFromSubscriber.prototype.notifyComplete = function () {
  174. // noop
  175. };
  176. WithLatestFromSubscriber.prototype._next = function (value) {
  177. if (this.toRespond.length === 0) {
  178. var args = [value].concat(this.values);
  179. if (this.project) {
  180. this._tryProject(args);
  181. }
  182. else {
  183. this.destination.next(args);
  184. }
  185. }
  186. };
  187. WithLatestFromSubscriber.prototype._tryProject = function (args) {
  188. var result;
  189. try {
  190. result = this.project.apply(this, args);
  191. }
  192. catch (err) {
  193. this.destination.error(err);
  194. return;
  195. }
  196. this.destination.next(result);
  197. };
  198. return WithLatestFromSubscriber;
  199. }(OuterSubscriber_1.OuterSubscriber));
  200. //# sourceMappingURL=withLatestFrom.js.map
  201. /***/ }),
  202. /* 1 */
  203. /***/ (function(module, exports, __webpack_require__) {
  204. "use strict";
  205. var root_1 = __webpack_require__(7);
  206. var toSubscriber_1 = __webpack_require__(103);
  207. var observable_1 = __webpack_require__(45);
  208. var pipe_1 = __webpack_require__(105);
  209. /**
  210. * A representation of any set of values over any amount of time. This is the most basic building block
  211. * of RxJS.
  212. *
  213. * @class Observable<T>
  214. */
  215. var Observable = (function () {
  216. /**
  217. * @constructor
  218. * @param {Function} subscribe the function that is called when the Observable is
  219. * initially subscribed to. This function is given a Subscriber, to which new values
  220. * can be `next`ed, or an `error` method can be called to raise an error, or
  221. * `complete` can be called to notify of a successful completion.
  222. */
  223. function Observable(subscribe) {
  224. this._isScalar = false;
  225. if (subscribe) {
  226. this._subscribe = subscribe;
  227. }
  228. }
  229. /**
  230. * Creates a new Observable, with this Observable as the source, and the passed
  231. * operator defined as the new observable's operator.
  232. * @method lift
  233. * @param {Operator} operator the operator defining the operation to take on the observable
  234. * @return {Observable} a new observable with the Operator applied
  235. */
  236. Observable.prototype.lift = function (operator) {
  237. var observable = new Observable();
  238. observable.source = this;
  239. observable.operator = operator;
  240. return observable;
  241. };
  242. /**
  243. * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit.
  244. *
  245. * <span class="informal">Use it when you have all these Observables, but still nothing is happening.</span>
  246. *
  247. * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It
  248. * might be for example a function that you passed to a {@link create} static factory, but most of the time it is
  249. * a library implementation, which defines what and when will be emitted by an Observable. This means that calling
  250. * `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often
  251. * thought.
  252. *
  253. * Apart from starting the execution of an Observable, this method allows you to listen for values
  254. * that an Observable emits, as well as for when it completes or errors. You can achieve this in two
  255. * following ways.
  256. *
  257. * The first way is creating an object that implements {@link Observer} interface. It should have methods
  258. * defined by that interface, but note that it should be just a regular JavaScript object, which you can create
  259. * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular do
  260. * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also
  261. * that your object does not have to implement all methods. If you find yourself creating a method that doesn't
  262. * do anything, you can simply omit it. Note however, that if `error` method is not provided, all errors will
  263. * be left uncaught.
  264. *
  265. * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods.
  266. * This means you can provide three functions as arguments to `subscribe`, where first function is equivalent
  267. * of a `next` method, second of an `error` method and third of a `complete` method. Just as in case of Observer,
  268. * if you do not need to listen for something, you can omit a function, preferably by passing `undefined` or `null`,
  269. * since `subscribe` recognizes these functions by where they were placed in function call. When it comes
  270. * to `error` function, just as before, if not provided, errors emitted by an Observable will be thrown.
  271. *
  272. * Whatever style of calling `subscribe` you use, in both cases it returns a Subscription object.
  273. * This object allows you to call `unsubscribe` on it, which in turn will stop work that an Observable does and will clean
  274. * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback
  275. * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable.
  276. *
  277. * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously.
  278. * It is an Observable itself that decides when these functions will be called. For example {@link of}
  279. * by default emits all its values synchronously. Always check documentation for how given Observable
  280. * will behave when subscribed and if its default behavior can be modified with a {@link Scheduler}.
  281. *
  282. * @example <caption>Subscribe with an Observer</caption>
  283. * const sumObserver = {
  284. * sum: 0,
  285. * next(value) {
  286. * console.log('Adding: ' + value);
  287. * this.sum = this.sum + value;
  288. * },
  289. * error() { // We actually could just remove this method,
  290. * }, // since we do not really care about errors right now.
  291. * complete() {
  292. * console.log('Sum equals: ' + this.sum);
  293. * }
  294. * };
  295. *
  296. * Rx.Observable.of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes.
  297. * .subscribe(sumObserver);
  298. *
  299. * // Logs:
  300. * // "Adding: 1"
  301. * // "Adding: 2"
  302. * // "Adding: 3"
  303. * // "Sum equals: 6"
  304. *
  305. *
  306. * @example <caption>Subscribe with functions</caption>
  307. * let sum = 0;
  308. *
  309. * Rx.Observable.of(1, 2, 3)
  310. * .subscribe(
  311. * function(value) {
  312. * console.log('Adding: ' + value);
  313. * sum = sum + value;
  314. * },
  315. * undefined,
  316. * function() {
  317. * console.log('Sum equals: ' + sum);
  318. * }
  319. * );
  320. *
  321. * // Logs:
  322. * // "Adding: 1"
  323. * // "Adding: 2"
  324. * // "Adding: 3"
  325. * // "Sum equals: 6"
  326. *
  327. *
  328. * @example <caption>Cancel a subscription</caption>
  329. * const subscription = Rx.Observable.interval(1000).subscribe(
  330. * num => console.log(num),
  331. * undefined,
  332. * () => console.log('completed!') // Will not be called, even
  333. * ); // when cancelling subscription
  334. *
  335. *
  336. * setTimeout(() => {
  337. * subscription.unsubscribe();
  338. * console.log('unsubscribed!');
  339. * }, 2500);
  340. *
  341. * // Logs:
  342. * // 0 after 1s
  343. * // 1 after 2s
  344. * // "unsubscribed!" after 2.5s
  345. *
  346. *
  347. * @param {Observer|Function} observerOrNext (optional) Either an observer with methods to be called,
  348. * or the first of three possible handlers, which is the handler for each value emitted from the subscribed
  349. * Observable.
  350. * @param {Function} error (optional) A handler for a terminal event resulting from an error. If no error handler is provided,
  351. * the error will be thrown as unhandled.
  352. * @param {Function} complete (optional) A handler for a terminal event resulting from successful completion.
  353. * @return {ISubscription} a subscription reference to the registered handlers
  354. * @method subscribe
  355. */
  356. Observable.prototype.subscribe = function (observerOrNext, error, complete) {
  357. var operator = this.operator;
  358. var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
  359. if (operator) {
  360. operator.call(sink, this.source);
  361. }
  362. else {
  363. sink.add(this.source || !sink.syncErrorThrowable ? this._subscribe(sink) : this._trySubscribe(sink));
  364. }
  365. if (sink.syncErrorThrowable) {
  366. sink.syncErrorThrowable = false;
  367. if (sink.syncErrorThrown) {
  368. throw sink.syncErrorValue;
  369. }
  370. }
  371. return sink;
  372. };
  373. Observable.prototype._trySubscribe = function (sink) {
  374. try {
  375. return this._subscribe(sink);
  376. }
  377. catch (err) {
  378. sink.syncErrorThrown = true;
  379. sink.syncErrorValue = err;
  380. sink.error(err);
  381. }
  382. };
  383. /**
  384. * @method forEach
  385. * @param {Function} next a handler for each value emitted by the observable
  386. * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise
  387. * @return {Promise} a promise that either resolves on observable completion or
  388. * rejects with the handled error
  389. */
  390. Observable.prototype.forEach = function (next, PromiseCtor) {
  391. var _this = this;
  392. if (!PromiseCtor) {
  393. if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
  394. PromiseCtor = root_1.root.Rx.config.Promise;
  395. }
  396. else if (root_1.root.Promise) {
  397. PromiseCtor = root_1.root.Promise;
  398. }
  399. }
  400. if (!PromiseCtor) {
  401. throw new Error('no Promise impl found');
  402. }
  403. return new PromiseCtor(function (resolve, reject) {
  404. // Must be declared in a separate statement to avoid a RefernceError when
  405. // accessing subscription below in the closure due to Temporal Dead Zone.
  406. var subscription;
  407. subscription = _this.subscribe(function (value) {
  408. if (subscription) {
  409. // if there is a subscription, then we can surmise
  410. // the next handling is asynchronous. Any errors thrown
  411. // need to be rejected explicitly and unsubscribe must be
  412. // called manually
  413. try {
  414. next(value);
  415. }
  416. catch (err) {
  417. reject(err);
  418. subscription.unsubscribe();
  419. }
  420. }
  421. else {
  422. // if there is NO subscription, then we're getting a nexted
  423. // value synchronously during subscription. We can just call it.
  424. // If it errors, Observable's `subscribe` will ensure the
  425. // unsubscription logic is called, then synchronously rethrow the error.
  426. // After that, Promise will trap the error and send it
  427. // down the rejection path.
  428. next(value);
  429. }
  430. }, reject, resolve);
  431. });
  432. };
  433. /** @deprecated internal use only */ Observable.prototype._subscribe = function (subscriber) {
  434. return this.source.subscribe(subscriber);
  435. };
  436. /**
  437. * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
  438. * @method Symbol.observable
  439. * @return {Observable} this instance of the observable
  440. */
  441. Observable.prototype[observable_1.observable] = function () {
  442. return this;
  443. };
  444. /* tslint:enable:max-line-length */
  445. /**
  446. * Used to stitch together functional operators into a chain.
  447. * @method pipe
  448. * @return {Observable} the Observable result of all of the operators having
  449. * been called in the order they were passed in.
  450. *
  451. * @example
  452. *
  453. * import { map, filter, scan } from 'rxjs/operators';
  454. *
  455. * Rx.Observable.interval(1000)
  456. * .pipe(
  457. * filter(x => x % 2 === 0),
  458. * map(x => x + x),
  459. * scan((acc, x) => acc + x)
  460. * )
  461. * .subscribe(x => console.log(x))
  462. */
  463. Observable.prototype.pipe = function () {
  464. var operations = [];
  465. for (var _i = 0; _i < arguments.length; _i++) {
  466. operations[_i - 0] = arguments[_i];
  467. }
  468. if (operations.length === 0) {
  469. return this;
  470. }
  471. return pipe_1.pipeFromArray(operations)(this);
  472. };
  473. /* tslint:enable:max-line-length */
  474. Observable.prototype.toPromise = function (PromiseCtor) {
  475. var _this = this;
  476. if (!PromiseCtor) {
  477. if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
  478. PromiseCtor = root_1.root.Rx.config.Promise;
  479. }
  480. else if (root_1.root.Promise) {
  481. PromiseCtor = root_1.root.Promise;
  482. }
  483. }
  484. if (!PromiseCtor) {
  485. throw new Error('no Promise impl found');
  486. }
  487. return new PromiseCtor(function (resolve, reject) {
  488. var value;
  489. _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
  490. });
  491. };
  492. // HACK: Since TypeScript inherits static properties too, we have to
  493. // fight against TypeScript here so Subject can have a different static create signature
  494. /**
  495. * Creates a new cold Observable by calling the Observable constructor
  496. * @static true
  497. * @owner Observable
  498. * @method create
  499. * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
  500. * @return {Observable} a new cold observable
  501. */
  502. Observable.create = function (subscribe) {
  503. return new Observable(subscribe);
  504. };
  505. return Observable;
  506. }());
  507. exports.Observable = Observable;
  508. //# sourceMappingURL=Observable.js.map
  509. /***/ }),
  510. /* 2 */
  511. /***/ (function(module, exports, __webpack_require__) {
  512. "use strict";
  513. var __extends = (this && this.__extends) || function (d, b) {
  514. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  515. function __() { this.constructor = d; }
  516. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  517. };
  518. var Subscriber_1 = __webpack_require__(3);
  519. /**
  520. * Applies a given `project` function to each value emitted by the source
  521. * Observable, and emits the resulting values as an Observable.
  522. *
  523. * <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
  524. * it passes each source value through a transformation function to get
  525. * corresponding output values.</span>
  526. *
  527. * <img src="./img/map.png" width="100%">
  528. *
  529. * Similar to the well known `Array.prototype.map` function, this operator
  530. * applies a projection to each value and emits that projection in the output
  531. * Observable.
  532. *
  533. * @example <caption>Map every click to the clientX position of that click</caption>
  534. * var clicks = Rx.Observable.fromEvent(document, 'click');
  535. * var positions = clicks.map(ev => ev.clientX);
  536. * positions.subscribe(x => console.log(x));
  537. *
  538. * @see {@link mapTo}
  539. * @see {@link pluck}
  540. *
  541. * @param {function(value: T, index: number): R} project The function to apply
  542. * to each `value` emitted by the source Observable. The `index` parameter is
  543. * the number `i` for the i-th emission that has happened since the
  544. * subscription, starting from the number `0`.
  545. * @param {any} [thisArg] An optional argument to define what `this` is in the
  546. * `project` function.
  547. * @return {Observable<R>} An Observable that emits the values from the source
  548. * Observable transformed by the given `project` function.
  549. * @method map
  550. * @owner Observable
  551. */
  552. function map(project, thisArg) {
  553. return function mapOperation(source) {
  554. if (typeof project !== 'function') {
  555. throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
  556. }
  557. return source.lift(new MapOperator(project, thisArg));
  558. };
  559. }
  560. exports.map = map;
  561. var MapOperator = (function () {
  562. function MapOperator(project, thisArg) {
  563. this.project = project;
  564. this.thisArg = thisArg;
  565. }
  566. MapOperator.prototype.call = function (subscriber, source) {
  567. return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
  568. };
  569. return MapOperator;
  570. }());
  571. exports.MapOperator = MapOperator;
  572. /**
  573. * We need this JSDoc comment for affecting ESDoc.
  574. * @ignore
  575. * @extends {Ignored}
  576. */
  577. var MapSubscriber = (function (_super) {
  578. __extends(MapSubscriber, _super);
  579. function MapSubscriber(destination, project, thisArg) {
  580. _super.call(this, destination);
  581. this.project = project;
  582. this.count = 0;
  583. this.thisArg = thisArg || this;
  584. }
  585. // NOTE: This looks unoptimized, but it's actually purposefully NOT
  586. // using try/catch optimizations.
  587. MapSubscriber.prototype._next = function (value) {
  588. var result;
  589. try {
  590. result = this.project.call(this.thisArg, value, this.count++);
  591. }
  592. catch (err) {
  593. this.destination.error(err);
  594. return;
  595. }
  596. this.destination.next(result);
  597. };
  598. return MapSubscriber;
  599. }(Subscriber_1.Subscriber));
  600. //# sourceMappingURL=map.js.map
  601. /***/ }),
  602. /* 3 */
  603. /***/ (function(module, exports, __webpack_require__) {
  604. "use strict";
  605. var __extends = (this && this.__extends) || function (d, b) {
  606. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  607. function __() { this.constructor = d; }
  608. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  609. };
  610. var isFunction_1 = __webpack_require__(42);
  611. var Subscription_1 = __webpack_require__(12);
  612. var Observer_1 = __webpack_require__(57);
  613. var rxSubscriber_1 = __webpack_require__(44);
  614. /**
  615. * Implements the {@link Observer} interface and extends the
  616. * {@link Subscription} class. While the {@link Observer} is the public API for
  617. * consuming the values of an {@link Observable}, all Observers get converted to
  618. * a Subscriber, in order to provide Subscription-like capabilities such as
  619. * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
  620. * implementing operators, but it is rarely used as a public API.
  621. *
  622. * @class Subscriber<T>
  623. */
  624. var Subscriber = (function (_super) {
  625. __extends(Subscriber, _super);
  626. /**
  627. * @param {Observer|function(value: T): void} [destinationOrNext] A partially
  628. * defined Observer or a `next` callback function.
  629. * @param {function(e: ?any): void} [error] The `error` callback of an
  630. * Observer.
  631. * @param {function(): void} [complete] The `complete` callback of an
  632. * Observer.
  633. */
  634. function Subscriber(destinationOrNext, error, complete) {
  635. _super.call(this);
  636. this.syncErrorValue = null;
  637. this.syncErrorThrown = false;
  638. this.syncErrorThrowable = false;
  639. this.isStopped = false;
  640. switch (arguments.length) {
  641. case 0:
  642. this.destination = Observer_1.empty;
  643. break;
  644. case 1:
  645. if (!destinationOrNext) {
  646. this.destination = Observer_1.empty;
  647. break;
  648. }
  649. if (typeof destinationOrNext === 'object') {
  650. // HACK(benlesh): To resolve an issue where Node users may have multiple
  651. // copies of rxjs in their node_modules directory.
  652. if (isTrustedSubscriber(destinationOrNext)) {
  653. var trustedSubscriber = destinationOrNext[rxSubscriber_1.rxSubscriber]();
  654. this.syncErrorThrowable = trustedSubscriber.syncErrorThrowable;
  655. this.destination = trustedSubscriber;
  656. trustedSubscriber.add(this);
  657. }
  658. else {
  659. this.syncErrorThrowable = true;
  660. this.destination = new SafeSubscriber(this, destinationOrNext);
  661. }
  662. break;
  663. }
  664. default:
  665. this.syncErrorThrowable = true;
  666. this.destination = new SafeSubscriber(this, destinationOrNext, error, complete);
  667. break;
  668. }
  669. }
  670. Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function () { return this; };
  671. /**
  672. * A static factory for a Subscriber, given a (potentially partial) definition
  673. * of an Observer.
  674. * @param {function(x: ?T): void} [next] The `next` callback of an Observer.
  675. * @param {function(e: ?any): void} [error] The `error` callback of an
  676. * Observer.
  677. * @param {function(): void} [complete] The `complete` callback of an
  678. * Observer.
  679. * @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
  680. * Observer represented by the given arguments.
  681. */
  682. Subscriber.create = function (next, error, complete) {
  683. var subscriber = new Subscriber(next, error, complete);
  684. subscriber.syncErrorThrowable = false;
  685. return subscriber;
  686. };
  687. /**
  688. * The {@link Observer} callback to receive notifications of type `next` from
  689. * the Observable, with a value. The Observable may call this method 0 or more
  690. * times.
  691. * @param {T} [value] The `next` value.
  692. * @return {void}
  693. */
  694. Subscriber.prototype.next = function (value) {
  695. if (!this.isStopped) {
  696. this._next(value);
  697. }
  698. };
  699. /**
  700. * The {@link Observer} callback to receive notifications of type `error` from
  701. * the Observable, with an attached {@link Error}. Notifies the Observer that
  702. * the Observable has experienced an error condition.
  703. * @param {any} [err] The `error` exception.
  704. * @return {void}
  705. */
  706. Subscriber.prototype.error = function (err) {
  707. if (!this.isStopped) {
  708. this.isStopped = true;
  709. this._error(err);
  710. }
  711. };
  712. /**
  713. * The {@link Observer} callback to receive a valueless notification of type
  714. * `complete` from the Observable. Notifies the Observer that the Observable
  715. * has finished sending push-based notifications.
  716. * @return {void}
  717. */
  718. Subscriber.prototype.complete = function () {
  719. if (!this.isStopped) {
  720. this.isStopped = true;
  721. this._complete();
  722. }
  723. };
  724. Subscriber.prototype.unsubscribe = function () {
  725. if (this.closed) {
  726. return;
  727. }
  728. this.isStopped = true;
  729. _super.prototype.unsubscribe.call(this);
  730. };
  731. Subscriber.prototype._next = function (value) {
  732. this.destination.next(value);
  733. };
  734. Subscriber.prototype._error = function (err) {
  735. this.destination.error(err);
  736. this.unsubscribe();
  737. };
  738. Subscriber.prototype._complete = function () {
  739. this.destination.complete();
  740. this.unsubscribe();
  741. };
  742. /** @deprecated internal use only */ Subscriber.prototype._unsubscribeAndRecycle = function () {
  743. var _a = this, _parent = _a._parent, _parents = _a._parents;
  744. this._parent = null;
  745. this._parents = null;
  746. this.unsubscribe();
  747. this.closed = false;
  748. this.isStopped = false;
  749. this._parent = _parent;
  750. this._parents = _parents;
  751. return this;
  752. };
  753. return Subscriber;
  754. }(Subscription_1.Subscription));
  755. exports.Subscriber = Subscriber;
  756. /**
  757. * We need this JSDoc comment for affecting ESDoc.
  758. * @ignore
  759. * @extends {Ignored}
  760. */
  761. var SafeSubscriber = (function (_super) {
  762. __extends(SafeSubscriber, _super);
  763. function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
  764. _super.call(this);
  765. this._parentSubscriber = _parentSubscriber;
  766. var next;
  767. var context = this;
  768. if (isFunction_1.isFunction(observerOrNext)) {
  769. next = observerOrNext;
  770. }
  771. else if (observerOrNext) {
  772. next = observerOrNext.next;
  773. error = observerOrNext.error;
  774. complete = observerOrNext.complete;
  775. if (observerOrNext !== Observer_1.empty) {
  776. context = Object.create(observerOrNext);
  777. if (isFunction_1.isFunction(context.unsubscribe)) {
  778. this.add(context.unsubscribe.bind(context));
  779. }
  780. context.unsubscribe = this.unsubscribe.bind(this);
  781. }
  782. }
  783. this._context = context;
  784. this._next = next;
  785. this._error = error;
  786. this._complete = complete;
  787. }
  788. SafeSubscriber.prototype.next = function (value) {
  789. if (!this.isStopped && this._next) {
  790. var _parentSubscriber = this._parentSubscriber;
  791. if (!_parentSubscriber.syncErrorThrowable) {
  792. this.__tryOrUnsub(this._next, value);
  793. }
  794. else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
  795. this.unsubscribe();
  796. }
  797. }
  798. };
  799. SafeSubscriber.prototype.error = function (err) {
  800. if (!this.isStopped) {
  801. var _parentSubscriber = this._parentSubscriber;
  802. if (this._error) {
  803. if (!_parentSubscriber.syncErrorThrowable) {
  804. this.__tryOrUnsub(this._error, err);
  805. this.unsubscribe();
  806. }
  807. else {
  808. this.__tryOrSetError(_parentSubscriber, this._error, err);
  809. this.unsubscribe();
  810. }
  811. }
  812. else if (!_parentSubscriber.syncErrorThrowable) {
  813. this.unsubscribe();
  814. throw err;
  815. }
  816. else {
  817. _parentSubscriber.syncErrorValue = err;
  818. _parentSubscriber.syncErrorThrown = true;
  819. this.unsubscribe();
  820. }
  821. }
  822. };
  823. SafeSubscriber.prototype.complete = function () {
  824. var _this = this;
  825. if (!this.isStopped) {
  826. var _parentSubscriber = this._parentSubscriber;
  827. if (this._complete) {
  828. var wrappedComplete = function () { return _this._complete.call(_this._context); };
  829. if (!_parentSubscriber.syncErrorThrowable) {
  830. this.__tryOrUnsub(wrappedComplete);
  831. this.unsubscribe();
  832. }
  833. else {
  834. this.__tryOrSetError(_parentSubscriber, wrappedComplete);
  835. this.unsubscribe();
  836. }
  837. }
  838. else {
  839. this.unsubscribe();
  840. }
  841. }
  842. };
  843. SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
  844. try {
  845. fn.call(this._context, value);
  846. }
  847. catch (err) {
  848. this.unsubscribe();
  849. throw err;
  850. }
  851. };
  852. SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
  853. try {
  854. fn.call(this._context, value);
  855. }
  856. catch (err) {
  857. parent.syncErrorValue = err;
  858. parent.syncErrorThrown = true;
  859. return true;
  860. }
  861. return false;
  862. };
  863. /** @deprecated internal use only */ SafeSubscriber.prototype._unsubscribe = function () {
  864. var _parentSubscriber = this._parentSubscriber;
  865. this._context = null;
  866. this._parentSubscriber = null;
  867. _parentSubscriber.unsubscribe();
  868. };
  869. return SafeSubscriber;
  870. }(Subscriber));
  871. function isTrustedSubscriber(obj) {
  872. return obj instanceof Subscriber || ('syncErrorThrowable' in obj && obj[rxSubscriber_1.rxSubscriber]);
  873. }
  874. //# sourceMappingURL=Subscriber.js.map
  875. /***/ }),
  876. /* 4 */
  877. /***/ (function(module, exports, __webpack_require__) {
  878. "use strict";
  879. var __extends = (this && this.__extends) || function (d, b) {
  880. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  881. function __() { this.constructor = d; }
  882. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  883. };
  884. var Subscriber_1 = __webpack_require__(3);
  885. /* tslint:enable:max-line-length */
  886. /**
  887. * Filter items emitted by the source Observable by only emitting those that
  888. * satisfy a specified predicate.
  889. *
  890. * <span class="informal">Like
  891. * [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
  892. * it only emits a value from the source if it passes a criterion function.</span>
  893. *
  894. * <img src="./img/filter.png" width="100%">
  895. *
  896. * Similar to the well-known `Array.prototype.filter` method, this operator
  897. * takes values from the source Observable, passes them through a `predicate`
  898. * function and only emits those values that yielded `true`.
  899. *
  900. * @example <caption>Emit only click events whose target was a DIV element</caption>
  901. * var clicks = Rx.Observable.fromEvent(document, 'click');
  902. * var clicksOnDivs = clicks.filter(ev => ev.target.tagName === 'DIV');
  903. * clicksOnDivs.subscribe(x => console.log(x));
  904. *
  905. * @see {@link distinct}
  906. * @see {@link distinctUntilChanged}
  907. * @see {@link distinctUntilKeyChanged}
  908. * @see {@link ignoreElements}
  909. * @see {@link partition}
  910. * @see {@link skip}
  911. *
  912. * @param {function(value: T, index: number): boolean} predicate A function that
  913. * evaluates each value emitted by the source Observable. If it returns `true`,
  914. * the value is emitted, if `false` the value is not passed to the output
  915. * Observable. The `index` parameter is the number `i` for the i-th source
  916. * emission that has happened since the subscription, starting from the number
  917. * `0`.
  918. * @param {any} [thisArg] An optional argument to determine the value of `this`
  919. * in the `predicate` function.
  920. * @return {Observable} An Observable of values from the source that were
  921. * allowed by the `predicate` function.
  922. * @method filter
  923. * @owner Observable
  924. */
  925. function filter(predicate, thisArg) {
  926. return function filterOperatorFunction(source) {
  927. return source.lift(new FilterOperator(predicate, thisArg));
  928. };
  929. }
  930. exports.filter = filter;
  931. var FilterOperator = (function () {
  932. function FilterOperator(predicate, thisArg) {
  933. this.predicate = predicate;
  934. this.thisArg = thisArg;
  935. }
  936. FilterOperator.prototype.call = function (subscriber, source) {
  937. return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
  938. };
  939. return FilterOperator;
  940. }());
  941. /**
  942. * We need this JSDoc comment for affecting ESDoc.
  943. * @ignore
  944. * @extends {Ignored}
  945. */
  946. var FilterSubscriber = (function (_super) {
  947. __extends(FilterSubscriber, _super);
  948. function FilterSubscriber(destination, predicate, thisArg) {
  949. _super.call(this, destination);
  950. this.predicate = predicate;
  951. this.thisArg = thisArg;
  952. this.count = 0;
  953. }
  954. // the try catch block below is left specifically for
  955. // optimization and perf reasons. a tryCatcher is not necessary here.
  956. FilterSubscriber.prototype._next = function (value) {
  957. var result;
  958. try {
  959. result = this.predicate.call(this.thisArg, value, this.count++);
  960. }
  961. catch (err) {
  962. this.destination.error(err);
  963. return;
  964. }
  965. if (result) {
  966. this.destination.next(value);
  967. }
  968. };
  969. return FilterSubscriber;
  970. }(Subscriber_1.Subscriber));
  971. //# sourceMappingURL=filter.js.map
  972. /***/ }),
  973. /* 5 */
  974. /***/ (function(module, exports, __webpack_require__) {
  975. "use strict";
  976. var __extends = (this && this.__extends) || function (d, b) {
  977. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  978. function __() { this.constructor = d; }
  979. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  980. };
  981. var Subscriber_1 = __webpack_require__(3);
  982. /* tslint:enable:max-line-length */
  983. /**
  984. * Perform a side effect for every emission on the source Observable, but return
  985. * an Observable that is identical to the source.
  986. *
  987. * <span class="informal">Intercepts each emission on the source and runs a
  988. * function, but returns an output which is identical to the source as long as errors don't occur.</span>
  989. *
  990. * <img src="./img/do.png" width="100%">
  991. *
  992. * Returns a mirrored Observable of the source Observable, but modified so that
  993. * the provided Observer is called to perform a side effect for every value,
  994. * error, and completion emitted by the source. Any errors that are thrown in
  995. * the aforementioned Observer or handlers are safely sent down the error path
  996. * of the output Observable.
  997. *
  998. * This operator is useful for debugging your Observables for the correct values
  999. * or performing other side effects.
  1000. *
  1001. * Note: this is different to a `subscribe` on the Observable. If the Observable
  1002. * returned by `do` is not subscribed, the side effects specified by the
  1003. * Observer will never happen. `do` therefore simply spies on existing
  1004. * execution, it does not trigger an execution to happen like `subscribe` does.
  1005. *
  1006. * @example <caption>Map every click to the clientX position of that click, while also logging the click event</caption>
  1007. * var clicks = Rx.Observable.fromEvent(document, 'click');
  1008. * var positions = clicks
  1009. * .do(ev => console.log(ev))
  1010. * .map(ev => ev.clientX);
  1011. * positions.subscribe(x => console.log(x));
  1012. *
  1013. * @see {@link map}
  1014. * @see {@link subscribe}
  1015. *
  1016. * @param {Observer|function} [nextOrObserver] A normal Observer object or a
  1017. * callback for `next`.
  1018. * @param {function} [error] Callback for errors in the source.
  1019. * @param {function} [complete] Callback for the completion of the source.
  1020. * @return {Observable} An Observable identical to the source, but runs the
  1021. * specified Observer or callback(s) for each item.
  1022. * @name tap
  1023. */
  1024. function tap(nextOrObserver, error, complete) {
  1025. return function tapOperatorFunction(source) {
  1026. return source.lift(new DoOperator(nextOrObserver, error, complete));
  1027. };
  1028. }
  1029. exports.tap = tap;
  1030. var DoOperator = (function () {
  1031. function DoOperator(nextOrObserver, error, complete) {
  1032. this.nextOrObserver = nextOrObserver;
  1033. this.error = error;
  1034. this.complete = complete;
  1035. }
  1036. DoOperator.prototype.call = function (subscriber, source) {
  1037. return source.subscribe(new DoSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
  1038. };
  1039. return DoOperator;
  1040. }());
  1041. /**
  1042. * We need this JSDoc comment for affecting ESDoc.
  1043. * @ignore
  1044. * @extends {Ignored}
  1045. */
  1046. var DoSubscriber = (function (_super) {
  1047. __extends(DoSubscriber, _super);
  1048. function DoSubscriber(destination, nextOrObserver, error, complete) {
  1049. _super.call(this, destination);
  1050. var safeSubscriber = new Subscriber_1.Subscriber(nextOrObserver, error, complete);
  1051. safeSubscriber.syncErrorThrowable = true;
  1052. this.add(safeSubscriber);
  1053. this.safeSubscriber = safeSubscriber;
  1054. }
  1055. DoSubscriber.prototype._next = function (value) {
  1056. var safeSubscriber = this.safeSubscriber;
  1057. safeSubscriber.next(value);
  1058. if (safeSubscriber.syncErrorThrown) {
  1059. this.destination.error(safeSubscriber.syncErrorValue);
  1060. }
  1061. else {
  1062. this.destination.next(value);
  1063. }
  1064. };
  1065. DoSubscriber.prototype._error = function (err) {
  1066. var safeSubscriber = this.safeSubscriber;
  1067. safeSubscriber.error(err);
  1068. if (safeSubscriber.syncErrorThrown) {
  1069. this.destination.error(safeSubscriber.syncErrorValue);
  1070. }
  1071. else {
  1072. this.destination.error(err);
  1073. }
  1074. };
  1075. DoSubscriber.prototype._complete = function () {
  1076. var safeSubscriber = this.safeSubscriber;
  1077. safeSubscriber.complete();
  1078. if (safeSubscriber.syncErrorThrown) {
  1079. this.destination.error(safeSubscriber.syncErrorValue);
  1080. }
  1081. else {
  1082. this.destination.complete();
  1083. }
  1084. };
  1085. return DoSubscriber;
  1086. }(Subscriber_1.Subscriber));
  1087. //# sourceMappingURL=tap.js.map
  1088. /***/ }),
  1089. /* 6 */
  1090. /***/ (function(module, exports, __webpack_require__) {
  1091. "use strict";
  1092. var map_1 = __webpack_require__(2);
  1093. /**
  1094. * Maps each source value (an object) to its specified nested property.
  1095. *
  1096. * <span class="informal">Like {@link map}, but meant only for picking one of
  1097. * the nested properties of every emitted object.</span>
  1098. *
  1099. * <img src="./img/pluck.png" width="100%">
  1100. *
  1101. * Given a list of strings describing a path to an object property, retrieves
  1102. * the value of a specified nested property from all values in the source
  1103. * Observable. If a property can't be resolved, it will return `undefined` for
  1104. * that value.
  1105. *
  1106. * @example <caption>Map every click to the tagName of the clicked target element</caption>
  1107. * var clicks = Rx.Observable.fromEvent(document, 'click');
  1108. * var tagNames = clicks.pluck('target', 'tagName');
  1109. * tagNames.subscribe(x => console.log(x));
  1110. *
  1111. * @see {@link map}
  1112. *
  1113. * @param {...string} properties The nested properties to pluck from each source
  1114. * value (an object).
  1115. * @return {Observable} A new Observable of property values from the source values.
  1116. * @method pluck
  1117. * @owner Observable
  1118. */
  1119. function pluck() {
  1120. var properties = [];
  1121. for (var _i = 0; _i < arguments.length; _i++) {
  1122. properties[_i - 0] = arguments[_i];
  1123. }
  1124. var length = properties.length;
  1125. if (length === 0) {
  1126. throw new Error('list of properties cannot be empty.');
  1127. }
  1128. return function (source) { return map_1.map(plucker(properties, length))(source); };
  1129. }
  1130. exports.pluck = pluck;
  1131. function plucker(props, length) {
  1132. var mapper = function (x) {
  1133. var currentProp = x;
  1134. for (var i = 0; i < length; i++) {
  1135. var p = currentProp[props[i]];
  1136. if (typeof p !== 'undefined') {
  1137. currentProp = p;
  1138. }
  1139. else {
  1140. return undefined;
  1141. }
  1142. }
  1143. return currentProp;
  1144. };
  1145. return mapper;
  1146. }
  1147. //# sourceMappingURL=pluck.js.map
  1148. /***/ }),
  1149. /* 7 */
  1150. /***/ (function(module, exports, __webpack_require__) {
  1151. "use strict";
  1152. /* WEBPACK VAR INJECTION */(function(global) {
  1153. // CommonJS / Node have global context exposed as "global" variable.
  1154. // We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
  1155. // the global "global" var for now.
  1156. var __window = typeof window !== 'undefined' && window;
  1157. var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
  1158. self instanceof WorkerGlobalScope && self;
  1159. var __global = typeof global !== 'undefined' && global;
  1160. var _root = __window || __global || __self;
  1161. exports.root = _root;
  1162. // Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
  1163. // This is needed when used with angular/tsickle which inserts a goog.module statement.
  1164. // Wrap in IIFE
  1165. (function () {
  1166. if (!_root) {
  1167. throw new Error('RxJS could not find any global context (window, self, global)');
  1168. }
  1169. })();
  1170. //# sourceMappingURL=root.js.map
  1171. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24)))
  1172. /***/ }),
  1173. /* 8 */
  1174. /***/ (function(module, exports, __webpack_require__) {
  1175. "use strict";
  1176. Object.defineProperty(exports, "__esModule", { value: true });
  1177. var _a;
  1178. var BehaviorSubject_1 = __webpack_require__(13);
  1179. var set_options_effect_1 = __webpack_require__(53);
  1180. var file_reload_effect_1 = __webpack_require__(86);
  1181. var browser_set_location_effect_1 = __webpack_require__(89);
  1182. var simulate_click_effect_1 = __webpack_require__(90);
  1183. var set_element_value_effect_1 = __webpack_require__(91);
  1184. var set_element_toggle_value_effect_1 = __webpack_require__(92);
  1185. var set_scroll_1 = __webpack_require__(153);
  1186. var browser_reload_effect_1 = __webpack_require__(93);
  1187. var EffectNames;
  1188. (function (EffectNames) {
  1189. EffectNames["FileReload"] = "@@FileReload";
  1190. EffectNames["PreBrowserReload"] = "@@PreBrowserReload";
  1191. EffectNames["BrowserReload"] = "@@BrowserReload";
  1192. EffectNames["BrowserSetLocation"] = "@@BrowserSetLocation";
  1193. EffectNames["BrowserSetScroll"] = "@@BrowserSetScroll";
  1194. EffectNames["SetOptions"] = "@@SetOptions";
  1195. EffectNames["SimulateClick"] = "@@SimulateClick";
  1196. EffectNames["SetElementValue"] = "@@SetElementValue";
  1197. EffectNames["SetElementToggleValue"] = "@@SetElementToggleValue";
  1198. })(EffectNames = exports.EffectNames || (exports.EffectNames = {}));
  1199. exports.effectOutputHandlers$ = new BehaviorSubject_1.BehaviorSubject((_a = {},
  1200. _a[EffectNames.SetOptions] = set_options_effect_1.setOptionsEffect,
  1201. _a[EffectNames.FileReload] = file_reload_effect_1.fileReloadEffect,
  1202. _a[EffectNames.BrowserReload] = browser_reload_effect_1.browserReloadEffect,
  1203. _a[EffectNames.BrowserSetLocation] = browser_set_location_effect_1.browserSetLocationEffect,
  1204. _a[EffectNames.SimulateClick] = simulate_click_effect_1.simulateClickEffect,
  1205. _a[EffectNames.SetElementValue] = set_element_value_effect_1.setElementValueEffect,
  1206. _a[EffectNames.SetElementToggleValue] = set_element_toggle_value_effect_1.setElementToggleValueEffect,
  1207. _a[EffectNames.BrowserSetScroll] = set_scroll_1.setScrollEffect,
  1208. _a));
  1209. /***/ }),
  1210. /* 9 */
  1211. /***/ (function(module, exports, __webpack_require__) {
  1212. "use strict";
  1213. var ArrayObservable_1 = __webpack_require__(23);
  1214. exports.of = ArrayObservable_1.ArrayObservable.of;
  1215. //# sourceMappingURL=of.js.map
  1216. /***/ }),
  1217. /* 10 */
  1218. /***/ (function(module, exports, __webpack_require__) {
  1219. "use strict";
  1220. var __assign = (this && this.__assign) || function () {
  1221. __assign = Object.assign || function(t) {
  1222. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1223. s = arguments[i];
  1224. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1225. t[p] = s[p];
  1226. }
  1227. return t;
  1228. };
  1229. return __assign.apply(this, arguments);
  1230. };
  1231. Object.defineProperty(exports, "__esModule", { value: true });
  1232. var _a;
  1233. var BehaviorSubject_1 = __webpack_require__(13);
  1234. var withLatestFrom_1 = __webpack_require__(0);
  1235. var ignoreElements_1 = __webpack_require__(11);
  1236. var tap_1 = __webpack_require__(5);
  1237. var pluck_1 = __webpack_require__(6);
  1238. var ScrollEvent_1 = __webpack_require__(85);
  1239. var ClickEvent_1 = __webpack_require__(94);
  1240. var KeyupEvent_1 = __webpack_require__(95);
  1241. var BrowserNotify_1 = __webpack_require__(156);
  1242. var BrowserLocation_1 = __webpack_require__(157);
  1243. var BrowserReload_1 = __webpack_require__(96);
  1244. var FileReload_1 = __webpack_require__(165);
  1245. var Connection_1 = __webpack_require__(166);
  1246. var Disconnect_1 = __webpack_require__(167);
  1247. var FormToggleEvent_1 = __webpack_require__(98);
  1248. var OptionsSet_1 = __webpack_require__(168);
  1249. var IncomingSocketNames;
  1250. (function (IncomingSocketNames) {
  1251. IncomingSocketNames["Connection"] = "connection";
  1252. IncomingSocketNames["Disconnect"] = "disconnect";
  1253. IncomingSocketNames["FileReload"] = "file:reload";
  1254. IncomingSocketNames["BrowserReload"] = "browser:reload";
  1255. IncomingSocketNames["BrowserLocation"] = "browser:location";
  1256. IncomingSocketNames["BrowserNotify"] = "browser:notify";
  1257. IncomingSocketNames["Scroll"] = "scroll";
  1258. IncomingSocketNames["Click"] = "click";
  1259. IncomingSocketNames["Keyup"] = "input:text";
  1260. IncomingSocketNames["InputToggle"] = "input:toggles";
  1261. IncomingSocketNames["OptionsSet"] = "options:set";
  1262. })(IncomingSocketNames = exports.IncomingSocketNames || (exports.IncomingSocketNames = {}));
  1263. var OutgoingSocketEvents;
  1264. (function (OutgoingSocketEvents) {
  1265. OutgoingSocketEvents["Scroll"] = "@@outgoing/scroll";
  1266. OutgoingSocketEvents["Click"] = "@@outgoing/click";
  1267. OutgoingSocketEvents["Keyup"] = "@@outgoing/keyup";
  1268. OutgoingSocketEvents["InputToggle"] = "@@outgoing/Toggle";
  1269. })(OutgoingSocketEvents = exports.OutgoingSocketEvents || (exports.OutgoingSocketEvents = {}));
  1270. exports.socketHandlers$ = new BehaviorSubject_1.BehaviorSubject((_a = {},
  1271. _a[IncomingSocketNames.Connection] = Connection_1.incomingConnection,
  1272. _a[IncomingSocketNames.Disconnect] = Disconnect_1.incomingDisconnect,
  1273. _a[IncomingSocketNames.FileReload] = FileReload_1.incomingFileReload,
  1274. _a[IncomingSocketNames.BrowserReload] = BrowserReload_1.incomingBrowserReload,
  1275. _a[IncomingSocketNames.BrowserLocation] = BrowserLocation_1.incomingBrowserLocation,
  1276. _a[IncomingSocketNames.BrowserNotify] = BrowserNotify_1.incomingBrowserNotify,
  1277. _a[IncomingSocketNames.Scroll] = ScrollEvent_1.incomingScrollHandler,
  1278. _a[IncomingSocketNames.Click] = ClickEvent_1.incomingHandler$,
  1279. _a[IncomingSocketNames.Keyup] = KeyupEvent_1.incomingKeyupHandler,
  1280. _a[IncomingSocketNames.InputToggle] = FormToggleEvent_1.incomingInputsToggles,
  1281. _a[IncomingSocketNames.OptionsSet] = OptionsSet_1.incomingOptionsSet,
  1282. _a[OutgoingSocketEvents.Scroll] = emitWithPathname(IncomingSocketNames.Scroll),
  1283. _a[OutgoingSocketEvents.Click] = emitWithPathname(IncomingSocketNames.Click),
  1284. _a[OutgoingSocketEvents.Keyup] = emitWithPathname(IncomingSocketNames.Keyup),
  1285. _a[OutgoingSocketEvents.InputToggle] = emitWithPathname(IncomingSocketNames.InputToggle),
  1286. _a));
  1287. function emitWithPathname(name) {
  1288. return function (xs, inputs) {
  1289. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.io$, inputs.window$.pipe(pluck_1.pluck("location", "pathname"))), tap_1.tap(function (_a) {
  1290. var event = _a[0], io = _a[1], pathname = _a[2];
  1291. return io.emit(name, __assign({}, event, { pathname: pathname }));
  1292. }), ignoreElements_1.ignoreElements());
  1293. };
  1294. }
  1295. /***/ }),
  1296. /* 11 */
  1297. /***/ (function(module, exports, __webpack_require__) {
  1298. "use strict";
  1299. var __extends = (this && this.__extends) || function (d, b) {
  1300. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1301. function __() { this.constructor = d; }
  1302. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1303. };
  1304. var Subscriber_1 = __webpack_require__(3);
  1305. var noop_1 = __webpack_require__(58);
  1306. /**
  1307. * Ignores all items emitted by the source Observable and only passes calls of `complete` or `error`.
  1308. *
  1309. * <img src="./img/ignoreElements.png" width="100%">
  1310. *
  1311. * @return {Observable} An empty Observable that only calls `complete`
  1312. * or `error`, based on which one is called by the source Observable.
  1313. * @method ignoreElements
  1314. * @owner Observable
  1315. */
  1316. function ignoreElements() {
  1317. return function ignoreElementsOperatorFunction(source) {
  1318. return source.lift(new IgnoreElementsOperator());
  1319. };
  1320. }
  1321. exports.ignoreElements = ignoreElements;
  1322. var IgnoreElementsOperator = (function () {
  1323. function IgnoreElementsOperator() {
  1324. }
  1325. IgnoreElementsOperator.prototype.call = function (subscriber, source) {
  1326. return source.subscribe(new IgnoreElementsSubscriber(subscriber));
  1327. };
  1328. return IgnoreElementsOperator;
  1329. }());
  1330. /**
  1331. * We need this JSDoc comment for affecting ESDoc.
  1332. * @ignore
  1333. * @extends {Ignored}
  1334. */
  1335. var IgnoreElementsSubscriber = (function (_super) {
  1336. __extends(IgnoreElementsSubscriber, _super);
  1337. function IgnoreElementsSubscriber() {
  1338. _super.apply(this, arguments);
  1339. }
  1340. IgnoreElementsSubscriber.prototype._next = function (unused) {
  1341. noop_1.noop();
  1342. };
  1343. return IgnoreElementsSubscriber;
  1344. }(Subscriber_1.Subscriber));
  1345. //# sourceMappingURL=ignoreElements.js.map
  1346. /***/ }),
  1347. /* 12 */
  1348. /***/ (function(module, exports, __webpack_require__) {
  1349. "use strict";
  1350. var isArray_1 = __webpack_require__(26);
  1351. var isObject_1 = __webpack_require__(56);
  1352. var isFunction_1 = __webpack_require__(42);
  1353. var tryCatch_1 = __webpack_require__(43);
  1354. var errorObject_1 = __webpack_require__(27);
  1355. var UnsubscriptionError_1 = __webpack_require__(104);
  1356. /**
  1357. * Represents a disposable resource, such as the execution of an Observable. A
  1358. * Subscription has one important method, `unsubscribe`, that takes no argument
  1359. * and just disposes the resource held by the subscription.
  1360. *
  1361. * Additionally, subscriptions may be grouped together through the `add()`
  1362. * method, which will attach a child Subscription to the current Subscription.
  1363. * When a Subscription is unsubscribed, all its children (and its grandchildren)
  1364. * will be unsubscribed as well.
  1365. *
  1366. * @class Subscription
  1367. */
  1368. var Subscription = (function () {
  1369. /**
  1370. * @param {function(): void} [unsubscribe] A function describing how to
  1371. * perform the disposal of resources when the `unsubscribe` method is called.
  1372. */
  1373. function Subscription(unsubscribe) {
  1374. /**
  1375. * A flag to indicate whether this Subscription has already been unsubscribed.
  1376. * @type {boolean}
  1377. */
  1378. this.closed = false;
  1379. this._parent = null;
  1380. this._parents = null;
  1381. this._subscriptions = null;
  1382. if (unsubscribe) {
  1383. this._unsubscribe = unsubscribe;
  1384. }
  1385. }
  1386. /**
  1387. * Disposes the resources held by the subscription. May, for instance, cancel
  1388. * an ongoing Observable execution or cancel any other type of work that
  1389. * started when the Subscription was created.
  1390. * @return {void}
  1391. */
  1392. Subscription.prototype.unsubscribe = function () {
  1393. var hasErrors = false;
  1394. var errors;
  1395. if (this.closed) {
  1396. return;
  1397. }
  1398. var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
  1399. this.closed = true;
  1400. this._parent = null;
  1401. this._parents = null;
  1402. // null out _subscriptions first so any child subscriptions that attempt
  1403. // to remove themselves from this subscription will noop
  1404. this._subscriptions = null;
  1405. var index = -1;
  1406. var len = _parents ? _parents.length : 0;
  1407. // if this._parent is null, then so is this._parents, and we
  1408. // don't have to remove ourselves from any parent subscriptions.
  1409. while (_parent) {
  1410. _parent.remove(this);
  1411. // if this._parents is null or index >= len,
  1412. // then _parent is set to null, and the loop exits
  1413. _parent = ++index < len && _parents[index] || null;
  1414. }
  1415. if (isFunction_1.isFunction(_unsubscribe)) {
  1416. var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
  1417. if (trial === errorObject_1.errorObject) {
  1418. hasErrors = true;
  1419. errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ?
  1420. flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]);
  1421. }
  1422. }
  1423. if (isArray_1.isArray(_subscriptions)) {
  1424. index = -1;
  1425. len = _subscriptions.length;
  1426. while (++index < len) {
  1427. var sub = _subscriptions[index];
  1428. if (isObject_1.isObject(sub)) {
  1429. var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
  1430. if (trial === errorObject_1.errorObject) {
  1431. hasErrors = true;
  1432. errors = errors || [];
  1433. var err = errorObject_1.errorObject.e;
  1434. if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
  1435. errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
  1436. }
  1437. else {
  1438. errors.push(err);
  1439. }
  1440. }
  1441. }
  1442. }
  1443. }
  1444. if (hasErrors) {
  1445. throw new UnsubscriptionError_1.UnsubscriptionError(errors);
  1446. }
  1447. };
  1448. /**
  1449. * Adds a tear down to be called during the unsubscribe() of this
  1450. * Subscription.
  1451. *
  1452. * If the tear down being added is a subscription that is already
  1453. * unsubscribed, is the same reference `add` is being called on, or is
  1454. * `Subscription.EMPTY`, it will not be added.
  1455. *
  1456. * If this subscription is already in an `closed` state, the passed
  1457. * tear down logic will be executed immediately.
  1458. *
  1459. * @param {TeardownLogic} teardown The additional logic to execute on
  1460. * teardown.
  1461. * @return {Subscription} Returns the Subscription used or created to be
  1462. * added to the inner subscriptions list. This Subscription can be used with
  1463. * `remove()` to remove the passed teardown logic from the inner subscriptions
  1464. * list.
  1465. */
  1466. Subscription.prototype.add = function (teardown) {
  1467. if (!teardown || (teardown === Subscription.EMPTY)) {
  1468. return Subscription.EMPTY;
  1469. }
  1470. if (teardown === this) {
  1471. return this;
  1472. }
  1473. var subscription = teardown;
  1474. switch (typeof teardown) {
  1475. case 'function':
  1476. subscription = new Subscription(teardown);
  1477. case 'object':
  1478. if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
  1479. return subscription;
  1480. }
  1481. else if (this.closed) {
  1482. subscription.unsubscribe();
  1483. return subscription;
  1484. }
  1485. else if (typeof subscription._addParent !== 'function' /* quack quack */) {
  1486. var tmp = subscription;
  1487. subscription = new Subscription();
  1488. subscription._subscriptions = [tmp];
  1489. }
  1490. break;
  1491. default:
  1492. throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
  1493. }
  1494. var subscriptions = this._subscriptions || (this._subscriptions = []);
  1495. subscriptions.push(subscription);
  1496. subscription._addParent(this);
  1497. return subscription;
  1498. };
  1499. /**
  1500. * Removes a Subscription from the internal list of subscriptions that will
  1501. * unsubscribe during the unsubscribe process of this Subscription.
  1502. * @param {Subscription} subscription The subscription to remove.
  1503. * @return {void}
  1504. */
  1505. Subscription.prototype.remove = function (subscription) {
  1506. var subscriptions = this._subscriptions;
  1507. if (subscriptions) {
  1508. var subscriptionIndex = subscriptions.indexOf(subscription);
  1509. if (subscriptionIndex !== -1) {
  1510. subscriptions.splice(subscriptionIndex, 1);
  1511. }
  1512. }
  1513. };
  1514. Subscription.prototype._addParent = function (parent) {
  1515. var _a = this, _parent = _a._parent, _parents = _a._parents;
  1516. if (!_parent || _parent === parent) {
  1517. // If we don't have a parent, or the new parent is the same as the
  1518. // current parent, then set this._parent to the new parent.
  1519. this._parent = parent;
  1520. }
  1521. else if (!_parents) {
  1522. // If there's already one parent, but not multiple, allocate an Array to
  1523. // store the rest of the parent Subscriptions.
  1524. this._parents = [parent];
  1525. }
  1526. else if (_parents.indexOf(parent) === -1) {
  1527. // Only add the new parent to the _parents list if it's not already there.
  1528. _parents.push(parent);
  1529. }
  1530. };
  1531. Subscription.EMPTY = (function (empty) {
  1532. empty.closed = true;
  1533. return empty;
  1534. }(new Subscription()));
  1535. return Subscription;
  1536. }());
  1537. exports.Subscription = Subscription;
  1538. function flattenUnsubscriptionErrors(errors) {
  1539. return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
  1540. }
  1541. //# sourceMappingURL=Subscription.js.map
  1542. /***/ }),
  1543. /* 13 */
  1544. /***/ (function(module, exports, __webpack_require__) {
  1545. "use strict";
  1546. var __extends = (this && this.__extends) || function (d, b) {
  1547. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1548. function __() { this.constructor = d; }
  1549. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1550. };
  1551. var Subject_1 = __webpack_require__(37);
  1552. var ObjectUnsubscribedError_1 = __webpack_require__(73);
  1553. /**
  1554. * @class BehaviorSubject<T>
  1555. */
  1556. var BehaviorSubject = (function (_super) {
  1557. __extends(BehaviorSubject, _super);
  1558. function BehaviorSubject(_value) {
  1559. _super.call(this);
  1560. this._value = _value;
  1561. }
  1562. Object.defineProperty(BehaviorSubject.prototype, "value", {
  1563. get: function () {
  1564. return this.getValue();
  1565. },
  1566. enumerable: true,
  1567. configurable: true
  1568. });
  1569. /** @deprecated internal use only */ BehaviorSubject.prototype._subscribe = function (subscriber) {
  1570. var subscription = _super.prototype._subscribe.call(this, subscriber);
  1571. if (subscription && !subscription.closed) {
  1572. subscriber.next(this._value);
  1573. }
  1574. return subscription;
  1575. };
  1576. BehaviorSubject.prototype.getValue = function () {
  1577. if (this.hasError) {
  1578. throw this.thrownError;
  1579. }
  1580. else if (this.closed) {
  1581. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  1582. }
  1583. else {
  1584. return this._value;
  1585. }
  1586. };
  1587. BehaviorSubject.prototype.next = function (value) {
  1588. _super.prototype.next.call(this, this._value = value);
  1589. };
  1590. return BehaviorSubject;
  1591. }(Subject_1.Subject));
  1592. exports.BehaviorSubject = BehaviorSubject;
  1593. //# sourceMappingURL=BehaviorSubject.js.map
  1594. /***/ }),
  1595. /* 14 */
  1596. /***/ (function(module, exports, __webpack_require__) {
  1597. "use strict";
  1598. Object.defineProperty(exports, "__esModule", { value: true });
  1599. var _a;
  1600. var BehaviorSubject_1 = __webpack_require__(13);
  1601. var timer_1 = __webpack_require__(52);
  1602. var of_1 = __webpack_require__(9);
  1603. var logger_1 = __webpack_require__(142);
  1604. var filter_1 = __webpack_require__(4);
  1605. var tap_1 = __webpack_require__(5);
  1606. var withLatestFrom_1 = __webpack_require__(0);
  1607. var switchMap_1 = __webpack_require__(20);
  1608. var pluck_1 = __webpack_require__(6);
  1609. function initLogger(options) {
  1610. var log = new logger_1.Nanologger(options.logPrefix || "", {
  1611. colors: { magenta: "#0F2634" }
  1612. });
  1613. return of_1.of(log);
  1614. }
  1615. exports.initLogger = initLogger;
  1616. var LogNames;
  1617. (function (LogNames) {
  1618. LogNames["Log"] = "@@Log";
  1619. LogNames["Info"] = "@@Log.info";
  1620. LogNames["Debug"] = "@@Log.debug";
  1621. })(LogNames = exports.LogNames || (exports.LogNames = {}));
  1622. var Overlay;
  1623. (function (Overlay) {
  1624. Overlay["Info"] = "@@Overlay.info";
  1625. })(Overlay = exports.Overlay || (exports.Overlay = {}));
  1626. function consoleInfo() {
  1627. var args = [];
  1628. for (var _i = 0; _i < arguments.length; _i++) {
  1629. args[_i] = arguments[_i];
  1630. }
  1631. return [LogNames.Log, [LogNames.Info, args]];
  1632. }
  1633. exports.consoleInfo = consoleInfo;
  1634. function consoleDebug() {
  1635. var args = [];
  1636. for (var _i = 0; _i < arguments.length; _i++) {
  1637. args[_i] = arguments[_i];
  1638. }
  1639. return [LogNames.Log, [LogNames.Debug, args]];
  1640. }
  1641. exports.consoleDebug = consoleDebug;
  1642. function overlayInfo(message, timeout) {
  1643. if (timeout === void 0) { timeout = 2000; }
  1644. return [Overlay.Info, [message, timeout]];
  1645. }
  1646. exports.overlayInfo = overlayInfo;
  1647. exports.logHandler$ = new BehaviorSubject_1.BehaviorSubject((_a = {},
  1648. _a[LogNames.Log] = function (xs, inputs) {
  1649. return xs.pipe(
  1650. /**
  1651. * access injectNotification from the options stream
  1652. */
  1653. withLatestFrom_1.withLatestFrom(inputs.logInstance$, inputs.option$.pipe(pluck_1.pluck("injectNotification"))),
  1654. /**
  1655. * only accept messages if injectNotification !== console
  1656. */
  1657. filter_1.filter(function (_a) {
  1658. var injectNotification = _a[2];
  1659. return injectNotification === "console";
  1660. }), tap_1.tap(function (_a) {
  1661. var event = _a[0], log = _a[1];
  1662. switch (event[0]) {
  1663. case LogNames.Info: {
  1664. return log.info.apply(log, event[1]);
  1665. }
  1666. case LogNames.Debug: {
  1667. return log.debug.apply(log, event[1]);
  1668. }
  1669. }
  1670. }));
  1671. },
  1672. _a[Overlay.Info] = function (xs, inputs) {
  1673. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$, inputs.notifyElement$, inputs.document$),
  1674. /**
  1675. * Reject all notifications if notify: false
  1676. */
  1677. filter_1.filter(function (_a) {
  1678. var options = _a[1];
  1679. return Boolean(options.notify);
  1680. }),
  1681. /**
  1682. * Set the HTML of the notify element
  1683. */
  1684. tap_1.tap(function (_a) {
  1685. var event = _a[0], options = _a[1], element = _a[2], document = _a[3];
  1686. element.innerHTML = event[0];
  1687. element.style.display = "block";
  1688. document.body.appendChild(element);
  1689. }),
  1690. /**
  1691. * Now remove the element after the given timeout
  1692. */
  1693. switchMap_1.switchMap(function (_a) {
  1694. var event = _a[0], options = _a[1], element = _a[2], document = _a[3];
  1695. return timer_1.timer(event[1] || 2000).pipe(tap_1.tap(function () {
  1696. element.style.display = "none";
  1697. if (element.parentNode) {
  1698. document.body.removeChild(element);
  1699. }
  1700. }));
  1701. }));
  1702. },
  1703. _a));
  1704. /***/ }),
  1705. /* 15 */
  1706. /***/ (function(module, exports, __webpack_require__) {
  1707. "use strict";
  1708. var __extends = (this && this.__extends) || function (d, b) {
  1709. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1710. function __() { this.constructor = d; }
  1711. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1712. };
  1713. var subscribeToResult_1 = __webpack_require__(30);
  1714. var OuterSubscriber_1 = __webpack_require__(29);
  1715. /* tslint:enable:max-line-length */
  1716. /**
  1717. * Projects each source value to an Observable which is merged in the output
  1718. * Observable.
  1719. *
  1720. * <span class="informal">Maps each value to an Observable, then flattens all of
  1721. * these inner Observables using {@link mergeAll}.</span>
  1722. *
  1723. * <img src="./img/mergeMap.png" width="100%">
  1724. *
  1725. * Returns an Observable that emits items based on applying a function that you
  1726. * supply to each item emitted by the source Observable, where that function
  1727. * returns an Observable, and then merging those resulting Observables and
  1728. * emitting the results of this merger.
  1729. *
  1730. * @example <caption>Map and flatten each letter to an Observable ticking every 1 second</caption>
  1731. * var letters = Rx.Observable.of('a', 'b', 'c');
  1732. * var result = letters.mergeMap(x =>
  1733. * Rx.Observable.interval(1000).map(i => x+i)
  1734. * );
  1735. * result.subscribe(x => console.log(x));
  1736. *
  1737. * // Results in the following:
  1738. * // a0
  1739. * // b0
  1740. * // c0
  1741. * // a1
  1742. * // b1
  1743. * // c1
  1744. * // continues to list a,b,c with respective ascending integers
  1745. *
  1746. * @see {@link concatMap}
  1747. * @see {@link exhaustMap}
  1748. * @see {@link merge}
  1749. * @see {@link mergeAll}
  1750. * @see {@link mergeMapTo}
  1751. * @see {@link mergeScan}
  1752. * @see {@link switchMap}
  1753. *
  1754. * @param {function(value: T, ?index: number): ObservableInput} project A function
  1755. * that, when applied to an item emitted by the source Observable, returns an
  1756. * Observable.
  1757. * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
  1758. * A function to produce the value on the output Observable based on the values
  1759. * and the indices of the source (outer) emission and the inner Observable
  1760. * emission. The arguments passed to this function are:
  1761. * - `outerValue`: the value that came from the source
  1762. * - `innerValue`: the value that came from the projected Observable
  1763. * - `outerIndex`: the "index" of the value that came from the source
  1764. * - `innerIndex`: the "index" of the value from the projected Observable
  1765. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
  1766. * Observables being subscribed to concurrently.
  1767. * @return {Observable} An Observable that emits the result of applying the
  1768. * projection function (and the optional `resultSelector`) to each item emitted
  1769. * by the source Observable and merging the results of the Observables obtained
  1770. * from this transformation.
  1771. * @method mergeMap
  1772. * @owner Observable
  1773. */
  1774. function mergeMap(project, resultSelector, concurrent) {
  1775. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  1776. return function mergeMapOperatorFunction(source) {
  1777. if (typeof resultSelector === 'number') {
  1778. concurrent = resultSelector;
  1779. resultSelector = null;
  1780. }
  1781. return source.lift(new MergeMapOperator(project, resultSelector, concurrent));
  1782. };
  1783. }
  1784. exports.mergeMap = mergeMap;
  1785. var MergeMapOperator = (function () {
  1786. function MergeMapOperator(project, resultSelector, concurrent) {
  1787. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  1788. this.project = project;
  1789. this.resultSelector = resultSelector;
  1790. this.concurrent = concurrent;
  1791. }
  1792. MergeMapOperator.prototype.call = function (observer, source) {
  1793. return source.subscribe(new MergeMapSubscriber(observer, this.project, this.resultSelector, this.concurrent));
  1794. };
  1795. return MergeMapOperator;
  1796. }());
  1797. exports.MergeMapOperator = MergeMapOperator;
  1798. /**
  1799. * We need this JSDoc comment for affecting ESDoc.
  1800. * @ignore
  1801. * @extends {Ignored}
  1802. */
  1803. var MergeMapSubscriber = (function (_super) {
  1804. __extends(MergeMapSubscriber, _super);
  1805. function MergeMapSubscriber(destination, project, resultSelector, concurrent) {
  1806. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  1807. _super.call(this, destination);
  1808. this.project = project;
  1809. this.resultSelector = resultSelector;
  1810. this.concurrent = concurrent;
  1811. this.hasCompleted = false;
  1812. this.buffer = [];
  1813. this.active = 0;
  1814. this.index = 0;
  1815. }
  1816. MergeMapSubscriber.prototype._next = function (value) {
  1817. if (this.active < this.concurrent) {
  1818. this._tryNext(value);
  1819. }
  1820. else {
  1821. this.buffer.push(value);
  1822. }
  1823. };
  1824. MergeMapSubscriber.prototype._tryNext = function (value) {
  1825. var result;
  1826. var index = this.index++;
  1827. try {
  1828. result = this.project(value, index);
  1829. }
  1830. catch (err) {
  1831. this.destination.error(err);
  1832. return;
  1833. }
  1834. this.active++;
  1835. this._innerSub(result, value, index);
  1836. };
  1837. MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
  1838. this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index));
  1839. };
  1840. MergeMapSubscriber.prototype._complete = function () {
  1841. this.hasCompleted = true;
  1842. if (this.active === 0 && this.buffer.length === 0) {
  1843. this.destination.complete();
  1844. }
  1845. };
  1846. MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  1847. if (this.resultSelector) {
  1848. this._notifyResultSelector(outerValue, innerValue, outerIndex, innerIndex);
  1849. }
  1850. else {
  1851. this.destination.next(innerValue);
  1852. }
  1853. };
  1854. MergeMapSubscriber.prototype._notifyResultSelector = function (outerValue, innerValue, outerIndex, innerIndex) {
  1855. var result;
  1856. try {
  1857. result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex);
  1858. }
  1859. catch (err) {
  1860. this.destination.error(err);
  1861. return;
  1862. }
  1863. this.destination.next(result);
  1864. };
  1865. MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
  1866. var buffer = this.buffer;
  1867. this.remove(innerSub);
  1868. this.active--;
  1869. if (buffer.length > 0) {
  1870. this._next(buffer.shift());
  1871. }
  1872. else if (this.active === 0 && this.hasCompleted) {
  1873. this.destination.complete();
  1874. }
  1875. };
  1876. return MergeMapSubscriber;
  1877. }(OuterSubscriber_1.OuterSubscriber));
  1878. exports.MergeMapSubscriber = MergeMapSubscriber;
  1879. //# sourceMappingURL=mergeMap.js.map
  1880. /***/ }),
  1881. /* 16 */
  1882. /***/ (function(module, exports, __webpack_require__) {
  1883. "use strict";
  1884. var EmptyObservable_1 = __webpack_require__(28);
  1885. exports.empty = EmptyObservable_1.EmptyObservable.create;
  1886. //# sourceMappingURL=empty.js.map
  1887. /***/ }),
  1888. /* 17 */
  1889. /***/ (function(module, exports, __webpack_require__) {
  1890. /**
  1891. * Expose `Emitter`.
  1892. */
  1893. if (true) {
  1894. module.exports = Emitter;
  1895. }
  1896. /**
  1897. * Initialize a new `Emitter`.
  1898. *
  1899. * @api public
  1900. */
  1901. function Emitter(obj) {
  1902. if (obj) return mixin(obj);
  1903. };
  1904. /**
  1905. * Mixin the emitter properties.
  1906. *
  1907. * @param {Object} obj
  1908. * @return {Object}
  1909. * @api private
  1910. */
  1911. function mixin(obj) {
  1912. for (var key in Emitter.prototype) {
  1913. obj[key] = Emitter.prototype[key];
  1914. }
  1915. return obj;
  1916. }
  1917. /**
  1918. * Listen on the given `event` with `fn`.
  1919. *
  1920. * @param {String} event
  1921. * @param {Function} fn
  1922. * @return {Emitter}
  1923. * @api public
  1924. */
  1925. Emitter.prototype.on =
  1926. Emitter.prototype.addEventListener = function(event, fn){
  1927. this._callbacks = this._callbacks || {};
  1928. (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
  1929. .push(fn);
  1930. return this;
  1931. };
  1932. /**
  1933. * Adds an `event` listener that will be invoked a single
  1934. * time then automatically removed.
  1935. *
  1936. * @param {String} event
  1937. * @param {Function} fn
  1938. * @return {Emitter}
  1939. * @api public
  1940. */
  1941. Emitter.prototype.once = function(event, fn){
  1942. function on() {
  1943. this.off(event, on);
  1944. fn.apply(this, arguments);
  1945. }
  1946. on.fn = fn;
  1947. this.on(event, on);
  1948. return this;
  1949. };
  1950. /**
  1951. * Remove the given callback for `event` or all
  1952. * registered callbacks.
  1953. *
  1954. * @param {String} event
  1955. * @param {Function} fn
  1956. * @return {Emitter}
  1957. * @api public
  1958. */
  1959. Emitter.prototype.off =
  1960. Emitter.prototype.removeListener =
  1961. Emitter.prototype.removeAllListeners =
  1962. Emitter.prototype.removeEventListener = function(event, fn){
  1963. this._callbacks = this._callbacks || {};
  1964. // all
  1965. if (0 == arguments.length) {
  1966. this._callbacks = {};
  1967. return this;
  1968. }
  1969. // specific event
  1970. var callbacks = this._callbacks['$' + event];
  1971. if (!callbacks) return this;
  1972. // remove all handlers
  1973. if (1 == arguments.length) {
  1974. delete this._callbacks['$' + event];
  1975. return this;
  1976. }
  1977. // remove specific handler
  1978. var cb;
  1979. for (var i = 0; i < callbacks.length; i++) {
  1980. cb = callbacks[i];
  1981. if (cb === fn || cb.fn === fn) {
  1982. callbacks.splice(i, 1);
  1983. break;
  1984. }
  1985. }
  1986. return this;
  1987. };
  1988. /**
  1989. * Emit `event` with the given args.
  1990. *
  1991. * @param {String} event
  1992. * @param {Mixed} ...
  1993. * @return {Emitter}
  1994. */
  1995. Emitter.prototype.emit = function(event){
  1996. this._callbacks = this._callbacks || {};
  1997. var args = [].slice.call(arguments, 1)
  1998. , callbacks = this._callbacks['$' + event];
  1999. if (callbacks) {
  2000. callbacks = callbacks.slice(0);
  2001. for (var i = 0, len = callbacks.length; i < len; ++i) {
  2002. callbacks[i].apply(this, args);
  2003. }
  2004. }
  2005. return this;
  2006. };
  2007. /**
  2008. * Return array of callbacks for `event`.
  2009. *
  2010. * @param {String} event
  2011. * @return {Array}
  2012. * @api public
  2013. */
  2014. Emitter.prototype.listeners = function(event){
  2015. this._callbacks = this._callbacks || {};
  2016. return this._callbacks['$' + event] || [];
  2017. };
  2018. /**
  2019. * Check if this emitter has `event` handlers.
  2020. *
  2021. * @param {String} event
  2022. * @return {Boolean}
  2023. * @api public
  2024. */
  2025. Emitter.prototype.hasListeners = function(event){
  2026. return !! this.listeners(event).length;
  2027. };
  2028. /***/ }),
  2029. /* 18 */
  2030. /***/ (function(module, exports, __webpack_require__) {
  2031. /**
  2032. * Module dependencies.
  2033. */
  2034. var keys = __webpack_require__(121);
  2035. var hasBinary = __webpack_require__(67);
  2036. var sliceBuffer = __webpack_require__(123);
  2037. var after = __webpack_require__(124);
  2038. var utf8 = __webpack_require__(125);
  2039. var base64encoder;
  2040. if (typeof ArrayBuffer !== 'undefined') {
  2041. base64encoder = __webpack_require__(126);
  2042. }
  2043. /**
  2044. * Check if we are running an android browser. That requires us to use
  2045. * ArrayBuffer with polling transports...
  2046. *
  2047. * http://ghinda.net/jpeg-blob-ajax-android/
  2048. */
  2049. var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
  2050. /**
  2051. * Check if we are running in PhantomJS.
  2052. * Uploading a Blob with PhantomJS does not work correctly, as reported here:
  2053. * https://github.com/ariya/phantomjs/issues/11395
  2054. * @type boolean
  2055. */
  2056. var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
  2057. /**
  2058. * When true, avoids using Blobs to encode payloads.
  2059. * @type boolean
  2060. */
  2061. var dontSendBlobs = isAndroid || isPhantomJS;
  2062. /**
  2063. * Current protocol version.
  2064. */
  2065. exports.protocol = 3;
  2066. /**
  2067. * Packet types.
  2068. */
  2069. var packets = exports.packets = {
  2070. open: 0 // non-ws
  2071. , close: 1 // non-ws
  2072. , ping: 2
  2073. , pong: 3
  2074. , message: 4
  2075. , upgrade: 5
  2076. , noop: 6
  2077. };
  2078. var packetslist = keys(packets);
  2079. /**
  2080. * Premade error packet.
  2081. */
  2082. var err = { type: 'error', data: 'parser error' };
  2083. /**
  2084. * Create a blob api even for blob builder when vendor prefixes exist
  2085. */
  2086. var Blob = __webpack_require__(127);
  2087. /**
  2088. * Encodes a packet.
  2089. *
  2090. * <packet type id> [ <data> ]
  2091. *
  2092. * Example:
  2093. *
  2094. * 5hello world
  2095. * 3
  2096. * 4
  2097. *
  2098. * Binary is encoded in an identical principle
  2099. *
  2100. * @api private
  2101. */
  2102. exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
  2103. if (typeof supportsBinary === 'function') {
  2104. callback = supportsBinary;
  2105. supportsBinary = false;
  2106. }
  2107. if (typeof utf8encode === 'function') {
  2108. callback = utf8encode;
  2109. utf8encode = null;
  2110. }
  2111. var data = (packet.data === undefined)
  2112. ? undefined
  2113. : packet.data.buffer || packet.data;
  2114. if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) {
  2115. return encodeArrayBuffer(packet, supportsBinary, callback);
  2116. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  2117. return encodeBlob(packet, supportsBinary, callback);
  2118. }
  2119. // might be an object with { base64: true, data: dataAsBase64String }
  2120. if (data && data.base64) {
  2121. return encodeBase64Object(packet, callback);
  2122. }
  2123. // Sending data as a utf-8 string
  2124. var encoded = packets[packet.type];
  2125. // data fragment is optional
  2126. if (undefined !== packet.data) {
  2127. encoded += utf8encode ? utf8.encode(String(packet.data), { strict: false }) : String(packet.data);
  2128. }
  2129. return callback('' + encoded);
  2130. };
  2131. function encodeBase64Object(packet, callback) {
  2132. // packet data is an object { base64: true, data: dataAsBase64String }
  2133. var message = 'b' + exports.packets[packet.type] + packet.data.data;
  2134. return callback(message);
  2135. }
  2136. /**
  2137. * Encode packet helpers for binary types
  2138. */
  2139. function encodeArrayBuffer(packet, supportsBinary, callback) {
  2140. if (!supportsBinary) {
  2141. return exports.encodeBase64Packet(packet, callback);
  2142. }
  2143. var data = packet.data;
  2144. var contentArray = new Uint8Array(data);
  2145. var resultBuffer = new Uint8Array(1 + data.byteLength);
  2146. resultBuffer[0] = packets[packet.type];
  2147. for (var i = 0; i < contentArray.length; i++) {
  2148. resultBuffer[i+1] = contentArray[i];
  2149. }
  2150. return callback(resultBuffer.buffer);
  2151. }
  2152. function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
  2153. if (!supportsBinary) {
  2154. return exports.encodeBase64Packet(packet, callback);
  2155. }
  2156. var fr = new FileReader();
  2157. fr.onload = function() {
  2158. exports.encodePacket({ type: packet.type, data: fr.result }, supportsBinary, true, callback);
  2159. };
  2160. return fr.readAsArrayBuffer(packet.data);
  2161. }
  2162. function encodeBlob(packet, supportsBinary, callback) {
  2163. if (!supportsBinary) {
  2164. return exports.encodeBase64Packet(packet, callback);
  2165. }
  2166. if (dontSendBlobs) {
  2167. return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
  2168. }
  2169. var length = new Uint8Array(1);
  2170. length[0] = packets[packet.type];
  2171. var blob = new Blob([length.buffer, packet.data]);
  2172. return callback(blob);
  2173. }
  2174. /**
  2175. * Encodes a packet with binary data in a base64 string
  2176. *
  2177. * @param {Object} packet, has `type` and `data`
  2178. * @return {String} base64 encoded message
  2179. */
  2180. exports.encodeBase64Packet = function(packet, callback) {
  2181. var message = 'b' + exports.packets[packet.type];
  2182. if (typeof Blob !== 'undefined' && packet.data instanceof Blob) {
  2183. var fr = new FileReader();
  2184. fr.onload = function() {
  2185. var b64 = fr.result.split(',')[1];
  2186. callback(message + b64);
  2187. };
  2188. return fr.readAsDataURL(packet.data);
  2189. }
  2190. var b64data;
  2191. try {
  2192. b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
  2193. } catch (e) {
  2194. // iPhone Safari doesn't let you apply with typed arrays
  2195. var typed = new Uint8Array(packet.data);
  2196. var basic = new Array(typed.length);
  2197. for (var i = 0; i < typed.length; i++) {
  2198. basic[i] = typed[i];
  2199. }
  2200. b64data = String.fromCharCode.apply(null, basic);
  2201. }
  2202. message += btoa(b64data);
  2203. return callback(message);
  2204. };
  2205. /**
  2206. * Decodes a packet. Changes format to Blob if requested.
  2207. *
  2208. * @return {Object} with `type` and `data` (if any)
  2209. * @api private
  2210. */
  2211. exports.decodePacket = function (data, binaryType, utf8decode) {
  2212. if (data === undefined) {
  2213. return err;
  2214. }
  2215. // String data
  2216. if (typeof data === 'string') {
  2217. if (data.charAt(0) === 'b') {
  2218. return exports.decodeBase64Packet(data.substr(1), binaryType);
  2219. }
  2220. if (utf8decode) {
  2221. data = tryDecode(data);
  2222. if (data === false) {
  2223. return err;
  2224. }
  2225. }
  2226. var type = data.charAt(0);
  2227. if (Number(type) != type || !packetslist[type]) {
  2228. return err;
  2229. }
  2230. if (data.length > 1) {
  2231. return { type: packetslist[type], data: data.substring(1) };
  2232. } else {
  2233. return { type: packetslist[type] };
  2234. }
  2235. }
  2236. var asArray = new Uint8Array(data);
  2237. var type = asArray[0];
  2238. var rest = sliceBuffer(data, 1);
  2239. if (Blob && binaryType === 'blob') {
  2240. rest = new Blob([rest]);
  2241. }
  2242. return { type: packetslist[type], data: rest };
  2243. };
  2244. function tryDecode(data) {
  2245. try {
  2246. data = utf8.decode(data, { strict: false });
  2247. } catch (e) {
  2248. return false;
  2249. }
  2250. return data;
  2251. }
  2252. /**
  2253. * Decodes a packet encoded in a base64 string
  2254. *
  2255. * @param {String} base64 encoded message
  2256. * @return {Object} with `type` and `data` (if any)
  2257. */
  2258. exports.decodeBase64Packet = function(msg, binaryType) {
  2259. var type = packetslist[msg.charAt(0)];
  2260. if (!base64encoder) {
  2261. return { type: type, data: { base64: true, data: msg.substr(1) } };
  2262. }
  2263. var data = base64encoder.decode(msg.substr(1));
  2264. if (binaryType === 'blob' && Blob) {
  2265. data = new Blob([data]);
  2266. }
  2267. return { type: type, data: data };
  2268. };
  2269. /**
  2270. * Encodes multiple messages (payload).
  2271. *
  2272. * <length>:data
  2273. *
  2274. * Example:
  2275. *
  2276. * 11:hello world2:hi
  2277. *
  2278. * If any contents are binary, they will be encoded as base64 strings. Base64
  2279. * encoded strings are marked with a b before the length specifier
  2280. *
  2281. * @param {Array} packets
  2282. * @api private
  2283. */
  2284. exports.encodePayload = function (packets, supportsBinary, callback) {
  2285. if (typeof supportsBinary === 'function') {
  2286. callback = supportsBinary;
  2287. supportsBinary = null;
  2288. }
  2289. var isBinary = hasBinary(packets);
  2290. if (supportsBinary && isBinary) {
  2291. if (Blob && !dontSendBlobs) {
  2292. return exports.encodePayloadAsBlob(packets, callback);
  2293. }
  2294. return exports.encodePayloadAsArrayBuffer(packets, callback);
  2295. }
  2296. if (!packets.length) {
  2297. return callback('0:');
  2298. }
  2299. function setLengthHeader(message) {
  2300. return message.length + ':' + message;
  2301. }
  2302. function encodeOne(packet, doneCallback) {
  2303. exports.encodePacket(packet, !isBinary ? false : supportsBinary, false, function(message) {
  2304. doneCallback(null, setLengthHeader(message));
  2305. });
  2306. }
  2307. map(packets, encodeOne, function(err, results) {
  2308. return callback(results.join(''));
  2309. });
  2310. };
  2311. /**
  2312. * Async array map using after
  2313. */
  2314. function map(ary, each, done) {
  2315. var result = new Array(ary.length);
  2316. var next = after(ary.length, done);
  2317. var eachWithIndex = function(i, el, cb) {
  2318. each(el, function(error, msg) {
  2319. result[i] = msg;
  2320. cb(error, result);
  2321. });
  2322. };
  2323. for (var i = 0; i < ary.length; i++) {
  2324. eachWithIndex(i, ary[i], next);
  2325. }
  2326. }
  2327. /*
  2328. * Decodes data when a payload is maybe expected. Possible binary contents are
  2329. * decoded from their base64 representation
  2330. *
  2331. * @param {String} data, callback method
  2332. * @api public
  2333. */
  2334. exports.decodePayload = function (data, binaryType, callback) {
  2335. if (typeof data !== 'string') {
  2336. return exports.decodePayloadAsBinary(data, binaryType, callback);
  2337. }
  2338. if (typeof binaryType === 'function') {
  2339. callback = binaryType;
  2340. binaryType = null;
  2341. }
  2342. var packet;
  2343. if (data === '') {
  2344. // parser error - ignoring payload
  2345. return callback(err, 0, 1);
  2346. }
  2347. var length = '', n, msg;
  2348. for (var i = 0, l = data.length; i < l; i++) {
  2349. var chr = data.charAt(i);
  2350. if (chr !== ':') {
  2351. length += chr;
  2352. continue;
  2353. }
  2354. if (length === '' || (length != (n = Number(length)))) {
  2355. // parser error - ignoring payload
  2356. return callback(err, 0, 1);
  2357. }
  2358. msg = data.substr(i + 1, n);
  2359. if (length != msg.length) {
  2360. // parser error - ignoring payload
  2361. return callback(err, 0, 1);
  2362. }
  2363. if (msg.length) {
  2364. packet = exports.decodePacket(msg, binaryType, false);
  2365. if (err.type === packet.type && err.data === packet.data) {
  2366. // parser error in individual packet - ignoring payload
  2367. return callback(err, 0, 1);
  2368. }
  2369. var ret = callback(packet, i + n, l);
  2370. if (false === ret) return;
  2371. }
  2372. // advance cursor
  2373. i += n;
  2374. length = '';
  2375. }
  2376. if (length !== '') {
  2377. // parser error - ignoring payload
  2378. return callback(err, 0, 1);
  2379. }
  2380. };
  2381. /**
  2382. * Encodes multiple messages (payload) as binary.
  2383. *
  2384. * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
  2385. * 255><data>
  2386. *
  2387. * Example:
  2388. * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
  2389. *
  2390. * @param {Array} packets
  2391. * @return {ArrayBuffer} encoded payload
  2392. * @api private
  2393. */
  2394. exports.encodePayloadAsArrayBuffer = function(packets, callback) {
  2395. if (!packets.length) {
  2396. return callback(new ArrayBuffer(0));
  2397. }
  2398. function encodeOne(packet, doneCallback) {
  2399. exports.encodePacket(packet, true, true, function(data) {
  2400. return doneCallback(null, data);
  2401. });
  2402. }
  2403. map(packets, encodeOne, function(err, encodedPackets) {
  2404. var totalLength = encodedPackets.reduce(function(acc, p) {
  2405. var len;
  2406. if (typeof p === 'string'){
  2407. len = p.length;
  2408. } else {
  2409. len = p.byteLength;
  2410. }
  2411. return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
  2412. }, 0);
  2413. var resultArray = new Uint8Array(totalLength);
  2414. var bufferIndex = 0;
  2415. encodedPackets.forEach(function(p) {
  2416. var isString = typeof p === 'string';
  2417. var ab = p;
  2418. if (isString) {
  2419. var view = new Uint8Array(p.length);
  2420. for (var i = 0; i < p.length; i++) {
  2421. view[i] = p.charCodeAt(i);
  2422. }
  2423. ab = view.buffer;
  2424. }
  2425. if (isString) { // not true binary
  2426. resultArray[bufferIndex++] = 0;
  2427. } else { // true binary
  2428. resultArray[bufferIndex++] = 1;
  2429. }
  2430. var lenStr = ab.byteLength.toString();
  2431. for (var i = 0; i < lenStr.length; i++) {
  2432. resultArray[bufferIndex++] = parseInt(lenStr[i]);
  2433. }
  2434. resultArray[bufferIndex++] = 255;
  2435. var view = new Uint8Array(ab);
  2436. for (var i = 0; i < view.length; i++) {
  2437. resultArray[bufferIndex++] = view[i];
  2438. }
  2439. });
  2440. return callback(resultArray.buffer);
  2441. });
  2442. };
  2443. /**
  2444. * Encode as Blob
  2445. */
  2446. exports.encodePayloadAsBlob = function(packets, callback) {
  2447. function encodeOne(packet, doneCallback) {
  2448. exports.encodePacket(packet, true, true, function(encoded) {
  2449. var binaryIdentifier = new Uint8Array(1);
  2450. binaryIdentifier[0] = 1;
  2451. if (typeof encoded === 'string') {
  2452. var view = new Uint8Array(encoded.length);
  2453. for (var i = 0; i < encoded.length; i++) {
  2454. view[i] = encoded.charCodeAt(i);
  2455. }
  2456. encoded = view.buffer;
  2457. binaryIdentifier[0] = 0;
  2458. }
  2459. var len = (encoded instanceof ArrayBuffer)
  2460. ? encoded.byteLength
  2461. : encoded.size;
  2462. var lenStr = len.toString();
  2463. var lengthAry = new Uint8Array(lenStr.length + 1);
  2464. for (var i = 0; i < lenStr.length; i++) {
  2465. lengthAry[i] = parseInt(lenStr[i]);
  2466. }
  2467. lengthAry[lenStr.length] = 255;
  2468. if (Blob) {
  2469. var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
  2470. doneCallback(null, blob);
  2471. }
  2472. });
  2473. }
  2474. map(packets, encodeOne, function(err, results) {
  2475. return callback(new Blob(results));
  2476. });
  2477. };
  2478. /*
  2479. * Decodes data when a payload is maybe expected. Strings are decoded by
  2480. * interpreting each byte as a key code for entries marked to start with 0. See
  2481. * description of encodePayloadAsBinary
  2482. *
  2483. * @param {ArrayBuffer} data, callback method
  2484. * @api public
  2485. */
  2486. exports.decodePayloadAsBinary = function (data, binaryType, callback) {
  2487. if (typeof binaryType === 'function') {
  2488. callback = binaryType;
  2489. binaryType = null;
  2490. }
  2491. var bufferTail = data;
  2492. var buffers = [];
  2493. while (bufferTail.byteLength > 0) {
  2494. var tailArray = new Uint8Array(bufferTail);
  2495. var isString = tailArray[0] === 0;
  2496. var msgLength = '';
  2497. for (var i = 1; ; i++) {
  2498. if (tailArray[i] === 255) break;
  2499. // 310 = char length of Number.MAX_VALUE
  2500. if (msgLength.length > 310) {
  2501. return callback(err, 0, 1);
  2502. }
  2503. msgLength += tailArray[i];
  2504. }
  2505. bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
  2506. msgLength = parseInt(msgLength);
  2507. var msg = sliceBuffer(bufferTail, 0, msgLength);
  2508. if (isString) {
  2509. try {
  2510. msg = String.fromCharCode.apply(null, new Uint8Array(msg));
  2511. } catch (e) {
  2512. // iPhone Safari doesn't let you apply to typed arrays
  2513. var typed = new Uint8Array(msg);
  2514. msg = '';
  2515. for (var i = 0; i < typed.length; i++) {
  2516. msg += String.fromCharCode(typed[i]);
  2517. }
  2518. }
  2519. }
  2520. buffers.push(msg);
  2521. bufferTail = sliceBuffer(bufferTail, msgLength);
  2522. }
  2523. var total = buffers.length;
  2524. buffers.forEach(function(buffer, i) {
  2525. callback(exports.decodePacket(buffer, binaryType, true), i, total);
  2526. });
  2527. };
  2528. /***/ }),
  2529. /* 19 */
  2530. /***/ (function(module, exports, __webpack_require__) {
  2531. "use strict";
  2532. Object.defineProperty(exports, "__esModule", { value: true });
  2533. var _a;
  2534. var BehaviorSubject_1 = __webpack_require__(13);
  2535. var prop_set_dom_effect_1 = __webpack_require__(76);
  2536. var style_set_dom_effect_1 = __webpack_require__(81);
  2537. var link_replace_dom_effect_1 = __webpack_require__(82);
  2538. var set_scroll_dom_effect_1 = __webpack_require__(83);
  2539. var set_window_name_dom_effect_1 = __webpack_require__(84);
  2540. var Events;
  2541. (function (Events) {
  2542. Events["PropSet"] = "@@BSDOM.Events.PropSet";
  2543. Events["StyleSet"] = "@@BSDOM.Events.StyleSet";
  2544. Events["LinkReplace"] = "@@BSDOM.Events.LinkReplace";
  2545. Events["SetScroll"] = "@@BSDOM.Events.SetScroll";
  2546. Events["SetWindowName"] = "@@BSDOM.Events.SetWindowName";
  2547. })(Events = exports.Events || (exports.Events = {}));
  2548. exports.domHandlers$ = new BehaviorSubject_1.BehaviorSubject((_a = {},
  2549. _a[Events.PropSet] = prop_set_dom_effect_1.propSetDomEffect,
  2550. _a[Events.StyleSet] = style_set_dom_effect_1.styleSetDomEffect,
  2551. _a[Events.LinkReplace] = link_replace_dom_effect_1.linkReplaceDomEffect,
  2552. _a[Events.SetScroll] = set_scroll_dom_effect_1.setScrollDomEffect,
  2553. _a[Events.SetWindowName] = set_window_name_dom_effect_1.setWindowNameDomEffect,
  2554. _a));
  2555. /***/ }),
  2556. /* 20 */
  2557. /***/ (function(module, exports, __webpack_require__) {
  2558. "use strict";
  2559. var __extends = (this && this.__extends) || function (d, b) {
  2560. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2561. function __() { this.constructor = d; }
  2562. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2563. };
  2564. var OuterSubscriber_1 = __webpack_require__(29);
  2565. var subscribeToResult_1 = __webpack_require__(30);
  2566. /* tslint:enable:max-line-length */
  2567. /**
  2568. * Projects each source value to an Observable which is merged in the output
  2569. * Observable, emitting values only from the most recently projected Observable.
  2570. *
  2571. * <span class="informal">Maps each value to an Observable, then flattens all of
  2572. * these inner Observables using {@link switch}.</span>
  2573. *
  2574. * <img src="./img/switchMap.png" width="100%">
  2575. *
  2576. * Returns an Observable that emits items based on applying a function that you
  2577. * supply to each item emitted by the source Observable, where that function
  2578. * returns an (so-called "inner") Observable. Each time it observes one of these
  2579. * inner Observables, the output Observable begins emitting the items emitted by
  2580. * that inner Observable. When a new inner Observable is emitted, `switchMap`
  2581. * stops emitting items from the earlier-emitted inner Observable and begins
  2582. * emitting items from the new one. It continues to behave like this for
  2583. * subsequent inner Observables.
  2584. *
  2585. * @example <caption>Rerun an interval Observable on every click event</caption>
  2586. * var clicks = Rx.Observable.fromEvent(document, 'click');
  2587. * var result = clicks.switchMap((ev) => Rx.Observable.interval(1000));
  2588. * result.subscribe(x => console.log(x));
  2589. *
  2590. * @see {@link concatMap}
  2591. * @see {@link exhaustMap}
  2592. * @see {@link mergeMap}
  2593. * @see {@link switch}
  2594. * @see {@link switchMapTo}
  2595. *
  2596. * @param {function(value: T, ?index: number): ObservableInput} project A function
  2597. * that, when applied to an item emitted by the source Observable, returns an
  2598. * Observable.
  2599. * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
  2600. * A function to produce the value on the output Observable based on the values
  2601. * and the indices of the source (outer) emission and the inner Observable
  2602. * emission. The arguments passed to this function are:
  2603. * - `outerValue`: the value that came from the source
  2604. * - `innerValue`: the value that came from the projected Observable
  2605. * - `outerIndex`: the "index" of the value that came from the source
  2606. * - `innerIndex`: the "index" of the value from the projected Observable
  2607. * @return {Observable} An Observable that emits the result of applying the
  2608. * projection function (and the optional `resultSelector`) to each item emitted
  2609. * by the source Observable and taking only the values from the most recently
  2610. * projected inner Observable.
  2611. * @method switchMap
  2612. * @owner Observable
  2613. */
  2614. function switchMap(project, resultSelector) {
  2615. return function switchMapOperatorFunction(source) {
  2616. return source.lift(new SwitchMapOperator(project, resultSelector));
  2617. };
  2618. }
  2619. exports.switchMap = switchMap;
  2620. var SwitchMapOperator = (function () {
  2621. function SwitchMapOperator(project, resultSelector) {
  2622. this.project = project;
  2623. this.resultSelector = resultSelector;
  2624. }
  2625. SwitchMapOperator.prototype.call = function (subscriber, source) {
  2626. return source.subscribe(new SwitchMapSubscriber(subscriber, this.project, this.resultSelector));
  2627. };
  2628. return SwitchMapOperator;
  2629. }());
  2630. /**
  2631. * We need this JSDoc comment for affecting ESDoc.
  2632. * @ignore
  2633. * @extends {Ignored}
  2634. */
  2635. var SwitchMapSubscriber = (function (_super) {
  2636. __extends(SwitchMapSubscriber, _super);
  2637. function SwitchMapSubscriber(destination, project, resultSelector) {
  2638. _super.call(this, destination);
  2639. this.project = project;
  2640. this.resultSelector = resultSelector;
  2641. this.index = 0;
  2642. }
  2643. SwitchMapSubscriber.prototype._next = function (value) {
  2644. var result;
  2645. var index = this.index++;
  2646. try {
  2647. result = this.project(value, index);
  2648. }
  2649. catch (error) {
  2650. this.destination.error(error);
  2651. return;
  2652. }
  2653. this._innerSub(result, value, index);
  2654. };
  2655. SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
  2656. var innerSubscription = this.innerSubscription;
  2657. if (innerSubscription) {
  2658. innerSubscription.unsubscribe();
  2659. }
  2660. this.add(this.innerSubscription = subscribeToResult_1.subscribeToResult(this, result, value, index));
  2661. };
  2662. SwitchMapSubscriber.prototype._complete = function () {
  2663. var innerSubscription = this.innerSubscription;
  2664. if (!innerSubscription || innerSubscription.closed) {
  2665. _super.prototype._complete.call(this);
  2666. }
  2667. };
  2668. /** @deprecated internal use only */ SwitchMapSubscriber.prototype._unsubscribe = function () {
  2669. this.innerSubscription = null;
  2670. };
  2671. SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
  2672. this.remove(innerSub);
  2673. this.innerSubscription = null;
  2674. if (this.isStopped) {
  2675. _super.prototype._complete.call(this);
  2676. }
  2677. };
  2678. SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  2679. if (this.resultSelector) {
  2680. this._tryNotifyNext(outerValue, innerValue, outerIndex, innerIndex);
  2681. }
  2682. else {
  2683. this.destination.next(innerValue);
  2684. }
  2685. };
  2686. SwitchMapSubscriber.prototype._tryNotifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
  2687. var result;
  2688. try {
  2689. result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex);
  2690. }
  2691. catch (err) {
  2692. this.destination.error(err);
  2693. return;
  2694. }
  2695. this.destination.next(result);
  2696. };
  2697. return SwitchMapSubscriber;
  2698. }(OuterSubscriber_1.OuterSubscriber));
  2699. //# sourceMappingURL=switchMap.js.map
  2700. /***/ }),
  2701. /* 21 */
  2702. /***/ (function(module, exports, __webpack_require__) {
  2703. "use strict";
  2704. Object.defineProperty(exports, "__esModule", { value: true });
  2705. var concat_1 = __webpack_require__(54);
  2706. var timer_1 = __webpack_require__(52);
  2707. var of_1 = __webpack_require__(9);
  2708. var switchMap_1 = __webpack_require__(20);
  2709. var startWith_1 = __webpack_require__(152);
  2710. var mapTo_1 = __webpack_require__(88);
  2711. function each(incoming) {
  2712. return [].slice.call(incoming || []);
  2713. }
  2714. exports.each = each;
  2715. exports.splitUrl = function (url) {
  2716. var hash, index, params;
  2717. if ((index = url.indexOf("#")) >= 0) {
  2718. hash = url.slice(index);
  2719. url = url.slice(0, index);
  2720. }
  2721. else {
  2722. hash = "";
  2723. }
  2724. if ((index = url.indexOf("?")) >= 0) {
  2725. params = url.slice(index);
  2726. url = url.slice(0, index);
  2727. }
  2728. else {
  2729. params = "";
  2730. }
  2731. return { url: url, params: params, hash: hash };
  2732. };
  2733. exports.pathFromUrl = function (url) {
  2734. var path;
  2735. (url = exports.splitUrl(url).url);
  2736. if (url.indexOf("file://") === 0) {
  2737. path = url.replace(new RegExp("^file://(localhost)?"), "");
  2738. }
  2739. else {
  2740. // http : // hostname :8080 /
  2741. path = url.replace(new RegExp("^([^:]+:)?//([^:/]+)(:\\d*)?/"), "/");
  2742. }
  2743. // decodeURI has special handling of stuff like semicolons, so use decodeURIComponent
  2744. return decodeURIComponent(path);
  2745. };
  2746. exports.pickBestMatch = function (path, objects, pathFunc) {
  2747. var score;
  2748. var bestMatch = { score: 0, object: null };
  2749. objects.forEach(function (object) {
  2750. score = exports.numberOfMatchingSegments(path, pathFunc(object));
  2751. if (score > bestMatch.score) {
  2752. bestMatch = { object: object, score: score };
  2753. }
  2754. });
  2755. if (bestMatch.score > 0) {
  2756. return bestMatch;
  2757. }
  2758. else {
  2759. return null;
  2760. }
  2761. };
  2762. exports.numberOfMatchingSegments = function (path1, path2) {
  2763. path1 = normalisePath(path1);
  2764. path2 = normalisePath(path2);
  2765. if (path1 === path2) {
  2766. return 10000;
  2767. }
  2768. var comps1 = path1.split("/").reverse();
  2769. var comps2 = path2.split("/").reverse();
  2770. var len = Math.min(comps1.length, comps2.length);
  2771. var eqCount = 0;
  2772. while (eqCount < len && comps1[eqCount] === comps2[eqCount]) {
  2773. ++eqCount;
  2774. }
  2775. return eqCount;
  2776. };
  2777. exports.pathsMatch = function (path1, path2) {
  2778. return exports.numberOfMatchingSegments(path1, path2) > 0;
  2779. };
  2780. function getLocation(url) {
  2781. var location = document.createElement("a");
  2782. location.href = url;
  2783. if (location.host === "") {
  2784. location.href = location.href;
  2785. }
  2786. return location;
  2787. }
  2788. exports.getLocation = getLocation;
  2789. /**
  2790. * @param {string} search
  2791. * @param {string} key
  2792. * @param {string} suffix
  2793. */
  2794. function updateSearch(search, key, suffix) {
  2795. if (search === "") {
  2796. return "?" + suffix;
  2797. }
  2798. return ("?" +
  2799. search
  2800. .slice(1)
  2801. .split("&")
  2802. .map(function (item) {
  2803. return item.split("=");
  2804. })
  2805. .filter(function (tuple) {
  2806. return tuple[0] !== key;
  2807. })
  2808. .map(function (item) {
  2809. return [item[0], item[1]].join("=");
  2810. })
  2811. .concat(suffix)
  2812. .join("&"));
  2813. }
  2814. exports.updateSearch = updateSearch;
  2815. var blacklist = [
  2816. // never allow .map files through
  2817. function (incoming) {
  2818. return incoming.ext === "map";
  2819. }
  2820. ];
  2821. /**
  2822. * @param incoming
  2823. * @returns {boolean}
  2824. */
  2825. function isBlacklisted(incoming) {
  2826. return blacklist.some(function (fn) {
  2827. return fn(incoming);
  2828. });
  2829. }
  2830. exports.isBlacklisted = isBlacklisted;
  2831. function createTimedBooleanSwitch(source$, timeout) {
  2832. if (timeout === void 0) { timeout = 1000; }
  2833. return source$.pipe(switchMap_1.switchMap(function () {
  2834. return concat_1.concat(of_1.of(false), timer_1.timer(timeout).pipe(mapTo_1.mapTo(true)));
  2835. }), startWith_1.startWith(true));
  2836. }
  2837. exports.createTimedBooleanSwitch = createTimedBooleanSwitch;
  2838. function array(incoming) {
  2839. return [].slice.call(incoming);
  2840. }
  2841. exports.array = array;
  2842. function normalisePath(path) {
  2843. return path
  2844. .replace(/^\/+/, "")
  2845. .replace(/\\/g, "/")
  2846. .toLowerCase();
  2847. }
  2848. exports.normalisePath = normalisePath;
  2849. /***/ }),
  2850. /* 22 */
  2851. /***/ (function(module, exports, __webpack_require__) {
  2852. "use strict";
  2853. Object.defineProperty(exports, "__esModule", { value: true });
  2854. function getWindow() {
  2855. return window;
  2856. }
  2857. exports.getWindow = getWindow;
  2858. /**
  2859. * @returns {HTMLDocument}
  2860. */
  2861. function getDocument() {
  2862. return document;
  2863. }
  2864. exports.getDocument = getDocument;
  2865. /**
  2866. * Get the current x/y position crossbow
  2867. * @returns {{x: *, y: *}}
  2868. */
  2869. function getBrowserScrollPosition(window, document) {
  2870. var scrollX;
  2871. var scrollY;
  2872. var dElement = document.documentElement;
  2873. var dBody = document.body;
  2874. if (window.pageYOffset !== undefined) {
  2875. scrollX = window.pageXOffset;
  2876. scrollY = window.pageYOffset;
  2877. }
  2878. else {
  2879. scrollX = dElement.scrollLeft || dBody.scrollLeft || 0;
  2880. scrollY = dElement.scrollTop || dBody.scrollTop || 0;
  2881. }
  2882. return {
  2883. x: scrollX,
  2884. y: scrollY
  2885. };
  2886. }
  2887. exports.getBrowserScrollPosition = getBrowserScrollPosition;
  2888. /**
  2889. * @returns {{x: number, y: number}}
  2890. */
  2891. function getDocumentScrollSpace(document) {
  2892. var dElement = document.documentElement;
  2893. var dBody = document.body;
  2894. return {
  2895. x: dBody.scrollHeight - dElement.clientWidth,
  2896. y: dBody.scrollHeight - dElement.clientHeight
  2897. };
  2898. }
  2899. exports.getDocumentScrollSpace = getDocumentScrollSpace;
  2900. /**
  2901. * Saves scroll position into cookies
  2902. */
  2903. function saveScrollPosition(window, document) {
  2904. var pos = getBrowserScrollPosition(window, document);
  2905. document.cookie = "bs_scroll_pos=" + [pos.x, pos.y].join(",");
  2906. }
  2907. exports.saveScrollPosition = saveScrollPosition;
  2908. /**
  2909. * Restores scroll position from cookies
  2910. */
  2911. function restoreScrollPosition() {
  2912. var pos = getDocument()
  2913. .cookie.replace(/(?:(?:^|.*;\s*)bs_scroll_pos\s*\=\s*([^;]*).*$)|^.*$/, "$1")
  2914. .split(",");
  2915. getWindow().scrollTo(Number(pos[0]), Number(pos[1]));
  2916. }
  2917. exports.restoreScrollPosition = restoreScrollPosition;
  2918. /**
  2919. * @param tagName
  2920. * @param elem
  2921. * @returns {*|number}
  2922. */
  2923. function getElementIndex(tagName, elem) {
  2924. var allElems = getDocument().getElementsByTagName(tagName);
  2925. return Array.prototype.indexOf.call(allElems, elem);
  2926. }
  2927. exports.getElementIndex = getElementIndex;
  2928. /**
  2929. * Force Change event on radio & checkboxes (IE)
  2930. */
  2931. function forceChange(elem) {
  2932. elem.blur();
  2933. elem.focus();
  2934. }
  2935. exports.forceChange = forceChange;
  2936. /**
  2937. * @param elem
  2938. * @returns {{tagName: (elem.tagName|*), index: *}}
  2939. */
  2940. function getElementData(elem) {
  2941. var tagName = elem.tagName;
  2942. var index = getElementIndex(tagName, elem);
  2943. return {
  2944. tagName: tagName,
  2945. index: index
  2946. };
  2947. }
  2948. exports.getElementData = getElementData;
  2949. /**
  2950. * @param {string} tagName
  2951. * @param {number} index
  2952. */
  2953. function getSingleElement(tagName, index) {
  2954. var elems = getDocument().getElementsByTagName(tagName);
  2955. return elems[index];
  2956. }
  2957. exports.getSingleElement = getSingleElement;
  2958. /**
  2959. * Get the body element
  2960. */
  2961. function getBody() {
  2962. return getDocument().getElementsByTagName("body")[0];
  2963. }
  2964. exports.getBody = getBody;
  2965. /**
  2966. * @param {{x: number, y: number}} pos
  2967. */
  2968. function setScroll(pos) {
  2969. getWindow().scrollTo(pos.x, pos.y);
  2970. }
  2971. exports.setScroll = setScroll;
  2972. /**
  2973. * Hard reload
  2974. */
  2975. function reloadBrowser() {
  2976. getWindow().location.reload(true);
  2977. }
  2978. exports.reloadBrowser = reloadBrowser;
  2979. /**
  2980. * Foreach polyfill
  2981. * @param coll
  2982. * @param fn
  2983. */
  2984. function forEach(coll, fn) {
  2985. for (var i = 0, n = coll.length; i < n; i += 1) {
  2986. fn(coll[i], i, coll);
  2987. }
  2988. }
  2989. exports.forEach = forEach;
  2990. /**
  2991. * Are we dealing with old IE?
  2992. * @returns {boolean}
  2993. */
  2994. function isOldIe() {
  2995. return typeof getWindow().attachEvent !== "undefined";
  2996. }
  2997. exports.isOldIe = isOldIe;
  2998. /**
  2999. * Split the URL information
  3000. * @returns {object}
  3001. */
  3002. function getLocation(url) {
  3003. var location = getDocument().createElement("a");
  3004. location.href = url;
  3005. if (location.host === "") {
  3006. location.href = location.href;
  3007. }
  3008. return location;
  3009. }
  3010. exports.getLocation = getLocation;
  3011. /**
  3012. * @param {String} val
  3013. * @returns {boolean}
  3014. */
  3015. function isUndefined(val) {
  3016. return "undefined" === typeof val;
  3017. }
  3018. exports.isUndefined = isUndefined;
  3019. /**
  3020. * @param obj
  3021. * @param path
  3022. */
  3023. function getByPath(obj, path) {
  3024. for (var i = 0, tempPath = path.split("."), len = tempPath.length; i < len; i++) {
  3025. if (!obj || typeof obj !== "object") {
  3026. return false;
  3027. }
  3028. obj = obj[tempPath[i]];
  3029. }
  3030. if (typeof obj === "undefined") {
  3031. return false;
  3032. }
  3033. return obj;
  3034. }
  3035. exports.getByPath = getByPath;
  3036. function getScrollPosition(window, document) {
  3037. var pos = getBrowserScrollPosition(window, document);
  3038. return {
  3039. raw: pos,
  3040. proportional: getScrollTopPercentage(pos, document) // Get % of y axis of scroll
  3041. };
  3042. }
  3043. exports.getScrollPosition = getScrollPosition;
  3044. function getScrollPositionForElement(element) {
  3045. var raw = {
  3046. x: element.scrollLeft,
  3047. y: element.scrollTop
  3048. };
  3049. var scrollSpace = {
  3050. x: element.scrollWidth,
  3051. y: element.scrollHeight
  3052. };
  3053. return {
  3054. raw: raw,
  3055. proportional: getScrollPercentage(scrollSpace, raw).y // Get % of y axis of scroll
  3056. };
  3057. }
  3058. exports.getScrollPositionForElement = getScrollPositionForElement;
  3059. function getScrollTopPercentage(pos, document) {
  3060. var scrollSpace = getDocumentScrollSpace(document);
  3061. var percentage = getScrollPercentage(scrollSpace, pos);
  3062. return percentage.y;
  3063. }
  3064. exports.getScrollTopPercentage = getScrollTopPercentage;
  3065. function getScrollPercentage(scrollSpace, scrollPosition) {
  3066. var x = scrollPosition.x / scrollSpace.x;
  3067. var y = scrollPosition.y / scrollSpace.y;
  3068. return {
  3069. x: x || 0,
  3070. y: y
  3071. };
  3072. }
  3073. exports.getScrollPercentage = getScrollPercentage;
  3074. /***/ }),
  3075. /* 23 */
  3076. /***/ (function(module, exports, __webpack_require__) {
  3077. "use strict";
  3078. var __extends = (this && this.__extends) || function (d, b) {
  3079. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3080. function __() { this.constructor = d; }
  3081. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3082. };
  3083. var Observable_1 = __webpack_require__(1);
  3084. var ScalarObservable_1 = __webpack_require__(46);
  3085. var EmptyObservable_1 = __webpack_require__(28);
  3086. var isScheduler_1 = __webpack_require__(25);
  3087. /**
  3088. * We need this JSDoc comment for affecting ESDoc.
  3089. * @extends {Ignored}
  3090. * @hide true
  3091. */
  3092. var ArrayObservable = (function (_super) {
  3093. __extends(ArrayObservable, _super);
  3094. function ArrayObservable(array, scheduler) {
  3095. _super.call(this);
  3096. this.array = array;
  3097. this.scheduler = scheduler;
  3098. if (!scheduler && array.length === 1) {
  3099. this._isScalar = true;
  3100. this.value = array[0];
  3101. }
  3102. }
  3103. ArrayObservable.create = function (array, scheduler) {
  3104. return new ArrayObservable(array, scheduler);
  3105. };
  3106. /**
  3107. * Creates an Observable that emits some values you specify as arguments,
  3108. * immediately one after the other, and then emits a complete notification.
  3109. *
  3110. * <span class="informal">Emits the arguments you provide, then completes.
  3111. * </span>
  3112. *
  3113. * <img src="./img/of.png" width="100%">
  3114. *
  3115. * This static operator is useful for creating a simple Observable that only
  3116. * emits the arguments given, and the complete notification thereafter. It can
  3117. * be used for composing with other Observables, such as with {@link concat}.
  3118. * By default, it uses a `null` IScheduler, which means the `next`
  3119. * notifications are sent synchronously, although with a different IScheduler
  3120. * it is possible to determine when those notifications will be delivered.
  3121. *
  3122. * @example <caption>Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second.</caption>
  3123. * var numbers = Rx.Observable.of(10, 20, 30);
  3124. * var letters = Rx.Observable.of('a', 'b', 'c');
  3125. * var interval = Rx.Observable.interval(1000);
  3126. * var result = numbers.concat(letters).concat(interval);
  3127. * result.subscribe(x => console.log(x));
  3128. *
  3129. * @see {@link create}
  3130. * @see {@link empty}
  3131. * @see {@link never}
  3132. * @see {@link throw}
  3133. *
  3134. * @param {...T} values Arguments that represent `next` values to be emitted.
  3135. * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
  3136. * the emissions of the `next` notifications.
  3137. * @return {Observable<T>} An Observable that emits each given input value.
  3138. * @static true
  3139. * @name of
  3140. * @owner Observable
  3141. */
  3142. ArrayObservable.of = function () {
  3143. var array = [];
  3144. for (var _i = 0; _i < arguments.length; _i++) {
  3145. array[_i - 0] = arguments[_i];
  3146. }
  3147. var scheduler = array[array.length - 1];
  3148. if (isScheduler_1.isScheduler(scheduler)) {
  3149. array.pop();
  3150. }
  3151. else {
  3152. scheduler = null;
  3153. }
  3154. var len = array.length;
  3155. if (len > 1) {
  3156. return new ArrayObservable(array, scheduler);
  3157. }
  3158. else if (len === 1) {
  3159. return new ScalarObservable_1.ScalarObservable(array[0], scheduler);
  3160. }
  3161. else {
  3162. return new EmptyObservable_1.EmptyObservable(scheduler);
  3163. }
  3164. };
  3165. ArrayObservable.dispatch = function (state) {
  3166. var array = state.array, index = state.index, count = state.count, subscriber = state.subscriber;
  3167. if (index >= count) {
  3168. subscriber.complete();
  3169. return;
  3170. }
  3171. subscriber.next(array[index]);
  3172. if (subscriber.closed) {
  3173. return;
  3174. }
  3175. state.index = index + 1;
  3176. this.schedule(state);
  3177. };
  3178. /** @deprecated internal use only */ ArrayObservable.prototype._subscribe = function (subscriber) {
  3179. var index = 0;
  3180. var array = this.array;
  3181. var count = array.length;
  3182. var scheduler = this.scheduler;
  3183. if (scheduler) {
  3184. return scheduler.schedule(ArrayObservable.dispatch, 0, {
  3185. array: array, index: index, count: count, subscriber: subscriber
  3186. });
  3187. }
  3188. else {
  3189. for (var i = 0; i < count && !subscriber.closed; i++) {
  3190. subscriber.next(array[i]);
  3191. }
  3192. subscriber.complete();
  3193. }
  3194. };
  3195. return ArrayObservable;
  3196. }(Observable_1.Observable));
  3197. exports.ArrayObservable = ArrayObservable;
  3198. //# sourceMappingURL=ArrayObservable.js.map
  3199. /***/ }),
  3200. /* 24 */
  3201. /***/ (function(module, exports) {
  3202. var g;
  3203. // This works in non-strict mode
  3204. g = (function() {
  3205. return this;
  3206. })();
  3207. try {
  3208. // This works if eval is allowed (see CSP)
  3209. g = g || Function("return this")() || (1,eval)("this");
  3210. } catch(e) {
  3211. // This works if the window reference is available
  3212. if(typeof window === "object")
  3213. g = window;
  3214. }
  3215. // g can still be undefined, but nothing to do about it...
  3216. // We return undefined, instead of nothing here, so it's
  3217. // easier to handle this case. if(!global) { ...}
  3218. module.exports = g;
  3219. /***/ }),
  3220. /* 25 */
  3221. /***/ (function(module, exports, __webpack_require__) {
  3222. "use strict";
  3223. function isScheduler(value) {
  3224. return value && typeof value.schedule === 'function';
  3225. }
  3226. exports.isScheduler = isScheduler;
  3227. //# sourceMappingURL=isScheduler.js.map
  3228. /***/ }),
  3229. /* 26 */
  3230. /***/ (function(module, exports, __webpack_require__) {
  3231. "use strict";
  3232. exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
  3233. //# sourceMappingURL=isArray.js.map
  3234. /***/ }),
  3235. /* 27 */
  3236. /***/ (function(module, exports, __webpack_require__) {
  3237. "use strict";
  3238. // typeof any so that it we don't have to cast when comparing a result to the error object
  3239. exports.errorObject = { e: {} };
  3240. //# sourceMappingURL=errorObject.js.map
  3241. /***/ }),
  3242. /* 28 */
  3243. /***/ (function(module, exports, __webpack_require__) {
  3244. "use strict";
  3245. var __extends = (this && this.__extends) || function (d, b) {
  3246. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3247. function __() { this.constructor = d; }
  3248. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3249. };
  3250. var Observable_1 = __webpack_require__(1);
  3251. /**
  3252. * We need this JSDoc comment for affecting ESDoc.
  3253. * @extends {Ignored}
  3254. * @hide true
  3255. */
  3256. var EmptyObservable = (function (_super) {
  3257. __extends(EmptyObservable, _super);
  3258. function EmptyObservable(scheduler) {
  3259. _super.call(this);
  3260. this.scheduler = scheduler;
  3261. }
  3262. /**
  3263. * Creates an Observable that emits no items to the Observer and immediately
  3264. * emits a complete notification.
  3265. *
  3266. * <span class="informal">Just emits 'complete', and nothing else.
  3267. * </span>
  3268. *
  3269. * <img src="./img/empty.png" width="100%">
  3270. *
  3271. * This static operator is useful for creating a simple Observable that only
  3272. * emits the complete notification. It can be used for composing with other
  3273. * Observables, such as in a {@link mergeMap}.
  3274. *
  3275. * @example <caption>Emit the number 7, then complete.</caption>
  3276. * var result = Rx.Observable.empty().startWith(7);
  3277. * result.subscribe(x => console.log(x));
  3278. *
  3279. * @example <caption>Map and flatten only odd numbers to the sequence 'a', 'b', 'c'</caption>
  3280. * var interval = Rx.Observable.interval(1000);
  3281. * var result = interval.mergeMap(x =>
  3282. * x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
  3283. * );
  3284. * result.subscribe(x => console.log(x));
  3285. *
  3286. * // Results in the following to the console:
  3287. * // x is equal to the count on the interval eg(0,1,2,3,...)
  3288. * // x will occur every 1000ms
  3289. * // if x % 2 is equal to 1 print abc
  3290. * // if x % 2 is not equal to 1 nothing will be output
  3291. *
  3292. * @see {@link create}
  3293. * @see {@link never}
  3294. * @see {@link of}
  3295. * @see {@link throw}
  3296. *
  3297. * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
  3298. * the emission of the complete notification.
  3299. * @return {Observable} An "empty" Observable: emits only the complete
  3300. * notification.
  3301. * @static true
  3302. * @name empty
  3303. * @owner Observable
  3304. */
  3305. EmptyObservable.create = function (scheduler) {
  3306. return new EmptyObservable(scheduler);
  3307. };
  3308. EmptyObservable.dispatch = function (arg) {
  3309. var subscriber = arg.subscriber;
  3310. subscriber.complete();
  3311. };
  3312. /** @deprecated internal use only */ EmptyObservable.prototype._subscribe = function (subscriber) {
  3313. var scheduler = this.scheduler;
  3314. if (scheduler) {
  3315. return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber });
  3316. }
  3317. else {
  3318. subscriber.complete();
  3319. }
  3320. };
  3321. return EmptyObservable;
  3322. }(Observable_1.Observable));
  3323. exports.EmptyObservable = EmptyObservable;
  3324. //# sourceMappingURL=EmptyObservable.js.map
  3325. /***/ }),
  3326. /* 29 */
  3327. /***/ (function(module, exports, __webpack_require__) {
  3328. "use strict";
  3329. var __extends = (this && this.__extends) || function (d, b) {
  3330. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3331. function __() { this.constructor = d; }
  3332. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3333. };
  3334. var Subscriber_1 = __webpack_require__(3);
  3335. /**
  3336. * We need this JSDoc comment for affecting ESDoc.
  3337. * @ignore
  3338. * @extends {Ignored}
  3339. */
  3340. var OuterSubscriber = (function (_super) {
  3341. __extends(OuterSubscriber, _super);
  3342. function OuterSubscriber() {
  3343. _super.apply(this, arguments);
  3344. }
  3345. OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  3346. this.destination.next(innerValue);
  3347. };
  3348. OuterSubscriber.prototype.notifyError = function (error, innerSub) {
  3349. this.destination.error(error);
  3350. };
  3351. OuterSubscriber.prototype.notifyComplete = function (innerSub) {
  3352. this.destination.complete();
  3353. };
  3354. return OuterSubscriber;
  3355. }(Subscriber_1.Subscriber));
  3356. exports.OuterSubscriber = OuterSubscriber;
  3357. //# sourceMappingURL=OuterSubscriber.js.map
  3358. /***/ }),
  3359. /* 30 */
  3360. /***/ (function(module, exports, __webpack_require__) {
  3361. "use strict";
  3362. var root_1 = __webpack_require__(7);
  3363. var isArrayLike_1 = __webpack_require__(59);
  3364. var isPromise_1 = __webpack_require__(60);
  3365. var isObject_1 = __webpack_require__(56);
  3366. var Observable_1 = __webpack_require__(1);
  3367. var iterator_1 = __webpack_require__(31);
  3368. var InnerSubscriber_1 = __webpack_require__(106);
  3369. var observable_1 = __webpack_require__(45);
  3370. function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) {
  3371. var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex);
  3372. if (destination.closed) {
  3373. return null;
  3374. }
  3375. if (result instanceof Observable_1.Observable) {
  3376. if (result._isScalar) {
  3377. destination.next(result.value);
  3378. destination.complete();
  3379. return null;
  3380. }
  3381. else {
  3382. destination.syncErrorThrowable = true;
  3383. return result.subscribe(destination);
  3384. }
  3385. }
  3386. else if (isArrayLike_1.isArrayLike(result)) {
  3387. for (var i = 0, len = result.length; i < len && !destination.closed; i++) {
  3388. destination.next(result[i]);
  3389. }
  3390. if (!destination.closed) {
  3391. destination.complete();
  3392. }
  3393. }
  3394. else if (isPromise_1.isPromise(result)) {
  3395. result.then(function (value) {
  3396. if (!destination.closed) {
  3397. destination.next(value);
  3398. destination.complete();
  3399. }
  3400. }, function (err) { return destination.error(err); })
  3401. .then(null, function (err) {
  3402. // Escaping the Promise trap: globally throw unhandled errors
  3403. root_1.root.setTimeout(function () { throw err; });
  3404. });
  3405. return destination;
  3406. }
  3407. else if (result && typeof result[iterator_1.iterator] === 'function') {
  3408. var iterator = result[iterator_1.iterator]();
  3409. do {
  3410. var item = iterator.next();
  3411. if (item.done) {
  3412. destination.complete();
  3413. break;
  3414. }
  3415. destination.next(item.value);
  3416. if (destination.closed) {
  3417. break;
  3418. }
  3419. } while (true);
  3420. }
  3421. else if (result && typeof result[observable_1.observable] === 'function') {
  3422. var obs = result[observable_1.observable]();
  3423. if (typeof obs.subscribe !== 'function') {
  3424. destination.error(new TypeError('Provided object does not correctly implement Symbol.observable'));
  3425. }
  3426. else {
  3427. return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex));
  3428. }
  3429. }
  3430. else {
  3431. var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
  3432. var msg = ("You provided " + value + " where a stream was expected.")
  3433. + ' You can provide an Observable, Promise, Array, or Iterable.';
  3434. destination.error(new TypeError(msg));
  3435. }
  3436. return null;
  3437. }
  3438. exports.subscribeToResult = subscribeToResult;
  3439. //# sourceMappingURL=subscribeToResult.js.map
  3440. /***/ }),
  3441. /* 31 */
  3442. /***/ (function(module, exports, __webpack_require__) {
  3443. "use strict";
  3444. var root_1 = __webpack_require__(7);
  3445. function symbolIteratorPonyfill(root) {
  3446. var Symbol = root.Symbol;
  3447. if (typeof Symbol === 'function') {
  3448. if (!Symbol.iterator) {
  3449. Symbol.iterator = Symbol('iterator polyfill');
  3450. }
  3451. return Symbol.iterator;
  3452. }
  3453. else {
  3454. // [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC)
  3455. var Set_1 = root.Set;
  3456. if (Set_1 && typeof new Set_1()['@@iterator'] === 'function') {
  3457. return '@@iterator';
  3458. }
  3459. var Map_1 = root.Map;
  3460. // required for compatability with es6-shim
  3461. if (Map_1) {
  3462. var keys = Object.getOwnPropertyNames(Map_1.prototype);
  3463. for (var i = 0; i < keys.length; ++i) {
  3464. var key = keys[i];
  3465. // according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal.
  3466. if (key !== 'entries' && key !== 'size' && Map_1.prototype[key] === Map_1.prototype['entries']) {
  3467. return key;
  3468. }
  3469. }
  3470. }
  3471. return '@@iterator';
  3472. }
  3473. }
  3474. exports.symbolIteratorPonyfill = symbolIteratorPonyfill;
  3475. exports.iterator = symbolIteratorPonyfill(root_1.root);
  3476. /**
  3477. * @deprecated use iterator instead
  3478. */
  3479. exports.$$iterator = exports.iterator;
  3480. //# sourceMappingURL=iterator.js.map
  3481. /***/ }),
  3482. /* 32 */
  3483. /***/ (function(module, exports, __webpack_require__) {
  3484. /* WEBPACK VAR INJECTION */(function(process) {/**
  3485. * This is the web browser implementation of `debug()`.
  3486. *
  3487. * Expose `debug()` as the module.
  3488. */
  3489. exports = module.exports = __webpack_require__(110);
  3490. exports.log = log;
  3491. exports.formatArgs = formatArgs;
  3492. exports.save = save;
  3493. exports.load = load;
  3494. exports.useColors = useColors;
  3495. exports.storage = 'undefined' != typeof chrome
  3496. && 'undefined' != typeof chrome.storage
  3497. ? chrome.storage.local
  3498. : localstorage();
  3499. /**
  3500. * Colors.
  3501. */
  3502. exports.colors = [
  3503. '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
  3504. '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
  3505. '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
  3506. '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
  3507. '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
  3508. '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
  3509. '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
  3510. '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
  3511. '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
  3512. '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
  3513. '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
  3514. ];
  3515. /**
  3516. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  3517. * and the Firebug extension (any Firefox version) are known
  3518. * to support "%c" CSS customizations.
  3519. *
  3520. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  3521. */
  3522. function useColors() {
  3523. // NB: In an Electron preload script, document will be defined but not fully
  3524. // initialized. Since we know we're in Chrome, we'll just detect this case
  3525. // explicitly
  3526. if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
  3527. return true;
  3528. }
  3529. // Internet Explorer and Edge do not support colors.
  3530. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  3531. return false;
  3532. }
  3533. // is webkit? http://stackoverflow.com/a/16459606/376773
  3534. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  3535. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  3536. // is firebug? http://stackoverflow.com/a/398120/376773
  3537. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  3538. // is firefox >= v31?
  3539. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  3540. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  3541. // double check webkit in userAgent just in case we are in a worker
  3542. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  3543. }
  3544. /**
  3545. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  3546. */
  3547. exports.formatters.j = function(v) {
  3548. try {
  3549. return JSON.stringify(v);
  3550. } catch (err) {
  3551. return '[UnexpectedJSONParseError]: ' + err.message;
  3552. }
  3553. };
  3554. /**
  3555. * Colorize log arguments if enabled.
  3556. *
  3557. * @api public
  3558. */
  3559. function formatArgs(args) {
  3560. var useColors = this.useColors;
  3561. args[0] = (useColors ? '%c' : '')
  3562. + this.namespace
  3563. + (useColors ? ' %c' : ' ')
  3564. + args[0]
  3565. + (useColors ? '%c ' : ' ')
  3566. + '+' + exports.humanize(this.diff);
  3567. if (!useColors) return;
  3568. var c = 'color: ' + this.color;
  3569. args.splice(1, 0, c, 'color: inherit')
  3570. // the final "%c" is somewhat tricky, because there could be other
  3571. // arguments passed either before or after the %c, so we need to
  3572. // figure out the correct index to insert the CSS into
  3573. var index = 0;
  3574. var lastC = 0;
  3575. args[0].replace(/%[a-zA-Z%]/g, function(match) {
  3576. if ('%%' === match) return;
  3577. index++;
  3578. if ('%c' === match) {
  3579. // we only are interested in the *last* %c
  3580. // (the user may have provided their own)
  3581. lastC = index;
  3582. }
  3583. });
  3584. args.splice(lastC, 0, c);
  3585. }
  3586. /**
  3587. * Invokes `console.log()` when available.
  3588. * No-op when `console.log` is not a "function".
  3589. *
  3590. * @api public
  3591. */
  3592. function log() {
  3593. // this hackery is required for IE8/9, where
  3594. // the `console.log` function doesn't have 'apply'
  3595. return 'object' === typeof console
  3596. && console.log
  3597. && Function.prototype.apply.call(console.log, console, arguments);
  3598. }
  3599. /**
  3600. * Save `namespaces`.
  3601. *
  3602. * @param {String} namespaces
  3603. * @api private
  3604. */
  3605. function save(namespaces) {
  3606. try {
  3607. if (null == namespaces) {
  3608. exports.storage.removeItem('debug');
  3609. } else {
  3610. exports.storage.debug = namespaces;
  3611. }
  3612. } catch(e) {}
  3613. }
  3614. /**
  3615. * Load `namespaces`.
  3616. *
  3617. * @return {String} returns the previously persisted debug modes
  3618. * @api private
  3619. */
  3620. function load() {
  3621. var r;
  3622. try {
  3623. r = exports.storage.debug;
  3624. } catch(e) {}
  3625. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  3626. if (!r && typeof process !== 'undefined' && 'env' in process) {
  3627. r = process.env.DEBUG;
  3628. }
  3629. return r;
  3630. }
  3631. /**
  3632. * Enable namespaces listed in `localStorage.debug` initially.
  3633. */
  3634. exports.enable(load());
  3635. /**
  3636. * Localstorage attempts to return the localstorage.
  3637. *
  3638. * This is necessary because safari throws
  3639. * when a user disables cookies/localstorage
  3640. * and you attempt to access it.
  3641. *
  3642. * @return {LocalStorage}
  3643. * @api private
  3644. */
  3645. function localstorage() {
  3646. try {
  3647. return window.localStorage;
  3648. } catch (e) {}
  3649. }
  3650. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33)))
  3651. /***/ }),
  3652. /* 33 */
  3653. /***/ (function(module, exports) {
  3654. // shim for using process in browser
  3655. var process = module.exports = {};
  3656. // cached from whatever global is present so that test runners that stub it
  3657. // don't break things. But we need to wrap it in a try catch in case it is
  3658. // wrapped in strict mode code which doesn't define any globals. It's inside a
  3659. // function because try/catches deoptimize in certain engines.
  3660. var cachedSetTimeout;
  3661. var cachedClearTimeout;
  3662. function defaultSetTimout() {
  3663. throw new Error('setTimeout has not been defined');
  3664. }
  3665. function defaultClearTimeout () {
  3666. throw new Error('clearTimeout has not been defined');
  3667. }
  3668. (function () {
  3669. try {
  3670. if (typeof setTimeout === 'function') {
  3671. cachedSetTimeout = setTimeout;
  3672. } else {
  3673. cachedSetTimeout = defaultSetTimout;
  3674. }
  3675. } catch (e) {
  3676. cachedSetTimeout = defaultSetTimout;
  3677. }
  3678. try {
  3679. if (typeof clearTimeout === 'function') {
  3680. cachedClearTimeout = clearTimeout;
  3681. } else {
  3682. cachedClearTimeout = defaultClearTimeout;
  3683. }
  3684. } catch (e) {
  3685. cachedClearTimeout = defaultClearTimeout;
  3686. }
  3687. } ())
  3688. function runTimeout(fun) {
  3689. if (cachedSetTimeout === setTimeout) {
  3690. //normal enviroments in sane situations
  3691. return setTimeout(fun, 0);
  3692. }
  3693. // if setTimeout wasn't available but was latter defined
  3694. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  3695. cachedSetTimeout = setTimeout;
  3696. return setTimeout(fun, 0);
  3697. }
  3698. try {
  3699. // when when somebody has screwed with setTimeout but no I.E. maddness
  3700. return cachedSetTimeout(fun, 0);
  3701. } catch(e){
  3702. try {
  3703. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  3704. return cachedSetTimeout.call(null, fun, 0);
  3705. } catch(e){
  3706. // 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
  3707. return cachedSetTimeout.call(this, fun, 0);
  3708. }
  3709. }
  3710. }
  3711. function runClearTimeout(marker) {
  3712. if (cachedClearTimeout === clearTimeout) {
  3713. //normal enviroments in sane situations
  3714. return clearTimeout(marker);
  3715. }
  3716. // if clearTimeout wasn't available but was latter defined
  3717. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  3718. cachedClearTimeout = clearTimeout;
  3719. return clearTimeout(marker);
  3720. }
  3721. try {
  3722. // when when somebody has screwed with setTimeout but no I.E. maddness
  3723. return cachedClearTimeout(marker);
  3724. } catch (e){
  3725. try {
  3726. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  3727. return cachedClearTimeout.call(null, marker);
  3728. } catch (e){
  3729. // 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.
  3730. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  3731. return cachedClearTimeout.call(this, marker);
  3732. }
  3733. }
  3734. }
  3735. var queue = [];
  3736. var draining = false;
  3737. var currentQueue;
  3738. var queueIndex = -1;
  3739. function cleanUpNextTick() {
  3740. if (!draining || !currentQueue) {
  3741. return;
  3742. }
  3743. draining = false;
  3744. if (currentQueue.length) {
  3745. queue = currentQueue.concat(queue);
  3746. } else {
  3747. queueIndex = -1;
  3748. }
  3749. if (queue.length) {
  3750. drainQueue();
  3751. }
  3752. }
  3753. function drainQueue() {
  3754. if (draining) {
  3755. return;
  3756. }
  3757. var timeout = runTimeout(cleanUpNextTick);
  3758. draining = true;
  3759. var len = queue.length;
  3760. while(len) {
  3761. currentQueue = queue;
  3762. queue = [];
  3763. while (++queueIndex < len) {
  3764. if (currentQueue) {
  3765. currentQueue[queueIndex].run();
  3766. }
  3767. }
  3768. queueIndex = -1;
  3769. len = queue.length;
  3770. }
  3771. currentQueue = null;
  3772. draining = false;
  3773. runClearTimeout(timeout);
  3774. }
  3775. process.nextTick = function (fun) {
  3776. var args = new Array(arguments.length - 1);
  3777. if (arguments.length > 1) {
  3778. for (var i = 1; i < arguments.length; i++) {
  3779. args[i - 1] = arguments[i];
  3780. }
  3781. }
  3782. queue.push(new Item(fun, args));
  3783. if (queue.length === 1 && !draining) {
  3784. runTimeout(drainQueue);
  3785. }
  3786. };
  3787. // v8 likes predictible objects
  3788. function Item(fun, array) {
  3789. this.fun = fun;
  3790. this.array = array;
  3791. }
  3792. Item.prototype.run = function () {
  3793. this.fun.apply(null, this.array);
  3794. };
  3795. process.title = 'browser';
  3796. process.browser = true;
  3797. process.env = {};
  3798. process.argv = [];
  3799. process.version = ''; // empty string to avoid regexp issues
  3800. process.versions = {};
  3801. function noop() {}
  3802. process.on = noop;
  3803. process.addListener = noop;
  3804. process.once = noop;
  3805. process.off = noop;
  3806. process.removeListener = noop;
  3807. process.removeAllListeners = noop;
  3808. process.emit = noop;
  3809. process.prependListener = noop;
  3810. process.prependOnceListener = noop;
  3811. process.listeners = function (name) { return [] }
  3812. process.binding = function (name) {
  3813. throw new Error('process.binding is not supported');
  3814. };
  3815. process.cwd = function () { return '/' };
  3816. process.chdir = function (dir) {
  3817. throw new Error('process.chdir is not supported');
  3818. };
  3819. process.umask = function() { return 0; };
  3820. /***/ }),
  3821. /* 34 */
  3822. /***/ (function(module, exports) {
  3823. /**
  3824. * Compiles a querystring
  3825. * Returns string representation of the object
  3826. *
  3827. * @param {Object}
  3828. * @api private
  3829. */
  3830. exports.encode = function (obj) {
  3831. var str = '';
  3832. for (var i in obj) {
  3833. if (obj.hasOwnProperty(i)) {
  3834. if (str.length) str += '&';
  3835. str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
  3836. }
  3837. }
  3838. return str;
  3839. };
  3840. /**
  3841. * Parses a simple querystring into an object
  3842. *
  3843. * @param {String} qs
  3844. * @api private
  3845. */
  3846. exports.decode = function(qs){
  3847. var qry = {};
  3848. var pairs = qs.split('&');
  3849. for (var i = 0, l = pairs.length; i < l; i++) {
  3850. var pair = pairs[i].split('=');
  3851. qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  3852. }
  3853. return qry;
  3854. };
  3855. /***/ }),
  3856. /* 35 */
  3857. /***/ (function(module, exports) {
  3858. module.exports = function(a, b){
  3859. var fn = function(){};
  3860. fn.prototype = b.prototype;
  3861. a.prototype = new fn;
  3862. a.prototype.constructor = a;
  3863. };
  3864. /***/ }),
  3865. /* 36 */
  3866. /***/ (function(module, exports, __webpack_require__) {
  3867. /* WEBPACK VAR INJECTION */(function(process) {/**
  3868. * This is the web browser implementation of `debug()`.
  3869. *
  3870. * Expose `debug()` as the module.
  3871. */
  3872. exports = module.exports = __webpack_require__(128);
  3873. exports.log = log;
  3874. exports.formatArgs = formatArgs;
  3875. exports.save = save;
  3876. exports.load = load;
  3877. exports.useColors = useColors;
  3878. exports.storage = 'undefined' != typeof chrome
  3879. && 'undefined' != typeof chrome.storage
  3880. ? chrome.storage.local
  3881. : localstorage();
  3882. /**
  3883. * Colors.
  3884. */
  3885. exports.colors = [
  3886. '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
  3887. '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
  3888. '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
  3889. '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
  3890. '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
  3891. '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
  3892. '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
  3893. '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
  3894. '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
  3895. '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
  3896. '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
  3897. ];
  3898. /**
  3899. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  3900. * and the Firebug extension (any Firefox version) are known
  3901. * to support "%c" CSS customizations.
  3902. *
  3903. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  3904. */
  3905. function useColors() {
  3906. // NB: In an Electron preload script, document will be defined but not fully
  3907. // initialized. Since we know we're in Chrome, we'll just detect this case
  3908. // explicitly
  3909. if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
  3910. return true;
  3911. }
  3912. // Internet Explorer and Edge do not support colors.
  3913. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  3914. return false;
  3915. }
  3916. // is webkit? http://stackoverflow.com/a/16459606/376773
  3917. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  3918. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  3919. // is firebug? http://stackoverflow.com/a/398120/376773
  3920. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  3921. // is firefox >= v31?
  3922. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  3923. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  3924. // double check webkit in userAgent just in case we are in a worker
  3925. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  3926. }
  3927. /**
  3928. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  3929. */
  3930. exports.formatters.j = function(v) {
  3931. try {
  3932. return JSON.stringify(v);
  3933. } catch (err) {
  3934. return '[UnexpectedJSONParseError]: ' + err.message;
  3935. }
  3936. };
  3937. /**
  3938. * Colorize log arguments if enabled.
  3939. *
  3940. * @api public
  3941. */
  3942. function formatArgs(args) {
  3943. var useColors = this.useColors;
  3944. args[0] = (useColors ? '%c' : '')
  3945. + this.namespace
  3946. + (useColors ? ' %c' : ' ')
  3947. + args[0]
  3948. + (useColors ? '%c ' : ' ')
  3949. + '+' + exports.humanize(this.diff);
  3950. if (!useColors) return;
  3951. var c = 'color: ' + this.color;
  3952. args.splice(1, 0, c, 'color: inherit')
  3953. // the final "%c" is somewhat tricky, because there could be other
  3954. // arguments passed either before or after the %c, so we need to
  3955. // figure out the correct index to insert the CSS into
  3956. var index = 0;
  3957. var lastC = 0;
  3958. args[0].replace(/%[a-zA-Z%]/g, function(match) {
  3959. if ('%%' === match) return;
  3960. index++;
  3961. if ('%c' === match) {
  3962. // we only are interested in the *last* %c
  3963. // (the user may have provided their own)
  3964. lastC = index;
  3965. }
  3966. });
  3967. args.splice(lastC, 0, c);
  3968. }
  3969. /**
  3970. * Invokes `console.log()` when available.
  3971. * No-op when `console.log` is not a "function".
  3972. *
  3973. * @api public
  3974. */
  3975. function log() {
  3976. // this hackery is required for IE8/9, where
  3977. // the `console.log` function doesn't have 'apply'
  3978. return 'object' === typeof console
  3979. && console.log
  3980. && Function.prototype.apply.call(console.log, console, arguments);
  3981. }
  3982. /**
  3983. * Save `namespaces`.
  3984. *
  3985. * @param {String} namespaces
  3986. * @api private
  3987. */
  3988. function save(namespaces) {
  3989. try {
  3990. if (null == namespaces) {
  3991. exports.storage.removeItem('debug');
  3992. } else {
  3993. exports.storage.debug = namespaces;
  3994. }
  3995. } catch(e) {}
  3996. }
  3997. /**
  3998. * Load `namespaces`.
  3999. *
  4000. * @return {String} returns the previously persisted debug modes
  4001. * @api private
  4002. */
  4003. function load() {
  4004. var r;
  4005. try {
  4006. r = exports.storage.debug;
  4007. } catch(e) {}
  4008. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  4009. if (!r && typeof process !== 'undefined' && 'env' in process) {
  4010. r = process.env.DEBUG;
  4011. }
  4012. return r;
  4013. }
  4014. /**
  4015. * Enable namespaces listed in `localStorage.debug` initially.
  4016. */
  4017. exports.enable(load());
  4018. /**
  4019. * Localstorage attempts to return the localstorage.
  4020. *
  4021. * This is necessary because safari throws
  4022. * when a user disables cookies/localstorage
  4023. * and you attempt to access it.
  4024. *
  4025. * @return {LocalStorage}
  4026. * @api private
  4027. */
  4028. function localstorage() {
  4029. try {
  4030. return window.localStorage;
  4031. } catch (e) {}
  4032. }
  4033. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33)))
  4034. /***/ }),
  4035. /* 37 */
  4036. /***/ (function(module, exports, __webpack_require__) {
  4037. "use strict";
  4038. var __extends = (this && this.__extends) || function (d, b) {
  4039. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4040. function __() { this.constructor = d; }
  4041. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4042. };
  4043. var Observable_1 = __webpack_require__(1);
  4044. var Subscriber_1 = __webpack_require__(3);
  4045. var Subscription_1 = __webpack_require__(12);
  4046. var ObjectUnsubscribedError_1 = __webpack_require__(73);
  4047. var SubjectSubscription_1 = __webpack_require__(134);
  4048. var rxSubscriber_1 = __webpack_require__(44);
  4049. /**
  4050. * @class SubjectSubscriber<T>
  4051. */
  4052. var SubjectSubscriber = (function (_super) {
  4053. __extends(SubjectSubscriber, _super);
  4054. function SubjectSubscriber(destination) {
  4055. _super.call(this, destination);
  4056. this.destination = destination;
  4057. }
  4058. return SubjectSubscriber;
  4059. }(Subscriber_1.Subscriber));
  4060. exports.SubjectSubscriber = SubjectSubscriber;
  4061. /**
  4062. * @class Subject<T>
  4063. */
  4064. var Subject = (function (_super) {
  4065. __extends(Subject, _super);
  4066. function Subject() {
  4067. _super.call(this);
  4068. this.observers = [];
  4069. this.closed = false;
  4070. this.isStopped = false;
  4071. this.hasError = false;
  4072. this.thrownError = null;
  4073. }
  4074. Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
  4075. return new SubjectSubscriber(this);
  4076. };
  4077. Subject.prototype.lift = function (operator) {
  4078. var subject = new AnonymousSubject(this, this);
  4079. subject.operator = operator;
  4080. return subject;
  4081. };
  4082. Subject.prototype.next = function (value) {
  4083. if (this.closed) {
  4084. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  4085. }
  4086. if (!this.isStopped) {
  4087. var observers = this.observers;
  4088. var len = observers.length;
  4089. var copy = observers.slice();
  4090. for (var i = 0; i < len; i++) {
  4091. copy[i].next(value);
  4092. }
  4093. }
  4094. };
  4095. Subject.prototype.error = function (err) {
  4096. if (this.closed) {
  4097. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  4098. }
  4099. this.hasError = true;
  4100. this.thrownError = err;
  4101. this.isStopped = true;
  4102. var observers = this.observers;
  4103. var len = observers.length;
  4104. var copy = observers.slice();
  4105. for (var i = 0; i < len; i++) {
  4106. copy[i].error(err);
  4107. }
  4108. this.observers.length = 0;
  4109. };
  4110. Subject.prototype.complete = function () {
  4111. if (this.closed) {
  4112. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  4113. }
  4114. this.isStopped = true;
  4115. var observers = this.observers;
  4116. var len = observers.length;
  4117. var copy = observers.slice();
  4118. for (var i = 0; i < len; i++) {
  4119. copy[i].complete();
  4120. }
  4121. this.observers.length = 0;
  4122. };
  4123. Subject.prototype.unsubscribe = function () {
  4124. this.isStopped = true;
  4125. this.closed = true;
  4126. this.observers = null;
  4127. };
  4128. Subject.prototype._trySubscribe = function (subscriber) {
  4129. if (this.closed) {
  4130. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  4131. }
  4132. else {
  4133. return _super.prototype._trySubscribe.call(this, subscriber);
  4134. }
  4135. };
  4136. /** @deprecated internal use only */ Subject.prototype._subscribe = function (subscriber) {
  4137. if (this.closed) {
  4138. throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
  4139. }
  4140. else if (this.hasError) {
  4141. subscriber.error(this.thrownError);
  4142. return Subscription_1.Subscription.EMPTY;
  4143. }
  4144. else if (this.isStopped) {
  4145. subscriber.complete();
  4146. return Subscription_1.Subscription.EMPTY;
  4147. }
  4148. else {
  4149. this.observers.push(subscriber);
  4150. return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
  4151. }
  4152. };
  4153. Subject.prototype.asObservable = function () {
  4154. var observable = new Observable_1.Observable();
  4155. observable.source = this;
  4156. return observable;
  4157. };
  4158. Subject.create = function (destination, source) {
  4159. return new AnonymousSubject(destination, source);
  4160. };
  4161. return Subject;
  4162. }(Observable_1.Observable));
  4163. exports.Subject = Subject;
  4164. /**
  4165. * @class AnonymousSubject<T>
  4166. */
  4167. var AnonymousSubject = (function (_super) {
  4168. __extends(AnonymousSubject, _super);
  4169. function AnonymousSubject(destination, source) {
  4170. _super.call(this);
  4171. this.destination = destination;
  4172. this.source = source;
  4173. }
  4174. AnonymousSubject.prototype.next = function (value) {
  4175. var destination = this.destination;
  4176. if (destination && destination.next) {
  4177. destination.next(value);
  4178. }
  4179. };
  4180. AnonymousSubject.prototype.error = function (err) {
  4181. var destination = this.destination;
  4182. if (destination && destination.error) {
  4183. this.destination.error(err);
  4184. }
  4185. };
  4186. AnonymousSubject.prototype.complete = function () {
  4187. var destination = this.destination;
  4188. if (destination && destination.complete) {
  4189. this.destination.complete();
  4190. }
  4191. };
  4192. /** @deprecated internal use only */ AnonymousSubject.prototype._subscribe = function (subscriber) {
  4193. var source = this.source;
  4194. if (source) {
  4195. return this.source.subscribe(subscriber);
  4196. }
  4197. else {
  4198. return Subscription_1.Subscription.EMPTY;
  4199. }
  4200. };
  4201. return AnonymousSubject;
  4202. }(Subject));
  4203. exports.AnonymousSubject = AnonymousSubject;
  4204. //# sourceMappingURL=Subject.js.map
  4205. /***/ }),
  4206. /* 38 */
  4207. /***/ (function(module, exports, __webpack_require__) {
  4208. "use strict";
  4209. var Observable_1 = __webpack_require__(1);
  4210. var ArrayObservable_1 = __webpack_require__(23);
  4211. var isScheduler_1 = __webpack_require__(25);
  4212. var mergeAll_1 = __webpack_require__(55);
  4213. /* tslint:enable:max-line-length */
  4214. /**
  4215. * Creates an output Observable which concurrently emits all values from every
  4216. * given input Observable.
  4217. *
  4218. * <span class="informal">Flattens multiple Observables together by blending
  4219. * their values into one Observable.</span>
  4220. *
  4221. * <img src="./img/merge.png" width="100%">
  4222. *
  4223. * `merge` subscribes to each given input Observable (as arguments), and simply
  4224. * forwards (without doing any transformation) all the values from all the input
  4225. * Observables to the output Observable. The output Observable only completes
  4226. * once all input Observables have completed. Any error delivered by an input
  4227. * Observable will be immediately emitted on the output Observable.
  4228. *
  4229. * @example <caption>Merge together two Observables: 1s interval and clicks</caption>
  4230. * var clicks = Rx.Observable.fromEvent(document, 'click');
  4231. * var timer = Rx.Observable.interval(1000);
  4232. * var clicksOrTimer = Rx.Observable.merge(clicks, timer);
  4233. * clicksOrTimer.subscribe(x => console.log(x));
  4234. *
  4235. * // Results in the following:
  4236. * // timer will emit ascending values, one every second(1000ms) to console
  4237. * // clicks logs MouseEvents to console everytime the "document" is clicked
  4238. * // Since the two streams are merged you see these happening
  4239. * // as they occur.
  4240. *
  4241. * @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
  4242. * var timer1 = Rx.Observable.interval(1000).take(10);
  4243. * var timer2 = Rx.Observable.interval(2000).take(6);
  4244. * var timer3 = Rx.Observable.interval(500).take(10);
  4245. * var concurrent = 2; // the argument
  4246. * var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent);
  4247. * merged.subscribe(x => console.log(x));
  4248. *
  4249. * // Results in the following:
  4250. * // - First timer1 and timer2 will run concurrently
  4251. * // - timer1 will emit a value every 1000ms for 10 iterations
  4252. * // - timer2 will emit a value every 2000ms for 6 iterations
  4253. * // - after timer1 hits it's max iteration, timer2 will
  4254. * // continue, and timer3 will start to run concurrently with timer2
  4255. * // - when timer2 hits it's max iteration it terminates, and
  4256. * // timer3 will continue to emit a value every 500ms until it is complete
  4257. *
  4258. * @see {@link mergeAll}
  4259. * @see {@link mergeMap}
  4260. * @see {@link mergeMapTo}
  4261. * @see {@link mergeScan}
  4262. *
  4263. * @param {...ObservableInput} observables Input Observables to merge together.
  4264. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
  4265. * Observables being subscribed to concurrently.
  4266. * @param {Scheduler} [scheduler=null] The IScheduler to use for managing
  4267. * concurrency of input Observables.
  4268. * @return {Observable} an Observable that emits items that are the result of
  4269. * every input Observable.
  4270. * @static true
  4271. * @name merge
  4272. * @owner Observable
  4273. */
  4274. function merge() {
  4275. var observables = [];
  4276. for (var _i = 0; _i < arguments.length; _i++) {
  4277. observables[_i - 0] = arguments[_i];
  4278. }
  4279. var concurrent = Number.POSITIVE_INFINITY;
  4280. var scheduler = null;
  4281. var last = observables[observables.length - 1];
  4282. if (isScheduler_1.isScheduler(last)) {
  4283. scheduler = observables.pop();
  4284. if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
  4285. concurrent = observables.pop();
  4286. }
  4287. }
  4288. else if (typeof last === 'number') {
  4289. concurrent = observables.pop();
  4290. }
  4291. if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
  4292. return observables[0];
  4293. }
  4294. return mergeAll_1.mergeAll(concurrent)(new ArrayObservable_1.ArrayObservable(observables, scheduler));
  4295. }
  4296. exports.merge = merge;
  4297. //# sourceMappingURL=merge.js.map
  4298. /***/ }),
  4299. /* 39 */
  4300. /***/ (function(module, exports, __webpack_require__) {
  4301. "use strict";
  4302. var __extends = (this && this.__extends) || function (d, b) {
  4303. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4304. function __() { this.constructor = d; }
  4305. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4306. };
  4307. var Subscriber_1 = __webpack_require__(3);
  4308. /**
  4309. * Returns an Observable that skips the first `count` items emitted by the source Observable.
  4310. *
  4311. * <img src="./img/skip.png" width="100%">
  4312. *
  4313. * @param {Number} count - The number of times, items emitted by source Observable should be skipped.
  4314. * @return {Observable} An Observable that skips values emitted by the source Observable.
  4315. *
  4316. * @method skip
  4317. * @owner Observable
  4318. */
  4319. function skip(count) {
  4320. return function (source) { return source.lift(new SkipOperator(count)); };
  4321. }
  4322. exports.skip = skip;
  4323. var SkipOperator = (function () {
  4324. function SkipOperator(total) {
  4325. this.total = total;
  4326. }
  4327. SkipOperator.prototype.call = function (subscriber, source) {
  4328. return source.subscribe(new SkipSubscriber(subscriber, this.total));
  4329. };
  4330. return SkipOperator;
  4331. }());
  4332. /**
  4333. * We need this JSDoc comment for affecting ESDoc.
  4334. * @ignore
  4335. * @extends {Ignored}
  4336. */
  4337. var SkipSubscriber = (function (_super) {
  4338. __extends(SkipSubscriber, _super);
  4339. function SkipSubscriber(destination, total) {
  4340. _super.call(this, destination);
  4341. this.total = total;
  4342. this.count = 0;
  4343. }
  4344. SkipSubscriber.prototype._next = function (x) {
  4345. if (++this.count > this.total) {
  4346. this.destination.next(x);
  4347. }
  4348. };
  4349. return SkipSubscriber;
  4350. }(Subscriber_1.Subscriber));
  4351. //# sourceMappingURL=skip.js.map
  4352. /***/ }),
  4353. /* 40 */
  4354. /***/ (function(module, exports, __webpack_require__) {
  4355. "use strict";
  4356. var __extends = (this && this.__extends) || function (d, b) {
  4357. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4358. function __() { this.constructor = d; }
  4359. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4360. };
  4361. var Subscriber_1 = __webpack_require__(3);
  4362. var tryCatch_1 = __webpack_require__(43);
  4363. var errorObject_1 = __webpack_require__(27);
  4364. /* tslint:enable:max-line-length */
  4365. /**
  4366. * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from the previous item.
  4367. *
  4368. * 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.
  4369. *
  4370. * If a comparator function is not provided, an equality check is used by default.
  4371. *
  4372. * @example <caption>A simple example with numbers</caption>
  4373. * Observable.of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4)
  4374. * .distinctUntilChanged()
  4375. * .subscribe(x => console.log(x)); // 1, 2, 1, 2, 3, 4
  4376. *
  4377. * @example <caption>An example using a compare function</caption>
  4378. * interface Person {
  4379. * age: number,
  4380. * name: string
  4381. * }
  4382. *
  4383. * Observable.of<Person>(
  4384. * { age: 4, name: 'Foo'},
  4385. * { age: 7, name: 'Bar'},
  4386. * { age: 5, name: 'Foo'})
  4387. * { age: 6, name: 'Foo'})
  4388. * .distinctUntilChanged((p: Person, q: Person) => p.name === q.name)
  4389. * .subscribe(x => console.log(x));
  4390. *
  4391. * // displays:
  4392. * // { age: 4, name: 'Foo' }
  4393. * // { age: 7, name: 'Bar' }
  4394. * // { age: 5, name: 'Foo' }
  4395. *
  4396. * @see {@link distinct}
  4397. * @see {@link distinctUntilKeyChanged}
  4398. *
  4399. * @param {function} [compare] Optional comparison function called to test if an item is distinct from the previous item in the source.
  4400. * @return {Observable} An Observable that emits items from the source Observable with distinct values.
  4401. * @method distinctUntilChanged
  4402. * @owner Observable
  4403. */
  4404. function distinctUntilChanged(compare, keySelector) {
  4405. return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
  4406. }
  4407. exports.distinctUntilChanged = distinctUntilChanged;
  4408. var DistinctUntilChangedOperator = (function () {
  4409. function DistinctUntilChangedOperator(compare, keySelector) {
  4410. this.compare = compare;
  4411. this.keySelector = keySelector;
  4412. }
  4413. DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
  4414. return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
  4415. };
  4416. return DistinctUntilChangedOperator;
  4417. }());
  4418. /**
  4419. * We need this JSDoc comment for affecting ESDoc.
  4420. * @ignore
  4421. * @extends {Ignored}
  4422. */
  4423. var DistinctUntilChangedSubscriber = (function (_super) {
  4424. __extends(DistinctUntilChangedSubscriber, _super);
  4425. function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
  4426. _super.call(this, destination);
  4427. this.keySelector = keySelector;
  4428. this.hasKey = false;
  4429. if (typeof compare === 'function') {
  4430. this.compare = compare;
  4431. }
  4432. }
  4433. DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
  4434. return x === y;
  4435. };
  4436. DistinctUntilChangedSubscriber.prototype._next = function (value) {
  4437. var keySelector = this.keySelector;
  4438. var key = value;
  4439. if (keySelector) {
  4440. key = tryCatch_1.tryCatch(this.keySelector)(value);
  4441. if (key === errorObject_1.errorObject) {
  4442. return this.destination.error(errorObject_1.errorObject.e);
  4443. }
  4444. }
  4445. var result = false;
  4446. if (this.hasKey) {
  4447. result = tryCatch_1.tryCatch(this.compare)(this.key, key);
  4448. if (result === errorObject_1.errorObject) {
  4449. return this.destination.error(errorObject_1.errorObject.e);
  4450. }
  4451. }
  4452. else {
  4453. this.hasKey = true;
  4454. }
  4455. if (Boolean(result) === false) {
  4456. this.key = key;
  4457. this.destination.next(value);
  4458. }
  4459. };
  4460. return DistinctUntilChangedSubscriber;
  4461. }(Subscriber_1.Subscriber));
  4462. //# sourceMappingURL=distinctUntilChanged.js.map
  4463. /***/ }),
  4464. /* 41 */
  4465. /***/ (function(module, exports, __webpack_require__) {
  4466. "use strict";
  4467. var FromEventObservable_1 = __webpack_require__(172);
  4468. exports.fromEvent = FromEventObservable_1.FromEventObservable.create;
  4469. //# sourceMappingURL=fromEvent.js.map
  4470. /***/ }),
  4471. /* 42 */
  4472. /***/ (function(module, exports, __webpack_require__) {
  4473. "use strict";
  4474. function isFunction(x) {
  4475. return typeof x === 'function';
  4476. }
  4477. exports.isFunction = isFunction;
  4478. //# sourceMappingURL=isFunction.js.map
  4479. /***/ }),
  4480. /* 43 */
  4481. /***/ (function(module, exports, __webpack_require__) {
  4482. "use strict";
  4483. var errorObject_1 = __webpack_require__(27);
  4484. var tryCatchTarget;
  4485. function tryCatcher() {
  4486. try {
  4487. return tryCatchTarget.apply(this, arguments);
  4488. }
  4489. catch (e) {
  4490. errorObject_1.errorObject.e = e;
  4491. return errorObject_1.errorObject;
  4492. }
  4493. }
  4494. function tryCatch(fn) {
  4495. tryCatchTarget = fn;
  4496. return tryCatcher;
  4497. }
  4498. exports.tryCatch = tryCatch;
  4499. ;
  4500. //# sourceMappingURL=tryCatch.js.map
  4501. /***/ }),
  4502. /* 44 */
  4503. /***/ (function(module, exports, __webpack_require__) {
  4504. "use strict";
  4505. var root_1 = __webpack_require__(7);
  4506. var Symbol = root_1.root.Symbol;
  4507. exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
  4508. Symbol.for('rxSubscriber') : '@@rxSubscriber';
  4509. /**
  4510. * @deprecated use rxSubscriber instead
  4511. */
  4512. exports.$$rxSubscriber = exports.rxSubscriber;
  4513. //# sourceMappingURL=rxSubscriber.js.map
  4514. /***/ }),
  4515. /* 45 */
  4516. /***/ (function(module, exports, __webpack_require__) {
  4517. "use strict";
  4518. var root_1 = __webpack_require__(7);
  4519. function getSymbolObservable(context) {
  4520. var $$observable;
  4521. var Symbol = context.Symbol;
  4522. if (typeof Symbol === 'function') {
  4523. if (Symbol.observable) {
  4524. $$observable = Symbol.observable;
  4525. }
  4526. else {
  4527. $$observable = Symbol('observable');
  4528. Symbol.observable = $$observable;
  4529. }
  4530. }
  4531. else {
  4532. $$observable = '@@observable';
  4533. }
  4534. return $$observable;
  4535. }
  4536. exports.getSymbolObservable = getSymbolObservable;
  4537. exports.observable = getSymbolObservable(root_1.root);
  4538. /**
  4539. * @deprecated use observable instead
  4540. */
  4541. exports.$$observable = exports.observable;
  4542. //# sourceMappingURL=observable.js.map
  4543. /***/ }),
  4544. /* 46 */
  4545. /***/ (function(module, exports, __webpack_require__) {
  4546. "use strict";
  4547. var __extends = (this && this.__extends) || function (d, b) {
  4548. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4549. function __() { this.constructor = d; }
  4550. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4551. };
  4552. var Observable_1 = __webpack_require__(1);
  4553. /**
  4554. * We need this JSDoc comment for affecting ESDoc.
  4555. * @extends {Ignored}
  4556. * @hide true
  4557. */
  4558. var ScalarObservable = (function (_super) {
  4559. __extends(ScalarObservable, _super);
  4560. function ScalarObservable(value, scheduler) {
  4561. _super.call(this);
  4562. this.value = value;
  4563. this.scheduler = scheduler;
  4564. this._isScalar = true;
  4565. if (scheduler) {
  4566. this._isScalar = false;
  4567. }
  4568. }
  4569. ScalarObservable.create = function (value, scheduler) {
  4570. return new ScalarObservable(value, scheduler);
  4571. };
  4572. ScalarObservable.dispatch = function (state) {
  4573. var done = state.done, value = state.value, subscriber = state.subscriber;
  4574. if (done) {
  4575. subscriber.complete();
  4576. return;
  4577. }
  4578. subscriber.next(value);
  4579. if (subscriber.closed) {
  4580. return;
  4581. }
  4582. state.done = true;
  4583. this.schedule(state);
  4584. };
  4585. /** @deprecated internal use only */ ScalarObservable.prototype._subscribe = function (subscriber) {
  4586. var value = this.value;
  4587. var scheduler = this.scheduler;
  4588. if (scheduler) {
  4589. return scheduler.schedule(ScalarObservable.dispatch, 0, {
  4590. done: false, value: value, subscriber: subscriber
  4591. });
  4592. }
  4593. else {
  4594. subscriber.next(value);
  4595. if (!subscriber.closed) {
  4596. subscriber.complete();
  4597. }
  4598. }
  4599. };
  4600. return ScalarObservable;
  4601. }(Observable_1.Observable));
  4602. exports.ScalarObservable = ScalarObservable;
  4603. //# sourceMappingURL=ScalarObservable.js.map
  4604. /***/ }),
  4605. /* 47 */
  4606. /***/ (function(module, exports) {
  4607. /**
  4608. * Helpers.
  4609. */
  4610. var s = 1000;
  4611. var m = s * 60;
  4612. var h = m * 60;
  4613. var d = h * 24;
  4614. var y = d * 365.25;
  4615. /**
  4616. * Parse or format the given `val`.
  4617. *
  4618. * Options:
  4619. *
  4620. * - `long` verbose formatting [false]
  4621. *
  4622. * @param {String|Number} val
  4623. * @param {Object} [options]
  4624. * @throws {Error} throw an error if val is not a non-empty string or a number
  4625. * @return {String|Number}
  4626. * @api public
  4627. */
  4628. module.exports = function(val, options) {
  4629. options = options || {};
  4630. var type = typeof val;
  4631. if (type === 'string' && val.length > 0) {
  4632. return parse(val);
  4633. } else if (type === 'number' && isNaN(val) === false) {
  4634. return options.long ? fmtLong(val) : fmtShort(val);
  4635. }
  4636. throw new Error(
  4637. 'val is not a non-empty string or a valid number. val=' +
  4638. JSON.stringify(val)
  4639. );
  4640. };
  4641. /**
  4642. * Parse the given `str` and return milliseconds.
  4643. *
  4644. * @param {String} str
  4645. * @return {Number}
  4646. * @api private
  4647. */
  4648. function parse(str) {
  4649. str = String(str);
  4650. if (str.length > 100) {
  4651. return;
  4652. }
  4653. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
  4654. str
  4655. );
  4656. if (!match) {
  4657. return;
  4658. }
  4659. var n = parseFloat(match[1]);
  4660. var type = (match[2] || 'ms').toLowerCase();
  4661. switch (type) {
  4662. case 'years':
  4663. case 'year':
  4664. case 'yrs':
  4665. case 'yr':
  4666. case 'y':
  4667. return n * y;
  4668. case 'days':
  4669. case 'day':
  4670. case 'd':
  4671. return n * d;
  4672. case 'hours':
  4673. case 'hour':
  4674. case 'hrs':
  4675. case 'hr':
  4676. case 'h':
  4677. return n * h;
  4678. case 'minutes':
  4679. case 'minute':
  4680. case 'mins':
  4681. case 'min':
  4682. case 'm':
  4683. return n * m;
  4684. case 'seconds':
  4685. case 'second':
  4686. case 'secs':
  4687. case 'sec':
  4688. case 's':
  4689. return n * s;
  4690. case 'milliseconds':
  4691. case 'millisecond':
  4692. case 'msecs':
  4693. case 'msec':
  4694. case 'ms':
  4695. return n;
  4696. default:
  4697. return undefined;
  4698. }
  4699. }
  4700. /**
  4701. * Short format for `ms`.
  4702. *
  4703. * @param {Number} ms
  4704. * @return {String}
  4705. * @api private
  4706. */
  4707. function fmtShort(ms) {
  4708. if (ms >= d) {
  4709. return Math.round(ms / d) + 'd';
  4710. }
  4711. if (ms >= h) {
  4712. return Math.round(ms / h) + 'h';
  4713. }
  4714. if (ms >= m) {
  4715. return Math.round(ms / m) + 'm';
  4716. }
  4717. if (ms >= s) {
  4718. return Math.round(ms / s) + 's';
  4719. }
  4720. return ms + 'ms';
  4721. }
  4722. /**
  4723. * Long format for `ms`.
  4724. *
  4725. * @param {Number} ms
  4726. * @return {String}
  4727. * @api private
  4728. */
  4729. function fmtLong(ms) {
  4730. return plural(ms, d, 'day') ||
  4731. plural(ms, h, 'hour') ||
  4732. plural(ms, m, 'minute') ||
  4733. plural(ms, s, 'second') ||
  4734. ms + ' ms';
  4735. }
  4736. /**
  4737. * Pluralization helper.
  4738. */
  4739. function plural(ms, n, name) {
  4740. if (ms < n) {
  4741. return;
  4742. }
  4743. if (ms < n * 1.5) {
  4744. return Math.floor(ms / n) + ' ' + name;
  4745. }
  4746. return Math.ceil(ms / n) + ' ' + name + 's';
  4747. }
  4748. /***/ }),
  4749. /* 48 */
  4750. /***/ (function(module, exports, __webpack_require__) {
  4751. /**
  4752. * Module dependencies.
  4753. */
  4754. var debug = __webpack_require__(111)('socket.io-parser');
  4755. var Emitter = __webpack_require__(17);
  4756. var binary = __webpack_require__(113);
  4757. var isArray = __webpack_require__(62);
  4758. var isBuf = __webpack_require__(63);
  4759. /**
  4760. * Protocol version.
  4761. *
  4762. * @api public
  4763. */
  4764. exports.protocol = 4;
  4765. /**
  4766. * Packet types.
  4767. *
  4768. * @api public
  4769. */
  4770. exports.types = [
  4771. 'CONNECT',
  4772. 'DISCONNECT',
  4773. 'EVENT',
  4774. 'ACK',
  4775. 'ERROR',
  4776. 'BINARY_EVENT',
  4777. 'BINARY_ACK'
  4778. ];
  4779. /**
  4780. * Packet type `connect`.
  4781. *
  4782. * @api public
  4783. */
  4784. exports.CONNECT = 0;
  4785. /**
  4786. * Packet type `disconnect`.
  4787. *
  4788. * @api public
  4789. */
  4790. exports.DISCONNECT = 1;
  4791. /**
  4792. * Packet type `event`.
  4793. *
  4794. * @api public
  4795. */
  4796. exports.EVENT = 2;
  4797. /**
  4798. * Packet type `ack`.
  4799. *
  4800. * @api public
  4801. */
  4802. exports.ACK = 3;
  4803. /**
  4804. * Packet type `error`.
  4805. *
  4806. * @api public
  4807. */
  4808. exports.ERROR = 4;
  4809. /**
  4810. * Packet type 'binary event'
  4811. *
  4812. * @api public
  4813. */
  4814. exports.BINARY_EVENT = 5;
  4815. /**
  4816. * Packet type `binary ack`. For acks with binary arguments.
  4817. *
  4818. * @api public
  4819. */
  4820. exports.BINARY_ACK = 6;
  4821. /**
  4822. * Encoder constructor.
  4823. *
  4824. * @api public
  4825. */
  4826. exports.Encoder = Encoder;
  4827. /**
  4828. * Decoder constructor.
  4829. *
  4830. * @api public
  4831. */
  4832. exports.Decoder = Decoder;
  4833. /**
  4834. * A socket.io Encoder instance
  4835. *
  4836. * @api public
  4837. */
  4838. function Encoder() {}
  4839. var ERROR_PACKET = exports.ERROR + '"encode error"';
  4840. /**
  4841. * Encode a packet as a single string if non-binary, or as a
  4842. * buffer sequence, depending on packet type.
  4843. *
  4844. * @param {Object} obj - packet object
  4845. * @param {Function} callback - function to handle encodings (likely engine.write)
  4846. * @return Calls callback with Array of encodings
  4847. * @api public
  4848. */
  4849. Encoder.prototype.encode = function(obj, callback){
  4850. debug('encoding packet %j', obj);
  4851. if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {
  4852. encodeAsBinary(obj, callback);
  4853. } else {
  4854. var encoding = encodeAsString(obj);
  4855. callback([encoding]);
  4856. }
  4857. };
  4858. /**
  4859. * Encode packet as string.
  4860. *
  4861. * @param {Object} packet
  4862. * @return {String} encoded
  4863. * @api private
  4864. */
  4865. function encodeAsString(obj) {
  4866. // first is type
  4867. var str = '' + obj.type;
  4868. // attachments if we have them
  4869. if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {
  4870. str += obj.attachments + '-';
  4871. }
  4872. // if we have a namespace other than `/`
  4873. // we append it followed by a comma `,`
  4874. if (obj.nsp && '/' !== obj.nsp) {
  4875. str += obj.nsp + ',';
  4876. }
  4877. // immediately followed by the id
  4878. if (null != obj.id) {
  4879. str += obj.id;
  4880. }
  4881. // json data
  4882. if (null != obj.data) {
  4883. var payload = tryStringify(obj.data);
  4884. if (payload !== false) {
  4885. str += payload;
  4886. } else {
  4887. return ERROR_PACKET;
  4888. }
  4889. }
  4890. debug('encoded %j as %s', obj, str);
  4891. return str;
  4892. }
  4893. function tryStringify(str) {
  4894. try {
  4895. return JSON.stringify(str);
  4896. } catch(e){
  4897. return false;
  4898. }
  4899. }
  4900. /**
  4901. * Encode packet as 'buffer sequence' by removing blobs, and
  4902. * deconstructing packet into object with placeholders and
  4903. * a list of buffers.
  4904. *
  4905. * @param {Object} packet
  4906. * @return {Buffer} encoded
  4907. * @api private
  4908. */
  4909. function encodeAsBinary(obj, callback) {
  4910. function writeEncoding(bloblessData) {
  4911. var deconstruction = binary.deconstructPacket(bloblessData);
  4912. var pack = encodeAsString(deconstruction.packet);
  4913. var buffers = deconstruction.buffers;
  4914. buffers.unshift(pack); // add packet info to beginning of data list
  4915. callback(buffers); // write all the buffers
  4916. }
  4917. binary.removeBlobs(obj, writeEncoding);
  4918. }
  4919. /**
  4920. * A socket.io Decoder instance
  4921. *
  4922. * @return {Object} decoder
  4923. * @api public
  4924. */
  4925. function Decoder() {
  4926. this.reconstructor = null;
  4927. }
  4928. /**
  4929. * Mix in `Emitter` with Decoder.
  4930. */
  4931. Emitter(Decoder.prototype);
  4932. /**
  4933. * Decodes an encoded packet string into packet JSON.
  4934. *
  4935. * @param {String} obj - encoded packet
  4936. * @return {Object} packet
  4937. * @api public
  4938. */
  4939. Decoder.prototype.add = function(obj) {
  4940. var packet;
  4941. if (typeof obj === 'string') {
  4942. packet = decodeString(obj);
  4943. if (exports.BINARY_EVENT === packet.type || exports.BINARY_ACK === packet.type) { // binary packet's json
  4944. this.reconstructor = new BinaryReconstructor(packet);
  4945. // no attachments, labeled binary but no binary data to follow
  4946. if (this.reconstructor.reconPack.attachments === 0) {
  4947. this.emit('decoded', packet);
  4948. }
  4949. } else { // non-binary full packet
  4950. this.emit('decoded', packet);
  4951. }
  4952. } else if (isBuf(obj) || obj.base64) { // raw binary data
  4953. if (!this.reconstructor) {
  4954. throw new Error('got binary data when not reconstructing a packet');
  4955. } else {
  4956. packet = this.reconstructor.takeBinaryData(obj);
  4957. if (packet) { // received final buffer
  4958. this.reconstructor = null;
  4959. this.emit('decoded', packet);
  4960. }
  4961. }
  4962. } else {
  4963. throw new Error('Unknown type: ' + obj);
  4964. }
  4965. };
  4966. /**
  4967. * Decode a packet String (JSON data)
  4968. *
  4969. * @param {String} str
  4970. * @return {Object} packet
  4971. * @api private
  4972. */
  4973. function decodeString(str) {
  4974. var i = 0;
  4975. // look up type
  4976. var p = {
  4977. type: Number(str.charAt(0))
  4978. };
  4979. if (null == exports.types[p.type]) {
  4980. return error('unknown packet type ' + p.type);
  4981. }
  4982. // look up attachments if type binary
  4983. if (exports.BINARY_EVENT === p.type || exports.BINARY_ACK === p.type) {
  4984. var buf = '';
  4985. while (str.charAt(++i) !== '-') {
  4986. buf += str.charAt(i);
  4987. if (i == str.length) break;
  4988. }
  4989. if (buf != Number(buf) || str.charAt(i) !== '-') {
  4990. throw new Error('Illegal attachments');
  4991. }
  4992. p.attachments = Number(buf);
  4993. }
  4994. // look up namespace (if any)
  4995. if ('/' === str.charAt(i + 1)) {
  4996. p.nsp = '';
  4997. while (++i) {
  4998. var c = str.charAt(i);
  4999. if (',' === c) break;
  5000. p.nsp += c;
  5001. if (i === str.length) break;
  5002. }
  5003. } else {
  5004. p.nsp = '/';
  5005. }
  5006. // look up id
  5007. var next = str.charAt(i + 1);
  5008. if ('' !== next && Number(next) == next) {
  5009. p.id = '';
  5010. while (++i) {
  5011. var c = str.charAt(i);
  5012. if (null == c || Number(c) != c) {
  5013. --i;
  5014. break;
  5015. }
  5016. p.id += str.charAt(i);
  5017. if (i === str.length) break;
  5018. }
  5019. p.id = Number(p.id);
  5020. }
  5021. // look up json data
  5022. if (str.charAt(++i)) {
  5023. var payload = tryParse(str.substr(i));
  5024. var isPayloadValid = payload !== false && (p.type === exports.ERROR || isArray(payload));
  5025. if (isPayloadValid) {
  5026. p.data = payload;
  5027. } else {
  5028. return error('invalid payload');
  5029. }
  5030. }
  5031. debug('decoded %s as %j', str, p);
  5032. return p;
  5033. }
  5034. function tryParse(str) {
  5035. try {
  5036. return JSON.parse(str);
  5037. } catch(e){
  5038. return false;
  5039. }
  5040. }
  5041. /**
  5042. * Deallocates a parser's resources
  5043. *
  5044. * @api public
  5045. */
  5046. Decoder.prototype.destroy = function() {
  5047. if (this.reconstructor) {
  5048. this.reconstructor.finishedReconstruction();
  5049. }
  5050. };
  5051. /**
  5052. * A manager of a binary event's 'buffer sequence'. Should
  5053. * be constructed whenever a packet of type BINARY_EVENT is
  5054. * decoded.
  5055. *
  5056. * @param {Object} packet
  5057. * @return {BinaryReconstructor} initialized reconstructor
  5058. * @api private
  5059. */
  5060. function BinaryReconstructor(packet) {
  5061. this.reconPack = packet;
  5062. this.buffers = [];
  5063. }
  5064. /**
  5065. * Method to be called when binary data received from connection
  5066. * after a BINARY_EVENT packet.
  5067. *
  5068. * @param {Buffer | ArrayBuffer} binData - the raw binary data received
  5069. * @return {null | Object} returns null if more binary data is expected or
  5070. * a reconstructed packet object if all buffers have been received.
  5071. * @api private
  5072. */
  5073. BinaryReconstructor.prototype.takeBinaryData = function(binData) {
  5074. this.buffers.push(binData);
  5075. if (this.buffers.length === this.reconPack.attachments) { // done with buffer list
  5076. var packet = binary.reconstructPacket(this.reconPack, this.buffers);
  5077. this.finishedReconstruction();
  5078. return packet;
  5079. }
  5080. return null;
  5081. };
  5082. /**
  5083. * Cleans up binary packet reconstruction variables.
  5084. *
  5085. * @api private
  5086. */
  5087. BinaryReconstructor.prototype.finishedReconstruction = function() {
  5088. this.reconPack = null;
  5089. this.buffers = [];
  5090. };
  5091. function error(msg) {
  5092. return {
  5093. type: exports.ERROR,
  5094. data: 'parser error: ' + msg
  5095. };
  5096. }
  5097. /***/ }),
  5098. /* 49 */
  5099. /***/ (function(module, exports, __webpack_require__) {
  5100. "use strict";
  5101. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5102. * The buffer module from node.js, for the browser.
  5103. *
  5104. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  5105. * @license MIT
  5106. */
  5107. /* eslint-disable no-proto */
  5108. var base64 = __webpack_require__(114)
  5109. var ieee754 = __webpack_require__(115)
  5110. var isArray = __webpack_require__(116)
  5111. exports.Buffer = Buffer
  5112. exports.SlowBuffer = SlowBuffer
  5113. exports.INSPECT_MAX_BYTES = 50
  5114. /**
  5115. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5116. * === true Use Uint8Array implementation (fastest)
  5117. * === false Use Object implementation (most compatible, even IE6)
  5118. *
  5119. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5120. * Opera 11.6+, iOS 4.2+.
  5121. *
  5122. * Due to various browser bugs, sometimes the Object implementation will be used even
  5123. * when the browser supports typed arrays.
  5124. *
  5125. * Note:
  5126. *
  5127. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5128. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5129. *
  5130. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5131. *
  5132. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5133. * incorrect length in some situations.
  5134. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5135. * get the Object implementation, which is slower but behaves correctly.
  5136. */
  5137. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5138. ? global.TYPED_ARRAY_SUPPORT
  5139. : typedArraySupport()
  5140. /*
  5141. * Export kMaxLength after typed array support is determined.
  5142. */
  5143. exports.kMaxLength = kMaxLength()
  5144. function typedArraySupport () {
  5145. try {
  5146. var arr = new Uint8Array(1)
  5147. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5148. return arr.foo() === 42 && // typed array instances can be augmented
  5149. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5150. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5151. } catch (e) {
  5152. return false
  5153. }
  5154. }
  5155. function kMaxLength () {
  5156. return Buffer.TYPED_ARRAY_SUPPORT
  5157. ? 0x7fffffff
  5158. : 0x3fffffff
  5159. }
  5160. function createBuffer (that, length) {
  5161. if (kMaxLength() < length) {
  5162. throw new RangeError('Invalid typed array length')
  5163. }
  5164. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5165. // Return an augmented `Uint8Array` instance, for best performance
  5166. that = new Uint8Array(length)
  5167. that.__proto__ = Buffer.prototype
  5168. } else {
  5169. // Fallback: Return an object instance of the Buffer class
  5170. if (that === null) {
  5171. that = new Buffer(length)
  5172. }
  5173. that.length = length
  5174. }
  5175. return that
  5176. }
  5177. /**
  5178. * The Buffer constructor returns instances of `Uint8Array` that have their
  5179. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5180. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5181. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5182. * returns a single octet.
  5183. *
  5184. * The `Uint8Array` prototype remains unmodified.
  5185. */
  5186. function Buffer (arg, encodingOrOffset, length) {
  5187. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5188. return new Buffer(arg, encodingOrOffset, length)
  5189. }
  5190. // Common case.
  5191. if (typeof arg === 'number') {
  5192. if (typeof encodingOrOffset === 'string') {
  5193. throw new Error(
  5194. 'If encoding is specified then the first argument must be a string'
  5195. )
  5196. }
  5197. return allocUnsafe(this, arg)
  5198. }
  5199. return from(this, arg, encodingOrOffset, length)
  5200. }
  5201. Buffer.poolSize = 8192 // not used by this implementation
  5202. // TODO: Legacy, not needed anymore. Remove in next major version.
  5203. Buffer._augment = function (arr) {
  5204. arr.__proto__ = Buffer.prototype
  5205. return arr
  5206. }
  5207. function from (that, value, encodingOrOffset, length) {
  5208. if (typeof value === 'number') {
  5209. throw new TypeError('"value" argument must not be a number')
  5210. }
  5211. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5212. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5213. }
  5214. if (typeof value === 'string') {
  5215. return fromString(that, value, encodingOrOffset)
  5216. }
  5217. return fromObject(that, value)
  5218. }
  5219. /**
  5220. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5221. * if value is a number.
  5222. * Buffer.from(str[, encoding])
  5223. * Buffer.from(array)
  5224. * Buffer.from(buffer)
  5225. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5226. **/
  5227. Buffer.from = function (value, encodingOrOffset, length) {
  5228. return from(null, value, encodingOrOffset, length)
  5229. }
  5230. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5231. Buffer.prototype.__proto__ = Uint8Array.prototype
  5232. Buffer.__proto__ = Uint8Array
  5233. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5234. Buffer[Symbol.species] === Buffer) {
  5235. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5236. Object.defineProperty(Buffer, Symbol.species, {
  5237. value: null,
  5238. configurable: true
  5239. })
  5240. }
  5241. }
  5242. function assertSize (size) {
  5243. if (typeof size !== 'number') {
  5244. throw new TypeError('"size" argument must be a number')
  5245. } else if (size < 0) {
  5246. throw new RangeError('"size" argument must not be negative')
  5247. }
  5248. }
  5249. function alloc (that, size, fill, encoding) {
  5250. assertSize(size)
  5251. if (size <= 0) {
  5252. return createBuffer(that, size)
  5253. }
  5254. if (fill !== undefined) {
  5255. // Only pay attention to encoding if it's a string. This
  5256. // prevents accidentally sending in a number that would
  5257. // be interpretted as a start offset.
  5258. return typeof encoding === 'string'
  5259. ? createBuffer(that, size).fill(fill, encoding)
  5260. : createBuffer(that, size).fill(fill)
  5261. }
  5262. return createBuffer(that, size)
  5263. }
  5264. /**
  5265. * Creates a new filled Buffer instance.
  5266. * alloc(size[, fill[, encoding]])
  5267. **/
  5268. Buffer.alloc = function (size, fill, encoding) {
  5269. return alloc(null, size, fill, encoding)
  5270. }
  5271. function allocUnsafe (that, size) {
  5272. assertSize(size)
  5273. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5274. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5275. for (var i = 0; i < size; ++i) {
  5276. that[i] = 0
  5277. }
  5278. }
  5279. return that
  5280. }
  5281. /**
  5282. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5283. * */
  5284. Buffer.allocUnsafe = function (size) {
  5285. return allocUnsafe(null, size)
  5286. }
  5287. /**
  5288. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5289. */
  5290. Buffer.allocUnsafeSlow = function (size) {
  5291. return allocUnsafe(null, size)
  5292. }
  5293. function fromString (that, string, encoding) {
  5294. if (typeof encoding !== 'string' || encoding === '') {
  5295. encoding = 'utf8'
  5296. }
  5297. if (!Buffer.isEncoding(encoding)) {
  5298. throw new TypeError('"encoding" must be a valid string encoding')
  5299. }
  5300. var length = byteLength(string, encoding) | 0
  5301. that = createBuffer(that, length)
  5302. var actual = that.write(string, encoding)
  5303. if (actual !== length) {
  5304. // Writing a hex string, for example, that contains invalid characters will
  5305. // cause everything after the first invalid character to be ignored. (e.g.
  5306. // 'abxxcd' will be treated as 'ab')
  5307. that = that.slice(0, actual)
  5308. }
  5309. return that
  5310. }
  5311. function fromArrayLike (that, array) {
  5312. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5313. that = createBuffer(that, length)
  5314. for (var i = 0; i < length; i += 1) {
  5315. that[i] = array[i] & 255
  5316. }
  5317. return that
  5318. }
  5319. function fromArrayBuffer (that, array, byteOffset, length) {
  5320. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5321. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5322. throw new RangeError('\'offset\' is out of bounds')
  5323. }
  5324. if (array.byteLength < byteOffset + (length || 0)) {
  5325. throw new RangeError('\'length\' is out of bounds')
  5326. }
  5327. if (byteOffset === undefined && length === undefined) {
  5328. array = new Uint8Array(array)
  5329. } else if (length === undefined) {
  5330. array = new Uint8Array(array, byteOffset)
  5331. } else {
  5332. array = new Uint8Array(array, byteOffset, length)
  5333. }
  5334. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5335. // Return an augmented `Uint8Array` instance, for best performance
  5336. that = array
  5337. that.__proto__ = Buffer.prototype
  5338. } else {
  5339. // Fallback: Return an object instance of the Buffer class
  5340. that = fromArrayLike(that, array)
  5341. }
  5342. return that
  5343. }
  5344. function fromObject (that, obj) {
  5345. if (Buffer.isBuffer(obj)) {
  5346. var len = checked(obj.length) | 0
  5347. that = createBuffer(that, len)
  5348. if (that.length === 0) {
  5349. return that
  5350. }
  5351. obj.copy(that, 0, 0, len)
  5352. return that
  5353. }
  5354. if (obj) {
  5355. if ((typeof ArrayBuffer !== 'undefined' &&
  5356. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5357. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5358. return createBuffer(that, 0)
  5359. }
  5360. return fromArrayLike(that, obj)
  5361. }
  5362. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5363. return fromArrayLike(that, obj.data)
  5364. }
  5365. }
  5366. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5367. }
  5368. function checked (length) {
  5369. // Note: cannot use `length < kMaxLength()` here because that fails when
  5370. // length is NaN (which is otherwise coerced to zero.)
  5371. if (length >= kMaxLength()) {
  5372. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5373. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5374. }
  5375. return length | 0
  5376. }
  5377. function SlowBuffer (length) {
  5378. if (+length != length) { // eslint-disable-line eqeqeq
  5379. length = 0
  5380. }
  5381. return Buffer.alloc(+length)
  5382. }
  5383. Buffer.isBuffer = function isBuffer (b) {
  5384. return !!(b != null && b._isBuffer)
  5385. }
  5386. Buffer.compare = function compare (a, b) {
  5387. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5388. throw new TypeError('Arguments must be Buffers')
  5389. }
  5390. if (a === b) return 0
  5391. var x = a.length
  5392. var y = b.length
  5393. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5394. if (a[i] !== b[i]) {
  5395. x = a[i]
  5396. y = b[i]
  5397. break
  5398. }
  5399. }
  5400. if (x < y) return -1
  5401. if (y < x) return 1
  5402. return 0
  5403. }
  5404. Buffer.isEncoding = function isEncoding (encoding) {
  5405. switch (String(encoding).toLowerCase()) {
  5406. case 'hex':
  5407. case 'utf8':
  5408. case 'utf-8':
  5409. case 'ascii':
  5410. case 'latin1':
  5411. case 'binary':
  5412. case 'base64':
  5413. case 'ucs2':
  5414. case 'ucs-2':
  5415. case 'utf16le':
  5416. case 'utf-16le':
  5417. return true
  5418. default:
  5419. return false
  5420. }
  5421. }
  5422. Buffer.concat = function concat (list, length) {
  5423. if (!isArray(list)) {
  5424. throw new TypeError('"list" argument must be an Array of Buffers')
  5425. }
  5426. if (list.length === 0) {
  5427. return Buffer.alloc(0)
  5428. }
  5429. var i
  5430. if (length === undefined) {
  5431. length = 0
  5432. for (i = 0; i < list.length; ++i) {
  5433. length += list[i].length
  5434. }
  5435. }
  5436. var buffer = Buffer.allocUnsafe(length)
  5437. var pos = 0
  5438. for (i = 0; i < list.length; ++i) {
  5439. var buf = list[i]
  5440. if (!Buffer.isBuffer(buf)) {
  5441. throw new TypeError('"list" argument must be an Array of Buffers')
  5442. }
  5443. buf.copy(buffer, pos)
  5444. pos += buf.length
  5445. }
  5446. return buffer
  5447. }
  5448. function byteLength (string, encoding) {
  5449. if (Buffer.isBuffer(string)) {
  5450. return string.length
  5451. }
  5452. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5453. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5454. return string.byteLength
  5455. }
  5456. if (typeof string !== 'string') {
  5457. string = '' + string
  5458. }
  5459. var len = string.length
  5460. if (len === 0) return 0
  5461. // Use a for loop to avoid recursion
  5462. var loweredCase = false
  5463. for (;;) {
  5464. switch (encoding) {
  5465. case 'ascii':
  5466. case 'latin1':
  5467. case 'binary':
  5468. return len
  5469. case 'utf8':
  5470. case 'utf-8':
  5471. case undefined:
  5472. return utf8ToBytes(string).length
  5473. case 'ucs2':
  5474. case 'ucs-2':
  5475. case 'utf16le':
  5476. case 'utf-16le':
  5477. return len * 2
  5478. case 'hex':
  5479. return len >>> 1
  5480. case 'base64':
  5481. return base64ToBytes(string).length
  5482. default:
  5483. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5484. encoding = ('' + encoding).toLowerCase()
  5485. loweredCase = true
  5486. }
  5487. }
  5488. }
  5489. Buffer.byteLength = byteLength
  5490. function slowToString (encoding, start, end) {
  5491. var loweredCase = false
  5492. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5493. // property of a typed array.
  5494. // This behaves neither like String nor Uint8Array in that we set start/end
  5495. // to their upper/lower bounds if the value passed is out of range.
  5496. // undefined is handled specially as per ECMA-262 6th Edition,
  5497. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5498. if (start === undefined || start < 0) {
  5499. start = 0
  5500. }
  5501. // Return early if start > this.length. Done here to prevent potential uint32
  5502. // coercion fail below.
  5503. if (start > this.length) {
  5504. return ''
  5505. }
  5506. if (end === undefined || end > this.length) {
  5507. end = this.length
  5508. }
  5509. if (end <= 0) {
  5510. return ''
  5511. }
  5512. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5513. end >>>= 0
  5514. start >>>= 0
  5515. if (end <= start) {
  5516. return ''
  5517. }
  5518. if (!encoding) encoding = 'utf8'
  5519. while (true) {
  5520. switch (encoding) {
  5521. case 'hex':
  5522. return hexSlice(this, start, end)
  5523. case 'utf8':
  5524. case 'utf-8':
  5525. return utf8Slice(this, start, end)
  5526. case 'ascii':
  5527. return asciiSlice(this, start, end)
  5528. case 'latin1':
  5529. case 'binary':
  5530. return latin1Slice(this, start, end)
  5531. case 'base64':
  5532. return base64Slice(this, start, end)
  5533. case 'ucs2':
  5534. case 'ucs-2':
  5535. case 'utf16le':
  5536. case 'utf-16le':
  5537. return utf16leSlice(this, start, end)
  5538. default:
  5539. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5540. encoding = (encoding + '').toLowerCase()
  5541. loweredCase = true
  5542. }
  5543. }
  5544. }
  5545. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5546. // Buffer instances.
  5547. Buffer.prototype._isBuffer = true
  5548. function swap (b, n, m) {
  5549. var i = b[n]
  5550. b[n] = b[m]
  5551. b[m] = i
  5552. }
  5553. Buffer.prototype.swap16 = function swap16 () {
  5554. var len = this.length
  5555. if (len % 2 !== 0) {
  5556. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5557. }
  5558. for (var i = 0; i < len; i += 2) {
  5559. swap(this, i, i + 1)
  5560. }
  5561. return this
  5562. }
  5563. Buffer.prototype.swap32 = function swap32 () {
  5564. var len = this.length
  5565. if (len % 4 !== 0) {
  5566. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5567. }
  5568. for (var i = 0; i < len; i += 4) {
  5569. swap(this, i, i + 3)
  5570. swap(this, i + 1, i + 2)
  5571. }
  5572. return this
  5573. }
  5574. Buffer.prototype.swap64 = function swap64 () {
  5575. var len = this.length
  5576. if (len % 8 !== 0) {
  5577. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5578. }
  5579. for (var i = 0; i < len; i += 8) {
  5580. swap(this, i, i + 7)
  5581. swap(this, i + 1, i + 6)
  5582. swap(this, i + 2, i + 5)
  5583. swap(this, i + 3, i + 4)
  5584. }
  5585. return this
  5586. }
  5587. Buffer.prototype.toString = function toString () {
  5588. var length = this.length | 0
  5589. if (length === 0) return ''
  5590. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5591. return slowToString.apply(this, arguments)
  5592. }
  5593. Buffer.prototype.equals = function equals (b) {
  5594. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5595. if (this === b) return true
  5596. return Buffer.compare(this, b) === 0
  5597. }
  5598. Buffer.prototype.inspect = function inspect () {
  5599. var str = ''
  5600. var max = exports.INSPECT_MAX_BYTES
  5601. if (this.length > 0) {
  5602. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  5603. if (this.length > max) str += ' ... '
  5604. }
  5605. return '<Buffer ' + str + '>'
  5606. }
  5607. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  5608. if (!Buffer.isBuffer(target)) {
  5609. throw new TypeError('Argument must be a Buffer')
  5610. }
  5611. if (start === undefined) {
  5612. start = 0
  5613. }
  5614. if (end === undefined) {
  5615. end = target ? target.length : 0
  5616. }
  5617. if (thisStart === undefined) {
  5618. thisStart = 0
  5619. }
  5620. if (thisEnd === undefined) {
  5621. thisEnd = this.length
  5622. }
  5623. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  5624. throw new RangeError('out of range index')
  5625. }
  5626. if (thisStart >= thisEnd && start >= end) {
  5627. return 0
  5628. }
  5629. if (thisStart >= thisEnd) {
  5630. return -1
  5631. }
  5632. if (start >= end) {
  5633. return 1
  5634. }
  5635. start >>>= 0
  5636. end >>>= 0
  5637. thisStart >>>= 0
  5638. thisEnd >>>= 0
  5639. if (this === target) return 0
  5640. var x = thisEnd - thisStart
  5641. var y = end - start
  5642. var len = Math.min(x, y)
  5643. var thisCopy = this.slice(thisStart, thisEnd)
  5644. var targetCopy = target.slice(start, end)
  5645. for (var i = 0; i < len; ++i) {
  5646. if (thisCopy[i] !== targetCopy[i]) {
  5647. x = thisCopy[i]
  5648. y = targetCopy[i]
  5649. break
  5650. }
  5651. }
  5652. if (x < y) return -1
  5653. if (y < x) return 1
  5654. return 0
  5655. }
  5656. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  5657. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  5658. //
  5659. // Arguments:
  5660. // - buffer - a Buffer to search
  5661. // - val - a string, Buffer, or number
  5662. // - byteOffset - an index into `buffer`; will be clamped to an int32
  5663. // - encoding - an optional encoding, relevant is val is a string
  5664. // - dir - true for indexOf, false for lastIndexOf
  5665. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  5666. // Empty buffer means no match
  5667. if (buffer.length === 0) return -1
  5668. // Normalize byteOffset
  5669. if (typeof byteOffset === 'string') {
  5670. encoding = byteOffset
  5671. byteOffset = 0
  5672. } else if (byteOffset > 0x7fffffff) {
  5673. byteOffset = 0x7fffffff
  5674. } else if (byteOffset < -0x80000000) {
  5675. byteOffset = -0x80000000
  5676. }
  5677. byteOffset = +byteOffset // Coerce to Number.
  5678. if (isNaN(byteOffset)) {
  5679. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  5680. byteOffset = dir ? 0 : (buffer.length - 1)
  5681. }
  5682. // Normalize byteOffset: negative offsets start from the end of the buffer
  5683. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  5684. if (byteOffset >= buffer.length) {
  5685. if (dir) return -1
  5686. else byteOffset = buffer.length - 1
  5687. } else if (byteOffset < 0) {
  5688. if (dir) byteOffset = 0
  5689. else return -1
  5690. }
  5691. // Normalize val
  5692. if (typeof val === 'string') {
  5693. val = Buffer.from(val, encoding)
  5694. }
  5695. // Finally, search either indexOf (if dir is true) or lastIndexOf
  5696. if (Buffer.isBuffer(val)) {
  5697. // Special case: looking for empty string/buffer always fails
  5698. if (val.length === 0) {
  5699. return -1
  5700. }
  5701. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  5702. } else if (typeof val === 'number') {
  5703. val = val & 0xFF // Search for a byte value [0-255]
  5704. if (Buffer.TYPED_ARRAY_SUPPORT &&
  5705. typeof Uint8Array.prototype.indexOf === 'function') {
  5706. if (dir) {
  5707. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  5708. } else {
  5709. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  5710. }
  5711. }
  5712. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  5713. }
  5714. throw new TypeError('val must be string, number or Buffer')
  5715. }
  5716. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  5717. var indexSize = 1
  5718. var arrLength = arr.length
  5719. var valLength = val.length
  5720. if (encoding !== undefined) {
  5721. encoding = String(encoding).toLowerCase()
  5722. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  5723. encoding === 'utf16le' || encoding === 'utf-16le') {
  5724. if (arr.length < 2 || val.length < 2) {
  5725. return -1
  5726. }
  5727. indexSize = 2
  5728. arrLength /= 2
  5729. valLength /= 2
  5730. byteOffset /= 2
  5731. }
  5732. }
  5733. function read (buf, i) {
  5734. if (indexSize === 1) {
  5735. return buf[i]
  5736. } else {
  5737. return buf.readUInt16BE(i * indexSize)
  5738. }
  5739. }
  5740. var i
  5741. if (dir) {
  5742. var foundIndex = -1
  5743. for (i = byteOffset; i < arrLength; i++) {
  5744. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  5745. if (foundIndex === -1) foundIndex = i
  5746. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  5747. } else {
  5748. if (foundIndex !== -1) i -= i - foundIndex
  5749. foundIndex = -1
  5750. }
  5751. }
  5752. } else {
  5753. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  5754. for (i = byteOffset; i >= 0; i--) {
  5755. var found = true
  5756. for (var j = 0; j < valLength; j++) {
  5757. if (read(arr, i + j) !== read(val, j)) {
  5758. found = false
  5759. break
  5760. }
  5761. }
  5762. if (found) return i
  5763. }
  5764. }
  5765. return -1
  5766. }
  5767. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  5768. return this.indexOf(val, byteOffset, encoding) !== -1
  5769. }
  5770. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  5771. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  5772. }
  5773. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  5774. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  5775. }
  5776. function hexWrite (buf, string, offset, length) {
  5777. offset = Number(offset) || 0
  5778. var remaining = buf.length - offset
  5779. if (!length) {
  5780. length = remaining
  5781. } else {
  5782. length = Number(length)
  5783. if (length > remaining) {
  5784. length = remaining
  5785. }
  5786. }
  5787. // must be an even number of digits
  5788. var strLen = string.length
  5789. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  5790. if (length > strLen / 2) {
  5791. length = strLen / 2
  5792. }
  5793. for (var i = 0; i < length; ++i) {
  5794. var parsed = parseInt(string.substr(i * 2, 2), 16)
  5795. if (isNaN(parsed)) return i
  5796. buf[offset + i] = parsed
  5797. }
  5798. return i
  5799. }
  5800. function utf8Write (buf, string, offset, length) {
  5801. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  5802. }
  5803. function asciiWrite (buf, string, offset, length) {
  5804. return blitBuffer(asciiToBytes(string), buf, offset, length)
  5805. }
  5806. function latin1Write (buf, string, offset, length) {
  5807. return asciiWrite(buf, string, offset, length)
  5808. }
  5809. function base64Write (buf, string, offset, length) {
  5810. return blitBuffer(base64ToBytes(string), buf, offset, length)
  5811. }
  5812. function ucs2Write (buf, string, offset, length) {
  5813. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  5814. }
  5815. Buffer.prototype.write = function write (string, offset, length, encoding) {
  5816. // Buffer#write(string)
  5817. if (offset === undefined) {
  5818. encoding = 'utf8'
  5819. length = this.length
  5820. offset = 0
  5821. // Buffer#write(string, encoding)
  5822. } else if (length === undefined && typeof offset === 'string') {
  5823. encoding = offset
  5824. length = this.length
  5825. offset = 0
  5826. // Buffer#write(string, offset[, length][, encoding])
  5827. } else if (isFinite(offset)) {
  5828. offset = offset | 0
  5829. if (isFinite(length)) {
  5830. length = length | 0
  5831. if (encoding === undefined) encoding = 'utf8'
  5832. } else {
  5833. encoding = length
  5834. length = undefined
  5835. }
  5836. // legacy write(string, encoding, offset, length) - remove in v0.13
  5837. } else {
  5838. throw new Error(
  5839. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  5840. )
  5841. }
  5842. var remaining = this.length - offset
  5843. if (length === undefined || length > remaining) length = remaining
  5844. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  5845. throw new RangeError('Attempt to write outside buffer bounds')
  5846. }
  5847. if (!encoding) encoding = 'utf8'
  5848. var loweredCase = false
  5849. for (;;) {
  5850. switch (encoding) {
  5851. case 'hex':
  5852. return hexWrite(this, string, offset, length)
  5853. case 'utf8':
  5854. case 'utf-8':
  5855. return utf8Write(this, string, offset, length)
  5856. case 'ascii':
  5857. return asciiWrite(this, string, offset, length)
  5858. case 'latin1':
  5859. case 'binary':
  5860. return latin1Write(this, string, offset, length)
  5861. case 'base64':
  5862. // Warning: maxLength not taken into account in base64Write
  5863. return base64Write(this, string, offset, length)
  5864. case 'ucs2':
  5865. case 'ucs-2':
  5866. case 'utf16le':
  5867. case 'utf-16le':
  5868. return ucs2Write(this, string, offset, length)
  5869. default:
  5870. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5871. encoding = ('' + encoding).toLowerCase()
  5872. loweredCase = true
  5873. }
  5874. }
  5875. }
  5876. Buffer.prototype.toJSON = function toJSON () {
  5877. return {
  5878. type: 'Buffer',
  5879. data: Array.prototype.slice.call(this._arr || this, 0)
  5880. }
  5881. }
  5882. function base64Slice (buf, start, end) {
  5883. if (start === 0 && end === buf.length) {
  5884. return base64.fromByteArray(buf)
  5885. } else {
  5886. return base64.fromByteArray(buf.slice(start, end))
  5887. }
  5888. }
  5889. function utf8Slice (buf, start, end) {
  5890. end = Math.min(buf.length, end)
  5891. var res = []
  5892. var i = start
  5893. while (i < end) {
  5894. var firstByte = buf[i]
  5895. var codePoint = null
  5896. var bytesPerSequence = (firstByte > 0xEF) ? 4
  5897. : (firstByte > 0xDF) ? 3
  5898. : (firstByte > 0xBF) ? 2
  5899. : 1
  5900. if (i + bytesPerSequence <= end) {
  5901. var secondByte, thirdByte, fourthByte, tempCodePoint
  5902. switch (bytesPerSequence) {
  5903. case 1:
  5904. if (firstByte < 0x80) {
  5905. codePoint = firstByte
  5906. }
  5907. break
  5908. case 2:
  5909. secondByte = buf[i + 1]
  5910. if ((secondByte & 0xC0) === 0x80) {
  5911. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  5912. if (tempCodePoint > 0x7F) {
  5913. codePoint = tempCodePoint
  5914. }
  5915. }
  5916. break
  5917. case 3:
  5918. secondByte = buf[i + 1]
  5919. thirdByte = buf[i + 2]
  5920. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  5921. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  5922. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  5923. codePoint = tempCodePoint
  5924. }
  5925. }
  5926. break
  5927. case 4:
  5928. secondByte = buf[i + 1]
  5929. thirdByte = buf[i + 2]
  5930. fourthByte = buf[i + 3]
  5931. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  5932. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  5933. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  5934. codePoint = tempCodePoint
  5935. }
  5936. }
  5937. }
  5938. }
  5939. if (codePoint === null) {
  5940. // we did not generate a valid codePoint so insert a
  5941. // replacement char (U+FFFD) and advance only 1 byte
  5942. codePoint = 0xFFFD
  5943. bytesPerSequence = 1
  5944. } else if (codePoint > 0xFFFF) {
  5945. // encode to utf16 (surrogate pair dance)
  5946. codePoint -= 0x10000
  5947. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  5948. codePoint = 0xDC00 | codePoint & 0x3FF
  5949. }
  5950. res.push(codePoint)
  5951. i += bytesPerSequence
  5952. }
  5953. return decodeCodePointsArray(res)
  5954. }
  5955. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  5956. // the lowest limit is Chrome, with 0x10000 args.
  5957. // We go 1 magnitude less, for safety
  5958. var MAX_ARGUMENTS_LENGTH = 0x1000
  5959. function decodeCodePointsArray (codePoints) {
  5960. var len = codePoints.length
  5961. if (len <= MAX_ARGUMENTS_LENGTH) {
  5962. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  5963. }
  5964. // Decode in chunks to avoid "call stack size exceeded".
  5965. var res = ''
  5966. var i = 0
  5967. while (i < len) {
  5968. res += String.fromCharCode.apply(
  5969. String,
  5970. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  5971. )
  5972. }
  5973. return res
  5974. }
  5975. function asciiSlice (buf, start, end) {
  5976. var ret = ''
  5977. end = Math.min(buf.length, end)
  5978. for (var i = start; i < end; ++i) {
  5979. ret += String.fromCharCode(buf[i] & 0x7F)
  5980. }
  5981. return ret
  5982. }
  5983. function latin1Slice (buf, start, end) {
  5984. var ret = ''
  5985. end = Math.min(buf.length, end)
  5986. for (var i = start; i < end; ++i) {
  5987. ret += String.fromCharCode(buf[i])
  5988. }
  5989. return ret
  5990. }
  5991. function hexSlice (buf, start, end) {
  5992. var len = buf.length
  5993. if (!start || start < 0) start = 0
  5994. if (!end || end < 0 || end > len) end = len
  5995. var out = ''
  5996. for (var i = start; i < end; ++i) {
  5997. out += toHex(buf[i])
  5998. }
  5999. return out
  6000. }
  6001. function utf16leSlice (buf, start, end) {
  6002. var bytes = buf.slice(start, end)
  6003. var res = ''
  6004. for (var i = 0; i < bytes.length; i += 2) {
  6005. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6006. }
  6007. return res
  6008. }
  6009. Buffer.prototype.slice = function slice (start, end) {
  6010. var len = this.length
  6011. start = ~~start
  6012. end = end === undefined ? len : ~~end
  6013. if (start < 0) {
  6014. start += len
  6015. if (start < 0) start = 0
  6016. } else if (start > len) {
  6017. start = len
  6018. }
  6019. if (end < 0) {
  6020. end += len
  6021. if (end < 0) end = 0
  6022. } else if (end > len) {
  6023. end = len
  6024. }
  6025. if (end < start) end = start
  6026. var newBuf
  6027. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6028. newBuf = this.subarray(start, end)
  6029. newBuf.__proto__ = Buffer.prototype
  6030. } else {
  6031. var sliceLen = end - start
  6032. newBuf = new Buffer(sliceLen, undefined)
  6033. for (var i = 0; i < sliceLen; ++i) {
  6034. newBuf[i] = this[i + start]
  6035. }
  6036. }
  6037. return newBuf
  6038. }
  6039. /*
  6040. * Need to make sure that buffer isn't trying to write out of bounds.
  6041. */
  6042. function checkOffset (offset, ext, length) {
  6043. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6044. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6045. }
  6046. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6047. offset = offset | 0
  6048. byteLength = byteLength | 0
  6049. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6050. var val = this[offset]
  6051. var mul = 1
  6052. var i = 0
  6053. while (++i < byteLength && (mul *= 0x100)) {
  6054. val += this[offset + i] * mul
  6055. }
  6056. return val
  6057. }
  6058. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6059. offset = offset | 0
  6060. byteLength = byteLength | 0
  6061. if (!noAssert) {
  6062. checkOffset(offset, byteLength, this.length)
  6063. }
  6064. var val = this[offset + --byteLength]
  6065. var mul = 1
  6066. while (byteLength > 0 && (mul *= 0x100)) {
  6067. val += this[offset + --byteLength] * mul
  6068. }
  6069. return val
  6070. }
  6071. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6072. if (!noAssert) checkOffset(offset, 1, this.length)
  6073. return this[offset]
  6074. }
  6075. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6076. if (!noAssert) checkOffset(offset, 2, this.length)
  6077. return this[offset] | (this[offset + 1] << 8)
  6078. }
  6079. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6080. if (!noAssert) checkOffset(offset, 2, this.length)
  6081. return (this[offset] << 8) | this[offset + 1]
  6082. }
  6083. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6084. if (!noAssert) checkOffset(offset, 4, this.length)
  6085. return ((this[offset]) |
  6086. (this[offset + 1] << 8) |
  6087. (this[offset + 2] << 16)) +
  6088. (this[offset + 3] * 0x1000000)
  6089. }
  6090. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6091. if (!noAssert) checkOffset(offset, 4, this.length)
  6092. return (this[offset] * 0x1000000) +
  6093. ((this[offset + 1] << 16) |
  6094. (this[offset + 2] << 8) |
  6095. this[offset + 3])
  6096. }
  6097. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6098. offset = offset | 0
  6099. byteLength = byteLength | 0
  6100. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6101. var val = this[offset]
  6102. var mul = 1
  6103. var i = 0
  6104. while (++i < byteLength && (mul *= 0x100)) {
  6105. val += this[offset + i] * mul
  6106. }
  6107. mul *= 0x80
  6108. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6109. return val
  6110. }
  6111. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6112. offset = offset | 0
  6113. byteLength = byteLength | 0
  6114. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6115. var i = byteLength
  6116. var mul = 1
  6117. var val = this[offset + --i]
  6118. while (i > 0 && (mul *= 0x100)) {
  6119. val += this[offset + --i] * mul
  6120. }
  6121. mul *= 0x80
  6122. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6123. return val
  6124. }
  6125. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6126. if (!noAssert) checkOffset(offset, 1, this.length)
  6127. if (!(this[offset] & 0x80)) return (this[offset])
  6128. return ((0xff - this[offset] + 1) * -1)
  6129. }
  6130. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6131. if (!noAssert) checkOffset(offset, 2, this.length)
  6132. var val = this[offset] | (this[offset + 1] << 8)
  6133. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6134. }
  6135. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6136. if (!noAssert) checkOffset(offset, 2, this.length)
  6137. var val = this[offset + 1] | (this[offset] << 8)
  6138. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6139. }
  6140. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6141. if (!noAssert) checkOffset(offset, 4, this.length)
  6142. return (this[offset]) |
  6143. (this[offset + 1] << 8) |
  6144. (this[offset + 2] << 16) |
  6145. (this[offset + 3] << 24)
  6146. }
  6147. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6148. if (!noAssert) checkOffset(offset, 4, this.length)
  6149. return (this[offset] << 24) |
  6150. (this[offset + 1] << 16) |
  6151. (this[offset + 2] << 8) |
  6152. (this[offset + 3])
  6153. }
  6154. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6155. if (!noAssert) checkOffset(offset, 4, this.length)
  6156. return ieee754.read(this, offset, true, 23, 4)
  6157. }
  6158. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6159. if (!noAssert) checkOffset(offset, 4, this.length)
  6160. return ieee754.read(this, offset, false, 23, 4)
  6161. }
  6162. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6163. if (!noAssert) checkOffset(offset, 8, this.length)
  6164. return ieee754.read(this, offset, true, 52, 8)
  6165. }
  6166. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6167. if (!noAssert) checkOffset(offset, 8, this.length)
  6168. return ieee754.read(this, offset, false, 52, 8)
  6169. }
  6170. function checkInt (buf, value, offset, ext, max, min) {
  6171. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6172. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6173. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6174. }
  6175. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6176. value = +value
  6177. offset = offset | 0
  6178. byteLength = byteLength | 0
  6179. if (!noAssert) {
  6180. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6181. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6182. }
  6183. var mul = 1
  6184. var i = 0
  6185. this[offset] = value & 0xFF
  6186. while (++i < byteLength && (mul *= 0x100)) {
  6187. this[offset + i] = (value / mul) & 0xFF
  6188. }
  6189. return offset + byteLength
  6190. }
  6191. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6192. value = +value
  6193. offset = offset | 0
  6194. byteLength = byteLength | 0
  6195. if (!noAssert) {
  6196. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6197. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6198. }
  6199. var i = byteLength - 1
  6200. var mul = 1
  6201. this[offset + i] = value & 0xFF
  6202. while (--i >= 0 && (mul *= 0x100)) {
  6203. this[offset + i] = (value / mul) & 0xFF
  6204. }
  6205. return offset + byteLength
  6206. }
  6207. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6208. value = +value
  6209. offset = offset | 0
  6210. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6211. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6212. this[offset] = (value & 0xff)
  6213. return offset + 1
  6214. }
  6215. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6216. if (value < 0) value = 0xffff + value + 1
  6217. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6218. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6219. (littleEndian ? i : 1 - i) * 8
  6220. }
  6221. }
  6222. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6223. value = +value
  6224. offset = offset | 0
  6225. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6226. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6227. this[offset] = (value & 0xff)
  6228. this[offset + 1] = (value >>> 8)
  6229. } else {
  6230. objectWriteUInt16(this, value, offset, true)
  6231. }
  6232. return offset + 2
  6233. }
  6234. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6235. value = +value
  6236. offset = offset | 0
  6237. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6238. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6239. this[offset] = (value >>> 8)
  6240. this[offset + 1] = (value & 0xff)
  6241. } else {
  6242. objectWriteUInt16(this, value, offset, false)
  6243. }
  6244. return offset + 2
  6245. }
  6246. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6247. if (value < 0) value = 0xffffffff + value + 1
  6248. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6249. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6250. }
  6251. }
  6252. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6253. value = +value
  6254. offset = offset | 0
  6255. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6256. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6257. this[offset + 3] = (value >>> 24)
  6258. this[offset + 2] = (value >>> 16)
  6259. this[offset + 1] = (value >>> 8)
  6260. this[offset] = (value & 0xff)
  6261. } else {
  6262. objectWriteUInt32(this, value, offset, true)
  6263. }
  6264. return offset + 4
  6265. }
  6266. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6267. value = +value
  6268. offset = offset | 0
  6269. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6270. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6271. this[offset] = (value >>> 24)
  6272. this[offset + 1] = (value >>> 16)
  6273. this[offset + 2] = (value >>> 8)
  6274. this[offset + 3] = (value & 0xff)
  6275. } else {
  6276. objectWriteUInt32(this, value, offset, false)
  6277. }
  6278. return offset + 4
  6279. }
  6280. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6281. value = +value
  6282. offset = offset | 0
  6283. if (!noAssert) {
  6284. var limit = Math.pow(2, 8 * byteLength - 1)
  6285. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6286. }
  6287. var i = 0
  6288. var mul = 1
  6289. var sub = 0
  6290. this[offset] = value & 0xFF
  6291. while (++i < byteLength && (mul *= 0x100)) {
  6292. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6293. sub = 1
  6294. }
  6295. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6296. }
  6297. return offset + byteLength
  6298. }
  6299. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6300. value = +value
  6301. offset = offset | 0
  6302. if (!noAssert) {
  6303. var limit = Math.pow(2, 8 * byteLength - 1)
  6304. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6305. }
  6306. var i = byteLength - 1
  6307. var mul = 1
  6308. var sub = 0
  6309. this[offset + i] = value & 0xFF
  6310. while (--i >= 0 && (mul *= 0x100)) {
  6311. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6312. sub = 1
  6313. }
  6314. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6315. }
  6316. return offset + byteLength
  6317. }
  6318. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6319. value = +value
  6320. offset = offset | 0
  6321. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6322. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6323. if (value < 0) value = 0xff + value + 1
  6324. this[offset] = (value & 0xff)
  6325. return offset + 1
  6326. }
  6327. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6328. value = +value
  6329. offset = offset | 0
  6330. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6331. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6332. this[offset] = (value & 0xff)
  6333. this[offset + 1] = (value >>> 8)
  6334. } else {
  6335. objectWriteUInt16(this, value, offset, true)
  6336. }
  6337. return offset + 2
  6338. }
  6339. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6340. value = +value
  6341. offset = offset | 0
  6342. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6343. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6344. this[offset] = (value >>> 8)
  6345. this[offset + 1] = (value & 0xff)
  6346. } else {
  6347. objectWriteUInt16(this, value, offset, false)
  6348. }
  6349. return offset + 2
  6350. }
  6351. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6352. value = +value
  6353. offset = offset | 0
  6354. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6355. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6356. this[offset] = (value & 0xff)
  6357. this[offset + 1] = (value >>> 8)
  6358. this[offset + 2] = (value >>> 16)
  6359. this[offset + 3] = (value >>> 24)
  6360. } else {
  6361. objectWriteUInt32(this, value, offset, true)
  6362. }
  6363. return offset + 4
  6364. }
  6365. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6366. value = +value
  6367. offset = offset | 0
  6368. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6369. if (value < 0) value = 0xffffffff + value + 1
  6370. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6371. this[offset] = (value >>> 24)
  6372. this[offset + 1] = (value >>> 16)
  6373. this[offset + 2] = (value >>> 8)
  6374. this[offset + 3] = (value & 0xff)
  6375. } else {
  6376. objectWriteUInt32(this, value, offset, false)
  6377. }
  6378. return offset + 4
  6379. }
  6380. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6381. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6382. if (offset < 0) throw new RangeError('Index out of range')
  6383. }
  6384. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6385. if (!noAssert) {
  6386. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6387. }
  6388. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6389. return offset + 4
  6390. }
  6391. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6392. return writeFloat(this, value, offset, true, noAssert)
  6393. }
  6394. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6395. return writeFloat(this, value, offset, false, noAssert)
  6396. }
  6397. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6398. if (!noAssert) {
  6399. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6400. }
  6401. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6402. return offset + 8
  6403. }
  6404. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6405. return writeDouble(this, value, offset, true, noAssert)
  6406. }
  6407. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6408. return writeDouble(this, value, offset, false, noAssert)
  6409. }
  6410. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6411. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6412. if (!start) start = 0
  6413. if (!end && end !== 0) end = this.length
  6414. if (targetStart >= target.length) targetStart = target.length
  6415. if (!targetStart) targetStart = 0
  6416. if (end > 0 && end < start) end = start
  6417. // Copy 0 bytes; we're done
  6418. if (end === start) return 0
  6419. if (target.length === 0 || this.length === 0) return 0
  6420. // Fatal error conditions
  6421. if (targetStart < 0) {
  6422. throw new RangeError('targetStart out of bounds')
  6423. }
  6424. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6425. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6426. // Are we oob?
  6427. if (end > this.length) end = this.length
  6428. if (target.length - targetStart < end - start) {
  6429. end = target.length - targetStart + start
  6430. }
  6431. var len = end - start
  6432. var i
  6433. if (this === target && start < targetStart && targetStart < end) {
  6434. // descending copy from end
  6435. for (i = len - 1; i >= 0; --i) {
  6436. target[i + targetStart] = this[i + start]
  6437. }
  6438. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6439. // ascending copy from start
  6440. for (i = 0; i < len; ++i) {
  6441. target[i + targetStart] = this[i + start]
  6442. }
  6443. } else {
  6444. Uint8Array.prototype.set.call(
  6445. target,
  6446. this.subarray(start, start + len),
  6447. targetStart
  6448. )
  6449. }
  6450. return len
  6451. }
  6452. // Usage:
  6453. // buffer.fill(number[, offset[, end]])
  6454. // buffer.fill(buffer[, offset[, end]])
  6455. // buffer.fill(string[, offset[, end]][, encoding])
  6456. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6457. // Handle string cases:
  6458. if (typeof val === 'string') {
  6459. if (typeof start === 'string') {
  6460. encoding = start
  6461. start = 0
  6462. end = this.length
  6463. } else if (typeof end === 'string') {
  6464. encoding = end
  6465. end = this.length
  6466. }
  6467. if (val.length === 1) {
  6468. var code = val.charCodeAt(0)
  6469. if (code < 256) {
  6470. val = code
  6471. }
  6472. }
  6473. if (encoding !== undefined && typeof encoding !== 'string') {
  6474. throw new TypeError('encoding must be a string')
  6475. }
  6476. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6477. throw new TypeError('Unknown encoding: ' + encoding)
  6478. }
  6479. } else if (typeof val === 'number') {
  6480. val = val & 255
  6481. }
  6482. // Invalid ranges are not set to a default, so can range check early.
  6483. if (start < 0 || this.length < start || this.length < end) {
  6484. throw new RangeError('Out of range index')
  6485. }
  6486. if (end <= start) {
  6487. return this
  6488. }
  6489. start = start >>> 0
  6490. end = end === undefined ? this.length : end >>> 0
  6491. if (!val) val = 0
  6492. var i
  6493. if (typeof val === 'number') {
  6494. for (i = start; i < end; ++i) {
  6495. this[i] = val
  6496. }
  6497. } else {
  6498. var bytes = Buffer.isBuffer(val)
  6499. ? val
  6500. : utf8ToBytes(new Buffer(val, encoding).toString())
  6501. var len = bytes.length
  6502. for (i = 0; i < end - start; ++i) {
  6503. this[i + start] = bytes[i % len]
  6504. }
  6505. }
  6506. return this
  6507. }
  6508. // HELPER FUNCTIONS
  6509. // ================
  6510. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6511. function base64clean (str) {
  6512. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6513. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6514. // Node converts strings with length < 2 to ''
  6515. if (str.length < 2) return ''
  6516. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6517. while (str.length % 4 !== 0) {
  6518. str = str + '='
  6519. }
  6520. return str
  6521. }
  6522. function stringtrim (str) {
  6523. if (str.trim) return str.trim()
  6524. return str.replace(/^\s+|\s+$/g, '')
  6525. }
  6526. function toHex (n) {
  6527. if (n < 16) return '0' + n.toString(16)
  6528. return n.toString(16)
  6529. }
  6530. function utf8ToBytes (string, units) {
  6531. units = units || Infinity
  6532. var codePoint
  6533. var length = string.length
  6534. var leadSurrogate = null
  6535. var bytes = []
  6536. for (var i = 0; i < length; ++i) {
  6537. codePoint = string.charCodeAt(i)
  6538. // is surrogate component
  6539. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6540. // last char was a lead
  6541. if (!leadSurrogate) {
  6542. // no lead yet
  6543. if (codePoint > 0xDBFF) {
  6544. // unexpected trail
  6545. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6546. continue
  6547. } else if (i + 1 === length) {
  6548. // unpaired lead
  6549. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6550. continue
  6551. }
  6552. // valid lead
  6553. leadSurrogate = codePoint
  6554. continue
  6555. }
  6556. // 2 leads in a row
  6557. if (codePoint < 0xDC00) {
  6558. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6559. leadSurrogate = codePoint
  6560. continue
  6561. }
  6562. // valid surrogate pair
  6563. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6564. } else if (leadSurrogate) {
  6565. // valid bmp char, but last char was a lead
  6566. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6567. }
  6568. leadSurrogate = null
  6569. // encode utf8
  6570. if (codePoint < 0x80) {
  6571. if ((units -= 1) < 0) break
  6572. bytes.push(codePoint)
  6573. } else if (codePoint < 0x800) {
  6574. if ((units -= 2) < 0) break
  6575. bytes.push(
  6576. codePoint >> 0x6 | 0xC0,
  6577. codePoint & 0x3F | 0x80
  6578. )
  6579. } else if (codePoint < 0x10000) {
  6580. if ((units -= 3) < 0) break
  6581. bytes.push(
  6582. codePoint >> 0xC | 0xE0,
  6583. codePoint >> 0x6 & 0x3F | 0x80,
  6584. codePoint & 0x3F | 0x80
  6585. )
  6586. } else if (codePoint < 0x110000) {
  6587. if ((units -= 4) < 0) break
  6588. bytes.push(
  6589. codePoint >> 0x12 | 0xF0,
  6590. codePoint >> 0xC & 0x3F | 0x80,
  6591. codePoint >> 0x6 & 0x3F | 0x80,
  6592. codePoint & 0x3F | 0x80
  6593. )
  6594. } else {
  6595. throw new Error('Invalid code point')
  6596. }
  6597. }
  6598. return bytes
  6599. }
  6600. function asciiToBytes (str) {
  6601. var byteArray = []
  6602. for (var i = 0; i < str.length; ++i) {
  6603. // Node's code seems to be doing this and not & 0x7F..
  6604. byteArray.push(str.charCodeAt(i) & 0xFF)
  6605. }
  6606. return byteArray
  6607. }
  6608. function utf16leToBytes (str, units) {
  6609. var c, hi, lo
  6610. var byteArray = []
  6611. for (var i = 0; i < str.length; ++i) {
  6612. if ((units -= 2) < 0) break
  6613. c = str.charCodeAt(i)
  6614. hi = c >> 8
  6615. lo = c % 256
  6616. byteArray.push(lo)
  6617. byteArray.push(hi)
  6618. }
  6619. return byteArray
  6620. }
  6621. function base64ToBytes (str) {
  6622. return base64.toByteArray(base64clean(str))
  6623. }
  6624. function blitBuffer (src, dst, offset, length) {
  6625. for (var i = 0; i < length; ++i) {
  6626. if ((i + offset >= dst.length) || (i >= src.length)) break
  6627. dst[i + offset] = src[i]
  6628. }
  6629. return i
  6630. }
  6631. function isnan (val) {
  6632. return val !== val // eslint-disable-line no-self-compare
  6633. }
  6634. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24)))
  6635. /***/ }),
  6636. /* 50 */
  6637. /***/ (function(module, exports, __webpack_require__) {
  6638. // browser shim for xmlhttprequest module
  6639. var hasCORS = __webpack_require__(119);
  6640. module.exports = function (opts) {
  6641. var xdomain = opts.xdomain;
  6642. // scheme must be same when usign XDomainRequest
  6643. // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
  6644. var xscheme = opts.xscheme;
  6645. // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
  6646. // https://github.com/Automattic/engine.io-client/pull/217
  6647. var enablesXDR = opts.enablesXDR;
  6648. // XMLHttpRequest can be disabled on IE
  6649. try {
  6650. if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
  6651. return new XMLHttpRequest();
  6652. }
  6653. } catch (e) { }
  6654. // Use XDomainRequest for IE8 if enablesXDR is true
  6655. // because loading bar keeps flashing when using jsonp-polling
  6656. // https://github.com/yujiosaka/socke.io-ie8-loading-example
  6657. try {
  6658. if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
  6659. return new XDomainRequest();
  6660. }
  6661. } catch (e) { }
  6662. if (!xdomain) {
  6663. try {
  6664. return new self[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP');
  6665. } catch (e) { }
  6666. }
  6667. };
  6668. /***/ }),
  6669. /* 51 */
  6670. /***/ (function(module, exports, __webpack_require__) {
  6671. /**
  6672. * Module dependencies.
  6673. */
  6674. var parser = __webpack_require__(18);
  6675. var Emitter = __webpack_require__(17);
  6676. /**
  6677. * Module exports.
  6678. */
  6679. module.exports = Transport;
  6680. /**
  6681. * Transport abstract constructor.
  6682. *
  6683. * @param {Object} options.
  6684. * @api private
  6685. */
  6686. function Transport (opts) {
  6687. this.path = opts.path;
  6688. this.hostname = opts.hostname;
  6689. this.port = opts.port;
  6690. this.secure = opts.secure;
  6691. this.query = opts.query;
  6692. this.timestampParam = opts.timestampParam;
  6693. this.timestampRequests = opts.timestampRequests;
  6694. this.readyState = '';
  6695. this.agent = opts.agent || false;
  6696. this.socket = opts.socket;
  6697. this.enablesXDR = opts.enablesXDR;
  6698. // SSL options for Node.js client
  6699. this.pfx = opts.pfx;
  6700. this.key = opts.key;
  6701. this.passphrase = opts.passphrase;
  6702. this.cert = opts.cert;
  6703. this.ca = opts.ca;
  6704. this.ciphers = opts.ciphers;
  6705. this.rejectUnauthorized = opts.rejectUnauthorized;
  6706. this.forceNode = opts.forceNode;
  6707. // results of ReactNative environment detection
  6708. this.isReactNative = opts.isReactNative;
  6709. // other options for Node.js client
  6710. this.extraHeaders = opts.extraHeaders;
  6711. this.localAddress = opts.localAddress;
  6712. }
  6713. /**
  6714. * Mix in `Emitter`.
  6715. */
  6716. Emitter(Transport.prototype);
  6717. /**
  6718. * Emits an error.
  6719. *
  6720. * @param {String} str
  6721. * @return {Transport} for chaining
  6722. * @api public
  6723. */
  6724. Transport.prototype.onError = function (msg, desc) {
  6725. var err = new Error(msg);
  6726. err.type = 'TransportError';
  6727. err.description = desc;
  6728. this.emit('error', err);
  6729. return this;
  6730. };
  6731. /**
  6732. * Opens the transport.
  6733. *
  6734. * @api public
  6735. */
  6736. Transport.prototype.open = function () {
  6737. if ('closed' === this.readyState || '' === this.readyState) {
  6738. this.readyState = 'opening';
  6739. this.doOpen();
  6740. }
  6741. return this;
  6742. };
  6743. /**
  6744. * Closes the transport.
  6745. *
  6746. * @api private
  6747. */
  6748. Transport.prototype.close = function () {
  6749. if ('opening' === this.readyState || 'open' === this.readyState) {
  6750. this.doClose();
  6751. this.onClose();
  6752. }
  6753. return this;
  6754. };
  6755. /**
  6756. * Sends multiple packets.
  6757. *
  6758. * @param {Array} packets
  6759. * @api private
  6760. */
  6761. Transport.prototype.send = function (packets) {
  6762. if ('open' === this.readyState) {
  6763. this.write(packets);
  6764. } else {
  6765. throw new Error('Transport not open');
  6766. }
  6767. };
  6768. /**
  6769. * Called upon open
  6770. *
  6771. * @api private
  6772. */
  6773. Transport.prototype.onOpen = function () {
  6774. this.readyState = 'open';
  6775. this.writable = true;
  6776. this.emit('open');
  6777. };
  6778. /**
  6779. * Called with data.
  6780. *
  6781. * @param {String} data
  6782. * @api private
  6783. */
  6784. Transport.prototype.onData = function (data) {
  6785. var packet = parser.decodePacket(data, this.socket.binaryType);
  6786. this.onPacket(packet);
  6787. };
  6788. /**
  6789. * Called with a decoded packet.
  6790. */
  6791. Transport.prototype.onPacket = function (packet) {
  6792. this.emit('packet', packet);
  6793. };
  6794. /**
  6795. * Called upon close.
  6796. *
  6797. * @api private
  6798. */
  6799. Transport.prototype.onClose = function () {
  6800. this.readyState = 'closed';
  6801. this.emit('close');
  6802. };
  6803. /***/ }),
  6804. /* 52 */
  6805. /***/ (function(module, exports, __webpack_require__) {
  6806. "use strict";
  6807. var TimerObservable_1 = __webpack_require__(138);
  6808. exports.timer = TimerObservable_1.TimerObservable.create;
  6809. //# sourceMappingURL=timer.js.map
  6810. /***/ }),
  6811. /* 53 */
  6812. /***/ (function(module, exports, __webpack_require__) {
  6813. "use strict";
  6814. Object.defineProperty(exports, "__esModule", { value: true });
  6815. var ignoreElements_1 = __webpack_require__(11);
  6816. var tap_1 = __webpack_require__(5);
  6817. var effects_1 = __webpack_require__(8);
  6818. /**
  6819. * Set the local client options
  6820. * @param xs
  6821. * @param inputs
  6822. */
  6823. function setOptionsEffect(xs, inputs) {
  6824. return xs.pipe(tap_1.tap(function (options) { return inputs.option$.next(options); }),
  6825. // map(() => consoleInfo('set options'))
  6826. ignoreElements_1.ignoreElements());
  6827. }
  6828. exports.setOptionsEffect = setOptionsEffect;
  6829. function setOptions(options) {
  6830. return [effects_1.EffectNames.SetOptions, options];
  6831. }
  6832. exports.setOptions = setOptions;
  6833. /***/ }),
  6834. /* 54 */
  6835. /***/ (function(module, exports, __webpack_require__) {
  6836. "use strict";
  6837. var isScheduler_1 = __webpack_require__(25);
  6838. var of_1 = __webpack_require__(9);
  6839. var from_1 = __webpack_require__(87);
  6840. var concatAll_1 = __webpack_require__(150);
  6841. /* tslint:enable:max-line-length */
  6842. /**
  6843. * Creates an output Observable which sequentially emits all values from given
  6844. * Observable and then moves on to the next.
  6845. *
  6846. * <span class="informal">Concatenates multiple Observables together by
  6847. * sequentially emitting their values, one Observable after the other.</span>
  6848. *
  6849. * <img src="./img/concat.png" width="100%">
  6850. *
  6851. * `concat` joins multiple Observables together, by subscribing to them one at a time and
  6852. * merging their results into the output Observable. You can pass either an array of
  6853. * Observables, or put them directly as arguments. Passing an empty array will result
  6854. * in Observable that completes immediately.
  6855. *
  6856. * `concat` will subscribe to first input Observable and emit all its values, without
  6857. * changing or affecting them in any way. When that Observable completes, it will
  6858. * subscribe to then next Observable passed and, again, emit its values. This will be
  6859. * repeated, until the operator runs out of Observables. When last input Observable completes,
  6860. * `concat` will complete as well. At any given moment only one Observable passed to operator
  6861. * emits values. If you would like to emit values from passed Observables concurrently, check out
  6862. * {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact,
  6863. * `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`.
  6864. *
  6865. * Note that if some input Observable never completes, `concat` will also never complete
  6866. * and Observables following the one that did not complete will never be subscribed. On the other
  6867. * hand, if some Observable simply completes immediately after it is subscribed, it will be
  6868. * invisible for `concat`, which will just move on to the next Observable.
  6869. *
  6870. * If any Observable in chain errors, instead of passing control to the next Observable,
  6871. * `concat` will error immediately as well. Observables that would be subscribed after
  6872. * the one that emitted error, never will.
  6873. *
  6874. * If you pass to `concat` the same Observable many times, its stream of values
  6875. * will be "replayed" on every subscription, which means you can repeat given Observable
  6876. * as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious,
  6877. * you can always use {@link repeat}.
  6878. *
  6879. * @example <caption>Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10</caption>
  6880. * var timer = Rx.Observable.interval(1000).take(4);
  6881. * var sequence = Rx.Observable.range(1, 10);
  6882. * var result = Rx.Observable.concat(timer, sequence);
  6883. * result.subscribe(x => console.log(x));
  6884. *
  6885. * // results in:
  6886. * // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10
  6887. *
  6888. *
  6889. * @example <caption>Concatenate an array of 3 Observables</caption>
  6890. * var timer1 = Rx.Observable.interval(1000).take(10);
  6891. * var timer2 = Rx.Observable.interval(2000).take(6);
  6892. * var timer3 = Rx.Observable.interval(500).take(10);
  6893. * var result = Rx.Observable.concat([timer1, timer2, timer3]); // note that array is passed
  6894. * result.subscribe(x => console.log(x));
  6895. *
  6896. * // results in the following:
  6897. * // (Prints to console sequentially)
  6898. * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9
  6899. * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5
  6900. * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9
  6901. *
  6902. *
  6903. * @example <caption>Concatenate the same Observable to repeat it</caption>
  6904. * const timer = Rx.Observable.interval(1000).take(2);
  6905. *
  6906. * Rx.Observable.concat(timer, timer) // concating the same Observable!
  6907. * .subscribe(
  6908. * value => console.log(value),
  6909. * err => {},
  6910. * () => console.log('...and it is done!')
  6911. * );
  6912. *
  6913. * // Logs:
  6914. * // 0 after 1s
  6915. * // 1 after 2s
  6916. * // 0 after 3s
  6917. * // 1 after 4s
  6918. * // "...and it is done!" also after 4s
  6919. *
  6920. * @see {@link concatAll}
  6921. * @see {@link concatMap}
  6922. * @see {@link concatMapTo}
  6923. *
  6924. * @param {ObservableInput} input1 An input Observable to concatenate with others.
  6925. * @param {ObservableInput} input2 An input Observable to concatenate with others.
  6926. * More than one input Observables may be given as argument.
  6927. * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each
  6928. * Observable subscription on.
  6929. * @return {Observable} All values of each passed Observable merged into a
  6930. * single Observable, in order, in serial fashion.
  6931. * @static true
  6932. * @name concat
  6933. * @owner Observable
  6934. */
  6935. function concat() {
  6936. var observables = [];
  6937. for (var _i = 0; _i < arguments.length; _i++) {
  6938. observables[_i - 0] = arguments[_i];
  6939. }
  6940. if (observables.length === 1 || (observables.length === 2 && isScheduler_1.isScheduler(observables[1]))) {
  6941. return from_1.from(observables[0]);
  6942. }
  6943. return concatAll_1.concatAll()(of_1.of.apply(void 0, observables));
  6944. }
  6945. exports.concat = concat;
  6946. //# sourceMappingURL=concat.js.map
  6947. /***/ }),
  6948. /* 55 */
  6949. /***/ (function(module, exports, __webpack_require__) {
  6950. "use strict";
  6951. var mergeMap_1 = __webpack_require__(15);
  6952. var identity_1 = __webpack_require__(151);
  6953. /**
  6954. * Converts a higher-order Observable into a first-order Observable which
  6955. * concurrently delivers all values that are emitted on the inner Observables.
  6956. *
  6957. * <span class="informal">Flattens an Observable-of-Observables.</span>
  6958. *
  6959. * <img src="./img/mergeAll.png" width="100%">
  6960. *
  6961. * `mergeAll` subscribes to an Observable that emits Observables, also known as
  6962. * a higher-order Observable. Each time it observes one of these emitted inner
  6963. * Observables, it subscribes to that and delivers all the values from the
  6964. * inner Observable on the output Observable. The output Observable only
  6965. * completes once all inner Observables have completed. Any error delivered by
  6966. * a inner Observable will be immediately emitted on the output Observable.
  6967. *
  6968. * @example <caption>Spawn a new interval Observable for each click event, and blend their outputs as one Observable</caption>
  6969. * var clicks = Rx.Observable.fromEvent(document, 'click');
  6970. * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
  6971. * var firstOrder = higherOrder.mergeAll();
  6972. * firstOrder.subscribe(x => console.log(x));
  6973. *
  6974. * @example <caption>Count from 0 to 9 every second for each click, but only allow 2 concurrent timers</caption>
  6975. * var clicks = Rx.Observable.fromEvent(document, 'click');
  6976. * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10));
  6977. * var firstOrder = higherOrder.mergeAll(2);
  6978. * firstOrder.subscribe(x => console.log(x));
  6979. *
  6980. * @see {@link combineAll}
  6981. * @see {@link concatAll}
  6982. * @see {@link exhaust}
  6983. * @see {@link merge}
  6984. * @see {@link mergeMap}
  6985. * @see {@link mergeMapTo}
  6986. * @see {@link mergeScan}
  6987. * @see {@link switch}
  6988. * @see {@link zipAll}
  6989. *
  6990. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
  6991. * Observables being subscribed to concurrently.
  6992. * @return {Observable} An Observable that emits values coming from all the
  6993. * inner Observables emitted by the source Observable.
  6994. * @method mergeAll
  6995. * @owner Observable
  6996. */
  6997. function mergeAll(concurrent) {
  6998. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  6999. return mergeMap_1.mergeMap(identity_1.identity, null, concurrent);
  7000. }
  7001. exports.mergeAll = mergeAll;
  7002. //# sourceMappingURL=mergeAll.js.map
  7003. /***/ }),
  7004. /* 56 */
  7005. /***/ (function(module, exports, __webpack_require__) {
  7006. "use strict";
  7007. function isObject(x) {
  7008. return x != null && typeof x === 'object';
  7009. }
  7010. exports.isObject = isObject;
  7011. //# sourceMappingURL=isObject.js.map
  7012. /***/ }),
  7013. /* 57 */
  7014. /***/ (function(module, exports, __webpack_require__) {
  7015. "use strict";
  7016. exports.empty = {
  7017. closed: true,
  7018. next: function (value) { },
  7019. error: function (err) { throw err; },
  7020. complete: function () { }
  7021. };
  7022. //# sourceMappingURL=Observer.js.map
  7023. /***/ }),
  7024. /* 58 */
  7025. /***/ (function(module, exports, __webpack_require__) {
  7026. "use strict";
  7027. /* tslint:disable:no-empty */
  7028. function noop() { }
  7029. exports.noop = noop;
  7030. //# sourceMappingURL=noop.js.map
  7031. /***/ }),
  7032. /* 59 */
  7033. /***/ (function(module, exports, __webpack_require__) {
  7034. "use strict";
  7035. exports.isArrayLike = (function (x) { return x && typeof x.length === 'number'; });
  7036. //# sourceMappingURL=isArrayLike.js.map
  7037. /***/ }),
  7038. /* 60 */
  7039. /***/ (function(module, exports, __webpack_require__) {
  7040. "use strict";
  7041. function isPromise(value) {
  7042. return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
  7043. }
  7044. exports.isPromise = isPromise;
  7045. //# sourceMappingURL=isPromise.js.map
  7046. /***/ }),
  7047. /* 61 */
  7048. /***/ (function(module, exports) {
  7049. /**
  7050. * Parses an URI
  7051. *
  7052. * @author Steven Levithan <stevenlevithan.com> (MIT license)
  7053. * @api private
  7054. */
  7055. var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
  7056. var parts = [
  7057. 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
  7058. ];
  7059. module.exports = function parseuri(str) {
  7060. var src = str,
  7061. b = str.indexOf('['),
  7062. e = str.indexOf(']');
  7063. if (b != -1 && e != -1) {
  7064. str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
  7065. }
  7066. var m = re.exec(str || ''),
  7067. uri = {},
  7068. i = 14;
  7069. while (i--) {
  7070. uri[parts[i]] = m[i] || '';
  7071. }
  7072. if (b != -1 && e != -1) {
  7073. uri.source = src;
  7074. uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
  7075. uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
  7076. uri.ipv6uri = true;
  7077. }
  7078. return uri;
  7079. };
  7080. /***/ }),
  7081. /* 62 */
  7082. /***/ (function(module, exports) {
  7083. var toString = {}.toString;
  7084. module.exports = Array.isArray || function (arr) {
  7085. return toString.call(arr) == '[object Array]';
  7086. };
  7087. /***/ }),
  7088. /* 63 */
  7089. /***/ (function(module, exports, __webpack_require__) {
  7090. /* WEBPACK VAR INJECTION */(function(Buffer) {
  7091. module.exports = isBuf;
  7092. var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function';
  7093. var withNativeArrayBuffer = typeof ArrayBuffer === 'function';
  7094. var isView = function (obj) {
  7095. return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer);
  7096. };
  7097. /**
  7098. * Returns true if obj is a buffer or an arraybuffer.
  7099. *
  7100. * @api private
  7101. */
  7102. function isBuf(obj) {
  7103. return (withNativeBuffer && Buffer.isBuffer(obj)) ||
  7104. (withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj)));
  7105. }
  7106. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(49).Buffer))
  7107. /***/ }),
  7108. /* 64 */
  7109. /***/ (function(module, exports, __webpack_require__) {
  7110. /**
  7111. * Module dependencies.
  7112. */
  7113. var eio = __webpack_require__(117);
  7114. var Socket = __webpack_require__(70);
  7115. var Emitter = __webpack_require__(17);
  7116. var parser = __webpack_require__(48);
  7117. var on = __webpack_require__(71);
  7118. var bind = __webpack_require__(72);
  7119. var debug = __webpack_require__(32)('socket.io-client:manager');
  7120. var indexOf = __webpack_require__(69);
  7121. var Backoff = __webpack_require__(133);
  7122. /**
  7123. * IE6+ hasOwnProperty
  7124. */
  7125. var has = Object.prototype.hasOwnProperty;
  7126. /**
  7127. * Module exports
  7128. */
  7129. module.exports = Manager;
  7130. /**
  7131. * `Manager` constructor.
  7132. *
  7133. * @param {String} engine instance or engine uri/opts
  7134. * @param {Object} options
  7135. * @api public
  7136. */
  7137. function Manager (uri, opts) {
  7138. if (!(this instanceof Manager)) return new Manager(uri, opts);
  7139. if (uri && ('object' === typeof uri)) {
  7140. opts = uri;
  7141. uri = undefined;
  7142. }
  7143. opts = opts || {};
  7144. opts.path = opts.path || '/socket.io';
  7145. this.nsps = {};
  7146. this.subs = [];
  7147. this.opts = opts;
  7148. this.reconnection(opts.reconnection !== false);
  7149. this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
  7150. this.reconnectionDelay(opts.reconnectionDelay || 1000);
  7151. this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
  7152. this.randomizationFactor(opts.randomizationFactor || 0.5);
  7153. this.backoff = new Backoff({
  7154. min: this.reconnectionDelay(),
  7155. max: this.reconnectionDelayMax(),
  7156. jitter: this.randomizationFactor()
  7157. });
  7158. this.timeout(null == opts.timeout ? 20000 : opts.timeout);
  7159. this.readyState = 'closed';
  7160. this.uri = uri;
  7161. this.connecting = [];
  7162. this.lastPing = null;
  7163. this.encoding = false;
  7164. this.packetBuffer = [];
  7165. var _parser = opts.parser || parser;
  7166. this.encoder = new _parser.Encoder();
  7167. this.decoder = new _parser.Decoder();
  7168. this.autoConnect = opts.autoConnect !== false;
  7169. if (this.autoConnect) this.open();
  7170. }
  7171. /**
  7172. * Propagate given event to sockets and emit on `this`
  7173. *
  7174. * @api private
  7175. */
  7176. Manager.prototype.emitAll = function () {
  7177. this.emit.apply(this, arguments);
  7178. for (var nsp in this.nsps) {
  7179. if (has.call(this.nsps, nsp)) {
  7180. this.nsps[nsp].emit.apply(this.nsps[nsp], arguments);
  7181. }
  7182. }
  7183. };
  7184. /**
  7185. * Update `socket.id` of all sockets
  7186. *
  7187. * @api private
  7188. */
  7189. Manager.prototype.updateSocketIds = function () {
  7190. for (var nsp in this.nsps) {
  7191. if (has.call(this.nsps, nsp)) {
  7192. this.nsps[nsp].id = this.generateId(nsp);
  7193. }
  7194. }
  7195. };
  7196. /**
  7197. * generate `socket.id` for the given `nsp`
  7198. *
  7199. * @param {String} nsp
  7200. * @return {String}
  7201. * @api private
  7202. */
  7203. Manager.prototype.generateId = function (nsp) {
  7204. return (nsp === '/' ? '' : (nsp + '#')) + this.engine.id;
  7205. };
  7206. /**
  7207. * Mix in `Emitter`.
  7208. */
  7209. Emitter(Manager.prototype);
  7210. /**
  7211. * Sets the `reconnection` config.
  7212. *
  7213. * @param {Boolean} true/false if it should automatically reconnect
  7214. * @return {Manager} self or value
  7215. * @api public
  7216. */
  7217. Manager.prototype.reconnection = function (v) {
  7218. if (!arguments.length) return this._reconnection;
  7219. this._reconnection = !!v;
  7220. return this;
  7221. };
  7222. /**
  7223. * Sets the reconnection attempts config.
  7224. *
  7225. * @param {Number} max reconnection attempts before giving up
  7226. * @return {Manager} self or value
  7227. * @api public
  7228. */
  7229. Manager.prototype.reconnectionAttempts = function (v) {
  7230. if (!arguments.length) return this._reconnectionAttempts;
  7231. this._reconnectionAttempts = v;
  7232. return this;
  7233. };
  7234. /**
  7235. * Sets the delay between reconnections.
  7236. *
  7237. * @param {Number} delay
  7238. * @return {Manager} self or value
  7239. * @api public
  7240. */
  7241. Manager.prototype.reconnectionDelay = function (v) {
  7242. if (!arguments.length) return this._reconnectionDelay;
  7243. this._reconnectionDelay = v;
  7244. this.backoff && this.backoff.setMin(v);
  7245. return this;
  7246. };
  7247. Manager.prototype.randomizationFactor = function (v) {
  7248. if (!arguments.length) return this._randomizationFactor;
  7249. this._randomizationFactor = v;
  7250. this.backoff && this.backoff.setJitter(v);
  7251. return this;
  7252. };
  7253. /**
  7254. * Sets the maximum delay between reconnections.
  7255. *
  7256. * @param {Number} delay
  7257. * @return {Manager} self or value
  7258. * @api public
  7259. */
  7260. Manager.prototype.reconnectionDelayMax = function (v) {
  7261. if (!arguments.length) return this._reconnectionDelayMax;
  7262. this._reconnectionDelayMax = v;
  7263. this.backoff && this.backoff.setMax(v);
  7264. return this;
  7265. };
  7266. /**
  7267. * Sets the connection timeout. `false` to disable
  7268. *
  7269. * @return {Manager} self or value
  7270. * @api public
  7271. */
  7272. Manager.prototype.timeout = function (v) {
  7273. if (!arguments.length) return this._timeout;
  7274. this._timeout = v;
  7275. return this;
  7276. };
  7277. /**
  7278. * Starts trying to reconnect if reconnection is enabled and we have not
  7279. * started reconnecting yet
  7280. *
  7281. * @api private
  7282. */
  7283. Manager.prototype.maybeReconnectOnOpen = function () {
  7284. // Only try to reconnect if it's the first time we're connecting
  7285. if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) {
  7286. // keeps reconnection from firing twice for the same reconnection loop
  7287. this.reconnect();
  7288. }
  7289. };
  7290. /**
  7291. * Sets the current transport `socket`.
  7292. *
  7293. * @param {Function} optional, callback
  7294. * @return {Manager} self
  7295. * @api public
  7296. */
  7297. Manager.prototype.open =
  7298. Manager.prototype.connect = function (fn, opts) {
  7299. debug('readyState %s', this.readyState);
  7300. if (~this.readyState.indexOf('open')) return this;
  7301. debug('opening %s', this.uri);
  7302. this.engine = eio(this.uri, this.opts);
  7303. var socket = this.engine;
  7304. var self = this;
  7305. this.readyState = 'opening';
  7306. this.skipReconnect = false;
  7307. // emit `open`
  7308. var openSub = on(socket, 'open', function () {
  7309. self.onopen();
  7310. fn && fn();
  7311. });
  7312. // emit `connect_error`
  7313. var errorSub = on(socket, 'error', function (data) {
  7314. debug('connect_error');
  7315. self.cleanup();
  7316. self.readyState = 'closed';
  7317. self.emitAll('connect_error', data);
  7318. if (fn) {
  7319. var err = new Error('Connection error');
  7320. err.data = data;
  7321. fn(err);
  7322. } else {
  7323. // Only do this if there is no fn to handle the error
  7324. self.maybeReconnectOnOpen();
  7325. }
  7326. });
  7327. // emit `connect_timeout`
  7328. if (false !== this._timeout) {
  7329. var timeout = this._timeout;
  7330. debug('connect attempt will timeout after %d', timeout);
  7331. // set timer
  7332. var timer = setTimeout(function () {
  7333. debug('connect attempt timed out after %d', timeout);
  7334. openSub.destroy();
  7335. socket.close();
  7336. socket.emit('error', 'timeout');
  7337. self.emitAll('connect_timeout', timeout);
  7338. }, timeout);
  7339. this.subs.push({
  7340. destroy: function () {
  7341. clearTimeout(timer);
  7342. }
  7343. });
  7344. }
  7345. this.subs.push(openSub);
  7346. this.subs.push(errorSub);
  7347. return this;
  7348. };
  7349. /**
  7350. * Called upon transport open.
  7351. *
  7352. * @api private
  7353. */
  7354. Manager.prototype.onopen = function () {
  7355. debug('open');
  7356. // clear old subs
  7357. this.cleanup();
  7358. // mark as open
  7359. this.readyState = 'open';
  7360. this.emit('open');
  7361. // add new subs
  7362. var socket = this.engine;
  7363. this.subs.push(on(socket, 'data', bind(this, 'ondata')));
  7364. this.subs.push(on(socket, 'ping', bind(this, 'onping')));
  7365. this.subs.push(on(socket, 'pong', bind(this, 'onpong')));
  7366. this.subs.push(on(socket, 'error', bind(this, 'onerror')));
  7367. this.subs.push(on(socket, 'close', bind(this, 'onclose')));
  7368. this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded')));
  7369. };
  7370. /**
  7371. * Called upon a ping.
  7372. *
  7373. * @api private
  7374. */
  7375. Manager.prototype.onping = function () {
  7376. this.lastPing = new Date();
  7377. this.emitAll('ping');
  7378. };
  7379. /**
  7380. * Called upon a packet.
  7381. *
  7382. * @api private
  7383. */
  7384. Manager.prototype.onpong = function () {
  7385. this.emitAll('pong', new Date() - this.lastPing);
  7386. };
  7387. /**
  7388. * Called with data.
  7389. *
  7390. * @api private
  7391. */
  7392. Manager.prototype.ondata = function (data) {
  7393. this.decoder.add(data);
  7394. };
  7395. /**
  7396. * Called when parser fully decodes a packet.
  7397. *
  7398. * @api private
  7399. */
  7400. Manager.prototype.ondecoded = function (packet) {
  7401. this.emit('packet', packet);
  7402. };
  7403. /**
  7404. * Called upon socket error.
  7405. *
  7406. * @api private
  7407. */
  7408. Manager.prototype.onerror = function (err) {
  7409. debug('error', err);
  7410. this.emitAll('error', err);
  7411. };
  7412. /**
  7413. * Creates a new socket for the given `nsp`.
  7414. *
  7415. * @return {Socket}
  7416. * @api public
  7417. */
  7418. Manager.prototype.socket = function (nsp, opts) {
  7419. var socket = this.nsps[nsp];
  7420. if (!socket) {
  7421. socket = new Socket(this, nsp, opts);
  7422. this.nsps[nsp] = socket;
  7423. var self = this;
  7424. socket.on('connecting', onConnecting);
  7425. socket.on('connect', function () {
  7426. socket.id = self.generateId(nsp);
  7427. });
  7428. if (this.autoConnect) {
  7429. // manually call here since connecting event is fired before listening
  7430. onConnecting();
  7431. }
  7432. }
  7433. function onConnecting () {
  7434. if (!~indexOf(self.connecting, socket)) {
  7435. self.connecting.push(socket);
  7436. }
  7437. }
  7438. return socket;
  7439. };
  7440. /**
  7441. * Called upon a socket close.
  7442. *
  7443. * @param {Socket} socket
  7444. */
  7445. Manager.prototype.destroy = function (socket) {
  7446. var index = indexOf(this.connecting, socket);
  7447. if (~index) this.connecting.splice(index, 1);
  7448. if (this.connecting.length) return;
  7449. this.close();
  7450. };
  7451. /**
  7452. * Writes a packet.
  7453. *
  7454. * @param {Object} packet
  7455. * @api private
  7456. */
  7457. Manager.prototype.packet = function (packet) {
  7458. debug('writing packet %j', packet);
  7459. var self = this;
  7460. if (packet.query && packet.type === 0) packet.nsp += '?' + packet.query;
  7461. if (!self.encoding) {
  7462. // encode, then write to engine with result
  7463. self.encoding = true;
  7464. this.encoder.encode(packet, function (encodedPackets) {
  7465. for (var i = 0; i < encodedPackets.length; i++) {
  7466. self.engine.write(encodedPackets[i], packet.options);
  7467. }
  7468. self.encoding = false;
  7469. self.processPacketQueue();
  7470. });
  7471. } else { // add packet to the queue
  7472. self.packetBuffer.push(packet);
  7473. }
  7474. };
  7475. /**
  7476. * If packet buffer is non-empty, begins encoding the
  7477. * next packet in line.
  7478. *
  7479. * @api private
  7480. */
  7481. Manager.prototype.processPacketQueue = function () {
  7482. if (this.packetBuffer.length > 0 && !this.encoding) {
  7483. var pack = this.packetBuffer.shift();
  7484. this.packet(pack);
  7485. }
  7486. };
  7487. /**
  7488. * Clean up transport subscriptions and packet buffer.
  7489. *
  7490. * @api private
  7491. */
  7492. Manager.prototype.cleanup = function () {
  7493. debug('cleanup');
  7494. var subsLength = this.subs.length;
  7495. for (var i = 0; i < subsLength; i++) {
  7496. var sub = this.subs.shift();
  7497. sub.destroy();
  7498. }
  7499. this.packetBuffer = [];
  7500. this.encoding = false;
  7501. this.lastPing = null;
  7502. this.decoder.destroy();
  7503. };
  7504. /**
  7505. * Close the current socket.
  7506. *
  7507. * @api private
  7508. */
  7509. Manager.prototype.close =
  7510. Manager.prototype.disconnect = function () {
  7511. debug('disconnect');
  7512. this.skipReconnect = true;
  7513. this.reconnecting = false;
  7514. if ('opening' === this.readyState) {
  7515. // `onclose` will not fire because
  7516. // an open event never happened
  7517. this.cleanup();
  7518. }
  7519. this.backoff.reset();
  7520. this.readyState = 'closed';
  7521. if (this.engine) this.engine.close();
  7522. };
  7523. /**
  7524. * Called upon engine close.
  7525. *
  7526. * @api private
  7527. */
  7528. Manager.prototype.onclose = function (reason) {
  7529. debug('onclose');
  7530. this.cleanup();
  7531. this.backoff.reset();
  7532. this.readyState = 'closed';
  7533. this.emit('close', reason);
  7534. if (this._reconnection && !this.skipReconnect) {
  7535. this.reconnect();
  7536. }
  7537. };
  7538. /**
  7539. * Attempt a reconnection.
  7540. *
  7541. * @api private
  7542. */
  7543. Manager.prototype.reconnect = function () {
  7544. if (this.reconnecting || this.skipReconnect) return this;
  7545. var self = this;
  7546. if (this.backoff.attempts >= this._reconnectionAttempts) {
  7547. debug('reconnect failed');
  7548. this.backoff.reset();
  7549. this.emitAll('reconnect_failed');
  7550. this.reconnecting = false;
  7551. } else {
  7552. var delay = this.backoff.duration();
  7553. debug('will wait %dms before reconnect attempt', delay);
  7554. this.reconnecting = true;
  7555. var timer = setTimeout(function () {
  7556. if (self.skipReconnect) return;
  7557. debug('attempting reconnect');
  7558. self.emitAll('reconnect_attempt', self.backoff.attempts);
  7559. self.emitAll('reconnecting', self.backoff.attempts);
  7560. // check again for the case socket closed in above events
  7561. if (self.skipReconnect) return;
  7562. self.open(function (err) {
  7563. if (err) {
  7564. debug('reconnect attempt error');
  7565. self.reconnecting = false;
  7566. self.reconnect();
  7567. self.emitAll('reconnect_error', err.data);
  7568. } else {
  7569. debug('reconnect success');
  7570. self.onreconnect();
  7571. }
  7572. });
  7573. }, delay);
  7574. this.subs.push({
  7575. destroy: function () {
  7576. clearTimeout(timer);
  7577. }
  7578. });
  7579. }
  7580. };
  7581. /**
  7582. * Called upon successful reconnect.
  7583. *
  7584. * @api private
  7585. */
  7586. Manager.prototype.onreconnect = function () {
  7587. var attempt = this.backoff.attempts;
  7588. this.reconnecting = false;
  7589. this.backoff.reset();
  7590. this.updateSocketIds();
  7591. this.emitAll('reconnect', attempt);
  7592. };
  7593. /***/ }),
  7594. /* 65 */
  7595. /***/ (function(module, exports, __webpack_require__) {
  7596. /**
  7597. * Module dependencies
  7598. */
  7599. var XMLHttpRequest = __webpack_require__(50);
  7600. var XHR = __webpack_require__(120);
  7601. var JSONP = __webpack_require__(129);
  7602. var websocket = __webpack_require__(130);
  7603. /**
  7604. * Export transports.
  7605. */
  7606. exports.polling = polling;
  7607. exports.websocket = websocket;
  7608. /**
  7609. * Polling transport polymorphic constructor.
  7610. * Decides on xhr vs jsonp based on feature detection.
  7611. *
  7612. * @api private
  7613. */
  7614. function polling (opts) {
  7615. var xhr;
  7616. var xd = false;
  7617. var xs = false;
  7618. var jsonp = false !== opts.jsonp;
  7619. if (typeof location !== 'undefined') {
  7620. var isSSL = 'https:' === location.protocol;
  7621. var port = location.port;
  7622. // some user agents have empty `location.port`
  7623. if (!port) {
  7624. port = isSSL ? 443 : 80;
  7625. }
  7626. xd = opts.hostname !== location.hostname || port !== opts.port;
  7627. xs = opts.secure !== isSSL;
  7628. }
  7629. opts.xdomain = xd;
  7630. opts.xscheme = xs;
  7631. xhr = new XMLHttpRequest(opts);
  7632. if ('open' in xhr && !opts.forceJSONP) {
  7633. return new XHR(opts);
  7634. } else {
  7635. if (!jsonp) throw new Error('JSONP disabled');
  7636. return new JSONP(opts);
  7637. }
  7638. }
  7639. /***/ }),
  7640. /* 66 */
  7641. /***/ (function(module, exports, __webpack_require__) {
  7642. /**
  7643. * Module dependencies.
  7644. */
  7645. var Transport = __webpack_require__(51);
  7646. var parseqs = __webpack_require__(34);
  7647. var parser = __webpack_require__(18);
  7648. var inherit = __webpack_require__(35);
  7649. var yeast = __webpack_require__(68);
  7650. var debug = __webpack_require__(36)('engine.io-client:polling');
  7651. /**
  7652. * Module exports.
  7653. */
  7654. module.exports = Polling;
  7655. /**
  7656. * Is XHR2 supported?
  7657. */
  7658. var hasXHR2 = (function () {
  7659. var XMLHttpRequest = __webpack_require__(50);
  7660. var xhr = new XMLHttpRequest({ xdomain: false });
  7661. return null != xhr.responseType;
  7662. })();
  7663. /**
  7664. * Polling interface.
  7665. *
  7666. * @param {Object} opts
  7667. * @api private
  7668. */
  7669. function Polling (opts) {
  7670. var forceBase64 = (opts && opts.forceBase64);
  7671. if (!hasXHR2 || forceBase64) {
  7672. this.supportsBinary = false;
  7673. }
  7674. Transport.call(this, opts);
  7675. }
  7676. /**
  7677. * Inherits from Transport.
  7678. */
  7679. inherit(Polling, Transport);
  7680. /**
  7681. * Transport name.
  7682. */
  7683. Polling.prototype.name = 'polling';
  7684. /**
  7685. * Opens the socket (triggers polling). We write a PING message to determine
  7686. * when the transport is open.
  7687. *
  7688. * @api private
  7689. */
  7690. Polling.prototype.doOpen = function () {
  7691. this.poll();
  7692. };
  7693. /**
  7694. * Pauses polling.
  7695. *
  7696. * @param {Function} callback upon buffers are flushed and transport is paused
  7697. * @api private
  7698. */
  7699. Polling.prototype.pause = function (onPause) {
  7700. var self = this;
  7701. this.readyState = 'pausing';
  7702. function pause () {
  7703. debug('paused');
  7704. self.readyState = 'paused';
  7705. onPause();
  7706. }
  7707. if (this.polling || !this.writable) {
  7708. var total = 0;
  7709. if (this.polling) {
  7710. debug('we are currently polling - waiting to pause');
  7711. total++;
  7712. this.once('pollComplete', function () {
  7713. debug('pre-pause polling complete');
  7714. --total || pause();
  7715. });
  7716. }
  7717. if (!this.writable) {
  7718. debug('we are currently writing - waiting to pause');
  7719. total++;
  7720. this.once('drain', function () {
  7721. debug('pre-pause writing complete');
  7722. --total || pause();
  7723. });
  7724. }
  7725. } else {
  7726. pause();
  7727. }
  7728. };
  7729. /**
  7730. * Starts polling cycle.
  7731. *
  7732. * @api public
  7733. */
  7734. Polling.prototype.poll = function () {
  7735. debug('polling');
  7736. this.polling = true;
  7737. this.doPoll();
  7738. this.emit('poll');
  7739. };
  7740. /**
  7741. * Overloads onData to detect payloads.
  7742. *
  7743. * @api private
  7744. */
  7745. Polling.prototype.onData = function (data) {
  7746. var self = this;
  7747. debug('polling got data %s', data);
  7748. var callback = function (packet, index, total) {
  7749. // if its the first message we consider the transport open
  7750. if ('opening' === self.readyState) {
  7751. self.onOpen();
  7752. }
  7753. // if its a close packet, we close the ongoing requests
  7754. if ('close' === packet.type) {
  7755. self.onClose();
  7756. return false;
  7757. }
  7758. // otherwise bypass onData and handle the message
  7759. self.onPacket(packet);
  7760. };
  7761. // decode payload
  7762. parser.decodePayload(data, this.socket.binaryType, callback);
  7763. // if an event did not trigger closing
  7764. if ('closed' !== this.readyState) {
  7765. // if we got data we're not polling
  7766. this.polling = false;
  7767. this.emit('pollComplete');
  7768. if ('open' === this.readyState) {
  7769. this.poll();
  7770. } else {
  7771. debug('ignoring poll - transport state "%s"', this.readyState);
  7772. }
  7773. }
  7774. };
  7775. /**
  7776. * For polling, send a close packet.
  7777. *
  7778. * @api private
  7779. */
  7780. Polling.prototype.doClose = function () {
  7781. var self = this;
  7782. function close () {
  7783. debug('writing close packet');
  7784. self.write([{ type: 'close' }]);
  7785. }
  7786. if ('open' === this.readyState) {
  7787. debug('transport open - closing');
  7788. close();
  7789. } else {
  7790. // in case we're trying to close while
  7791. // handshaking is in progress (GH-164)
  7792. debug('transport not open - deferring close');
  7793. this.once('open', close);
  7794. }
  7795. };
  7796. /**
  7797. * Writes a packets payload.
  7798. *
  7799. * @param {Array} data packets
  7800. * @param {Function} drain callback
  7801. * @api private
  7802. */
  7803. Polling.prototype.write = function (packets) {
  7804. var self = this;
  7805. this.writable = false;
  7806. var callbackfn = function () {
  7807. self.writable = true;
  7808. self.emit('drain');
  7809. };
  7810. parser.encodePayload(packets, this.supportsBinary, function (data) {
  7811. self.doWrite(data, callbackfn);
  7812. });
  7813. };
  7814. /**
  7815. * Generates uri for connection.
  7816. *
  7817. * @api private
  7818. */
  7819. Polling.prototype.uri = function () {
  7820. var query = this.query || {};
  7821. var schema = this.secure ? 'https' : 'http';
  7822. var port = '';
  7823. // cache busting is forced
  7824. if (false !== this.timestampRequests) {
  7825. query[this.timestampParam] = yeast();
  7826. }
  7827. if (!this.supportsBinary && !query.sid) {
  7828. query.b64 = 1;
  7829. }
  7830. query = parseqs.encode(query);
  7831. // avoid port if default for schema
  7832. if (this.port && (('https' === schema && Number(this.port) !== 443) ||
  7833. ('http' === schema && Number(this.port) !== 80))) {
  7834. port = ':' + this.port;
  7835. }
  7836. // prepend ? to query
  7837. if (query.length) {
  7838. query = '?' + query;
  7839. }
  7840. var ipv6 = this.hostname.indexOf(':') !== -1;
  7841. return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
  7842. };
  7843. /***/ }),
  7844. /* 67 */
  7845. /***/ (function(module, exports, __webpack_require__) {
  7846. /* WEBPACK VAR INJECTION */(function(Buffer) {/* global Blob File */
  7847. /*
  7848. * Module requirements.
  7849. */
  7850. var isArray = __webpack_require__(122);
  7851. var toString = Object.prototype.toString;
  7852. var withNativeBlob = typeof Blob === 'function' ||
  7853. typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]';
  7854. var withNativeFile = typeof File === 'function' ||
  7855. typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]';
  7856. /**
  7857. * Module exports.
  7858. */
  7859. module.exports = hasBinary;
  7860. /**
  7861. * Checks for binary data.
  7862. *
  7863. * Supports Buffer, ArrayBuffer, Blob and File.
  7864. *
  7865. * @param {Object} anything
  7866. * @api public
  7867. */
  7868. function hasBinary (obj) {
  7869. if (!obj || typeof obj !== 'object') {
  7870. return false;
  7871. }
  7872. if (isArray(obj)) {
  7873. for (var i = 0, l = obj.length; i < l; i++) {
  7874. if (hasBinary(obj[i])) {
  7875. return true;
  7876. }
  7877. }
  7878. return false;
  7879. }
  7880. if ((typeof Buffer === 'function' && Buffer.isBuffer && Buffer.isBuffer(obj)) ||
  7881. (typeof ArrayBuffer === 'function' && obj instanceof ArrayBuffer) ||
  7882. (withNativeBlob && obj instanceof Blob) ||
  7883. (withNativeFile && obj instanceof File)
  7884. ) {
  7885. return true;
  7886. }
  7887. // see: https://github.com/Automattic/has-binary/pull/4
  7888. if (obj.toJSON && typeof obj.toJSON === 'function' && arguments.length === 1) {
  7889. return hasBinary(obj.toJSON(), true);
  7890. }
  7891. for (var key in obj) {
  7892. if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
  7893. return true;
  7894. }
  7895. }
  7896. return false;
  7897. }
  7898. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(49).Buffer))
  7899. /***/ }),
  7900. /* 68 */
  7901. /***/ (function(module, exports, __webpack_require__) {
  7902. "use strict";
  7903. var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
  7904. , length = 64
  7905. , map = {}
  7906. , seed = 0
  7907. , i = 0
  7908. , prev;
  7909. /**
  7910. * Return a string representing the specified number.
  7911. *
  7912. * @param {Number} num The number to convert.
  7913. * @returns {String} The string representation of the number.
  7914. * @api public
  7915. */
  7916. function encode(num) {
  7917. var encoded = '';
  7918. do {
  7919. encoded = alphabet[num % length] + encoded;
  7920. num = Math.floor(num / length);
  7921. } while (num > 0);
  7922. return encoded;
  7923. }
  7924. /**
  7925. * Return the integer value specified by the given string.
  7926. *
  7927. * @param {String} str The string to convert.
  7928. * @returns {Number} The integer value represented by the string.
  7929. * @api public
  7930. */
  7931. function decode(str) {
  7932. var decoded = 0;
  7933. for (i = 0; i < str.length; i++) {
  7934. decoded = decoded * length + map[str.charAt(i)];
  7935. }
  7936. return decoded;
  7937. }
  7938. /**
  7939. * Yeast: A tiny growing id generator.
  7940. *
  7941. * @returns {String} A unique id.
  7942. * @api public
  7943. */
  7944. function yeast() {
  7945. var now = encode(+new Date());
  7946. if (now !== prev) return seed = 0, prev = now;
  7947. return now +'.'+ encode(seed++);
  7948. }
  7949. //
  7950. // Map each character to its index.
  7951. //
  7952. for (; i < length; i++) map[alphabet[i]] = i;
  7953. //
  7954. // Expose the `yeast`, `encode` and `decode` functions.
  7955. //
  7956. yeast.encode = encode;
  7957. yeast.decode = decode;
  7958. module.exports = yeast;
  7959. /***/ }),
  7960. /* 69 */
  7961. /***/ (function(module, exports) {
  7962. var indexOf = [].indexOf;
  7963. module.exports = function(arr, obj){
  7964. if (indexOf) return arr.indexOf(obj);
  7965. for (var i = 0; i < arr.length; ++i) {
  7966. if (arr[i] === obj) return i;
  7967. }
  7968. return -1;
  7969. };
  7970. /***/ }),
  7971. /* 70 */
  7972. /***/ (function(module, exports, __webpack_require__) {
  7973. /**
  7974. * Module dependencies.
  7975. */
  7976. var parser = __webpack_require__(48);
  7977. var Emitter = __webpack_require__(17);
  7978. var toArray = __webpack_require__(132);
  7979. var on = __webpack_require__(71);
  7980. var bind = __webpack_require__(72);
  7981. var debug = __webpack_require__(32)('socket.io-client:socket');
  7982. var parseqs = __webpack_require__(34);
  7983. var hasBin = __webpack_require__(67);
  7984. /**
  7985. * Module exports.
  7986. */
  7987. module.exports = exports = Socket;
  7988. /**
  7989. * Internal events (blacklisted).
  7990. * These events can't be emitted by the user.
  7991. *
  7992. * @api private
  7993. */
  7994. var events = {
  7995. connect: 1,
  7996. connect_error: 1,
  7997. connect_timeout: 1,
  7998. connecting: 1,
  7999. disconnect: 1,
  8000. error: 1,
  8001. reconnect: 1,
  8002. reconnect_attempt: 1,
  8003. reconnect_failed: 1,
  8004. reconnect_error: 1,
  8005. reconnecting: 1,
  8006. ping: 1,
  8007. pong: 1
  8008. };
  8009. /**
  8010. * Shortcut to `Emitter#emit`.
  8011. */
  8012. var emit = Emitter.prototype.emit;
  8013. /**
  8014. * `Socket` constructor.
  8015. *
  8016. * @api public
  8017. */
  8018. function Socket (io, nsp, opts) {
  8019. this.io = io;
  8020. this.nsp = nsp;
  8021. this.json = this; // compat
  8022. this.ids = 0;
  8023. this.acks = {};
  8024. this.receiveBuffer = [];
  8025. this.sendBuffer = [];
  8026. this.connected = false;
  8027. this.disconnected = true;
  8028. this.flags = {};
  8029. if (opts && opts.query) {
  8030. this.query = opts.query;
  8031. }
  8032. if (this.io.autoConnect) this.open();
  8033. }
  8034. /**
  8035. * Mix in `Emitter`.
  8036. */
  8037. Emitter(Socket.prototype);
  8038. /**
  8039. * Subscribe to open, close and packet events
  8040. *
  8041. * @api private
  8042. */
  8043. Socket.prototype.subEvents = function () {
  8044. if (this.subs) return;
  8045. var io = this.io;
  8046. this.subs = [
  8047. on(io, 'open', bind(this, 'onopen')),
  8048. on(io, 'packet', bind(this, 'onpacket')),
  8049. on(io, 'close', bind(this, 'onclose'))
  8050. ];
  8051. };
  8052. /**
  8053. * "Opens" the socket.
  8054. *
  8055. * @api public
  8056. */
  8057. Socket.prototype.open =
  8058. Socket.prototype.connect = function () {
  8059. if (this.connected) return this;
  8060. this.subEvents();
  8061. this.io.open(); // ensure open
  8062. if ('open' === this.io.readyState) this.onopen();
  8063. this.emit('connecting');
  8064. return this;
  8065. };
  8066. /**
  8067. * Sends a `message` event.
  8068. *
  8069. * @return {Socket} self
  8070. * @api public
  8071. */
  8072. Socket.prototype.send = function () {
  8073. var args = toArray(arguments);
  8074. args.unshift('message');
  8075. this.emit.apply(this, args);
  8076. return this;
  8077. };
  8078. /**
  8079. * Override `emit`.
  8080. * If the event is in `events`, it's emitted normally.
  8081. *
  8082. * @param {String} event name
  8083. * @return {Socket} self
  8084. * @api public
  8085. */
  8086. Socket.prototype.emit = function (ev) {
  8087. if (events.hasOwnProperty(ev)) {
  8088. emit.apply(this, arguments);
  8089. return this;
  8090. }
  8091. var args = toArray(arguments);
  8092. var packet = {
  8093. type: (this.flags.binary !== undefined ? this.flags.binary : hasBin(args)) ? parser.BINARY_EVENT : parser.EVENT,
  8094. data: args
  8095. };
  8096. packet.options = {};
  8097. packet.options.compress = !this.flags || false !== this.flags.compress;
  8098. // event ack callback
  8099. if ('function' === typeof args[args.length - 1]) {
  8100. debug('emitting packet with ack id %d', this.ids);
  8101. this.acks[this.ids] = args.pop();
  8102. packet.id = this.ids++;
  8103. }
  8104. if (this.connected) {
  8105. this.packet(packet);
  8106. } else {
  8107. this.sendBuffer.push(packet);
  8108. }
  8109. this.flags = {};
  8110. return this;
  8111. };
  8112. /**
  8113. * Sends a packet.
  8114. *
  8115. * @param {Object} packet
  8116. * @api private
  8117. */
  8118. Socket.prototype.packet = function (packet) {
  8119. packet.nsp = this.nsp;
  8120. this.io.packet(packet);
  8121. };
  8122. /**
  8123. * Called upon engine `open`.
  8124. *
  8125. * @api private
  8126. */
  8127. Socket.prototype.onopen = function () {
  8128. debug('transport is open - connecting');
  8129. // write connect packet if necessary
  8130. if ('/' !== this.nsp) {
  8131. if (this.query) {
  8132. var query = typeof this.query === 'object' ? parseqs.encode(this.query) : this.query;
  8133. debug('sending connect packet with query %s', query);
  8134. this.packet({type: parser.CONNECT, query: query});
  8135. } else {
  8136. this.packet({type: parser.CONNECT});
  8137. }
  8138. }
  8139. };
  8140. /**
  8141. * Called upon engine `close`.
  8142. *
  8143. * @param {String} reason
  8144. * @api private
  8145. */
  8146. Socket.prototype.onclose = function (reason) {
  8147. debug('close (%s)', reason);
  8148. this.connected = false;
  8149. this.disconnected = true;
  8150. delete this.id;
  8151. this.emit('disconnect', reason);
  8152. };
  8153. /**
  8154. * Called with socket packet.
  8155. *
  8156. * @param {Object} packet
  8157. * @api private
  8158. */
  8159. Socket.prototype.onpacket = function (packet) {
  8160. var sameNamespace = packet.nsp === this.nsp;
  8161. var rootNamespaceError = packet.type === parser.ERROR && packet.nsp === '/';
  8162. if (!sameNamespace && !rootNamespaceError) return;
  8163. switch (packet.type) {
  8164. case parser.CONNECT:
  8165. this.onconnect();
  8166. break;
  8167. case parser.EVENT:
  8168. this.onevent(packet);
  8169. break;
  8170. case parser.BINARY_EVENT:
  8171. this.onevent(packet);
  8172. break;
  8173. case parser.ACK:
  8174. this.onack(packet);
  8175. break;
  8176. case parser.BINARY_ACK:
  8177. this.onack(packet);
  8178. break;
  8179. case parser.DISCONNECT:
  8180. this.ondisconnect();
  8181. break;
  8182. case parser.ERROR:
  8183. this.emit('error', packet.data);
  8184. break;
  8185. }
  8186. };
  8187. /**
  8188. * Called upon a server event.
  8189. *
  8190. * @param {Object} packet
  8191. * @api private
  8192. */
  8193. Socket.prototype.onevent = function (packet) {
  8194. var args = packet.data || [];
  8195. debug('emitting event %j', args);
  8196. if (null != packet.id) {
  8197. debug('attaching ack callback to event');
  8198. args.push(this.ack(packet.id));
  8199. }
  8200. if (this.connected) {
  8201. emit.apply(this, args);
  8202. } else {
  8203. this.receiveBuffer.push(args);
  8204. }
  8205. };
  8206. /**
  8207. * Produces an ack callback to emit with an event.
  8208. *
  8209. * @api private
  8210. */
  8211. Socket.prototype.ack = function (id) {
  8212. var self = this;
  8213. var sent = false;
  8214. return function () {
  8215. // prevent double callbacks
  8216. if (sent) return;
  8217. sent = true;
  8218. var args = toArray(arguments);
  8219. debug('sending ack %j', args);
  8220. self.packet({
  8221. type: hasBin(args) ? parser.BINARY_ACK : parser.ACK,
  8222. id: id,
  8223. data: args
  8224. });
  8225. };
  8226. };
  8227. /**
  8228. * Called upon a server acknowlegement.
  8229. *
  8230. * @param {Object} packet
  8231. * @api private
  8232. */
  8233. Socket.prototype.onack = function (packet) {
  8234. var ack = this.acks[packet.id];
  8235. if ('function' === typeof ack) {
  8236. debug('calling ack %s with %j', packet.id, packet.data);
  8237. ack.apply(this, packet.data);
  8238. delete this.acks[packet.id];
  8239. } else {
  8240. debug('bad ack %s', packet.id);
  8241. }
  8242. };
  8243. /**
  8244. * Called upon server connect.
  8245. *
  8246. * @api private
  8247. */
  8248. Socket.prototype.onconnect = function () {
  8249. this.connected = true;
  8250. this.disconnected = false;
  8251. this.emit('connect');
  8252. this.emitBuffered();
  8253. };
  8254. /**
  8255. * Emit buffered events (received and emitted).
  8256. *
  8257. * @api private
  8258. */
  8259. Socket.prototype.emitBuffered = function () {
  8260. var i;
  8261. for (i = 0; i < this.receiveBuffer.length; i++) {
  8262. emit.apply(this, this.receiveBuffer[i]);
  8263. }
  8264. this.receiveBuffer = [];
  8265. for (i = 0; i < this.sendBuffer.length; i++) {
  8266. this.packet(this.sendBuffer[i]);
  8267. }
  8268. this.sendBuffer = [];
  8269. };
  8270. /**
  8271. * Called upon server disconnect.
  8272. *
  8273. * @api private
  8274. */
  8275. Socket.prototype.ondisconnect = function () {
  8276. debug('server disconnect (%s)', this.nsp);
  8277. this.destroy();
  8278. this.onclose('io server disconnect');
  8279. };
  8280. /**
  8281. * Called upon forced client/server side disconnections,
  8282. * this method ensures the manager stops tracking us and
  8283. * that reconnections don't get triggered for this.
  8284. *
  8285. * @api private.
  8286. */
  8287. Socket.prototype.destroy = function () {
  8288. if (this.subs) {
  8289. // clean subscriptions to avoid reconnections
  8290. for (var i = 0; i < this.subs.length; i++) {
  8291. this.subs[i].destroy();
  8292. }
  8293. this.subs = null;
  8294. }
  8295. this.io.destroy(this);
  8296. };
  8297. /**
  8298. * Disconnects the socket manually.
  8299. *
  8300. * @return {Socket} self
  8301. * @api public
  8302. */
  8303. Socket.prototype.close =
  8304. Socket.prototype.disconnect = function () {
  8305. if (this.connected) {
  8306. debug('performing disconnect (%s)', this.nsp);
  8307. this.packet({ type: parser.DISCONNECT });
  8308. }
  8309. // remove socket from pool
  8310. this.destroy();
  8311. if (this.connected) {
  8312. // fire events
  8313. this.onclose('io client disconnect');
  8314. }
  8315. return this;
  8316. };
  8317. /**
  8318. * Sets the compress flag.
  8319. *
  8320. * @param {Boolean} if `true`, compresses the sending data
  8321. * @return {Socket} self
  8322. * @api public
  8323. */
  8324. Socket.prototype.compress = function (compress) {
  8325. this.flags.compress = compress;
  8326. return this;
  8327. };
  8328. /**
  8329. * Sets the binary flag
  8330. *
  8331. * @param {Boolean} whether the emitted data contains binary
  8332. * @return {Socket} self
  8333. * @api public
  8334. */
  8335. Socket.prototype.binary = function (binary) {
  8336. this.flags.binary = binary;
  8337. return this;
  8338. };
  8339. /***/ }),
  8340. /* 71 */
  8341. /***/ (function(module, exports) {
  8342. /**
  8343. * Module exports.
  8344. */
  8345. module.exports = on;
  8346. /**
  8347. * Helper for subscriptions.
  8348. *
  8349. * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter`
  8350. * @param {String} event name
  8351. * @param {Function} callback
  8352. * @api public
  8353. */
  8354. function on (obj, ev, fn) {
  8355. obj.on(ev, fn);
  8356. return {
  8357. destroy: function () {
  8358. obj.removeListener(ev, fn);
  8359. }
  8360. };
  8361. }
  8362. /***/ }),
  8363. /* 72 */
  8364. /***/ (function(module, exports) {
  8365. /**
  8366. * Slice reference.
  8367. */
  8368. var slice = [].slice;
  8369. /**
  8370. * Bind `obj` to `fn`.
  8371. *
  8372. * @param {Object} obj
  8373. * @param {Function|String} fn or string
  8374. * @return {Function}
  8375. * @api public
  8376. */
  8377. module.exports = function(obj, fn){
  8378. if ('string' == typeof fn) fn = obj[fn];
  8379. if ('function' != typeof fn) throw new Error('bind() requires a function');
  8380. var args = slice.call(arguments, 2);
  8381. return function(){
  8382. return fn.apply(obj, args.concat(slice.call(arguments)));
  8383. }
  8384. };
  8385. /***/ }),
  8386. /* 73 */
  8387. /***/ (function(module, exports, __webpack_require__) {
  8388. "use strict";
  8389. var __extends = (this && this.__extends) || function (d, b) {
  8390. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8391. function __() { this.constructor = d; }
  8392. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8393. };
  8394. /**
  8395. * An error thrown when an action is invalid because the object has been
  8396. * unsubscribed.
  8397. *
  8398. * @see {@link Subject}
  8399. * @see {@link BehaviorSubject}
  8400. *
  8401. * @class ObjectUnsubscribedError
  8402. */
  8403. var ObjectUnsubscribedError = (function (_super) {
  8404. __extends(ObjectUnsubscribedError, _super);
  8405. function ObjectUnsubscribedError() {
  8406. var err = _super.call(this, 'object unsubscribed');
  8407. this.name = err.name = 'ObjectUnsubscribedError';
  8408. this.stack = err.stack;
  8409. this.message = err.message;
  8410. }
  8411. return ObjectUnsubscribedError;
  8412. }(Error));
  8413. exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
  8414. //# sourceMappingURL=ObjectUnsubscribedError.js.map
  8415. /***/ }),
  8416. /* 74 */
  8417. /***/ (function(module, exports, __webpack_require__) {
  8418. "use strict";
  8419. var multicast_1 = __webpack_require__(135);
  8420. var refCount_1 = __webpack_require__(75);
  8421. var Subject_1 = __webpack_require__(37);
  8422. function shareSubjectFactory() {
  8423. return new Subject_1.Subject();
  8424. }
  8425. /**
  8426. * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
  8427. * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
  8428. * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
  8429. * This is an alias for .multicast(() => new Subject()).refCount().
  8430. *
  8431. * <img src="./img/share.png" width="100%">
  8432. *
  8433. * @return {Observable<T>} An Observable that upon connection causes the source Observable to emit items to its Observers.
  8434. * @method share
  8435. * @owner Observable
  8436. */
  8437. function share() {
  8438. return function (source) { return refCount_1.refCount()(multicast_1.multicast(shareSubjectFactory)(source)); };
  8439. }
  8440. exports.share = share;
  8441. ;
  8442. //# sourceMappingURL=share.js.map
  8443. /***/ }),
  8444. /* 75 */
  8445. /***/ (function(module, exports, __webpack_require__) {
  8446. "use strict";
  8447. var __extends = (this && this.__extends) || function (d, b) {
  8448. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8449. function __() { this.constructor = d; }
  8450. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8451. };
  8452. var Subscriber_1 = __webpack_require__(3);
  8453. function refCount() {
  8454. return function refCountOperatorFunction(source) {
  8455. return source.lift(new RefCountOperator(source));
  8456. };
  8457. }
  8458. exports.refCount = refCount;
  8459. var RefCountOperator = (function () {
  8460. function RefCountOperator(connectable) {
  8461. this.connectable = connectable;
  8462. }
  8463. RefCountOperator.prototype.call = function (subscriber, source) {
  8464. var connectable = this.connectable;
  8465. connectable._refCount++;
  8466. var refCounter = new RefCountSubscriber(subscriber, connectable);
  8467. var subscription = source.subscribe(refCounter);
  8468. if (!refCounter.closed) {
  8469. refCounter.connection = connectable.connect();
  8470. }
  8471. return subscription;
  8472. };
  8473. return RefCountOperator;
  8474. }());
  8475. var RefCountSubscriber = (function (_super) {
  8476. __extends(RefCountSubscriber, _super);
  8477. function RefCountSubscriber(destination, connectable) {
  8478. _super.call(this, destination);
  8479. this.connectable = connectable;
  8480. }
  8481. /** @deprecated internal use only */ RefCountSubscriber.prototype._unsubscribe = function () {
  8482. var connectable = this.connectable;
  8483. if (!connectable) {
  8484. this.connection = null;
  8485. return;
  8486. }
  8487. this.connectable = null;
  8488. var refCount = connectable._refCount;
  8489. if (refCount <= 0) {
  8490. this.connection = null;
  8491. return;
  8492. }
  8493. connectable._refCount = refCount - 1;
  8494. if (refCount > 1) {
  8495. this.connection = null;
  8496. return;
  8497. }
  8498. ///
  8499. // Compare the local RefCountSubscriber's connection Subscription to the
  8500. // connection Subscription on the shared ConnectableObservable. In cases
  8501. // where the ConnectableObservable source synchronously emits values, and
  8502. // the RefCountSubscriber's downstream Observers synchronously unsubscribe,
  8503. // execution continues to here before the RefCountOperator has a chance to
  8504. // supply the RefCountSubscriber with the shared connection Subscription.
  8505. // For example:
  8506. // ```
  8507. // Observable.range(0, 10)
  8508. // .publish()
  8509. // .refCount()
  8510. // .take(5)
  8511. // .subscribe();
  8512. // ```
  8513. // In order to account for this case, RefCountSubscriber should only dispose
  8514. // the ConnectableObservable's shared connection Subscription if the
  8515. // connection Subscription exists, *and* either:
  8516. // a. RefCountSubscriber doesn't have a reference to the shared connection
  8517. // Subscription yet, or,
  8518. // b. RefCountSubscriber's connection Subscription reference is identical
  8519. // to the shared connection Subscription
  8520. ///
  8521. var connection = this.connection;
  8522. var sharedConnection = connectable._connection;
  8523. this.connection = null;
  8524. if (sharedConnection && (!connection || sharedConnection === connection)) {
  8525. sharedConnection.unsubscribe();
  8526. }
  8527. };
  8528. return RefCountSubscriber;
  8529. }(Subscriber_1.Subscriber));
  8530. //# sourceMappingURL=refCount.js.map
  8531. /***/ }),
  8532. /* 76 */
  8533. /***/ (function(module, exports, __webpack_require__) {
  8534. "use strict";
  8535. Object.defineProperty(exports, "__esModule", { value: true });
  8536. var map_1 = __webpack_require__(2);
  8537. var tap_1 = __webpack_require__(5);
  8538. var dom_effects_1 = __webpack_require__(19);
  8539. var Log = __webpack_require__(14);
  8540. function propSetDomEffect(xs) {
  8541. return xs.pipe(tap_1.tap(function (event) {
  8542. var target = event.target, prop = event.prop, value = event.value;
  8543. target[prop] = value;
  8544. }), map_1.map(function (e) {
  8545. return Log.consoleInfo("[PropSet]", e.target, e.prop + " = " + e.pathname);
  8546. }));
  8547. }
  8548. exports.propSetDomEffect = propSetDomEffect;
  8549. function propSet(incoming) {
  8550. return [dom_effects_1.Events.PropSet, incoming];
  8551. }
  8552. exports.propSet = propSet;
  8553. /***/ }),
  8554. /* 77 */
  8555. /***/ (function(module, exports, __webpack_require__) {
  8556. "use strict";
  8557. var isArray_1 = __webpack_require__(26);
  8558. function isNumeric(val) {
  8559. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  8560. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  8561. // subtraction forces infinities to NaN
  8562. // adding 1 corrects loss of precision from parseFloat (#15100)
  8563. return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0;
  8564. }
  8565. exports.isNumeric = isNumeric;
  8566. ;
  8567. //# sourceMappingURL=isNumeric.js.map
  8568. /***/ }),
  8569. /* 78 */
  8570. /***/ (function(module, exports, __webpack_require__) {
  8571. "use strict";
  8572. var AsyncAction_1 = __webpack_require__(79);
  8573. var AsyncScheduler_1 = __webpack_require__(80);
  8574. /**
  8575. *
  8576. * Async Scheduler
  8577. *
  8578. * <span class="informal">Schedule task as if you used setTimeout(task, duration)</span>
  8579. *
  8580. * `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript
  8581. * event loop queue. It is best used to delay tasks in time or to schedule tasks repeating
  8582. * in intervals.
  8583. *
  8584. * If you just want to "defer" task, that is to perform it right after currently
  8585. * executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`),
  8586. * better choice will be the {@link asap} scheduler.
  8587. *
  8588. * @example <caption>Use async scheduler to delay task</caption>
  8589. * const task = () => console.log('it works!');
  8590. *
  8591. * Rx.Scheduler.async.schedule(task, 2000);
  8592. *
  8593. * // After 2 seconds logs:
  8594. * // "it works!"
  8595. *
  8596. *
  8597. * @example <caption>Use async scheduler to repeat task in intervals</caption>
  8598. * function task(state) {
  8599. * console.log(state);
  8600. * this.schedule(state + 1, 1000); // `this` references currently executing Action,
  8601. * // which we reschedule with new state and delay
  8602. * }
  8603. *
  8604. * Rx.Scheduler.async.schedule(task, 3000, 0);
  8605. *
  8606. * // Logs:
  8607. * // 0 after 3s
  8608. * // 1 after 4s
  8609. * // 2 after 5s
  8610. * // 3 after 6s
  8611. *
  8612. * @static true
  8613. * @name async
  8614. * @owner Scheduler
  8615. */
  8616. exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction);
  8617. //# sourceMappingURL=async.js.map
  8618. /***/ }),
  8619. /* 79 */
  8620. /***/ (function(module, exports, __webpack_require__) {
  8621. "use strict";
  8622. var __extends = (this && this.__extends) || function (d, b) {
  8623. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8624. function __() { this.constructor = d; }
  8625. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8626. };
  8627. var root_1 = __webpack_require__(7);
  8628. var Action_1 = __webpack_require__(139);
  8629. /**
  8630. * We need this JSDoc comment for affecting ESDoc.
  8631. * @ignore
  8632. * @extends {Ignored}
  8633. */
  8634. var AsyncAction = (function (_super) {
  8635. __extends(AsyncAction, _super);
  8636. function AsyncAction(scheduler, work) {
  8637. _super.call(this, scheduler, work);
  8638. this.scheduler = scheduler;
  8639. this.pending = false;
  8640. this.work = work;
  8641. }
  8642. AsyncAction.prototype.schedule = function (state, delay) {
  8643. if (delay === void 0) { delay = 0; }
  8644. if (this.closed) {
  8645. return this;
  8646. }
  8647. // Always replace the current state with the new state.
  8648. this.state = state;
  8649. // Set the pending flag indicating that this action has been scheduled, or
  8650. // has recursively rescheduled itself.
  8651. this.pending = true;
  8652. var id = this.id;
  8653. var scheduler = this.scheduler;
  8654. //
  8655. // Important implementation note:
  8656. //
  8657. // Actions only execute once by default, unless rescheduled from within the
  8658. // scheduled callback. This allows us to implement single and repeat
  8659. // actions via the same code path, without adding API surface area, as well
  8660. // as mimic traditional recursion but across asynchronous boundaries.
  8661. //
  8662. // However, JS runtimes and timers distinguish between intervals achieved by
  8663. // serial `setTimeout` calls vs. a single `setInterval` call. An interval of
  8664. // serial `setTimeout` calls can be individually delayed, which delays
  8665. // scheduling the next `setTimeout`, and so on. `setInterval` attempts to
  8666. // guarantee the interval callback will be invoked more precisely to the
  8667. // interval period, regardless of load.
  8668. //
  8669. // Therefore, we use `setInterval` to schedule single and repeat actions.
  8670. // If the action reschedules itself with the same delay, the interval is not
  8671. // canceled. If the action doesn't reschedule, or reschedules with a
  8672. // different delay, the interval will be canceled after scheduled callback
  8673. // execution.
  8674. //
  8675. if (id != null) {
  8676. this.id = this.recycleAsyncId(scheduler, id, delay);
  8677. }
  8678. this.delay = delay;
  8679. // If this action has already an async Id, don't request a new one.
  8680. this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
  8681. return this;
  8682. };
  8683. AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  8684. if (delay === void 0) { delay = 0; }
  8685. return root_1.root.setInterval(scheduler.flush.bind(scheduler, this), delay);
  8686. };
  8687. AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  8688. if (delay === void 0) { delay = 0; }
  8689. // If this action is rescheduled with the same delay time, don't clear the interval id.
  8690. if (delay !== null && this.delay === delay && this.pending === false) {
  8691. return id;
  8692. }
  8693. // Otherwise, if the action's delay time is different from the current delay,
  8694. // or the action has been rescheduled before it's executed, clear the interval id
  8695. return root_1.root.clearInterval(id) && undefined || undefined;
  8696. };
  8697. /**
  8698. * Immediately executes this action and the `work` it contains.
  8699. * @return {any}
  8700. */
  8701. AsyncAction.prototype.execute = function (state, delay) {
  8702. if (this.closed) {
  8703. return new Error('executing a cancelled action');
  8704. }
  8705. this.pending = false;
  8706. var error = this._execute(state, delay);
  8707. if (error) {
  8708. return error;
  8709. }
  8710. else if (this.pending === false && this.id != null) {
  8711. // Dequeue if the action didn't reschedule itself. Don't call
  8712. // unsubscribe(), because the action could reschedule later.
  8713. // For example:
  8714. // ```
  8715. // scheduler.schedule(function doWork(counter) {
  8716. // /* ... I'm a busy worker bee ... */
  8717. // var originalAction = this;
  8718. // /* wait 100ms before rescheduling the action */
  8719. // setTimeout(function () {
  8720. // originalAction.schedule(counter + 1);
  8721. // }, 100);
  8722. // }, 1000);
  8723. // ```
  8724. this.id = this.recycleAsyncId(this.scheduler, this.id, null);
  8725. }
  8726. };
  8727. AsyncAction.prototype._execute = function (state, delay) {
  8728. var errored = false;
  8729. var errorValue = undefined;
  8730. try {
  8731. this.work(state);
  8732. }
  8733. catch (e) {
  8734. errored = true;
  8735. errorValue = !!e && e || new Error(e);
  8736. }
  8737. if (errored) {
  8738. this.unsubscribe();
  8739. return errorValue;
  8740. }
  8741. };
  8742. /** @deprecated internal use only */ AsyncAction.prototype._unsubscribe = function () {
  8743. var id = this.id;
  8744. var scheduler = this.scheduler;
  8745. var actions = scheduler.actions;
  8746. var index = actions.indexOf(this);
  8747. this.work = null;
  8748. this.state = null;
  8749. this.pending = false;
  8750. this.scheduler = null;
  8751. if (index !== -1) {
  8752. actions.splice(index, 1);
  8753. }
  8754. if (id != null) {
  8755. this.id = this.recycleAsyncId(scheduler, id, null);
  8756. }
  8757. this.delay = null;
  8758. };
  8759. return AsyncAction;
  8760. }(Action_1.Action));
  8761. exports.AsyncAction = AsyncAction;
  8762. //# sourceMappingURL=AsyncAction.js.map
  8763. /***/ }),
  8764. /* 80 */
  8765. /***/ (function(module, exports, __webpack_require__) {
  8766. "use strict";
  8767. var __extends = (this && this.__extends) || function (d, b) {
  8768. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8769. function __() { this.constructor = d; }
  8770. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8771. };
  8772. var Scheduler_1 = __webpack_require__(140);
  8773. var AsyncScheduler = (function (_super) {
  8774. __extends(AsyncScheduler, _super);
  8775. function AsyncScheduler() {
  8776. _super.apply(this, arguments);
  8777. this.actions = [];
  8778. /**
  8779. * A flag to indicate whether the Scheduler is currently executing a batch of
  8780. * queued actions.
  8781. * @type {boolean}
  8782. */
  8783. this.active = false;
  8784. /**
  8785. * An internal ID used to track the latest asynchronous task such as those
  8786. * coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and
  8787. * others.
  8788. * @type {any}
  8789. */
  8790. this.scheduled = undefined;
  8791. }
  8792. AsyncScheduler.prototype.flush = function (action) {
  8793. var actions = this.actions;
  8794. if (this.active) {
  8795. actions.push(action);
  8796. return;
  8797. }
  8798. var error;
  8799. this.active = true;
  8800. do {
  8801. if (error = action.execute(action.state, action.delay)) {
  8802. break;
  8803. }
  8804. } while (action = actions.shift()); // exhaust the scheduler queue
  8805. this.active = false;
  8806. if (error) {
  8807. while (action = actions.shift()) {
  8808. action.unsubscribe();
  8809. }
  8810. throw error;
  8811. }
  8812. };
  8813. return AsyncScheduler;
  8814. }(Scheduler_1.Scheduler));
  8815. exports.AsyncScheduler = AsyncScheduler;
  8816. //# sourceMappingURL=AsyncScheduler.js.map
  8817. /***/ }),
  8818. /* 81 */
  8819. /***/ (function(module, exports, __webpack_require__) {
  8820. "use strict";
  8821. Object.defineProperty(exports, "__esModule", { value: true });
  8822. var map_1 = __webpack_require__(2);
  8823. var dom_effects_1 = __webpack_require__(19);
  8824. var tap_1 = __webpack_require__(5);
  8825. var Log = __webpack_require__(14);
  8826. function styleSetDomEffect(xs) {
  8827. return xs.pipe(tap_1.tap(function (event) {
  8828. var style = event.style, styleName = event.styleName, newValue = event.newValue;
  8829. style[styleName] = newValue;
  8830. }), map_1.map(function (e) { return Log.consoleInfo("[StyleSet] " + e.styleName + " = " + e.pathName); }));
  8831. }
  8832. exports.styleSetDomEffect = styleSetDomEffect;
  8833. function styleSet(incoming) {
  8834. return [dom_effects_1.Events.StyleSet, incoming];
  8835. }
  8836. exports.styleSet = styleSet;
  8837. /***/ }),
  8838. /* 82 */
  8839. /***/ (function(module, exports, __webpack_require__) {
  8840. "use strict";
  8841. Object.defineProperty(exports, "__esModule", { value: true });
  8842. var map_1 = __webpack_require__(2);
  8843. var filter_1 = __webpack_require__(4);
  8844. var withLatestFrom_1 = __webpack_require__(0);
  8845. var Log = __webpack_require__(14);
  8846. var pluck_1 = __webpack_require__(6);
  8847. var dom_effects_1 = __webpack_require__(19);
  8848. function linkReplaceDomEffect(xs, inputs) {
  8849. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("injectNotification"))), filter_1.filter(function (_a) {
  8850. var inject = _a[1];
  8851. return inject;
  8852. }), map_1.map(function (_a) {
  8853. var incoming = _a[0], inject = _a[1];
  8854. var message = "[LinkReplace] " + incoming.basename;
  8855. if (inject === "overlay") {
  8856. return Log.overlayInfo(message);
  8857. }
  8858. return Log.consoleInfo(message);
  8859. }));
  8860. }
  8861. exports.linkReplaceDomEffect = linkReplaceDomEffect;
  8862. function linkReplace(incoming) {
  8863. return [dom_effects_1.Events.LinkReplace, incoming];
  8864. }
  8865. exports.linkReplace = linkReplace;
  8866. /***/ }),
  8867. /* 83 */
  8868. /***/ (function(module, exports, __webpack_require__) {
  8869. "use strict";
  8870. Object.defineProperty(exports, "__esModule", { value: true });
  8871. var ignoreElements_1 = __webpack_require__(11);
  8872. var withLatestFrom_1 = __webpack_require__(0);
  8873. var tap_1 = __webpack_require__(5);
  8874. var dom_effects_1 = __webpack_require__(19);
  8875. function setScroll(x, y) {
  8876. return [dom_effects_1.Events.SetScroll, { x: x, y: y }];
  8877. }
  8878. exports.setScroll = setScroll;
  8879. function setScrollDomEffect(xs, inputs) {
  8880. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.window$), tap_1.tap(function (_a) {
  8881. var event = _a[0], window = _a[1];
  8882. return window.scrollTo(event.x, event.y);
  8883. }), ignoreElements_1.ignoreElements());
  8884. }
  8885. exports.setScrollDomEffect = setScrollDomEffect;
  8886. /***/ }),
  8887. /* 84 */
  8888. /***/ (function(module, exports, __webpack_require__) {
  8889. "use strict";
  8890. Object.defineProperty(exports, "__esModule", { value: true });
  8891. var ignoreElements_1 = __webpack_require__(11);
  8892. var withLatestFrom_1 = __webpack_require__(0);
  8893. var tap_1 = __webpack_require__(5);
  8894. var dom_effects_1 = __webpack_require__(19);
  8895. function setWindowNameDomEffect(xs, inputs) {
  8896. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.window$), tap_1.tap(function (_a) {
  8897. var value = _a[0], window = _a[1];
  8898. return (window.name = value);
  8899. }), ignoreElements_1.ignoreElements());
  8900. }
  8901. exports.setWindowNameDomEffect = setWindowNameDomEffect;
  8902. function setWindowName(incoming) {
  8903. return [dom_effects_1.Events.SetWindowName, incoming];
  8904. }
  8905. exports.setWindowName = setWindowName;
  8906. /***/ }),
  8907. /* 85 */
  8908. /***/ (function(module, exports, __webpack_require__) {
  8909. "use strict";
  8910. Object.defineProperty(exports, "__esModule", { value: true });
  8911. var socket_messages_1 = __webpack_require__(10);
  8912. var pluck_1 = __webpack_require__(6);
  8913. var filter_1 = __webpack_require__(4);
  8914. var map_1 = __webpack_require__(2);
  8915. var withLatestFrom_1 = __webpack_require__(0);
  8916. var effects_1 = __webpack_require__(8);
  8917. function outgoing(data, tagName, index, mappingIndex) {
  8918. if (mappingIndex === void 0) { mappingIndex = -1; }
  8919. return [
  8920. socket_messages_1.OutgoingSocketEvents.Scroll,
  8921. { position: data, tagName: tagName, index: index, mappingIndex: mappingIndex }
  8922. ];
  8923. }
  8924. exports.outgoing = outgoing;
  8925. function incomingScrollHandler(xs, inputs) {
  8926. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("ghostMode", "scroll")), inputs.window$.pipe(pluck_1.pluck("location", "pathname"))), filter_1.filter(function (_a) {
  8927. var event = _a[0], canScroll = _a[1], pathname = _a[2];
  8928. return canScroll && event.pathname === pathname;
  8929. }), map_1.map(function (_a) {
  8930. var event = _a[0];
  8931. return [effects_1.EffectNames.BrowserSetScroll, event];
  8932. }));
  8933. }
  8934. exports.incomingScrollHandler = incomingScrollHandler;
  8935. /***/ }),
  8936. /* 86 */
  8937. /***/ (function(module, exports, __webpack_require__) {
  8938. "use strict";
  8939. Object.defineProperty(exports, "__esModule", { value: true });
  8940. var effects_1 = __webpack_require__(8);
  8941. var Reloader_1 = __webpack_require__(143);
  8942. var withLatestFrom_1 = __webpack_require__(0);
  8943. var mergeMap_1 = __webpack_require__(15);
  8944. function fileReload(event) {
  8945. return [effects_1.EffectNames.FileReload, event];
  8946. }
  8947. exports.fileReload = fileReload;
  8948. /**
  8949. * Attempt to reload files in place
  8950. * @param xs
  8951. * @param inputs
  8952. */
  8953. function fileReloadEffect(xs, inputs) {
  8954. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$, inputs.document$, inputs.navigator$), mergeMap_1.mergeMap(function (_a) {
  8955. var event = _a[0], options = _a[1], document = _a[2], navigator = _a[3];
  8956. return Reloader_1.reload(document, navigator)(event, {
  8957. tagNames: options.tagNames,
  8958. liveCSS: true,
  8959. liveImg: true
  8960. });
  8961. }));
  8962. }
  8963. exports.fileReloadEffect = fileReloadEffect;
  8964. /***/ }),
  8965. /* 87 */
  8966. /***/ (function(module, exports, __webpack_require__) {
  8967. "use strict";
  8968. var FromObservable_1 = __webpack_require__(144);
  8969. exports.from = FromObservable_1.FromObservable.create;
  8970. //# sourceMappingURL=from.js.map
  8971. /***/ }),
  8972. /* 88 */
  8973. /***/ (function(module, exports, __webpack_require__) {
  8974. "use strict";
  8975. var __extends = (this && this.__extends) || function (d, b) {
  8976. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  8977. function __() { this.constructor = d; }
  8978. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8979. };
  8980. var Subscriber_1 = __webpack_require__(3);
  8981. /**
  8982. * Emits the given constant value on the output Observable every time the source
  8983. * Observable emits a value.
  8984. *
  8985. * <span class="informal">Like {@link map}, but it maps every source value to
  8986. * the same output value every time.</span>
  8987. *
  8988. * <img src="./img/mapTo.png" width="100%">
  8989. *
  8990. * Takes a constant `value` as argument, and emits that whenever the source
  8991. * Observable emits a value. In other words, ignores the actual source value,
  8992. * and simply uses the emission moment to know when to emit the given `value`.
  8993. *
  8994. * @example <caption>Map every click to the string 'Hi'</caption>
  8995. * var clicks = Rx.Observable.fromEvent(document, 'click');
  8996. * var greetings = clicks.mapTo('Hi');
  8997. * greetings.subscribe(x => console.log(x));
  8998. *
  8999. * @see {@link map}
  9000. *
  9001. * @param {any} value The value to map each source value to.
  9002. * @return {Observable} An Observable that emits the given `value` every time
  9003. * the source Observable emits something.
  9004. * @method mapTo
  9005. * @owner Observable
  9006. */
  9007. function mapTo(value) {
  9008. return function (source) { return source.lift(new MapToOperator(value)); };
  9009. }
  9010. exports.mapTo = mapTo;
  9011. var MapToOperator = (function () {
  9012. function MapToOperator(value) {
  9013. this.value = value;
  9014. }
  9015. MapToOperator.prototype.call = function (subscriber, source) {
  9016. return source.subscribe(new MapToSubscriber(subscriber, this.value));
  9017. };
  9018. return MapToOperator;
  9019. }());
  9020. /**
  9021. * We need this JSDoc comment for affecting ESDoc.
  9022. * @ignore
  9023. * @extends {Ignored}
  9024. */
  9025. var MapToSubscriber = (function (_super) {
  9026. __extends(MapToSubscriber, _super);
  9027. function MapToSubscriber(destination, value) {
  9028. _super.call(this, destination);
  9029. this.value = value;
  9030. }
  9031. MapToSubscriber.prototype._next = function (x) {
  9032. this.destination.next(this.value);
  9033. };
  9034. return MapToSubscriber;
  9035. }(Subscriber_1.Subscriber));
  9036. //# sourceMappingURL=mapTo.js.map
  9037. /***/ }),
  9038. /* 89 */
  9039. /***/ (function(module, exports, __webpack_require__) {
  9040. "use strict";
  9041. Object.defineProperty(exports, "__esModule", { value: true });
  9042. var ignoreElements_1 = __webpack_require__(11);
  9043. var tap_1 = __webpack_require__(5);
  9044. var withLatestFrom_1 = __webpack_require__(0);
  9045. var effects_1 = __webpack_require__(8);
  9046. function browserSetLocationEffect(xs, inputs) {
  9047. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.window$), tap_1.tap(function (_a) {
  9048. var event = _a[0], window = _a[1];
  9049. if (event.path) {
  9050. return (window.location =
  9051. window.location.protocol +
  9052. "//" +
  9053. window.location.host +
  9054. event.path);
  9055. }
  9056. if (event.url) {
  9057. return (window.location = event.url);
  9058. }
  9059. }), ignoreElements_1.ignoreElements());
  9060. }
  9061. exports.browserSetLocationEffect = browserSetLocationEffect;
  9062. function browserSetLocation(input) {
  9063. return [effects_1.EffectNames.BrowserSetLocation, input];
  9064. }
  9065. exports.browserSetLocation = browserSetLocation;
  9066. /***/ }),
  9067. /* 90 */
  9068. /***/ (function(module, exports, __webpack_require__) {
  9069. "use strict";
  9070. Object.defineProperty(exports, "__esModule", { value: true });
  9071. var ignoreElements_1 = __webpack_require__(11);
  9072. var tap_1 = __webpack_require__(5);
  9073. var withLatestFrom_1 = __webpack_require__(0);
  9074. var effects_1 = __webpack_require__(8);
  9075. function simulateClickEffect(xs, inputs) {
  9076. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.window$, inputs.document$), tap_1.tap(function (_a) {
  9077. var event = _a[0], window = _a[1], document = _a[2];
  9078. var elems = document.getElementsByTagName(event.tagName);
  9079. var match = elems[event.index];
  9080. if (match) {
  9081. if (document.createEvent) {
  9082. window.setTimeout(function () {
  9083. var evObj = document.createEvent("MouseEvents");
  9084. evObj.initEvent("click", true, true);
  9085. match.dispatchEvent(evObj);
  9086. }, 0);
  9087. }
  9088. else {
  9089. window.setTimeout(function () {
  9090. if (document.createEventObject) {
  9091. var evObj = document.createEventObject();
  9092. evObj.cancelBubble = true;
  9093. match.fireEvent("on" + "click", evObj);
  9094. }
  9095. }, 0);
  9096. }
  9097. }
  9098. }), ignoreElements_1.ignoreElements());
  9099. }
  9100. exports.simulateClickEffect = simulateClickEffect;
  9101. function simulateClick(event) {
  9102. return [effects_1.EffectNames.SimulateClick, event];
  9103. }
  9104. exports.simulateClick = simulateClick;
  9105. /***/ }),
  9106. /* 91 */
  9107. /***/ (function(module, exports, __webpack_require__) {
  9108. "use strict";
  9109. Object.defineProperty(exports, "__esModule", { value: true });
  9110. var tap_1 = __webpack_require__(5);
  9111. var withLatestFrom_1 = __webpack_require__(0);
  9112. var effects_1 = __webpack_require__(8);
  9113. function setElementValueEffect(xs, inputs) {
  9114. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.document$), tap_1.tap(function (_a) {
  9115. var event = _a[0], document = _a[1];
  9116. var elems = document.getElementsByTagName(event.tagName);
  9117. var match = elems[event.index];
  9118. if (match) {
  9119. match.value = event.value;
  9120. }
  9121. }));
  9122. }
  9123. exports.setElementValueEffect = setElementValueEffect;
  9124. function setElementValue(event) {
  9125. return [effects_1.EffectNames.SetElementValue, event];
  9126. }
  9127. exports.setElementValue = setElementValue;
  9128. /***/ }),
  9129. /* 92 */
  9130. /***/ (function(module, exports, __webpack_require__) {
  9131. "use strict";
  9132. Object.defineProperty(exports, "__esModule", { value: true });
  9133. var tap_1 = __webpack_require__(5);
  9134. var withLatestFrom_1 = __webpack_require__(0);
  9135. var effects_1 = __webpack_require__(8);
  9136. function setElementToggleValueEffect(xs, inputs) {
  9137. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.document$), tap_1.tap(function (_a) {
  9138. var event = _a[0], document = _a[1];
  9139. var elems = document.getElementsByTagName(event.tagName);
  9140. var match = elems[event.index];
  9141. if (match) {
  9142. if (event.type === "radio") {
  9143. match.checked = true;
  9144. }
  9145. if (event.type === "checkbox") {
  9146. match.checked = event.checked;
  9147. }
  9148. if (event.tagName === "SELECT") {
  9149. match.value = event.value;
  9150. }
  9151. }
  9152. }));
  9153. }
  9154. exports.setElementToggleValueEffect = setElementToggleValueEffect;
  9155. function setElementToggleValue(event) {
  9156. return [effects_1.EffectNames.SetElementToggleValue, event];
  9157. }
  9158. exports.setElementToggleValue = setElementToggleValue;
  9159. /***/ }),
  9160. /* 93 */
  9161. /***/ (function(module, exports, __webpack_require__) {
  9162. "use strict";
  9163. Object.defineProperty(exports, "__esModule", { value: true });
  9164. var effects_1 = __webpack_require__(8);
  9165. var tap_1 = __webpack_require__(5);
  9166. var withLatestFrom_1 = __webpack_require__(0);
  9167. function browserReload() {
  9168. return [effects_1.EffectNames.BrowserReload];
  9169. }
  9170. exports.browserReload = browserReload;
  9171. function preBrowserReload() {
  9172. return [effects_1.EffectNames.PreBrowserReload];
  9173. }
  9174. exports.preBrowserReload = preBrowserReload;
  9175. function browserReloadEffect(xs, inputs) {
  9176. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.window$), tap_1.tap(function (_a) {
  9177. var window = _a[1];
  9178. return window.location.reload(true);
  9179. }));
  9180. }
  9181. exports.browserReloadEffect = browserReloadEffect;
  9182. /***/ }),
  9183. /* 94 */
  9184. /***/ (function(module, exports, __webpack_require__) {
  9185. "use strict";
  9186. Object.defineProperty(exports, "__esModule", { value: true });
  9187. var socket_messages_1 = __webpack_require__(10);
  9188. var pluck_1 = __webpack_require__(6);
  9189. var filter_1 = __webpack_require__(4);
  9190. var map_1 = __webpack_require__(2);
  9191. var withLatestFrom_1 = __webpack_require__(0);
  9192. var simulate_click_effect_1 = __webpack_require__(90);
  9193. function outgoing(data) {
  9194. return [socket_messages_1.OutgoingSocketEvents.Click, data];
  9195. }
  9196. exports.outgoing = outgoing;
  9197. function incomingHandler$(xs, inputs) {
  9198. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("ghostMode", "clicks")), inputs.window$.pipe(pluck_1.pluck("location", "pathname"))), filter_1.filter(function (_a) {
  9199. var event = _a[0], canClick = _a[1], pathname = _a[2];
  9200. return canClick && event.pathname === pathname;
  9201. }), map_1.map(function (_a) {
  9202. var event = _a[0];
  9203. return simulate_click_effect_1.simulateClick(event);
  9204. }));
  9205. }
  9206. exports.incomingHandler$ = incomingHandler$;
  9207. /***/ }),
  9208. /* 95 */
  9209. /***/ (function(module, exports, __webpack_require__) {
  9210. "use strict";
  9211. var __assign = (this && this.__assign) || function () {
  9212. __assign = Object.assign || function(t) {
  9213. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9214. s = arguments[i];
  9215. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  9216. t[p] = s[p];
  9217. }
  9218. return t;
  9219. };
  9220. return __assign.apply(this, arguments);
  9221. };
  9222. Object.defineProperty(exports, "__esModule", { value: true });
  9223. var socket_messages_1 = __webpack_require__(10);
  9224. var pluck_1 = __webpack_require__(6);
  9225. var filter_1 = __webpack_require__(4);
  9226. var map_1 = __webpack_require__(2);
  9227. var withLatestFrom_1 = __webpack_require__(0);
  9228. var set_element_value_effect_1 = __webpack_require__(91);
  9229. function outgoing(element, value) {
  9230. return [
  9231. socket_messages_1.OutgoingSocketEvents.Keyup,
  9232. __assign({}, element, { value: value })
  9233. ];
  9234. }
  9235. exports.outgoing = outgoing;
  9236. function incomingKeyupHandler(xs, inputs) {
  9237. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("ghostMode", "forms", "inputs")), inputs.window$.pipe(pluck_1.pluck("location", "pathname"))), filter_1.filter(function (_a) {
  9238. var event = _a[0], canKeyup = _a[1], pathname = _a[2];
  9239. return canKeyup && event.pathname === pathname;
  9240. }), map_1.map(function (_a) {
  9241. var event = _a[0];
  9242. return set_element_value_effect_1.setElementValue(event);
  9243. }));
  9244. }
  9245. exports.incomingKeyupHandler = incomingKeyupHandler;
  9246. /***/ }),
  9247. /* 96 */
  9248. /***/ (function(module, exports, __webpack_require__) {
  9249. "use strict";
  9250. Object.defineProperty(exports, "__esModule", { value: true });
  9251. var filter_1 = __webpack_require__(4);
  9252. var withLatestFrom_1 = __webpack_require__(0);
  9253. var mergeMap_1 = __webpack_require__(15);
  9254. var concat_1 = __webpack_require__(54);
  9255. var of_1 = __webpack_require__(9);
  9256. var browser_reload_effect_1 = __webpack_require__(93);
  9257. var subscribeOn_1 = __webpack_require__(158);
  9258. var async_1 = __webpack_require__(78);
  9259. function incomingBrowserReload(xs, inputs) {
  9260. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$), filter_1.filter(function (_a) {
  9261. var event = _a[0], options = _a[1];
  9262. return options.codeSync;
  9263. }), mergeMap_1.mergeMap(reloadBrowserSafe));
  9264. }
  9265. exports.incomingBrowserReload = incomingBrowserReload;
  9266. function reloadBrowserSafe() {
  9267. return concat_1.concat(
  9268. /**
  9269. * Emit a warning message allowing others to do some work
  9270. */
  9271. of_1.of(browser_reload_effect_1.preBrowserReload()),
  9272. /**
  9273. * On the next tick, perform the reload
  9274. */
  9275. of_1.of(browser_reload_effect_1.browserReload()).pipe(subscribeOn_1.subscribeOn(async_1.async)));
  9276. }
  9277. exports.reloadBrowserSafe = reloadBrowserSafe;
  9278. /***/ }),
  9279. /* 97 */
  9280. /***/ (function(module, exports, __webpack_require__) {
  9281. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  9282. (typeof self !== "undefined" && self) ||
  9283. window;
  9284. var apply = Function.prototype.apply;
  9285. // DOM APIs, for completeness
  9286. exports.setTimeout = function() {
  9287. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  9288. };
  9289. exports.setInterval = function() {
  9290. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  9291. };
  9292. exports.clearTimeout =
  9293. exports.clearInterval = function(timeout) {
  9294. if (timeout) {
  9295. timeout.close();
  9296. }
  9297. };
  9298. function Timeout(id, clearFn) {
  9299. this._id = id;
  9300. this._clearFn = clearFn;
  9301. }
  9302. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  9303. Timeout.prototype.close = function() {
  9304. this._clearFn.call(scope, this._id);
  9305. };
  9306. // Does not start the time, just sets up the members needed.
  9307. exports.enroll = function(item, msecs) {
  9308. clearTimeout(item._idleTimeoutId);
  9309. item._idleTimeout = msecs;
  9310. };
  9311. exports.unenroll = function(item) {
  9312. clearTimeout(item._idleTimeoutId);
  9313. item._idleTimeout = -1;
  9314. };
  9315. exports._unrefActive = exports.active = function(item) {
  9316. clearTimeout(item._idleTimeoutId);
  9317. var msecs = item._idleTimeout;
  9318. if (msecs >= 0) {
  9319. item._idleTimeoutId = setTimeout(function onTimeout() {
  9320. if (item._onTimeout)
  9321. item._onTimeout();
  9322. }, msecs);
  9323. }
  9324. };
  9325. // setimmediate attaches itself to the global object
  9326. __webpack_require__(163);
  9327. // On some exotic environments, it's not clear which object `setimmediate` was
  9328. // able to install onto. Search each possibility in the same order as the
  9329. // `setimmediate` library.
  9330. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  9331. (typeof global !== "undefined" && global.setImmediate) ||
  9332. (this && this.setImmediate);
  9333. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  9334. (typeof global !== "undefined" && global.clearImmediate) ||
  9335. (this && this.clearImmediate);
  9336. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24)))
  9337. /***/ }),
  9338. /* 98 */
  9339. /***/ (function(module, exports, __webpack_require__) {
  9340. "use strict";
  9341. var __assign = (this && this.__assign) || function () {
  9342. __assign = Object.assign || function(t) {
  9343. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9344. s = arguments[i];
  9345. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  9346. t[p] = s[p];
  9347. }
  9348. return t;
  9349. };
  9350. return __assign.apply(this, arguments);
  9351. };
  9352. Object.defineProperty(exports, "__esModule", { value: true });
  9353. var socket_messages_1 = __webpack_require__(10);
  9354. var pluck_1 = __webpack_require__(6);
  9355. var filter_1 = __webpack_require__(4);
  9356. var map_1 = __webpack_require__(2);
  9357. var withLatestFrom_1 = __webpack_require__(0);
  9358. var set_element_toggle_value_effect_1 = __webpack_require__(92);
  9359. function outgoing(element, props) {
  9360. return [
  9361. socket_messages_1.OutgoingSocketEvents.InputToggle,
  9362. __assign({}, element, props)
  9363. ];
  9364. }
  9365. exports.outgoing = outgoing;
  9366. function incomingInputsToggles(xs, inputs) {
  9367. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("ghostMode", "forms", "toggles")), inputs.window$.pipe(pluck_1.pluck("location", "pathname"))), filter_1.filter(function (_a) {
  9368. var toggles = _a[1];
  9369. return toggles === true;
  9370. }), map_1.map(function (_a) {
  9371. var event = _a[0];
  9372. return set_element_toggle_value_effect_1.setElementToggleValue(event);
  9373. }));
  9374. }
  9375. exports.incomingInputsToggles = incomingInputsToggles;
  9376. /***/ }),
  9377. /* 99 */
  9378. /***/ (function(module, exports, __webpack_require__) {
  9379. module.exports = __webpack_require__(100);
  9380. /***/ }),
  9381. /* 100 */
  9382. /***/ (function(module, exports, __webpack_require__) {
  9383. "use strict";
  9384. var __assign = (this && this.__assign) || function () {
  9385. __assign = Object.assign || function(t) {
  9386. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9387. s = arguments[i];
  9388. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  9389. t[p] = s[p];
  9390. }
  9391. return t;
  9392. };
  9393. return __assign.apply(this, arguments);
  9394. };
  9395. Object.defineProperty(exports, "__esModule", { value: true });
  9396. var zip_1 = __webpack_require__(101);
  9397. var socket_1 = __webpack_require__(107);
  9398. var notify_1 = __webpack_require__(137);
  9399. var dom_effects_1 = __webpack_require__(19);
  9400. var socket_messages_1 = __webpack_require__(10);
  9401. var merge_1 = __webpack_require__(38);
  9402. var log_1 = __webpack_require__(14);
  9403. var effects_1 = __webpack_require__(8);
  9404. var scroll_restore_1 = __webpack_require__(169);
  9405. var listeners_1 = __webpack_require__(170);
  9406. var groupBy_1 = __webpack_require__(176);
  9407. var withLatestFrom_1 = __webpack_require__(0);
  9408. var mergeMap_1 = __webpack_require__(15);
  9409. var share_1 = __webpack_require__(74);
  9410. var filter_1 = __webpack_require__(4);
  9411. var pluck_1 = __webpack_require__(6);
  9412. var of_1 = __webpack_require__(9);
  9413. var window$ = socket_1.initWindow();
  9414. var document$ = socket_1.initDocument();
  9415. var names$ = scroll_restore_1.initWindowName(window);
  9416. var _a = socket_1.initSocket(), socket$ = _a.socket$, io$ = _a.io$;
  9417. var option$ = socket_1.initOptions();
  9418. var navigator$ = of_1.of(navigator);
  9419. var notifyElement$ = notify_1.initNotify(option$.getValue());
  9420. var logInstance$ = log_1.initLogger(option$.getValue());
  9421. var outgoing$ = listeners_1.initListeners(window, document, socket$, option$);
  9422. var inputs = {
  9423. window$: window$,
  9424. document$: document$,
  9425. socket$: socket$,
  9426. option$: option$,
  9427. navigator$: navigator$,
  9428. notifyElement$: notifyElement$,
  9429. logInstance$: logInstance$,
  9430. io$: io$,
  9431. outgoing$: outgoing$
  9432. };
  9433. function getStream(name, inputs) {
  9434. return function (handlers$, inputStream$) {
  9435. return inputStream$.pipe(groupBy_1.groupBy(function (_a) {
  9436. var keyName = _a[0];
  9437. return keyName;
  9438. }), withLatestFrom_1.withLatestFrom(handlers$), filter_1.filter(function (_a) {
  9439. var x = _a[0], handlers = _a[1];
  9440. return typeof handlers[x.key] === "function";
  9441. }), mergeMap_1.mergeMap(function (_a) {
  9442. var x = _a[0], handlers = _a[1];
  9443. return handlers[x.key](x.pipe(pluck_1.pluck(String(1))), inputs);
  9444. }), share_1.share());
  9445. };
  9446. }
  9447. var combinedEffectHandler$ = zip_1.zip(effects_1.effectOutputHandlers$, scroll_restore_1.scrollRestoreHandlers$, function () {
  9448. var args = [];
  9449. for (var _i = 0; _i < arguments.length; _i++) {
  9450. args[_i] = arguments[_i];
  9451. }
  9452. return args.reduce(function (acc, item) { return (__assign({}, acc, item)); }, {});
  9453. });
  9454. var output$ = getStream("[socket]", inputs)(socket_messages_1.socketHandlers$, merge_1.merge(inputs.socket$, outgoing$));
  9455. var effect$ = getStream("[effect]", inputs)(combinedEffectHandler$, output$);
  9456. var dom$ = getStream("[dom-effect]", inputs)(dom_effects_1.domHandlers$, merge_1.merge(effect$, names$));
  9457. var merged$ = merge_1.merge(output$, effect$, dom$);
  9458. var log$ = getStream("[log]", inputs)(log_1.logHandler$, merged$);
  9459. log$.subscribe();
  9460. // resume$.next(true);
  9461. // var socket = require("./socket");
  9462. // var shims = require("./client-shims");
  9463. // var notify = require("./notify");
  9464. // // var codeSync = require("./code-sync");
  9465. // const { BrowserSync } = require("./browser-sync");
  9466. // var ghostMode = require("./ghostmode");
  9467. // var events = require("./events");
  9468. // var utils = require("./browser.utils");
  9469. //
  9470. // const mitt = require("mitt").default;
  9471. //
  9472. // var shouldReload = false;
  9473. // var initialised = false;
  9474. //
  9475. // /**
  9476. // * @param options
  9477. // */
  9478. // function init(options: bs.InitOptions) {
  9479. // if (shouldReload && options.reloadOnRestart) {
  9480. // utils.reloadBrowser();
  9481. // }
  9482. //
  9483. // var BS = window.___browserSync___ || {};
  9484. // var emitter = mitt();
  9485. //
  9486. // if (!BS.client) {
  9487. // BS.client = true;
  9488. //
  9489. // var browserSync = new BrowserSync({ options, emitter, socket });
  9490. //
  9491. // // codeSync.init(browserSync);
  9492. //
  9493. // // // Always init on page load
  9494. // // ghostMode.init(browserSync);
  9495. // //
  9496. // // notify.init(browserSync);
  9497. // //
  9498. // // if (options.notify) {
  9499. // // notify.flash("Connected to BrowserSync");
  9500. // // }
  9501. // }
  9502. //
  9503. // // if (!initialised) {
  9504. // // socket.on("disconnect", function() {
  9505. // // if (options.notify) {
  9506. // // notify.flash("Disconnected from BrowserSync");
  9507. // // }
  9508. // // shouldReload = true;
  9509. // // });
  9510. // // initialised = true;
  9511. // // }
  9512. // }
  9513. //
  9514. // /**
  9515. // * Handle individual socket connections
  9516. // */
  9517. // socket.on("connection", init);
  9518. /***/ }),
  9519. /* 101 */
  9520. /***/ (function(module, exports, __webpack_require__) {
  9521. "use strict";
  9522. var zip_1 = __webpack_require__(102);
  9523. exports.zip = zip_1.zipStatic;
  9524. //# sourceMappingURL=zip.js.map
  9525. /***/ }),
  9526. /* 102 */
  9527. /***/ (function(module, exports, __webpack_require__) {
  9528. "use strict";
  9529. var __extends = (this && this.__extends) || function (d, b) {
  9530. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  9531. function __() { this.constructor = d; }
  9532. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9533. };
  9534. var ArrayObservable_1 = __webpack_require__(23);
  9535. var isArray_1 = __webpack_require__(26);
  9536. var Subscriber_1 = __webpack_require__(3);
  9537. var OuterSubscriber_1 = __webpack_require__(29);
  9538. var subscribeToResult_1 = __webpack_require__(30);
  9539. var iterator_1 = __webpack_require__(31);
  9540. /* tslint:enable:max-line-length */
  9541. /**
  9542. * @param observables
  9543. * @return {Observable<R>}
  9544. * @method zip
  9545. * @owner Observable
  9546. */
  9547. function zip() {
  9548. var observables = [];
  9549. for (var _i = 0; _i < arguments.length; _i++) {
  9550. observables[_i - 0] = arguments[_i];
  9551. }
  9552. return function zipOperatorFunction(source) {
  9553. return source.lift.call(zipStatic.apply(void 0, [source].concat(observables)));
  9554. };
  9555. }
  9556. exports.zip = zip;
  9557. /* tslint:enable:max-line-length */
  9558. /**
  9559. * Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each
  9560. * of its input Observables.
  9561. *
  9562. * If the latest parameter is a function, this function is used to compute the created value from the input values.
  9563. * Otherwise, an array of the input values is returned.
  9564. *
  9565. * @example <caption>Combine age and name from different sources</caption>
  9566. *
  9567. * let age$ = Observable.of<number>(27, 25, 29);
  9568. * let name$ = Observable.of<string>('Foo', 'Bar', 'Beer');
  9569. * let isDev$ = Observable.of<boolean>(true, true, false);
  9570. *
  9571. * Observable
  9572. * .zip(age$,
  9573. * name$,
  9574. * isDev$,
  9575. * (age: number, name: string, isDev: boolean) => ({ age, name, isDev }))
  9576. * .subscribe(x => console.log(x));
  9577. *
  9578. * // outputs
  9579. * // { age: 27, name: 'Foo', isDev: true }
  9580. * // { age: 25, name: 'Bar', isDev: true }
  9581. * // { age: 29, name: 'Beer', isDev: false }
  9582. *
  9583. * @param observables
  9584. * @return {Observable<R>}
  9585. * @static true
  9586. * @name zip
  9587. * @owner Observable
  9588. */
  9589. function zipStatic() {
  9590. var observables = [];
  9591. for (var _i = 0; _i < arguments.length; _i++) {
  9592. observables[_i - 0] = arguments[_i];
  9593. }
  9594. var project = observables[observables.length - 1];
  9595. if (typeof project === 'function') {
  9596. observables.pop();
  9597. }
  9598. return new ArrayObservable_1.ArrayObservable(observables).lift(new ZipOperator(project));
  9599. }
  9600. exports.zipStatic = zipStatic;
  9601. var ZipOperator = (function () {
  9602. function ZipOperator(project) {
  9603. this.project = project;
  9604. }
  9605. ZipOperator.prototype.call = function (subscriber, source) {
  9606. return source.subscribe(new ZipSubscriber(subscriber, this.project));
  9607. };
  9608. return ZipOperator;
  9609. }());
  9610. exports.ZipOperator = ZipOperator;
  9611. /**
  9612. * We need this JSDoc comment for affecting ESDoc.
  9613. * @ignore
  9614. * @extends {Ignored}
  9615. */
  9616. var ZipSubscriber = (function (_super) {
  9617. __extends(ZipSubscriber, _super);
  9618. function ZipSubscriber(destination, project, values) {
  9619. if (values === void 0) { values = Object.create(null); }
  9620. _super.call(this, destination);
  9621. this.iterators = [];
  9622. this.active = 0;
  9623. this.project = (typeof project === 'function') ? project : null;
  9624. this.values = values;
  9625. }
  9626. ZipSubscriber.prototype._next = function (value) {
  9627. var iterators = this.iterators;
  9628. if (isArray_1.isArray(value)) {
  9629. iterators.push(new StaticArrayIterator(value));
  9630. }
  9631. else if (typeof value[iterator_1.iterator] === 'function') {
  9632. iterators.push(new StaticIterator(value[iterator_1.iterator]()));
  9633. }
  9634. else {
  9635. iterators.push(new ZipBufferIterator(this.destination, this, value));
  9636. }
  9637. };
  9638. ZipSubscriber.prototype._complete = function () {
  9639. var iterators = this.iterators;
  9640. var len = iterators.length;
  9641. if (len === 0) {
  9642. this.destination.complete();
  9643. return;
  9644. }
  9645. this.active = len;
  9646. for (var i = 0; i < len; i++) {
  9647. var iterator = iterators[i];
  9648. if (iterator.stillUnsubscribed) {
  9649. this.add(iterator.subscribe(iterator, i));
  9650. }
  9651. else {
  9652. this.active--; // not an observable
  9653. }
  9654. }
  9655. };
  9656. ZipSubscriber.prototype.notifyInactive = function () {
  9657. this.active--;
  9658. if (this.active === 0) {
  9659. this.destination.complete();
  9660. }
  9661. };
  9662. ZipSubscriber.prototype.checkIterators = function () {
  9663. var iterators = this.iterators;
  9664. var len = iterators.length;
  9665. var destination = this.destination;
  9666. // abort if not all of them have values
  9667. for (var i = 0; i < len; i++) {
  9668. var iterator = iterators[i];
  9669. if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) {
  9670. return;
  9671. }
  9672. }
  9673. var shouldComplete = false;
  9674. var args = [];
  9675. for (var i = 0; i < len; i++) {
  9676. var iterator = iterators[i];
  9677. var result = iterator.next();
  9678. // check to see if it's completed now that you've gotten
  9679. // the next value.
  9680. if (iterator.hasCompleted()) {
  9681. shouldComplete = true;
  9682. }
  9683. if (result.done) {
  9684. destination.complete();
  9685. return;
  9686. }
  9687. args.push(result.value);
  9688. }
  9689. if (this.project) {
  9690. this._tryProject(args);
  9691. }
  9692. else {
  9693. destination.next(args);
  9694. }
  9695. if (shouldComplete) {
  9696. destination.complete();
  9697. }
  9698. };
  9699. ZipSubscriber.prototype._tryProject = function (args) {
  9700. var result;
  9701. try {
  9702. result = this.project.apply(this, args);
  9703. }
  9704. catch (err) {
  9705. this.destination.error(err);
  9706. return;
  9707. }
  9708. this.destination.next(result);
  9709. };
  9710. return ZipSubscriber;
  9711. }(Subscriber_1.Subscriber));
  9712. exports.ZipSubscriber = ZipSubscriber;
  9713. var StaticIterator = (function () {
  9714. function StaticIterator(iterator) {
  9715. this.iterator = iterator;
  9716. this.nextResult = iterator.next();
  9717. }
  9718. StaticIterator.prototype.hasValue = function () {
  9719. return true;
  9720. };
  9721. StaticIterator.prototype.next = function () {
  9722. var result = this.nextResult;
  9723. this.nextResult = this.iterator.next();
  9724. return result;
  9725. };
  9726. StaticIterator.prototype.hasCompleted = function () {
  9727. var nextResult = this.nextResult;
  9728. return nextResult && nextResult.done;
  9729. };
  9730. return StaticIterator;
  9731. }());
  9732. var StaticArrayIterator = (function () {
  9733. function StaticArrayIterator(array) {
  9734. this.array = array;
  9735. this.index = 0;
  9736. this.length = 0;
  9737. this.length = array.length;
  9738. }
  9739. StaticArrayIterator.prototype[iterator_1.iterator] = function () {
  9740. return this;
  9741. };
  9742. StaticArrayIterator.prototype.next = function (value) {
  9743. var i = this.index++;
  9744. var array = this.array;
  9745. return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
  9746. };
  9747. StaticArrayIterator.prototype.hasValue = function () {
  9748. return this.array.length > this.index;
  9749. };
  9750. StaticArrayIterator.prototype.hasCompleted = function () {
  9751. return this.array.length === this.index;
  9752. };
  9753. return StaticArrayIterator;
  9754. }());
  9755. /**
  9756. * We need this JSDoc comment for affecting ESDoc.
  9757. * @ignore
  9758. * @extends {Ignored}
  9759. */
  9760. var ZipBufferIterator = (function (_super) {
  9761. __extends(ZipBufferIterator, _super);
  9762. function ZipBufferIterator(destination, parent, observable) {
  9763. _super.call(this, destination);
  9764. this.parent = parent;
  9765. this.observable = observable;
  9766. this.stillUnsubscribed = true;
  9767. this.buffer = [];
  9768. this.isComplete = false;
  9769. }
  9770. ZipBufferIterator.prototype[iterator_1.iterator] = function () {
  9771. return this;
  9772. };
  9773. // NOTE: there is actually a name collision here with Subscriber.next and Iterator.next
  9774. // this is legit because `next()` will never be called by a subscription in this case.
  9775. ZipBufferIterator.prototype.next = function () {
  9776. var buffer = this.buffer;
  9777. if (buffer.length === 0 && this.isComplete) {
  9778. return { value: null, done: true };
  9779. }
  9780. else {
  9781. return { value: buffer.shift(), done: false };
  9782. }
  9783. };
  9784. ZipBufferIterator.prototype.hasValue = function () {
  9785. return this.buffer.length > 0;
  9786. };
  9787. ZipBufferIterator.prototype.hasCompleted = function () {
  9788. return this.buffer.length === 0 && this.isComplete;
  9789. };
  9790. ZipBufferIterator.prototype.notifyComplete = function () {
  9791. if (this.buffer.length > 0) {
  9792. this.isComplete = true;
  9793. this.parent.notifyInactive();
  9794. }
  9795. else {
  9796. this.destination.complete();
  9797. }
  9798. };
  9799. ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
  9800. this.buffer.push(innerValue);
  9801. this.parent.checkIterators();
  9802. };
  9803. ZipBufferIterator.prototype.subscribe = function (value, index) {
  9804. return subscribeToResult_1.subscribeToResult(this, this.observable, this, index);
  9805. };
  9806. return ZipBufferIterator;
  9807. }(OuterSubscriber_1.OuterSubscriber));
  9808. //# sourceMappingURL=zip.js.map
  9809. /***/ }),
  9810. /* 103 */
  9811. /***/ (function(module, exports, __webpack_require__) {
  9812. "use strict";
  9813. var Subscriber_1 = __webpack_require__(3);
  9814. var rxSubscriber_1 = __webpack_require__(44);
  9815. var Observer_1 = __webpack_require__(57);
  9816. function toSubscriber(nextOrObserver, error, complete) {
  9817. if (nextOrObserver) {
  9818. if (nextOrObserver instanceof Subscriber_1.Subscriber) {
  9819. return nextOrObserver;
  9820. }
  9821. if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
  9822. return nextOrObserver[rxSubscriber_1.rxSubscriber]();
  9823. }
  9824. }
  9825. if (!nextOrObserver && !error && !complete) {
  9826. return new Subscriber_1.Subscriber(Observer_1.empty);
  9827. }
  9828. return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
  9829. }
  9830. exports.toSubscriber = toSubscriber;
  9831. //# sourceMappingURL=toSubscriber.js.map
  9832. /***/ }),
  9833. /* 104 */
  9834. /***/ (function(module, exports, __webpack_require__) {
  9835. "use strict";
  9836. var __extends = (this && this.__extends) || function (d, b) {
  9837. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  9838. function __() { this.constructor = d; }
  9839. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9840. };
  9841. /**
  9842. * An error thrown when one or more errors have occurred during the
  9843. * `unsubscribe` of a {@link Subscription}.
  9844. */
  9845. var UnsubscriptionError = (function (_super) {
  9846. __extends(UnsubscriptionError, _super);
  9847. function UnsubscriptionError(errors) {
  9848. _super.call(this);
  9849. this.errors = errors;
  9850. var err = Error.call(this, errors ?
  9851. errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) { return ((i + 1) + ") " + err.toString()); }).join('\n ') : '');
  9852. this.name = err.name = 'UnsubscriptionError';
  9853. this.stack = err.stack;
  9854. this.message = err.message;
  9855. }
  9856. return UnsubscriptionError;
  9857. }(Error));
  9858. exports.UnsubscriptionError = UnsubscriptionError;
  9859. //# sourceMappingURL=UnsubscriptionError.js.map
  9860. /***/ }),
  9861. /* 105 */
  9862. /***/ (function(module, exports, __webpack_require__) {
  9863. "use strict";
  9864. var noop_1 = __webpack_require__(58);
  9865. /* tslint:enable:max-line-length */
  9866. function pipe() {
  9867. var fns = [];
  9868. for (var _i = 0; _i < arguments.length; _i++) {
  9869. fns[_i - 0] = arguments[_i];
  9870. }
  9871. return pipeFromArray(fns);
  9872. }
  9873. exports.pipe = pipe;
  9874. /* @internal */
  9875. function pipeFromArray(fns) {
  9876. if (!fns) {
  9877. return noop_1.noop;
  9878. }
  9879. if (fns.length === 1) {
  9880. return fns[0];
  9881. }
  9882. return function piped(input) {
  9883. return fns.reduce(function (prev, fn) { return fn(prev); }, input);
  9884. };
  9885. }
  9886. exports.pipeFromArray = pipeFromArray;
  9887. //# sourceMappingURL=pipe.js.map
  9888. /***/ }),
  9889. /* 106 */
  9890. /***/ (function(module, exports, __webpack_require__) {
  9891. "use strict";
  9892. var __extends = (this && this.__extends) || function (d, b) {
  9893. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  9894. function __() { this.constructor = d; }
  9895. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9896. };
  9897. var Subscriber_1 = __webpack_require__(3);
  9898. /**
  9899. * We need this JSDoc comment for affecting ESDoc.
  9900. * @ignore
  9901. * @extends {Ignored}
  9902. */
  9903. var InnerSubscriber = (function (_super) {
  9904. __extends(InnerSubscriber, _super);
  9905. function InnerSubscriber(parent, outerValue, outerIndex) {
  9906. _super.call(this);
  9907. this.parent = parent;
  9908. this.outerValue = outerValue;
  9909. this.outerIndex = outerIndex;
  9910. this.index = 0;
  9911. }
  9912. InnerSubscriber.prototype._next = function (value) {
  9913. this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
  9914. };
  9915. InnerSubscriber.prototype._error = function (error) {
  9916. this.parent.notifyError(error, this);
  9917. this.unsubscribe();
  9918. };
  9919. InnerSubscriber.prototype._complete = function () {
  9920. this.parent.notifyComplete(this);
  9921. this.unsubscribe();
  9922. };
  9923. return InnerSubscriber;
  9924. }(Subscriber_1.Subscriber));
  9925. exports.InnerSubscriber = InnerSubscriber;
  9926. //# sourceMappingURL=InnerSubscriber.js.map
  9927. /***/ }),
  9928. /* 107 */
  9929. /***/ (function(module, exports, __webpack_require__) {
  9930. "use strict";
  9931. Object.defineProperty(exports, "__esModule", { value: true });
  9932. var socket = __webpack_require__(108);
  9933. var Observable_1 = __webpack_require__(1);
  9934. var BehaviorSubject_1 = __webpack_require__(13);
  9935. var of_1 = __webpack_require__(9);
  9936. var share_1 = __webpack_require__(74);
  9937. /**
  9938. * Alias for socket.emit
  9939. * @param name
  9940. * @param data
  9941. */
  9942. // export function emit(name, data) {
  9943. // if (io && io.emit) {
  9944. // // send relative path of where the event is sent
  9945. // data.url = window.location.pathname;
  9946. // io.emit(name, data);
  9947. // }
  9948. // }
  9949. //
  9950. // /**
  9951. // * Alias for socket.on
  9952. // * @param name
  9953. // * @param func
  9954. // */
  9955. // export function on(name, func) {
  9956. // io.on(name, func);
  9957. // }
  9958. function initWindow() {
  9959. return of_1.of(window);
  9960. }
  9961. exports.initWindow = initWindow;
  9962. function initDocument() {
  9963. return of_1.of(document);
  9964. }
  9965. exports.initDocument = initDocument;
  9966. function initNavigator() {
  9967. return of_1.of(navigator);
  9968. }
  9969. exports.initNavigator = initNavigator;
  9970. function initOptions() {
  9971. return new BehaviorSubject_1.BehaviorSubject(window.___browserSync___.options);
  9972. }
  9973. exports.initOptions = initOptions;
  9974. function initSocket() {
  9975. /**
  9976. * @type {{emit: emit, on: on}}
  9977. */
  9978. var socketConfig = window.___browserSync___.socketConfig;
  9979. var socketUrl = window.___browserSync___.socketUrl;
  9980. var io = socket(socketUrl, socketConfig);
  9981. var onevent = io.onevent;
  9982. var socket$ = Observable_1.Observable.create(function (obs) {
  9983. io.onevent = function (packet) {
  9984. onevent.call(this, packet);
  9985. obs.next(packet.data);
  9986. };
  9987. }).pipe(share_1.share());
  9988. var io$ = new BehaviorSubject_1.BehaviorSubject(io);
  9989. /**
  9990. * *****BACK-COMPAT*******
  9991. * Scripts that come after Browsersync may rely on the previous window.___browserSync___.socket
  9992. */
  9993. window.___browserSync___.socket = io;
  9994. return { socket$: socket$, io$: io$ };
  9995. }
  9996. exports.initSocket = initSocket;
  9997. /***/ }),
  9998. /* 108 */
  9999. /***/ (function(module, exports, __webpack_require__) {
  10000. /**
  10001. * Module dependencies.
  10002. */
  10003. var url = __webpack_require__(109);
  10004. var parser = __webpack_require__(48);
  10005. var Manager = __webpack_require__(64);
  10006. var debug = __webpack_require__(32)('socket.io-client');
  10007. /**
  10008. * Module exports.
  10009. */
  10010. module.exports = exports = lookup;
  10011. /**
  10012. * Managers cache.
  10013. */
  10014. var cache = exports.managers = {};
  10015. /**
  10016. * Looks up an existing `Manager` for multiplexing.
  10017. * If the user summons:
  10018. *
  10019. * `io('http://localhost/a');`
  10020. * `io('http://localhost/b');`
  10021. *
  10022. * We reuse the existing instance based on same scheme/port/host,
  10023. * and we initialize sockets for each namespace.
  10024. *
  10025. * @api public
  10026. */
  10027. function lookup (uri, opts) {
  10028. if (typeof uri === 'object') {
  10029. opts = uri;
  10030. uri = undefined;
  10031. }
  10032. opts = opts || {};
  10033. var parsed = url(uri);
  10034. var source = parsed.source;
  10035. var id = parsed.id;
  10036. var path = parsed.path;
  10037. var sameNamespace = cache[id] && path in cache[id].nsps;
  10038. var newConnection = opts.forceNew || opts['force new connection'] ||
  10039. false === opts.multiplex || sameNamespace;
  10040. var io;
  10041. if (newConnection) {
  10042. debug('ignoring socket cache for %s', source);
  10043. io = Manager(source, opts);
  10044. } else {
  10045. if (!cache[id]) {
  10046. debug('new io instance for %s', source);
  10047. cache[id] = Manager(source, opts);
  10048. }
  10049. io = cache[id];
  10050. }
  10051. if (parsed.query && !opts.query) {
  10052. opts.query = parsed.query;
  10053. }
  10054. return io.socket(parsed.path, opts);
  10055. }
  10056. /**
  10057. * Protocol version.
  10058. *
  10059. * @api public
  10060. */
  10061. exports.protocol = parser.protocol;
  10062. /**
  10063. * `connect`.
  10064. *
  10065. * @param {String} uri
  10066. * @api public
  10067. */
  10068. exports.connect = lookup;
  10069. /**
  10070. * Expose constructors for standalone build.
  10071. *
  10072. * @api public
  10073. */
  10074. exports.Manager = __webpack_require__(64);
  10075. exports.Socket = __webpack_require__(70);
  10076. /***/ }),
  10077. /* 109 */
  10078. /***/ (function(module, exports, __webpack_require__) {
  10079. /**
  10080. * Module dependencies.
  10081. */
  10082. var parseuri = __webpack_require__(61);
  10083. var debug = __webpack_require__(32)('socket.io-client:url');
  10084. /**
  10085. * Module exports.
  10086. */
  10087. module.exports = url;
  10088. /**
  10089. * URL parser.
  10090. *
  10091. * @param {String} url
  10092. * @param {Object} An object meant to mimic window.location.
  10093. * Defaults to window.location.
  10094. * @api public
  10095. */
  10096. function url (uri, loc) {
  10097. var obj = uri;
  10098. // default to window.location
  10099. loc = loc || (typeof location !== 'undefined' && location);
  10100. if (null == uri) uri = loc.protocol + '//' + loc.host;
  10101. // relative path support
  10102. if ('string' === typeof uri) {
  10103. if ('/' === uri.charAt(0)) {
  10104. if ('/' === uri.charAt(1)) {
  10105. uri = loc.protocol + uri;
  10106. } else {
  10107. uri = loc.host + uri;
  10108. }
  10109. }
  10110. if (!/^(https?|wss?):\/\//.test(uri)) {
  10111. debug('protocol-less url %s', uri);
  10112. if ('undefined' !== typeof loc) {
  10113. uri = loc.protocol + '//' + uri;
  10114. } else {
  10115. uri = 'https://' + uri;
  10116. }
  10117. }
  10118. // parse
  10119. debug('parse %s', uri);
  10120. obj = parseuri(uri);
  10121. }
  10122. // make sure we treat `localhost:80` and `localhost` equally
  10123. if (!obj.port) {
  10124. if (/^(http|ws)$/.test(obj.protocol)) {
  10125. obj.port = '80';
  10126. } else if (/^(http|ws)s$/.test(obj.protocol)) {
  10127. obj.port = '443';
  10128. }
  10129. }
  10130. obj.path = obj.path || '/';
  10131. var ipv6 = obj.host.indexOf(':') !== -1;
  10132. var host = ipv6 ? '[' + obj.host + ']' : obj.host;
  10133. // define unique id
  10134. obj.id = obj.protocol + '://' + host + ':' + obj.port;
  10135. // define href
  10136. obj.href = obj.protocol + '://' + host + (loc && loc.port === obj.port ? '' : (':' + obj.port));
  10137. return obj;
  10138. }
  10139. /***/ }),
  10140. /* 110 */
  10141. /***/ (function(module, exports, __webpack_require__) {
  10142. /**
  10143. * This is the common logic for both the Node.js and web browser
  10144. * implementations of `debug()`.
  10145. *
  10146. * Expose `debug()` as the module.
  10147. */
  10148. exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
  10149. exports.coerce = coerce;
  10150. exports.disable = disable;
  10151. exports.enable = enable;
  10152. exports.enabled = enabled;
  10153. exports.humanize = __webpack_require__(47);
  10154. /**
  10155. * Active `debug` instances.
  10156. */
  10157. exports.instances = [];
  10158. /**
  10159. * The currently active debug mode names, and names to skip.
  10160. */
  10161. exports.names = [];
  10162. exports.skips = [];
  10163. /**
  10164. * Map of special "%n" handling functions, for the debug "format" argument.
  10165. *
  10166. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  10167. */
  10168. exports.formatters = {};
  10169. /**
  10170. * Select a color.
  10171. * @param {String} namespace
  10172. * @return {Number}
  10173. * @api private
  10174. */
  10175. function selectColor(namespace) {
  10176. var hash = 0, i;
  10177. for (i in namespace) {
  10178. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  10179. hash |= 0; // Convert to 32bit integer
  10180. }
  10181. return exports.colors[Math.abs(hash) % exports.colors.length];
  10182. }
  10183. /**
  10184. * Create a debugger with the given `namespace`.
  10185. *
  10186. * @param {String} namespace
  10187. * @return {Function}
  10188. * @api public
  10189. */
  10190. function createDebug(namespace) {
  10191. var prevTime;
  10192. function debug() {
  10193. // disabled?
  10194. if (!debug.enabled) return;
  10195. var self = debug;
  10196. // set `diff` timestamp
  10197. var curr = +new Date();
  10198. var ms = curr - (prevTime || curr);
  10199. self.diff = ms;
  10200. self.prev = prevTime;
  10201. self.curr = curr;
  10202. prevTime = curr;
  10203. // turn the `arguments` into a proper Array
  10204. var args = new Array(arguments.length);
  10205. for (var i = 0; i < args.length; i++) {
  10206. args[i] = arguments[i];
  10207. }
  10208. args[0] = exports.coerce(args[0]);
  10209. if ('string' !== typeof args[0]) {
  10210. // anything else let's inspect with %O
  10211. args.unshift('%O');
  10212. }
  10213. // apply any `formatters` transformations
  10214. var index = 0;
  10215. args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  10216. // if we encounter an escaped % then don't increase the array index
  10217. if (match === '%%') return match;
  10218. index++;
  10219. var formatter = exports.formatters[format];
  10220. if ('function' === typeof formatter) {
  10221. var val = args[index];
  10222. match = formatter.call(self, val);
  10223. // now we need to remove `args[index]` since it's inlined in the `format`
  10224. args.splice(index, 1);
  10225. index--;
  10226. }
  10227. return match;
  10228. });
  10229. // apply env-specific formatting (colors, etc.)
  10230. exports.formatArgs.call(self, args);
  10231. var logFn = debug.log || exports.log || console.log.bind(console);
  10232. logFn.apply(self, args);
  10233. }
  10234. debug.namespace = namespace;
  10235. debug.enabled = exports.enabled(namespace);
  10236. debug.useColors = exports.useColors();
  10237. debug.color = selectColor(namespace);
  10238. debug.destroy = destroy;
  10239. // env-specific initialization logic for debug instances
  10240. if ('function' === typeof exports.init) {
  10241. exports.init(debug);
  10242. }
  10243. exports.instances.push(debug);
  10244. return debug;
  10245. }
  10246. function destroy () {
  10247. var index = exports.instances.indexOf(this);
  10248. if (index !== -1) {
  10249. exports.instances.splice(index, 1);
  10250. return true;
  10251. } else {
  10252. return false;
  10253. }
  10254. }
  10255. /**
  10256. * Enables a debug mode by namespaces. This can include modes
  10257. * separated by a colon and wildcards.
  10258. *
  10259. * @param {String} namespaces
  10260. * @api public
  10261. */
  10262. function enable(namespaces) {
  10263. exports.save(namespaces);
  10264. exports.names = [];
  10265. exports.skips = [];
  10266. var i;
  10267. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  10268. var len = split.length;
  10269. for (i = 0; i < len; i++) {
  10270. if (!split[i]) continue; // ignore empty strings
  10271. namespaces = split[i].replace(/\*/g, '.*?');
  10272. if (namespaces[0] === '-') {
  10273. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  10274. } else {
  10275. exports.names.push(new RegExp('^' + namespaces + '$'));
  10276. }
  10277. }
  10278. for (i = 0; i < exports.instances.length; i++) {
  10279. var instance = exports.instances[i];
  10280. instance.enabled = exports.enabled(instance.namespace);
  10281. }
  10282. }
  10283. /**
  10284. * Disable debug output.
  10285. *
  10286. * @api public
  10287. */
  10288. function disable() {
  10289. exports.enable('');
  10290. }
  10291. /**
  10292. * Returns true if the given mode name is enabled, false otherwise.
  10293. *
  10294. * @param {String} name
  10295. * @return {Boolean}
  10296. * @api public
  10297. */
  10298. function enabled(name) {
  10299. if (name[name.length - 1] === '*') {
  10300. return true;
  10301. }
  10302. var i, len;
  10303. for (i = 0, len = exports.skips.length; i < len; i++) {
  10304. if (exports.skips[i].test(name)) {
  10305. return false;
  10306. }
  10307. }
  10308. for (i = 0, len = exports.names.length; i < len; i++) {
  10309. if (exports.names[i].test(name)) {
  10310. return true;
  10311. }
  10312. }
  10313. return false;
  10314. }
  10315. /**
  10316. * Coerce `val`.
  10317. *
  10318. * @param {Mixed} val
  10319. * @return {Mixed}
  10320. * @api private
  10321. */
  10322. function coerce(val) {
  10323. if (val instanceof Error) return val.stack || val.message;
  10324. return val;
  10325. }
  10326. /***/ }),
  10327. /* 111 */
  10328. /***/ (function(module, exports, __webpack_require__) {
  10329. /* WEBPACK VAR INJECTION */(function(process) {/**
  10330. * This is the web browser implementation of `debug()`.
  10331. *
  10332. * Expose `debug()` as the module.
  10333. */
  10334. exports = module.exports = __webpack_require__(112);
  10335. exports.log = log;
  10336. exports.formatArgs = formatArgs;
  10337. exports.save = save;
  10338. exports.load = load;
  10339. exports.useColors = useColors;
  10340. exports.storage = 'undefined' != typeof chrome
  10341. && 'undefined' != typeof chrome.storage
  10342. ? chrome.storage.local
  10343. : localstorage();
  10344. /**
  10345. * Colors.
  10346. */
  10347. exports.colors = [
  10348. '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
  10349. '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
  10350. '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
  10351. '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
  10352. '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
  10353. '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
  10354. '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
  10355. '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
  10356. '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
  10357. '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
  10358. '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
  10359. ];
  10360. /**
  10361. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  10362. * and the Firebug extension (any Firefox version) are known
  10363. * to support "%c" CSS customizations.
  10364. *
  10365. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  10366. */
  10367. function useColors() {
  10368. // NB: In an Electron preload script, document will be defined but not fully
  10369. // initialized. Since we know we're in Chrome, we'll just detect this case
  10370. // explicitly
  10371. if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
  10372. return true;
  10373. }
  10374. // Internet Explorer and Edge do not support colors.
  10375. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  10376. return false;
  10377. }
  10378. // is webkit? http://stackoverflow.com/a/16459606/376773
  10379. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  10380. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  10381. // is firebug? http://stackoverflow.com/a/398120/376773
  10382. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  10383. // is firefox >= v31?
  10384. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  10385. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  10386. // double check webkit in userAgent just in case we are in a worker
  10387. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  10388. }
  10389. /**
  10390. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  10391. */
  10392. exports.formatters.j = function(v) {
  10393. try {
  10394. return JSON.stringify(v);
  10395. } catch (err) {
  10396. return '[UnexpectedJSONParseError]: ' + err.message;
  10397. }
  10398. };
  10399. /**
  10400. * Colorize log arguments if enabled.
  10401. *
  10402. * @api public
  10403. */
  10404. function formatArgs(args) {
  10405. var useColors = this.useColors;
  10406. args[0] = (useColors ? '%c' : '')
  10407. + this.namespace
  10408. + (useColors ? ' %c' : ' ')
  10409. + args[0]
  10410. + (useColors ? '%c ' : ' ')
  10411. + '+' + exports.humanize(this.diff);
  10412. if (!useColors) return;
  10413. var c = 'color: ' + this.color;
  10414. args.splice(1, 0, c, 'color: inherit')
  10415. // the final "%c" is somewhat tricky, because there could be other
  10416. // arguments passed either before or after the %c, so we need to
  10417. // figure out the correct index to insert the CSS into
  10418. var index = 0;
  10419. var lastC = 0;
  10420. args[0].replace(/%[a-zA-Z%]/g, function(match) {
  10421. if ('%%' === match) return;
  10422. index++;
  10423. if ('%c' === match) {
  10424. // we only are interested in the *last* %c
  10425. // (the user may have provided their own)
  10426. lastC = index;
  10427. }
  10428. });
  10429. args.splice(lastC, 0, c);
  10430. }
  10431. /**
  10432. * Invokes `console.log()` when available.
  10433. * No-op when `console.log` is not a "function".
  10434. *
  10435. * @api public
  10436. */
  10437. function log() {
  10438. // this hackery is required for IE8/9, where
  10439. // the `console.log` function doesn't have 'apply'
  10440. return 'object' === typeof console
  10441. && console.log
  10442. && Function.prototype.apply.call(console.log, console, arguments);
  10443. }
  10444. /**
  10445. * Save `namespaces`.
  10446. *
  10447. * @param {String} namespaces
  10448. * @api private
  10449. */
  10450. function save(namespaces) {
  10451. try {
  10452. if (null == namespaces) {
  10453. exports.storage.removeItem('debug');
  10454. } else {
  10455. exports.storage.debug = namespaces;
  10456. }
  10457. } catch(e) {}
  10458. }
  10459. /**
  10460. * Load `namespaces`.
  10461. *
  10462. * @return {String} returns the previously persisted debug modes
  10463. * @api private
  10464. */
  10465. function load() {
  10466. var r;
  10467. try {
  10468. r = exports.storage.debug;
  10469. } catch(e) {}
  10470. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  10471. if (!r && typeof process !== 'undefined' && 'env' in process) {
  10472. r = process.env.DEBUG;
  10473. }
  10474. return r;
  10475. }
  10476. /**
  10477. * Enable namespaces listed in `localStorage.debug` initially.
  10478. */
  10479. exports.enable(load());
  10480. /**
  10481. * Localstorage attempts to return the localstorage.
  10482. *
  10483. * This is necessary because safari throws
  10484. * when a user disables cookies/localstorage
  10485. * and you attempt to access it.
  10486. *
  10487. * @return {LocalStorage}
  10488. * @api private
  10489. */
  10490. function localstorage() {
  10491. try {
  10492. return window.localStorage;
  10493. } catch (e) {}
  10494. }
  10495. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33)))
  10496. /***/ }),
  10497. /* 112 */
  10498. /***/ (function(module, exports, __webpack_require__) {
  10499. /**
  10500. * This is the common logic for both the Node.js and web browser
  10501. * implementations of `debug()`.
  10502. *
  10503. * Expose `debug()` as the module.
  10504. */
  10505. exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
  10506. exports.coerce = coerce;
  10507. exports.disable = disable;
  10508. exports.enable = enable;
  10509. exports.enabled = enabled;
  10510. exports.humanize = __webpack_require__(47);
  10511. /**
  10512. * Active `debug` instances.
  10513. */
  10514. exports.instances = [];
  10515. /**
  10516. * The currently active debug mode names, and names to skip.
  10517. */
  10518. exports.names = [];
  10519. exports.skips = [];
  10520. /**
  10521. * Map of special "%n" handling functions, for the debug "format" argument.
  10522. *
  10523. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  10524. */
  10525. exports.formatters = {};
  10526. /**
  10527. * Select a color.
  10528. * @param {String} namespace
  10529. * @return {Number}
  10530. * @api private
  10531. */
  10532. function selectColor(namespace) {
  10533. var hash = 0, i;
  10534. for (i in namespace) {
  10535. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  10536. hash |= 0; // Convert to 32bit integer
  10537. }
  10538. return exports.colors[Math.abs(hash) % exports.colors.length];
  10539. }
  10540. /**
  10541. * Create a debugger with the given `namespace`.
  10542. *
  10543. * @param {String} namespace
  10544. * @return {Function}
  10545. * @api public
  10546. */
  10547. function createDebug(namespace) {
  10548. var prevTime;
  10549. function debug() {
  10550. // disabled?
  10551. if (!debug.enabled) return;
  10552. var self = debug;
  10553. // set `diff` timestamp
  10554. var curr = +new Date();
  10555. var ms = curr - (prevTime || curr);
  10556. self.diff = ms;
  10557. self.prev = prevTime;
  10558. self.curr = curr;
  10559. prevTime = curr;
  10560. // turn the `arguments` into a proper Array
  10561. var args = new Array(arguments.length);
  10562. for (var i = 0; i < args.length; i++) {
  10563. args[i] = arguments[i];
  10564. }
  10565. args[0] = exports.coerce(args[0]);
  10566. if ('string' !== typeof args[0]) {
  10567. // anything else let's inspect with %O
  10568. args.unshift('%O');
  10569. }
  10570. // apply any `formatters` transformations
  10571. var index = 0;
  10572. args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  10573. // if we encounter an escaped % then don't increase the array index
  10574. if (match === '%%') return match;
  10575. index++;
  10576. var formatter = exports.formatters[format];
  10577. if ('function' === typeof formatter) {
  10578. var val = args[index];
  10579. match = formatter.call(self, val);
  10580. // now we need to remove `args[index]` since it's inlined in the `format`
  10581. args.splice(index, 1);
  10582. index--;
  10583. }
  10584. return match;
  10585. });
  10586. // apply env-specific formatting (colors, etc.)
  10587. exports.formatArgs.call(self, args);
  10588. var logFn = debug.log || exports.log || console.log.bind(console);
  10589. logFn.apply(self, args);
  10590. }
  10591. debug.namespace = namespace;
  10592. debug.enabled = exports.enabled(namespace);
  10593. debug.useColors = exports.useColors();
  10594. debug.color = selectColor(namespace);
  10595. debug.destroy = destroy;
  10596. // env-specific initialization logic for debug instances
  10597. if ('function' === typeof exports.init) {
  10598. exports.init(debug);
  10599. }
  10600. exports.instances.push(debug);
  10601. return debug;
  10602. }
  10603. function destroy () {
  10604. var index = exports.instances.indexOf(this);
  10605. if (index !== -1) {
  10606. exports.instances.splice(index, 1);
  10607. return true;
  10608. } else {
  10609. return false;
  10610. }
  10611. }
  10612. /**
  10613. * Enables a debug mode by namespaces. This can include modes
  10614. * separated by a colon and wildcards.
  10615. *
  10616. * @param {String} namespaces
  10617. * @api public
  10618. */
  10619. function enable(namespaces) {
  10620. exports.save(namespaces);
  10621. exports.names = [];
  10622. exports.skips = [];
  10623. var i;
  10624. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  10625. var len = split.length;
  10626. for (i = 0; i < len; i++) {
  10627. if (!split[i]) continue; // ignore empty strings
  10628. namespaces = split[i].replace(/\*/g, '.*?');
  10629. if (namespaces[0] === '-') {
  10630. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  10631. } else {
  10632. exports.names.push(new RegExp('^' + namespaces + '$'));
  10633. }
  10634. }
  10635. for (i = 0; i < exports.instances.length; i++) {
  10636. var instance = exports.instances[i];
  10637. instance.enabled = exports.enabled(instance.namespace);
  10638. }
  10639. }
  10640. /**
  10641. * Disable debug output.
  10642. *
  10643. * @api public
  10644. */
  10645. function disable() {
  10646. exports.enable('');
  10647. }
  10648. /**
  10649. * Returns true if the given mode name is enabled, false otherwise.
  10650. *
  10651. * @param {String} name
  10652. * @return {Boolean}
  10653. * @api public
  10654. */
  10655. function enabled(name) {
  10656. if (name[name.length - 1] === '*') {
  10657. return true;
  10658. }
  10659. var i, len;
  10660. for (i = 0, len = exports.skips.length; i < len; i++) {
  10661. if (exports.skips[i].test(name)) {
  10662. return false;
  10663. }
  10664. }
  10665. for (i = 0, len = exports.names.length; i < len; i++) {
  10666. if (exports.names[i].test(name)) {
  10667. return true;
  10668. }
  10669. }
  10670. return false;
  10671. }
  10672. /**
  10673. * Coerce `val`.
  10674. *
  10675. * @param {Mixed} val
  10676. * @return {Mixed}
  10677. * @api private
  10678. */
  10679. function coerce(val) {
  10680. if (val instanceof Error) return val.stack || val.message;
  10681. return val;
  10682. }
  10683. /***/ }),
  10684. /* 113 */
  10685. /***/ (function(module, exports, __webpack_require__) {
  10686. /*global Blob,File*/
  10687. /**
  10688. * Module requirements
  10689. */
  10690. var isArray = __webpack_require__(62);
  10691. var isBuf = __webpack_require__(63);
  10692. var toString = Object.prototype.toString;
  10693. var withNativeBlob = typeof Blob === 'function' || (typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]');
  10694. var withNativeFile = typeof File === 'function' || (typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]');
  10695. /**
  10696. * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
  10697. * Anything with blobs or files should be fed through removeBlobs before coming
  10698. * here.
  10699. *
  10700. * @param {Object} packet - socket.io event packet
  10701. * @return {Object} with deconstructed packet and list of buffers
  10702. * @api public
  10703. */
  10704. exports.deconstructPacket = function(packet) {
  10705. var buffers = [];
  10706. var packetData = packet.data;
  10707. var pack = packet;
  10708. pack.data = _deconstructPacket(packetData, buffers);
  10709. pack.attachments = buffers.length; // number of binary 'attachments'
  10710. return {packet: pack, buffers: buffers};
  10711. };
  10712. function _deconstructPacket(data, buffers) {
  10713. if (!data) return data;
  10714. if (isBuf(data)) {
  10715. var placeholder = { _placeholder: true, num: buffers.length };
  10716. buffers.push(data);
  10717. return placeholder;
  10718. } else if (isArray(data)) {
  10719. var newData = new Array(data.length);
  10720. for (var i = 0; i < data.length; i++) {
  10721. newData[i] = _deconstructPacket(data[i], buffers);
  10722. }
  10723. return newData;
  10724. } else if (typeof data === 'object' && !(data instanceof Date)) {
  10725. var newData = {};
  10726. for (var key in data) {
  10727. newData[key] = _deconstructPacket(data[key], buffers);
  10728. }
  10729. return newData;
  10730. }
  10731. return data;
  10732. }
  10733. /**
  10734. * Reconstructs a binary packet from its placeholder packet and buffers
  10735. *
  10736. * @param {Object} packet - event packet with placeholders
  10737. * @param {Array} buffers - binary buffers to put in placeholder positions
  10738. * @return {Object} reconstructed packet
  10739. * @api public
  10740. */
  10741. exports.reconstructPacket = function(packet, buffers) {
  10742. packet.data = _reconstructPacket(packet.data, buffers);
  10743. packet.attachments = undefined; // no longer useful
  10744. return packet;
  10745. };
  10746. function _reconstructPacket(data, buffers) {
  10747. if (!data) return data;
  10748. if (data && data._placeholder) {
  10749. return buffers[data.num]; // appropriate buffer (should be natural order anyway)
  10750. } else if (isArray(data)) {
  10751. for (var i = 0; i < data.length; i++) {
  10752. data[i] = _reconstructPacket(data[i], buffers);
  10753. }
  10754. } else if (typeof data === 'object') {
  10755. for (var key in data) {
  10756. data[key] = _reconstructPacket(data[key], buffers);
  10757. }
  10758. }
  10759. return data;
  10760. }
  10761. /**
  10762. * Asynchronously removes Blobs or Files from data via
  10763. * FileReader's readAsArrayBuffer method. Used before encoding
  10764. * data as msgpack. Calls callback with the blobless data.
  10765. *
  10766. * @param {Object} data
  10767. * @param {Function} callback
  10768. * @api private
  10769. */
  10770. exports.removeBlobs = function(data, callback) {
  10771. function _removeBlobs(obj, curKey, containingObject) {
  10772. if (!obj) return obj;
  10773. // convert any blob
  10774. if ((withNativeBlob && obj instanceof Blob) ||
  10775. (withNativeFile && obj instanceof File)) {
  10776. pendingBlobs++;
  10777. // async filereader
  10778. var fileReader = new FileReader();
  10779. fileReader.onload = function() { // this.result == arraybuffer
  10780. if (containingObject) {
  10781. containingObject[curKey] = this.result;
  10782. }
  10783. else {
  10784. bloblessData = this.result;
  10785. }
  10786. // if nothing pending its callback time
  10787. if(! --pendingBlobs) {
  10788. callback(bloblessData);
  10789. }
  10790. };
  10791. fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer
  10792. } else if (isArray(obj)) { // handle array
  10793. for (var i = 0; i < obj.length; i++) {
  10794. _removeBlobs(obj[i], i, obj);
  10795. }
  10796. } else if (typeof obj === 'object' && !isBuf(obj)) { // and object
  10797. for (var key in obj) {
  10798. _removeBlobs(obj[key], key, obj);
  10799. }
  10800. }
  10801. }
  10802. var pendingBlobs = 0;
  10803. var bloblessData = data;
  10804. _removeBlobs(bloblessData);
  10805. if (!pendingBlobs) {
  10806. callback(bloblessData);
  10807. }
  10808. };
  10809. /***/ }),
  10810. /* 114 */
  10811. /***/ (function(module, exports, __webpack_require__) {
  10812. "use strict";
  10813. exports.byteLength = byteLength
  10814. exports.toByteArray = toByteArray
  10815. exports.fromByteArray = fromByteArray
  10816. var lookup = []
  10817. var revLookup = []
  10818. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  10819. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  10820. for (var i = 0, len = code.length; i < len; ++i) {
  10821. lookup[i] = code[i]
  10822. revLookup[code.charCodeAt(i)] = i
  10823. }
  10824. // Support decoding URL-safe base64 strings, as Node.js does.
  10825. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  10826. revLookup['-'.charCodeAt(0)] = 62
  10827. revLookup['_'.charCodeAt(0)] = 63
  10828. function getLens (b64) {
  10829. var len = b64.length
  10830. if (len % 4 > 0) {
  10831. throw new Error('Invalid string. Length must be a multiple of 4')
  10832. }
  10833. // Trim off extra bytes after placeholder bytes are found
  10834. // See: https://github.com/beatgammit/base64-js/issues/42
  10835. var validLen = b64.indexOf('=')
  10836. if (validLen === -1) validLen = len
  10837. var placeHoldersLen = validLen === len
  10838. ? 0
  10839. : 4 - (validLen % 4)
  10840. return [validLen, placeHoldersLen]
  10841. }
  10842. // base64 is 4/3 + up to two characters of the original data
  10843. function byteLength (b64) {
  10844. var lens = getLens(b64)
  10845. var validLen = lens[0]
  10846. var placeHoldersLen = lens[1]
  10847. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  10848. }
  10849. function _byteLength (b64, validLen, placeHoldersLen) {
  10850. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  10851. }
  10852. function toByteArray (b64) {
  10853. var tmp
  10854. var lens = getLens(b64)
  10855. var validLen = lens[0]
  10856. var placeHoldersLen = lens[1]
  10857. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  10858. var curByte = 0
  10859. // if there are placeholders, only get up to the last complete 4 chars
  10860. var len = placeHoldersLen > 0
  10861. ? validLen - 4
  10862. : validLen
  10863. for (var i = 0; i < len; i += 4) {
  10864. tmp =
  10865. (revLookup[b64.charCodeAt(i)] << 18) |
  10866. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  10867. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  10868. revLookup[b64.charCodeAt(i + 3)]
  10869. arr[curByte++] = (tmp >> 16) & 0xFF
  10870. arr[curByte++] = (tmp >> 8) & 0xFF
  10871. arr[curByte++] = tmp & 0xFF
  10872. }
  10873. if (placeHoldersLen === 2) {
  10874. tmp =
  10875. (revLookup[b64.charCodeAt(i)] << 2) |
  10876. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  10877. arr[curByte++] = tmp & 0xFF
  10878. }
  10879. if (placeHoldersLen === 1) {
  10880. tmp =
  10881. (revLookup[b64.charCodeAt(i)] << 10) |
  10882. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  10883. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  10884. arr[curByte++] = (tmp >> 8) & 0xFF
  10885. arr[curByte++] = tmp & 0xFF
  10886. }
  10887. return arr
  10888. }
  10889. function tripletToBase64 (num) {
  10890. return lookup[num >> 18 & 0x3F] +
  10891. lookup[num >> 12 & 0x3F] +
  10892. lookup[num >> 6 & 0x3F] +
  10893. lookup[num & 0x3F]
  10894. }
  10895. function encodeChunk (uint8, start, end) {
  10896. var tmp
  10897. var output = []
  10898. for (var i = start; i < end; i += 3) {
  10899. tmp =
  10900. ((uint8[i] << 16) & 0xFF0000) +
  10901. ((uint8[i + 1] << 8) & 0xFF00) +
  10902. (uint8[i + 2] & 0xFF)
  10903. output.push(tripletToBase64(tmp))
  10904. }
  10905. return output.join('')
  10906. }
  10907. function fromByteArray (uint8) {
  10908. var tmp
  10909. var len = uint8.length
  10910. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  10911. var parts = []
  10912. var maxChunkLength = 16383 // must be multiple of 3
  10913. // go through the array every three bytes, we'll deal with trailing stuff later
  10914. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  10915. parts.push(encodeChunk(
  10916. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  10917. ))
  10918. }
  10919. // pad the end with zeros, but make sure to not forget the extra bytes
  10920. if (extraBytes === 1) {
  10921. tmp = uint8[len - 1]
  10922. parts.push(
  10923. lookup[tmp >> 2] +
  10924. lookup[(tmp << 4) & 0x3F] +
  10925. '=='
  10926. )
  10927. } else if (extraBytes === 2) {
  10928. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  10929. parts.push(
  10930. lookup[tmp >> 10] +
  10931. lookup[(tmp >> 4) & 0x3F] +
  10932. lookup[(tmp << 2) & 0x3F] +
  10933. '='
  10934. )
  10935. }
  10936. return parts.join('')
  10937. }
  10938. /***/ }),
  10939. /* 115 */
  10940. /***/ (function(module, exports) {
  10941. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  10942. var e, m
  10943. var eLen = (nBytes * 8) - mLen - 1
  10944. var eMax = (1 << eLen) - 1
  10945. var eBias = eMax >> 1
  10946. var nBits = -7
  10947. var i = isLE ? (nBytes - 1) : 0
  10948. var d = isLE ? -1 : 1
  10949. var s = buffer[offset + i]
  10950. i += d
  10951. e = s & ((1 << (-nBits)) - 1)
  10952. s >>= (-nBits)
  10953. nBits += eLen
  10954. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  10955. m = e & ((1 << (-nBits)) - 1)
  10956. e >>= (-nBits)
  10957. nBits += mLen
  10958. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  10959. if (e === 0) {
  10960. e = 1 - eBias
  10961. } else if (e === eMax) {
  10962. return m ? NaN : ((s ? -1 : 1) * Infinity)
  10963. } else {
  10964. m = m + Math.pow(2, mLen)
  10965. e = e - eBias
  10966. }
  10967. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  10968. }
  10969. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  10970. var e, m, c
  10971. var eLen = (nBytes * 8) - mLen - 1
  10972. var eMax = (1 << eLen) - 1
  10973. var eBias = eMax >> 1
  10974. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  10975. var i = isLE ? 0 : (nBytes - 1)
  10976. var d = isLE ? 1 : -1
  10977. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  10978. value = Math.abs(value)
  10979. if (isNaN(value) || value === Infinity) {
  10980. m = isNaN(value) ? 1 : 0
  10981. e = eMax
  10982. } else {
  10983. e = Math.floor(Math.log(value) / Math.LN2)
  10984. if (value * (c = Math.pow(2, -e)) < 1) {
  10985. e--
  10986. c *= 2
  10987. }
  10988. if (e + eBias >= 1) {
  10989. value += rt / c
  10990. } else {
  10991. value += rt * Math.pow(2, 1 - eBias)
  10992. }
  10993. if (value * c >= 2) {
  10994. e++
  10995. c /= 2
  10996. }
  10997. if (e + eBias >= eMax) {
  10998. m = 0
  10999. e = eMax
  11000. } else if (e + eBias >= 1) {
  11001. m = ((value * c) - 1) * Math.pow(2, mLen)
  11002. e = e + eBias
  11003. } else {
  11004. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  11005. e = 0
  11006. }
  11007. }
  11008. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  11009. e = (e << mLen) | m
  11010. eLen += mLen
  11011. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  11012. buffer[offset + i - d] |= s * 128
  11013. }
  11014. /***/ }),
  11015. /* 116 */
  11016. /***/ (function(module, exports) {
  11017. var toString = {}.toString;
  11018. module.exports = Array.isArray || function (arr) {
  11019. return toString.call(arr) == '[object Array]';
  11020. };
  11021. /***/ }),
  11022. /* 117 */
  11023. /***/ (function(module, exports, __webpack_require__) {
  11024. module.exports = __webpack_require__(118);
  11025. /**
  11026. * Exports parser
  11027. *
  11028. * @api public
  11029. *
  11030. */
  11031. module.exports.parser = __webpack_require__(18);
  11032. /***/ }),
  11033. /* 118 */
  11034. /***/ (function(module, exports, __webpack_require__) {
  11035. /**
  11036. * Module dependencies.
  11037. */
  11038. var transports = __webpack_require__(65);
  11039. var Emitter = __webpack_require__(17);
  11040. var debug = __webpack_require__(36)('engine.io-client:socket');
  11041. var index = __webpack_require__(69);
  11042. var parser = __webpack_require__(18);
  11043. var parseuri = __webpack_require__(61);
  11044. var parseqs = __webpack_require__(34);
  11045. /**
  11046. * Module exports.
  11047. */
  11048. module.exports = Socket;
  11049. /**
  11050. * Socket constructor.
  11051. *
  11052. * @param {String|Object} uri or options
  11053. * @param {Object} options
  11054. * @api public
  11055. */
  11056. function Socket (uri, opts) {
  11057. if (!(this instanceof Socket)) return new Socket(uri, opts);
  11058. opts = opts || {};
  11059. if (uri && 'object' === typeof uri) {
  11060. opts = uri;
  11061. uri = null;
  11062. }
  11063. if (uri) {
  11064. uri = parseuri(uri);
  11065. opts.hostname = uri.host;
  11066. opts.secure = uri.protocol === 'https' || uri.protocol === 'wss';
  11067. opts.port = uri.port;
  11068. if (uri.query) opts.query = uri.query;
  11069. } else if (opts.host) {
  11070. opts.hostname = parseuri(opts.host).host;
  11071. }
  11072. this.secure = null != opts.secure ? opts.secure
  11073. : (typeof location !== 'undefined' && 'https:' === location.protocol);
  11074. if (opts.hostname && !opts.port) {
  11075. // if no port is specified manually, use the protocol default
  11076. opts.port = this.secure ? '443' : '80';
  11077. }
  11078. this.agent = opts.agent || false;
  11079. this.hostname = opts.hostname ||
  11080. (typeof location !== 'undefined' ? location.hostname : 'localhost');
  11081. this.port = opts.port || (typeof location !== 'undefined' && location.port
  11082. ? location.port
  11083. : (this.secure ? 443 : 80));
  11084. this.query = opts.query || {};
  11085. if ('string' === typeof this.query) this.query = parseqs.decode(this.query);
  11086. this.upgrade = false !== opts.upgrade;
  11087. this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
  11088. this.forceJSONP = !!opts.forceJSONP;
  11089. this.jsonp = false !== opts.jsonp;
  11090. this.forceBase64 = !!opts.forceBase64;
  11091. this.enablesXDR = !!opts.enablesXDR;
  11092. this.timestampParam = opts.timestampParam || 't';
  11093. this.timestampRequests = opts.timestampRequests;
  11094. this.transports = opts.transports || ['polling', 'websocket'];
  11095. this.transportOptions = opts.transportOptions || {};
  11096. this.readyState = '';
  11097. this.writeBuffer = [];
  11098. this.prevBufferLen = 0;
  11099. this.policyPort = opts.policyPort || 843;
  11100. this.rememberUpgrade = opts.rememberUpgrade || false;
  11101. this.binaryType = null;
  11102. this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
  11103. this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;
  11104. if (true === this.perMessageDeflate) this.perMessageDeflate = {};
  11105. if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
  11106. this.perMessageDeflate.threshold = 1024;
  11107. }
  11108. // SSL options for Node.js client
  11109. this.pfx = opts.pfx || null;
  11110. this.key = opts.key || null;
  11111. this.passphrase = opts.passphrase || null;
  11112. this.cert = opts.cert || null;
  11113. this.ca = opts.ca || null;
  11114. this.ciphers = opts.ciphers || null;
  11115. this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized;
  11116. this.forceNode = !!opts.forceNode;
  11117. // detect ReactNative environment
  11118. this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative');
  11119. // other options for Node.js or ReactNative client
  11120. if (typeof self === 'undefined' || this.isReactNative) {
  11121. if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
  11122. this.extraHeaders = opts.extraHeaders;
  11123. }
  11124. if (opts.localAddress) {
  11125. this.localAddress = opts.localAddress;
  11126. }
  11127. }
  11128. // set on handshake
  11129. this.id = null;
  11130. this.upgrades = null;
  11131. this.pingInterval = null;
  11132. this.pingTimeout = null;
  11133. // set on heartbeat
  11134. this.pingIntervalTimer = null;
  11135. this.pingTimeoutTimer = null;
  11136. this.open();
  11137. }
  11138. Socket.priorWebsocketSuccess = false;
  11139. /**
  11140. * Mix in `Emitter`.
  11141. */
  11142. Emitter(Socket.prototype);
  11143. /**
  11144. * Protocol version.
  11145. *
  11146. * @api public
  11147. */
  11148. Socket.protocol = parser.protocol; // this is an int
  11149. /**
  11150. * Expose deps for legacy compatibility
  11151. * and standalone browser access.
  11152. */
  11153. Socket.Socket = Socket;
  11154. Socket.Transport = __webpack_require__(51);
  11155. Socket.transports = __webpack_require__(65);
  11156. Socket.parser = __webpack_require__(18);
  11157. /**
  11158. * Creates transport of the given type.
  11159. *
  11160. * @param {String} transport name
  11161. * @return {Transport}
  11162. * @api private
  11163. */
  11164. Socket.prototype.createTransport = function (name) {
  11165. debug('creating transport "%s"', name);
  11166. var query = clone(this.query);
  11167. // append engine.io protocol identifier
  11168. query.EIO = parser.protocol;
  11169. // transport name
  11170. query.transport = name;
  11171. // per-transport options
  11172. var options = this.transportOptions[name] || {};
  11173. // session id if we already have one
  11174. if (this.id) query.sid = this.id;
  11175. var transport = new transports[name]({
  11176. query: query,
  11177. socket: this,
  11178. agent: options.agent || this.agent,
  11179. hostname: options.hostname || this.hostname,
  11180. port: options.port || this.port,
  11181. secure: options.secure || this.secure,
  11182. path: options.path || this.path,
  11183. forceJSONP: options.forceJSONP || this.forceJSONP,
  11184. jsonp: options.jsonp || this.jsonp,
  11185. forceBase64: options.forceBase64 || this.forceBase64,
  11186. enablesXDR: options.enablesXDR || this.enablesXDR,
  11187. timestampRequests: options.timestampRequests || this.timestampRequests,
  11188. timestampParam: options.timestampParam || this.timestampParam,
  11189. policyPort: options.policyPort || this.policyPort,
  11190. pfx: options.pfx || this.pfx,
  11191. key: options.key || this.key,
  11192. passphrase: options.passphrase || this.passphrase,
  11193. cert: options.cert || this.cert,
  11194. ca: options.ca || this.ca,
  11195. ciphers: options.ciphers || this.ciphers,
  11196. rejectUnauthorized: options.rejectUnauthorized || this.rejectUnauthorized,
  11197. perMessageDeflate: options.perMessageDeflate || this.perMessageDeflate,
  11198. extraHeaders: options.extraHeaders || this.extraHeaders,
  11199. forceNode: options.forceNode || this.forceNode,
  11200. localAddress: options.localAddress || this.localAddress,
  11201. requestTimeout: options.requestTimeout || this.requestTimeout,
  11202. protocols: options.protocols || void (0),
  11203. isReactNative: this.isReactNative
  11204. });
  11205. return transport;
  11206. };
  11207. function clone (obj) {
  11208. var o = {};
  11209. for (var i in obj) {
  11210. if (obj.hasOwnProperty(i)) {
  11211. o[i] = obj[i];
  11212. }
  11213. }
  11214. return o;
  11215. }
  11216. /**
  11217. * Initializes transport to use and starts probe.
  11218. *
  11219. * @api private
  11220. */
  11221. Socket.prototype.open = function () {
  11222. var transport;
  11223. if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) {
  11224. transport = 'websocket';
  11225. } else if (0 === this.transports.length) {
  11226. // Emit error on next tick so it can be listened to
  11227. var self = this;
  11228. setTimeout(function () {
  11229. self.emit('error', 'No transports available');
  11230. }, 0);
  11231. return;
  11232. } else {
  11233. transport = this.transports[0];
  11234. }
  11235. this.readyState = 'opening';
  11236. // Retry with the next transport if the transport is disabled (jsonp: false)
  11237. try {
  11238. transport = this.createTransport(transport);
  11239. } catch (e) {
  11240. this.transports.shift();
  11241. this.open();
  11242. return;
  11243. }
  11244. transport.open();
  11245. this.setTransport(transport);
  11246. };
  11247. /**
  11248. * Sets the current transport. Disables the existing one (if any).
  11249. *
  11250. * @api private
  11251. */
  11252. Socket.prototype.setTransport = function (transport) {
  11253. debug('setting transport %s', transport.name);
  11254. var self = this;
  11255. if (this.transport) {
  11256. debug('clearing existing transport %s', this.transport.name);
  11257. this.transport.removeAllListeners();
  11258. }
  11259. // set up transport
  11260. this.transport = transport;
  11261. // set up transport listeners
  11262. transport
  11263. .on('drain', function () {
  11264. self.onDrain();
  11265. })
  11266. .on('packet', function (packet) {
  11267. self.onPacket(packet);
  11268. })
  11269. .on('error', function (e) {
  11270. self.onError(e);
  11271. })
  11272. .on('close', function () {
  11273. self.onClose('transport close');
  11274. });
  11275. };
  11276. /**
  11277. * Probes a transport.
  11278. *
  11279. * @param {String} transport name
  11280. * @api private
  11281. */
  11282. Socket.prototype.probe = function (name) {
  11283. debug('probing transport "%s"', name);
  11284. var transport = this.createTransport(name, { probe: 1 });
  11285. var failed = false;
  11286. var self = this;
  11287. Socket.priorWebsocketSuccess = false;
  11288. function onTransportOpen () {
  11289. if (self.onlyBinaryUpgrades) {
  11290. var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
  11291. failed = failed || upgradeLosesBinary;
  11292. }
  11293. if (failed) return;
  11294. debug('probe transport "%s" opened', name);
  11295. transport.send([{ type: 'ping', data: 'probe' }]);
  11296. transport.once('packet', function (msg) {
  11297. if (failed) return;
  11298. if ('pong' === msg.type && 'probe' === msg.data) {
  11299. debug('probe transport "%s" pong', name);
  11300. self.upgrading = true;
  11301. self.emit('upgrading', transport);
  11302. if (!transport) return;
  11303. Socket.priorWebsocketSuccess = 'websocket' === transport.name;
  11304. debug('pausing current transport "%s"', self.transport.name);
  11305. self.transport.pause(function () {
  11306. if (failed) return;
  11307. if ('closed' === self.readyState) return;
  11308. debug('changing transport and sending upgrade packet');
  11309. cleanup();
  11310. self.setTransport(transport);
  11311. transport.send([{ type: 'upgrade' }]);
  11312. self.emit('upgrade', transport);
  11313. transport = null;
  11314. self.upgrading = false;
  11315. self.flush();
  11316. });
  11317. } else {
  11318. debug('probe transport "%s" failed', name);
  11319. var err = new Error('probe error');
  11320. err.transport = transport.name;
  11321. self.emit('upgradeError', err);
  11322. }
  11323. });
  11324. }
  11325. function freezeTransport () {
  11326. if (failed) return;
  11327. // Any callback called by transport should be ignored since now
  11328. failed = true;
  11329. cleanup();
  11330. transport.close();
  11331. transport = null;
  11332. }
  11333. // Handle any error that happens while probing
  11334. function onerror (err) {
  11335. var error = new Error('probe error: ' + err);
  11336. error.transport = transport.name;
  11337. freezeTransport();
  11338. debug('probe transport "%s" failed because of error: %s', name, err);
  11339. self.emit('upgradeError', error);
  11340. }
  11341. function onTransportClose () {
  11342. onerror('transport closed');
  11343. }
  11344. // When the socket is closed while we're probing
  11345. function onclose () {
  11346. onerror('socket closed');
  11347. }
  11348. // When the socket is upgraded while we're probing
  11349. function onupgrade (to) {
  11350. if (transport && to.name !== transport.name) {
  11351. debug('"%s" works - aborting "%s"', to.name, transport.name);
  11352. freezeTransport();
  11353. }
  11354. }
  11355. // Remove all listeners on the transport and on self
  11356. function cleanup () {
  11357. transport.removeListener('open', onTransportOpen);
  11358. transport.removeListener('error', onerror);
  11359. transport.removeListener('close', onTransportClose);
  11360. self.removeListener('close', onclose);
  11361. self.removeListener('upgrading', onupgrade);
  11362. }
  11363. transport.once('open', onTransportOpen);
  11364. transport.once('error', onerror);
  11365. transport.once('close', onTransportClose);
  11366. this.once('close', onclose);
  11367. this.once('upgrading', onupgrade);
  11368. transport.open();
  11369. };
  11370. /**
  11371. * Called when connection is deemed open.
  11372. *
  11373. * @api public
  11374. */
  11375. Socket.prototype.onOpen = function () {
  11376. debug('socket open');
  11377. this.readyState = 'open';
  11378. Socket.priorWebsocketSuccess = 'websocket' === this.transport.name;
  11379. this.emit('open');
  11380. this.flush();
  11381. // we check for `readyState` in case an `open`
  11382. // listener already closed the socket
  11383. if ('open' === this.readyState && this.upgrade && this.transport.pause) {
  11384. debug('starting upgrade probes');
  11385. for (var i = 0, l = this.upgrades.length; i < l; i++) {
  11386. this.probe(this.upgrades[i]);
  11387. }
  11388. }
  11389. };
  11390. /**
  11391. * Handles a packet.
  11392. *
  11393. * @api private
  11394. */
  11395. Socket.prototype.onPacket = function (packet) {
  11396. if ('opening' === this.readyState || 'open' === this.readyState ||
  11397. 'closing' === this.readyState) {
  11398. debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
  11399. this.emit('packet', packet);
  11400. // Socket is live - any packet counts
  11401. this.emit('heartbeat');
  11402. switch (packet.type) {
  11403. case 'open':
  11404. this.onHandshake(JSON.parse(packet.data));
  11405. break;
  11406. case 'pong':
  11407. this.setPing();
  11408. this.emit('pong');
  11409. break;
  11410. case 'error':
  11411. var err = new Error('server error');
  11412. err.code = packet.data;
  11413. this.onError(err);
  11414. break;
  11415. case 'message':
  11416. this.emit('data', packet.data);
  11417. this.emit('message', packet.data);
  11418. break;
  11419. }
  11420. } else {
  11421. debug('packet received with socket readyState "%s"', this.readyState);
  11422. }
  11423. };
  11424. /**
  11425. * Called upon handshake completion.
  11426. *
  11427. * @param {Object} handshake obj
  11428. * @api private
  11429. */
  11430. Socket.prototype.onHandshake = function (data) {
  11431. this.emit('handshake', data);
  11432. this.id = data.sid;
  11433. this.transport.query.sid = data.sid;
  11434. this.upgrades = this.filterUpgrades(data.upgrades);
  11435. this.pingInterval = data.pingInterval;
  11436. this.pingTimeout = data.pingTimeout;
  11437. this.onOpen();
  11438. // In case open handler closes socket
  11439. if ('closed' === this.readyState) return;
  11440. this.setPing();
  11441. // Prolong liveness of socket on heartbeat
  11442. this.removeListener('heartbeat', this.onHeartbeat);
  11443. this.on('heartbeat', this.onHeartbeat);
  11444. };
  11445. /**
  11446. * Resets ping timeout.
  11447. *
  11448. * @api private
  11449. */
  11450. Socket.prototype.onHeartbeat = function (timeout) {
  11451. clearTimeout(this.pingTimeoutTimer);
  11452. var self = this;
  11453. self.pingTimeoutTimer = setTimeout(function () {
  11454. if ('closed' === self.readyState) return;
  11455. self.onClose('ping timeout');
  11456. }, timeout || (self.pingInterval + self.pingTimeout));
  11457. };
  11458. /**
  11459. * Pings server every `this.pingInterval` and expects response
  11460. * within `this.pingTimeout` or closes connection.
  11461. *
  11462. * @api private
  11463. */
  11464. Socket.prototype.setPing = function () {
  11465. var self = this;
  11466. clearTimeout(self.pingIntervalTimer);
  11467. self.pingIntervalTimer = setTimeout(function () {
  11468. debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
  11469. self.ping();
  11470. self.onHeartbeat(self.pingTimeout);
  11471. }, self.pingInterval);
  11472. };
  11473. /**
  11474. * Sends a ping packet.
  11475. *
  11476. * @api private
  11477. */
  11478. Socket.prototype.ping = function () {
  11479. var self = this;
  11480. this.sendPacket('ping', function () {
  11481. self.emit('ping');
  11482. });
  11483. };
  11484. /**
  11485. * Called on `drain` event
  11486. *
  11487. * @api private
  11488. */
  11489. Socket.prototype.onDrain = function () {
  11490. this.writeBuffer.splice(0, this.prevBufferLen);
  11491. // setting prevBufferLen = 0 is very important
  11492. // for example, when upgrading, upgrade packet is sent over,
  11493. // and a nonzero prevBufferLen could cause problems on `drain`
  11494. this.prevBufferLen = 0;
  11495. if (0 === this.writeBuffer.length) {
  11496. this.emit('drain');
  11497. } else {
  11498. this.flush();
  11499. }
  11500. };
  11501. /**
  11502. * Flush write buffers.
  11503. *
  11504. * @api private
  11505. */
  11506. Socket.prototype.flush = function () {
  11507. if ('closed' !== this.readyState && this.transport.writable &&
  11508. !this.upgrading && this.writeBuffer.length) {
  11509. debug('flushing %d packets in socket', this.writeBuffer.length);
  11510. this.transport.send(this.writeBuffer);
  11511. // keep track of current length of writeBuffer
  11512. // splice writeBuffer and callbackBuffer on `drain`
  11513. this.prevBufferLen = this.writeBuffer.length;
  11514. this.emit('flush');
  11515. }
  11516. };
  11517. /**
  11518. * Sends a message.
  11519. *
  11520. * @param {String} message.
  11521. * @param {Function} callback function.
  11522. * @param {Object} options.
  11523. * @return {Socket} for chaining.
  11524. * @api public
  11525. */
  11526. Socket.prototype.write =
  11527. Socket.prototype.send = function (msg, options, fn) {
  11528. this.sendPacket('message', msg, options, fn);
  11529. return this;
  11530. };
  11531. /**
  11532. * Sends a packet.
  11533. *
  11534. * @param {String} packet type.
  11535. * @param {String} data.
  11536. * @param {Object} options.
  11537. * @param {Function} callback function.
  11538. * @api private
  11539. */
  11540. Socket.prototype.sendPacket = function (type, data, options, fn) {
  11541. if ('function' === typeof data) {
  11542. fn = data;
  11543. data = undefined;
  11544. }
  11545. if ('function' === typeof options) {
  11546. fn = options;
  11547. options = null;
  11548. }
  11549. if ('closing' === this.readyState || 'closed' === this.readyState) {
  11550. return;
  11551. }
  11552. options = options || {};
  11553. options.compress = false !== options.compress;
  11554. var packet = {
  11555. type: type,
  11556. data: data,
  11557. options: options
  11558. };
  11559. this.emit('packetCreate', packet);
  11560. this.writeBuffer.push(packet);
  11561. if (fn) this.once('flush', fn);
  11562. this.flush();
  11563. };
  11564. /**
  11565. * Closes the connection.
  11566. *
  11567. * @api private
  11568. */
  11569. Socket.prototype.close = function () {
  11570. if ('opening' === this.readyState || 'open' === this.readyState) {
  11571. this.readyState = 'closing';
  11572. var self = this;
  11573. if (this.writeBuffer.length) {
  11574. this.once('drain', function () {
  11575. if (this.upgrading) {
  11576. waitForUpgrade();
  11577. } else {
  11578. close();
  11579. }
  11580. });
  11581. } else if (this.upgrading) {
  11582. waitForUpgrade();
  11583. } else {
  11584. close();
  11585. }
  11586. }
  11587. function close () {
  11588. self.onClose('forced close');
  11589. debug('socket closing - telling transport to close');
  11590. self.transport.close();
  11591. }
  11592. function cleanupAndClose () {
  11593. self.removeListener('upgrade', cleanupAndClose);
  11594. self.removeListener('upgradeError', cleanupAndClose);
  11595. close();
  11596. }
  11597. function waitForUpgrade () {
  11598. // wait for upgrade to finish since we can't send packets while pausing a transport
  11599. self.once('upgrade', cleanupAndClose);
  11600. self.once('upgradeError', cleanupAndClose);
  11601. }
  11602. return this;
  11603. };
  11604. /**
  11605. * Called upon transport error
  11606. *
  11607. * @api private
  11608. */
  11609. Socket.prototype.onError = function (err) {
  11610. debug('socket error %j', err);
  11611. Socket.priorWebsocketSuccess = false;
  11612. this.emit('error', err);
  11613. this.onClose('transport error', err);
  11614. };
  11615. /**
  11616. * Called upon transport close.
  11617. *
  11618. * @api private
  11619. */
  11620. Socket.prototype.onClose = function (reason, desc) {
  11621. if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
  11622. debug('socket close with reason: "%s"', reason);
  11623. var self = this;
  11624. // clear timers
  11625. clearTimeout(this.pingIntervalTimer);
  11626. clearTimeout(this.pingTimeoutTimer);
  11627. // stop event from firing again for transport
  11628. this.transport.removeAllListeners('close');
  11629. // ensure transport won't stay open
  11630. this.transport.close();
  11631. // ignore further transport communication
  11632. this.transport.removeAllListeners();
  11633. // set ready state
  11634. this.readyState = 'closed';
  11635. // clear session id
  11636. this.id = null;
  11637. // emit close event
  11638. this.emit('close', reason, desc);
  11639. // clean buffers after, so users can still
  11640. // grab the buffers on `close` event
  11641. self.writeBuffer = [];
  11642. self.prevBufferLen = 0;
  11643. }
  11644. };
  11645. /**
  11646. * Filters upgrades, returning only those matching client transports.
  11647. *
  11648. * @param {Array} server upgrades
  11649. * @api private
  11650. *
  11651. */
  11652. Socket.prototype.filterUpgrades = function (upgrades) {
  11653. var filteredUpgrades = [];
  11654. for (var i = 0, j = upgrades.length; i < j; i++) {
  11655. if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
  11656. }
  11657. return filteredUpgrades;
  11658. };
  11659. /***/ }),
  11660. /* 119 */
  11661. /***/ (function(module, exports) {
  11662. /**
  11663. * Module exports.
  11664. *
  11665. * Logic borrowed from Modernizr:
  11666. *
  11667. * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
  11668. */
  11669. try {
  11670. module.exports = typeof XMLHttpRequest !== 'undefined' &&
  11671. 'withCredentials' in new XMLHttpRequest();
  11672. } catch (err) {
  11673. // if XMLHttp support is disabled in IE then it will throw
  11674. // when trying to create
  11675. module.exports = false;
  11676. }
  11677. /***/ }),
  11678. /* 120 */
  11679. /***/ (function(module, exports, __webpack_require__) {
  11680. /* global attachEvent */
  11681. /**
  11682. * Module requirements.
  11683. */
  11684. var XMLHttpRequest = __webpack_require__(50);
  11685. var Polling = __webpack_require__(66);
  11686. var Emitter = __webpack_require__(17);
  11687. var inherit = __webpack_require__(35);
  11688. var debug = __webpack_require__(36)('engine.io-client:polling-xhr');
  11689. /**
  11690. * Module exports.
  11691. */
  11692. module.exports = XHR;
  11693. module.exports.Request = Request;
  11694. /**
  11695. * Empty function
  11696. */
  11697. function empty () {}
  11698. /**
  11699. * XHR Polling constructor.
  11700. *
  11701. * @param {Object} opts
  11702. * @api public
  11703. */
  11704. function XHR (opts) {
  11705. Polling.call(this, opts);
  11706. this.requestTimeout = opts.requestTimeout;
  11707. this.extraHeaders = opts.extraHeaders;
  11708. if (typeof location !== 'undefined') {
  11709. var isSSL = 'https:' === location.protocol;
  11710. var port = location.port;
  11711. // some user agents have empty `location.port`
  11712. if (!port) {
  11713. port = isSSL ? 443 : 80;
  11714. }
  11715. this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) ||
  11716. port !== opts.port;
  11717. this.xs = opts.secure !== isSSL;
  11718. }
  11719. }
  11720. /**
  11721. * Inherits from Polling.
  11722. */
  11723. inherit(XHR, Polling);
  11724. /**
  11725. * XHR supports binary
  11726. */
  11727. XHR.prototype.supportsBinary = true;
  11728. /**
  11729. * Creates a request.
  11730. *
  11731. * @param {String} method
  11732. * @api private
  11733. */
  11734. XHR.prototype.request = function (opts) {
  11735. opts = opts || {};
  11736. opts.uri = this.uri();
  11737. opts.xd = this.xd;
  11738. opts.xs = this.xs;
  11739. opts.agent = this.agent || false;
  11740. opts.supportsBinary = this.supportsBinary;
  11741. opts.enablesXDR = this.enablesXDR;
  11742. // SSL options for Node.js client
  11743. opts.pfx = this.pfx;
  11744. opts.key = this.key;
  11745. opts.passphrase = this.passphrase;
  11746. opts.cert = this.cert;
  11747. opts.ca = this.ca;
  11748. opts.ciphers = this.ciphers;
  11749. opts.rejectUnauthorized = this.rejectUnauthorized;
  11750. opts.requestTimeout = this.requestTimeout;
  11751. // other options for Node.js client
  11752. opts.extraHeaders = this.extraHeaders;
  11753. return new Request(opts);
  11754. };
  11755. /**
  11756. * Sends data.
  11757. *
  11758. * @param {String} data to send.
  11759. * @param {Function} called upon flush.
  11760. * @api private
  11761. */
  11762. XHR.prototype.doWrite = function (data, fn) {
  11763. var isBinary = typeof data !== 'string' && data !== undefined;
  11764. var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
  11765. var self = this;
  11766. req.on('success', fn);
  11767. req.on('error', function (err) {
  11768. self.onError('xhr post error', err);
  11769. });
  11770. this.sendXhr = req;
  11771. };
  11772. /**
  11773. * Starts a poll cycle.
  11774. *
  11775. * @api private
  11776. */
  11777. XHR.prototype.doPoll = function () {
  11778. debug('xhr poll');
  11779. var req = this.request();
  11780. var self = this;
  11781. req.on('data', function (data) {
  11782. self.onData(data);
  11783. });
  11784. req.on('error', function (err) {
  11785. self.onError('xhr poll error', err);
  11786. });
  11787. this.pollXhr = req;
  11788. };
  11789. /**
  11790. * Request constructor
  11791. *
  11792. * @param {Object} options
  11793. * @api public
  11794. */
  11795. function Request (opts) {
  11796. this.method = opts.method || 'GET';
  11797. this.uri = opts.uri;
  11798. this.xd = !!opts.xd;
  11799. this.xs = !!opts.xs;
  11800. this.async = false !== opts.async;
  11801. this.data = undefined !== opts.data ? opts.data : null;
  11802. this.agent = opts.agent;
  11803. this.isBinary = opts.isBinary;
  11804. this.supportsBinary = opts.supportsBinary;
  11805. this.enablesXDR = opts.enablesXDR;
  11806. this.requestTimeout = opts.requestTimeout;
  11807. // SSL options for Node.js client
  11808. this.pfx = opts.pfx;
  11809. this.key = opts.key;
  11810. this.passphrase = opts.passphrase;
  11811. this.cert = opts.cert;
  11812. this.ca = opts.ca;
  11813. this.ciphers = opts.ciphers;
  11814. this.rejectUnauthorized = opts.rejectUnauthorized;
  11815. // other options for Node.js client
  11816. this.extraHeaders = opts.extraHeaders;
  11817. this.create();
  11818. }
  11819. /**
  11820. * Mix in `Emitter`.
  11821. */
  11822. Emitter(Request.prototype);
  11823. /**
  11824. * Creates the XHR object and sends the request.
  11825. *
  11826. * @api private
  11827. */
  11828. Request.prototype.create = function () {
  11829. var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
  11830. // SSL options for Node.js client
  11831. opts.pfx = this.pfx;
  11832. opts.key = this.key;
  11833. opts.passphrase = this.passphrase;
  11834. opts.cert = this.cert;
  11835. opts.ca = this.ca;
  11836. opts.ciphers = this.ciphers;
  11837. opts.rejectUnauthorized = this.rejectUnauthorized;
  11838. var xhr = this.xhr = new XMLHttpRequest(opts);
  11839. var self = this;
  11840. try {
  11841. debug('xhr open %s: %s', this.method, this.uri);
  11842. xhr.open(this.method, this.uri, this.async);
  11843. try {
  11844. if (this.extraHeaders) {
  11845. xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
  11846. for (var i in this.extraHeaders) {
  11847. if (this.extraHeaders.hasOwnProperty(i)) {
  11848. xhr.setRequestHeader(i, this.extraHeaders[i]);
  11849. }
  11850. }
  11851. }
  11852. } catch (e) {}
  11853. if ('POST' === this.method) {
  11854. try {
  11855. if (this.isBinary) {
  11856. xhr.setRequestHeader('Content-type', 'application/octet-stream');
  11857. } else {
  11858. xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
  11859. }
  11860. } catch (e) {}
  11861. }
  11862. try {
  11863. xhr.setRequestHeader('Accept', '*/*');
  11864. } catch (e) {}
  11865. // ie6 check
  11866. if ('withCredentials' in xhr) {
  11867. xhr.withCredentials = true;
  11868. }
  11869. if (this.requestTimeout) {
  11870. xhr.timeout = this.requestTimeout;
  11871. }
  11872. if (this.hasXDR()) {
  11873. xhr.onload = function () {
  11874. self.onLoad();
  11875. };
  11876. xhr.onerror = function () {
  11877. self.onError(xhr.responseText);
  11878. };
  11879. } else {
  11880. xhr.onreadystatechange = function () {
  11881. if (xhr.readyState === 2) {
  11882. try {
  11883. var contentType = xhr.getResponseHeader('Content-Type');
  11884. if (self.supportsBinary && contentType === 'application/octet-stream') {
  11885. xhr.responseType = 'arraybuffer';
  11886. }
  11887. } catch (e) {}
  11888. }
  11889. if (4 !== xhr.readyState) return;
  11890. if (200 === xhr.status || 1223 === xhr.status) {
  11891. self.onLoad();
  11892. } else {
  11893. // make sure the `error` event handler that's user-set
  11894. // does not throw in the same tick and gets caught here
  11895. setTimeout(function () {
  11896. self.onError(xhr.status);
  11897. }, 0);
  11898. }
  11899. };
  11900. }
  11901. debug('xhr data %s', this.data);
  11902. xhr.send(this.data);
  11903. } catch (e) {
  11904. // Need to defer since .create() is called directly fhrom the constructor
  11905. // and thus the 'error' event can only be only bound *after* this exception
  11906. // occurs. Therefore, also, we cannot throw here at all.
  11907. setTimeout(function () {
  11908. self.onError(e);
  11909. }, 0);
  11910. return;
  11911. }
  11912. if (typeof document !== 'undefined') {
  11913. this.index = Request.requestsCount++;
  11914. Request.requests[this.index] = this;
  11915. }
  11916. };
  11917. /**
  11918. * Called upon successful response.
  11919. *
  11920. * @api private
  11921. */
  11922. Request.prototype.onSuccess = function () {
  11923. this.emit('success');
  11924. this.cleanup();
  11925. };
  11926. /**
  11927. * Called if we have data.
  11928. *
  11929. * @api private
  11930. */
  11931. Request.prototype.onData = function (data) {
  11932. this.emit('data', data);
  11933. this.onSuccess();
  11934. };
  11935. /**
  11936. * Called upon error.
  11937. *
  11938. * @api private
  11939. */
  11940. Request.prototype.onError = function (err) {
  11941. this.emit('error', err);
  11942. this.cleanup(true);
  11943. };
  11944. /**
  11945. * Cleans up house.
  11946. *
  11947. * @api private
  11948. */
  11949. Request.prototype.cleanup = function (fromError) {
  11950. if ('undefined' === typeof this.xhr || null === this.xhr) {
  11951. return;
  11952. }
  11953. // xmlhttprequest
  11954. if (this.hasXDR()) {
  11955. this.xhr.onload = this.xhr.onerror = empty;
  11956. } else {
  11957. this.xhr.onreadystatechange = empty;
  11958. }
  11959. if (fromError) {
  11960. try {
  11961. this.xhr.abort();
  11962. } catch (e) {}
  11963. }
  11964. if (typeof document !== 'undefined') {
  11965. delete Request.requests[this.index];
  11966. }
  11967. this.xhr = null;
  11968. };
  11969. /**
  11970. * Called upon load.
  11971. *
  11972. * @api private
  11973. */
  11974. Request.prototype.onLoad = function () {
  11975. var data;
  11976. try {
  11977. var contentType;
  11978. try {
  11979. contentType = this.xhr.getResponseHeader('Content-Type');
  11980. } catch (e) {}
  11981. if (contentType === 'application/octet-stream') {
  11982. data = this.xhr.response || this.xhr.responseText;
  11983. } else {
  11984. data = this.xhr.responseText;
  11985. }
  11986. } catch (e) {
  11987. this.onError(e);
  11988. }
  11989. if (null != data) {
  11990. this.onData(data);
  11991. }
  11992. };
  11993. /**
  11994. * Check if it has XDomainRequest.
  11995. *
  11996. * @api private
  11997. */
  11998. Request.prototype.hasXDR = function () {
  11999. return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR;
  12000. };
  12001. /**
  12002. * Aborts the request.
  12003. *
  12004. * @api public
  12005. */
  12006. Request.prototype.abort = function () {
  12007. this.cleanup();
  12008. };
  12009. /**
  12010. * Aborts pending requests when unloading the window. This is needed to prevent
  12011. * memory leaks (e.g. when using IE) and to ensure that no spurious error is
  12012. * emitted.
  12013. */
  12014. Request.requestsCount = 0;
  12015. Request.requests = {};
  12016. if (typeof document !== 'undefined') {
  12017. if (typeof attachEvent === 'function') {
  12018. attachEvent('onunload', unloadHandler);
  12019. } else if (typeof addEventListener === 'function') {
  12020. var terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
  12021. addEventListener(terminationEvent, unloadHandler, false);
  12022. }
  12023. }
  12024. function unloadHandler () {
  12025. for (var i in Request.requests) {
  12026. if (Request.requests.hasOwnProperty(i)) {
  12027. Request.requests[i].abort();
  12028. }
  12029. }
  12030. }
  12031. /***/ }),
  12032. /* 121 */
  12033. /***/ (function(module, exports) {
  12034. /**
  12035. * Gets the keys for an object.
  12036. *
  12037. * @return {Array} keys
  12038. * @api private
  12039. */
  12040. module.exports = Object.keys || function keys (obj){
  12041. var arr = [];
  12042. var has = Object.prototype.hasOwnProperty;
  12043. for (var i in obj) {
  12044. if (has.call(obj, i)) {
  12045. arr.push(i);
  12046. }
  12047. }
  12048. return arr;
  12049. };
  12050. /***/ }),
  12051. /* 122 */
  12052. /***/ (function(module, exports) {
  12053. var toString = {}.toString;
  12054. module.exports = Array.isArray || function (arr) {
  12055. return toString.call(arr) == '[object Array]';
  12056. };
  12057. /***/ }),
  12058. /* 123 */
  12059. /***/ (function(module, exports) {
  12060. /**
  12061. * An abstraction for slicing an arraybuffer even when
  12062. * ArrayBuffer.prototype.slice is not supported
  12063. *
  12064. * @api public
  12065. */
  12066. module.exports = function(arraybuffer, start, end) {
  12067. var bytes = arraybuffer.byteLength;
  12068. start = start || 0;
  12069. end = end || bytes;
  12070. if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
  12071. if (start < 0) { start += bytes; }
  12072. if (end < 0) { end += bytes; }
  12073. if (end > bytes) { end = bytes; }
  12074. if (start >= bytes || start >= end || bytes === 0) {
  12075. return new ArrayBuffer(0);
  12076. }
  12077. var abv = new Uint8Array(arraybuffer);
  12078. var result = new Uint8Array(end - start);
  12079. for (var i = start, ii = 0; i < end; i++, ii++) {
  12080. result[ii] = abv[i];
  12081. }
  12082. return result.buffer;
  12083. };
  12084. /***/ }),
  12085. /* 124 */
  12086. /***/ (function(module, exports) {
  12087. module.exports = after
  12088. function after(count, callback, err_cb) {
  12089. var bail = false
  12090. err_cb = err_cb || noop
  12091. proxy.count = count
  12092. return (count === 0) ? callback() : proxy
  12093. function proxy(err, result) {
  12094. if (proxy.count <= 0) {
  12095. throw new Error('after called too many times')
  12096. }
  12097. --proxy.count
  12098. // after first error, rest are passed to err_cb
  12099. if (err) {
  12100. bail = true
  12101. callback(err)
  12102. // future error callbacks will go to error handler
  12103. callback = err_cb
  12104. } else if (proxy.count === 0 && !bail) {
  12105. callback(null, result)
  12106. }
  12107. }
  12108. }
  12109. function noop() {}
  12110. /***/ }),
  12111. /* 125 */
  12112. /***/ (function(module, exports) {
  12113. /*! https://mths.be/utf8js v2.1.2 by @mathias */
  12114. var stringFromCharCode = String.fromCharCode;
  12115. // Taken from https://mths.be/punycode
  12116. function ucs2decode(string) {
  12117. var output = [];
  12118. var counter = 0;
  12119. var length = string.length;
  12120. var value;
  12121. var extra;
  12122. while (counter < length) {
  12123. value = string.charCodeAt(counter++);
  12124. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  12125. // high surrogate, and there is a next character
  12126. extra = string.charCodeAt(counter++);
  12127. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  12128. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  12129. } else {
  12130. // unmatched surrogate; only append this code unit, in case the next
  12131. // code unit is the high surrogate of a surrogate pair
  12132. output.push(value);
  12133. counter--;
  12134. }
  12135. } else {
  12136. output.push(value);
  12137. }
  12138. }
  12139. return output;
  12140. }
  12141. // Taken from https://mths.be/punycode
  12142. function ucs2encode(array) {
  12143. var length = array.length;
  12144. var index = -1;
  12145. var value;
  12146. var output = '';
  12147. while (++index < length) {
  12148. value = array[index];
  12149. if (value > 0xFFFF) {
  12150. value -= 0x10000;
  12151. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  12152. value = 0xDC00 | value & 0x3FF;
  12153. }
  12154. output += stringFromCharCode(value);
  12155. }
  12156. return output;
  12157. }
  12158. function checkScalarValue(codePoint, strict) {
  12159. if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
  12160. if (strict) {
  12161. throw Error(
  12162. 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
  12163. ' is not a scalar value'
  12164. );
  12165. }
  12166. return false;
  12167. }
  12168. return true;
  12169. }
  12170. /*--------------------------------------------------------------------------*/
  12171. function createByte(codePoint, shift) {
  12172. return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
  12173. }
  12174. function encodeCodePoint(codePoint, strict) {
  12175. if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
  12176. return stringFromCharCode(codePoint);
  12177. }
  12178. var symbol = '';
  12179. if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
  12180. symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
  12181. }
  12182. else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
  12183. if (!checkScalarValue(codePoint, strict)) {
  12184. codePoint = 0xFFFD;
  12185. }
  12186. symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
  12187. symbol += createByte(codePoint, 6);
  12188. }
  12189. else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
  12190. symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
  12191. symbol += createByte(codePoint, 12);
  12192. symbol += createByte(codePoint, 6);
  12193. }
  12194. symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
  12195. return symbol;
  12196. }
  12197. function utf8encode(string, opts) {
  12198. opts = opts || {};
  12199. var strict = false !== opts.strict;
  12200. var codePoints = ucs2decode(string);
  12201. var length = codePoints.length;
  12202. var index = -1;
  12203. var codePoint;
  12204. var byteString = '';
  12205. while (++index < length) {
  12206. codePoint = codePoints[index];
  12207. byteString += encodeCodePoint(codePoint, strict);
  12208. }
  12209. return byteString;
  12210. }
  12211. /*--------------------------------------------------------------------------*/
  12212. function readContinuationByte() {
  12213. if (byteIndex >= byteCount) {
  12214. throw Error('Invalid byte index');
  12215. }
  12216. var continuationByte = byteArray[byteIndex] & 0xFF;
  12217. byteIndex++;
  12218. if ((continuationByte & 0xC0) == 0x80) {
  12219. return continuationByte & 0x3F;
  12220. }
  12221. // If we end up here, it’s not a continuation byte
  12222. throw Error('Invalid continuation byte');
  12223. }
  12224. function decodeSymbol(strict) {
  12225. var byte1;
  12226. var byte2;
  12227. var byte3;
  12228. var byte4;
  12229. var codePoint;
  12230. if (byteIndex > byteCount) {
  12231. throw Error('Invalid byte index');
  12232. }
  12233. if (byteIndex == byteCount) {
  12234. return false;
  12235. }
  12236. // Read first byte
  12237. byte1 = byteArray[byteIndex] & 0xFF;
  12238. byteIndex++;
  12239. // 1-byte sequence (no continuation bytes)
  12240. if ((byte1 & 0x80) == 0) {
  12241. return byte1;
  12242. }
  12243. // 2-byte sequence
  12244. if ((byte1 & 0xE0) == 0xC0) {
  12245. byte2 = readContinuationByte();
  12246. codePoint = ((byte1 & 0x1F) << 6) | byte2;
  12247. if (codePoint >= 0x80) {
  12248. return codePoint;
  12249. } else {
  12250. throw Error('Invalid continuation byte');
  12251. }
  12252. }
  12253. // 3-byte sequence (may include unpaired surrogates)
  12254. if ((byte1 & 0xF0) == 0xE0) {
  12255. byte2 = readContinuationByte();
  12256. byte3 = readContinuationByte();
  12257. codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
  12258. if (codePoint >= 0x0800) {
  12259. return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD;
  12260. } else {
  12261. throw Error('Invalid continuation byte');
  12262. }
  12263. }
  12264. // 4-byte sequence
  12265. if ((byte1 & 0xF8) == 0xF0) {
  12266. byte2 = readContinuationByte();
  12267. byte3 = readContinuationByte();
  12268. byte4 = readContinuationByte();
  12269. codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
  12270. (byte3 << 0x06) | byte4;
  12271. if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
  12272. return codePoint;
  12273. }
  12274. }
  12275. throw Error('Invalid UTF-8 detected');
  12276. }
  12277. var byteArray;
  12278. var byteCount;
  12279. var byteIndex;
  12280. function utf8decode(byteString, opts) {
  12281. opts = opts || {};
  12282. var strict = false !== opts.strict;
  12283. byteArray = ucs2decode(byteString);
  12284. byteCount = byteArray.length;
  12285. byteIndex = 0;
  12286. var codePoints = [];
  12287. var tmp;
  12288. while ((tmp = decodeSymbol(strict)) !== false) {
  12289. codePoints.push(tmp);
  12290. }
  12291. return ucs2encode(codePoints);
  12292. }
  12293. module.exports = {
  12294. version: '2.1.2',
  12295. encode: utf8encode,
  12296. decode: utf8decode
  12297. };
  12298. /***/ }),
  12299. /* 126 */
  12300. /***/ (function(module, exports) {
  12301. /*
  12302. * base64-arraybuffer
  12303. * https://github.com/niklasvh/base64-arraybuffer
  12304. *
  12305. * Copyright (c) 2012 Niklas von Hertzen
  12306. * Licensed under the MIT license.
  12307. */
  12308. (function(){
  12309. "use strict";
  12310. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  12311. // Use a lookup table to find the index.
  12312. var lookup = new Uint8Array(256);
  12313. for (var i = 0; i < chars.length; i++) {
  12314. lookup[chars.charCodeAt(i)] = i;
  12315. }
  12316. exports.encode = function(arraybuffer) {
  12317. var bytes = new Uint8Array(arraybuffer),
  12318. i, len = bytes.length, base64 = "";
  12319. for (i = 0; i < len; i+=3) {
  12320. base64 += chars[bytes[i] >> 2];
  12321. base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
  12322. base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
  12323. base64 += chars[bytes[i + 2] & 63];
  12324. }
  12325. if ((len % 3) === 2) {
  12326. base64 = base64.substring(0, base64.length - 1) + "=";
  12327. } else if (len % 3 === 1) {
  12328. base64 = base64.substring(0, base64.length - 2) + "==";
  12329. }
  12330. return base64;
  12331. };
  12332. exports.decode = function(base64) {
  12333. var bufferLength = base64.length * 0.75,
  12334. len = base64.length, i, p = 0,
  12335. encoded1, encoded2, encoded3, encoded4;
  12336. if (base64[base64.length - 1] === "=") {
  12337. bufferLength--;
  12338. if (base64[base64.length - 2] === "=") {
  12339. bufferLength--;
  12340. }
  12341. }
  12342. var arraybuffer = new ArrayBuffer(bufferLength),
  12343. bytes = new Uint8Array(arraybuffer);
  12344. for (i = 0; i < len; i+=4) {
  12345. encoded1 = lookup[base64.charCodeAt(i)];
  12346. encoded2 = lookup[base64.charCodeAt(i+1)];
  12347. encoded3 = lookup[base64.charCodeAt(i+2)];
  12348. encoded4 = lookup[base64.charCodeAt(i+3)];
  12349. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  12350. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  12351. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  12352. }
  12353. return arraybuffer;
  12354. };
  12355. })();
  12356. /***/ }),
  12357. /* 127 */
  12358. /***/ (function(module, exports) {
  12359. /**
  12360. * Create a blob builder even when vendor prefixes exist
  12361. */
  12362. var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
  12363. typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :
  12364. typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
  12365. typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder :
  12366. false;
  12367. /**
  12368. * Check if Blob constructor is supported
  12369. */
  12370. var blobSupported = (function() {
  12371. try {
  12372. var a = new Blob(['hi']);
  12373. return a.size === 2;
  12374. } catch(e) {
  12375. return false;
  12376. }
  12377. })();
  12378. /**
  12379. * Check if Blob constructor supports ArrayBufferViews
  12380. * Fails in Safari 6, so we need to map to ArrayBuffers there.
  12381. */
  12382. var blobSupportsArrayBufferView = blobSupported && (function() {
  12383. try {
  12384. var b = new Blob([new Uint8Array([1,2])]);
  12385. return b.size === 2;
  12386. } catch(e) {
  12387. return false;
  12388. }
  12389. })();
  12390. /**
  12391. * Check if BlobBuilder is supported
  12392. */
  12393. var blobBuilderSupported = BlobBuilder
  12394. && BlobBuilder.prototype.append
  12395. && BlobBuilder.prototype.getBlob;
  12396. /**
  12397. * Helper function that maps ArrayBufferViews to ArrayBuffers
  12398. * Used by BlobBuilder constructor and old browsers that didn't
  12399. * support it in the Blob constructor.
  12400. */
  12401. function mapArrayBufferViews(ary) {
  12402. return ary.map(function(chunk) {
  12403. if (chunk.buffer instanceof ArrayBuffer) {
  12404. var buf = chunk.buffer;
  12405. // if this is a subarray, make a copy so we only
  12406. // include the subarray region from the underlying buffer
  12407. if (chunk.byteLength !== buf.byteLength) {
  12408. var copy = new Uint8Array(chunk.byteLength);
  12409. copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
  12410. buf = copy.buffer;
  12411. }
  12412. return buf;
  12413. }
  12414. return chunk;
  12415. });
  12416. }
  12417. function BlobBuilderConstructor(ary, options) {
  12418. options = options || {};
  12419. var bb = new BlobBuilder();
  12420. mapArrayBufferViews(ary).forEach(function(part) {
  12421. bb.append(part);
  12422. });
  12423. return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
  12424. };
  12425. function BlobConstructor(ary, options) {
  12426. return new Blob(mapArrayBufferViews(ary), options || {});
  12427. };
  12428. if (typeof Blob !== 'undefined') {
  12429. BlobBuilderConstructor.prototype = Blob.prototype;
  12430. BlobConstructor.prototype = Blob.prototype;
  12431. }
  12432. module.exports = (function() {
  12433. if (blobSupported) {
  12434. return blobSupportsArrayBufferView ? Blob : BlobConstructor;
  12435. } else if (blobBuilderSupported) {
  12436. return BlobBuilderConstructor;
  12437. } else {
  12438. return undefined;
  12439. }
  12440. })();
  12441. /***/ }),
  12442. /* 128 */
  12443. /***/ (function(module, exports, __webpack_require__) {
  12444. /**
  12445. * This is the common logic for both the Node.js and web browser
  12446. * implementations of `debug()`.
  12447. *
  12448. * Expose `debug()` as the module.
  12449. */
  12450. exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
  12451. exports.coerce = coerce;
  12452. exports.disable = disable;
  12453. exports.enable = enable;
  12454. exports.enabled = enabled;
  12455. exports.humanize = __webpack_require__(47);
  12456. /**
  12457. * Active `debug` instances.
  12458. */
  12459. exports.instances = [];
  12460. /**
  12461. * The currently active debug mode names, and names to skip.
  12462. */
  12463. exports.names = [];
  12464. exports.skips = [];
  12465. /**
  12466. * Map of special "%n" handling functions, for the debug "format" argument.
  12467. *
  12468. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  12469. */
  12470. exports.formatters = {};
  12471. /**
  12472. * Select a color.
  12473. * @param {String} namespace
  12474. * @return {Number}
  12475. * @api private
  12476. */
  12477. function selectColor(namespace) {
  12478. var hash = 0, i;
  12479. for (i in namespace) {
  12480. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  12481. hash |= 0; // Convert to 32bit integer
  12482. }
  12483. return exports.colors[Math.abs(hash) % exports.colors.length];
  12484. }
  12485. /**
  12486. * Create a debugger with the given `namespace`.
  12487. *
  12488. * @param {String} namespace
  12489. * @return {Function}
  12490. * @api public
  12491. */
  12492. function createDebug(namespace) {
  12493. var prevTime;
  12494. function debug() {
  12495. // disabled?
  12496. if (!debug.enabled) return;
  12497. var self = debug;
  12498. // set `diff` timestamp
  12499. var curr = +new Date();
  12500. var ms = curr - (prevTime || curr);
  12501. self.diff = ms;
  12502. self.prev = prevTime;
  12503. self.curr = curr;
  12504. prevTime = curr;
  12505. // turn the `arguments` into a proper Array
  12506. var args = new Array(arguments.length);
  12507. for (var i = 0; i < args.length; i++) {
  12508. args[i] = arguments[i];
  12509. }
  12510. args[0] = exports.coerce(args[0]);
  12511. if ('string' !== typeof args[0]) {
  12512. // anything else let's inspect with %O
  12513. args.unshift('%O');
  12514. }
  12515. // apply any `formatters` transformations
  12516. var index = 0;
  12517. args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  12518. // if we encounter an escaped % then don't increase the array index
  12519. if (match === '%%') return match;
  12520. index++;
  12521. var formatter = exports.formatters[format];
  12522. if ('function' === typeof formatter) {
  12523. var val = args[index];
  12524. match = formatter.call(self, val);
  12525. // now we need to remove `args[index]` since it's inlined in the `format`
  12526. args.splice(index, 1);
  12527. index--;
  12528. }
  12529. return match;
  12530. });
  12531. // apply env-specific formatting (colors, etc.)
  12532. exports.formatArgs.call(self, args);
  12533. var logFn = debug.log || exports.log || console.log.bind(console);
  12534. logFn.apply(self, args);
  12535. }
  12536. debug.namespace = namespace;
  12537. debug.enabled = exports.enabled(namespace);
  12538. debug.useColors = exports.useColors();
  12539. debug.color = selectColor(namespace);
  12540. debug.destroy = destroy;
  12541. // env-specific initialization logic for debug instances
  12542. if ('function' === typeof exports.init) {
  12543. exports.init(debug);
  12544. }
  12545. exports.instances.push(debug);
  12546. return debug;
  12547. }
  12548. function destroy () {
  12549. var index = exports.instances.indexOf(this);
  12550. if (index !== -1) {
  12551. exports.instances.splice(index, 1);
  12552. return true;
  12553. } else {
  12554. return false;
  12555. }
  12556. }
  12557. /**
  12558. * Enables a debug mode by namespaces. This can include modes
  12559. * separated by a colon and wildcards.
  12560. *
  12561. * @param {String} namespaces
  12562. * @api public
  12563. */
  12564. function enable(namespaces) {
  12565. exports.save(namespaces);
  12566. exports.names = [];
  12567. exports.skips = [];
  12568. var i;
  12569. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  12570. var len = split.length;
  12571. for (i = 0; i < len; i++) {
  12572. if (!split[i]) continue; // ignore empty strings
  12573. namespaces = split[i].replace(/\*/g, '.*?');
  12574. if (namespaces[0] === '-') {
  12575. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  12576. } else {
  12577. exports.names.push(new RegExp('^' + namespaces + '$'));
  12578. }
  12579. }
  12580. for (i = 0; i < exports.instances.length; i++) {
  12581. var instance = exports.instances[i];
  12582. instance.enabled = exports.enabled(instance.namespace);
  12583. }
  12584. }
  12585. /**
  12586. * Disable debug output.
  12587. *
  12588. * @api public
  12589. */
  12590. function disable() {
  12591. exports.enable('');
  12592. }
  12593. /**
  12594. * Returns true if the given mode name is enabled, false otherwise.
  12595. *
  12596. * @param {String} name
  12597. * @return {Boolean}
  12598. * @api public
  12599. */
  12600. function enabled(name) {
  12601. if (name[name.length - 1] === '*') {
  12602. return true;
  12603. }
  12604. var i, len;
  12605. for (i = 0, len = exports.skips.length; i < len; i++) {
  12606. if (exports.skips[i].test(name)) {
  12607. return false;
  12608. }
  12609. }
  12610. for (i = 0, len = exports.names.length; i < len; i++) {
  12611. if (exports.names[i].test(name)) {
  12612. return true;
  12613. }
  12614. }
  12615. return false;
  12616. }
  12617. /**
  12618. * Coerce `val`.
  12619. *
  12620. * @param {Mixed} val
  12621. * @return {Mixed}
  12622. * @api private
  12623. */
  12624. function coerce(val) {
  12625. if (val instanceof Error) return val.stack || val.message;
  12626. return val;
  12627. }
  12628. /***/ }),
  12629. /* 129 */
  12630. /***/ (function(module, exports, __webpack_require__) {
  12631. /* WEBPACK VAR INJECTION */(function(global) {/**
  12632. * Module requirements.
  12633. */
  12634. var Polling = __webpack_require__(66);
  12635. var inherit = __webpack_require__(35);
  12636. /**
  12637. * Module exports.
  12638. */
  12639. module.exports = JSONPPolling;
  12640. /**
  12641. * Cached regular expressions.
  12642. */
  12643. var rNewline = /\n/g;
  12644. var rEscapedNewline = /\\n/g;
  12645. /**
  12646. * Global JSONP callbacks.
  12647. */
  12648. var callbacks;
  12649. /**
  12650. * Noop.
  12651. */
  12652. function empty () { }
  12653. /**
  12654. * Until https://github.com/tc39/proposal-global is shipped.
  12655. */
  12656. function glob () {
  12657. return typeof self !== 'undefined' ? self
  12658. : typeof window !== 'undefined' ? window
  12659. : typeof global !== 'undefined' ? global : {};
  12660. }
  12661. /**
  12662. * JSONP Polling constructor.
  12663. *
  12664. * @param {Object} opts.
  12665. * @api public
  12666. */
  12667. function JSONPPolling (opts) {
  12668. Polling.call(this, opts);
  12669. this.query = this.query || {};
  12670. // define global callbacks array if not present
  12671. // we do this here (lazily) to avoid unneeded global pollution
  12672. if (!callbacks) {
  12673. // we need to consider multiple engines in the same page
  12674. var global = glob();
  12675. callbacks = global.___eio = (global.___eio || []);
  12676. }
  12677. // callback identifier
  12678. this.index = callbacks.length;
  12679. // add callback to jsonp global
  12680. var self = this;
  12681. callbacks.push(function (msg) {
  12682. self.onData(msg);
  12683. });
  12684. // append to query string
  12685. this.query.j = this.index;
  12686. // prevent spurious errors from being emitted when the window is unloaded
  12687. if (typeof addEventListener === 'function') {
  12688. addEventListener('beforeunload', function () {
  12689. if (self.script) self.script.onerror = empty;
  12690. }, false);
  12691. }
  12692. }
  12693. /**
  12694. * Inherits from Polling.
  12695. */
  12696. inherit(JSONPPolling, Polling);
  12697. /*
  12698. * JSONP only supports binary as base64 encoded strings
  12699. */
  12700. JSONPPolling.prototype.supportsBinary = false;
  12701. /**
  12702. * Closes the socket.
  12703. *
  12704. * @api private
  12705. */
  12706. JSONPPolling.prototype.doClose = function () {
  12707. if (this.script) {
  12708. this.script.parentNode.removeChild(this.script);
  12709. this.script = null;
  12710. }
  12711. if (this.form) {
  12712. this.form.parentNode.removeChild(this.form);
  12713. this.form = null;
  12714. this.iframe = null;
  12715. }
  12716. Polling.prototype.doClose.call(this);
  12717. };
  12718. /**
  12719. * Starts a poll cycle.
  12720. *
  12721. * @api private
  12722. */
  12723. JSONPPolling.prototype.doPoll = function () {
  12724. var self = this;
  12725. var script = document.createElement('script');
  12726. if (this.script) {
  12727. this.script.parentNode.removeChild(this.script);
  12728. this.script = null;
  12729. }
  12730. script.async = true;
  12731. script.src = this.uri();
  12732. script.onerror = function (e) {
  12733. self.onError('jsonp poll error', e);
  12734. };
  12735. var insertAt = document.getElementsByTagName('script')[0];
  12736. if (insertAt) {
  12737. insertAt.parentNode.insertBefore(script, insertAt);
  12738. } else {
  12739. (document.head || document.body).appendChild(script);
  12740. }
  12741. this.script = script;
  12742. var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent);
  12743. if (isUAgecko) {
  12744. setTimeout(function () {
  12745. var iframe = document.createElement('iframe');
  12746. document.body.appendChild(iframe);
  12747. document.body.removeChild(iframe);
  12748. }, 100);
  12749. }
  12750. };
  12751. /**
  12752. * Writes with a hidden iframe.
  12753. *
  12754. * @param {String} data to send
  12755. * @param {Function} called upon flush.
  12756. * @api private
  12757. */
  12758. JSONPPolling.prototype.doWrite = function (data, fn) {
  12759. var self = this;
  12760. if (!this.form) {
  12761. var form = document.createElement('form');
  12762. var area = document.createElement('textarea');
  12763. var id = this.iframeId = 'eio_iframe_' + this.index;
  12764. var iframe;
  12765. form.className = 'socketio';
  12766. form.style.position = 'absolute';
  12767. form.style.top = '-1000px';
  12768. form.style.left = '-1000px';
  12769. form.target = id;
  12770. form.method = 'POST';
  12771. form.setAttribute('accept-charset', 'utf-8');
  12772. area.name = 'd';
  12773. form.appendChild(area);
  12774. document.body.appendChild(form);
  12775. this.form = form;
  12776. this.area = area;
  12777. }
  12778. this.form.action = this.uri();
  12779. function complete () {
  12780. initIframe();
  12781. fn();
  12782. }
  12783. function initIframe () {
  12784. if (self.iframe) {
  12785. try {
  12786. self.form.removeChild(self.iframe);
  12787. } catch (e) {
  12788. self.onError('jsonp polling iframe removal error', e);
  12789. }
  12790. }
  12791. try {
  12792. // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
  12793. var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
  12794. iframe = document.createElement(html);
  12795. } catch (e) {
  12796. iframe = document.createElement('iframe');
  12797. iframe.name = self.iframeId;
  12798. iframe.src = 'javascript:0';
  12799. }
  12800. iframe.id = self.iframeId;
  12801. self.form.appendChild(iframe);
  12802. self.iframe = iframe;
  12803. }
  12804. initIframe();
  12805. // escape \n to prevent it from being converted into \r\n by some UAs
  12806. // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
  12807. data = data.replace(rEscapedNewline, '\\\n');
  12808. this.area.value = data.replace(rNewline, '\\n');
  12809. try {
  12810. this.form.submit();
  12811. } catch (e) {}
  12812. if (this.iframe.attachEvent) {
  12813. this.iframe.onreadystatechange = function () {
  12814. if (self.iframe.readyState === 'complete') {
  12815. complete();
  12816. }
  12817. };
  12818. } else {
  12819. this.iframe.onload = complete;
  12820. }
  12821. };
  12822. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24)))
  12823. /***/ }),
  12824. /* 130 */
  12825. /***/ (function(module, exports, __webpack_require__) {
  12826. /* WEBPACK VAR INJECTION */(function(Buffer) {/**
  12827. * Module dependencies.
  12828. */
  12829. var Transport = __webpack_require__(51);
  12830. var parser = __webpack_require__(18);
  12831. var parseqs = __webpack_require__(34);
  12832. var inherit = __webpack_require__(35);
  12833. var yeast = __webpack_require__(68);
  12834. var debug = __webpack_require__(36)('engine.io-client:websocket');
  12835. var BrowserWebSocket, NodeWebSocket;
  12836. if (typeof WebSocket !== 'undefined') {
  12837. BrowserWebSocket = WebSocket;
  12838. } else if (typeof self !== 'undefined') {
  12839. BrowserWebSocket = self.WebSocket || self.MozWebSocket;
  12840. } else {
  12841. try {
  12842. NodeWebSocket = __webpack_require__(131);
  12843. } catch (e) { }
  12844. }
  12845. /**
  12846. * Get either the `WebSocket` or `MozWebSocket` globals
  12847. * in the browser or try to resolve WebSocket-compatible
  12848. * interface exposed by `ws` for Node-like environment.
  12849. */
  12850. var WebSocketImpl = BrowserWebSocket || NodeWebSocket;
  12851. /**
  12852. * Module exports.
  12853. */
  12854. module.exports = WS;
  12855. /**
  12856. * WebSocket transport constructor.
  12857. *
  12858. * @api {Object} connection options
  12859. * @api public
  12860. */
  12861. function WS (opts) {
  12862. var forceBase64 = (opts && opts.forceBase64);
  12863. if (forceBase64) {
  12864. this.supportsBinary = false;
  12865. }
  12866. this.perMessageDeflate = opts.perMessageDeflate;
  12867. this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode;
  12868. this.protocols = opts.protocols;
  12869. if (!this.usingBrowserWebSocket) {
  12870. WebSocketImpl = NodeWebSocket;
  12871. }
  12872. Transport.call(this, opts);
  12873. }
  12874. /**
  12875. * Inherits from Transport.
  12876. */
  12877. inherit(WS, Transport);
  12878. /**
  12879. * Transport name.
  12880. *
  12881. * @api public
  12882. */
  12883. WS.prototype.name = 'websocket';
  12884. /*
  12885. * WebSockets support binary
  12886. */
  12887. WS.prototype.supportsBinary = true;
  12888. /**
  12889. * Opens socket.
  12890. *
  12891. * @api private
  12892. */
  12893. WS.prototype.doOpen = function () {
  12894. if (!this.check()) {
  12895. // let probe timeout
  12896. return;
  12897. }
  12898. var uri = this.uri();
  12899. var protocols = this.protocols;
  12900. var opts = {
  12901. agent: this.agent,
  12902. perMessageDeflate: this.perMessageDeflate
  12903. };
  12904. // SSL options for Node.js client
  12905. opts.pfx = this.pfx;
  12906. opts.key = this.key;
  12907. opts.passphrase = this.passphrase;
  12908. opts.cert = this.cert;
  12909. opts.ca = this.ca;
  12910. opts.ciphers = this.ciphers;
  12911. opts.rejectUnauthorized = this.rejectUnauthorized;
  12912. if (this.extraHeaders) {
  12913. opts.headers = this.extraHeaders;
  12914. }
  12915. if (this.localAddress) {
  12916. opts.localAddress = this.localAddress;
  12917. }
  12918. try {
  12919. this.ws =
  12920. this.usingBrowserWebSocket && !this.isReactNative
  12921. ? protocols
  12922. ? new WebSocketImpl(uri, protocols)
  12923. : new WebSocketImpl(uri)
  12924. : new WebSocketImpl(uri, protocols, opts);
  12925. } catch (err) {
  12926. return this.emit('error', err);
  12927. }
  12928. if (this.ws.binaryType === undefined) {
  12929. this.supportsBinary = false;
  12930. }
  12931. if (this.ws.supports && this.ws.supports.binary) {
  12932. this.supportsBinary = true;
  12933. this.ws.binaryType = 'nodebuffer';
  12934. } else {
  12935. this.ws.binaryType = 'arraybuffer';
  12936. }
  12937. this.addEventListeners();
  12938. };
  12939. /**
  12940. * Adds event listeners to the socket
  12941. *
  12942. * @api private
  12943. */
  12944. WS.prototype.addEventListeners = function () {
  12945. var self = this;
  12946. this.ws.onopen = function () {
  12947. self.onOpen();
  12948. };
  12949. this.ws.onclose = function () {
  12950. self.onClose();
  12951. };
  12952. this.ws.onmessage = function (ev) {
  12953. self.onData(ev.data);
  12954. };
  12955. this.ws.onerror = function (e) {
  12956. self.onError('websocket error', e);
  12957. };
  12958. };
  12959. /**
  12960. * Writes data to socket.
  12961. *
  12962. * @param {Array} array of packets.
  12963. * @api private
  12964. */
  12965. WS.prototype.write = function (packets) {
  12966. var self = this;
  12967. this.writable = false;
  12968. // encodePacket efficient as it uses WS framing
  12969. // no need for encodePayload
  12970. var total = packets.length;
  12971. for (var i = 0, l = total; i < l; i++) {
  12972. (function (packet) {
  12973. parser.encodePacket(packet, self.supportsBinary, function (data) {
  12974. if (!self.usingBrowserWebSocket) {
  12975. // always create a new object (GH-437)
  12976. var opts = {};
  12977. if (packet.options) {
  12978. opts.compress = packet.options.compress;
  12979. }
  12980. if (self.perMessageDeflate) {
  12981. var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length;
  12982. if (len < self.perMessageDeflate.threshold) {
  12983. opts.compress = false;
  12984. }
  12985. }
  12986. }
  12987. // Sometimes the websocket has already been closed but the browser didn't
  12988. // have a chance of informing us about it yet, in that case send will
  12989. // throw an error
  12990. try {
  12991. if (self.usingBrowserWebSocket) {
  12992. // TypeError is thrown when passing the second argument on Safari
  12993. self.ws.send(data);
  12994. } else {
  12995. self.ws.send(data, opts);
  12996. }
  12997. } catch (e) {
  12998. debug('websocket closed before onclose event');
  12999. }
  13000. --total || done();
  13001. });
  13002. })(packets[i]);
  13003. }
  13004. function done () {
  13005. self.emit('flush');
  13006. // fake drain
  13007. // defer to next tick to allow Socket to clear writeBuffer
  13008. setTimeout(function () {
  13009. self.writable = true;
  13010. self.emit('drain');
  13011. }, 0);
  13012. }
  13013. };
  13014. /**
  13015. * Called upon close
  13016. *
  13017. * @api private
  13018. */
  13019. WS.prototype.onClose = function () {
  13020. Transport.prototype.onClose.call(this);
  13021. };
  13022. /**
  13023. * Closes socket.
  13024. *
  13025. * @api private
  13026. */
  13027. WS.prototype.doClose = function () {
  13028. if (typeof this.ws !== 'undefined') {
  13029. this.ws.close();
  13030. }
  13031. };
  13032. /**
  13033. * Generates uri for connection.
  13034. *
  13035. * @api private
  13036. */
  13037. WS.prototype.uri = function () {
  13038. var query = this.query || {};
  13039. var schema = this.secure ? 'wss' : 'ws';
  13040. var port = '';
  13041. // avoid port if default for schema
  13042. if (this.port && (('wss' === schema && Number(this.port) !== 443) ||
  13043. ('ws' === schema && Number(this.port) !== 80))) {
  13044. port = ':' + this.port;
  13045. }
  13046. // append timestamp to URI
  13047. if (this.timestampRequests) {
  13048. query[this.timestampParam] = yeast();
  13049. }
  13050. // communicate binary support capabilities
  13051. if (!this.supportsBinary) {
  13052. query.b64 = 1;
  13053. }
  13054. query = parseqs.encode(query);
  13055. // prepend ? to query
  13056. if (query.length) {
  13057. query = '?' + query;
  13058. }
  13059. var ipv6 = this.hostname.indexOf(':') !== -1;
  13060. return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
  13061. };
  13062. /**
  13063. * Feature detection for WebSocket.
  13064. *
  13065. * @return {Boolean} whether this transport is available.
  13066. * @api public
  13067. */
  13068. WS.prototype.check = function () {
  13069. return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name);
  13070. };
  13071. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(49).Buffer))
  13072. /***/ }),
  13073. /* 131 */
  13074. /***/ (function(module, exports) {
  13075. /* (ignored) */
  13076. /***/ }),
  13077. /* 132 */
  13078. /***/ (function(module, exports) {
  13079. module.exports = toArray
  13080. function toArray(list, index) {
  13081. var array = []
  13082. index = index || 0
  13083. for (var i = index || 0; i < list.length; i++) {
  13084. array[i - index] = list[i]
  13085. }
  13086. return array
  13087. }
  13088. /***/ }),
  13089. /* 133 */
  13090. /***/ (function(module, exports) {
  13091. /**
  13092. * Expose `Backoff`.
  13093. */
  13094. module.exports = Backoff;
  13095. /**
  13096. * Initialize backoff timer with `opts`.
  13097. *
  13098. * - `min` initial timeout in milliseconds [100]
  13099. * - `max` max timeout [10000]
  13100. * - `jitter` [0]
  13101. * - `factor` [2]
  13102. *
  13103. * @param {Object} opts
  13104. * @api public
  13105. */
  13106. function Backoff(opts) {
  13107. opts = opts || {};
  13108. this.ms = opts.min || 100;
  13109. this.max = opts.max || 10000;
  13110. this.factor = opts.factor || 2;
  13111. this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  13112. this.attempts = 0;
  13113. }
  13114. /**
  13115. * Return the backoff duration.
  13116. *
  13117. * @return {Number}
  13118. * @api public
  13119. */
  13120. Backoff.prototype.duration = function(){
  13121. var ms = this.ms * Math.pow(this.factor, this.attempts++);
  13122. if (this.jitter) {
  13123. var rand = Math.random();
  13124. var deviation = Math.floor(rand * this.jitter * ms);
  13125. ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
  13126. }
  13127. return Math.min(ms, this.max) | 0;
  13128. };
  13129. /**
  13130. * Reset the number of attempts.
  13131. *
  13132. * @api public
  13133. */
  13134. Backoff.prototype.reset = function(){
  13135. this.attempts = 0;
  13136. };
  13137. /**
  13138. * Set the minimum duration
  13139. *
  13140. * @api public
  13141. */
  13142. Backoff.prototype.setMin = function(min){
  13143. this.ms = min;
  13144. };
  13145. /**
  13146. * Set the maximum duration
  13147. *
  13148. * @api public
  13149. */
  13150. Backoff.prototype.setMax = function(max){
  13151. this.max = max;
  13152. };
  13153. /**
  13154. * Set the jitter
  13155. *
  13156. * @api public
  13157. */
  13158. Backoff.prototype.setJitter = function(jitter){
  13159. this.jitter = jitter;
  13160. };
  13161. /***/ }),
  13162. /* 134 */
  13163. /***/ (function(module, exports, __webpack_require__) {
  13164. "use strict";
  13165. var __extends = (this && this.__extends) || function (d, b) {
  13166. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13167. function __() { this.constructor = d; }
  13168. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13169. };
  13170. var Subscription_1 = __webpack_require__(12);
  13171. /**
  13172. * We need this JSDoc comment for affecting ESDoc.
  13173. * @ignore
  13174. * @extends {Ignored}
  13175. */
  13176. var SubjectSubscription = (function (_super) {
  13177. __extends(SubjectSubscription, _super);
  13178. function SubjectSubscription(subject, subscriber) {
  13179. _super.call(this);
  13180. this.subject = subject;
  13181. this.subscriber = subscriber;
  13182. this.closed = false;
  13183. }
  13184. SubjectSubscription.prototype.unsubscribe = function () {
  13185. if (this.closed) {
  13186. return;
  13187. }
  13188. this.closed = true;
  13189. var subject = this.subject;
  13190. var observers = subject.observers;
  13191. this.subject = null;
  13192. if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
  13193. return;
  13194. }
  13195. var subscriberIndex = observers.indexOf(this.subscriber);
  13196. if (subscriberIndex !== -1) {
  13197. observers.splice(subscriberIndex, 1);
  13198. }
  13199. };
  13200. return SubjectSubscription;
  13201. }(Subscription_1.Subscription));
  13202. exports.SubjectSubscription = SubjectSubscription;
  13203. //# sourceMappingURL=SubjectSubscription.js.map
  13204. /***/ }),
  13205. /* 135 */
  13206. /***/ (function(module, exports, __webpack_require__) {
  13207. "use strict";
  13208. var ConnectableObservable_1 = __webpack_require__(136);
  13209. /* tslint:enable:max-line-length */
  13210. /**
  13211. * Returns an Observable that emits the results of invoking a specified selector on items
  13212. * emitted by a ConnectableObservable that shares a single subscription to the underlying stream.
  13213. *
  13214. * <img src="./img/multicast.png" width="100%">
  13215. *
  13216. * @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through
  13217. * which the source sequence's elements will be multicast to the selector function
  13218. * or Subject to push source elements into.
  13219. * @param {Function} [selector] - Optional selector function that can use the multicasted source stream
  13220. * as many times as needed, without causing multiple subscriptions to the source stream.
  13221. * Subscribers to the given source will receive all notifications of the source from the
  13222. * time of the subscription forward.
  13223. * @return {Observable} An Observable that emits the results of invoking the selector
  13224. * on the items emitted by a `ConnectableObservable` that shares a single subscription to
  13225. * the underlying stream.
  13226. * @method multicast
  13227. * @owner Observable
  13228. */
  13229. function multicast(subjectOrSubjectFactory, selector) {
  13230. return function multicastOperatorFunction(source) {
  13231. var subjectFactory;
  13232. if (typeof subjectOrSubjectFactory === 'function') {
  13233. subjectFactory = subjectOrSubjectFactory;
  13234. }
  13235. else {
  13236. subjectFactory = function subjectFactory() {
  13237. return subjectOrSubjectFactory;
  13238. };
  13239. }
  13240. if (typeof selector === 'function') {
  13241. return source.lift(new MulticastOperator(subjectFactory, selector));
  13242. }
  13243. var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
  13244. connectable.source = source;
  13245. connectable.subjectFactory = subjectFactory;
  13246. return connectable;
  13247. };
  13248. }
  13249. exports.multicast = multicast;
  13250. var MulticastOperator = (function () {
  13251. function MulticastOperator(subjectFactory, selector) {
  13252. this.subjectFactory = subjectFactory;
  13253. this.selector = selector;
  13254. }
  13255. MulticastOperator.prototype.call = function (subscriber, source) {
  13256. var selector = this.selector;
  13257. var subject = this.subjectFactory();
  13258. var subscription = selector(subject).subscribe(subscriber);
  13259. subscription.add(source.subscribe(subject));
  13260. return subscription;
  13261. };
  13262. return MulticastOperator;
  13263. }());
  13264. exports.MulticastOperator = MulticastOperator;
  13265. //# sourceMappingURL=multicast.js.map
  13266. /***/ }),
  13267. /* 136 */
  13268. /***/ (function(module, exports, __webpack_require__) {
  13269. "use strict";
  13270. var __extends = (this && this.__extends) || function (d, b) {
  13271. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13272. function __() { this.constructor = d; }
  13273. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13274. };
  13275. var Subject_1 = __webpack_require__(37);
  13276. var Observable_1 = __webpack_require__(1);
  13277. var Subscriber_1 = __webpack_require__(3);
  13278. var Subscription_1 = __webpack_require__(12);
  13279. var refCount_1 = __webpack_require__(75);
  13280. /**
  13281. * @class ConnectableObservable<T>
  13282. */
  13283. var ConnectableObservable = (function (_super) {
  13284. __extends(ConnectableObservable, _super);
  13285. function ConnectableObservable(/** @deprecated internal use only */ source,
  13286. /** @deprecated internal use only */ subjectFactory) {
  13287. _super.call(this);
  13288. this.source = source;
  13289. this.subjectFactory = subjectFactory;
  13290. /** @deprecated internal use only */ this._refCount = 0;
  13291. this._isComplete = false;
  13292. }
  13293. /** @deprecated internal use only */ ConnectableObservable.prototype._subscribe = function (subscriber) {
  13294. return this.getSubject().subscribe(subscriber);
  13295. };
  13296. /** @deprecated internal use only */ ConnectableObservable.prototype.getSubject = function () {
  13297. var subject = this._subject;
  13298. if (!subject || subject.isStopped) {
  13299. this._subject = this.subjectFactory();
  13300. }
  13301. return this._subject;
  13302. };
  13303. ConnectableObservable.prototype.connect = function () {
  13304. var connection = this._connection;
  13305. if (!connection) {
  13306. this._isComplete = false;
  13307. connection = this._connection = new Subscription_1.Subscription();
  13308. connection.add(this.source
  13309. .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
  13310. if (connection.closed) {
  13311. this._connection = null;
  13312. connection = Subscription_1.Subscription.EMPTY;
  13313. }
  13314. else {
  13315. this._connection = connection;
  13316. }
  13317. }
  13318. return connection;
  13319. };
  13320. ConnectableObservable.prototype.refCount = function () {
  13321. return refCount_1.refCount()(this);
  13322. };
  13323. return ConnectableObservable;
  13324. }(Observable_1.Observable));
  13325. exports.ConnectableObservable = ConnectableObservable;
  13326. var connectableProto = ConnectableObservable.prototype;
  13327. exports.connectableObservableDescriptor = {
  13328. operator: { value: null },
  13329. _refCount: { value: 0, writable: true },
  13330. _subject: { value: null, writable: true },
  13331. _connection: { value: null, writable: true },
  13332. _subscribe: { value: connectableProto._subscribe },
  13333. _isComplete: { value: connectableProto._isComplete, writable: true },
  13334. getSubject: { value: connectableProto.getSubject },
  13335. connect: { value: connectableProto.connect },
  13336. refCount: { value: connectableProto.refCount }
  13337. };
  13338. var ConnectableSubscriber = (function (_super) {
  13339. __extends(ConnectableSubscriber, _super);
  13340. function ConnectableSubscriber(destination, connectable) {
  13341. _super.call(this, destination);
  13342. this.connectable = connectable;
  13343. }
  13344. ConnectableSubscriber.prototype._error = function (err) {
  13345. this._unsubscribe();
  13346. _super.prototype._error.call(this, err);
  13347. };
  13348. ConnectableSubscriber.prototype._complete = function () {
  13349. this.connectable._isComplete = true;
  13350. this._unsubscribe();
  13351. _super.prototype._complete.call(this);
  13352. };
  13353. /** @deprecated internal use only */ ConnectableSubscriber.prototype._unsubscribe = function () {
  13354. var connectable = this.connectable;
  13355. if (connectable) {
  13356. this.connectable = null;
  13357. var connection = connectable._connection;
  13358. connectable._refCount = 0;
  13359. connectable._subject = null;
  13360. connectable._connection = null;
  13361. if (connection) {
  13362. connection.unsubscribe();
  13363. }
  13364. }
  13365. };
  13366. return ConnectableSubscriber;
  13367. }(Subject_1.SubjectSubscriber));
  13368. var RefCountOperator = (function () {
  13369. function RefCountOperator(connectable) {
  13370. this.connectable = connectable;
  13371. }
  13372. RefCountOperator.prototype.call = function (subscriber, source) {
  13373. var connectable = this.connectable;
  13374. connectable._refCount++;
  13375. var refCounter = new RefCountSubscriber(subscriber, connectable);
  13376. var subscription = source.subscribe(refCounter);
  13377. if (!refCounter.closed) {
  13378. refCounter.connection = connectable.connect();
  13379. }
  13380. return subscription;
  13381. };
  13382. return RefCountOperator;
  13383. }());
  13384. var RefCountSubscriber = (function (_super) {
  13385. __extends(RefCountSubscriber, _super);
  13386. function RefCountSubscriber(destination, connectable) {
  13387. _super.call(this, destination);
  13388. this.connectable = connectable;
  13389. }
  13390. /** @deprecated internal use only */ RefCountSubscriber.prototype._unsubscribe = function () {
  13391. var connectable = this.connectable;
  13392. if (!connectable) {
  13393. this.connection = null;
  13394. return;
  13395. }
  13396. this.connectable = null;
  13397. var refCount = connectable._refCount;
  13398. if (refCount <= 0) {
  13399. this.connection = null;
  13400. return;
  13401. }
  13402. connectable._refCount = refCount - 1;
  13403. if (refCount > 1) {
  13404. this.connection = null;
  13405. return;
  13406. }
  13407. ///
  13408. // Compare the local RefCountSubscriber's connection Subscription to the
  13409. // connection Subscription on the shared ConnectableObservable. In cases
  13410. // where the ConnectableObservable source synchronously emits values, and
  13411. // the RefCountSubscriber's downstream Observers synchronously unsubscribe,
  13412. // execution continues to here before the RefCountOperator has a chance to
  13413. // supply the RefCountSubscriber with the shared connection Subscription.
  13414. // For example:
  13415. // ```
  13416. // Observable.range(0, 10)
  13417. // .publish()
  13418. // .refCount()
  13419. // .take(5)
  13420. // .subscribe();
  13421. // ```
  13422. // In order to account for this case, RefCountSubscriber should only dispose
  13423. // the ConnectableObservable's shared connection Subscription if the
  13424. // connection Subscription exists, *and* either:
  13425. // a. RefCountSubscriber doesn't have a reference to the shared connection
  13426. // Subscription yet, or,
  13427. // b. RefCountSubscriber's connection Subscription reference is identical
  13428. // to the shared connection Subscription
  13429. ///
  13430. var connection = this.connection;
  13431. var sharedConnection = connectable._connection;
  13432. this.connection = null;
  13433. if (sharedConnection && (!connection || sharedConnection === connection)) {
  13434. sharedConnection.unsubscribe();
  13435. }
  13436. };
  13437. return RefCountSubscriber;
  13438. }(Subscriber_1.Subscriber));
  13439. //# sourceMappingURL=ConnectableObservable.js.map
  13440. /***/ }),
  13441. /* 137 */
  13442. /***/ (function(module, exports, __webpack_require__) {
  13443. "use strict";
  13444. Object.defineProperty(exports, "__esModule", { value: true });
  13445. var BehaviorSubject_1 = __webpack_require__(13);
  13446. var styles = {
  13447. display: "none",
  13448. padding: "15px",
  13449. fontFamily: "sans-serif",
  13450. position: "fixed",
  13451. fontSize: "0.9em",
  13452. zIndex: 9999,
  13453. right: 0,
  13454. top: 0,
  13455. borderBottomLeftRadius: "5px",
  13456. backgroundColor: "#1B2032",
  13457. margin: 0,
  13458. color: "white",
  13459. textAlign: "center",
  13460. pointerEvents: "none"
  13461. };
  13462. /**
  13463. * @param {IBrowserSyncOptions} options
  13464. * @returns {BehaviorSubject<any>}
  13465. */
  13466. function initNotify(options) {
  13467. var cssStyles = styles;
  13468. var elem;
  13469. if (options.notify.styles) {
  13470. if (Object.prototype.toString.call(options.notify.styles) ===
  13471. "[object Array]") {
  13472. // handle original array behavior, replace all styles with a joined copy
  13473. cssStyles = options.notify.styles.join(";");
  13474. }
  13475. else {
  13476. for (var key in options.notify.styles) {
  13477. if (options.notify.styles.hasOwnProperty(key)) {
  13478. cssStyles[key] = options.notify.styles[key];
  13479. }
  13480. }
  13481. }
  13482. }
  13483. elem = document.createElement("DIV");
  13484. elem.id = "__bs_notify__";
  13485. if (typeof cssStyles === "string") {
  13486. elem.style.cssText = cssStyles;
  13487. }
  13488. else {
  13489. for (var rule in cssStyles) {
  13490. elem.style[rule] = cssStyles[rule];
  13491. }
  13492. }
  13493. return new BehaviorSubject_1.BehaviorSubject(elem);
  13494. }
  13495. exports.initNotify = initNotify;
  13496. /***/ }),
  13497. /* 138 */
  13498. /***/ (function(module, exports, __webpack_require__) {
  13499. "use strict";
  13500. var __extends = (this && this.__extends) || function (d, b) {
  13501. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13502. function __() { this.constructor = d; }
  13503. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13504. };
  13505. var isNumeric_1 = __webpack_require__(77);
  13506. var Observable_1 = __webpack_require__(1);
  13507. var async_1 = __webpack_require__(78);
  13508. var isScheduler_1 = __webpack_require__(25);
  13509. var isDate_1 = __webpack_require__(141);
  13510. /**
  13511. * We need this JSDoc comment for affecting ESDoc.
  13512. * @extends {Ignored}
  13513. * @hide true
  13514. */
  13515. var TimerObservable = (function (_super) {
  13516. __extends(TimerObservable, _super);
  13517. function TimerObservable(dueTime, period, scheduler) {
  13518. if (dueTime === void 0) { dueTime = 0; }
  13519. _super.call(this);
  13520. this.period = -1;
  13521. this.dueTime = 0;
  13522. if (isNumeric_1.isNumeric(period)) {
  13523. this.period = Number(period) < 1 && 1 || Number(period);
  13524. }
  13525. else if (isScheduler_1.isScheduler(period)) {
  13526. scheduler = period;
  13527. }
  13528. if (!isScheduler_1.isScheduler(scheduler)) {
  13529. scheduler = async_1.async;
  13530. }
  13531. this.scheduler = scheduler;
  13532. this.dueTime = isDate_1.isDate(dueTime) ?
  13533. (+dueTime - this.scheduler.now()) :
  13534. dueTime;
  13535. }
  13536. /**
  13537. * Creates an Observable that starts emitting after an `initialDelay` and
  13538. * emits ever increasing numbers after each `period` of time thereafter.
  13539. *
  13540. * <span class="informal">Its like {@link interval}, but you can specify when
  13541. * should the emissions start.</span>
  13542. *
  13543. * <img src="./img/timer.png" width="100%">
  13544. *
  13545. * `timer` returns an Observable that emits an infinite sequence of ascending
  13546. * integers, with a constant interval of time, `period` of your choosing
  13547. * between those emissions. The first emission happens after the specified
  13548. * `initialDelay`. The initial delay may be a {@link Date}. By default, this
  13549. * operator uses the `async` IScheduler to provide a notion of time, but you
  13550. * may pass any IScheduler to it. If `period` is not specified, the output
  13551. * Observable emits only one value, `0`. Otherwise, it emits an infinite
  13552. * sequence.
  13553. *
  13554. * @example <caption>Emits ascending numbers, one every second (1000ms), starting after 3 seconds</caption>
  13555. * var numbers = Rx.Observable.timer(3000, 1000);
  13556. * numbers.subscribe(x => console.log(x));
  13557. *
  13558. * @example <caption>Emits one number after five seconds</caption>
  13559. * var numbers = Rx.Observable.timer(5000);
  13560. * numbers.subscribe(x => console.log(x));
  13561. *
  13562. * @see {@link interval}
  13563. * @see {@link delay}
  13564. *
  13565. * @param {number|Date} initialDelay The initial delay time to wait before
  13566. * emitting the first value of `0`.
  13567. * @param {number} [period] The period of time between emissions of the
  13568. * subsequent numbers.
  13569. * @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling
  13570. * the emission of values, and providing a notion of "time".
  13571. * @return {Observable} An Observable that emits a `0` after the
  13572. * `initialDelay` and ever increasing numbers after each `period` of time
  13573. * thereafter.
  13574. * @static true
  13575. * @name timer
  13576. * @owner Observable
  13577. */
  13578. TimerObservable.create = function (initialDelay, period, scheduler) {
  13579. if (initialDelay === void 0) { initialDelay = 0; }
  13580. return new TimerObservable(initialDelay, period, scheduler);
  13581. };
  13582. TimerObservable.dispatch = function (state) {
  13583. var index = state.index, period = state.period, subscriber = state.subscriber;
  13584. var action = this;
  13585. subscriber.next(index);
  13586. if (subscriber.closed) {
  13587. return;
  13588. }
  13589. else if (period === -1) {
  13590. return subscriber.complete();
  13591. }
  13592. state.index = index + 1;
  13593. action.schedule(state, period);
  13594. };
  13595. /** @deprecated internal use only */ TimerObservable.prototype._subscribe = function (subscriber) {
  13596. var index = 0;
  13597. var _a = this, period = _a.period, dueTime = _a.dueTime, scheduler = _a.scheduler;
  13598. return scheduler.schedule(TimerObservable.dispatch, dueTime, {
  13599. index: index, period: period, subscriber: subscriber
  13600. });
  13601. };
  13602. return TimerObservable;
  13603. }(Observable_1.Observable));
  13604. exports.TimerObservable = TimerObservable;
  13605. //# sourceMappingURL=TimerObservable.js.map
  13606. /***/ }),
  13607. /* 139 */
  13608. /***/ (function(module, exports, __webpack_require__) {
  13609. "use strict";
  13610. var __extends = (this && this.__extends) || function (d, b) {
  13611. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  13612. function __() { this.constructor = d; }
  13613. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13614. };
  13615. var Subscription_1 = __webpack_require__(12);
  13616. /**
  13617. * A unit of work to be executed in a {@link Scheduler}. An action is typically
  13618. * created from within a Scheduler and an RxJS user does not need to concern
  13619. * themselves about creating and manipulating an Action.
  13620. *
  13621. * ```ts
  13622. * class Action<T> extends Subscription {
  13623. * new (scheduler: Scheduler, work: (state?: T) => void);
  13624. * schedule(state?: T, delay: number = 0): Subscription;
  13625. * }
  13626. * ```
  13627. *
  13628. * @class Action<T>
  13629. */
  13630. var Action = (function (_super) {
  13631. __extends(Action, _super);
  13632. function Action(scheduler, work) {
  13633. _super.call(this);
  13634. }
  13635. /**
  13636. * Schedules this action on its parent Scheduler for execution. May be passed
  13637. * some context object, `state`. May happen at some point in the future,
  13638. * according to the `delay` parameter, if specified.
  13639. * @param {T} [state] Some contextual data that the `work` function uses when
  13640. * called by the Scheduler.
  13641. * @param {number} [delay] Time to wait before executing the work, where the
  13642. * time unit is implicit and defined by the Scheduler.
  13643. * @return {void}
  13644. */
  13645. Action.prototype.schedule = function (state, delay) {
  13646. if (delay === void 0) { delay = 0; }
  13647. return this;
  13648. };
  13649. return Action;
  13650. }(Subscription_1.Subscription));
  13651. exports.Action = Action;
  13652. //# sourceMappingURL=Action.js.map
  13653. /***/ }),
  13654. /* 140 */
  13655. /***/ (function(module, exports, __webpack_require__) {
  13656. "use strict";
  13657. /**
  13658. * An execution context and a data structure to order tasks and schedule their
  13659. * execution. Provides a notion of (potentially virtual) time, through the
  13660. * `now()` getter method.
  13661. *
  13662. * Each unit of work in a Scheduler is called an {@link Action}.
  13663. *
  13664. * ```ts
  13665. * class Scheduler {
  13666. * now(): number;
  13667. * schedule(work, delay?, state?): Subscription;
  13668. * }
  13669. * ```
  13670. *
  13671. * @class Scheduler
  13672. */
  13673. var Scheduler = (function () {
  13674. function Scheduler(SchedulerAction, now) {
  13675. if (now === void 0) { now = Scheduler.now; }
  13676. this.SchedulerAction = SchedulerAction;
  13677. this.now = now;
  13678. }
  13679. /**
  13680. * Schedules a function, `work`, for execution. May happen at some point in
  13681. * the future, according to the `delay` parameter, if specified. May be passed
  13682. * some context object, `state`, which will be passed to the `work` function.
  13683. *
  13684. * The given arguments will be processed an stored as an Action object in a
  13685. * queue of actions.
  13686. *
  13687. * @param {function(state: ?T): ?Subscription} work A function representing a
  13688. * task, or some unit of work to be executed by the Scheduler.
  13689. * @param {number} [delay] Time to wait before executing the work, where the
  13690. * time unit is implicit and defined by the Scheduler itself.
  13691. * @param {T} [state] Some contextual data that the `work` function uses when
  13692. * called by the Scheduler.
  13693. * @return {Subscription} A subscription in order to be able to unsubscribe
  13694. * the scheduled work.
  13695. */
  13696. Scheduler.prototype.schedule = function (work, delay, state) {
  13697. if (delay === void 0) { delay = 0; }
  13698. return new this.SchedulerAction(this, work).schedule(state, delay);
  13699. };
  13700. Scheduler.now = Date.now ? Date.now : function () { return +new Date(); };
  13701. return Scheduler;
  13702. }());
  13703. exports.Scheduler = Scheduler;
  13704. //# sourceMappingURL=Scheduler.js.map
  13705. /***/ }),
  13706. /* 141 */
  13707. /***/ (function(module, exports, __webpack_require__) {
  13708. "use strict";
  13709. function isDate(value) {
  13710. return value instanceof Date && !isNaN(+value);
  13711. }
  13712. exports.isDate = isDate;
  13713. //# sourceMappingURL=isDate.js.map
  13714. /***/ }),
  13715. /* 142 */
  13716. /***/ (function(module, exports, __webpack_require__) {
  13717. "use strict";
  13718. var __assign = (this && this.__assign) || function () {
  13719. __assign = Object.assign || function(t) {
  13720. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13721. s = arguments[i];
  13722. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  13723. t[p] = s[p];
  13724. }
  13725. return t;
  13726. };
  13727. return __assign.apply(this, arguments);
  13728. };
  13729. Object.defineProperty(exports, "__esModule", { value: true });
  13730. var emojis = {
  13731. trace: '🔍',
  13732. debug: '🐛',
  13733. info: '✨',
  13734. warn: '⚠️',
  13735. error: '🚨',
  13736. fatal: '💀'
  13737. };
  13738. var levels = {
  13739. trace: 10,
  13740. debug: 20,
  13741. info: 30,
  13742. warn: 40,
  13743. error: 50,
  13744. fatal: 60
  13745. };
  13746. var defaultColors = {
  13747. foreground: '#d3c0c8',
  13748. background: '#2d2d2d',
  13749. black: '#2d2d2d',
  13750. red: '#f2777a',
  13751. green: '#99cc99',
  13752. yellow: '#ffcc66',
  13753. blue: '#6699cc',
  13754. magenta: '#cc99cc',
  13755. cyan: '#66cccc',
  13756. white: '#d3d0c8',
  13757. brightBlack: '#747369'
  13758. };
  13759. var Nanologger = /** @class */ (function () {
  13760. function Nanologger(name, opts) {
  13761. this.name = name;
  13762. this.opts = opts;
  13763. this._name = name || '';
  13764. this._colors = __assign({}, defaultColors, (opts.colors || {}));
  13765. try {
  13766. this.logLevel = window.localStorage.getItem('logLevel') || 'info';
  13767. }
  13768. catch (e) {
  13769. this.logLevel = 'info';
  13770. }
  13771. this._logLevel = levels[this.logLevel];
  13772. }
  13773. Nanologger.prototype.trace = function () {
  13774. var args = ['trace'];
  13775. for (var i = 0, len = arguments.length; i < len; i++)
  13776. args.push(arguments[i]);
  13777. this._print.apply(this, args);
  13778. };
  13779. Nanologger.prototype.debug = function () {
  13780. var args = ['debug'];
  13781. for (var i = 0, len = arguments.length; i < len; i++)
  13782. args.push(arguments[i]);
  13783. this._print.apply(this, args);
  13784. };
  13785. Nanologger.prototype.info = function () {
  13786. var args = ['info'];
  13787. for (var i = 0, len = arguments.length; i < len; i++)
  13788. args.push(arguments[i]);
  13789. this._print.apply(this, args);
  13790. };
  13791. Nanologger.prototype.warn = function () {
  13792. var args = ['warn'];
  13793. for (var i = 0, len = arguments.length; i < len; i++)
  13794. args.push(arguments[i]);
  13795. this._print.apply(this, args);
  13796. };
  13797. Nanologger.prototype.error = function () {
  13798. var args = ['error'];
  13799. for (var i = 0, len = arguments.length; i < len; i++)
  13800. args.push(arguments[i]);
  13801. this._print.apply(this, args);
  13802. };
  13803. Nanologger.prototype.fatal = function () {
  13804. var args = ['fatal'];
  13805. for (var i = 0, len = arguments.length; i < len; i++)
  13806. args.push(arguments[i]);
  13807. this._print.apply(this, args);
  13808. };
  13809. Nanologger.prototype._print = function (level) {
  13810. if (levels[level] < this._logLevel)
  13811. return;
  13812. // var time = getTimeStamp()
  13813. var emoji = emojis[level];
  13814. var name = this._name || 'unknown';
  13815. var msgColor = (level === 'error' || level.fatal)
  13816. ? this._colors.red
  13817. : level === 'warn'
  13818. ? this._colors.yellow
  13819. : this._colors.green;
  13820. var objs = [];
  13821. var args = [null];
  13822. var msg = emoji + ' %c%s';
  13823. // args.push(color(this._colors.brightBlack), time)
  13824. args.push(color(this._colors.magenta), name);
  13825. for (var i = 1, len = arguments.length; i < len; i++) {
  13826. var arg = arguments[i];
  13827. if (typeof arg === 'string') {
  13828. if (i === 1) {
  13829. // first string argument is in color
  13830. msg += ' %c%s';
  13831. args.push(color(msgColor));
  13832. args.push(arg);
  13833. }
  13834. else if (/ms$/.test(arg)) {
  13835. // arguments finishing with 'ms', grey out
  13836. msg += ' %c%s';
  13837. args.push(color(this._colors.brightBlack));
  13838. args.push(arg);
  13839. }
  13840. else {
  13841. // normal colors
  13842. msg += ' %c%s';
  13843. args.push(color(this._colors.white));
  13844. args.push(arg);
  13845. }
  13846. }
  13847. else if (typeof arg === 'number') {
  13848. msg += ' %c%d';
  13849. args.push(color(this._colors.magenta));
  13850. args.push(arg);
  13851. }
  13852. else {
  13853. objs.push(arg);
  13854. }
  13855. }
  13856. args[0] = msg;
  13857. objs.forEach(function (obj) {
  13858. args.push(obj);
  13859. });
  13860. // In IE/Edge console functions don't inherit from Function.prototype
  13861. // so this is necessary to get all the args applied.
  13862. Function.prototype.apply.apply(console.log, [console, args]);
  13863. };
  13864. return Nanologger;
  13865. }());
  13866. exports.Nanologger = Nanologger;
  13867. function color(color) {
  13868. return 'color: ' + color + ';';
  13869. }
  13870. function getTimeStamp() {
  13871. var date = new Date();
  13872. var hours = pad(date.getHours().toString());
  13873. var minutes = pad(date.getMinutes().toString());
  13874. var seconds = pad(date.getSeconds().toString());
  13875. return hours + ':' + minutes + ':' + seconds;
  13876. }
  13877. function pad(str) {
  13878. return str.length !== 2 ? 0 + str : str;
  13879. }
  13880. /***/ }),
  13881. /* 143 */
  13882. /***/ (function(module, exports, __webpack_require__) {
  13883. "use strict";
  13884. Object.defineProperty(exports, "__esModule", { value: true });
  13885. /**
  13886. *
  13887. * With thanks to https://github.com/livereload/livereload-js
  13888. * :) :) :)
  13889. *
  13890. */
  13891. var utils_1 = __webpack_require__(21);
  13892. var empty_1 = __webpack_require__(16);
  13893. var Observable_1 = __webpack_require__(1);
  13894. var merge_1 = __webpack_require__(38);
  13895. var timer_1 = __webpack_require__(52);
  13896. var from_1 = __webpack_require__(87);
  13897. var filter_1 = __webpack_require__(4);
  13898. var map_1 = __webpack_require__(2);
  13899. var mergeMap_1 = __webpack_require__(15);
  13900. var tap_1 = __webpack_require__(5);
  13901. var mapTo_1 = __webpack_require__(88);
  13902. var prop_set_dom_effect_1 = __webpack_require__(76);
  13903. var style_set_dom_effect_1 = __webpack_require__(81);
  13904. var link_replace_dom_effect_1 = __webpack_require__(82);
  13905. var mergeAll_1 = __webpack_require__(55);
  13906. var hiddenElem;
  13907. var IMAGE_STYLES = [
  13908. { selector: 'background', styleNames: ['backgroundImage'] },
  13909. { selector: 'border', styleNames: ['borderImage', 'webkitBorderImage', 'MozBorderImage'] }
  13910. ];
  13911. var attrs = {
  13912. link: "href",
  13913. img: "src",
  13914. script: "src"
  13915. };
  13916. function reload(document, navigator) {
  13917. return function (data, options) {
  13918. var path = data.path;
  13919. if (options.liveCSS) {
  13920. if (path.match(/\.css$/i)) {
  13921. return reloadStylesheet(path, document, navigator);
  13922. }
  13923. }
  13924. if (options.liveImg) {
  13925. if (path.match(/\.(jpe?g|png|gif)$/i)) {
  13926. return reloadImages(path, document);
  13927. }
  13928. }
  13929. /**
  13930. * LEGACY
  13931. */
  13932. var domData = getElems(data.ext, options, document);
  13933. var elems = getMatches(domData.elems, data.basename, domData.attr);
  13934. for (var i = 0, n = elems.length; i < n; i += 1) {
  13935. swapFile(elems[i], domData, options, document, navigator);
  13936. }
  13937. return empty_1.empty();
  13938. };
  13939. function getMatches(elems, url, attr) {
  13940. if (url[0] === "*") {
  13941. return elems;
  13942. }
  13943. var matches = [];
  13944. var urlMatcher = new RegExp("(^|/)" + url);
  13945. for (var i = 0, len = elems.length; i < len; i += 1) {
  13946. if (urlMatcher.test(elems[i][attr])) {
  13947. matches.push(elems[i]);
  13948. }
  13949. }
  13950. return matches;
  13951. }
  13952. function getElems(fileExtension, options, document) {
  13953. var tagName = options.tagNames[fileExtension];
  13954. var attr = attrs[tagName];
  13955. return {
  13956. attr: attr,
  13957. tagName: tagName,
  13958. elems: document.getElementsByTagName(tagName)
  13959. };
  13960. }
  13961. function reloadImages(path, document) {
  13962. var expando = generateUniqueString(Date.now());
  13963. return merge_1.merge(from_1.from([].slice.call(document.images))
  13964. .pipe(filter_1.filter(function (img) { return utils_1.pathsMatch(path, utils_1.pathFromUrl(img.src)); }), map_1.map(function (img) {
  13965. var payload = {
  13966. target: img,
  13967. prop: 'src',
  13968. value: generateCacheBustUrl(img.src, expando),
  13969. pathname: utils_1.getLocation(img.src).pathname
  13970. };
  13971. return prop_set_dom_effect_1.propSet(payload);
  13972. })), from_1.from(IMAGE_STYLES)
  13973. .pipe(mergeMap_1.mergeMap(function (_a) {
  13974. var selector = _a.selector, styleNames = _a.styleNames;
  13975. return from_1.from(document.querySelectorAll("[style*=" + selector + "]")).pipe(mergeMap_1.mergeMap(function (img) {
  13976. return reloadStyleImages(img.style, styleNames, path, expando);
  13977. }));
  13978. })));
  13979. // if (document.styleSheets) {
  13980. // return [].slice.call(document.styleSheets)
  13981. // .map((styleSheet) => {
  13982. // return reloadStylesheetImages(styleSheet, path, expando);
  13983. // });
  13984. // }
  13985. }
  13986. function reloadStylesheetImages(styleSheet, path, expando) {
  13987. var rules;
  13988. try {
  13989. rules = styleSheet != null ? styleSheet.cssRules : undefined;
  13990. }
  13991. catch (e) { }
  13992. //
  13993. if (!rules) {
  13994. return;
  13995. }
  13996. [].slice.call(rules).forEach(function (rule) {
  13997. switch (rule.type) {
  13998. case CSSRule.IMPORT_RULE:
  13999. reloadStylesheetImages(rule.styleSheet, path, expando);
  14000. break;
  14001. case CSSRule.STYLE_RULE:
  14002. [].slice.call(IMAGE_STYLES).forEach(function (_a) {
  14003. var styleNames = _a.styleNames;
  14004. reloadStyleImages(rule.style, styleNames, path, expando);
  14005. });
  14006. break;
  14007. case CSSRule.MEDIA_RULE:
  14008. reloadStylesheetImages(rule, path, expando);
  14009. break;
  14010. }
  14011. });
  14012. }
  14013. function reloadStyleImages(style, styleNames, path, expando) {
  14014. return from_1.from(styleNames).pipe(filter_1.filter(function (styleName) { return typeof style[styleName] === 'string'; }), map_1.map(function (styleName) {
  14015. var pathName;
  14016. var value = style[styleName];
  14017. var newValue = value.replace(new RegExp("\\burl\\s*\\(([^)]*)\\)"), function (match, src) {
  14018. var _src = src;
  14019. if (src[0] === '"' && src[src.length - 1] === '"') {
  14020. _src = src.slice(1, -1);
  14021. }
  14022. pathName = utils_1.getLocation(_src).pathname;
  14023. if (utils_1.pathsMatch(path, utils_1.pathFromUrl(_src))) {
  14024. return "url(" + generateCacheBustUrl(_src, expando) + ")";
  14025. }
  14026. else {
  14027. return match;
  14028. }
  14029. });
  14030. return [
  14031. style,
  14032. styleName,
  14033. value,
  14034. newValue,
  14035. pathName
  14036. ];
  14037. }), filter_1.filter(function (_a) {
  14038. var style = _a[0], styleName = _a[1], value = _a[2], newValue = _a[3];
  14039. return newValue !== value;
  14040. }), map_1.map(function (_a) {
  14041. var style = _a[0], styleName = _a[1], value = _a[2], newValue = _a[3], pathName = _a[4];
  14042. return style_set_dom_effect_1.styleSet({ style: style, styleName: styleName, value: value, newValue: newValue, pathName: pathName });
  14043. }));
  14044. }
  14045. function swapFile(elem, domData, options, document, navigator) {
  14046. var attr = domData.attr;
  14047. var currentValue = elem[attr];
  14048. var timeStamp = new Date().getTime();
  14049. var key = "browsersync-legacy";
  14050. var suffix = key + "=" + timeStamp;
  14051. var anchor = utils_1.getLocation(currentValue);
  14052. var search = utils_1.updateSearch(anchor.search, key, suffix);
  14053. switch (domData.tagName) {
  14054. case 'link': {
  14055. // this.logger.trace(`replacing LINK ${attr}`);
  14056. reloadStylesheet(currentValue, document, navigator);
  14057. break;
  14058. }
  14059. case 'img': {
  14060. reloadImages(currentValue, document);
  14061. break;
  14062. }
  14063. default: {
  14064. if (options.timestamps === false) {
  14065. elem[attr] = anchor.href;
  14066. }
  14067. else {
  14068. elem[attr] = anchor.href.split("?")[0] + search;
  14069. }
  14070. // this.logger.info(`reloading ${elem[attr]}`);
  14071. setTimeout(function () {
  14072. if (!hiddenElem) {
  14073. hiddenElem = document.createElement("DIV");
  14074. document.body.appendChild(hiddenElem);
  14075. }
  14076. else {
  14077. hiddenElem.style.display = "none";
  14078. hiddenElem.style.display = "block";
  14079. }
  14080. }, 200);
  14081. }
  14082. }
  14083. return {
  14084. elem: elem,
  14085. timeStamp: timeStamp
  14086. };
  14087. }
  14088. function reattachStylesheetLink(link, document, navigator) {
  14089. // ignore LINKs that will be removed by LR soon
  14090. var clone;
  14091. if (link.__LiveReload_pendingRemoval) {
  14092. return empty_1.empty();
  14093. }
  14094. link.__LiveReload_pendingRemoval = true;
  14095. if (link.tagName === 'STYLE') {
  14096. // prefixfree
  14097. clone = document.createElement('link');
  14098. clone.rel = 'stylesheet';
  14099. clone.media = link.media;
  14100. clone.disabled = link.disabled;
  14101. }
  14102. else {
  14103. clone = link.cloneNode(false);
  14104. }
  14105. var prevHref = link.href;
  14106. var nextHref = generateCacheBustUrl(linkHref(link));
  14107. clone.href = nextHref;
  14108. var pathname = utils_1.getLocation(nextHref).pathname;
  14109. var basename = pathname.split('/').slice(-1)[0];
  14110. // insert the new LINK before the old one
  14111. var parent = link.parentNode;
  14112. if (parent.lastChild === link) {
  14113. parent.appendChild(clone);
  14114. }
  14115. else {
  14116. parent.insertBefore(clone, link.nextSibling);
  14117. }
  14118. var additionalWaitingTime;
  14119. if (/AppleWebKit/.test(navigator.userAgent)) {
  14120. additionalWaitingTime = 5;
  14121. }
  14122. else {
  14123. additionalWaitingTime = 200;
  14124. }
  14125. return Observable_1.Observable.create(function (obs) {
  14126. clone.onload = function () {
  14127. obs.next(true);
  14128. obs.complete();
  14129. };
  14130. })
  14131. .pipe(mergeMap_1.mergeMap(function () {
  14132. return timer_1.timer(additionalWaitingTime)
  14133. .pipe(tap_1.tap(function () {
  14134. if (link && !link.parentNode) {
  14135. return;
  14136. }
  14137. link.parentNode.removeChild(link);
  14138. clone.onreadystatechange = null;
  14139. }), mapTo_1.mapTo(link_replace_dom_effect_1.linkReplace({ target: clone, nextHref: nextHref, prevHref: prevHref, pathname: pathname, basename: basename })));
  14140. }));
  14141. }
  14142. function reattachImportedRule(_a, document) {
  14143. var rule = _a.rule, index = _a.index, link = _a.link;
  14144. var parent = rule.parentStyleSheet;
  14145. var href = generateCacheBustUrl(rule.href);
  14146. var media = rule.media.length ? [].join.call(rule.media, ', ') : '';
  14147. var newRule = "@import url(\"" + href + "\") " + media + ";";
  14148. // used to detect if reattachImportedRule has been called again on the same rule
  14149. rule.__LiveReload_newHref = href;
  14150. // WORKAROUND FOR WEBKIT BUG: WebKit resets all styles if we add @import'ed
  14151. // stylesheet that hasn't been cached yet. Workaround is to pre-cache the
  14152. // stylesheet by temporarily adding it as a LINK tag.
  14153. var tempLink = document.createElement("link");
  14154. tempLink.rel = 'stylesheet';
  14155. tempLink.href = href;
  14156. tempLink.__LiveReload_pendingRemoval = true; // exclude from path matching
  14157. if (link.parentNode) {
  14158. link.parentNode.insertBefore(tempLink, link);
  14159. }
  14160. return timer_1.timer(200)
  14161. .pipe(tap_1.tap(function () {
  14162. if (tempLink.parentNode) {
  14163. tempLink.parentNode.removeChild(tempLink);
  14164. }
  14165. // if another reattachImportedRule call is in progress, abandon this one
  14166. if (rule.__LiveReload_newHref !== href) {
  14167. return;
  14168. }
  14169. parent.insertRule(newRule, index);
  14170. parent.deleteRule(index + 1);
  14171. // save the new rule, so that we can detect another reattachImportedRule call
  14172. rule = parent.cssRules[index];
  14173. rule.__LiveReload_newHref = href;
  14174. }), mergeMap_1.mergeMap(function () {
  14175. return timer_1.timer(200).pipe(tap_1.tap(function () {
  14176. // if another reattachImportedRule call is in progress, abandon this one
  14177. if (rule.__LiveReload_newHref !== href) {
  14178. return;
  14179. }
  14180. parent.insertRule(newRule, index);
  14181. return parent.deleteRule(index + 1);
  14182. }));
  14183. }));
  14184. }
  14185. function generateCacheBustUrl(url, expando) {
  14186. if (expando === void 0) { expando = generateUniqueString(Date.now()); }
  14187. var _a;
  14188. var hash, oldParams;
  14189. (_a = utils_1.splitUrl(url), url = _a.url, hash = _a.hash, oldParams = _a.params);
  14190. // if (this.options.overrideURL) {
  14191. // if (url.indexOf(this.options.serverURL) < 0) {
  14192. // const originalUrl = url;
  14193. // url = this.options.serverURL + this.options.overrideURL + "?url=" + encodeURIComponent(url);
  14194. // this.logger.debug(`overriding source URL ${originalUrl} with ${url}`);
  14195. // }
  14196. // }
  14197. var params = oldParams.replace(/(\?|&)browsersync=(\d+)/, function (match, sep) { return "" + sep + expando; });
  14198. if (params === oldParams) {
  14199. if (oldParams.length === 0) {
  14200. params = "?" + expando;
  14201. }
  14202. else {
  14203. params = oldParams + "&" + expando;
  14204. }
  14205. }
  14206. return url + params + hash;
  14207. }
  14208. function reloadStylesheet(path, document, navigator) {
  14209. // has to be a real array, because DOMNodeList will be modified
  14210. var links = utils_1.array(document.getElementsByTagName('link'))
  14211. .filter(function (link) {
  14212. return link.rel.match(/^stylesheet$/i)
  14213. && !link.__LiveReload_pendingRemoval;
  14214. });
  14215. /**
  14216. * Find imported style sheets in <style> tags
  14217. * @type {any[]}
  14218. */
  14219. var styleImported = utils_1.array(document.getElementsByTagName('style'))
  14220. .filter(function (style) { return Boolean(style.sheet); })
  14221. .reduce(function (acc, style) {
  14222. return acc.concat(collectImportedStylesheets(style, style.sheet));
  14223. }, []);
  14224. /**
  14225. * Find imported style sheets in <link> tags
  14226. * @type {any[]}
  14227. */
  14228. var linksImported = links
  14229. .reduce(function (acc, link) {
  14230. return acc.concat(collectImportedStylesheets(link, link.sheet));
  14231. }, []);
  14232. /**
  14233. * Combine all links + sheets
  14234. */
  14235. var allRules = links.concat(styleImported, linksImported);
  14236. /**
  14237. * Which href best matches the incoming href?
  14238. */
  14239. var match = utils_1.pickBestMatch(path, allRules, function (l) { return utils_1.pathFromUrl(linkHref(l)); });
  14240. if (match) {
  14241. if (match.object && match.object.rule) {
  14242. return reattachImportedRule(match.object, document);
  14243. }
  14244. return reattachStylesheetLink(match.object, document, navigator);
  14245. }
  14246. else {
  14247. if (links.length) {
  14248. // no <link> elements matched, so was the path including '*'?
  14249. var _a = path.split('.'), first = _a[0], rest = _a.slice(1);
  14250. if (first === '*') {
  14251. return from_1.from(links.map(function (link) { return reattachStylesheetLink(link, document, navigator); }))
  14252. .pipe(mergeAll_1.mergeAll());
  14253. }
  14254. }
  14255. }
  14256. return empty_1.empty();
  14257. }
  14258. function collectImportedStylesheets(link, styleSheet) {
  14259. // in WebKit, styleSheet.cssRules is null for inaccessible stylesheets;
  14260. // Firefox/Opera may throw exceptions
  14261. var output = [];
  14262. collect(link, makeRules(styleSheet));
  14263. return output;
  14264. function makeRules(styleSheet) {
  14265. var rules;
  14266. try {
  14267. rules = styleSheet != null ? styleSheet.cssRules : undefined;
  14268. }
  14269. catch (e) { }
  14270. return rules;
  14271. }
  14272. function collect(link, rules) {
  14273. if (rules && rules.length) {
  14274. for (var index = 0; index < rules.length; index++) {
  14275. var rule = rules[index];
  14276. switch (rule.type) {
  14277. case CSSRule.CHARSET_RULE:
  14278. break;
  14279. case CSSRule.IMPORT_RULE:
  14280. output.push({ link: link, rule: rule, index: index, href: rule.href });
  14281. collect(link, makeRules(rule.styleSheet));
  14282. break;
  14283. default:
  14284. break; // import rules can only be preceded by charset rules
  14285. }
  14286. }
  14287. }
  14288. }
  14289. }
  14290. function linkHref(link) {
  14291. // prefixfree uses data-href when it turns LINK into STYLE
  14292. return link.href || link.getAttribute('data-href');
  14293. }
  14294. function generateUniqueString(value) {
  14295. return "browsersync=" + value;
  14296. }
  14297. }
  14298. exports.reload = reload;
  14299. /***/ }),
  14300. /* 144 */
  14301. /***/ (function(module, exports, __webpack_require__) {
  14302. "use strict";
  14303. var __extends = (this && this.__extends) || function (d, b) {
  14304. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14305. function __() { this.constructor = d; }
  14306. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14307. };
  14308. var isArray_1 = __webpack_require__(26);
  14309. var isArrayLike_1 = __webpack_require__(59);
  14310. var isPromise_1 = __webpack_require__(60);
  14311. var PromiseObservable_1 = __webpack_require__(145);
  14312. var IteratorObservable_1 = __webpack_require__(146);
  14313. var ArrayObservable_1 = __webpack_require__(23);
  14314. var ArrayLikeObservable_1 = __webpack_require__(147);
  14315. var iterator_1 = __webpack_require__(31);
  14316. var Observable_1 = __webpack_require__(1);
  14317. var observeOn_1 = __webpack_require__(148);
  14318. var observable_1 = __webpack_require__(45);
  14319. /**
  14320. * We need this JSDoc comment for affecting ESDoc.
  14321. * @extends {Ignored}
  14322. * @hide true
  14323. */
  14324. var FromObservable = (function (_super) {
  14325. __extends(FromObservable, _super);
  14326. function FromObservable(ish, scheduler) {
  14327. _super.call(this, null);
  14328. this.ish = ish;
  14329. this.scheduler = scheduler;
  14330. }
  14331. /**
  14332. * Creates an Observable from an Array, an array-like object, a Promise, an
  14333. * iterable object, or an Observable-like object.
  14334. *
  14335. * <span class="informal">Converts almost anything to an Observable.</span>
  14336. *
  14337. * <img src="./img/from.png" width="100%">
  14338. *
  14339. * Convert various other objects and data types into Observables. `from`
  14340. * converts a Promise or an array-like or an
  14341. * [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)
  14342. * object into an Observable that emits the items in that promise or array or
  14343. * iterable. A String, in this context, is treated as an array of characters.
  14344. * Observable-like objects (contains a function named with the ES2015 Symbol
  14345. * for Observable) can also be converted through this operator.
  14346. *
  14347. * @example <caption>Converts an array to an Observable</caption>
  14348. * var array = [10, 20, 30];
  14349. * var result = Rx.Observable.from(array);
  14350. * result.subscribe(x => console.log(x));
  14351. *
  14352. * // Results in the following:
  14353. * // 10 20 30
  14354. *
  14355. * @example <caption>Convert an infinite iterable (from a generator) to an Observable</caption>
  14356. * function* generateDoubles(seed) {
  14357. * var i = seed;
  14358. * while (true) {
  14359. * yield i;
  14360. * i = 2 * i; // double it
  14361. * }
  14362. * }
  14363. *
  14364. * var iterator = generateDoubles(3);
  14365. * var result = Rx.Observable.from(iterator).take(10);
  14366. * result.subscribe(x => console.log(x));
  14367. *
  14368. * // Results in the following:
  14369. * // 3 6 12 24 48 96 192 384 768 1536
  14370. *
  14371. * @see {@link create}
  14372. * @see {@link fromEvent}
  14373. * @see {@link fromEventPattern}
  14374. * @see {@link fromPromise}
  14375. *
  14376. * @param {ObservableInput<T>} ish A subscribable object, a Promise, an
  14377. * Observable-like, an Array, an iterable or an array-like object to be
  14378. * converted.
  14379. * @param {Scheduler} [scheduler] The scheduler on which to schedule the
  14380. * emissions of values.
  14381. * @return {Observable<T>} The Observable whose values are originally from the
  14382. * input object that was converted.
  14383. * @static true
  14384. * @name from
  14385. * @owner Observable
  14386. */
  14387. FromObservable.create = function (ish, scheduler) {
  14388. if (ish != null) {
  14389. if (typeof ish[observable_1.observable] === 'function') {
  14390. if (ish instanceof Observable_1.Observable && !scheduler) {
  14391. return ish;
  14392. }
  14393. return new FromObservable(ish, scheduler);
  14394. }
  14395. else if (isArray_1.isArray(ish)) {
  14396. return new ArrayObservable_1.ArrayObservable(ish, scheduler);
  14397. }
  14398. else if (isPromise_1.isPromise(ish)) {
  14399. return new PromiseObservable_1.PromiseObservable(ish, scheduler);
  14400. }
  14401. else if (typeof ish[iterator_1.iterator] === 'function' || typeof ish === 'string') {
  14402. return new IteratorObservable_1.IteratorObservable(ish, scheduler);
  14403. }
  14404. else if (isArrayLike_1.isArrayLike(ish)) {
  14405. return new ArrayLikeObservable_1.ArrayLikeObservable(ish, scheduler);
  14406. }
  14407. }
  14408. throw new TypeError((ish !== null && typeof ish || ish) + ' is not observable');
  14409. };
  14410. /** @deprecated internal use only */ FromObservable.prototype._subscribe = function (subscriber) {
  14411. var ish = this.ish;
  14412. var scheduler = this.scheduler;
  14413. if (scheduler == null) {
  14414. return ish[observable_1.observable]().subscribe(subscriber);
  14415. }
  14416. else {
  14417. return ish[observable_1.observable]().subscribe(new observeOn_1.ObserveOnSubscriber(subscriber, scheduler, 0));
  14418. }
  14419. };
  14420. return FromObservable;
  14421. }(Observable_1.Observable));
  14422. exports.FromObservable = FromObservable;
  14423. //# sourceMappingURL=FromObservable.js.map
  14424. /***/ }),
  14425. /* 145 */
  14426. /***/ (function(module, exports, __webpack_require__) {
  14427. "use strict";
  14428. var __extends = (this && this.__extends) || function (d, b) {
  14429. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14430. function __() { this.constructor = d; }
  14431. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14432. };
  14433. var root_1 = __webpack_require__(7);
  14434. var Observable_1 = __webpack_require__(1);
  14435. /**
  14436. * We need this JSDoc comment for affecting ESDoc.
  14437. * @extends {Ignored}
  14438. * @hide true
  14439. */
  14440. var PromiseObservable = (function (_super) {
  14441. __extends(PromiseObservable, _super);
  14442. function PromiseObservable(promise, scheduler) {
  14443. _super.call(this);
  14444. this.promise = promise;
  14445. this.scheduler = scheduler;
  14446. }
  14447. /**
  14448. * Converts a Promise to an Observable.
  14449. *
  14450. * <span class="informal">Returns an Observable that just emits the Promise's
  14451. * resolved value, then completes.</span>
  14452. *
  14453. * Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an
  14454. * Observable. If the Promise resolves with a value, the output Observable
  14455. * emits that resolved value as a `next`, and then completes. If the Promise
  14456. * is rejected, then the output Observable emits the corresponding Error.
  14457. *
  14458. * @example <caption>Convert the Promise returned by Fetch to an Observable</caption>
  14459. * var result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
  14460. * result.subscribe(x => console.log(x), e => console.error(e));
  14461. *
  14462. * @see {@link bindCallback}
  14463. * @see {@link from}
  14464. *
  14465. * @param {PromiseLike<T>} promise The promise to be converted.
  14466. * @param {Scheduler} [scheduler] An optional IScheduler to use for scheduling
  14467. * the delivery of the resolved value (or the rejection).
  14468. * @return {Observable<T>} An Observable which wraps the Promise.
  14469. * @static true
  14470. * @name fromPromise
  14471. * @owner Observable
  14472. */
  14473. PromiseObservable.create = function (promise, scheduler) {
  14474. return new PromiseObservable(promise, scheduler);
  14475. };
  14476. /** @deprecated internal use only */ PromiseObservable.prototype._subscribe = function (subscriber) {
  14477. var _this = this;
  14478. var promise = this.promise;
  14479. var scheduler = this.scheduler;
  14480. if (scheduler == null) {
  14481. if (this._isScalar) {
  14482. if (!subscriber.closed) {
  14483. subscriber.next(this.value);
  14484. subscriber.complete();
  14485. }
  14486. }
  14487. else {
  14488. promise.then(function (value) {
  14489. _this.value = value;
  14490. _this._isScalar = true;
  14491. if (!subscriber.closed) {
  14492. subscriber.next(value);
  14493. subscriber.complete();
  14494. }
  14495. }, function (err) {
  14496. if (!subscriber.closed) {
  14497. subscriber.error(err);
  14498. }
  14499. })
  14500. .then(null, function (err) {
  14501. // escape the promise trap, throw unhandled errors
  14502. root_1.root.setTimeout(function () { throw err; });
  14503. });
  14504. }
  14505. }
  14506. else {
  14507. if (this._isScalar) {
  14508. if (!subscriber.closed) {
  14509. return scheduler.schedule(dispatchNext, 0, { value: this.value, subscriber: subscriber });
  14510. }
  14511. }
  14512. else {
  14513. promise.then(function (value) {
  14514. _this.value = value;
  14515. _this._isScalar = true;
  14516. if (!subscriber.closed) {
  14517. subscriber.add(scheduler.schedule(dispatchNext, 0, { value: value, subscriber: subscriber }));
  14518. }
  14519. }, function (err) {
  14520. if (!subscriber.closed) {
  14521. subscriber.add(scheduler.schedule(dispatchError, 0, { err: err, subscriber: subscriber }));
  14522. }
  14523. })
  14524. .then(null, function (err) {
  14525. // escape the promise trap, throw unhandled errors
  14526. root_1.root.setTimeout(function () { throw err; });
  14527. });
  14528. }
  14529. }
  14530. };
  14531. return PromiseObservable;
  14532. }(Observable_1.Observable));
  14533. exports.PromiseObservable = PromiseObservable;
  14534. function dispatchNext(arg) {
  14535. var value = arg.value, subscriber = arg.subscriber;
  14536. if (!subscriber.closed) {
  14537. subscriber.next(value);
  14538. subscriber.complete();
  14539. }
  14540. }
  14541. function dispatchError(arg) {
  14542. var err = arg.err, subscriber = arg.subscriber;
  14543. if (!subscriber.closed) {
  14544. subscriber.error(err);
  14545. }
  14546. }
  14547. //# sourceMappingURL=PromiseObservable.js.map
  14548. /***/ }),
  14549. /* 146 */
  14550. /***/ (function(module, exports, __webpack_require__) {
  14551. "use strict";
  14552. var __extends = (this && this.__extends) || function (d, b) {
  14553. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14554. function __() { this.constructor = d; }
  14555. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14556. };
  14557. var root_1 = __webpack_require__(7);
  14558. var Observable_1 = __webpack_require__(1);
  14559. var iterator_1 = __webpack_require__(31);
  14560. /**
  14561. * We need this JSDoc comment for affecting ESDoc.
  14562. * @extends {Ignored}
  14563. * @hide true
  14564. */
  14565. var IteratorObservable = (function (_super) {
  14566. __extends(IteratorObservable, _super);
  14567. function IteratorObservable(iterator, scheduler) {
  14568. _super.call(this);
  14569. this.scheduler = scheduler;
  14570. if (iterator == null) {
  14571. throw new Error('iterator cannot be null.');
  14572. }
  14573. this.iterator = getIterator(iterator);
  14574. }
  14575. IteratorObservable.create = function (iterator, scheduler) {
  14576. return new IteratorObservable(iterator, scheduler);
  14577. };
  14578. IteratorObservable.dispatch = function (state) {
  14579. var index = state.index, hasError = state.hasError, iterator = state.iterator, subscriber = state.subscriber;
  14580. if (hasError) {
  14581. subscriber.error(state.error);
  14582. return;
  14583. }
  14584. var result = iterator.next();
  14585. if (result.done) {
  14586. subscriber.complete();
  14587. return;
  14588. }
  14589. subscriber.next(result.value);
  14590. state.index = index + 1;
  14591. if (subscriber.closed) {
  14592. if (typeof iterator.return === 'function') {
  14593. iterator.return();
  14594. }
  14595. return;
  14596. }
  14597. this.schedule(state);
  14598. };
  14599. /** @deprecated internal use only */ IteratorObservable.prototype._subscribe = function (subscriber) {
  14600. var index = 0;
  14601. var _a = this, iterator = _a.iterator, scheduler = _a.scheduler;
  14602. if (scheduler) {
  14603. return scheduler.schedule(IteratorObservable.dispatch, 0, {
  14604. index: index, iterator: iterator, subscriber: subscriber
  14605. });
  14606. }
  14607. else {
  14608. do {
  14609. var result = iterator.next();
  14610. if (result.done) {
  14611. subscriber.complete();
  14612. break;
  14613. }
  14614. else {
  14615. subscriber.next(result.value);
  14616. }
  14617. if (subscriber.closed) {
  14618. if (typeof iterator.return === 'function') {
  14619. iterator.return();
  14620. }
  14621. break;
  14622. }
  14623. } while (true);
  14624. }
  14625. };
  14626. return IteratorObservable;
  14627. }(Observable_1.Observable));
  14628. exports.IteratorObservable = IteratorObservable;
  14629. var StringIterator = (function () {
  14630. function StringIterator(str, idx, len) {
  14631. if (idx === void 0) { idx = 0; }
  14632. if (len === void 0) { len = str.length; }
  14633. this.str = str;
  14634. this.idx = idx;
  14635. this.len = len;
  14636. }
  14637. StringIterator.prototype[iterator_1.iterator] = function () { return (this); };
  14638. StringIterator.prototype.next = function () {
  14639. return this.idx < this.len ? {
  14640. done: false,
  14641. value: this.str.charAt(this.idx++)
  14642. } : {
  14643. done: true,
  14644. value: undefined
  14645. };
  14646. };
  14647. return StringIterator;
  14648. }());
  14649. var ArrayIterator = (function () {
  14650. function ArrayIterator(arr, idx, len) {
  14651. if (idx === void 0) { idx = 0; }
  14652. if (len === void 0) { len = toLength(arr); }
  14653. this.arr = arr;
  14654. this.idx = idx;
  14655. this.len = len;
  14656. }
  14657. ArrayIterator.prototype[iterator_1.iterator] = function () { return this; };
  14658. ArrayIterator.prototype.next = function () {
  14659. return this.idx < this.len ? {
  14660. done: false,
  14661. value: this.arr[this.idx++]
  14662. } : {
  14663. done: true,
  14664. value: undefined
  14665. };
  14666. };
  14667. return ArrayIterator;
  14668. }());
  14669. function getIterator(obj) {
  14670. var i = obj[iterator_1.iterator];
  14671. if (!i && typeof obj === 'string') {
  14672. return new StringIterator(obj);
  14673. }
  14674. if (!i && obj.length !== undefined) {
  14675. return new ArrayIterator(obj);
  14676. }
  14677. if (!i) {
  14678. throw new TypeError('object is not iterable');
  14679. }
  14680. return obj[iterator_1.iterator]();
  14681. }
  14682. var maxSafeInteger = Math.pow(2, 53) - 1;
  14683. function toLength(o) {
  14684. var len = +o.length;
  14685. if (isNaN(len)) {
  14686. return 0;
  14687. }
  14688. if (len === 0 || !numberIsFinite(len)) {
  14689. return len;
  14690. }
  14691. len = sign(len) * Math.floor(Math.abs(len));
  14692. if (len <= 0) {
  14693. return 0;
  14694. }
  14695. if (len > maxSafeInteger) {
  14696. return maxSafeInteger;
  14697. }
  14698. return len;
  14699. }
  14700. function numberIsFinite(value) {
  14701. return typeof value === 'number' && root_1.root.isFinite(value);
  14702. }
  14703. function sign(value) {
  14704. var valueAsNumber = +value;
  14705. if (valueAsNumber === 0) {
  14706. return valueAsNumber;
  14707. }
  14708. if (isNaN(valueAsNumber)) {
  14709. return valueAsNumber;
  14710. }
  14711. return valueAsNumber < 0 ? -1 : 1;
  14712. }
  14713. //# sourceMappingURL=IteratorObservable.js.map
  14714. /***/ }),
  14715. /* 147 */
  14716. /***/ (function(module, exports, __webpack_require__) {
  14717. "use strict";
  14718. var __extends = (this && this.__extends) || function (d, b) {
  14719. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14720. function __() { this.constructor = d; }
  14721. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14722. };
  14723. var Observable_1 = __webpack_require__(1);
  14724. var ScalarObservable_1 = __webpack_require__(46);
  14725. var EmptyObservable_1 = __webpack_require__(28);
  14726. /**
  14727. * We need this JSDoc comment for affecting ESDoc.
  14728. * @extends {Ignored}
  14729. * @hide true
  14730. */
  14731. var ArrayLikeObservable = (function (_super) {
  14732. __extends(ArrayLikeObservable, _super);
  14733. function ArrayLikeObservable(arrayLike, scheduler) {
  14734. _super.call(this);
  14735. this.arrayLike = arrayLike;
  14736. this.scheduler = scheduler;
  14737. if (!scheduler && arrayLike.length === 1) {
  14738. this._isScalar = true;
  14739. this.value = arrayLike[0];
  14740. }
  14741. }
  14742. ArrayLikeObservable.create = function (arrayLike, scheduler) {
  14743. var length = arrayLike.length;
  14744. if (length === 0) {
  14745. return new EmptyObservable_1.EmptyObservable();
  14746. }
  14747. else if (length === 1) {
  14748. return new ScalarObservable_1.ScalarObservable(arrayLike[0], scheduler);
  14749. }
  14750. else {
  14751. return new ArrayLikeObservable(arrayLike, scheduler);
  14752. }
  14753. };
  14754. ArrayLikeObservable.dispatch = function (state) {
  14755. var arrayLike = state.arrayLike, index = state.index, length = state.length, subscriber = state.subscriber;
  14756. if (subscriber.closed) {
  14757. return;
  14758. }
  14759. if (index >= length) {
  14760. subscriber.complete();
  14761. return;
  14762. }
  14763. subscriber.next(arrayLike[index]);
  14764. state.index = index + 1;
  14765. this.schedule(state);
  14766. };
  14767. /** @deprecated internal use only */ ArrayLikeObservable.prototype._subscribe = function (subscriber) {
  14768. var index = 0;
  14769. var _a = this, arrayLike = _a.arrayLike, scheduler = _a.scheduler;
  14770. var length = arrayLike.length;
  14771. if (scheduler) {
  14772. return scheduler.schedule(ArrayLikeObservable.dispatch, 0, {
  14773. arrayLike: arrayLike, index: index, length: length, subscriber: subscriber
  14774. });
  14775. }
  14776. else {
  14777. for (var i = 0; i < length && !subscriber.closed; i++) {
  14778. subscriber.next(arrayLike[i]);
  14779. }
  14780. subscriber.complete();
  14781. }
  14782. };
  14783. return ArrayLikeObservable;
  14784. }(Observable_1.Observable));
  14785. exports.ArrayLikeObservable = ArrayLikeObservable;
  14786. //# sourceMappingURL=ArrayLikeObservable.js.map
  14787. /***/ }),
  14788. /* 148 */
  14789. /***/ (function(module, exports, __webpack_require__) {
  14790. "use strict";
  14791. var __extends = (this && this.__extends) || function (d, b) {
  14792. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  14793. function __() { this.constructor = d; }
  14794. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14795. };
  14796. var Subscriber_1 = __webpack_require__(3);
  14797. var Notification_1 = __webpack_require__(149);
  14798. /**
  14799. *
  14800. * Re-emits all notifications from source Observable with specified scheduler.
  14801. *
  14802. * <span class="informal">Ensure a specific scheduler is used, from outside of an Observable.</span>
  14803. *
  14804. * `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule
  14805. * notifications emitted by the source Observable. It might be useful, if you do not have control over
  14806. * internal scheduler of a given Observable, but want to control when its values are emitted nevertheless.
  14807. *
  14808. * Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable,
  14809. * but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal
  14810. * scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits
  14811. * notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`.
  14812. * An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split
  14813. * that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source
  14814. * Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a
  14815. * little bit more, to ensure that they are emitted at expected moments.
  14816. *
  14817. * As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications
  14818. * will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn`
  14819. * will delay all notifications - including error notifications - while `delay` will pass through error
  14820. * from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator
  14821. * for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used
  14822. * for notification emissions in general.
  14823. *
  14824. * @example <caption>Ensure values in subscribe are called just before browser repaint.</caption>
  14825. * const intervals = Rx.Observable.interval(10); // Intervals are scheduled
  14826. * // with async scheduler by default...
  14827. *
  14828. * intervals
  14829. * .observeOn(Rx.Scheduler.animationFrame) // ...but we will observe on animationFrame
  14830. * .subscribe(val => { // scheduler to ensure smooth animation.
  14831. * someDiv.style.height = val + 'px';
  14832. * });
  14833. *
  14834. * @see {@link delay}
  14835. *
  14836. * @param {IScheduler} scheduler Scheduler that will be used to reschedule notifications from source Observable.
  14837. * @param {number} [delay] Number of milliseconds that states with what delay every notification should be rescheduled.
  14838. * @return {Observable<T>} Observable that emits the same notifications as the source Observable,
  14839. * but with provided scheduler.
  14840. *
  14841. * @method observeOn
  14842. * @owner Observable
  14843. */
  14844. function observeOn(scheduler, delay) {
  14845. if (delay === void 0) { delay = 0; }
  14846. return function observeOnOperatorFunction(source) {
  14847. return source.lift(new ObserveOnOperator(scheduler, delay));
  14848. };
  14849. }
  14850. exports.observeOn = observeOn;
  14851. var ObserveOnOperator = (function () {
  14852. function ObserveOnOperator(scheduler, delay) {
  14853. if (delay === void 0) { delay = 0; }
  14854. this.scheduler = scheduler;
  14855. this.delay = delay;
  14856. }
  14857. ObserveOnOperator.prototype.call = function (subscriber, source) {
  14858. return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
  14859. };
  14860. return ObserveOnOperator;
  14861. }());
  14862. exports.ObserveOnOperator = ObserveOnOperator;
  14863. /**
  14864. * We need this JSDoc comment for affecting ESDoc.
  14865. * @ignore
  14866. * @extends {Ignored}
  14867. */
  14868. var ObserveOnSubscriber = (function (_super) {
  14869. __extends(ObserveOnSubscriber, _super);
  14870. function ObserveOnSubscriber(destination, scheduler, delay) {
  14871. if (delay === void 0) { delay = 0; }
  14872. _super.call(this, destination);
  14873. this.scheduler = scheduler;
  14874. this.delay = delay;
  14875. }
  14876. ObserveOnSubscriber.dispatch = function (arg) {
  14877. var notification = arg.notification, destination = arg.destination;
  14878. notification.observe(destination);
  14879. this.unsubscribe();
  14880. };
  14881. ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
  14882. this.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
  14883. };
  14884. ObserveOnSubscriber.prototype._next = function (value) {
  14885. this.scheduleMessage(Notification_1.Notification.createNext(value));
  14886. };
  14887. ObserveOnSubscriber.prototype._error = function (err) {
  14888. this.scheduleMessage(Notification_1.Notification.createError(err));
  14889. };
  14890. ObserveOnSubscriber.prototype._complete = function () {
  14891. this.scheduleMessage(Notification_1.Notification.createComplete());
  14892. };
  14893. return ObserveOnSubscriber;
  14894. }(Subscriber_1.Subscriber));
  14895. exports.ObserveOnSubscriber = ObserveOnSubscriber;
  14896. var ObserveOnMessage = (function () {
  14897. function ObserveOnMessage(notification, destination) {
  14898. this.notification = notification;
  14899. this.destination = destination;
  14900. }
  14901. return ObserveOnMessage;
  14902. }());
  14903. exports.ObserveOnMessage = ObserveOnMessage;
  14904. //# sourceMappingURL=observeOn.js.map
  14905. /***/ }),
  14906. /* 149 */
  14907. /***/ (function(module, exports, __webpack_require__) {
  14908. "use strict";
  14909. var Observable_1 = __webpack_require__(1);
  14910. /**
  14911. * Represents a push-based event or value that an {@link Observable} can emit.
  14912. * This class is particularly useful for operators that manage notifications,
  14913. * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and
  14914. * others. Besides wrapping the actual delivered value, it also annotates it
  14915. * with metadata of, for instance, what type of push message it is (`next`,
  14916. * `error`, or `complete`).
  14917. *
  14918. * @see {@link materialize}
  14919. * @see {@link dematerialize}
  14920. * @see {@link observeOn}
  14921. *
  14922. * @class Notification<T>
  14923. */
  14924. var Notification = (function () {
  14925. function Notification(kind, value, error) {
  14926. this.kind = kind;
  14927. this.value = value;
  14928. this.error = error;
  14929. this.hasValue = kind === 'N';
  14930. }
  14931. /**
  14932. * Delivers to the given `observer` the value wrapped by this Notification.
  14933. * @param {Observer} observer
  14934. * @return
  14935. */
  14936. Notification.prototype.observe = function (observer) {
  14937. switch (this.kind) {
  14938. case 'N':
  14939. return observer.next && observer.next(this.value);
  14940. case 'E':
  14941. return observer.error && observer.error(this.error);
  14942. case 'C':
  14943. return observer.complete && observer.complete();
  14944. }
  14945. };
  14946. /**
  14947. * Given some {@link Observer} callbacks, deliver the value represented by the
  14948. * current Notification to the correctly corresponding callback.
  14949. * @param {function(value: T): void} next An Observer `next` callback.
  14950. * @param {function(err: any): void} [error] An Observer `error` callback.
  14951. * @param {function(): void} [complete] An Observer `complete` callback.
  14952. * @return {any}
  14953. */
  14954. Notification.prototype.do = function (next, error, complete) {
  14955. var kind = this.kind;
  14956. switch (kind) {
  14957. case 'N':
  14958. return next && next(this.value);
  14959. case 'E':
  14960. return error && error(this.error);
  14961. case 'C':
  14962. return complete && complete();
  14963. }
  14964. };
  14965. /**
  14966. * Takes an Observer or its individual callback functions, and calls `observe`
  14967. * or `do` methods accordingly.
  14968. * @param {Observer|function(value: T): void} nextOrObserver An Observer or
  14969. * the `next` callback.
  14970. * @param {function(err: any): void} [error] An Observer `error` callback.
  14971. * @param {function(): void} [complete] An Observer `complete` callback.
  14972. * @return {any}
  14973. */
  14974. Notification.prototype.accept = function (nextOrObserver, error, complete) {
  14975. if (nextOrObserver && typeof nextOrObserver.next === 'function') {
  14976. return this.observe(nextOrObserver);
  14977. }
  14978. else {
  14979. return this.do(nextOrObserver, error, complete);
  14980. }
  14981. };
  14982. /**
  14983. * Returns a simple Observable that just delivers the notification represented
  14984. * by this Notification instance.
  14985. * @return {any}
  14986. */
  14987. Notification.prototype.toObservable = function () {
  14988. var kind = this.kind;
  14989. switch (kind) {
  14990. case 'N':
  14991. return Observable_1.Observable.of(this.value);
  14992. case 'E':
  14993. return Observable_1.Observable.throw(this.error);
  14994. case 'C':
  14995. return Observable_1.Observable.empty();
  14996. }
  14997. throw new Error('unexpected notification kind value');
  14998. };
  14999. /**
  15000. * A shortcut to create a Notification instance of the type `next` from a
  15001. * given value.
  15002. * @param {T} value The `next` value.
  15003. * @return {Notification<T>} The "next" Notification representing the
  15004. * argument.
  15005. */
  15006. Notification.createNext = function (value) {
  15007. if (typeof value !== 'undefined') {
  15008. return new Notification('N', value);
  15009. }
  15010. return Notification.undefinedValueNotification;
  15011. };
  15012. /**
  15013. * A shortcut to create a Notification instance of the type `error` from a
  15014. * given error.
  15015. * @param {any} [err] The `error` error.
  15016. * @return {Notification<T>} The "error" Notification representing the
  15017. * argument.
  15018. */
  15019. Notification.createError = function (err) {
  15020. return new Notification('E', undefined, err);
  15021. };
  15022. /**
  15023. * A shortcut to create a Notification instance of the type `complete`.
  15024. * @return {Notification<any>} The valueless "complete" Notification.
  15025. */
  15026. Notification.createComplete = function () {
  15027. return Notification.completeNotification;
  15028. };
  15029. Notification.completeNotification = new Notification('C');
  15030. Notification.undefinedValueNotification = new Notification('N', undefined);
  15031. return Notification;
  15032. }());
  15033. exports.Notification = Notification;
  15034. //# sourceMappingURL=Notification.js.map
  15035. /***/ }),
  15036. /* 150 */
  15037. /***/ (function(module, exports, __webpack_require__) {
  15038. "use strict";
  15039. var mergeAll_1 = __webpack_require__(55);
  15040. /**
  15041. * Converts a higher-order Observable into a first-order Observable by
  15042. * concatenating the inner Observables in order.
  15043. *
  15044. * <span class="informal">Flattens an Observable-of-Observables by putting one
  15045. * inner Observable after the other.</span>
  15046. *
  15047. * <img src="./img/concatAll.png" width="100%">
  15048. *
  15049. * Joins every Observable emitted by the source (a higher-order Observable), in
  15050. * a serial fashion. It subscribes to each inner Observable only after the
  15051. * previous inner Observable has completed, and merges all of their values into
  15052. * the returned observable.
  15053. *
  15054. * __Warning:__ If the source Observable emits Observables quickly and
  15055. * endlessly, and the inner Observables it emits generally complete slower than
  15056. * the source emits, you can run into memory issues as the incoming Observables
  15057. * collect in an unbounded buffer.
  15058. *
  15059. * Note: `concatAll` is equivalent to `mergeAll` with concurrency parameter set
  15060. * to `1`.
  15061. *
  15062. * @example <caption>For each click event, tick every second from 0 to 3, with no concurrency</caption>
  15063. * var clicks = Rx.Observable.fromEvent(document, 'click');
  15064. * var higherOrder = clicks.map(ev => Rx.Observable.interval(1000).take(4));
  15065. * var firstOrder = higherOrder.concatAll();
  15066. * firstOrder.subscribe(x => console.log(x));
  15067. *
  15068. * // Results in the following:
  15069. * // (results are not concurrent)
  15070. * // For every click on the "document" it will emit values 0 to 3 spaced
  15071. * // on a 1000ms interval
  15072. * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3
  15073. *
  15074. * @see {@link combineAll}
  15075. * @see {@link concat}
  15076. * @see {@link concatMap}
  15077. * @see {@link concatMapTo}
  15078. * @see {@link exhaust}
  15079. * @see {@link mergeAll}
  15080. * @see {@link switch}
  15081. * @see {@link zipAll}
  15082. *
  15083. * @return {Observable} An Observable emitting values from all the inner
  15084. * Observables concatenated.
  15085. * @method concatAll
  15086. * @owner Observable
  15087. */
  15088. function concatAll() {
  15089. return mergeAll_1.mergeAll(1);
  15090. }
  15091. exports.concatAll = concatAll;
  15092. //# sourceMappingURL=concatAll.js.map
  15093. /***/ }),
  15094. /* 151 */
  15095. /***/ (function(module, exports, __webpack_require__) {
  15096. "use strict";
  15097. function identity(x) {
  15098. return x;
  15099. }
  15100. exports.identity = identity;
  15101. //# sourceMappingURL=identity.js.map
  15102. /***/ }),
  15103. /* 152 */
  15104. /***/ (function(module, exports, __webpack_require__) {
  15105. "use strict";
  15106. var ArrayObservable_1 = __webpack_require__(23);
  15107. var ScalarObservable_1 = __webpack_require__(46);
  15108. var EmptyObservable_1 = __webpack_require__(28);
  15109. var concat_1 = __webpack_require__(54);
  15110. var isScheduler_1 = __webpack_require__(25);
  15111. /* tslint:enable:max-line-length */
  15112. /**
  15113. * Returns an Observable that emits the items you specify as arguments before it begins to emit
  15114. * items emitted by the source Observable.
  15115. *
  15116. * <img src="./img/startWith.png" width="100%">
  15117. *
  15118. * @param {...T} values - Items you want the modified Observable to emit first.
  15119. * @param {Scheduler} [scheduler] - A {@link IScheduler} to use for scheduling
  15120. * the emissions of the `next` notifications.
  15121. * @return {Observable} An Observable that emits the items in the specified Iterable and then emits the items
  15122. * emitted by the source Observable.
  15123. * @method startWith
  15124. * @owner Observable
  15125. */
  15126. function startWith() {
  15127. var array = [];
  15128. for (var _i = 0; _i < arguments.length; _i++) {
  15129. array[_i - 0] = arguments[_i];
  15130. }
  15131. return function (source) {
  15132. var scheduler = array[array.length - 1];
  15133. if (isScheduler_1.isScheduler(scheduler)) {
  15134. array.pop();
  15135. }
  15136. else {
  15137. scheduler = null;
  15138. }
  15139. var len = array.length;
  15140. if (len === 1) {
  15141. return concat_1.concat(new ScalarObservable_1.ScalarObservable(array[0], scheduler), source);
  15142. }
  15143. else if (len > 1) {
  15144. return concat_1.concat(new ArrayObservable_1.ArrayObservable(array, scheduler), source);
  15145. }
  15146. else {
  15147. return concat_1.concat(new EmptyObservable_1.EmptyObservable(scheduler), source);
  15148. }
  15149. };
  15150. }
  15151. exports.startWith = startWith;
  15152. //# sourceMappingURL=startWith.js.map
  15153. /***/ }),
  15154. /* 153 */
  15155. /***/ (function(module, exports, __webpack_require__) {
  15156. "use strict";
  15157. Object.defineProperty(exports, "__esModule", { value: true });
  15158. var pluck_1 = __webpack_require__(6);
  15159. var ignoreElements_1 = __webpack_require__(11);
  15160. var partition_1 = __webpack_require__(154);
  15161. var merge_1 = __webpack_require__(38);
  15162. var browser_utils_1 = __webpack_require__(22);
  15163. var tap_1 = __webpack_require__(5);
  15164. var withLatestFrom_1 = __webpack_require__(0);
  15165. var map_1 = __webpack_require__(2);
  15166. function setScrollEffect(xs, inputs) {
  15167. {
  15168. /**
  15169. * Group the incoming event with window, document & scrollProportionally argument
  15170. */
  15171. var tupleStream$ = xs.pipe(withLatestFrom_1.withLatestFrom(inputs.window$, inputs.document$, inputs.option$.pipe(pluck_1.pluck("scrollProportionally"))));
  15172. /**
  15173. * Split the stream between document scrolls and element scrolls
  15174. */
  15175. var _a = partition_1.partition(function (_a) {
  15176. var event = _a[0];
  15177. return event.tagName === "document";
  15178. })(tupleStream$), document$ = _a[0], element$ = _a[1];
  15179. /**
  15180. * Further split the element scroll between those matching in `scrollElementMapping`
  15181. * and regular element scrolls
  15182. */
  15183. var _b = partition_1.partition(function (_a) {
  15184. var event = _a[0];
  15185. return event.mappingIndex > -1;
  15186. })(element$), mapped$ = _b[0], nonMapped$ = _b[1];
  15187. return merge_1.merge(
  15188. /**
  15189. * Main window scroll
  15190. */
  15191. document$.pipe(tap_1.tap(function (incoming) {
  15192. var event = incoming[0], window = incoming[1], document = incoming[2], scrollProportionally = incoming[3];
  15193. var scrollSpace = browser_utils_1.getDocumentScrollSpace(document);
  15194. if (scrollProportionally) {
  15195. return window.scrollTo(0, scrollSpace.y * event.position.proportional); // % of y axis of scroll to px
  15196. }
  15197. return window.scrollTo(0, event.position.raw.y);
  15198. })),
  15199. /**
  15200. * Regular, non-mapped Element scrolls
  15201. */
  15202. nonMapped$.pipe(tap_1.tap(function (incoming) {
  15203. var event = incoming[0], window = incoming[1], document = incoming[2], scrollProportionally = incoming[3];
  15204. var matchingElements = document.getElementsByTagName(event.tagName);
  15205. if (matchingElements && matchingElements.length) {
  15206. var match = matchingElements[event.index];
  15207. if (match) {
  15208. return scrollElement(match, scrollProportionally, event);
  15209. }
  15210. }
  15211. })),
  15212. /**
  15213. * Element scrolls given in 'scrollElementMapping'
  15214. */
  15215. mapped$.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("scrollElementMapping"))),
  15216. /**
  15217. * Filter the elements in the option `scrollElementMapping` so
  15218. * that it does not contain the element that triggered the event
  15219. */
  15220. map_1.map(function (_a) {
  15221. var incoming = _a[0], scrollElementMapping = _a[1];
  15222. var event = incoming[0];
  15223. return [
  15224. incoming,
  15225. scrollElementMapping.filter(function (item, index) { return index !== event.mappingIndex; })
  15226. ];
  15227. }),
  15228. /**
  15229. * Now perform the scroll on all other matching elements
  15230. */
  15231. tap_1.tap(function (_a) {
  15232. var incoming = _a[0], scrollElementMapping = _a[1];
  15233. var event = incoming[0], window = incoming[1], document = incoming[2], scrollProportionally = incoming[3];
  15234. scrollElementMapping
  15235. .map(function (selector) { return document.querySelector(selector); })
  15236. .forEach(function (element) {
  15237. scrollElement(element, scrollProportionally, event);
  15238. });
  15239. }))).pipe(ignoreElements_1.ignoreElements());
  15240. }
  15241. }
  15242. exports.setScrollEffect = setScrollEffect;
  15243. function scrollElement(element, scrollProportionally, event) {
  15244. if (scrollProportionally && element.scrollTo) {
  15245. return element.scrollTo(0, element.scrollHeight * event.position.proportional); // % of y axis of scroll to px
  15246. }
  15247. return element.scrollTo(0, event.position.raw.y);
  15248. }
  15249. /***/ }),
  15250. /* 154 */
  15251. /***/ (function(module, exports, __webpack_require__) {
  15252. "use strict";
  15253. var not_1 = __webpack_require__(155);
  15254. var filter_1 = __webpack_require__(4);
  15255. /**
  15256. * Splits the source Observable into two, one with values that satisfy a
  15257. * predicate, and another with values that don't satisfy the predicate.
  15258. *
  15259. * <span class="informal">It's like {@link filter}, but returns two Observables:
  15260. * one like the output of {@link filter}, and the other with values that did not
  15261. * pass the condition.</span>
  15262. *
  15263. * <img src="./img/partition.png" width="100%">
  15264. *
  15265. * `partition` outputs an array with two Observables that partition the values
  15266. * from the source Observable through the given `predicate` function. The first
  15267. * Observable in that array emits source values for which the predicate argument
  15268. * returns true. The second Observable emits source values for which the
  15269. * predicate returns false. The first behaves like {@link filter} and the second
  15270. * behaves like {@link filter} with the predicate negated.
  15271. *
  15272. * @example <caption>Partition click events into those on DIV elements and those elsewhere</caption>
  15273. * var clicks = Rx.Observable.fromEvent(document, 'click');
  15274. * var parts = clicks.partition(ev => ev.target.tagName === 'DIV');
  15275. * var clicksOnDivs = parts[0];
  15276. * var clicksElsewhere = parts[1];
  15277. * clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x));
  15278. * clicksElsewhere.subscribe(x => console.log('Other clicked: ', x));
  15279. *
  15280. * @see {@link filter}
  15281. *
  15282. * @param {function(value: T, index: number): boolean} predicate A function that
  15283. * evaluates each value emitted by the source Observable. If it returns `true`,
  15284. * the value is emitted on the first Observable in the returned array, if
  15285. * `false` the value is emitted on the second Observable in the array. The
  15286. * `index` parameter is the number `i` for the i-th source emission that has
  15287. * happened since the subscription, starting from the number `0`.
  15288. * @param {any} [thisArg] An optional argument to determine the value of `this`
  15289. * in the `predicate` function.
  15290. * @return {[Observable<T>, Observable<T>]} An array with two Observables: one
  15291. * with values that passed the predicate, and another with values that did not
  15292. * pass the predicate.
  15293. * @method partition
  15294. * @owner Observable
  15295. */
  15296. function partition(predicate, thisArg) {
  15297. return function (source) { return [
  15298. filter_1.filter(predicate, thisArg)(source),
  15299. filter_1.filter(not_1.not(predicate, thisArg))(source)
  15300. ]; };
  15301. }
  15302. exports.partition = partition;
  15303. //# sourceMappingURL=partition.js.map
  15304. /***/ }),
  15305. /* 155 */
  15306. /***/ (function(module, exports, __webpack_require__) {
  15307. "use strict";
  15308. function not(pred, thisArg) {
  15309. function notPred() {
  15310. return !(notPred.pred.apply(notPred.thisArg, arguments));
  15311. }
  15312. notPred.pred = pred;
  15313. notPred.thisArg = thisArg;
  15314. return notPred;
  15315. }
  15316. exports.not = not;
  15317. //# sourceMappingURL=not.js.map
  15318. /***/ }),
  15319. /* 156 */
  15320. /***/ (function(module, exports, __webpack_require__) {
  15321. "use strict";
  15322. Object.defineProperty(exports, "__esModule", { value: true });
  15323. var map_1 = __webpack_require__(2);
  15324. var Log = __webpack_require__(14);
  15325. function incomingBrowserNotify(xs) {
  15326. return xs.pipe(map_1.map(function (event) { return Log.overlayInfo(event.message, event.timeout); }));
  15327. }
  15328. exports.incomingBrowserNotify = incomingBrowserNotify;
  15329. /***/ }),
  15330. /* 157 */
  15331. /***/ (function(module, exports, __webpack_require__) {
  15332. "use strict";
  15333. Object.defineProperty(exports, "__esModule", { value: true });
  15334. var pluck_1 = __webpack_require__(6);
  15335. var filter_1 = __webpack_require__(4);
  15336. var map_1 = __webpack_require__(2);
  15337. var withLatestFrom_1 = __webpack_require__(0);
  15338. var browser_set_location_effect_1 = __webpack_require__(89);
  15339. function incomingBrowserLocation(xs, inputs) {
  15340. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("ghostMode", "location"))), filter_1.filter(function (_a) {
  15341. var canSyncLocation = _a[1];
  15342. return canSyncLocation === true;
  15343. }), map_1.map(function (_a) {
  15344. var event = _a[0];
  15345. return browser_set_location_effect_1.browserSetLocation(event);
  15346. }));
  15347. }
  15348. exports.incomingBrowserLocation = incomingBrowserLocation;
  15349. /***/ }),
  15350. /* 158 */
  15351. /***/ (function(module, exports, __webpack_require__) {
  15352. "use strict";
  15353. var SubscribeOnObservable_1 = __webpack_require__(159);
  15354. /**
  15355. * Asynchronously subscribes Observers to this Observable on the specified IScheduler.
  15356. *
  15357. * <img src="./img/subscribeOn.png" width="100%">
  15358. *
  15359. * @param {Scheduler} scheduler - The IScheduler to perform subscription actions on.
  15360. * @return {Observable<T>} The source Observable modified so that its subscriptions happen on the specified IScheduler.
  15361. .
  15362. * @method subscribeOn
  15363. * @owner Observable
  15364. */
  15365. function subscribeOn(scheduler, delay) {
  15366. if (delay === void 0) { delay = 0; }
  15367. return function subscribeOnOperatorFunction(source) {
  15368. return source.lift(new SubscribeOnOperator(scheduler, delay));
  15369. };
  15370. }
  15371. exports.subscribeOn = subscribeOn;
  15372. var SubscribeOnOperator = (function () {
  15373. function SubscribeOnOperator(scheduler, delay) {
  15374. this.scheduler = scheduler;
  15375. this.delay = delay;
  15376. }
  15377. SubscribeOnOperator.prototype.call = function (subscriber, source) {
  15378. return new SubscribeOnObservable_1.SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
  15379. };
  15380. return SubscribeOnOperator;
  15381. }());
  15382. //# sourceMappingURL=subscribeOn.js.map
  15383. /***/ }),
  15384. /* 159 */
  15385. /***/ (function(module, exports, __webpack_require__) {
  15386. "use strict";
  15387. var __extends = (this && this.__extends) || function (d, b) {
  15388. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  15389. function __() { this.constructor = d; }
  15390. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15391. };
  15392. var Observable_1 = __webpack_require__(1);
  15393. var asap_1 = __webpack_require__(160);
  15394. var isNumeric_1 = __webpack_require__(77);
  15395. /**
  15396. * We need this JSDoc comment for affecting ESDoc.
  15397. * @extends {Ignored}
  15398. * @hide true
  15399. */
  15400. var SubscribeOnObservable = (function (_super) {
  15401. __extends(SubscribeOnObservable, _super);
  15402. function SubscribeOnObservable(source, delayTime, scheduler) {
  15403. if (delayTime === void 0) { delayTime = 0; }
  15404. if (scheduler === void 0) { scheduler = asap_1.asap; }
  15405. _super.call(this);
  15406. this.source = source;
  15407. this.delayTime = delayTime;
  15408. this.scheduler = scheduler;
  15409. if (!isNumeric_1.isNumeric(delayTime) || delayTime < 0) {
  15410. this.delayTime = 0;
  15411. }
  15412. if (!scheduler || typeof scheduler.schedule !== 'function') {
  15413. this.scheduler = asap_1.asap;
  15414. }
  15415. }
  15416. SubscribeOnObservable.create = function (source, delay, scheduler) {
  15417. if (delay === void 0) { delay = 0; }
  15418. if (scheduler === void 0) { scheduler = asap_1.asap; }
  15419. return new SubscribeOnObservable(source, delay, scheduler);
  15420. };
  15421. SubscribeOnObservable.dispatch = function (arg) {
  15422. var source = arg.source, subscriber = arg.subscriber;
  15423. return this.add(source.subscribe(subscriber));
  15424. };
  15425. /** @deprecated internal use only */ SubscribeOnObservable.prototype._subscribe = function (subscriber) {
  15426. var delay = this.delayTime;
  15427. var source = this.source;
  15428. var scheduler = this.scheduler;
  15429. return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
  15430. source: source, subscriber: subscriber
  15431. });
  15432. };
  15433. return SubscribeOnObservable;
  15434. }(Observable_1.Observable));
  15435. exports.SubscribeOnObservable = SubscribeOnObservable;
  15436. //# sourceMappingURL=SubscribeOnObservable.js.map
  15437. /***/ }),
  15438. /* 160 */
  15439. /***/ (function(module, exports, __webpack_require__) {
  15440. "use strict";
  15441. var AsapAction_1 = __webpack_require__(161);
  15442. var AsapScheduler_1 = __webpack_require__(164);
  15443. /**
  15444. *
  15445. * Asap Scheduler
  15446. *
  15447. * <span class="informal">Perform task as fast as it can be performed asynchronously</span>
  15448. *
  15449. * `asap` scheduler behaves the same as {@link async} scheduler when you use it to delay task
  15450. * in time. If however you set delay to `0`, `asap` will wait for current synchronously executing
  15451. * code to end and then it will try to execute given task as fast as possible.
  15452. *
  15453. * `asap` scheduler will do its best to minimize time between end of currently executing code
  15454. * and start of scheduled task. This makes it best candidate for performing so called "deferring".
  15455. * Traditionally this was achieved by calling `setTimeout(deferredTask, 0)`, but that technique involves
  15456. * some (although minimal) unwanted delay.
  15457. *
  15458. * Note that using `asap` scheduler does not necessarily mean that your task will be first to process
  15459. * after currently executing code. In particular, if some task was also scheduled with `asap` before,
  15460. * that task will execute first. That being said, if you need to schedule task asynchronously, but
  15461. * as soon as possible, `asap` scheduler is your best bet.
  15462. *
  15463. * @example <caption>Compare async and asap scheduler</caption>
  15464. *
  15465. * Rx.Scheduler.async.schedule(() => console.log('async')); // scheduling 'async' first...
  15466. * Rx.Scheduler.asap.schedule(() => console.log('asap'));
  15467. *
  15468. * // Logs:
  15469. * // "asap"
  15470. * // "async"
  15471. * // ... but 'asap' goes first!
  15472. *
  15473. * @static true
  15474. * @name asap
  15475. * @owner Scheduler
  15476. */
  15477. exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction);
  15478. //# sourceMappingURL=asap.js.map
  15479. /***/ }),
  15480. /* 161 */
  15481. /***/ (function(module, exports, __webpack_require__) {
  15482. "use strict";
  15483. var __extends = (this && this.__extends) || function (d, b) {
  15484. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  15485. function __() { this.constructor = d; }
  15486. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15487. };
  15488. var Immediate_1 = __webpack_require__(162);
  15489. var AsyncAction_1 = __webpack_require__(79);
  15490. /**
  15491. * We need this JSDoc comment for affecting ESDoc.
  15492. * @ignore
  15493. * @extends {Ignored}
  15494. */
  15495. var AsapAction = (function (_super) {
  15496. __extends(AsapAction, _super);
  15497. function AsapAction(scheduler, work) {
  15498. _super.call(this, scheduler, work);
  15499. this.scheduler = scheduler;
  15500. this.work = work;
  15501. }
  15502. AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  15503. if (delay === void 0) { delay = 0; }
  15504. // If delay is greater than 0, request as an async action.
  15505. if (delay !== null && delay > 0) {
  15506. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  15507. }
  15508. // Push the action to the end of the scheduler queue.
  15509. scheduler.actions.push(this);
  15510. // If a microtask has already been scheduled, don't schedule another
  15511. // one. If a microtask hasn't been scheduled yet, schedule one now. Return
  15512. // the current scheduled microtask id.
  15513. return scheduler.scheduled || (scheduler.scheduled = Immediate_1.Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
  15514. };
  15515. AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  15516. if (delay === void 0) { delay = 0; }
  15517. // If delay exists and is greater than 0, or if the delay is null (the
  15518. // action wasn't rescheduled) but was originally scheduled as an async
  15519. // action, then recycle as an async action.
  15520. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  15521. return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
  15522. }
  15523. // If the scheduler queue is empty, cancel the requested microtask and
  15524. // set the scheduled flag to undefined so the next AsapAction will schedule
  15525. // its own.
  15526. if (scheduler.actions.length === 0) {
  15527. Immediate_1.Immediate.clearImmediate(id);
  15528. scheduler.scheduled = undefined;
  15529. }
  15530. // Return undefined so the action knows to request a new async id if it's rescheduled.
  15531. return undefined;
  15532. };
  15533. return AsapAction;
  15534. }(AsyncAction_1.AsyncAction));
  15535. exports.AsapAction = AsapAction;
  15536. //# sourceMappingURL=AsapAction.js.map
  15537. /***/ }),
  15538. /* 162 */
  15539. /***/ (function(module, exports, __webpack_require__) {
  15540. "use strict";
  15541. /* WEBPACK VAR INJECTION */(function(clearImmediate, setImmediate) {/**
  15542. Some credit for this helper goes to http://github.com/YuzuJS/setImmediate
  15543. */
  15544. var root_1 = __webpack_require__(7);
  15545. var ImmediateDefinition = (function () {
  15546. function ImmediateDefinition(root) {
  15547. this.root = root;
  15548. if (root.setImmediate && typeof root.setImmediate === 'function') {
  15549. this.setImmediate = root.setImmediate.bind(root);
  15550. this.clearImmediate = root.clearImmediate.bind(root);
  15551. }
  15552. else {
  15553. this.nextHandle = 1;
  15554. this.tasksByHandle = {};
  15555. this.currentlyRunningATask = false;
  15556. // Don't get fooled by e.g. browserify environments.
  15557. if (this.canUseProcessNextTick()) {
  15558. // For Node.js before 0.9
  15559. this.setImmediate = this.createProcessNextTickSetImmediate();
  15560. }
  15561. else if (this.canUsePostMessage()) {
  15562. // For non-IE10 modern browsers
  15563. this.setImmediate = this.createPostMessageSetImmediate();
  15564. }
  15565. else if (this.canUseMessageChannel()) {
  15566. // For web workers, where supported
  15567. this.setImmediate = this.createMessageChannelSetImmediate();
  15568. }
  15569. else if (this.canUseReadyStateChange()) {
  15570. // For IE 6–8
  15571. this.setImmediate = this.createReadyStateChangeSetImmediate();
  15572. }
  15573. else {
  15574. // For older browsers
  15575. this.setImmediate = this.createSetTimeoutSetImmediate();
  15576. }
  15577. var ci = function clearImmediate(handle) {
  15578. delete clearImmediate.instance.tasksByHandle[handle];
  15579. };
  15580. ci.instance = this;
  15581. this.clearImmediate = ci;
  15582. }
  15583. }
  15584. ImmediateDefinition.prototype.identify = function (o) {
  15585. return this.root.Object.prototype.toString.call(o);
  15586. };
  15587. ImmediateDefinition.prototype.canUseProcessNextTick = function () {
  15588. return this.identify(this.root.process) === '[object process]';
  15589. };
  15590. ImmediateDefinition.prototype.canUseMessageChannel = function () {
  15591. return Boolean(this.root.MessageChannel);
  15592. };
  15593. ImmediateDefinition.prototype.canUseReadyStateChange = function () {
  15594. var document = this.root.document;
  15595. return Boolean(document && 'onreadystatechange' in document.createElement('script'));
  15596. };
  15597. ImmediateDefinition.prototype.canUsePostMessage = function () {
  15598. var root = this.root;
  15599. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  15600. // where `root.postMessage` means something completely different and can't be used for this purpose.
  15601. if (root.postMessage && !root.importScripts) {
  15602. var postMessageIsAsynchronous_1 = true;
  15603. var oldOnMessage = root.onmessage;
  15604. root.onmessage = function () {
  15605. postMessageIsAsynchronous_1 = false;
  15606. };
  15607. root.postMessage('', '*');
  15608. root.onmessage = oldOnMessage;
  15609. return postMessageIsAsynchronous_1;
  15610. }
  15611. return false;
  15612. };
  15613. // This function accepts the same arguments as setImmediate, but
  15614. // returns a function that requires no arguments.
  15615. ImmediateDefinition.prototype.partiallyApplied = function (handler) {
  15616. var args = [];
  15617. for (var _i = 1; _i < arguments.length; _i++) {
  15618. args[_i - 1] = arguments[_i];
  15619. }
  15620. var fn = function result() {
  15621. var _a = result, handler = _a.handler, args = _a.args;
  15622. if (typeof handler === 'function') {
  15623. handler.apply(undefined, args);
  15624. }
  15625. else {
  15626. (new Function('' + handler))();
  15627. }
  15628. };
  15629. fn.handler = handler;
  15630. fn.args = args;
  15631. return fn;
  15632. };
  15633. ImmediateDefinition.prototype.addFromSetImmediateArguments = function (args) {
  15634. this.tasksByHandle[this.nextHandle] = this.partiallyApplied.apply(undefined, args);
  15635. return this.nextHandle++;
  15636. };
  15637. ImmediateDefinition.prototype.createProcessNextTickSetImmediate = function () {
  15638. var fn = function setImmediate() {
  15639. var instance = setImmediate.instance;
  15640. var handle = instance.addFromSetImmediateArguments(arguments);
  15641. instance.root.process.nextTick(instance.partiallyApplied(instance.runIfPresent, handle));
  15642. return handle;
  15643. };
  15644. fn.instance = this;
  15645. return fn;
  15646. };
  15647. ImmediateDefinition.prototype.createPostMessageSetImmediate = function () {
  15648. // Installs an event handler on `global` for the `message` event: see
  15649. // * https://developer.mozilla.org/en/DOM/window.postMessage
  15650. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  15651. var root = this.root;
  15652. var messagePrefix = 'setImmediate$' + root.Math.random() + '$';
  15653. var onGlobalMessage = function globalMessageHandler(event) {
  15654. var instance = globalMessageHandler.instance;
  15655. if (event.source === root &&
  15656. typeof event.data === 'string' &&
  15657. event.data.indexOf(messagePrefix) === 0) {
  15658. instance.runIfPresent(+event.data.slice(messagePrefix.length));
  15659. }
  15660. };
  15661. onGlobalMessage.instance = this;
  15662. root.addEventListener('message', onGlobalMessage, false);
  15663. var fn = function setImmediate() {
  15664. var _a = setImmediate, messagePrefix = _a.messagePrefix, instance = _a.instance;
  15665. var handle = instance.addFromSetImmediateArguments(arguments);
  15666. instance.root.postMessage(messagePrefix + handle, '*');
  15667. return handle;
  15668. };
  15669. fn.instance = this;
  15670. fn.messagePrefix = messagePrefix;
  15671. return fn;
  15672. };
  15673. ImmediateDefinition.prototype.runIfPresent = function (handle) {
  15674. // From the spec: 'Wait until any invocations of this algorithm started before this one have completed.'
  15675. // So if we're currently running a task, we'll need to delay this invocation.
  15676. if (this.currentlyRunningATask) {
  15677. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  15678. // 'too much recursion' error.
  15679. this.root.setTimeout(this.partiallyApplied(this.runIfPresent, handle), 0);
  15680. }
  15681. else {
  15682. var task = this.tasksByHandle[handle];
  15683. if (task) {
  15684. this.currentlyRunningATask = true;
  15685. try {
  15686. task();
  15687. }
  15688. finally {
  15689. this.clearImmediate(handle);
  15690. this.currentlyRunningATask = false;
  15691. }
  15692. }
  15693. }
  15694. };
  15695. ImmediateDefinition.prototype.createMessageChannelSetImmediate = function () {
  15696. var _this = this;
  15697. var channel = new this.root.MessageChannel();
  15698. channel.port1.onmessage = function (event) {
  15699. var handle = event.data;
  15700. _this.runIfPresent(handle);
  15701. };
  15702. var fn = function setImmediate() {
  15703. var _a = setImmediate, channel = _a.channel, instance = _a.instance;
  15704. var handle = instance.addFromSetImmediateArguments(arguments);
  15705. channel.port2.postMessage(handle);
  15706. return handle;
  15707. };
  15708. fn.channel = channel;
  15709. fn.instance = this;
  15710. return fn;
  15711. };
  15712. ImmediateDefinition.prototype.createReadyStateChangeSetImmediate = function () {
  15713. var fn = function setImmediate() {
  15714. var instance = setImmediate.instance;
  15715. var root = instance.root;
  15716. var doc = root.document;
  15717. var html = doc.documentElement;
  15718. var handle = instance.addFromSetImmediateArguments(arguments);
  15719. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  15720. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  15721. var script = doc.createElement('script');
  15722. script.onreadystatechange = function () {
  15723. instance.runIfPresent(handle);
  15724. script.onreadystatechange = null;
  15725. html.removeChild(script);
  15726. script = null;
  15727. };
  15728. html.appendChild(script);
  15729. return handle;
  15730. };
  15731. fn.instance = this;
  15732. return fn;
  15733. };
  15734. ImmediateDefinition.prototype.createSetTimeoutSetImmediate = function () {
  15735. var fn = function setImmediate() {
  15736. var instance = setImmediate.instance;
  15737. var handle = instance.addFromSetImmediateArguments(arguments);
  15738. instance.root.setTimeout(instance.partiallyApplied(instance.runIfPresent, handle), 0);
  15739. return handle;
  15740. };
  15741. fn.instance = this;
  15742. return fn;
  15743. };
  15744. return ImmediateDefinition;
  15745. }());
  15746. exports.ImmediateDefinition = ImmediateDefinition;
  15747. exports.Immediate = new ImmediateDefinition(root_1.root);
  15748. //# sourceMappingURL=Immediate.js.map
  15749. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(97).clearImmediate, __webpack_require__(97).setImmediate))
  15750. /***/ }),
  15751. /* 163 */
  15752. /***/ (function(module, exports, __webpack_require__) {
  15753. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  15754. "use strict";
  15755. if (global.setImmediate) {
  15756. return;
  15757. }
  15758. var nextHandle = 1; // Spec says greater than zero
  15759. var tasksByHandle = {};
  15760. var currentlyRunningATask = false;
  15761. var doc = global.document;
  15762. var registerImmediate;
  15763. function setImmediate(callback) {
  15764. // Callback can either be a function or a string
  15765. if (typeof callback !== "function") {
  15766. callback = new Function("" + callback);
  15767. }
  15768. // Copy function arguments
  15769. var args = new Array(arguments.length - 1);
  15770. for (var i = 0; i < args.length; i++) {
  15771. args[i] = arguments[i + 1];
  15772. }
  15773. // Store and register the task
  15774. var task = { callback: callback, args: args };
  15775. tasksByHandle[nextHandle] = task;
  15776. registerImmediate(nextHandle);
  15777. return nextHandle++;
  15778. }
  15779. function clearImmediate(handle) {
  15780. delete tasksByHandle[handle];
  15781. }
  15782. function run(task) {
  15783. var callback = task.callback;
  15784. var args = task.args;
  15785. switch (args.length) {
  15786. case 0:
  15787. callback();
  15788. break;
  15789. case 1:
  15790. callback(args[0]);
  15791. break;
  15792. case 2:
  15793. callback(args[0], args[1]);
  15794. break;
  15795. case 3:
  15796. callback(args[0], args[1], args[2]);
  15797. break;
  15798. default:
  15799. callback.apply(undefined, args);
  15800. break;
  15801. }
  15802. }
  15803. function runIfPresent(handle) {
  15804. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  15805. // So if we're currently running a task, we'll need to delay this invocation.
  15806. if (currentlyRunningATask) {
  15807. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  15808. // "too much recursion" error.
  15809. setTimeout(runIfPresent, 0, handle);
  15810. } else {
  15811. var task = tasksByHandle[handle];
  15812. if (task) {
  15813. currentlyRunningATask = true;
  15814. try {
  15815. run(task);
  15816. } finally {
  15817. clearImmediate(handle);
  15818. currentlyRunningATask = false;
  15819. }
  15820. }
  15821. }
  15822. }
  15823. function installNextTickImplementation() {
  15824. registerImmediate = function(handle) {
  15825. process.nextTick(function () { runIfPresent(handle); });
  15826. };
  15827. }
  15828. function canUsePostMessage() {
  15829. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  15830. // where `global.postMessage` means something completely different and can't be used for this purpose.
  15831. if (global.postMessage && !global.importScripts) {
  15832. var postMessageIsAsynchronous = true;
  15833. var oldOnMessage = global.onmessage;
  15834. global.onmessage = function() {
  15835. postMessageIsAsynchronous = false;
  15836. };
  15837. global.postMessage("", "*");
  15838. global.onmessage = oldOnMessage;
  15839. return postMessageIsAsynchronous;
  15840. }
  15841. }
  15842. function installPostMessageImplementation() {
  15843. // Installs an event handler on `global` for the `message` event: see
  15844. // * https://developer.mozilla.org/en/DOM/window.postMessage
  15845. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  15846. var messagePrefix = "setImmediate$" + Math.random() + "$";
  15847. var onGlobalMessage = function(event) {
  15848. if (event.source === global &&
  15849. typeof event.data === "string" &&
  15850. event.data.indexOf(messagePrefix) === 0) {
  15851. runIfPresent(+event.data.slice(messagePrefix.length));
  15852. }
  15853. };
  15854. if (global.addEventListener) {
  15855. global.addEventListener("message", onGlobalMessage, false);
  15856. } else {
  15857. global.attachEvent("onmessage", onGlobalMessage);
  15858. }
  15859. registerImmediate = function(handle) {
  15860. global.postMessage(messagePrefix + handle, "*");
  15861. };
  15862. }
  15863. function installMessageChannelImplementation() {
  15864. var channel = new MessageChannel();
  15865. channel.port1.onmessage = function(event) {
  15866. var handle = event.data;
  15867. runIfPresent(handle);
  15868. };
  15869. registerImmediate = function(handle) {
  15870. channel.port2.postMessage(handle);
  15871. };
  15872. }
  15873. function installReadyStateChangeImplementation() {
  15874. var html = doc.documentElement;
  15875. registerImmediate = function(handle) {
  15876. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  15877. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  15878. var script = doc.createElement("script");
  15879. script.onreadystatechange = function () {
  15880. runIfPresent(handle);
  15881. script.onreadystatechange = null;
  15882. html.removeChild(script);
  15883. script = null;
  15884. };
  15885. html.appendChild(script);
  15886. };
  15887. }
  15888. function installSetTimeoutImplementation() {
  15889. registerImmediate = function(handle) {
  15890. setTimeout(runIfPresent, 0, handle);
  15891. };
  15892. }
  15893. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  15894. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  15895. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  15896. // Don't get fooled by e.g. browserify environments.
  15897. if ({}.toString.call(global.process) === "[object process]") {
  15898. // For Node.js before 0.9
  15899. installNextTickImplementation();
  15900. } else if (canUsePostMessage()) {
  15901. // For non-IE10 modern browsers
  15902. installPostMessageImplementation();
  15903. } else if (global.MessageChannel) {
  15904. // For web workers, where supported
  15905. installMessageChannelImplementation();
  15906. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  15907. // For IE 6–8
  15908. installReadyStateChangeImplementation();
  15909. } else {
  15910. // For older browsers
  15911. installSetTimeoutImplementation();
  15912. }
  15913. attachTo.setImmediate = setImmediate;
  15914. attachTo.clearImmediate = clearImmediate;
  15915. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  15916. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(24), __webpack_require__(33)))
  15917. /***/ }),
  15918. /* 164 */
  15919. /***/ (function(module, exports, __webpack_require__) {
  15920. "use strict";
  15921. var __extends = (this && this.__extends) || function (d, b) {
  15922. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  15923. function __() { this.constructor = d; }
  15924. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15925. };
  15926. var AsyncScheduler_1 = __webpack_require__(80);
  15927. var AsapScheduler = (function (_super) {
  15928. __extends(AsapScheduler, _super);
  15929. function AsapScheduler() {
  15930. _super.apply(this, arguments);
  15931. }
  15932. AsapScheduler.prototype.flush = function (action) {
  15933. this.active = true;
  15934. this.scheduled = undefined;
  15935. var actions = this.actions;
  15936. var error;
  15937. var index = -1;
  15938. var count = actions.length;
  15939. action = action || actions.shift();
  15940. do {
  15941. if (error = action.execute(action.state, action.delay)) {
  15942. break;
  15943. }
  15944. } while (++index < count && (action = actions.shift()));
  15945. this.active = false;
  15946. if (error) {
  15947. while (++index < count && (action = actions.shift())) {
  15948. action.unsubscribe();
  15949. }
  15950. throw error;
  15951. }
  15952. };
  15953. return AsapScheduler;
  15954. }(AsyncScheduler_1.AsyncScheduler));
  15955. exports.AsapScheduler = AsapScheduler;
  15956. //# sourceMappingURL=AsapScheduler.js.map
  15957. /***/ }),
  15958. /* 165 */
  15959. /***/ (function(module, exports, __webpack_require__) {
  15960. "use strict";
  15961. Object.defineProperty(exports, "__esModule", { value: true });
  15962. var filter_1 = __webpack_require__(4);
  15963. var empty_1 = __webpack_require__(16);
  15964. var utils_1 = __webpack_require__(21);
  15965. var of_1 = __webpack_require__(9);
  15966. var withLatestFrom_1 = __webpack_require__(0);
  15967. var mergeMap_1 = __webpack_require__(15);
  15968. var file_reload_effect_1 = __webpack_require__(86);
  15969. var BrowserReload_1 = __webpack_require__(96);
  15970. function incomingFileReload(xs, inputs) {
  15971. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$), filter_1.filter(function (_a) {
  15972. var event = _a[0], options = _a[1];
  15973. return options.codeSync;
  15974. }), mergeMap_1.mergeMap(function (_a) {
  15975. var event = _a[0], options = _a[1];
  15976. if (event.url || !options.injectChanges) {
  15977. return BrowserReload_1.reloadBrowserSafe();
  15978. }
  15979. if (event.basename && event.ext && utils_1.isBlacklisted(event)) {
  15980. return empty_1.empty();
  15981. }
  15982. return of_1.of(file_reload_effect_1.fileReload(event));
  15983. }));
  15984. }
  15985. exports.incomingFileReload = incomingFileReload;
  15986. /***/ }),
  15987. /* 166 */
  15988. /***/ (function(module, exports, __webpack_require__) {
  15989. "use strict";
  15990. Object.defineProperty(exports, "__esModule", { value: true });
  15991. var pluck_1 = __webpack_require__(6);
  15992. var of_1 = __webpack_require__(9);
  15993. var Log = __webpack_require__(14);
  15994. var withLatestFrom_1 = __webpack_require__(0);
  15995. var mergeMap_1 = __webpack_require__(15);
  15996. var set_options_effect_1 = __webpack_require__(53);
  15997. function incomingConnection(xs, inputs) {
  15998. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.option$.pipe(pluck_1.pluck("logPrefix"))), mergeMap_1.mergeMap(function (_a) {
  15999. var x = _a[0], logPrefix = _a[1];
  16000. var prefix = logPrefix
  16001. ? logPrefix + ": "
  16002. : '';
  16003. return of_1.of(set_options_effect_1.setOptions(x), Log.overlayInfo(prefix + "connected"));
  16004. }));
  16005. }
  16006. exports.incomingConnection = incomingConnection;
  16007. /***/ }),
  16008. /* 167 */
  16009. /***/ (function(module, exports, __webpack_require__) {
  16010. "use strict";
  16011. Object.defineProperty(exports, "__esModule", { value: true });
  16012. var ignoreElements_1 = __webpack_require__(11);
  16013. var tap_1 = __webpack_require__(5);
  16014. function incomingDisconnect(xs) {
  16015. return xs.pipe(tap_1.tap(function (x) { return console.log(x); }), ignoreElements_1.ignoreElements());
  16016. }
  16017. exports.incomingDisconnect = incomingDisconnect;
  16018. /***/ }),
  16019. /* 168 */
  16020. /***/ (function(module, exports, __webpack_require__) {
  16021. "use strict";
  16022. Object.defineProperty(exports, "__esModule", { value: true });
  16023. var map_1 = __webpack_require__(2);
  16024. var set_options_effect_1 = __webpack_require__(53);
  16025. function incomingOptionsSet(xs) {
  16026. return xs.pipe(map_1.map(function (event) { return set_options_effect_1.setOptions(event.options); }));
  16027. }
  16028. exports.incomingOptionsSet = incomingOptionsSet;
  16029. /***/ }),
  16030. /* 169 */
  16031. /***/ (function(module, exports, __webpack_require__) {
  16032. "use strict";
  16033. Object.defineProperty(exports, "__esModule", { value: true });
  16034. var _a;
  16035. var browser_utils_1 = __webpack_require__(22);
  16036. var effects_1 = __webpack_require__(8);
  16037. var BehaviorSubject_1 = __webpack_require__(13);
  16038. var empty_1 = __webpack_require__(16);
  16039. var of_1 = __webpack_require__(9);
  16040. var Log = __webpack_require__(14);
  16041. var withLatestFrom_1 = __webpack_require__(0);
  16042. var map_1 = __webpack_require__(2);
  16043. var set_window_name_dom_effect_1 = __webpack_require__(84);
  16044. var set_scroll_dom_effect_1 = __webpack_require__(83);
  16045. exports.PREFIX = "<<BS_START>>";
  16046. exports.SUFFIX = "<<BS_START>>";
  16047. exports.regex = new RegExp(exports.PREFIX + "(.+?)" + exports.SUFFIX, "g");
  16048. function parseFromString(input) {
  16049. var match;
  16050. var last;
  16051. while ((match = exports.regex.exec(input))) {
  16052. last = match[1];
  16053. }
  16054. if (last) {
  16055. return JSON.parse(last);
  16056. }
  16057. }
  16058. function initWindowName(window) {
  16059. var saved = (function () {
  16060. /**
  16061. * On page load, check window.name for an existing
  16062. * BS json blob & parse it.
  16063. */
  16064. try {
  16065. return parseFromString(window.name);
  16066. }
  16067. catch (e) {
  16068. return {};
  16069. }
  16070. })();
  16071. /**
  16072. * Remove any existing BS json from window.name
  16073. * to ensure we don't interfere with any other
  16074. * libs who may be using it.
  16075. */
  16076. window.name = window.name.replace(exports.regex, "");
  16077. /**
  16078. * If the JSON was parsed correctly, try to
  16079. * find a scroll property and restore it.
  16080. */
  16081. if (saved && saved.bs && saved.bs.hardReload && saved.bs.scroll) {
  16082. var _a = saved.bs.scroll, x = _a.x, y = _a.y;
  16083. return of_1.of(set_scroll_dom_effect_1.setScroll(x, y), Log.consoleDebug("[ScrollRestore] x = " + x + " y = " + y));
  16084. }
  16085. return empty_1.empty();
  16086. }
  16087. exports.initWindowName = initWindowName;
  16088. exports.scrollRestoreHandlers$ = new BehaviorSubject_1.BehaviorSubject((_a = {},
  16089. // [EffectNames.SetOptions]: (xs, inputs: Inputs) => {
  16090. // return xs.pipe(
  16091. // withLatestFrom(inputs.window$),
  16092. // take(1),
  16093. // mergeMap(([options, window]) => {
  16094. // if (options.scrollRestoreTechnique === "window.name") {
  16095. // return initWindowName(window);
  16096. // }
  16097. // return empty();
  16098. // })
  16099. // );
  16100. // },
  16101. /**
  16102. * Save the current scroll position
  16103. * before the browser is reloaded (via window.location.reload(true))
  16104. * @param xs
  16105. * @param {Inputs} inputs
  16106. */
  16107. _a[effects_1.EffectNames.PreBrowserReload] = function (xs, inputs) {
  16108. return xs.pipe(withLatestFrom_1.withLatestFrom(inputs.window$, inputs.document$), map_1.map(function (_a) {
  16109. var window = _a[1], document = _a[2];
  16110. return [
  16111. window.name,
  16112. exports.PREFIX,
  16113. JSON.stringify({
  16114. bs: {
  16115. hardReload: true,
  16116. scroll: browser_utils_1.getBrowserScrollPosition(window, document)
  16117. }
  16118. }),
  16119. exports.SUFFIX
  16120. ].join("");
  16121. }), map_1.map(function (value) { return set_window_name_dom_effect_1.setWindowName(value); }));
  16122. },
  16123. _a));
  16124. /***/ }),
  16125. /* 170 */
  16126. /***/ (function(module, exports, __webpack_require__) {
  16127. "use strict";
  16128. Object.defineProperty(exports, "__esModule", { value: true });
  16129. var merge_1 = __webpack_require__(38);
  16130. var form_inputs_listener_1 = __webpack_require__(171);
  16131. var clicks_listener_1 = __webpack_require__(173);
  16132. var scroll_listener_1 = __webpack_require__(174);
  16133. var form_toggles_listener_1 = __webpack_require__(175);
  16134. function initListeners(window, document, socket$, option$) {
  16135. var merged$ = merge_1.merge(scroll_listener_1.getScrollStream(window, document, socket$, option$), clicks_listener_1.getClickStream(document, socket$, option$), form_inputs_listener_1.getFormInputStream(document, socket$, option$), form_toggles_listener_1.getFormTogglesStream(document, socket$, option$));
  16136. return merged$;
  16137. }
  16138. exports.initListeners = initListeners;
  16139. /***/ }),
  16140. /* 171 */
  16141. /***/ (function(module, exports, __webpack_require__) {
  16142. "use strict";
  16143. Object.defineProperty(exports, "__esModule", { value: true });
  16144. var socket_messages_1 = __webpack_require__(10);
  16145. var browser_utils_1 = __webpack_require__(22);
  16146. var utils_1 = __webpack_require__(21);
  16147. var KeyupEvent = __webpack_require__(95);
  16148. var filter_1 = __webpack_require__(4);
  16149. var withLatestFrom_1 = __webpack_require__(0);
  16150. var map_1 = __webpack_require__(2);
  16151. var pluck_1 = __webpack_require__(6);
  16152. var skip_1 = __webpack_require__(39);
  16153. var distinctUntilChanged_1 = __webpack_require__(40);
  16154. var switchMap_1 = __webpack_require__(20);
  16155. var empty_1 = __webpack_require__(16);
  16156. var fromEvent_1 = __webpack_require__(41);
  16157. function getFormInputStream(document, socket$, option$) {
  16158. var canSync$ = utils_1.createTimedBooleanSwitch(socket$.pipe(filter_1.filter(function (_a) {
  16159. var name = _a[0];
  16160. return name === socket_messages_1.IncomingSocketNames.Keyup;
  16161. })));
  16162. return option$.pipe(skip_1.skip(1), // initial option set before the connection event
  16163. pluck_1.pluck("ghostMode", "forms", "inputs"), distinctUntilChanged_1.distinctUntilChanged(), switchMap_1.switchMap(function (formInputs) {
  16164. if (!formInputs) {
  16165. return empty_1.empty();
  16166. }
  16167. return fromEvent_1.fromEvent(document.body, "keyup", true).pipe(map_1.map(function (e) { return e.target || e.srcElement; }), filter_1.filter(function (target) {
  16168. return target.tagName === "INPUT" ||
  16169. target.tagName === "TEXTAREA";
  16170. }), withLatestFrom_1.withLatestFrom(canSync$), filter_1.filter(function (_a) {
  16171. var canSync = _a[1];
  16172. return canSync;
  16173. }), map_1.map(function (_a) {
  16174. var eventTarget = _a[0];
  16175. var target = browser_utils_1.getElementData(eventTarget);
  16176. var value = eventTarget.value;
  16177. return KeyupEvent.outgoing(target, value);
  16178. }));
  16179. }));
  16180. }
  16181. exports.getFormInputStream = getFormInputStream;
  16182. /***/ }),
  16183. /* 172 */
  16184. /***/ (function(module, exports, __webpack_require__) {
  16185. "use strict";
  16186. var __extends = (this && this.__extends) || function (d, b) {
  16187. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  16188. function __() { this.constructor = d; }
  16189. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16190. };
  16191. var Observable_1 = __webpack_require__(1);
  16192. var tryCatch_1 = __webpack_require__(43);
  16193. var isFunction_1 = __webpack_require__(42);
  16194. var errorObject_1 = __webpack_require__(27);
  16195. var Subscription_1 = __webpack_require__(12);
  16196. var toString = Object.prototype.toString;
  16197. function isNodeStyleEventEmitter(sourceObj) {
  16198. return !!sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
  16199. }
  16200. function isJQueryStyleEventEmitter(sourceObj) {
  16201. return !!sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
  16202. }
  16203. function isNodeList(sourceObj) {
  16204. return !!sourceObj && toString.call(sourceObj) === '[object NodeList]';
  16205. }
  16206. function isHTMLCollection(sourceObj) {
  16207. return !!sourceObj && toString.call(sourceObj) === '[object HTMLCollection]';
  16208. }
  16209. function isEventTarget(sourceObj) {
  16210. return !!sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
  16211. }
  16212. /**
  16213. * We need this JSDoc comment for affecting ESDoc.
  16214. * @extends {Ignored}
  16215. * @hide true
  16216. */
  16217. var FromEventObservable = (function (_super) {
  16218. __extends(FromEventObservable, _super);
  16219. function FromEventObservable(sourceObj, eventName, selector, options) {
  16220. _super.call(this);
  16221. this.sourceObj = sourceObj;
  16222. this.eventName = eventName;
  16223. this.selector = selector;
  16224. this.options = options;
  16225. }
  16226. /* tslint:enable:max-line-length */
  16227. /**
  16228. * Creates an Observable that emits events of a specific type coming from the
  16229. * given event target.
  16230. *
  16231. * <span class="informal">Creates an Observable from DOM events, or Node.js
  16232. * EventEmitter events or others.</span>
  16233. *
  16234. * <img src="./img/fromEvent.png" width="100%">
  16235. *
  16236. * `fromEvent` accepts as a first argument event target, which is an object with methods
  16237. * for registering event handler functions. As a second argument it takes string that indicates
  16238. * type of event we want to listen for. `fromEvent` supports selected types of event targets,
  16239. * which are described in detail below. If your event target does not match any of the ones listed,
  16240. * you should use {@link fromEventPattern}, which can be used on arbitrary APIs.
  16241. * When it comes to APIs supported by `fromEvent`, their methods for adding and removing event
  16242. * handler functions have different names, but they all accept a string describing event type
  16243. * and function itself, which will be called whenever said event happens.
  16244. *
  16245. * Every time resulting Observable is subscribed, event handler function will be registered
  16246. * to event target on given event type. When that event fires, value
  16247. * passed as a first argument to registered function will be emitted by output Observable.
  16248. * When Observable is unsubscribed, function will be unregistered from event target.
  16249. *
  16250. * Note that if event target calls registered function with more than one argument, second
  16251. * and following arguments will not appear in resulting stream. In order to get access to them,
  16252. * you can pass to `fromEvent` optional project function, which will be called with all arguments
  16253. * passed to event handler. Output Observable will then emit value returned by project function,
  16254. * instead of the usual value.
  16255. *
  16256. * Remember that event targets listed below are checked via duck typing. It means that
  16257. * no matter what kind of object you have and no matter what environment you work in,
  16258. * you can safely use `fromEvent` on that object if it exposes described methods (provided
  16259. * of course they behave as was described above). So for example if Node.js library exposes
  16260. * event target which has the same method names as DOM EventTarget, `fromEvent` is still
  16261. * a good choice.
  16262. *
  16263. * If the API you use is more callback then event handler oriented (subscribed
  16264. * callback function fires only once and thus there is no need to manually
  16265. * unregister it), you should use {@link bindCallback} or {@link bindNodeCallback}
  16266. * instead.
  16267. *
  16268. * `fromEvent` supports following types of event targets:
  16269. *
  16270. * **DOM EventTarget**
  16271. *
  16272. * This is an object with `addEventListener` and `removeEventListener` methods.
  16273. *
  16274. * In the browser, `addEventListener` accepts - apart from event type string and event
  16275. * handler function arguments - optional third parameter, which is either an object or boolean,
  16276. * both used for additional configuration how and when passed function will be called. When
  16277. * `fromEvent` is used with event target of that type, you can provide this values
  16278. * as third parameter as well.
  16279. *
  16280. * **Node.js EventEmitter**
  16281. *
  16282. * An object with `addListener` and `removeListener` methods.
  16283. *
  16284. * **JQuery-style event target**
  16285. *
  16286. * An object with `on` and `off` methods
  16287. *
  16288. * **DOM NodeList**
  16289. *
  16290. * List of DOM Nodes, returned for example by `document.querySelectorAll` or `Node.childNodes`.
  16291. *
  16292. * Although this collection is not event target in itself, `fromEvent` will iterate over all Nodes
  16293. * it contains and install event handler function in every of them. When returned Observable
  16294. * is unsubscribed, function will be removed from all Nodes.
  16295. *
  16296. * **DOM HtmlCollection**
  16297. *
  16298. * Just as in case of NodeList it is a collection of DOM nodes. Here as well event handler function is
  16299. * installed and removed in each of elements.
  16300. *
  16301. *
  16302. * @example <caption>Emits clicks happening on the DOM document</caption>
  16303. * var clicks = Rx.Observable.fromEvent(document, 'click');
  16304. * clicks.subscribe(x => console.log(x));
  16305. *
  16306. * // Results in:
  16307. * // MouseEvent object logged to console every time a click
  16308. * // occurs on the document.
  16309. *
  16310. *
  16311. * @example <caption>Use addEventListener with capture option</caption>
  16312. * var clicksInDocument = Rx.Observable.fromEvent(document, 'click', true); // note optional configuration parameter
  16313. * // which will be passed to addEventListener
  16314. * var clicksInDiv = Rx.Observable.fromEvent(someDivInDocument, 'click');
  16315. *
  16316. * clicksInDocument.subscribe(() => console.log('document'));
  16317. * clicksInDiv.subscribe(() => console.log('div'));
  16318. *
  16319. * // By default events bubble UP in DOM tree, so normally
  16320. * // when we would click on div in document
  16321. * // "div" would be logged first and then "document".
  16322. * // Since we specified optional `capture` option, document
  16323. * // will catch event when it goes DOWN DOM tree, so console
  16324. * // will log "document" and then "div".
  16325. *
  16326. * @see {@link bindCallback}
  16327. * @see {@link bindNodeCallback}
  16328. * @see {@link fromEventPattern}
  16329. *
  16330. * @param {EventTargetLike} target The DOM EventTarget, Node.js
  16331. * EventEmitter, JQuery-like event target, NodeList or HTMLCollection to attach the event handler to.
  16332. * @param {string} eventName The event name of interest, being emitted by the
  16333. * `target`.
  16334. * @param {EventListenerOptions} [options] Options to pass through to addEventListener
  16335. * @param {SelectorMethodSignature<T>} [selector] An optional function to
  16336. * post-process results. It takes the arguments from the event handler and
  16337. * should return a single value.
  16338. * @return {Observable<T>}
  16339. * @static true
  16340. * @name fromEvent
  16341. * @owner Observable
  16342. */
  16343. FromEventObservable.create = function (target, eventName, options, selector) {
  16344. if (isFunction_1.isFunction(options)) {
  16345. selector = options;
  16346. options = undefined;
  16347. }
  16348. return new FromEventObservable(target, eventName, selector, options);
  16349. };
  16350. FromEventObservable.setupSubscription = function (sourceObj, eventName, handler, subscriber, options) {
  16351. var unsubscribe;
  16352. if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {
  16353. for (var i = 0, len = sourceObj.length; i < len; i++) {
  16354. FromEventObservable.setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
  16355. }
  16356. }
  16357. else if (isEventTarget(sourceObj)) {
  16358. var source_1 = sourceObj;
  16359. sourceObj.addEventListener(eventName, handler, options);
  16360. unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
  16361. }
  16362. else if (isJQueryStyleEventEmitter(sourceObj)) {
  16363. var source_2 = sourceObj;
  16364. sourceObj.on(eventName, handler);
  16365. unsubscribe = function () { return source_2.off(eventName, handler); };
  16366. }
  16367. else if (isNodeStyleEventEmitter(sourceObj)) {
  16368. var source_3 = sourceObj;
  16369. sourceObj.addListener(eventName, handler);
  16370. unsubscribe = function () { return source_3.removeListener(eventName, handler); };
  16371. }
  16372. else {
  16373. throw new TypeError('Invalid event target');
  16374. }
  16375. subscriber.add(new Subscription_1.Subscription(unsubscribe));
  16376. };
  16377. /** @deprecated internal use only */ FromEventObservable.prototype._subscribe = function (subscriber) {
  16378. var sourceObj = this.sourceObj;
  16379. var eventName = this.eventName;
  16380. var options = this.options;
  16381. var selector = this.selector;
  16382. var handler = selector ? function () {
  16383. var args = [];
  16384. for (var _i = 0; _i < arguments.length; _i++) {
  16385. args[_i - 0] = arguments[_i];
  16386. }
  16387. var result = tryCatch_1.tryCatch(selector).apply(void 0, args);
  16388. if (result === errorObject_1.errorObject) {
  16389. subscriber.error(errorObject_1.errorObject.e);
  16390. }
  16391. else {
  16392. subscriber.next(result);
  16393. }
  16394. } : function (e) { return subscriber.next(e); };
  16395. FromEventObservable.setupSubscription(sourceObj, eventName, handler, subscriber, options);
  16396. };
  16397. return FromEventObservable;
  16398. }(Observable_1.Observable));
  16399. exports.FromEventObservable = FromEventObservable;
  16400. //# sourceMappingURL=FromEventObservable.js.map
  16401. /***/ }),
  16402. /* 173 */
  16403. /***/ (function(module, exports, __webpack_require__) {
  16404. "use strict";
  16405. Object.defineProperty(exports, "__esModule", { value: true });
  16406. var utils_1 = __webpack_require__(21);
  16407. var socket_messages_1 = __webpack_require__(10);
  16408. var browser_utils_1 = __webpack_require__(22);
  16409. var ClickEvent = __webpack_require__(94);
  16410. var withLatestFrom_1 = __webpack_require__(0);
  16411. var filter_1 = __webpack_require__(4);
  16412. var map_1 = __webpack_require__(2);
  16413. var pluck_1 = __webpack_require__(6);
  16414. var skip_1 = __webpack_require__(39);
  16415. var distinctUntilChanged_1 = __webpack_require__(40);
  16416. var switchMap_1 = __webpack_require__(20);
  16417. var fromEvent_1 = __webpack_require__(41);
  16418. var empty_1 = __webpack_require__(16);
  16419. function getClickStream(document, socket$, option$) {
  16420. var canSync$ = utils_1.createTimedBooleanSwitch(socket$.pipe(filter_1.filter(function (_a) {
  16421. var name = _a[0];
  16422. return name === socket_messages_1.IncomingSocketNames.Click;
  16423. })));
  16424. return option$.pipe(skip_1.skip(1), // initial option set before the connection event
  16425. pluck_1.pluck("ghostMode", "clicks"), distinctUntilChanged_1.distinctUntilChanged(), switchMap_1.switchMap(function (canClick) {
  16426. if (!canClick) {
  16427. return empty_1.empty();
  16428. }
  16429. return fromEvent_1.fromEvent(document, "click", true).pipe(map_1.map(function (e) { return e.target; }), filter_1.filter(function (target) {
  16430. if (target.tagName === "LABEL") {
  16431. var id = target.getAttribute("for");
  16432. if (id && document.getElementById(id)) {
  16433. return false;
  16434. }
  16435. }
  16436. return true;
  16437. }), withLatestFrom_1.withLatestFrom(canSync$), filter_1.filter(function (_a) {
  16438. var canSync = _a[1];
  16439. return canSync;
  16440. }), map_1.map(function (_a) {
  16441. var target = _a[0];
  16442. return ClickEvent.outgoing(browser_utils_1.getElementData(target));
  16443. }));
  16444. }));
  16445. }
  16446. exports.getClickStream = getClickStream;
  16447. /***/ }),
  16448. /* 174 */
  16449. /***/ (function(module, exports, __webpack_require__) {
  16450. "use strict";
  16451. Object.defineProperty(exports, "__esModule", { value: true });
  16452. var utils_1 = __webpack_require__(21);
  16453. var socket_messages_1 = __webpack_require__(10);
  16454. var browser_utils_1 = __webpack_require__(22);
  16455. var ScrollEvent = __webpack_require__(85);
  16456. var filter_1 = __webpack_require__(4);
  16457. var map_1 = __webpack_require__(2);
  16458. var withLatestFrom_1 = __webpack_require__(0);
  16459. var pluck_1 = __webpack_require__(6);
  16460. var distinctUntilChanged_1 = __webpack_require__(40);
  16461. var switchMap_1 = __webpack_require__(20);
  16462. var empty_1 = __webpack_require__(16);
  16463. var skip_1 = __webpack_require__(39);
  16464. var fromEvent_1 = __webpack_require__(41);
  16465. function getScrollStream(window, document, socket$, option$) {
  16466. var canSync$ = utils_1.createTimedBooleanSwitch(socket$.pipe(filter_1.filter(function (_a) {
  16467. var name = _a[0];
  16468. return name === socket_messages_1.IncomingSocketNames.Scroll;
  16469. })));
  16470. /**
  16471. * If the option 'scrollElementMapping' is provided
  16472. * we cache thw
  16473. * @type {Observable<(Element | null)[]>}
  16474. */
  16475. var elemMap$ = option$.pipe(pluck_1.pluck("scrollElementMapping"), map_1.map(function (selectors) {
  16476. return selectors.map(function (selector) { return document.querySelector(selector); });
  16477. }));
  16478. return option$.pipe(skip_1.skip(1), // initial option set before the connection event
  16479. pluck_1.pluck("ghostMode", "scroll"), distinctUntilChanged_1.distinctUntilChanged(), switchMap_1.switchMap(function (scroll) {
  16480. if (!scroll)
  16481. return empty_1.empty();
  16482. return fromEvent_1.fromEvent(document, "scroll", true).pipe(map_1.map(function (e) { return e.target; }), withLatestFrom_1.withLatestFrom(canSync$, elemMap$), filter_1.filter(function (_a) {
  16483. var canSync = _a[1];
  16484. return Boolean(canSync);
  16485. }), map_1.map(function (_a) {
  16486. var target = _a[0], canSync = _a[1], elemMap = _a[2];
  16487. if (target === document) {
  16488. return ScrollEvent.outgoing(browser_utils_1.getScrollPosition(window, document), "document", 0);
  16489. }
  16490. var elems = document.getElementsByTagName(target.tagName);
  16491. var index = Array.prototype.indexOf.call(elems || [], target);
  16492. return ScrollEvent.outgoing(browser_utils_1.getScrollPositionForElement(target), target.tagName, index, elemMap.indexOf(target));
  16493. }));
  16494. }));
  16495. }
  16496. exports.getScrollStream = getScrollStream;
  16497. /***/ }),
  16498. /* 175 */
  16499. /***/ (function(module, exports, __webpack_require__) {
  16500. "use strict";
  16501. Object.defineProperty(exports, "__esModule", { value: true });
  16502. var socket_messages_1 = __webpack_require__(10);
  16503. var browser_utils_1 = __webpack_require__(22);
  16504. var utils_1 = __webpack_require__(21);
  16505. var FormToggleEvent = __webpack_require__(98);
  16506. var filter_1 = __webpack_require__(4);
  16507. var skip_1 = __webpack_require__(39);
  16508. var pluck_1 = __webpack_require__(6);
  16509. var distinctUntilChanged_1 = __webpack_require__(40);
  16510. var withLatestFrom_1 = __webpack_require__(0);
  16511. var map_1 = __webpack_require__(2);
  16512. var switchMap_1 = __webpack_require__(20);
  16513. var empty_1 = __webpack_require__(16);
  16514. var fromEvent_1 = __webpack_require__(41);
  16515. function getFormTogglesStream(document, socket$, option$) {
  16516. var canSync$ = utils_1.createTimedBooleanSwitch(socket$.pipe(filter_1.filter(function (_a) {
  16517. var name = _a[0];
  16518. return name === socket_messages_1.IncomingSocketNames.InputToggle;
  16519. })));
  16520. return option$.pipe(skip_1.skip(1), pluck_1.pluck("ghostMode", "forms", "toggles"), distinctUntilChanged_1.distinctUntilChanged(), switchMap_1.switchMap(function (canToggle) {
  16521. if (!canToggle) {
  16522. return empty_1.empty();
  16523. }
  16524. return fromEvent_1.fromEvent(document, "change", true).pipe(map_1.map(function (e) { return e.target || e.srcElement; }), filter_1.filter(function (elem) { return elem.tagName === "SELECT"; }), withLatestFrom_1.withLatestFrom(canSync$), filter_1.filter(function (_a) {
  16525. var canSync = _a[1];
  16526. return canSync;
  16527. }), map_1.map(function (_a) {
  16528. var elem = _a[0], canSync = _a[1];
  16529. var data = browser_utils_1.getElementData(elem);
  16530. return FormToggleEvent.outgoing(data, {
  16531. type: elem.type,
  16532. checked: elem.checked,
  16533. value: elem.value
  16534. });
  16535. }));
  16536. }));
  16537. }
  16538. exports.getFormTogglesStream = getFormTogglesStream;
  16539. /***/ }),
  16540. /* 176 */
  16541. /***/ (function(module, exports, __webpack_require__) {
  16542. "use strict";
  16543. var __extends = (this && this.__extends) || function (d, b) {
  16544. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  16545. function __() { this.constructor = d; }
  16546. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16547. };
  16548. var Subscriber_1 = __webpack_require__(3);
  16549. var Subscription_1 = __webpack_require__(12);
  16550. var Observable_1 = __webpack_require__(1);
  16551. var Subject_1 = __webpack_require__(37);
  16552. var Map_1 = __webpack_require__(177);
  16553. var FastMap_1 = __webpack_require__(179);
  16554. /* tslint:enable:max-line-length */
  16555. /**
  16556. * Groups the items emitted by an Observable according to a specified criterion,
  16557. * and emits these grouped items as `GroupedObservables`, one
  16558. * {@link GroupedObservable} per group.
  16559. *
  16560. * <img src="./img/groupBy.png" width="100%">
  16561. *
  16562. * @example <caption>Group objects by id and return as array</caption>
  16563. * Observable.of<Obj>({id: 1, name: 'aze1'},
  16564. * {id: 2, name: 'sf2'},
  16565. * {id: 2, name: 'dg2'},
  16566. * {id: 1, name: 'erg1'},
  16567. * {id: 1, name: 'df1'},
  16568. * {id: 2, name: 'sfqfb2'},
  16569. * {id: 3, name: 'qfs3'},
  16570. * {id: 2, name: 'qsgqsfg2'}
  16571. * )
  16572. * .groupBy(p => p.id)
  16573. * .flatMap( (group$) => group$.reduce((acc, cur) => [...acc, cur], []))
  16574. * .subscribe(p => console.log(p));
  16575. *
  16576. * // displays:
  16577. * // [ { id: 1, name: 'aze1' },
  16578. * // { id: 1, name: 'erg1' },
  16579. * // { id: 1, name: 'df1' } ]
  16580. * //
  16581. * // [ { id: 2, name: 'sf2' },
  16582. * // { id: 2, name: 'dg2' },
  16583. * // { id: 2, name: 'sfqfb2' },
  16584. * // { id: 2, name: 'qsgqsfg2' } ]
  16585. * //
  16586. * // [ { id: 3, name: 'qfs3' } ]
  16587. *
  16588. * @example <caption>Pivot data on the id field</caption>
  16589. * Observable.of<Obj>({id: 1, name: 'aze1'},
  16590. * {id: 2, name: 'sf2'},
  16591. * {id: 2, name: 'dg2'},
  16592. * {id: 1, name: 'erg1'},
  16593. * {id: 1, name: 'df1'},
  16594. * {id: 2, name: 'sfqfb2'},
  16595. * {id: 3, name: 'qfs1'},
  16596. * {id: 2, name: 'qsgqsfg2'}
  16597. * )
  16598. * .groupBy(p => p.id, p => p.name)
  16599. * .flatMap( (group$) => group$.reduce((acc, cur) => [...acc, cur], ["" + group$.key]))
  16600. * .map(arr => ({'id': parseInt(arr[0]), 'values': arr.slice(1)}))
  16601. * .subscribe(p => console.log(p));
  16602. *
  16603. * // displays:
  16604. * // { id: 1, values: [ 'aze1', 'erg1', 'df1' ] }
  16605. * // { id: 2, values: [ 'sf2', 'dg2', 'sfqfb2', 'qsgqsfg2' ] }
  16606. * // { id: 3, values: [ 'qfs1' ] }
  16607. *
  16608. * @param {function(value: T): K} keySelector A function that extracts the key
  16609. * for each item.
  16610. * @param {function(value: T): R} [elementSelector] A function that extracts the
  16611. * return element for each item.
  16612. * @param {function(grouped: GroupedObservable<K,R>): Observable<any>} [durationSelector]
  16613. * A function that returns an Observable to determine how long each group should
  16614. * exist.
  16615. * @return {Observable<GroupedObservable<K,R>>} An Observable that emits
  16616. * GroupedObservables, each of which corresponds to a unique key value and each
  16617. * of which emits those items from the source Observable that share that key
  16618. * value.
  16619. * @method groupBy
  16620. * @owner Observable
  16621. */
  16622. function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
  16623. return function (source) {
  16624. return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
  16625. };
  16626. }
  16627. exports.groupBy = groupBy;
  16628. var GroupByOperator = (function () {
  16629. function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
  16630. this.keySelector = keySelector;
  16631. this.elementSelector = elementSelector;
  16632. this.durationSelector = durationSelector;
  16633. this.subjectSelector = subjectSelector;
  16634. }
  16635. GroupByOperator.prototype.call = function (subscriber, source) {
  16636. return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
  16637. };
  16638. return GroupByOperator;
  16639. }());
  16640. /**
  16641. * We need this JSDoc comment for affecting ESDoc.
  16642. * @ignore
  16643. * @extends {Ignored}
  16644. */
  16645. var GroupBySubscriber = (function (_super) {
  16646. __extends(GroupBySubscriber, _super);
  16647. function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
  16648. _super.call(this, destination);
  16649. this.keySelector = keySelector;
  16650. this.elementSelector = elementSelector;
  16651. this.durationSelector = durationSelector;
  16652. this.subjectSelector = subjectSelector;
  16653. this.groups = null;
  16654. this.attemptedToUnsubscribe = false;
  16655. this.count = 0;
  16656. }
  16657. GroupBySubscriber.prototype._next = function (value) {
  16658. var key;
  16659. try {
  16660. key = this.keySelector(value);
  16661. }
  16662. catch (err) {
  16663. this.error(err);
  16664. return;
  16665. }
  16666. this._group(value, key);
  16667. };
  16668. GroupBySubscriber.prototype._group = function (value, key) {
  16669. var groups = this.groups;
  16670. if (!groups) {
  16671. groups = this.groups = typeof key === 'string' ? new FastMap_1.FastMap() : new Map_1.Map();
  16672. }
  16673. var group = groups.get(key);
  16674. var element;
  16675. if (this.elementSelector) {
  16676. try {
  16677. element = this.elementSelector(value);
  16678. }
  16679. catch (err) {
  16680. this.error(err);
  16681. }
  16682. }
  16683. else {
  16684. element = value;
  16685. }
  16686. if (!group) {
  16687. group = this.subjectSelector ? this.subjectSelector() : new Subject_1.Subject();
  16688. groups.set(key, group);
  16689. var groupedObservable = new GroupedObservable(key, group, this);
  16690. this.destination.next(groupedObservable);
  16691. if (this.durationSelector) {
  16692. var duration = void 0;
  16693. try {
  16694. duration = this.durationSelector(new GroupedObservable(key, group));
  16695. }
  16696. catch (err) {
  16697. this.error(err);
  16698. return;
  16699. }
  16700. this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
  16701. }
  16702. }
  16703. if (!group.closed) {
  16704. group.next(element);
  16705. }
  16706. };
  16707. GroupBySubscriber.prototype._error = function (err) {
  16708. var groups = this.groups;
  16709. if (groups) {
  16710. groups.forEach(function (group, key) {
  16711. group.error(err);
  16712. });
  16713. groups.clear();
  16714. }
  16715. this.destination.error(err);
  16716. };
  16717. GroupBySubscriber.prototype._complete = function () {
  16718. var groups = this.groups;
  16719. if (groups) {
  16720. groups.forEach(function (group, key) {
  16721. group.complete();
  16722. });
  16723. groups.clear();
  16724. }
  16725. this.destination.complete();
  16726. };
  16727. GroupBySubscriber.prototype.removeGroup = function (key) {
  16728. this.groups.delete(key);
  16729. };
  16730. GroupBySubscriber.prototype.unsubscribe = function () {
  16731. if (!this.closed) {
  16732. this.attemptedToUnsubscribe = true;
  16733. if (this.count === 0) {
  16734. _super.prototype.unsubscribe.call(this);
  16735. }
  16736. }
  16737. };
  16738. return GroupBySubscriber;
  16739. }(Subscriber_1.Subscriber));
  16740. /**
  16741. * We need this JSDoc comment for affecting ESDoc.
  16742. * @ignore
  16743. * @extends {Ignored}
  16744. */
  16745. var GroupDurationSubscriber = (function (_super) {
  16746. __extends(GroupDurationSubscriber, _super);
  16747. function GroupDurationSubscriber(key, group, parent) {
  16748. _super.call(this, group);
  16749. this.key = key;
  16750. this.group = group;
  16751. this.parent = parent;
  16752. }
  16753. GroupDurationSubscriber.prototype._next = function (value) {
  16754. this.complete();
  16755. };
  16756. /** @deprecated internal use only */ GroupDurationSubscriber.prototype._unsubscribe = function () {
  16757. var _a = this, parent = _a.parent, key = _a.key;
  16758. this.key = this.parent = null;
  16759. if (parent) {
  16760. parent.removeGroup(key);
  16761. }
  16762. };
  16763. return GroupDurationSubscriber;
  16764. }(Subscriber_1.Subscriber));
  16765. /**
  16766. * An Observable representing values belonging to the same group represented by
  16767. * a common key. The values emitted by a GroupedObservable come from the source
  16768. * Observable. The common key is available as the field `key` on a
  16769. * GroupedObservable instance.
  16770. *
  16771. * @class GroupedObservable<K, T>
  16772. */
  16773. var GroupedObservable = (function (_super) {
  16774. __extends(GroupedObservable, _super);
  16775. function GroupedObservable(key, groupSubject, refCountSubscription) {
  16776. _super.call(this);
  16777. this.key = key;
  16778. this.groupSubject = groupSubject;
  16779. this.refCountSubscription = refCountSubscription;
  16780. }
  16781. /** @deprecated internal use only */ GroupedObservable.prototype._subscribe = function (subscriber) {
  16782. var subscription = new Subscription_1.Subscription();
  16783. var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
  16784. if (refCountSubscription && !refCountSubscription.closed) {
  16785. subscription.add(new InnerRefCountSubscription(refCountSubscription));
  16786. }
  16787. subscription.add(groupSubject.subscribe(subscriber));
  16788. return subscription;
  16789. };
  16790. return GroupedObservable;
  16791. }(Observable_1.Observable));
  16792. exports.GroupedObservable = GroupedObservable;
  16793. /**
  16794. * We need this JSDoc comment for affecting ESDoc.
  16795. * @ignore
  16796. * @extends {Ignored}
  16797. */
  16798. var InnerRefCountSubscription = (function (_super) {
  16799. __extends(InnerRefCountSubscription, _super);
  16800. function InnerRefCountSubscription(parent) {
  16801. _super.call(this);
  16802. this.parent = parent;
  16803. parent.count++;
  16804. }
  16805. InnerRefCountSubscription.prototype.unsubscribe = function () {
  16806. var parent = this.parent;
  16807. if (!parent.closed && !this.closed) {
  16808. _super.prototype.unsubscribe.call(this);
  16809. parent.count -= 1;
  16810. if (parent.count === 0 && parent.attemptedToUnsubscribe) {
  16811. parent.unsubscribe();
  16812. }
  16813. }
  16814. };
  16815. return InnerRefCountSubscription;
  16816. }(Subscription_1.Subscription));
  16817. //# sourceMappingURL=groupBy.js.map
  16818. /***/ }),
  16819. /* 177 */
  16820. /***/ (function(module, exports, __webpack_require__) {
  16821. "use strict";
  16822. var root_1 = __webpack_require__(7);
  16823. var MapPolyfill_1 = __webpack_require__(178);
  16824. exports.Map = root_1.root.Map || (function () { return MapPolyfill_1.MapPolyfill; })();
  16825. //# sourceMappingURL=Map.js.map
  16826. /***/ }),
  16827. /* 178 */
  16828. /***/ (function(module, exports, __webpack_require__) {
  16829. "use strict";
  16830. var MapPolyfill = (function () {
  16831. function MapPolyfill() {
  16832. this.size = 0;
  16833. this._values = [];
  16834. this._keys = [];
  16835. }
  16836. MapPolyfill.prototype.get = function (key) {
  16837. var i = this._keys.indexOf(key);
  16838. return i === -1 ? undefined : this._values[i];
  16839. };
  16840. MapPolyfill.prototype.set = function (key, value) {
  16841. var i = this._keys.indexOf(key);
  16842. if (i === -1) {
  16843. this._keys.push(key);
  16844. this._values.push(value);
  16845. this.size++;
  16846. }
  16847. else {
  16848. this._values[i] = value;
  16849. }
  16850. return this;
  16851. };
  16852. MapPolyfill.prototype.delete = function (key) {
  16853. var i = this._keys.indexOf(key);
  16854. if (i === -1) {
  16855. return false;
  16856. }
  16857. this._values.splice(i, 1);
  16858. this._keys.splice(i, 1);
  16859. this.size--;
  16860. return true;
  16861. };
  16862. MapPolyfill.prototype.clear = function () {
  16863. this._keys.length = 0;
  16864. this._values.length = 0;
  16865. this.size = 0;
  16866. };
  16867. MapPolyfill.prototype.forEach = function (cb, thisArg) {
  16868. for (var i = 0; i < this.size; i++) {
  16869. cb.call(thisArg, this._values[i], this._keys[i]);
  16870. }
  16871. };
  16872. return MapPolyfill;
  16873. }());
  16874. exports.MapPolyfill = MapPolyfill;
  16875. //# sourceMappingURL=MapPolyfill.js.map
  16876. /***/ }),
  16877. /* 179 */
  16878. /***/ (function(module, exports, __webpack_require__) {
  16879. "use strict";
  16880. var FastMap = (function () {
  16881. function FastMap() {
  16882. this.values = {};
  16883. }
  16884. FastMap.prototype.delete = function (key) {
  16885. this.values[key] = null;
  16886. return true;
  16887. };
  16888. FastMap.prototype.set = function (key, value) {
  16889. this.values[key] = value;
  16890. return this;
  16891. };
  16892. FastMap.prototype.get = function (key) {
  16893. return this.values[key];
  16894. };
  16895. FastMap.prototype.forEach = function (cb, thisArg) {
  16896. var values = this.values;
  16897. for (var key in values) {
  16898. if (values.hasOwnProperty(key) && values[key] !== null) {
  16899. cb.call(thisArg, values[key], key);
  16900. }
  16901. }
  16902. };
  16903. FastMap.prototype.clear = function () {
  16904. this.values = {};
  16905. };
  16906. return FastMap;
  16907. }());
  16908. exports.FastMap = FastMap;
  16909. //# sourceMappingURL=FastMap.js.map
  16910. /***/ })
  16911. /******/ ]);