From 8a9864ea81b320fb5ffec334075cb0ce95764974 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 19 Mar 2017 02:18:32 +0100 Subject: [PATCH] Initial commit --- .gitignore | 3 + config.json.example | 9 + gulpfile.js | 116 + package.json | 53 + public/css/style.css | 59 + public/js/bundle.js | 26001 ++++++++++++++++++++++++++++++ server.js | 81 + src/clamp-zero.js | 9 + src/client-store.js | 102 + src/error-reporting.js | 20 + src/errors.js | 7 + src/frontend/components/app.tag | 91 + src/frontend/index.js | 12 + src/frontend/ws-endpoint.js | 8 + src/paste-store.js | 37 + src/promise-set-interval.js | 49 + src/prune-array.js | 9 + src/scraper.js | 57 + src/scrapers/pastebin-com.js | 93 + src/scss/style.scss | 83 + views/index.pug | 225 + 21 files changed, 27124 insertions(+) create mode 100644 .gitignore create mode 100644 config.json.example create mode 100644 gulpfile.js create mode 100644 package.json create mode 100644 public/css/style.css create mode 100644 public/js/bundle.js create mode 100644 server.js create mode 100644 src/clamp-zero.js create mode 100644 src/client-store.js create mode 100644 src/error-reporting.js create mode 100644 src/errors.js create mode 100644 src/frontend/components/app.tag create mode 100644 src/frontend/index.js create mode 100644 src/frontend/ws-endpoint.js create mode 100644 src/paste-store.js create mode 100644 src/promise-set-interval.js create mode 100644 src/prune-array.js create mode 100644 src/scraper.js create mode 100644 src/scrapers/pastebin-com.js create mode 100644 src/scss/style.scss create mode 100644 views/index.pug diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..672cc82 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +errors +node_modules +config.json diff --git a/config.json.example b/config.json.example new file mode 100644 index 0000000..8f0e3fa --- /dev/null +++ b/config.json.example @@ -0,0 +1,9 @@ +{ + "scraperSettings": { + "pastebinCom": { + "listInterval": 60, + "listLimit": 100, + "pasteInterval": 1 + } + } +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..fe3433d --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,116 @@ +const Promise = require("bluebird"); +const path = require("path"); +const gulp = require("gulp"); +const webpackStream = require("webpack-stream"); +const webpack = require("webpack"); +const gulpNamedLog = require("gulp-named-log"); +const gulpRename = require("gulp-rename"); +const gulpNodemon = require("gulp-nodemon"); +const gulpCached = require("gulp-cached"); +const presetSCSS = require("@joepie91/gulp-preset-scss"); + +const awaitServer = require("await-server"); + +const gulpLivereload = require("gulp-livereload"); +const patchLivereloadLogger = require("@joepie91/gulp-partial-patch-livereload-logger"); + +patchLivereloadLogger(gulpLivereload); + +let config = { + scss: { + source: "./src/scss/**/*.scss", + destination: "./public/css/" + }, + cssModules: [] +} + +let serverLogger = gulpNamedLog("server"); + +gulp.task("nodemon", ["scss", "livereload"], () => { + gulpNodemon({ + script: "server.js", + ignore: [ + "gulpfile.js", + "node_modules", + "public" + ], + ext: "js pug" + }).on("start", () => { + Promise.try(() => { + serverLogger.info("Starting..."); + return awaitServer(3000); + }).then(() => { + serverLogger.info("Started!"); + gulpLivereload.changed("*"); + }); + }); +}); + +gulp.task("scss", () => { + return gulp.src(config.scss.source) + .pipe(presetSCSS({ + livereload: gulpLivereload + })) + .pipe(gulp.dest(config.scss.destination)); +}); + +gulp.task("livereload", () => { + gulpLivereload.listen({ + quiet: true + }); +}); + +gulp.task("webpack-watch", ["livereload"], () => { + return gulp.src("./src/frontend/index.js") + .pipe(webpackStream({ + watch: true, + module: { + preLoaders: [{ + test: /\.tag$/, + loader: "riotjs-loader", + exclude: /node_modules/, + query: { + type: "es6", + template: "pug", + parserOptions: { + js: { + presets: ["es2015-riot"] + } + } + } + }], + loaders: [{ + test: /\.js/, + loader: "babel-loader", + query: { + presets: ["es2015"] + } + }, { + test: /\.json$/, + loader: "json-loader" + }] + }, + resolve: { + extensions: [ + "", + ".tag", + ".web.js", ".js", + ".web.json", ".json" + ] + }, + plugins: [ new webpack.ProvidePlugin({riot: "riot"}) ], + debug: true + })) + .pipe(gulpRename("bundle.js")) + .pipe(gulpNamedLog("webpack").stream()) + .pipe(gulpLivereload()) + .pipe(gulp.dest("./public/js/")); +}); + +gulp.task("watch-css", () => { + gulp.watch(config.scss.source, ["scss"]); +}); + +gulp.task("watch", ["webpack-watch", "nodemon", "watch-css"]); + +gulp.task("default", ["watch"]); diff --git a/package.json b/package.json new file mode 100644 index 0000000..343cc48 --- /dev/null +++ b/package.json @@ -0,0 +1,53 @@ +{ + "name": "pastebin-stream", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git@git.cryto.net:joepie91/pastebin-stream.git" + }, + "keywords": [], + "author": "Sven Slootweg", + "license": "WTFPL", + "dependencies": { + "bhttp": "^1.2.4", + "bluebird": "^3.5.0", + "create-error": "^0.3.1", + "create-event-emitter": "^1.0.0", + "debug": "^2.6.3", + "default-value": "^1.0.0", + "document-ready-promise": "^3.0.1", + "express": "^4.15.2", + "express-ws": "^3.0.0", + "mkdirp": "^0.5.1", + "moment": "^2.18.0", + "promise-task-queue": "^1.2.0", + "pug": "^2.0.0-beta11", + "report-errors": "^1.0.0", + "ws": "^2.2.1" + }, + "devDependencies": { + "@joepie91/gulp-partial-patch-livereload-logger": "^1.0.1", + "@joepie91/gulp-preset-scss": "^1.0.3", + "babel-core": "^6.22.1", + "babel-loader": "^6.2.10", + "babel-preset-es2015": "^6.22.0", + "babel-preset-es2015-riot": "^1.1.0", + "document-ready-promise": "^3.0.1", + "gulp": "^3.9.1", + "gulp-cached": "^1.1.1", + "gulp-livereload": "^3.8.1", + "gulp-named-log": "^1.0.1", + "gulp-nodemon": "^2.2.1", + "gulp-rename": "^1.2.2", + "riot": "^3.3.2", + "riotjs-loader": "^4.0.0", + "webpack": "^1.14.0", + "webpack-stream": "^3.2.0", + "wsurl": "^1.0.0" + } +} diff --git a/public/css/style.css b/public/css/style.css new file mode 100644 index 0000000..8e71616 --- /dev/null +++ b/public/css/style.css @@ -0,0 +1,59 @@ +body { + font-family: sans-serif; + line-height: 1.4; } + +.wrapper { + max-width: 900px; + margin: 0px auto; } + +pre { + padding: 16px; + border: 1px solid #bababa; + background-color: #eeeeee; + border-radius: 5px; } + +code { + padding: 3px 7px 3px 7px; } + +code, pre { + font-size: 16px; + background-color: #eeeeee; + border-radius: 5px; } + +.donation-method { + padding: 16px; + border: 1px solid #bababa; + background-color: #eeeeee; + border-radius: 5px; + margin-bottom: 8px; } + .donation-method h3 { + margin-top: 0px; + margin-bottom: 7px; + border-bottom: none; } + .donation-method p { + margin: 5px 0px; } + .donation-method .amount { + font-size: 16px; } + .donation-method .amount label { + margin-right: 7px; } + .donation-method .amount input { + margin: 0px 2px; + font-size: 16px; + padding: 4px 5px; + border-radius: 3px; + border: 1px solid silver; + width: 80px; } + .donation-method.monthly .amount input { + width: 55px; } + .donation-method .amount, .donation-method .submit { + display: inline; } + .donation-method .submit { + position: relative; + top: 8px; + left: 12px; } + +h2 { + border-bottom: 1px solid silver; } + +h3 { + border-bottom: 1px solid #cdcdcd; } diff --git a/public/js/bundle.js b/public/js/bundle.js new file mode 100644 index 0000000..4587a4a --- /dev/null +++ b/public/js/bundle.js @@ -0,0 +1,26001 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Promise = __webpack_require__(1); + var documentReadyPromise = __webpack_require__(40); + var app = __webpack_require__(41); + var riot = __webpack_require__(42); + + Promise.try(function () { + return documentReadyPromise(); + }).then(function (result) { + riot.mount("*"); + }); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + + var old; + if (typeof Promise !== "undefined") old = Promise; + function noConflict() { + try { + if (Promise === bluebird) Promise = old; + } catch (e) {} + return bluebird; + } + var bluebird = __webpack_require__(2)(); + bluebird.noConflict = noConflict; + module.exports = bluebird; + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {"use strict"; + + module.exports = function () { + var makeSelfResolutionError = function makeSelfResolutionError() { + return new TypeError("circular promise resolution chain\n\n See http://goo.gl/MqrFmX\n"); + }; + var reflectHandler = function reflectHandler() { + return new Promise.PromiseInspection(this._target()); + }; + var apiRejection = function apiRejection(msg) { + return Promise.reject(new TypeError(msg)); + }; + function Proxyable() {} + var UNDEFINED_BINDING = {}; + var util = __webpack_require__(4); + + var getDomain; + if (util.isNode) { + getDomain = function getDomain() { + var ret = process.domain; + if (ret === undefined) ret = null; + return ret; + }; + } else { + getDomain = function getDomain() { + return null; + }; + } + util.notEnumerableProp(Promise, "_getDomain", getDomain); + + var es5 = __webpack_require__(5); + var Async = __webpack_require__(6); + var async = new Async(); + es5.defineProperty(Promise, "_async", { value: async }); + var errors = __webpack_require__(11); + var TypeError = Promise.TypeError = errors.TypeError; + Promise.RangeError = errors.RangeError; + var CancellationError = Promise.CancellationError = errors.CancellationError; + Promise.TimeoutError = errors.TimeoutError; + Promise.OperationalError = errors.OperationalError; + Promise.RejectionError = errors.OperationalError; + Promise.AggregateError = errors.AggregateError; + var INTERNAL = function INTERNAL() {}; + var APPLY = {}; + var NEXT_FILTER = {}; + var tryConvertToPromise = __webpack_require__(12)(Promise, INTERNAL); + var PromiseArray = __webpack_require__(13)(Promise, INTERNAL, tryConvertToPromise, apiRejection, Proxyable); + var Context = __webpack_require__(14)(Promise); + /*jshint unused:false*/ + var createContext = Context.create; + var debug = __webpack_require__(15)(Promise, Context); + var CapturedTrace = debug.CapturedTrace; + var PassThroughHandlerContext = __webpack_require__(16)(Promise, tryConvertToPromise, NEXT_FILTER); + var catchFilter = __webpack_require__(17)(NEXT_FILTER); + var nodebackForPromise = __webpack_require__(18); + var errorObj = util.errorObj; + var tryCatch = util.tryCatch; + function check(self, executor) { + if (self == null || self.constructor !== Promise) { + throw new TypeError("the promise constructor cannot be invoked directly\n\n See http://goo.gl/MqrFmX\n"); + } + if (typeof executor !== "function") { + throw new TypeError("expecting a function but got " + util.classString(executor)); + } + } + + function Promise(executor) { + if (executor !== INTERNAL) { + check(this, executor); + } + this._bitField = 0; + this._fulfillmentHandler0 = undefined; + this._rejectionHandler0 = undefined; + this._promise0 = undefined; + this._receiver0 = undefined; + this._resolveFromExecutor(executor); + this._promiseCreated(); + this._fireEvent("promiseCreated", this); + } + + Promise.prototype.toString = function () { + return "[object Promise]"; + }; + + Promise.prototype.caught = Promise.prototype["catch"] = function (fn) { + var len = arguments.length; + if (len > 1) { + var catchInstances = new Array(len - 1), + j = 0, + i; + for (i = 0; i < len - 1; ++i) { + var item = arguments[i]; + if (util.isObject(item)) { + catchInstances[j++] = item; + } else { + return apiRejection("Catch statement predicate: " + "expecting an object but got " + util.classString(item)); + } + } + catchInstances.length = j; + fn = arguments[i]; + return this.then(undefined, catchFilter(catchInstances, fn, this)); + } + return this.then(undefined, fn); + }; + + Promise.prototype.reflect = function () { + return this._then(reflectHandler, reflectHandler, undefined, this, undefined); + }; + + Promise.prototype.then = function (didFulfill, didReject) { + if (debug.warnings() && arguments.length > 0 && typeof didFulfill !== "function" && typeof didReject !== "function") { + var msg = ".then() only accepts functions but was passed: " + util.classString(didFulfill); + if (arguments.length > 1) { + msg += ", " + util.classString(didReject); + } + this._warn(msg); + } + return this._then(didFulfill, didReject, undefined, undefined, undefined); + }; + + Promise.prototype.done = function (didFulfill, didReject) { + var promise = this._then(didFulfill, didReject, undefined, undefined, undefined); + promise._setIsFinal(); + }; + + Promise.prototype.spread = function (fn) { + if (typeof fn !== "function") { + return apiRejection("expecting a function but got " + util.classString(fn)); + } + return this.all()._then(fn, undefined, undefined, APPLY, undefined); + }; + + Promise.prototype.toJSON = function () { + var ret = { + isFulfilled: false, + isRejected: false, + fulfillmentValue: undefined, + rejectionReason: undefined + }; + if (this.isFulfilled()) { + ret.fulfillmentValue = this.value(); + ret.isFulfilled = true; + } else if (this.isRejected()) { + ret.rejectionReason = this.reason(); + ret.isRejected = true; + } + return ret; + }; + + Promise.prototype.all = function () { + if (arguments.length > 0) { + this._warn(".all() was passed arguments but it does not take any"); + } + return new PromiseArray(this).promise(); + }; + + Promise.prototype.error = function (fn) { + return this.caught(util.originatesFromRejection, fn); + }; + + Promise.getNewLibraryCopy = module.exports; + + Promise.is = function (val) { + return val instanceof Promise; + }; + + Promise.fromNode = Promise.fromCallback = function (fn) { + var ret = new Promise(INTERNAL); + ret._captureStackTrace(); + var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs : false; + var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs)); + if (result === errorObj) { + ret._rejectCallback(result.e, true); + } + if (!ret._isFateSealed()) ret._setAsyncGuaranteed(); + return ret; + }; + + Promise.all = function (promises) { + return new PromiseArray(promises).promise(); + }; + + Promise.cast = function (obj) { + var ret = tryConvertToPromise(obj); + if (!(ret instanceof Promise)) { + ret = new Promise(INTERNAL); + ret._captureStackTrace(); + ret._setFulfilled(); + ret._rejectionHandler0 = obj; + } + return ret; + }; + + Promise.resolve = Promise.fulfilled = Promise.cast; + + Promise.reject = Promise.rejected = function (reason) { + var ret = new Promise(INTERNAL); + ret._captureStackTrace(); + ret._rejectCallback(reason, true); + return ret; + }; + + Promise.setScheduler = function (fn) { + if (typeof fn !== "function") { + throw new TypeError("expecting a function but got " + util.classString(fn)); + } + return async.setScheduler(fn); + }; + + Promise.prototype._then = function (didFulfill, didReject, _, receiver, internalData) { + var haveInternalData = internalData !== undefined; + var promise = haveInternalData ? internalData : new Promise(INTERNAL); + var target = this._target(); + var bitField = target._bitField; + + if (!haveInternalData) { + promise._propagateFrom(this, 3); + promise._captureStackTrace(); + if (receiver === undefined && (this._bitField & 2097152) !== 0) { + if (!((bitField & 50397184) === 0)) { + receiver = this._boundValue(); + } else { + receiver = target === this ? undefined : this._boundTo; + } + } + this._fireEvent("promiseChained", this, promise); + } + + var domain = getDomain(); + if (!((bitField & 50397184) === 0)) { + var handler, + value, + settler = target._settlePromiseCtx; + if ((bitField & 33554432) !== 0) { + value = target._rejectionHandler0; + handler = didFulfill; + } else if ((bitField & 16777216) !== 0) { + value = target._fulfillmentHandler0; + handler = didReject; + target._unsetRejectionIsUnhandled(); + } else { + settler = target._settlePromiseLateCancellationObserver; + value = new CancellationError("late cancellation observer"); + target._attachExtraTrace(value); + handler = didReject; + } + + async.invoke(settler, target, { + handler: domain === null ? handler : typeof handler === "function" && util.domainBind(domain, handler), + promise: promise, + receiver: receiver, + value: value + }); + } else { + target._addCallbacks(didFulfill, didReject, promise, receiver, domain); + } + + return promise; + }; + + Promise.prototype._length = function () { + return this._bitField & 65535; + }; + + Promise.prototype._isFateSealed = function () { + return (this._bitField & 117506048) !== 0; + }; + + Promise.prototype._isFollowing = function () { + return (this._bitField & 67108864) === 67108864; + }; + + Promise.prototype._setLength = function (len) { + this._bitField = this._bitField & -65536 | len & 65535; + }; + + Promise.prototype._setFulfilled = function () { + this._bitField = this._bitField | 33554432; + this._fireEvent("promiseFulfilled", this); + }; + + Promise.prototype._setRejected = function () { + this._bitField = this._bitField | 16777216; + this._fireEvent("promiseRejected", this); + }; + + Promise.prototype._setFollowing = function () { + this._bitField = this._bitField | 67108864; + this._fireEvent("promiseResolved", this); + }; + + Promise.prototype._setIsFinal = function () { + this._bitField = this._bitField | 4194304; + }; + + Promise.prototype._isFinal = function () { + return (this._bitField & 4194304) > 0; + }; + + Promise.prototype._unsetCancelled = function () { + this._bitField = this._bitField & ~65536; + }; + + Promise.prototype._setCancelled = function () { + this._bitField = this._bitField | 65536; + this._fireEvent("promiseCancelled", this); + }; + + Promise.prototype._setWillBeCancelled = function () { + this._bitField = this._bitField | 8388608; + }; + + Promise.prototype._setAsyncGuaranteed = function () { + if (async.hasCustomScheduler()) return; + this._bitField = this._bitField | 134217728; + }; + + Promise.prototype._receiverAt = function (index) { + var ret = index === 0 ? this._receiver0 : this[index * 4 - 4 + 3]; + if (ret === UNDEFINED_BINDING) { + return undefined; + } else if (ret === undefined && this._isBound()) { + return this._boundValue(); + } + return ret; + }; + + Promise.prototype._promiseAt = function (index) { + return this[index * 4 - 4 + 2]; + }; + + Promise.prototype._fulfillmentHandlerAt = function (index) { + return this[index * 4 - 4 + 0]; + }; + + Promise.prototype._rejectionHandlerAt = function (index) { + return this[index * 4 - 4 + 1]; + }; + + Promise.prototype._boundValue = function () {}; + + Promise.prototype._migrateCallback0 = function (follower) { + var bitField = follower._bitField; + var fulfill = follower._fulfillmentHandler0; + var reject = follower._rejectionHandler0; + var promise = follower._promise0; + var receiver = follower._receiverAt(0); + if (receiver === undefined) receiver = UNDEFINED_BINDING; + this._addCallbacks(fulfill, reject, promise, receiver, null); + }; + + Promise.prototype._migrateCallbackAt = function (follower, index) { + var fulfill = follower._fulfillmentHandlerAt(index); + var reject = follower._rejectionHandlerAt(index); + var promise = follower._promiseAt(index); + var receiver = follower._receiverAt(index); + if (receiver === undefined) receiver = UNDEFINED_BINDING; + this._addCallbacks(fulfill, reject, promise, receiver, null); + }; + + Promise.prototype._addCallbacks = function (fulfill, reject, promise, receiver, domain) { + var index = this._length(); + + if (index >= 65535 - 4) { + index = 0; + this._setLength(0); + } + + if (index === 0) { + this._promise0 = promise; + this._receiver0 = receiver; + if (typeof fulfill === "function") { + this._fulfillmentHandler0 = domain === null ? fulfill : util.domainBind(domain, fulfill); + } + if (typeof reject === "function") { + this._rejectionHandler0 = domain === null ? reject : util.domainBind(domain, reject); + } + } else { + var base = index * 4 - 4; + this[base + 2] = promise; + this[base + 3] = receiver; + if (typeof fulfill === "function") { + this[base + 0] = domain === null ? fulfill : util.domainBind(domain, fulfill); + } + if (typeof reject === "function") { + this[base + 1] = domain === null ? reject : util.domainBind(domain, reject); + } + } + this._setLength(index + 1); + return index; + }; + + Promise.prototype._proxy = function (proxyable, arg) { + this._addCallbacks(undefined, undefined, arg, proxyable, null); + }; + + Promise.prototype._resolveCallback = function (value, shouldBind) { + if ((this._bitField & 117506048) !== 0) return; + if (value === this) return this._rejectCallback(makeSelfResolutionError(), false); + var maybePromise = tryConvertToPromise(value, this); + if (!(maybePromise instanceof Promise)) return this._fulfill(value); + + if (shouldBind) this._propagateFrom(maybePromise, 2); + + var promise = maybePromise._target(); + + if (promise === this) { + this._reject(makeSelfResolutionError()); + return; + } + + var bitField = promise._bitField; + if ((bitField & 50397184) === 0) { + var len = this._length(); + if (len > 0) promise._migrateCallback0(this); + for (var i = 1; i < len; ++i) { + promise._migrateCallbackAt(this, i); + } + this._setFollowing(); + this._setLength(0); + this._setFollowee(promise); + } else if ((bitField & 33554432) !== 0) { + this._fulfill(promise._value()); + } else if ((bitField & 16777216) !== 0) { + this._reject(promise._reason()); + } else { + var reason = new CancellationError("late cancellation observer"); + promise._attachExtraTrace(reason); + this._reject(reason); + } + }; + + Promise.prototype._rejectCallback = function (reason, synchronous, ignoreNonErrorWarnings) { + var trace = util.ensureErrorObject(reason); + var hasStack = trace === reason; + if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) { + var message = "a promise was rejected with a non-error: " + util.classString(reason); + this._warn(message, true); + } + this._attachExtraTrace(trace, synchronous ? hasStack : false); + this._reject(reason); + }; + + Promise.prototype._resolveFromExecutor = function (executor) { + if (executor === INTERNAL) return; + var promise = this; + this._captureStackTrace(); + this._pushContext(); + var synchronous = true; + var r = this._execute(executor, function (value) { + promise._resolveCallback(value); + }, function (reason) { + promise._rejectCallback(reason, synchronous); + }); + synchronous = false; + this._popContext(); + + if (r !== undefined) { + promise._rejectCallback(r, true); + } + }; + + Promise.prototype._settlePromiseFromHandler = function (handler, receiver, value, promise) { + var bitField = promise._bitField; + if ((bitField & 65536) !== 0) return; + promise._pushContext(); + var x; + if (receiver === APPLY) { + if (!value || typeof value.length !== "number") { + x = errorObj; + x.e = new TypeError("cannot .spread() a non-array: " + util.classString(value)); + } else { + x = tryCatch(handler).apply(this._boundValue(), value); + } + } else { + x = tryCatch(handler).call(receiver, value); + } + var promiseCreated = promise._popContext(); + bitField = promise._bitField; + if ((bitField & 65536) !== 0) return; + + if (x === NEXT_FILTER) { + promise._reject(value); + } else if (x === errorObj) { + promise._rejectCallback(x.e, false); + } else { + debug.checkForgottenReturns(x, promiseCreated, "", promise, this); + promise._resolveCallback(x); + } + }; + + Promise.prototype._target = function () { + var ret = this; + while (ret._isFollowing()) { + ret = ret._followee(); + }return ret; + }; + + Promise.prototype._followee = function () { + return this._rejectionHandler0; + }; + + Promise.prototype._setFollowee = function (promise) { + this._rejectionHandler0 = promise; + }; + + Promise.prototype._settlePromise = function (promise, handler, receiver, value) { + var isPromise = promise instanceof Promise; + var bitField = this._bitField; + var asyncGuaranteed = (bitField & 134217728) !== 0; + if ((bitField & 65536) !== 0) { + if (isPromise) promise._invokeInternalOnCancel(); + + if (receiver instanceof PassThroughHandlerContext && receiver.isFinallyHandler()) { + receiver.cancelPromise = promise; + if (tryCatch(handler).call(receiver, value) === errorObj) { + promise._reject(errorObj.e); + } + } else if (handler === reflectHandler) { + promise._fulfill(reflectHandler.call(receiver)); + } else if (receiver instanceof Proxyable) { + receiver._promiseCancelled(promise); + } else if (isPromise || promise instanceof PromiseArray) { + promise._cancel(); + } else { + receiver.cancel(); + } + } else if (typeof handler === "function") { + if (!isPromise) { + handler.call(receiver, value, promise); + } else { + if (asyncGuaranteed) promise._setAsyncGuaranteed(); + this._settlePromiseFromHandler(handler, receiver, value, promise); + } + } else if (receiver instanceof Proxyable) { + if (!receiver._isResolved()) { + if ((bitField & 33554432) !== 0) { + receiver._promiseFulfilled(value, promise); + } else { + receiver._promiseRejected(value, promise); + } + } + } else if (isPromise) { + if (asyncGuaranteed) promise._setAsyncGuaranteed(); + if ((bitField & 33554432) !== 0) { + promise._fulfill(value); + } else { + promise._reject(value); + } + } + }; + + Promise.prototype._settlePromiseLateCancellationObserver = function (ctx) { + var handler = ctx.handler; + var promise = ctx.promise; + var receiver = ctx.receiver; + var value = ctx.value; + if (typeof handler === "function") { + if (!(promise instanceof Promise)) { + handler.call(receiver, value, promise); + } else { + this._settlePromiseFromHandler(handler, receiver, value, promise); + } + } else if (promise instanceof Promise) { + promise._reject(value); + } + }; + + Promise.prototype._settlePromiseCtx = function (ctx) { + this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value); + }; + + Promise.prototype._settlePromise0 = function (handler, value, bitField) { + var promise = this._promise0; + var receiver = this._receiverAt(0); + this._promise0 = undefined; + this._receiver0 = undefined; + this._settlePromise(promise, handler, receiver, value); + }; + + Promise.prototype._clearCallbackDataAtIndex = function (index) { + var base = index * 4 - 4; + this[base + 2] = this[base + 3] = this[base + 0] = this[base + 1] = undefined; + }; + + Promise.prototype._fulfill = function (value) { + var bitField = this._bitField; + if ((bitField & 117506048) >>> 16) return; + if (value === this) { + var err = makeSelfResolutionError(); + this._attachExtraTrace(err); + return this._reject(err); + } + this._setFulfilled(); + this._rejectionHandler0 = value; + + if ((bitField & 65535) > 0) { + if ((bitField & 134217728) !== 0) { + this._settlePromises(); + } else { + async.settlePromises(this); + } + } + }; + + Promise.prototype._reject = function (reason) { + var bitField = this._bitField; + if ((bitField & 117506048) >>> 16) return; + this._setRejected(); + this._fulfillmentHandler0 = reason; + + if (this._isFinal()) { + return async.fatalError(reason, util.isNode); + } + + if ((bitField & 65535) > 0) { + async.settlePromises(this); + } else { + this._ensurePossibleRejectionHandled(); + } + }; + + Promise.prototype._fulfillPromises = function (len, value) { + for (var i = 1; i < len; i++) { + var handler = this._fulfillmentHandlerAt(i); + var promise = this._promiseAt(i); + var receiver = this._receiverAt(i); + this._clearCallbackDataAtIndex(i); + this._settlePromise(promise, handler, receiver, value); + } + }; + + Promise.prototype._rejectPromises = function (len, reason) { + for (var i = 1; i < len; i++) { + var handler = this._rejectionHandlerAt(i); + var promise = this._promiseAt(i); + var receiver = this._receiverAt(i); + this._clearCallbackDataAtIndex(i); + this._settlePromise(promise, handler, receiver, reason); + } + }; + + Promise.prototype._settlePromises = function () { + var bitField = this._bitField; + var len = bitField & 65535; + + if (len > 0) { + if ((bitField & 16842752) !== 0) { + var reason = this._fulfillmentHandler0; + this._settlePromise0(this._rejectionHandler0, reason, bitField); + this._rejectPromises(len, reason); + } else { + var value = this._rejectionHandler0; + this._settlePromise0(this._fulfillmentHandler0, value, bitField); + this._fulfillPromises(len, value); + } + this._setLength(0); + } + this._clearCancellationData(); + }; + + Promise.prototype._settledValue = function () { + var bitField = this._bitField; + if ((bitField & 33554432) !== 0) { + return this._rejectionHandler0; + } else if ((bitField & 16777216) !== 0) { + return this._fulfillmentHandler0; + } + }; + + function deferResolve(v) { + this.promise._resolveCallback(v); + } + function deferReject(v) { + this.promise._rejectCallback(v, false); + } + + Promise.defer = Promise.pending = function () { + debug.deprecated("Promise.defer", "new Promise"); + var promise = new Promise(INTERNAL); + return { + promise: promise, + resolve: deferResolve, + reject: deferReject + }; + }; + + util.notEnumerableProp(Promise, "_makeSelfResolutionError", makeSelfResolutionError); + + __webpack_require__(19)(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug); + __webpack_require__(20)(Promise, INTERNAL, tryConvertToPromise, debug); + __webpack_require__(21)(Promise, PromiseArray, apiRejection, debug); + __webpack_require__(22)(Promise); + __webpack_require__(23)(Promise); + __webpack_require__(24)(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain); + Promise.Promise = Promise; + Promise.version = "3.5.0"; + __webpack_require__(25)(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug); + __webpack_require__(26)(Promise); + __webpack_require__(27)(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug); + __webpack_require__(28)(Promise, INTERNAL, debug); + __webpack_require__(29)(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug); + __webpack_require__(30)(Promise); + __webpack_require__(31)(Promise, INTERNAL); + __webpack_require__(32)(Promise, PromiseArray, tryConvertToPromise, apiRejection); + __webpack_require__(33)(Promise, INTERNAL, tryConvertToPromise, apiRejection); + __webpack_require__(34)(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug); + __webpack_require__(35)(Promise, PromiseArray, debug); + __webpack_require__(36)(Promise, PromiseArray, apiRejection); + __webpack_require__(37)(Promise, INTERNAL); + __webpack_require__(38)(Promise, INTERNAL); + __webpack_require__(39)(Promise); + + util.toFastProperties(Promise); + util.toFastProperties(Promise.prototype); + function fillTypes(value) { + var p = new Promise(INTERNAL); + p._fulfillmentHandler0 = value; + p._rejectionHandler0 = value; + p._promise0 = value; + p._receiver0 = value; + } + // Complete slack tracking, opt out of field-type tracking and + // stabilize map + fillTypes({ a: 1 }); + fillTypes({ b: 2 }); + fillTypes({ c: 3 }); + fillTypes(1); + fillTypes(function () {}); + fillTypes(undefined); + fillTypes(false); + fillTypes(new Promise(INTERNAL)); + debug.setBounds(Async.firstLineError, util.lastLineError); + return Promise; + }; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + 'use strict'; + + // shim for using process in browser + var process = module.exports = {}; + + // cached from whatever global is present so that test runners that stub it + // don't break things. But we need to wrap it in a try catch in case it is + // wrapped in strict mode code which doesn't define any globals. It's inside a + // function because try/catches deoptimize in certain engines. + + var cachedSetTimeout; + var cachedClearTimeout; + + function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); + } + function defaultClearTimeout() { + throw new Error('clearTimeout has not been defined'); + } + (function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } + })(); + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch (e) { + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch (e) { + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + } + function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e) { + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e) { + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + } + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + + function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + + function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while (len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); + } + + process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } + }; + + // v8 likes predictible objects + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + process.title = 'browser'; + process.browser = true; + process.env = {}; + process.argv = []; + process.version = ''; // empty string to avoid regexp issues + process.versions = {}; + + function noop() {} + + process.on = noop; + process.addListener = noop; + process.once = noop; + process.off = noop; + process.removeListener = noop; + process.removeAllListeners = noop; + process.emit = noop; + + process.binding = function (name) { + throw new Error('process.binding is not supported'); + }; + + process.cwd = function () { + return '/'; + }; + process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); + }; + process.umask = function () { + return 0; + }; + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global, process) {"use strict"; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + var es5 = __webpack_require__(5); + var canEvaluate = typeof navigator == "undefined"; + + var errorObj = { e: {} }; + var tryCatchTarget; + var globalObject = typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : undefined !== undefined ? undefined : null; + + function tryCatcher() { + try { + var target = tryCatchTarget; + tryCatchTarget = null; + return target.apply(this, arguments); + } catch (e) { + errorObj.e = e; + return errorObj; + } + } + function tryCatch(fn) { + tryCatchTarget = fn; + return tryCatcher; + } + + var inherits = function inherits(Child, Parent) { + var hasProp = {}.hasOwnProperty; + + function T() { + this.constructor = Child; + this.constructor$ = Parent; + for (var propertyName in Parent.prototype) { + if (hasProp.call(Parent.prototype, propertyName) && propertyName.charAt(propertyName.length - 1) !== "$") { + this[propertyName + "$"] = Parent.prototype[propertyName]; + } + } + } + T.prototype = Parent.prototype; + Child.prototype = new T(); + return Child.prototype; + }; + + function isPrimitive(val) { + return val == null || val === true || val === false || typeof val === "string" || typeof val === "number"; + } + + function isObject(value) { + return typeof value === "function" || (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value !== null; + } + + function maybeWrapAsError(maybeError) { + if (!isPrimitive(maybeError)) return maybeError; + + return new Error(safeToString(maybeError)); + } + + function withAppended(target, appendee) { + var len = target.length; + var ret = new Array(len + 1); + var i; + for (i = 0; i < len; ++i) { + ret[i] = target[i]; + } + ret[i] = appendee; + return ret; + } + + function getDataPropertyOrDefault(obj, key, defaultValue) { + if (es5.isES5) { + var desc = Object.getOwnPropertyDescriptor(obj, key); + + if (desc != null) { + return desc.get == null && desc.set == null ? desc.value : defaultValue; + } + } else { + return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined; + } + } + + function notEnumerableProp(obj, name, value) { + if (isPrimitive(obj)) return obj; + var descriptor = { + value: value, + configurable: true, + enumerable: false, + writable: true + }; + es5.defineProperty(obj, name, descriptor); + return obj; + } + + function thrower(r) { + throw r; + } + + var inheritedDataKeys = function () { + var excludedPrototypes = [Array.prototype, Object.prototype, Function.prototype]; + + var isExcludedProto = function isExcludedProto(val) { + for (var i = 0; i < excludedPrototypes.length; ++i) { + if (excludedPrototypes[i] === val) { + return true; + } + } + return false; + }; + + if (es5.isES5) { + var getKeys = Object.getOwnPropertyNames; + return function (obj) { + var ret = []; + var visitedKeys = Object.create(null); + while (obj != null && !isExcludedProto(obj)) { + var keys; + try { + keys = getKeys(obj); + } catch (e) { + return ret; + } + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (visitedKeys[key]) continue; + visitedKeys[key] = true; + var desc = Object.getOwnPropertyDescriptor(obj, key); + if (desc != null && desc.get == null && desc.set == null) { + ret.push(key); + } + } + obj = es5.getPrototypeOf(obj); + } + return ret; + }; + } else { + var hasProp = {}.hasOwnProperty; + return function (obj) { + if (isExcludedProto(obj)) return []; + var ret = []; + + /*jshint forin:false */ + enumeration: for (var key in obj) { + if (hasProp.call(obj, key)) { + ret.push(key); + } else { + for (var i = 0; i < excludedPrototypes.length; ++i) { + if (hasProp.call(excludedPrototypes[i], key)) { + continue enumeration; + } + } + ret.push(key); + } + } + return ret; + }; + } + }(); + + var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/; + function isClass(fn) { + try { + if (typeof fn === "function") { + var keys = es5.names(fn.prototype); + + var hasMethods = es5.isES5 && keys.length > 1; + var hasMethodsOtherThanConstructor = keys.length > 0 && !(keys.length === 1 && keys[0] === "constructor"); + var hasThisAssignmentAndStaticMethods = thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0; + + if (hasMethods || hasMethodsOtherThanConstructor || hasThisAssignmentAndStaticMethods) { + return true; + } + } + return false; + } catch (e) { + return false; + } + } + + function toFastProperties(obj) { + /*jshint -W027,-W055,-W031*/ + function FakeConstructor() {} + FakeConstructor.prototype = obj; + var l = 8; + while (l--) { + new FakeConstructor(); + }return obj; + eval(obj); + } + + var rident = /^[a-z$_][a-z$_0-9]*$/i; + function isIdentifier(str) { + return rident.test(str); + } + + function filledRange(count, prefix, suffix) { + var ret = new Array(count); + for (var i = 0; i < count; ++i) { + ret[i] = prefix + i + suffix; + } + return ret; + } + + function safeToString(obj) { + try { + return obj + ""; + } catch (e) { + return "[no string representation]"; + } + } + + function isError(obj) { + return obj !== null && (typeof obj === "undefined" ? "undefined" : _typeof(obj)) === "object" && typeof obj.message === "string" && typeof obj.name === "string"; + } + + function markAsOriginatingFromRejection(e) { + try { + notEnumerableProp(e, "isOperational", true); + } catch (ignore) {} + } + + function originatesFromRejection(e) { + if (e == null) return false; + return e instanceof Error["__BluebirdErrorTypes__"].OperationalError || e["isOperational"] === true; + } + + function canAttachTrace(obj) { + return isError(obj) && es5.propertyIsWritable(obj, "stack"); + } + + var ensureErrorObject = function () { + if (!("stack" in new Error())) { + return function (value) { + if (canAttachTrace(value)) return value; + try { + throw new Error(safeToString(value)); + } catch (err) { + return err; + } + }; + } else { + return function (value) { + if (canAttachTrace(value)) return value; + return new Error(safeToString(value)); + }; + } + }(); + + function classString(obj) { + return {}.toString.call(obj); + } + + function copyDescriptors(from, to, filter) { + var keys = es5.names(from); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (filter(key)) { + try { + es5.defineProperty(to, key, es5.getDescriptor(from, key)); + } catch (ignore) {} + } + } + } + + var asArray = function asArray(v) { + if (es5.isArray(v)) { + return v; + } + return null; + }; + + if (typeof Symbol !== "undefined" && Symbol.iterator) { + var ArrayFrom = typeof Array.from === "function" ? function (v) { + return Array.from(v); + } : function (v) { + var ret = []; + var it = v[Symbol.iterator](); + var itResult; + while (!(itResult = it.next()).done) { + ret.push(itResult.value); + } + return ret; + }; + + asArray = function asArray(v) { + if (es5.isArray(v)) { + return v; + } else if (v != null && typeof v[Symbol.iterator] === "function") { + return ArrayFrom(v); + } + return null; + }; + } + + var isNode = typeof process !== "undefined" && classString(process).toLowerCase() === "[object process]"; + + var hasEnvVariables = typeof process !== "undefined" && typeof process.env !== "undefined"; + + function env(key) { + return hasEnvVariables ? process.env[key] : undefined; + } + + function getNativePromise() { + if (typeof Promise === "function") { + try { + var promise = new Promise(function () {}); + if ({}.toString.call(promise) === "[object Promise]") { + return Promise; + } + } catch (e) {} + } + } + + function domainBind(self, cb) { + return self.bind(cb); + } + + var ret = { + isClass: isClass, + isIdentifier: isIdentifier, + inheritedDataKeys: inheritedDataKeys, + getDataPropertyOrDefault: getDataPropertyOrDefault, + thrower: thrower, + isArray: es5.isArray, + asArray: asArray, + notEnumerableProp: notEnumerableProp, + isPrimitive: isPrimitive, + isObject: isObject, + isError: isError, + canEvaluate: canEvaluate, + errorObj: errorObj, + tryCatch: tryCatch, + inherits: inherits, + withAppended: withAppended, + maybeWrapAsError: maybeWrapAsError, + toFastProperties: toFastProperties, + filledRange: filledRange, + toString: safeToString, + canAttachTrace: canAttachTrace, + ensureErrorObject: ensureErrorObject, + originatesFromRejection: originatesFromRejection, + markAsOriginatingFromRejection: markAsOriginatingFromRejection, + classString: classString, + copyDescriptors: copyDescriptors, + hasDevTools: typeof chrome !== "undefined" && chrome && typeof chrome.loadTimes === "function", + isNode: isNode, + hasEnvVariables: hasEnvVariables, + env: env, + global: globalObject, + getNativePromise: getNativePromise, + domainBind: domainBind + }; + ret.isRecentNode = ret.isNode && function () { + var version = process.versions.node.split(".").map(Number); + return version[0] === 0 && version[1] > 10 || version[0] > 0; + }(); + + if (ret.isNode) ret.toFastProperties(process); + + try { + throw new Error(); + } catch (e) { + ret.lastLineError = e; + } + module.exports = ret; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(3))) + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + "use strict"; + + var isES5 = function () { + "use strict"; + + return this === undefined; + }(); + + if (isES5) { + module.exports = { + freeze: Object.freeze, + defineProperty: Object.defineProperty, + getDescriptor: Object.getOwnPropertyDescriptor, + keys: Object.keys, + names: Object.getOwnPropertyNames, + getPrototypeOf: Object.getPrototypeOf, + isArray: Array.isArray, + isES5: isES5, + propertyIsWritable: function propertyIsWritable(obj, prop) { + var descriptor = Object.getOwnPropertyDescriptor(obj, prop); + return !!(!descriptor || descriptor.writable || descriptor.set); + } + }; + } else { + var has = {}.hasOwnProperty; + var str = {}.toString; + var proto = {}.constructor.prototype; + + var ObjectKeys = function ObjectKeys(o) { + var ret = []; + for (var key in o) { + if (has.call(o, key)) { + ret.push(key); + } + } + return ret; + }; + + var ObjectGetDescriptor = function ObjectGetDescriptor(o, key) { + return { value: o[key] }; + }; + + var ObjectDefineProperty = function ObjectDefineProperty(o, key, desc) { + o[key] = desc.value; + return o; + }; + + var ObjectFreeze = function ObjectFreeze(obj) { + return obj; + }; + + var ObjectGetPrototypeOf = function ObjectGetPrototypeOf(obj) { + try { + return Object(obj).constructor.prototype; + } catch (e) { + return proto; + } + }; + + var ArrayIsArray = function ArrayIsArray(obj) { + try { + return str.call(obj) === "[object Array]"; + } catch (e) { + return false; + } + }; + + module.exports = { + isArray: ArrayIsArray, + keys: ObjectKeys, + names: ObjectKeys, + defineProperty: ObjectDefineProperty, + getDescriptor: ObjectGetDescriptor, + freeze: ObjectFreeze, + getPrototypeOf: ObjectGetPrototypeOf, + isES5: isES5, + propertyIsWritable: function propertyIsWritable() { + return true; + } + }; + } + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {"use strict"; + + var firstLineError; + try { + throw new Error(); + } catch (e) { + firstLineError = e; + } + var schedule = __webpack_require__(7); + var Queue = __webpack_require__(10); + var util = __webpack_require__(4); + + function Async() { + this._customScheduler = false; + this._isTickUsed = false; + this._lateQueue = new Queue(16); + this._normalQueue = new Queue(16); + this._haveDrainedQueues = false; + this._trampolineEnabled = true; + var self = this; + this.drainQueues = function () { + self._drainQueues(); + }; + this._schedule = schedule; + } + + Async.prototype.setScheduler = function (fn) { + var prev = this._schedule; + this._schedule = fn; + this._customScheduler = true; + return prev; + }; + + Async.prototype.hasCustomScheduler = function () { + return this._customScheduler; + }; + + Async.prototype.enableTrampoline = function () { + this._trampolineEnabled = true; + }; + + Async.prototype.disableTrampolineIfNecessary = function () { + if (util.hasDevTools) { + this._trampolineEnabled = false; + } + }; + + Async.prototype.haveItemsQueued = function () { + return this._isTickUsed || this._haveDrainedQueues; + }; + + Async.prototype.fatalError = function (e, isNode) { + if (isNode) { + process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) + "\n"); + process.exit(2); + } else { + this.throwLater(e); + } + }; + + Async.prototype.throwLater = function (fn, arg) { + if (arguments.length === 1) { + arg = fn; + fn = function fn() { + throw arg; + }; + } + if (typeof setTimeout !== "undefined") { + setTimeout(function () { + fn(arg); + }, 0); + } else try { + this._schedule(function () { + fn(arg); + }); + } catch (e) { + throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n"); + } + }; + + function AsyncInvokeLater(fn, receiver, arg) { + this._lateQueue.push(fn, receiver, arg); + this._queueTick(); + } + + function AsyncInvoke(fn, receiver, arg) { + this._normalQueue.push(fn, receiver, arg); + this._queueTick(); + } + + function AsyncSettlePromises(promise) { + this._normalQueue._pushOne(promise); + this._queueTick(); + } + + if (!util.hasDevTools) { + Async.prototype.invokeLater = AsyncInvokeLater; + Async.prototype.invoke = AsyncInvoke; + Async.prototype.settlePromises = AsyncSettlePromises; + } else { + Async.prototype.invokeLater = function (fn, receiver, arg) { + if (this._trampolineEnabled) { + AsyncInvokeLater.call(this, fn, receiver, arg); + } else { + this._schedule(function () { + setTimeout(function () { + fn.call(receiver, arg); + }, 100); + }); + } + }; + + Async.prototype.invoke = function (fn, receiver, arg) { + if (this._trampolineEnabled) { + AsyncInvoke.call(this, fn, receiver, arg); + } else { + this._schedule(function () { + fn.call(receiver, arg); + }); + } + }; + + Async.prototype.settlePromises = function (promise) { + if (this._trampolineEnabled) { + AsyncSettlePromises.call(this, promise); + } else { + this._schedule(function () { + promise._settlePromises(); + }); + } + }; + } + + Async.prototype._drainQueue = function (queue) { + while (queue.length() > 0) { + var fn = queue.shift(); + if (typeof fn !== "function") { + fn._settlePromises(); + continue; + } + var receiver = queue.shift(); + var arg = queue.shift(); + fn.call(receiver, arg); + } + }; + + Async.prototype._drainQueues = function () { + this._drainQueue(this._normalQueue); + this._reset(); + this._haveDrainedQueues = true; + this._drainQueue(this._lateQueue); + }; + + Async.prototype._queueTick = function () { + if (!this._isTickUsed) { + this._isTickUsed = true; + this._schedule(this.drainQueues); + } + }; + + Async.prototype._reset = function () { + this._isTickUsed = false; + }; + + module.exports = Async; + module.exports.firstLineError = firstLineError; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global, process, setImmediate) {"use strict"; + + var util = __webpack_require__(4); + var schedule; + var noAsyncScheduler = function noAsyncScheduler() { + throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n"); + }; + var NativePromise = util.getNativePromise(); + if (util.isNode && typeof MutationObserver === "undefined") { + var GlobalSetImmediate = global.setImmediate; + var ProcessNextTick = process.nextTick; + schedule = util.isRecentNode ? function (fn) { + GlobalSetImmediate.call(global, fn); + } : function (fn) { + ProcessNextTick.call(process, fn); + }; + } else if (typeof NativePromise === "function" && typeof NativePromise.resolve === "function") { + var nativePromise = NativePromise.resolve(); + schedule = function schedule(fn) { + nativePromise.then(fn); + }; + } else if (typeof MutationObserver !== "undefined" && !(typeof window !== "undefined" && window.navigator && (window.navigator.standalone || window.cordova))) { + schedule = function () { + var div = document.createElement("div"); + var opts = { attributes: true }; + var toggleScheduled = false; + var div2 = document.createElement("div"); + var o2 = new MutationObserver(function () { + div.classList.toggle("foo"); + toggleScheduled = false; + }); + o2.observe(div2, opts); + + var scheduleToggle = function scheduleToggle() { + if (toggleScheduled) return; + toggleScheduled = true; + div2.classList.toggle("foo"); + }; + + return function schedule(fn) { + var o = new MutationObserver(function () { + o.disconnect(); + fn(); + }); + o.observe(div, opts); + scheduleToggle(); + }; + }(); + } else if (typeof setImmediate !== "undefined") { + schedule = function schedule(fn) { + setImmediate(fn); + }; + } else if (typeof setTimeout !== "undefined") { + schedule = function schedule(fn) { + setTimeout(fn, 0); + }; + } else { + schedule = noAsyncScheduler; + } + module.exports = schedule; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(3), __webpack_require__(8).setImmediate)) + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + + var apply = Function.prototype.apply; + + // DOM APIs, for completeness + + exports.setTimeout = function () { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); + }; + exports.setInterval = function () { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); + }; + exports.clearTimeout = exports.clearInterval = function (timeout) { + if (timeout) { + timeout.close(); + } + }; + + function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; + } + Timeout.prototype.unref = Timeout.prototype.ref = function () {}; + Timeout.prototype.close = function () { + this._clearFn.call(window, this._id); + }; + + // Does not start the time, just sets up the members needed. + exports.enroll = function (item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; + }; + + exports.unenroll = function (item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; + }; + + exports._unrefActive = exports.active = function (item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) item._onTimeout(); + }, msecs); + } + }; + + // setimmediate attaches itself to the global object + __webpack_require__(9); + exports.setImmediate = setImmediate; + exports.clearImmediate = clearImmediate; + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global, process) {"use strict"; + + (function (global, undefined) { + "use strict"; + + if (global.setImmediate) { + return; + } + + var nextHandle = 1; // Spec says greater than zero + var tasksByHandle = {}; + var currentlyRunningATask = false; + var doc = global.document; + var registerImmediate; + + function setImmediate(callback) { + // Callback can either be a function or a string + if (typeof callback !== "function") { + callback = new Function("" + callback); + } + // Copy function arguments + var args = new Array(arguments.length - 1); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i + 1]; + } + // Store and register the task + var task = { callback: callback, args: args }; + tasksByHandle[nextHandle] = task; + registerImmediate(nextHandle); + return nextHandle++; + } + + function clearImmediate(handle) { + delete tasksByHandle[handle]; + } + + function run(task) { + var callback = task.callback; + var args = task.args; + switch (args.length) { + case 0: + callback(); + break; + case 1: + callback(args[0]); + break; + case 2: + callback(args[0], args[1]); + break; + case 3: + callback(args[0], args[1], args[2]); + break; + default: + callback.apply(undefined, args); + break; + } + } + + function runIfPresent(handle) { + // From the spec: "Wait until any invocations of this algorithm started before this one have completed." + // So if we're currently running a task, we'll need to delay this invocation. + if (currentlyRunningATask) { + // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a + // "too much recursion" error. + setTimeout(runIfPresent, 0, handle); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunningATask = true; + try { + run(task); + } finally { + clearImmediate(handle); + currentlyRunningATask = false; + } + } + } + } + + function installNextTickImplementation() { + registerImmediate = function registerImmediate(handle) { + process.nextTick(function () { + runIfPresent(handle); + }); + }; + } + + function canUsePostMessage() { + // The test against `importScripts` prevents this implementation from being installed inside a web worker, + // where `global.postMessage` means something completely different and can't be used for this purpose. + if (global.postMessage && !global.importScripts) { + var postMessageIsAsynchronous = true; + var oldOnMessage = global.onmessage; + global.onmessage = function () { + postMessageIsAsynchronous = false; + }; + global.postMessage("", "*"); + global.onmessage = oldOnMessage; + return postMessageIsAsynchronous; + } + } + + function installPostMessageImplementation() { + // Installs an event handler on `global` for the `message` event: see + // * https://developer.mozilla.org/en/DOM/window.postMessage + // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages + + var messagePrefix = "setImmediate$" + Math.random() + "$"; + var onGlobalMessage = function onGlobalMessage(event) { + if (event.source === global && typeof event.data === "string" && event.data.indexOf(messagePrefix) === 0) { + runIfPresent(+event.data.slice(messagePrefix.length)); + } + }; + + if (global.addEventListener) { + global.addEventListener("message", onGlobalMessage, false); + } else { + global.attachEvent("onmessage", onGlobalMessage); + } + + registerImmediate = function registerImmediate(handle) { + global.postMessage(messagePrefix + handle, "*"); + }; + } + + function installMessageChannelImplementation() { + var channel = new MessageChannel(); + channel.port1.onmessage = function (event) { + var handle = event.data; + runIfPresent(handle); + }; + + registerImmediate = function registerImmediate(handle) { + channel.port2.postMessage(handle); + }; + } + + function installReadyStateChangeImplementation() { + var html = doc.documentElement; + registerImmediate = function registerImmediate(handle) { + // Create a