UNPKG

cordova-app-loader

Version:

Cordova App Loader - remote update your cordova app

1,434 lines (1,305 loc) 180 kB
/** * bluebird build version 2.3.11 * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, progress, cancel, using, filter, any, each, timers */ /** * @preserve The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.Promise=e():"undefined"!=typeof global?global.Promise=e():"undefined"!=typeof self&&(self.Promise=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(Promise) { var SomePromiseArray = Promise._SomePromiseArray; function Promise$_Any(promises) { var ret = new SomePromiseArray(promises); var promise = ret.promise(); if (promise.isRejected()) { return promise; } ret.setHowMany(1); ret.setUnwrap(); ret.init(); return promise; } Promise.any = function Promise$Any(promises) { return Promise$_Any(promises); }; Promise.prototype.any = function Promise$any() { return Promise$_Any(this); }; }; },{}],2:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; var schedule = require("./schedule.js"); var Queue = require("./queue.js"); var errorObj = require("./util.js").errorObj; var tryCatch1 = require("./util.js").tryCatch1; var _process = typeof process !== "undefined" ? process : void 0; function Async() { this._isTickUsed = false; this._schedule = schedule; this._length = 0; this._lateBuffer = new Queue(16); this._functionBuffer = new Queue(65536); var self = this; this.consumeFunctionBuffer = function Async$consumeFunctionBuffer() { self._consumeFunctionBuffer(); }; } Async.prototype.haveItemsQueued = function Async$haveItemsQueued() { return this._length > 0; }; Async.prototype.invokeLater = function Async$invokeLater(fn, receiver, arg) { if (_process !== void 0 && _process.domain != null && !fn.domain) { fn = _process.domain.bind(fn); } this._lateBuffer.push(fn, receiver, arg); this._queueTick(); }; Async.prototype.invoke = function Async$invoke(fn, receiver, arg) { if (_process !== void 0 && _process.domain != null && !fn.domain) { fn = _process.domain.bind(fn); } var functionBuffer = this._functionBuffer; functionBuffer.push(fn, receiver, arg); this._length = functionBuffer.length(); this._queueTick(); }; Async.prototype._consumeFunctionBuffer = function Async$_consumeFunctionBuffer() { var functionBuffer = this._functionBuffer; while (functionBuffer.length() > 0) { var fn = functionBuffer.shift(); var receiver = functionBuffer.shift(); var arg = functionBuffer.shift(); fn.call(receiver, arg); } this._reset(); this._consumeLateBuffer(); }; Async.prototype._consumeLateBuffer = function Async$_consumeLateBuffer() { var buffer = this._lateBuffer; while(buffer.length() > 0) { var fn = buffer.shift(); var receiver = buffer.shift(); var arg = buffer.shift(); var res = tryCatch1(fn, receiver, arg); if (res === errorObj) { this._queueTick(); if (fn.domain != null) { fn.domain.emit("error", res.e); } else { throw res.e; } } } }; Async.prototype._queueTick = function Async$_queue() { if (!this._isTickUsed) { this._schedule(this.consumeFunctionBuffer); this._isTickUsed = true; } }; Async.prototype._reset = function Async$_reset() { this._isTickUsed = false; this._length = 0; }; module.exports = new Async(); },{"./queue.js":25,"./schedule.js":28,"./util.js":35}],3:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; var Promise = require("./promise.js")(); module.exports = Promise; },{"./promise.js":20}],4:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; var cr = Object.create; if (cr) { var callerCache = cr(null); var getterCache = cr(null); callerCache[" size"] = getterCache[" size"] = 0; } module.exports = function(Promise) { var util = require("./util.js"); var canEvaluate = util.canEvaluate; var isIdentifier = util.isIdentifier; function makeMethodCaller (methodName) { return new Function("obj", " \n\ 'use strict' \n\ var len = this.length; \n\ switch(len) { \n\ case 1: return obj.methodName(this[0]); \n\ case 2: return obj.methodName(this[0], this[1]); \n\ case 3: return obj.methodName(this[0], this[1], this[2]); \n\ case 0: return obj.methodName(); \n\ default: return obj.methodName.apply(obj, this); \n\ } \n\ ".replace(/methodName/g, methodName)); } function makeGetter (propertyName) { return new Function("obj", " \n\ 'use strict'; \n\ return obj.propertyName; \n\ ".replace("propertyName", propertyName)); } function getCompiled(name, compiler, cache) { var ret = cache[name]; if (typeof ret !== "function") { if (!isIdentifier(name)) { return null; } ret = compiler(name); cache[name] = ret; cache[" size"]++; if (cache[" size"] > 512) { var keys = Object.keys(cache); for (var i = 0; i < 256; ++i) delete cache[keys[i]]; cache[" size"] = keys.length - 256; } } return ret; } function getMethodCaller(name) { return getCompiled(name, makeMethodCaller, callerCache); } function getGetter(name) { return getCompiled(name, makeGetter, getterCache); } function caller(obj) { return obj[this.pop()].apply(obj, this); } Promise.prototype.call = function Promise$call(methodName) { var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];} if (canEvaluate) { var maybeCaller = getMethodCaller(methodName); if (maybeCaller !== null) { return this._then(maybeCaller, void 0, void 0, args, void 0); } } args.push(methodName); return this._then(caller, void 0, void 0, args, void 0); }; function namedGetter(obj) { return obj[this]; } function indexedGetter(obj) { return obj[this]; } Promise.prototype.get = function Promise$get(propertyName) { var isIndex = (typeof propertyName === "number"); var getter; if (!isIndex) { if (canEvaluate) { var maybeGetter = getGetter(propertyName); getter = maybeGetter !== null ? maybeGetter : namedGetter; } else { getter = namedGetter; } } else { getter = indexedGetter; } return this._then(getter, void 0, void 0, propertyName, void 0); }; }; },{"./util.js":35}],5:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(Promise, INTERNAL) { var errors = require("./errors.js"); var canAttach = errors.canAttach; var async = require("./async.js"); var CancellationError = errors.CancellationError; Promise.prototype._cancel = function Promise$_cancel(reason) { if (!this.isCancellable()) return this; var parent; var promiseToReject = this; while ((parent = promiseToReject._cancellationParent) !== void 0 && parent.isCancellable()) { promiseToReject = parent; } this._unsetCancellable(); promiseToReject._attachExtraTrace(reason); promiseToReject._rejectUnchecked(reason); }; Promise.prototype.cancel = function Promise$cancel(reason) { if (!this.isCancellable()) return this; reason = reason !== void 0 ? (canAttach(reason) ? reason : new Error(reason + "")) : new CancellationError(); async.invokeLater(this._cancel, this, reason); return this; }; Promise.prototype.cancellable = function Promise$cancellable() { if (this._cancellable()) return this; this._setCancellable(); this._cancellationParent = void 0; return this; }; Promise.prototype.uncancellable = function Promise$uncancellable() { var ret = new Promise(INTERNAL); ret._propagateFrom(this, 2 | 4); ret._follow(this); ret._unsetCancellable(); return ret; }; Promise.prototype.fork = function Promise$fork(didFulfill, didReject, didProgress) { var ret = this._then(didFulfill, didReject, didProgress, void 0, void 0); ret._setCancellable(); ret._cancellationParent = void 0; return ret; }; }; },{"./async.js":2,"./errors.js":10}],6:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function() { var inherits = require("./util.js").inherits; var defineProperty = require("./es5.js").defineProperty; var rignore = new RegExp( "\\b(?:[a-zA-Z0-9.]+\\$_\\w+|" + "tryCatch(?:1|2|3|4|Apply)|new \\w*PromiseArray|" + "\\w*PromiseArray\\.\\w*PromiseArray|" + "setTimeout|CatchFilter\\$_\\w+|makeNodePromisified|processImmediate|" + "process._tickCallback|nextTick|Async\\$\\w+)\\b" ); var rtraceline = null; var formatStack = null; function formatNonError(obj) { var str; if (typeof obj === "function") { str = "[function " + (obj.name || "anonymous") + "]"; } else { str = obj.toString(); var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/; if (ruselessToString.test(str)) { try { var newStr = JSON.stringify(obj); str = newStr; } catch(e) { } } if (str.length === 0) { str = "(empty array)"; } } return ("(<" + snip(str) + ">, no stack trace)"); } function snip(str) { var maxChars = 41; if (str.length < maxChars) { return str; } return str.substr(0, maxChars - 3) + "..."; } function CapturedTrace(ignoreUntil, isTopLevel) { this.captureStackTrace(CapturedTrace, isTopLevel); } inherits(CapturedTrace, Error); CapturedTrace.prototype.captureStackTrace = function CapturedTrace$captureStackTrace(ignoreUntil, isTopLevel) { captureStackTrace(this, ignoreUntil, isTopLevel); }; CapturedTrace.possiblyUnhandledRejection = function CapturedTrace$PossiblyUnhandledRejection(reason) { if (typeof console === "object") { var message; if (typeof reason === "object" || typeof reason === "function") { var stack = reason.stack; message = "Possibly unhandled " + formatStack(stack, reason); } else { message = "Possibly unhandled " + String(reason); } if (typeof console.error === "function" || typeof console.error === "object") { console.error(message); } else if (typeof console.log === "function" || typeof console.log === "object") { console.log(message); } } }; CapturedTrace.combine = function CapturedTrace$Combine(current, prev) { var currentLastIndex = current.length - 1; var currentLastLine = current[currentLastIndex]; var commonRootMeetPoint = -1; for (var i = prev.length - 1; i >= 0; --i) { if (prev[i] === currentLastLine) { commonRootMeetPoint = i; break; } } for (var i = commonRootMeetPoint; i >= 0; --i) { var line = prev[i]; if (current[currentLastIndex] === line) { current.pop(); currentLastIndex--; } else { break; } } current.push("From previous event:"); var lines = current.concat(prev); var ret = []; for (var i = 0, len = lines.length; i < len; ++i) { if (((rignore.test(lines[i]) && rtraceline.test(lines[i])) || (i > 0 && !rtraceline.test(lines[i])) && lines[i] !== "From previous event:") ) { continue; } ret.push(lines[i]); } return ret; }; CapturedTrace.protectErrorMessageNewlines = function(stack) { for (var i = 0; i < stack.length; ++i) { if (rtraceline.test(stack[i])) { break; } } if (i <= 1) return; var errorMessageLines = []; for (var j = 0; j < i; ++j) { errorMessageLines.push(stack.shift()); } stack.unshift(errorMessageLines.join("\u0002\u0000\u0001")); }; CapturedTrace.isSupported = function CapturedTrace$IsSupported() { return typeof captureStackTrace === "function"; }; var captureStackTrace = (function stackDetection() { if (typeof Error.stackTraceLimit === "number" && typeof Error.captureStackTrace === "function") { rtraceline = /^\s*at\s*/; formatStack = function(stack, error) { if (typeof stack === "string") return stack; if (error.name !== void 0 && error.message !== void 0) { return error.name + ". " + error.message; } return formatNonError(error); }; var captureStackTrace = Error.captureStackTrace; return function CapturedTrace$_captureStackTrace( receiver, ignoreUntil) { captureStackTrace(receiver, ignoreUntil); }; } var err = new Error(); if (typeof err.stack === "string" && typeof "".startsWith === "function" && (err.stack.startsWith("stackDetection@")) && stackDetection.name === "stackDetection") { defineProperty(Error, "stackTraceLimit", { writable: true, enumerable: false, configurable: false, value: 25 }); rtraceline = /@/; var rline = /[@\n]/; formatStack = function(stack, error) { if (typeof stack === "string") { return (error.name + ". " + error.message + "\n" + stack); } if (error.name !== void 0 && error.message !== void 0) { return error.name + ". " + error.message; } return formatNonError(error); }; return function captureStackTrace(o) { var stack = new Error().stack; var split = stack.split(rline); var len = split.length; var ret = ""; for (var i = 0; i < len; i += 2) { ret += split[i]; ret += "@"; ret += split[i + 1]; ret += "\n"; } o.stack = ret; }; } else { formatStack = function(stack, error) { if (typeof stack === "string") return stack; if ((typeof error === "object" || typeof error === "function") && error.name !== void 0 && error.message !== void 0) { return error.name + ". " + error.message; } return formatNonError(error); }; return null; } })(); return CapturedTrace; }; },{"./es5.js":12,"./util.js":35}],7:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(NEXT_FILTER) { var util = require("./util.js"); var errors = require("./errors.js"); var tryCatch1 = util.tryCatch1; var errorObj = util.errorObj; var keys = require("./es5.js").keys; var TypeError = errors.TypeError; function CatchFilter(instances, callback, promise) { this._instances = instances; this._callback = callback; this._promise = promise; } function CatchFilter$_safePredicate(predicate, e) { var safeObject = {}; var retfilter = tryCatch1(predicate, safeObject, e); if (retfilter === errorObj) return retfilter; var safeKeys = keys(safeObject); if (safeKeys.length) { errorObj.e = new TypeError( "Catch filter must inherit from Error " + "or be a simple predicate function"); return errorObj; } return retfilter; } CatchFilter.prototype.doFilter = function CatchFilter$_doFilter(e) { var cb = this._callback; var promise = this._promise; var boundTo = promise._boundTo; for (var i = 0, len = this._instances.length; i < len; ++i) { var item = this._instances[i]; var itemIsErrorType = item === Error || (item != null && item.prototype instanceof Error); if (itemIsErrorType && e instanceof item) { var ret = tryCatch1(cb, boundTo, e); if (ret === errorObj) { NEXT_FILTER.e = ret.e; return NEXT_FILTER; } return ret; } else if (typeof item === "function" && !itemIsErrorType) { var shouldHandle = CatchFilter$_safePredicate(item, e); if (shouldHandle === errorObj) { var trace = errors.canAttach(errorObj.e) ? errorObj.e : new Error(errorObj.e + ""); this._promise._attachExtraTrace(trace); e = errorObj.e; break; } else if (shouldHandle) { var ret = tryCatch1(cb, boundTo, e); if (ret === errorObj) { NEXT_FILTER.e = ret.e; return NEXT_FILTER; } return ret; } } } NEXT_FILTER.e = e; return NEXT_FILTER; }; return CatchFilter; }; },{"./errors.js":10,"./es5.js":12,"./util.js":35}],8:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; var util = require("./util.js"); var isPrimitive = util.isPrimitive; var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver; module.exports = function(Promise) { var returner = function Promise$_returner() { return this; }; var thrower = function Promise$_thrower() { throw this; }; var wrapper = function Promise$_wrapper(value, action) { if (action === 1) { return function Promise$_thrower() { throw value; }; } else if (action === 2) { return function Promise$_returner() { return value; }; } }; Promise.prototype["return"] = Promise.prototype.thenReturn = function Promise$thenReturn(value) { if (wrapsPrimitiveReceiver && isPrimitive(value)) { return this._then( wrapper(value, 2), void 0, void 0, void 0, void 0 ); } return this._then(returner, void 0, void 0, value, void 0); }; Promise.prototype["throw"] = Promise.prototype.thenThrow = function Promise$thenThrow(reason) { if (wrapsPrimitiveReceiver && isPrimitive(reason)) { return this._then( wrapper(reason, 1), void 0, void 0, void 0, void 0 ); } return this._then(thrower, void 0, void 0, reason, void 0); }; }; },{"./util.js":35}],9:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(Promise, INTERNAL) { var PromiseReduce = Promise.reduce; Promise.prototype.each = function Promise$each(fn) { return PromiseReduce(this, fn, null, INTERNAL); }; Promise.each = function Promise$Each(promises, fn) { return PromiseReduce(promises, fn, null, INTERNAL); }; }; },{}],10:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; var Objectfreeze = require("./es5.js").freeze; var util = require("./util.js"); var inherits = util.inherits; var notEnumerableProp = util.notEnumerableProp; function markAsOriginatingFromRejection(e) { try { notEnumerableProp(e, "isOperational", true); } catch(ignore) {} } function originatesFromRejection(e) { if (e == null) return false; return ((e instanceof OperationalError) || e["isOperational"] === true); } function isError(obj) { return obj instanceof Error; } function canAttach(obj) { return isError(obj); } function subError(nameProperty, defaultMessage) { function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); this.message = typeof message === "string" ? message : defaultMessage; this.name = nameProperty; if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } inherits(SubError, Error); return SubError; } var _TypeError, _RangeError; var CancellationError = subError("CancellationError", "cancellation error"); var TimeoutError = subError("TimeoutError", "timeout error"); var AggregateError = subError("AggregateError", "aggregate error"); try { _TypeError = TypeError; _RangeError = RangeError; } catch(e) { _TypeError = subError("TypeError", "type error"); _RangeError = subError("RangeError", "range error"); } var methods = ("join pop push shift unshift slice filter forEach some " + "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" "); for (var i = 0; i < methods.length; ++i) { if (typeof Array.prototype[methods[i]] === "function") { AggregateError.prototype[methods[i]] = Array.prototype[methods[i]]; } } AggregateError.prototype.length = 0; AggregateError.prototype["isOperational"] = true; var level = 0; AggregateError.prototype.toString = function() { var indent = Array(level * 4 + 1).join(" "); var ret = "\n" + indent + "AggregateError of:" + "\n"; level++; indent = Array(level * 4 + 1).join(" "); for (var i = 0; i < this.length; ++i) { var str = this[i] === this ? "[Circular AggregateError]" : this[i] + ""; var lines = str.split("\n"); for (var j = 0; j < lines.length; ++j) { lines[j] = indent + lines[j]; } str = lines.join("\n"); ret += str + "\n"; } level--; return ret; }; function OperationalError(message) { this.name = "OperationalError"; this.message = message; this.cause = message; this["isOperational"] = true; if (message instanceof Error) { this.message = message.message; this.stack = message.stack; } else if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } inherits(OperationalError, Error); var key = "__BluebirdErrorTypes__"; var errorTypes = Error[key]; if (!errorTypes) { errorTypes = Objectfreeze({ CancellationError: CancellationError, TimeoutError: TimeoutError, OperationalError: OperationalError, RejectionError: OperationalError, AggregateError: AggregateError }); notEnumerableProp(Error, key, errorTypes); } module.exports = { Error: Error, TypeError: _TypeError, RangeError: _RangeError, CancellationError: errorTypes.CancellationError, OperationalError: errorTypes.OperationalError, TimeoutError: errorTypes.TimeoutError, AggregateError: errorTypes.AggregateError, originatesFromRejection: originatesFromRejection, markAsOriginatingFromRejection: markAsOriginatingFromRejection, canAttach: canAttach }; },{"./es5.js":12,"./util.js":35}],11:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(Promise) { var TypeError = require('./errors.js').TypeError; function apiRejection(msg) { var error = new TypeError(msg); var ret = Promise.rejected(error); var parent = ret._peekContext(); if (parent != null) { parent._attachExtraTrace(error); } return ret; } return apiRejection; }; },{"./errors.js":10}],12:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ var isES5 = (function(){ "use strict"; return this === void 0; })(); if (isES5) { module.exports = { freeze: Object.freeze, defineProperty: Object.defineProperty, keys: Object.keys, getPrototypeOf: Object.getPrototypeOf, isArray: Array.isArray, isES5: isES5 }; } 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 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, defineProperty: ObjectDefineProperty, freeze: ObjectFreeze, getPrototypeOf: ObjectGetPrototypeOf, isES5: isES5 }; } },{}],13:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(Promise, INTERNAL) { var PromiseMap = Promise.map; Promise.prototype.filter = function Promise$filter(fn, options) { return PromiseMap(this, fn, options, INTERNAL); }; Promise.filter = function Promise$Filter(promises, fn, options) { return PromiseMap(promises, fn, options, INTERNAL); }; }; },{}],14:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(Promise, NEXT_FILTER, cast) { var util = require("./util.js"); var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver; var isPrimitive = util.isPrimitive; var thrower = util.thrower; function returnThis() { return this; } function throwThis() { throw this; } function return$(r) { return function Promise$_returner() { return r; }; } function throw$(r) { return function Promise$_thrower() { throw r; }; } function promisedFinally(ret, reasonOrValue, isFulfilled) { var then; if (wrapsPrimitiveReceiver && isPrimitive(reasonOrValue)) { then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue); } else { then = isFulfilled ? returnThis : throwThis; } return ret._then(then, thrower, void 0, reasonOrValue, void 0); } function finallyHandler(reasonOrValue) { var promise = this.promise; var handler = this.handler; var ret = promise._isBound() ? handler.call(promise._boundTo) : handler(); if (ret !== void 0) { var maybePromise = cast(ret, void 0); if (maybePromise instanceof Promise) { return promisedFinally(maybePromise, reasonOrValue, promise.isFulfilled()); } } if (promise.isRejected()) { NEXT_FILTER.e = reasonOrValue; return NEXT_FILTER; } else { return reasonOrValue; } } function tapHandler(value) { var promise = this.promise; var handler = this.handler; var ret = promise._isBound() ? handler.call(promise._boundTo, value) : handler(value); if (ret !== void 0) { var maybePromise = cast(ret, void 0); if (maybePromise instanceof Promise) { return promisedFinally(maybePromise, value, true); } } return value; } Promise.prototype._passThroughHandler = function Promise$_passThroughHandler(handler, isFinally) { if (typeof handler !== "function") return this.then(); var promiseAndHandler = { promise: this, handler: handler }; return this._then( isFinally ? finallyHandler : tapHandler, isFinally ? finallyHandler : void 0, void 0, promiseAndHandler, void 0); }; Promise.prototype.lastly = Promise.prototype["finally"] = function Promise$finally(handler) { return this._passThroughHandler(handler, true); }; Promise.prototype.tap = function Promise$tap(handler) { return this._passThroughHandler(handler, false); }; }; },{"./util.js":35}],15:[function(require,module,exports){ /** * The MIT License (MIT) * * Copyright (c) 2014 Petka Antonov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:</p> * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ "use strict"; module.exports = function(Promise, apiRejection, INTERNAL, cast) { var errors = require("./errors.js"); var TypeError = errors.TypeError; var deprecated = require("./util.js").deprecated; var util = require("./util.js"); var errorObj = util.errorObj; var tryCatch1 = util.tryCatch1; var yieldHandlers = []; function promiseFromYieldHandler(value, yieldHandlers) { var _errorObj = errorObj; var _Promise = Promise; var len = yieldHandlers.length; for (var i = 0; i < len; ++i) { var result = tryCatch1(yieldHandlers[i], void 0, value); if (result === _errorObj) { return _Promise.reject(_errorObj.e); } var maybePromise = cast(result, promiseFromYieldHandler); if (maybePromise instanceof _Promise) return maybePromise; } return null; } function PromiseSpawn(generatorFunction, receiver, yieldHandler) { var promise = this._promise = new Promise(INTERNAL); promise._setTrace(void 0); this._generatorFunction = generatorFunction; this._receiver = receiver; this._generator = void 0; this._yieldHandlers = typeof yieldHandler === "function" ? [yieldHandler].concat(yieldHandlers) : yieldHandlers; } PromiseSpawn.prototype.promise = function PromiseSpawn$promise() { return this._promise; }; PromiseSpawn.prototype._run = function PromiseSpawn$_run() { this._generator = this._generatorFunction.call(this._receiver); this._receiver = this._generatorFunction = void 0; this._next(void 0); }; PromiseSpawn.prototype._continue = function PromiseSpawn$_continue(result) { if (result === errorObj) { this._generator = void 0; var trace = errors.canAttach(result.e) ? result.e : new Error(result.e + ""); this._promise._attachExtraTrace(trace); this._promise._reject(result.e, trace); return; } var value = result.value; if (result.done === true) { this._generator = void 0; if (!this._promise._tryFollow(value)) { this._promise._fulfill(value); } } else { var maybePromise = cast(value, void 0); if (!(maybePromise instanceof Promise)) { maybePromise = promiseFromYieldHandler(maybePromise, this._yieldHandlers); if (maybePromise === null) { this._throw(new TypeError("A value was yielded that could not be treated as a promise")); return; } } maybePromise._then( this._next, this._throw,