Created
June 26, 2017 18:04
-
-
Save ymichael/7232d9d71bd371da835908ee74a5d9c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******/ (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] = { | |
/******/ i: moduleId, | |
/******/ l: false, | |
/******/ exports: {} | |
/******/ }; | |
/******/ | |
/******/ // Execute the module function | |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | |
/******/ | |
/******/ // Flag the module as loaded | |
/******/ module.l = true; | |
/******/ | |
/******/ // Return the exports of the module | |
/******/ return module.exports; | |
/******/ } | |
/******/ | |
/******/ | |
/******/ // expose the modules object (__webpack_modules__) | |
/******/ __webpack_require__.m = modules; | |
/******/ | |
/******/ // expose the module cache | |
/******/ __webpack_require__.c = installedModules; | |
/******/ | |
/******/ // identity function for calling harmony imports with the correct context | |
/******/ __webpack_require__.i = function(value) { return value; }; | |
/******/ | |
/******/ // define getter function for harmony exports | |
/******/ __webpack_require__.d = function(exports, name, getter) { | |
/******/ if(!__webpack_require__.o(exports, name)) { | |
/******/ Object.defineProperty(exports, name, { | |
/******/ configurable: false, | |
/******/ enumerable: true, | |
/******/ get: getter | |
/******/ }); | |
/******/ } | |
/******/ }; | |
/******/ | |
/******/ // getDefaultExport function for compatibility with non-harmony modules | |
/******/ __webpack_require__.n = function(module) { | |
/******/ var getter = module && module.__esModule ? | |
/******/ function getDefault() { return module['default']; } : | |
/******/ function getModuleExports() { return module; }; | |
/******/ __webpack_require__.d(getter, 'a', getter); | |
/******/ return getter; | |
/******/ }; | |
/******/ | |
/******/ // Object.prototype.hasOwnProperty.call | |
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | |
/******/ | |
/******/ // __webpack_public_path__ | |
/******/ __webpack_require__.p = "https://ma-0.twimg.com/twitter-assets/responsive-web/serviceworker/"; | |
/******/ | |
/******/ // Load entry module and return exports | |
/******/ return __webpack_require__(__webpack_require__.s = 61); | |
/******/ }) | |
/************************************************************************/ | |
/******/ ([ | |
/* 0 */ | |
/***/ (function(module, exports) { | |
var core = module.exports = {version: '2.4.0'}; | |
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef | |
/***/ }), | |
/* 1 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var store = __webpack_require__(46)('wks') | |
, uid = __webpack_require__(48) | |
, Symbol = __webpack_require__(2).Symbol | |
, USE_SYMBOL = typeof Symbol == 'function'; | |
var $exports = module.exports = function(name){ | |
return store[name] || (store[name] = | |
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); | |
}; | |
$exports.store = store; | |
/***/ }), | |
/* 2 */ | |
/***/ (function(module, exports) { | |
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 | |
var global = module.exports = typeof window != 'undefined' && window.Math == Math | |
? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); | |
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef | |
/***/ }), | |
/* 3 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var global = __webpack_require__(2) | |
, core = __webpack_require__(0) | |
, ctx = __webpack_require__(10) | |
, hide = __webpack_require__(7) | |
, PROTOTYPE = 'prototype'; | |
var $export = function(type, name, source){ | |
var IS_FORCED = type & $export.F | |
, IS_GLOBAL = type & $export.G | |
, IS_STATIC = type & $export.S | |
, IS_PROTO = type & $export.P | |
, IS_BIND = type & $export.B | |
, IS_WRAP = type & $export.W | |
, exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) | |
, expProto = exports[PROTOTYPE] | |
, target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] | |
, key, own, out; | |
if(IS_GLOBAL)source = name; | |
for(key in source){ | |
// contains in native | |
own = !IS_FORCED && target && target[key] !== undefined; | |
if(own && key in exports)continue; | |
// export native or passed | |
out = own ? target[key] : source[key]; | |
// prevent global pollution for namespaces | |
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] | |
// bind timers to global for call from export context | |
: IS_BIND && own ? ctx(out, global) | |
// wrap global constructors for prevent change them in library | |
: IS_WRAP && target[key] == out ? (function(C){ | |
var F = function(a, b, c){ | |
if(this instanceof C){ | |
switch(arguments.length){ | |
case 0: return new C; | |
case 1: return new C(a); | |
case 2: return new C(a, b); | |
} return new C(a, b, c); | |
} return C.apply(this, arguments); | |
}; | |
F[PROTOTYPE] = C[PROTOTYPE]; | |
return F; | |
// make static versions for prototype methods | |
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; | |
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME% | |
if(IS_PROTO){ | |
(exports.virtual || (exports.virtual = {}))[key] = out; | |
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% | |
if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out); | |
} | |
} | |
}; | |
// type bitmap | |
$export.F = 1; // forced | |
$export.G = 2; // global | |
$export.S = 4; // static | |
$export.P = 8; // proto | |
$export.B = 16; // bind | |
$export.W = 32; // wrap | |
$export.U = 64; // safe | |
$export.R = 128; // real proto method for `library` | |
module.exports = $export; | |
/***/ }), | |
/* 4 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var isObject = __webpack_require__(15); | |
module.exports = function(it){ | |
if(!isObject(it))throw TypeError(it + ' is not an object!'); | |
return it; | |
}; | |
/***/ }), | |
/* 5 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(87), __esModule: true }; | |
/***/ }), | |
/* 6 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// Thank's IE8 for his funny defineProperty | |
module.exports = !__webpack_require__(13)(function(){ | |
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; | |
}); | |
/***/ }), | |
/* 7 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var dP = __webpack_require__(9) | |
, createDesc = __webpack_require__(26); | |
module.exports = __webpack_require__(6) ? function(object, key, value){ | |
return dP.f(object, key, createDesc(1, value)); | |
} : function(object, key, value){ | |
object[key] = value; | |
return object; | |
}; | |
/***/ }), | |
/* 8 */ | |
/***/ (function(module, exports) { | |
module.exports = {}; | |
/***/ }), | |
/* 9 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var anObject = __webpack_require__(4) | |
, IE8_DOM_DEFINE = __webpack_require__(93) | |
, toPrimitive = __webpack_require__(111) | |
, dP = Object.defineProperty; | |
exports.f = __webpack_require__(6) ? Object.defineProperty : function defineProperty(O, P, Attributes){ | |
anObject(O); | |
P = toPrimitive(P, true); | |
anObject(Attributes); | |
if(IE8_DOM_DEFINE)try { | |
return dP(O, P, Attributes); | |
} catch(e){ /* empty */ } | |
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); | |
if('value' in Attributes)O[P] = Attributes.value; | |
return O; | |
}; | |
/***/ }), | |
/* 10 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// optional / simple context binding | |
var aFunction = __webpack_require__(22); | |
module.exports = function(fn, that, length){ | |
aFunction(fn); | |
if(that === undefined)return fn; | |
switch(length){ | |
case 1: return function(a){ | |
return fn.call(that, a); | |
}; | |
case 2: return function(a, b){ | |
return fn.call(that, a, b); | |
}; | |
case 3: return function(a, b, c){ | |
return fn.call(that, a, b, c); | |
}; | |
} | |
return function(/* ...args */){ | |
return fn.apply(that, arguments); | |
}; | |
}; | |
/***/ }), | |
/* 11 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
exports.__esModule = true; | |
var _assign = __webpack_require__(70); | |
var _assign2 = _interopRequireDefault(_assign); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
exports.default = _assign2.default || function (target) { | |
for (var i = 1; i < arguments.length; i++) { | |
var source = arguments[i]; | |
for (var key in source) { | |
if (Object.prototype.hasOwnProperty.call(source, key)) { | |
target[key] = source[key]; | |
} | |
} | |
} | |
return target; | |
}; | |
/***/ }), | |
/* 12 */ | |
/***/ (function(module, exports) { | |
var toString = {}.toString; | |
module.exports = function(it){ | |
return toString.call(it).slice(8, -1); | |
}; | |
/***/ }), | |
/* 13 */ | |
/***/ (function(module, exports) { | |
module.exports = function(exec){ | |
try { | |
return !!exec(); | |
} catch(e){ | |
return true; | |
} | |
}; | |
/***/ }), | |
/* 14 */ | |
/***/ (function(module, exports) { | |
var hasOwnProperty = {}.hasOwnProperty; | |
module.exports = function(it, key){ | |
return hasOwnProperty.call(it, key); | |
}; | |
/***/ }), | |
/* 15 */ | |
/***/ (function(module, exports) { | |
module.exports = function(it){ | |
return typeof it === 'object' ? it !== null : typeof it === 'function'; | |
}; | |
/***/ }), | |
/* 16 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 19.1.2.14 / 15.2.3.14 Object.keys(O) | |
var $keys = __webpack_require__(102) | |
, enumBugKeys = __webpack_require__(36); | |
module.exports = Object.keys || function keys(O){ | |
return $keys(O, enumBugKeys); | |
}; | |
/***/ }), | |
/* 17 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// to indexed object, toObject with fallback for non-array-like ES3 strings | |
var IObject = __webpack_require__(38) | |
, defined = __webpack_require__(24); | |
module.exports = function(it){ | |
return IObject(defined(it)); | |
}; | |
/***/ }), | |
/* 18 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 7.1.13 ToObject(argument) | |
var defined = __webpack_require__(24); | |
module.exports = function(it){ | |
return Object(defined(it)); | |
}; | |
/***/ }), | |
/* 19 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var $at = __webpack_require__(109)(true); | |
// 21.1.3.27 String.prototype[@@iterator]() | |
__webpack_require__(41)(String, 'String', function(iterated){ | |
this._t = String(iterated); // target | |
this._i = 0; // next index | |
// 21.1.5.2.1 %StringIteratorPrototype%.next() | |
}, function(){ | |
var O = this._t | |
, index = this._i | |
, point; | |
if(index >= O.length)return {value: undefined, done: true}; | |
point = $at(O, index); | |
this._i += point.length; | |
return {value: point, done: false}; | |
}); | |
/***/ }), | |
/* 20 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(81), __esModule: true }; | |
/***/ }), | |
/* 21 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.isOnline = exports.networkPriorityFirst = exports.requestWithUrl = exports.urlWithParam = exports.networkFirst = exports.cacheFirst = exports.regexEscapeString = undefined; | |
var _extends2 = __webpack_require__(11); | |
var _extends3 = _interopRequireDefault(_extends2); | |
var _promise = __webpack_require__(5); | |
var _promise2 = _interopRequireDefault(_promise); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
/* global caches, fetch, Request, self */ | |
var ONE_HOUR_MS = 1000 * 60 * 60; | |
var MIN_FETCH_PRIORITY_MS = ONE_HOUR_MS * 24; // 24 hours | |
var MED_FETCH_PRIORITY_MS = ONE_HOUR_MS * 24 * 3; // 3 days | |
var MIN_CACHE_TIMEOUT_MS = 50; | |
var MED_CACHE_TIMEOUT_MS = 500; | |
var MAX_CACHE_TIMEOUT_MS = 5000; | |
var regexEscapeString = exports.regexEscapeString = function regexEscapeString(str) { | |
return str.replace(/[:\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | |
}; | |
/** | |
* Return a request from cache if found, otherwise fetch. | |
* Uses request.url so as to not restrict on varying headers | |
* @param {String} cacheName Name of the cache storage DB to search | |
* @param {Request} request | |
* @return {Promise} | |
*/ | |
var getFromCache = function getFromCache(cacheName, request) { | |
return caches.open(cacheName).then(function (cache) { | |
return cache.match(request.url).then(function (response) { | |
if (response && response.ok) { | |
return response; | |
} else { | |
return _promise2.default.reject(); | |
} | |
}); | |
}); | |
}; | |
/** | |
* Return a response from cache first | |
* @param {String} cacheName Name of the cache storage DB to search | |
* @param {Request} request | |
* @return {Promise} | |
*/ | |
var cacheFirst = exports.cacheFirst = function cacheFirst(cacheName, request, networkFallback) { | |
var networkRequest = networkFallback || request; | |
return getFromCache(cacheName, request).catch(function () { | |
return fetch(networkRequest); | |
}); | |
}; | |
/** | |
* Return a response from the network first. If failed, attempt to find from cache. | |
* @param {String} cacheName Name of the cache storage DB to search | |
* @param {Request} request | |
* @param {Request?} cachedFallback Optional fallback URL to search if network request fails | |
* @return {Promise} | |
*/ | |
var networkFirst = exports.networkFirst = function networkFirst(cacheName, request, cachedFallback) { | |
var cachedRequest = cachedFallback || request; | |
return fetch(request).catch(function () { | |
return getFromCache(cacheName, cachedRequest); | |
}); | |
}; | |
var getNetworkPriorityTimeout = function getNetworkPriorityTimeout(cachedResponse, requestTime) { | |
var responseDateString = cachedResponse.headers.get('date'); | |
var timeout = MAX_CACHE_TIMEOUT_MS; | |
var timeElapsed = Date.now() - requestTime; | |
if (responseDateString) { | |
var responseDate = new Date(responseDateString); | |
var timeSinceCache = requestTime - responseDate; | |
if (timeSinceCache < MIN_FETCH_PRIORITY_MS) { | |
timeout = MIN_CACHE_TIMEOUT_MS; | |
} else if (timeSinceCache < MED_FETCH_PRIORITY_MS) { | |
timeout = MED_CACHE_TIMEOUT_MS; | |
} | |
} | |
return Math.max(timeout - timeElapsed, 1); | |
}; | |
var urlWithParam = exports.urlWithParam = function urlWithParam(url, paramName, paramValue) { | |
var hasExistingQuery = url.indexOf('?') !== -1; | |
var separator = hasExistingQuery ? '&' : '?'; | |
return '' + url + separator + paramName + '=' + paramValue; | |
}; | |
var requestWithUrl = exports.requestWithUrl = function requestWithUrl(request, url) { | |
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | |
return new Request(url, (0, _extends3.default)({ | |
body: request.clone().body, | |
method: request.method, | |
headers: request.headers, | |
mode: 'same-origin', | |
credentials: request.credentials, | |
cache: request.cache, | |
redirect: request.redirect, | |
integrity: request.integrity | |
}, options)); | |
}; | |
/** | |
* Prioritize network response depending on cache age. | |
* Puts the newly fetched request/response into the cache in place of the previous to ensure | |
* that the cache is not stale the next time we come back to the same request. | |
* | |
* @param {String} cacheName Name of the cache storage DB to search | |
* @param {Request} request Request object for fresh fetch | |
* @param {Request?} cachedFallback Request object to save to/read from cache | |
* @return {Promise} | |
*/ | |
var networkPriorityFirst = exports.networkPriorityFirst = function networkPriorityFirst(cacheName, request, cachedFallback) { | |
var cachedRequest = cachedFallback || request; | |
return new _promise2.default(function (resolve, reject) { | |
var now = Date.now(); | |
var failedOnce = false; | |
var cacheTimeoutId = void 0; | |
var rejectIfDoubleFailure = function rejectIfDoubleFailure(error) { | |
if (failedOnce) { | |
reject(error); | |
} else { | |
failedOnce = true; | |
} | |
}; | |
fetch(request).then(function (response) { | |
if (response && response.ok) { | |
cacheTimeoutId && clearTimeout(cacheTimeoutId); | |
caches.open(cacheName).then(function (cache) { | |
return cache.put(cachedRequest, response.clone()); | |
}); | |
resolve(response.clone()); | |
} else { | |
rejectIfDoubleFailure(); | |
} | |
}).catch(rejectIfDoubleFailure); | |
getFromCache(cacheName, cachedRequest).then(function (response) { | |
var priorityTimeout = getNetworkPriorityTimeout(response, now); | |
if (response && response.ok) { | |
cacheTimeoutId = setTimeout(function () { | |
cacheTimeoutId = undefined; | |
resolve(response); | |
}, priorityTimeout); | |
} else { | |
rejectIfDoubleFailure(); | |
} | |
}).catch(rejectIfDoubleFailure); | |
}); | |
}; | |
var isOnline = exports.isOnline = function isOnline() { | |
return self.navigator.onLine; | |
}; | |
/***/ }), | |
/* 22 */ | |
/***/ (function(module, exports) { | |
module.exports = function(it){ | |
if(typeof it != 'function')throw TypeError(it + ' is not a function!'); | |
return it; | |
}; | |
/***/ }), | |
/* 23 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// getting tag from 19.1.3.6 Object.prototype.toString() | |
var cof = __webpack_require__(12) | |
, TAG = __webpack_require__(1)('toStringTag') | |
// ES3 wrong here | |
, ARG = cof(function(){ return arguments; }()) == 'Arguments'; | |
// fallback for IE11 Script Access Denied error | |
var tryGet = function(it, key){ | |
try { | |
return it[key]; | |
} catch(e){ /* empty */ } | |
}; | |
module.exports = function(it){ | |
var O, T, B; | |
return it === undefined ? 'Undefined' : it === null ? 'Null' | |
// @@toStringTag case | |
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T | |
// builtinTag case | |
: ARG ? cof(O) | |
// ES3 arguments fallback | |
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; | |
}; | |
/***/ }), | |
/* 24 */ | |
/***/ (function(module, exports) { | |
// 7.2.1 RequireObjectCoercible(argument) | |
module.exports = function(it){ | |
if(it == undefined)throw TypeError("Can't call method on " + it); | |
return it; | |
}; | |
/***/ }), | |
/* 25 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var isObject = __webpack_require__(15) | |
, document = __webpack_require__(2).document | |
// in old IE typeof document.createElement is 'object' | |
, is = isObject(document) && isObject(document.createElement); | |
module.exports = function(it){ | |
return is ? document.createElement(it) : {}; | |
}; | |
/***/ }), | |
/* 26 */ | |
/***/ (function(module, exports) { | |
module.exports = function(bitmap, value){ | |
return { | |
enumerable : !(bitmap & 1), | |
configurable: !(bitmap & 2), | |
writable : !(bitmap & 4), | |
value : value | |
}; | |
}; | |
/***/ }), | |
/* 27 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var def = __webpack_require__(9).f | |
, has = __webpack_require__(14) | |
, TAG = __webpack_require__(1)('toStringTag'); | |
module.exports = function(it, tag, stat){ | |
if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); | |
}; | |
/***/ }), | |
/* 28 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var shared = __webpack_require__(46)('keys') | |
, uid = __webpack_require__(48); | |
module.exports = function(key){ | |
return shared[key] || (shared[key] = uid(key)); | |
}; | |
/***/ }), | |
/* 29 */ | |
/***/ (function(module, exports) { | |
// 7.1.4 ToInteger | |
var ceil = Math.ceil | |
, floor = Math.floor; | |
module.exports = function(it){ | |
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); | |
}; | |
/***/ }), | |
/* 30 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 7.1.15 ToLength | |
var toInteger = __webpack_require__(29) | |
, min = Math.min; | |
module.exports = function(it){ | |
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 | |
}; | |
/***/ }), | |
/* 31 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var classof = __webpack_require__(23) | |
, ITERATOR = __webpack_require__(1)('iterator') | |
, Iterators = __webpack_require__(8); | |
module.exports = __webpack_require__(0).getIteratorMethod = function(it){ | |
if(it != undefined)return it[ITERATOR] | |
|| it['@@iterator'] | |
|| Iterators[classof(it)]; | |
}; | |
/***/ }), | |
/* 32 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(115); | |
var global = __webpack_require__(2) | |
, hide = __webpack_require__(7) | |
, Iterators = __webpack_require__(8) | |
, TO_STRING_TAG = __webpack_require__(1)('toStringTag'); | |
for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){ | |
var NAME = collections[i] | |
, Collection = global[NAME] | |
, proto = Collection && Collection.prototype; | |
if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME); | |
Iterators[NAME] = Iterators.Array; | |
} | |
/***/ }), | |
/* 33 */ | |
/***/ (function(module, exports) { | |
var g; | |
// This works in non-strict mode | |
g = (function() { | |
return this; | |
})(); | |
try { | |
// This works if eval is allowed (see CSP) | |
g = g || Function("return this")() || (1,eval)("this"); | |
} catch(e) { | |
// This works if the window reference is available | |
if(typeof window === "object") | |
g = window; | |
} | |
// g can still be undefined, but nothing to do about it... | |
// We return undefined, instead of nothing here, so it's | |
// easier to handle this case. if(!global) { ...} | |
module.exports = g; | |
/***/ }), | |
/* 34 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* eslint-disable max-len */ | |
/** | |
* Uses module.exports to allow Node.js tools to require this file | |
*/ | |
module.exports = { | |
API_CARDS_PLATFORM: 'Web-12', | |
BEARER_TOKEN: 'AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA', | |
CLIENT_APPLICATION_ID: '3033300', | |
CSRF_COOKIE: 'ct0', | |
EXPERIMENT_OVERRIDE_COOKIE: 'ab_decider', | |
FLASH_MESSAGE_COOKIE: 'fm', | |
GCM_SENDER_ID: '49625052041', | |
GUEST_ID_COOKIE: 'guest_id', | |
GUEST_TOKEN_COOKIE: 'gt', | |
LOGLENS_INDEX_PREFIX: 'responsive_web', | |
MOBILE_LOGIN_COOKIE: '_mb_tk', | |
MUTE_EDUCATION_COOKIE: 'conversation_muted_education', | |
MUTE_KEYWORD_EDUCATION_COOKIE: 'mute_keyword_education', | |
// always use the zero-rated domain (see RWEB-2217) | |
PUBLIC_HOST: 'ma-0.twimg.com', | |
SENTRY_DSN: 'https://[email protected]/66490', | |
SERVICE_WORKER_PATH: '/sw.js', | |
TWID_COOKIE: 'twid', | |
TWITTER_IP_TAGS_HEADER: 'x-twitter-ip-tags', | |
UNMUTE_KEYWORD_CONFIRMATION_COOKIE: 'unmute_keyword_confirmation', | |
// JS Version of the VAPID Public key in /etc/twkeys/notifications/delivery-push/service.yml | |
// If this changes, the push version in the API needs to be bumped so that the backend can differentiate which key to use | |
VAPID_PUBLIC_KEY: new Uint8Array([0x04, 0x5e, 0x68, 0x12, 0x8d, 0x31, 0x0d, 0x4a, 0x60, 0xca, 0x52, 0x83, 0x4e, 0x5b, 0x1d, 0xf2, 0x96, 0x66, 0xc5, 0x00, 0x35, 0x95, 0xe6, 0x08, 0x36, 0x26, 0x3e, 0xad, 0x2b, 0x1c, 0x59, 0x82, 0xbf, 0xde, 0xd5, 0x80, 0x93, 0x3e, 0x15, 0x31, 0xbb, 0x5f, 0xd4, 0xc2, 0xc4, 0xfd, 0x8c, 0x9d, 0xea, 0x22, 0x08, 0xea, 0x8f, 0x9e, 0xdd, 0x0f, 0x53, 0x08, 0xde, 0x6f, 0x64, 0xcc, 0xd5, 0x30, 0x4b]), | |
WEBPACK_CHUNK_MANIFEST_VARIABLE: 'webpackChunkManifest' | |
}; | |
/***/ }), | |
/* 35 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(79), __esModule: true }; | |
/***/ }), | |
/* 36 */ | |
/***/ (function(module, exports) { | |
// IE 8- don't enum bug keys | |
module.exports = ( | |
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' | |
).split(','); | |
/***/ }), | |
/* 37 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = __webpack_require__(2).document && document.documentElement; | |
/***/ }), | |
/* 38 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// fallback for non-array-like ES3 and non-enumerable old V8 strings | |
var cof = __webpack_require__(12); | |
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ | |
return cof(it) == 'String' ? it.split('') : Object(it); | |
}; | |
/***/ }), | |
/* 39 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// check on default Array iterator | |
var Iterators = __webpack_require__(8) | |
, ITERATOR = __webpack_require__(1)('iterator') | |
, ArrayProto = Array.prototype; | |
module.exports = function(it){ | |
return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); | |
}; | |
/***/ }), | |
/* 40 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// call something on iterator step with safe closing on error | |
var anObject = __webpack_require__(4); | |
module.exports = function(iterator, fn, value, entries){ | |
try { | |
return entries ? fn(anObject(value)[0], value[1]) : fn(value); | |
// 7.4.6 IteratorClose(iterator, completion) | |
} catch(e){ | |
var ret = iterator['return']; | |
if(ret !== undefined)anObject(ret.call(iterator)); | |
throw e; | |
} | |
}; | |
/***/ }), | |
/* 41 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var LIBRARY = __webpack_require__(43) | |
, $export = __webpack_require__(3) | |
, redefine = __webpack_require__(106) | |
, hide = __webpack_require__(7) | |
, has = __webpack_require__(14) | |
, Iterators = __webpack_require__(8) | |
, $iterCreate = __webpack_require__(95) | |
, setToStringTag = __webpack_require__(27) | |
, getPrototypeOf = __webpack_require__(101) | |
, ITERATOR = __webpack_require__(1)('iterator') | |
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` | |
, FF_ITERATOR = '@@iterator' | |
, KEYS = 'keys' | |
, VALUES = 'values'; | |
var returnThis = function(){ return this; }; | |
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ | |
$iterCreate(Constructor, NAME, next); | |
var getMethod = function(kind){ | |
if(!BUGGY && kind in proto)return proto[kind]; | |
switch(kind){ | |
case KEYS: return function keys(){ return new Constructor(this, kind); }; | |
case VALUES: return function values(){ return new Constructor(this, kind); }; | |
} return function entries(){ return new Constructor(this, kind); }; | |
}; | |
var TAG = NAME + ' Iterator' | |
, DEF_VALUES = DEFAULT == VALUES | |
, VALUES_BUG = false | |
, proto = Base.prototype | |
, $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] | |
, $default = $native || getMethod(DEFAULT) | |
, $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined | |
, $anyNative = NAME == 'Array' ? proto.entries || $native : $native | |
, methods, key, IteratorPrototype; | |
// Fix native | |
if($anyNative){ | |
IteratorPrototype = getPrototypeOf($anyNative.call(new Base)); | |
if(IteratorPrototype !== Object.prototype){ | |
// Set @@toStringTag to native iterators | |
setToStringTag(IteratorPrototype, TAG, true); | |
// fix for some old engines | |
if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); | |
} | |
} | |
// fix Array#{values, @@iterator}.name in V8 / FF | |
if(DEF_VALUES && $native && $native.name !== VALUES){ | |
VALUES_BUG = true; | |
$default = function values(){ return $native.call(this); }; | |
} | |
// Define iterator | |
if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){ | |
hide(proto, ITERATOR, $default); | |
} | |
// Plug for library | |
Iterators[NAME] = $default; | |
Iterators[TAG] = returnThis; | |
if(DEFAULT){ | |
methods = { | |
values: DEF_VALUES ? $default : getMethod(VALUES), | |
keys: IS_SET ? $default : getMethod(KEYS), | |
entries: $entries | |
}; | |
if(FORCED)for(key in methods){ | |
if(!(key in proto))redefine(proto, key, methods[key]); | |
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); | |
} | |
return methods; | |
}; | |
/***/ }), | |
/* 42 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var ITERATOR = __webpack_require__(1)('iterator') | |
, SAFE_CLOSING = false; | |
try { | |
var riter = [7][ITERATOR](); | |
riter['return'] = function(){ SAFE_CLOSING = true; }; | |
Array.from(riter, function(){ throw 2; }); | |
} catch(e){ /* empty */ } | |
module.exports = function(exec, skipClosing){ | |
if(!skipClosing && !SAFE_CLOSING)return false; | |
var safe = false; | |
try { | |
var arr = [7] | |
, iter = arr[ITERATOR](); | |
iter.next = function(){ return {done: safe = true}; }; | |
arr[ITERATOR] = function(){ return iter; }; | |
exec(arr); | |
} catch(e){ /* empty */ } | |
return safe; | |
}; | |
/***/ }), | |
/* 43 */ | |
/***/ (function(module, exports) { | |
module.exports = true; | |
/***/ }), | |
/* 44 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) | |
var anObject = __webpack_require__(4) | |
, dPs = __webpack_require__(99) | |
, enumBugKeys = __webpack_require__(36) | |
, IE_PROTO = __webpack_require__(28)('IE_PROTO') | |
, Empty = function(){ /* empty */ } | |
, PROTOTYPE = 'prototype'; | |
// Create object with fake `null` prototype: use iframe Object with cleared prototype | |
var createDict = function(){ | |
// Thrash, waste and sodomy: IE GC bug | |
var iframe = __webpack_require__(25)('iframe') | |
, i = enumBugKeys.length | |
, lt = '<' | |
, gt = '>' | |
, iframeDocument; | |
iframe.style.display = 'none'; | |
__webpack_require__(37).appendChild(iframe); | |
iframe.src = 'javascript:'; // eslint-disable-line no-script-url | |
// createDict = iframe.contentWindow.Object; | |
// html.removeChild(iframe); | |
iframeDocument = iframe.contentWindow.document; | |
iframeDocument.open(); | |
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); | |
iframeDocument.close(); | |
createDict = iframeDocument.F; | |
while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]]; | |
return createDict(); | |
}; | |
module.exports = Object.create || function create(O, Properties){ | |
var result; | |
if(O !== null){ | |
Empty[PROTOTYPE] = anObject(O); | |
result = new Empty; | |
Empty[PROTOTYPE] = null; | |
// add "__proto__" for Object.getPrototypeOf polyfill | |
result[IE_PROTO] = O; | |
} else result = createDict(); | |
return Properties === undefined ? result : dPs(result, Properties); | |
}; | |
/***/ }), | |
/* 45 */ | |
/***/ (function(module, exports) { | |
exports.f = {}.propertyIsEnumerable; | |
/***/ }), | |
/* 46 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var global = __webpack_require__(2) | |
, SHARED = '__core-js_shared__' | |
, store = global[SHARED] || (global[SHARED] = {}); | |
module.exports = function(key){ | |
return store[key] || (store[key] = {}); | |
}; | |
/***/ }), | |
/* 47 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var ctx = __webpack_require__(10) | |
, invoke = __webpack_require__(94) | |
, html = __webpack_require__(37) | |
, cel = __webpack_require__(25) | |
, global = __webpack_require__(2) | |
, process = global.process | |
, setTask = global.setImmediate | |
, clearTask = global.clearImmediate | |
, MessageChannel = global.MessageChannel | |
, counter = 0 | |
, queue = {} | |
, ONREADYSTATECHANGE = 'onreadystatechange' | |
, defer, channel, port; | |
var run = function(){ | |
var id = +this; | |
if(queue.hasOwnProperty(id)){ | |
var fn = queue[id]; | |
delete queue[id]; | |
fn(); | |
} | |
}; | |
var listener = function(event){ | |
run.call(event.data); | |
}; | |
// Node.js 0.9+ & IE10+ has setImmediate, otherwise: | |
if(!setTask || !clearTask){ | |
setTask = function setImmediate(fn){ | |
var args = [], i = 1; | |
while(arguments.length > i)args.push(arguments[i++]); | |
queue[++counter] = function(){ | |
invoke(typeof fn == 'function' ? fn : Function(fn), args); | |
}; | |
defer(counter); | |
return counter; | |
}; | |
clearTask = function clearImmediate(id){ | |
delete queue[id]; | |
}; | |
// Node.js 0.8- | |
if(__webpack_require__(12)(process) == 'process'){ | |
defer = function(id){ | |
process.nextTick(ctx(run, id, 1)); | |
}; | |
// Browsers with MessageChannel, includes WebWorkers | |
} else if(MessageChannel){ | |
channel = new MessageChannel; | |
port = channel.port2; | |
channel.port1.onmessage = listener; | |
defer = ctx(port.postMessage, port, 1); | |
// Browsers with postMessage, skip WebWorkers | |
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object' | |
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){ | |
defer = function(id){ | |
global.postMessage(id + '', '*'); | |
}; | |
global.addEventListener('message', listener, false); | |
// IE8- | |
} else if(ONREADYSTATECHANGE in cel('script')){ | |
defer = function(id){ | |
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){ | |
html.removeChild(this); | |
run.call(id); | |
}; | |
}; | |
// Rest old browsers | |
} else { | |
defer = function(id){ | |
setTimeout(ctx(run, id, 1), 0); | |
}; | |
} | |
} | |
module.exports = { | |
set: setTask, | |
clear: clearTask | |
}; | |
/***/ }), | |
/* 48 */ | |
/***/ (function(module, exports) { | |
var id = 0 | |
, px = Math.random(); | |
module.exports = function(key){ | |
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); | |
}; | |
/***/ }), | |
/* 49 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* | |
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | |
Copyrights licensed under the New BSD License. | |
See the accompanying LICENSE file for terms. | |
*/ | |
/* jslint esnext: true */ | |
exports.extend = extend; | |
var hop = Object.prototype.hasOwnProperty; | |
function extend(obj) { | |
var sources = Array.prototype.slice.call(arguments, 1), | |
i, len, source, key; | |
for (i = 0, len = sources.length; i < len; i += 1) { | |
source = sources[i]; | |
if (!source) { continue; } | |
for (key in source) { | |
if (hop.call(source, key)) { | |
obj[key] = source[key]; | |
} | |
} | |
} | |
return obj; | |
} | |
exports.hop = hop; | |
//# sourceMappingURL=utils.js.map | |
/***/ }), | |
/* 50 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
/** | |
* initRaven | |
* this function is serialized and sent to the client. Default args like | |
* dsn=DEFAULT_DSN will throw errors. | |
*/ | |
var initRaven = exports.initRaven = function initRaven(Raven, _ref, isWebview) { | |
var dsn = _ref.dsn, | |
quota = _ref.quota, | |
release = _ref.release, | |
tags = _ref.tags, | |
userHash = _ref.userHash; | |
if (!Raven) { | |
return; | |
} | |
var q = quota; | |
var shouldIgnoreError = typeof isWebview === 'function' ? function (data) { | |
// UIWebviews that try to do nasty things to our site sometimes throw errors | |
// They always appear to happen on line 1, so we ignore them. | |
var frames = data.exception && data.exception.values && data.exception.values.stacktrace && data.exception.values.stacktrace.frames || []; | |
return isWebview(window) && !frames.length || frames.length === 1 && frames[0].lineno === 1; | |
} : function () { | |
return false; | |
}; | |
if (userHash) { | |
Raven.setUserContext({ id: userHash }); | |
} | |
Raven.config(dsn, { | |
// https://docs.sentry.io/hosted/clients/javascript/tips/#decluttering-sentry | |
ignoreErrors: [ | |
// Random plugins/extensions | |
'top.GLOBALS', | |
// See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html | |
'originalCreateNotification', 'canvas.contentDocument', 'MyApp_RemoveAllHighlights', /Refused to connect to '(?!https:\/\/[^.*]\.?(twimg|twitter)\.com)/, 'waitUntil is not a function', | |
// TODO: RWEB-5177 re-evaluate after upgrading to webpack@2 | |
'webpackJsonp is not defined'], | |
release: release, | |
shouldSendCallback: function shouldSendCallback() { | |
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | |
if (shouldIgnoreError(data)) { | |
return false; | |
} | |
return !!(q && q--); | |
}, | |
tags: tags, | |
whitelistUrls: [/https:\/\/(abs-\d+|ma-\d+|o|pbs)\.twimg\.com/, /https:\/\/(\w+\.)?twitter\.com/] | |
}).install(); | |
}; | |
var decideSampleRate = exports.decideSampleRate = function decideSampleRate(config, settings) { | |
if (config.canary) { | |
return settings.canary_user_sample_rate; | |
} else if (config.preflight) { | |
return settings.preflight_user_sample_rate; | |
} else { | |
return settings.user_sample_rate; | |
} | |
}; | |
/***/ }), | |
/* 51 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.handlePush = exports.handleNotificationClick = exports.handleNotificationDismiss = undefined; | |
var _extends2 = __webpack_require__(11); | |
var _extends3 = _interopRequireDefault(_extends2); | |
var _promise = __webpack_require__(5); | |
var _promise2 = _interopRequireDefault(_promise); | |
var _helpers = __webpack_require__(62); | |
var Helpers = _interopRequireWildcard(_helpers); | |
var _constants = __webpack_require__(59); | |
var _logo = __webpack_require__(139); | |
var _logo2 = _interopRequireDefault(_logo); | |
var _iconDefault = __webpack_require__(138); | |
var _iconDefault2 = _interopRequireDefault(_iconDefault); | |
var _locales = __webpack_require__(63); | |
var _locales2 = _interopRequireDefault(_locales); | |
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var BUNDLED_NOTIF_TAG = 'bundle'; /* global self */ | |
var DEFAULT_NOTIF_TAG = 'default'; | |
var BUNDLE_THRESHOLD = 6; // Represents the number of visible notifications, not the total interaction count | |
var DEFAULT_CLICK_PATH = '/notifications'; | |
var NORMAL_TAG_PREFIXES = ['favorite', 'retweet', 'mention', 'reply', 'quote', 'follow']; | |
var RWEB_TAG_PREFIXES = ['rweb_favorite', 'rweb_retweet', 'rweb_mention', 'rweb_reply', 'rweb_quote', 'rweb_follow']; | |
var COLLAPSIBLE_TAG_PREFIXES = NORMAL_TAG_PREFIXES.concat(RWEB_TAG_PREFIXES); | |
var notifIsCollapsible = function notifIsCollapsible(notif) { | |
return notif.tag && COLLAPSIBLE_TAG_PREFIXES.some(function (prefix) { | |
return notif.tag.indexOf(prefix) === 0; | |
}); | |
}; | |
/** | |
* This file handles all the push related concerns of the service worker. | |
* | |
* Push notifications are dispatched via ibis2 and can be configured in two places | |
* default "templates" are in ibis2 itself, while the infividual notifications | |
* fill in details (i.e. title and body) via their own templates. | |
* See go/ibis2 for more or go/ibis2ui for individual notifications. | |
* Also check out the rweb docs (go/rweb-docs) for more info. | |
* | |
* Ibis determines the params for all notifications, some accepted are: | |
* @param {string} title - One-line bold header or lead. | |
* @param {string} body - Limited, multi-line text / content. | |
* @param {string} tag - Client-side collapse/uniqueness key. | |
* @param {string} data.uri - Path to request upon click. | |
* @param {string} data.iid - Snowflake ID of a specific push, used for scribing | |
* @param {string} data.scribe_target - Element for scribe namespace | |
* @param {string} data.lang - The language the notif should be rendered in | |
* @param {string} data.uri - Path to request upon click. | |
* @param {string} data.multi_title - overrides for stacking notifications with the same tag | |
* @param {string} data.multi_body - overrides for stacking notifications with the same tag | |
* @param {string} data.multi_uri - overrides for stacking notifications with the same tag | |
* @param {string} data.bundle_text - Text for creating a "bundle" notification when too many others are on screen | |
*/ | |
var handleNotificationDismiss = exports.handleNotificationDismiss = function handleNotificationDismiss(event) { | |
var data = event.notification.data; | |
Helpers.scribeActionForData('dismiss', data); | |
}; | |
var handleNotificationClick = exports.handleNotificationClick = function handleNotificationClick(event) { | |
var data = event.notification.data; | |
event.notification.close(); | |
Helpers.scribeActionForData('open', data); | |
return event.waitUntil(navigateToPage(data.uri || DEFAULT_CLICK_PATH)); | |
}; | |
var navigateToPage = function navigateToPage(uri) { | |
return Helpers.getBestClient().then(function (client) { | |
if (client && client.focus) { | |
return client.focus().then(function () { | |
return client.postMessage({ | |
type: _constants.ACTION_NAVIGATE, | |
payload: uri | |
}); | |
}); | |
} else { | |
return Helpers.openUri(uri); | |
} | |
}); | |
}; | |
var handlePush = exports.handlePush = function handlePush(event) { | |
// If they are on a browser that doesn't support payloads, we do the best we can | |
// by just showing something (as required by Chrome) and linking them to the notification page. | |
if (!event.data) { | |
Helpers.scribeActionForData('impression', defaultNotification.data); | |
return event.waitUntil(Helpers.showNotification(defaultNotification)); | |
} | |
var notification = event.data.json(); | |
var checkShouldShowNotification = Helpers.shouldShowNotification(notification.data && notification.data.uri); | |
return event.waitUntil(checkShouldShowNotification.then(function (shouldShowNotification) { | |
if (shouldShowNotification) { | |
return getNotificationToShow(notification).then(function (notification) { | |
Helpers.scribeActionForData('impression', notification.data); | |
return Helpers.showNotification(notification); | |
}); | |
} else { | |
return _promise2.default.resolve(); | |
} | |
})); | |
}; | |
var defaultNotification = { | |
title: 'Twitter', | |
body: 'New notification', | |
tag: DEFAULT_NOTIF_TAG, | |
icon: _iconDefault2.default, | |
badge: _logo2.default, | |
data: { | |
scribe_target: 'default', | |
uri: DEFAULT_CLICK_PATH | |
} | |
}; | |
var getNotificationToShow = function getNotificationToShow(notification) { | |
// Notifs must have a tag and data to be eligible for extra processing | |
if (!notification.tag || !notification.data) { | |
return _promise2.default.resolve((0, _extends3.default)({}, notification, { badge: _logo2.default, data: (0, _extends3.default)({}, notification.data, { totalCount: 1 }) })); | |
} | |
if (notifIsCollapsible(notification)) { | |
// If the notification doesn't need bundling, then we'll fall back to single notification | |
return getBundledNotificationToShow(notification).catch(function () { | |
return getSingleNotificationToShow(notification); | |
}); | |
} else { | |
return getSingleNotificationToShow(notification); | |
} | |
}; | |
// Handle displaying the notification, some of these can be themselves bundled so we still need to check tags | |
var getSingleNotificationToShow = function getSingleNotificationToShow(notification) { | |
return Helpers.getOpenNotifications(notification.tag).then(function (notifications) { | |
var openNotification = notifications[0]; | |
var totalCount = (openNotification ? openNotification.data.totalCount : 0) + 1; | |
// Construct the new notification | |
var othersCount = totalCount - 1; | |
var _notification$data = notification.data, | |
multi_title = _notification$data.multi_title, | |
multi_body = _notification$data.multi_body, | |
multi_uri = _notification$data.multi_uri; | |
var body = notification.body, | |
title = notification.title; | |
if (multi_title && totalCount > 1) { | |
var msg = new _locales2.default(multi_title, Helpers.getCurrentLanguages(notification.data)); | |
title = msg.format({ num_others: othersCount, num_total: totalCount }); | |
} | |
if (multi_body && totalCount > 1) { | |
var _msg = new _locales2.default(multi_body, Helpers.getCurrentLanguages(notification.data)); | |
body = _msg.format({ num_others: othersCount, num_total: totalCount }); | |
} | |
var uri = multi_uri & totalCount > 1 ? multi_uri : notification.data.uri || DEFAULT_CLICK_PATH; | |
return (0, _extends3.default)({}, notification, { | |
title: title, | |
body: body, | |
badge: _logo2.default, | |
icon: notification.icon || _iconDefault2.default, | |
data: (0, _extends3.default)({}, notification.data, { | |
uri: uri, | |
totalCount: totalCount | |
}) | |
}); | |
}); | |
}; | |
var getBundledNotificationToShow = function getBundledNotificationToShow(notification) { | |
return Helpers.getOpenNotifications().then(function (notifications) { | |
var collapseNotifs = notifications.filter(notifIsCollapsible); | |
var bundleNotif = notifications.find(function (notif) { | |
return notif.tag && notif.tag === BUNDLED_NOTIF_TAG; | |
}); | |
// Check if we have an interaction bundle already going or if this one would push us over | |
// if so, we collect everything to remove and shove their counts in the bundle | |
if ((bundleNotif || collapseNotifs.length >= BUNDLE_THRESHOLD) && notification.data.bundle_text) { | |
var shownNotifSum = collapseNotifs.reduce(function (acc, notif) { | |
return acc + (notif.data.totalCount || 1); | |
}, 0); | |
var totalCount = (bundleNotif ? bundleNotif.data.totalCount : 0) + shownNotifSum + 1; | |
collapseNotifs.forEach(function (notif) { | |
return notif.close(); | |
}); | |
// construct a bundle notification from scratch | |
var msg = new _locales2.default(notification.data.bundle_text, Helpers.getCurrentLanguages(notification.data)); | |
var body = msg.format({ num_total: totalCount }); | |
return { | |
title: 'Twitter', | |
body: body, | |
tag: BUNDLED_NOTIF_TAG, | |
icon: _iconDefault2.default, | |
badge: _logo2.default, | |
data: { | |
scribe_target: 'interaction_bundle', | |
totalCount: totalCount, | |
uri: DEFAULT_CLICK_PATH | |
} | |
}; | |
} else { | |
return _promise2.default.reject("Doesn't need bundling"); | |
} | |
}); | |
}; | |
self.addEventListener('push', handlePush); | |
self.addEventListener('notificationclose', handleNotificationDismiss); | |
self.addEventListener('notificationclick', handleNotificationClick); | |
/***/ }), | |
/* 52 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
__webpack_require__(64); | |
__webpack_require__(65); | |
__webpack_require__(66); | |
/***/ }), | |
/* 53 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
__webpack_require__(137); | |
/***/ }), | |
/* 54 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(86), __esModule: true }; | |
/***/ }), | |
/* 55 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* WEBPACK VAR INJECTION */(function(global) {/** | |
* Enforces a single instance of the Raven client, and the | |
* main entry point for Raven. If you are a consumer of the | |
* Raven library, you SHOULD load this file (vs raven.js). | |
**/ | |
var RavenConstructor = __webpack_require__(135); | |
// This is to be defensive in environments where window does not exist (see https://github.com/getsentry/raven-js/pull/785) | |
var _window = typeof window !== 'undefined' ? window | |
: typeof global !== 'undefined' ? global | |
: typeof self !== 'undefined' ? self | |
: {}; | |
var _Raven = _window.Raven; | |
var Raven = new RavenConstructor(); | |
/* | |
* Allow multiple versions of Raven to be installed. | |
* Strip Raven from the global context and returns the instance. | |
* | |
* @return {Raven} | |
*/ | |
Raven.noConflict = function () { | |
_window.Raven = _Raven; | |
return Raven; | |
}; | |
Raven.afterLoad(); | |
module.exports = Raven; | |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33))) | |
/***/ }), | |
/* 56 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.diskStore = exports.DB_VERSION = exports.STORE_NAME = exports.DB_NAME = undefined; | |
var _promise = __webpack_require__(5); | |
var _promise2 = _interopRequireDefault(_promise); | |
var _classCallCheck2 = __webpack_require__(74); | |
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | |
var _createClass2 = __webpack_require__(75); | |
var _createClass3 = _interopRequireDefault(_createClass2); | |
var _create = __webpack_require__(71); | |
var _create2 = _interopRequireDefault(_create); | |
exports.DiskStorageUnavailableError = DiskStorageUnavailableError; | |
var _ExecutionEnvironment = __webpack_require__(123); | |
var _errorReporting = __webpack_require__(57); | |
var _errorReporting2 = _interopRequireDefault(_errorReporting); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
/* global indexedDB, self */ | |
var DB_NAME = exports.DB_NAME = 'localforage'; | |
var STORE_NAME = exports.STORE_NAME = 'keyvaluepairs'; | |
// Must be numerically increasing, or client errors will ensue | |
var DB_VERSION = exports.DB_VERSION = 2; | |
var canUseStorage = _ExecutionEnvironment.canUseDOM && typeof window !== 'undefined' && window.indexedDB || typeof self !== 'undefined' && self.indexedDB; | |
var TransactionModes = { | |
READONLY: 'readonly', | |
READWRITE: 'readwrite' | |
}; | |
if (canUseStorage && _ExecutionEnvironment.canUseDOM) { | |
try { | |
// Safari Private Browsing disables localstorage/indexedDB calls by making them | |
// fail with non-descript errors. Check for this once to disable DiskStorage. | |
window.localStorage.setItem('test', 'a'); | |
window.localStorage.removeItem('test'); | |
} catch (e) { | |
canUseStorage = false; | |
} | |
} | |
function DiskStorageUnavailableError(message) { | |
this.name = 'DiskStorageUnavailableError'; | |
this.message = message || 'Disk Storage is unavailable for this client'; | |
this.stack = new Error().stack; | |
} | |
DiskStorageUnavailableError.prototype = (0, _create2.default)(Error.prototype); | |
DiskStorageUnavailableError.prototype.constructor = DiskStorageUnavailableError; | |
/** | |
* DiskStorage is a Promise-based wrapper for IndexedDB | |
* Based on https://github.com/jakearchibald/idb-keyval | |
*/ | |
var DiskStorage = function () { | |
function DiskStorage(dbName, storeName, version) { | |
var _this = this; | |
(0, _classCallCheck3.default)(this, DiskStorage); | |
this.isAvailable = function () { | |
return canUseStorage && !_this._isFailing; | |
}; | |
this._dbName = dbName; | |
this._storeName = storeName; | |
this._version = version || 1; | |
this._isFailing = false; | |
} | |
(0, _createClass3.default)(DiskStorage, [{ | |
key: '_getDB', | |
value: function _getDB() { | |
var _this2 = this; | |
if (!this._DB) { | |
this._DB = new _promise2.default(function (resolve, reject) { | |
var openRequest = indexedDB.open(_this2._dbName, _this2._version); | |
openRequest.onerror = function () { | |
reject(openRequest.error); | |
return true; // Prevents `InvalidStateError` and `UnknownError` exceptions. | |
}; | |
openRequest.onupgradeneeded = function (event) { | |
var newDB = event.target.result; | |
if (!newDB.objectStoreNames.contains(_this2._storeName)) { | |
newDB.createObjectStore(_this2._storeName); | |
} | |
}; | |
openRequest.onsuccess = function () { | |
resolve(openRequest.result); | |
}; | |
}); | |
} | |
return this._DB; | |
} | |
}, { | |
key: '_withStore', | |
value: function _withStore(transactionMode, callback) { | |
var _this3 = this; | |
if (!this.isAvailable()) { | |
return _promise2.default.reject(new DiskStorageUnavailableError()); | |
} | |
return this._getDB().then(function (db) { | |
return new _promise2.default(function (resolve, reject) { | |
var transaction = db.transaction(_this3._storeName, transactionMode); | |
transaction.oncomplete = function () { | |
_this3._retrying = false; | |
resolve(); | |
}; | |
transaction.onerror = function () { | |
var error = transaction.error; | |
reject(error); | |
}; | |
if (db.objectStoreNames.contains(_this3._storeName)) { | |
callback(transaction.objectStore(_this3._storeName)); | |
} else { | |
reject(new DiskStorageUnavailableError('Object store "' + _this3._storeName + '" does not exist in DB "' + _this3._dbName + '".')); | |
} | |
}); | |
}).catch(function (error) { | |
var errorName = error && error.name; | |
// The DB was previously closed. Clear the cached version and try once to reopen it | |
if (!_this3._retrying && errorName === 'InvalidStateError') { | |
_this3._DB = null; | |
_this3._retrying = true; | |
return _this3._withStore(transactionMode, callback); | |
} | |
// IndexedDB errors vary wildly across different browsers | |
// Disable Storage and report the error for observation | |
_this3._isFailing = true; | |
var reportFallback = function reportFallback() { | |
(0, _errorReporting2.default)(error); | |
}; | |
if (_ExecutionEnvironment.canUseDOM && 'webkitTemporaryStorage' in window.navigator) { | |
window.navigator.webkitTemporaryStorage.queryUsageAndQuota(function (storageUsed, storageQuota) { | |
(0, _errorReporting2.default)(error, { extra: { storageUsed: storageUsed, storageQuota: storageQuota } }); | |
}, reportFallback); | |
} else if (_ExecutionEnvironment.canUseDOM && 'webkitStorageInfo' in window) { | |
// Deprecated webkitStorageInfo returns storage remaining instead of quota | |
window.webkitStorageInfo.queryUsageAndQuota(window.webkitStorageInfo.TEMPORARY, function (storageUsed, storageRemaining) { | |
var storageQuota = storageUsed + storageRemaining; | |
(0, _errorReporting2.default)(error, { extra: { storageUsed: storageUsed, storageQuota: storageQuota } }); | |
}, reportFallback); | |
} else { | |
reportFallback(); | |
} | |
return _promise2.default.resolve(); | |
}); | |
} | |
}, { | |
key: 'get', | |
value: function get(key) { | |
var request = void 0; | |
return this._withStore(TransactionModes.READONLY, function (store) { | |
request = store.get(key); | |
}).then(function () { | |
return request && request.result; | |
}); | |
} | |
}, { | |
key: 'set', | |
value: function set(key, value) { | |
return this._withStore(TransactionModes.READWRITE, function (store) { | |
store.put(value, key); | |
}); | |
} | |
}, { | |
key: 'clear', | |
value: function clear() { | |
return this._withStore(TransactionModes.READWRITE, function (store) { | |
store.clear(); | |
}); | |
} | |
}, { | |
key: 'delete', | |
value: function _delete(key) { | |
return this._withStore(TransactionModes.READWRITE, function (store) { | |
store.delete(key); | |
}); | |
} | |
}, { | |
key: 'iterate', | |
value: function iterate(callback) { | |
return this._withStore(TransactionModes.READONLY, function (store) { | |
store.openCursor().onsuccess = function () { | |
if (this.result) { | |
callback(this.result.value, this.result.key); | |
this.result.continue(); | |
} | |
}; | |
}); | |
} | |
}]); | |
return DiskStorage; | |
}(); | |
exports.default = DiskStorage; | |
var diskStore = exports.diskStore = new DiskStorage(DB_NAME, STORE_NAME, DB_VERSION); | |
/***/ }), | |
/* 57 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
var _backends = []; | |
var getErrorClass = exports.getErrorClass = function getErrorClass(err) { | |
try { | |
return err.constructor.name; | |
} catch (e) { | |
return 'unknown error class'; | |
} | |
}; | |
var report = exports.report = function report(reportedError) { | |
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | |
extra = _ref.extra, | |
level = _ref.level, | |
logger = _ref.logger, | |
tags = _ref.tags; | |
var error = reportedError; | |
// Generic DOMErrors are not instances of actual Errors | |
// They have a `name` param, but not a `message`, so we normalize the | |
// DOMError to a string with some context, then pass that to Raven.js | |
if (/DOMError/.test({}.toString.call(error))) { | |
error = 'DOMError: ' + reportedError.name; | |
} | |
_backends.forEach(function (backend) { | |
return backend({ error: error, extra: extra, level: level, logger: logger, tags: tags }); | |
}); | |
}; | |
var install = exports.install = function install(backends) { | |
_backends = backends; | |
}; | |
var uninstall = exports.uninstall = function uninstall() { | |
_backends.length = 0; | |
}; | |
exports.default = report; | |
/***/ }), | |
/* 58 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
/** | |
* Thrift constants for scribing - sourced from M5's | |
* services/core/logger/js/logger.js | |
* | |
* Canonical source: | |
* src/thrift/com/twitter/clientapp/gen/client_app.thrift | |
*/ | |
var ThriftTypes = { | |
ItemType: { | |
TWEET: 0, | |
USER: 3, | |
ACTIVITY: 5, | |
MESSAGE: 6, | |
STORY: 7, | |
TREND: 8, | |
LIST: 11, | |
SEARCH: 12, | |
SAVED_SEARCH: 13, | |
PEOPLE_SEARCH: 14 | |
}, | |
CardType: { | |
PHOTO_TWEET: 1, | |
PHOTO_CARD: 2, | |
PLAYER_CARD: 3, | |
SUMMARY_CARD: 4, | |
PROMOTION_CARD: 5, // M5 doesn't support promotion yet, for completeness | |
PLUS_CARD: 6 | |
}, | |
AssociationType: { | |
ASSOCIATED_TWEET: 1, | |
PLATFORM_CARD_PUBLISHER: 2, | |
PLATFORM_CARD_CREATOR: 3, | |
CONVERSATION_ORIGIN: 4, | |
ASSOCIATED_USER: 5, | |
ASSOCIATED_TIMELINE: 6 | |
} | |
}; | |
exports.default = ThriftTypes; | |
/***/ }), | |
/* 59 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
/* Shared Actions */ | |
var ACTION_NAVIGATE = exports.ACTION_NAVIGATE = 'ACTION_NAVIGATE'; | |
/***/ }), | |
/* 60 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
var DOMAIN = 'abs-0.twimg.com'; | |
/** | |
* Builds an absolute URL to a twemoji | |
* @param {String} emojiCodePoint Code point of a unicode emoji string | |
* @param {String} domain domain that is hosting the twemoji | |
* @return {String} URL | |
*/ | |
var getTwemojiUrl = exports.getTwemojiUrl = function getTwemojiUrl(rawEmoji) { | |
var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DOMAIN; | |
var emojiCodePoint = getIconName(rawEmoji); | |
return 'https://' + DOMAIN + '/emoji/v2/svg/' + emojiCodePoint + '.svg'; | |
}; | |
var asImageRegExp = /\uFE0F/g; | |
// avoid using a string literal like '\u200D' here because minifiers expand it inline | |
var zeroWidthJoiner = String.fromCharCode(0x200D); | |
var removeImageFlags = exports.removeImageFlags = function removeImageFlags(rawEmoji) { | |
return rawEmoji.indexOf(zeroWidthJoiner) < 0 ? rawEmoji.replace(asImageRegExp, '') : rawEmoji; | |
}; | |
var toCodePoint = function toCodePoint(unicodeSurrogates) { | |
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '-'; | |
var points = []; | |
var char = 0; | |
var previous = 0; | |
var i = 0; | |
while (i < unicodeSurrogates.length) { | |
char = unicodeSurrogates.charCodeAt(i++); | |
if (previous) { | |
points.push((0x10000 + (previous - 0xD800 << 10) + (char - 0xDC00)).toString(16)); | |
previous = 0; | |
} else if (char > 0xD800 && char <= 0xDBFF) { | |
previous = char; | |
} else { | |
points.push(char.toString(16)); | |
} | |
} | |
return points.join(separator); | |
}; | |
var getIconName = function getIconName(rawEmoji) { | |
return toCodePoint(removeImageFlags(rawEmoji)); | |
}; | |
/***/ }), | |
/* 61 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var _extends2 = __webpack_require__(11); | |
var _extends3 = _interopRequireDefault(_extends2); | |
var _stringify = __webpack_require__(20); | |
var _stringify2 = _interopRequireDefault(_stringify); | |
var _keys = __webpack_require__(54); | |
var _keys2 = _interopRequireDefault(_keys); | |
__webpack_require__(53); | |
__webpack_require__(52); | |
__webpack_require__(51); | |
var _sentry = __webpack_require__(50); | |
var _ravenJs = __webpack_require__(55); | |
var _ravenJs2 = _interopRequireDefault(_ravenJs); | |
var _constants = __webpack_require__(34); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
/* global self, Headers, Request, Blob, fetch */ | |
// Polyfills must be imported first | |
/* eslint-disable sort-imports */ | |
if (Math.random() <= self.SENTRY_SAMPLE_RATE) { | |
(0, _sentry.initRaven)(_ravenJs2.default, { | |
dsn: _constants.SENTRY_DSN, | |
quota: 10, | |
release: self.BUILD_SHA, | |
tags: { | |
environment: 'serviceworker' | |
} | |
}); | |
} | |
/* eslint-enable sort-imports */ | |
_ravenJs2.default._makeRequest = function (opts) { | |
var auth = (0, _keys2.default)(opts.auth).map(function (key) { | |
return key + '=' + opts.auth[key]; | |
}).join('&'); | |
var headers = new Headers(); | |
headers.append('origin', self.location.origin); | |
var req = new Request(opts.url + '?' + auth, { | |
method: 'POST', | |
body: new Blob([(0, _stringify2.default)((0, _extends3.default)({}, opts.data, opts.auth), null, 2)], { type: 'application/json' }), | |
mode: 'cors', | |
credentials: 'omit', | |
headers: headers, | |
referrer: self.location.origin | |
}); | |
fetch(req); | |
}; | |
var handleInstall = function handleInstall(event) { | |
// force waiting ServiceWorker to become the active ServiceWorker | |
event.waitUntil(self.skipWaiting()); | |
}; | |
var handleActivate = function handleActivate(event) { | |
// sets as active ServiceWorker for all clients + triggers oncontrollerchange event | |
event.waitUntil(self.clients.claim()); | |
}; | |
self.addEventListener('install', handleInstall); | |
self.addEventListener('activate', handleActivate); | |
/***/ }), | |
/* 62 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.getFocusedClient = exports.getBestClient = exports.shouldShowNotification = exports.getCurrentLanguages = exports.getOpenNotifications = exports.openUri = exports.showNotification = exports.scribeActionForData = undefined; | |
var _scribe = __webpack_require__(67); | |
var _scribe2 = _interopRequireDefault(_scribe); | |
var _ThriftTypes = __webpack_require__(58); | |
var _ThriftTypes2 = _interopRequireDefault(_ThriftTypes); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// Push helpers which are separated out primarily to make mocking and testing easier | |
/* global self, URL */ | |
var itemsDataForScribe = function itemsDataForScribe(data) { | |
if (!data) { | |
return []; | |
} | |
if (data.tweet_id) { | |
return [{ | |
id: data.tweet_id, | |
item_type: _ThriftTypes2.default.ItemType.TWEET | |
}]; | |
} else if (data.user_id) { | |
return [{ | |
id: data.user_id, | |
item_type: _ThriftTypes2.default.ItemType.USER | |
}]; | |
} else { | |
return []; | |
} | |
}; | |
var scribeActionForData = exports.scribeActionForData = function scribeActionForData(action, data) { | |
return (0, _scribe2.default)({ | |
section: 'push', | |
element: data && data.scribe_target || 'other', | |
action: action | |
}, { | |
event_value: data && data.totalCount, | |
impression_id: data && data.impression_id, | |
items: itemsDataForScribe(data) | |
}); | |
}; | |
var showNotification = exports.showNotification = function showNotification(notification) { | |
return self.registration.showNotification(notification.title, notification); | |
}; | |
var openUri = exports.openUri = function openUri(uri) { | |
return self.clients.openWindow(uri); | |
}; | |
var getOpenNotifications = exports.getOpenNotifications = function getOpenNotifications(tag) { | |
return self.registration.getNotifications({ tag: tag }); | |
}; | |
// Can return an array of prefered languages or just a single string | |
var getCurrentLanguages = exports.getCurrentLanguages = function getCurrentLanguages(data) { | |
return data && data.lang || navigator.languages || navigator.language || navigator.userLanguage || 'en'; | |
}; | |
var shouldShowNotification = exports.shouldShowNotification = function shouldShowNotification(pathToMatch) { | |
var funcGetFocusedClient = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getFocusedClient; | |
return funcGetFocusedClient().then(function (client) { | |
if (!client || !pathToMatch) { | |
return true; | |
} | |
var url = void 0; | |
try { | |
url = new URL(client.url); | |
} catch (e) { | |
return true; | |
} | |
// if it's DM, we suppress the notification when you're in either DMInbox or | |
// the conversation. | |
if (pathToMatch.match(/^\/messages/)) { | |
return !(url.pathname === '/messages' || url.pathname === pathToMatch); | |
} else { | |
return !(url.pathname === '/notifications'); | |
} | |
}); | |
}; | |
// Prefer the visible window, or fallback to any window we own otherwise. Null if none open. | |
var getBestClient = exports.getBestClient = function getBestClient() { | |
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | |
preferVisible = _ref.preferVisible; | |
var clients = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : self.clients.matchAll({ type: 'window' }); | |
return clients.then(function (windows) { | |
var realWindows = windows.filter(function (client) { | |
return client.frameType === 'top-level'; | |
}); | |
var visibleWindows = realWindows.filter(function (client) { | |
return !preferVisible || client.visibilityState === 'visible'; | |
}); | |
return visibleWindows[0] || realWindows[0]; | |
}); | |
}; | |
var getFocusedClient = exports.getFocusedClient = function getFocusedClient() { | |
var clients = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : self.clients.matchAll({ type: 'window' }); | |
return clients.then(function (windows) { | |
return windows.filter(function (client) { | |
return client.focused && client.frameType === 'top-level' && client.visibilityState === 'visible'; | |
})[0]; | |
}); | |
}; | |
/***/ }), | |
/* 63 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
var _intlMessageformat = __webpack_require__(126); | |
var _intlMessageformat2 = _interopRequireDefault(_intlMessageformat); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// This is a smaller version of intl-messageformat/locales which only uses | |
// the languages we actually support to keep it smaller | |
/* eslint-disable */ | |
var locales = [{ "locale": "ar", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
t0 = Number(s[0]) == n, | |
n100 = t0 && s[0].slice(-2);if (ord) return "other";return n == 0 ? "zero" : n == 1 ? "one" : n == 2 ? "two" : n100 >= 3 && n100 <= 10 ? "few" : n100 >= 11 && n100 <= 99 ? "many" : "other"; | |
} }, { "locale": "bg", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "bn", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10 ? "one" : n == 2 || n == 3 ? "two" : n == 4 ? "few" : n == 6 ? "many" : "other";return n >= 0 && n <= 1 ? "one" : "other"; | |
} }, { "locale": "ca", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1];if (ord) return n == 1 || n == 3 ? "one" : n == 2 ? "two" : n == 4 ? "few" : "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "cs", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
v0 = !s[1];if (ord) return "other";return n == 1 && v0 ? "one" : i >= 2 && i <= 4 && v0 ? "few" : !v0 ? "many" : "other"; | |
} }, { "locale": "da", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
t0 = Number(s[0]) == n;if (ord) return "other";return n == 1 || !t0 && (i == 0 || i == 1) ? "one" : "other"; | |
} }, { "locale": "de", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1];if (ord) return "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "el", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "en", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1], | |
t0 = Number(s[0]) == n, | |
n10 = t0 && s[0].slice(-1), | |
n100 = t0 && s[0].slice(-2);if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "es", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "eu", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "fa", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n >= 0 && n <= 1 ? "one" : "other"; | |
} }, { "locale": "fi", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1];if (ord) return "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "fil", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
f = s[1] || "", | |
v0 = !s[1], | |
i10 = i.slice(-1), | |
f10 = f.slice(-1);if (ord) return n == 1 ? "one" : "other";return v0 && (i == 1 || i == 2 || i == 3) || v0 && i10 != 4 && i10 != 6 && i10 != 9 || !v0 && f10 != 4 && f10 != 6 && f10 != 9 ? "one" : "other"; | |
} }, { "locale": "fr", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 ? "one" : "other";return n >= 0 && n < 2 ? "one" : "other"; | |
} }, { "locale": "gl", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1];if (ord) return "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "gu", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 ? "one" : n == 2 || n == 3 ? "two" : n == 4 ? "few" : n == 6 ? "many" : "other";return n >= 0 && n <= 1 ? "one" : "other"; | |
} }, { "locale": "he", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
v0 = !s[1], | |
t0 = Number(s[0]) == n, | |
n10 = t0 && s[0].slice(-1);if (ord) return "other";return n == 1 && v0 ? "one" : i == 2 && v0 ? "two" : v0 && (n < 0 || n > 10) && t0 && n10 == 0 ? "many" : "other"; | |
} }, { "locale": "hi", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 ? "one" : n == 2 || n == 3 ? "two" : n == 4 ? "few" : n == 6 ? "many" : "other";return n >= 0 && n <= 1 ? "one" : "other"; | |
} }, { "locale": "hr", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
f = s[1] || "", | |
v0 = !s[1], | |
i10 = i.slice(-1), | |
i100 = i.slice(-2), | |
f10 = f.slice(-1), | |
f100 = f.slice(-2);if (ord) return "other";return v0 && i10 == 1 && i100 != 11 || f10 == 1 && f100 != 11 ? "one" : v0 && i10 >= 2 && i10 <= 4 && (i100 < 12 || i100 > 14) || f10 >= 2 && f10 <= 4 && (f100 < 12 || f100 > 14) ? "few" : "other"; | |
} }, { "locale": "hu", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 || n == 5 ? "one" : "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "id", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return "other"; | |
} }, { "locale": "it", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1];if (ord) return n == 11 || n == 8 || n == 80 || n == 800 ? "many" : "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "ja", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return "other"; | |
} }, { "locale": "kn", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n >= 0 && n <= 1 ? "one" : "other"; | |
} }, { "locale": "ko", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return "other"; | |
} }, { "locale": "mr", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 ? "one" : n == 2 || n == 3 ? "two" : n == 4 ? "few" : "other";return n >= 0 && n <= 1 ? "one" : "other"; | |
} }, { "locale": "ms", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 ? "one" : "other";return "other"; | |
} }, { "locale": "nb", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "nl", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1];if (ord) return "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "pl", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
v0 = !s[1], | |
i10 = i.slice(-1), | |
i100 = i.slice(-2);if (ord) return "other";return n == 1 && v0 ? "one" : v0 && i10 >= 2 && i10 <= 4 && (i100 < 12 || i100 > 14) ? "few" : v0 && i != 1 && (i10 == 0 || i10 == 1) || v0 && i10 >= 5 && i10 <= 9 || v0 && i100 >= 12 && i100 <= 14 ? "many" : "other"; | |
} }, { "locale": "pt", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
t0 = Number(s[0]) == n;if (ord) return "other";return t0 && n >= 0 && n <= 2 && n != 2 ? "one" : "other"; | |
} }, { "locale": "ro", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1], | |
t0 = Number(s[0]) == n, | |
n100 = t0 && s[0].slice(-2);if (ord) return n == 1 ? "one" : "other";return n == 1 && v0 ? "one" : !v0 || n == 0 || n != 1 && n100 >= 1 && n100 <= 19 ? "few" : "other"; | |
} }, { "locale": "ru", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
v0 = !s[1], | |
i10 = i.slice(-1), | |
i100 = i.slice(-2);if (ord) return "other";return v0 && i10 == 1 && i100 != 11 ? "one" : v0 && i10 >= 2 && i10 <= 4 && (i100 < 12 || i100 > 14) ? "few" : v0 && i10 == 0 || v0 && i10 >= 5 && i10 <= 9 || v0 && i100 >= 11 && i100 <= 14 ? "many" : "other"; | |
} }, { "locale": "sk", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
v0 = !s[1];if (ord) return "other";return n == 1 && v0 ? "one" : i >= 2 && i <= 4 && v0 ? "few" : !v0 ? "many" : "other"; | |
} }, { "locale": "sr", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
f = s[1] || "", | |
v0 = !s[1], | |
i10 = i.slice(-1), | |
i100 = i.slice(-2), | |
f10 = f.slice(-1), | |
f100 = f.slice(-2);if (ord) return "other";return v0 && i10 == 1 && i100 != 11 || f10 == 1 && f100 != 11 ? "one" : v0 && i10 >= 2 && i10 <= 4 && (i100 < 12 || i100 > 14) || f10 >= 2 && f10 <= 4 && (f100 < 12 || f100 > 14) ? "few" : "other"; | |
} }, { "locale": "sv", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1], | |
t0 = Number(s[0]) == n, | |
n10 = t0 && s[0].slice(-1), | |
n100 = t0 && s[0].slice(-2);if (ord) return (n10 == 1 || n10 == 2) && n100 != 11 && n100 != 12 ? "one" : "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "ta", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "th", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return "other"; | |
} }, { "locale": "tr", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return n == 1 ? "one" : "other"; | |
} }, { "locale": "uk", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
i = s[0], | |
v0 = !s[1], | |
t0 = Number(s[0]) == n, | |
n10 = t0 && s[0].slice(-1), | |
n100 = t0 && s[0].slice(-2), | |
i10 = i.slice(-1), | |
i100 = i.slice(-2);if (ord) return n10 == 3 && n100 != 13 ? "few" : "other";return v0 && i10 == 1 && i100 != 11 ? "one" : v0 && i10 >= 2 && i10 <= 4 && (i100 < 12 || i100 > 14) ? "few" : v0 && i10 == 0 || v0 && i10 >= 5 && i10 <= 9 || v0 && i100 >= 11 && i100 <= 14 ? "many" : "other"; | |
} }, { "locale": "ur", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
var s = String(n).split("."), | |
v0 = !s[1];if (ord) return "other";return n == 1 && v0 ? "one" : "other"; | |
} }, { "locale": "vi", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return n == 1 ? "one" : "other";return "other"; | |
} }, { "locale": "zh", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return "other"; | |
} }, { "locale": "zh-Hant", "pluralRuleFunction": function pluralRuleFunction(n, ord) { | |
if (ord) return "other";return "other"; | |
} }]; | |
/* eslint-enable */ | |
locales.forEach(function (obj) { | |
return _intlMessageformat2.default.__addLocaleData(obj); | |
}); | |
exports.default = _intlMessageformat2.default; | |
/***/ }), | |
/* 64 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.handleCleanupStaleAssets = exports.handleCacheAssets = exports.handleFetchAsset = undefined; | |
var _promise = __webpack_require__(5); | |
var _promise2 = _interopRequireDefault(_promise); | |
var _toConsumableArray2 = __webpack_require__(77); | |
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | |
var _utils = __webpack_require__(21); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var ASSET_CACHE_KEY = 'assets'; /* global caches, fetch, Request, self */ | |
var DEV = self.ENV === 'development'; | |
var HOME_PATH = '/home?precache=1'; | |
var homeRequest = void 0; | |
var CacheableRoutes = [self.location.origin + '/', self.location.origin + '/compose', self.location.origin + '/home', self.location.origin + '/notifications', self.location.origin + '/login']; | |
var CacheableRouteMatchers = [ | |
// DM Inbox and DMs | |
new RegExp('^' + (0, _utils.regexEscapeString)(self.location.origin) + '/messages(/.+)?'), | |
// Search home and various search types | |
new RegExp('^' + (0, _utils.regexEscapeString)(self.location.origin) + '/search(.+)?'), | |
// Permalink | |
new RegExp('^' + (0, _utils.regexEscapeString)(self.location.origin) + '/[a-zA-Z0-9_]{1,20}/status')]; | |
var isCacheableUrl = function isCacheableUrl(url) { | |
if (CacheableRoutes.indexOf(url) !== -1) { | |
return true; | |
} else { | |
for (var i = 0; i < CacheableRouteMatchers.length; i++) { | |
// Build a match for the entire URL, starting from the origin | |
var matcher = CacheableRouteMatchers[i]; | |
if (matcher.test(url)) { | |
return true; | |
} | |
} | |
} | |
return false; | |
}; | |
var getHomeRequest = function getHomeRequest() { | |
if (!homeRequest) { | |
homeRequest = new Request(HOME_PATH, { | |
cache: 'reload', | |
mode: 'same-origin', | |
credentials: 'include' | |
}); | |
} | |
return homeRequest; | |
}; | |
var getRequestPath = function getRequestPath(request) { | |
return request.url.replace(self.location.origin, ''); | |
}; | |
var isNavigatingFrom = function isNavigatingFrom(request, paths) { | |
return request.mode === 'navigate' && paths.some(function (path) { | |
return request.referrer && request.referrer.indexOf('' + self.location.origin + path) !== -1; | |
}); | |
}; | |
var isNavigatingTo = function isNavigatingTo(request, paths) { | |
return request.mode === 'navigate' && paths.some(function (path) { | |
return request.url.indexOf('' + self.location.origin + path) !== -1; | |
}); | |
}; | |
var fetchAndCacheHomeForRequest = function fetchAndCacheHomeForRequest(request) { | |
// Ensure we're not pulling local resources that are not the app shell (manifest.json, loading.gif, etc) | |
var cacheableRequest = (0, _utils.requestWithUrl)(request, (0, _utils.urlWithParam)(request.url, 'prefetchTimestamp', Date.now())); | |
return (0, _utils.networkPriorityFirst)(ASSET_CACHE_KEY, cacheableRequest, getHomeRequest()); | |
}; | |
var handleFetchAsset = exports.handleFetchAsset = function handleFetchAsset(event) { | |
var request = event.request; | |
var url = request.url; | |
var assetPathMap = self.ASSETS.map(_utils.regexEscapeString).join('|'); | |
var assetPathRegExp = new RegExp('(' + assetPathMap + ')$'); | |
// Do not proceed use cached assets/html while in DEV environment | |
if (DEV) { | |
return; | |
} | |
if (assetPathRegExp.test(url)) { | |
// outside of prod, the asset URLs are constant, so relying on cache is not a usable approach | |
event.respondWith((0, _utils.cacheFirst)(ASSET_CACHE_KEY, request)); | |
return; | |
} | |
if (isNavigatingTo(request, ['/?logout', '/login', '/signup']) || isNavigatingFrom(request, ['/login', '/signup'])) { | |
// Remove the pre-cached app shell on logout, login, or signup | |
event.respondWith(caches.open(ASSET_CACHE_KEY).then(function (cache) { | |
cache.delete(homeRequest); | |
if (isCacheableUrl(url)) { | |
return fetchAndCacheHomeForRequest(request); | |
} else { | |
return fetch(request); | |
} | |
}).catch(function () { | |
return fetch(request); | |
})); | |
return; | |
} | |
if (isCacheableUrl(url)) { | |
event.respondWith(fetchAndCacheHomeForRequest(request)); | |
} | |
}; | |
// Prime the cache with a new version of the HTML shell as well as only re-caching | |
// the ASSETS at paths not already in cache. | |
var handleCacheAssets = exports.handleCacheAssets = function handleCacheAssets(event) { | |
event.waitUntil(caches.open(ASSET_CACHE_KEY).then(function (cache) { | |
return cache.keys().then(function (keys) { | |
var inCache = keys.map(getRequestPath); | |
var newlyCacheable = self.ASSETS.filter(function (path) { | |
return inCache.indexOf(path) === -1; | |
}); | |
return cache.addAll([getHomeRequest()].concat((0, _toConsumableArray3.default)(newlyCacheable))); | |
}); | |
})); | |
}; | |
// Clean up stale pre-cached items that we don't need anymore (old ASSETS) | |
var handleCleanupStaleAssets = exports.handleCleanupStaleAssets = function handleCleanupStaleAssets(event) { | |
event.waitUntil(caches.open(ASSET_CACHE_KEY).then(function (cache) { | |
return cache.keys().then(function (keys) { | |
var inCache = keys.map(getRequestPath); | |
var newestCacheItems = [HOME_PATH].concat((0, _toConsumableArray3.default)(self.ASSETS)); | |
var staleCacheItems = inCache.filter(function (path) { | |
return newestCacheItems.indexOf(path) === -1; | |
}); | |
return _promise2.default.all(staleCacheItems.map(function (path) { | |
return cache.delete(path); | |
})); | |
}); | |
})); | |
}; | |
self.addEventListener('fetch', handleFetchAsset); | |
self.addEventListener('install', handleCacheAssets); | |
self.addEventListener('activate', handleCleanupStaleAssets); | |
/***/ }), | |
/* 65 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.handleActivate = exports.handleFetch = undefined; | |
var _stringify = __webpack_require__(20); | |
var _stringify2 = _interopRequireDefault(_stringify); | |
var _entries = __webpack_require__(73); | |
var _entries2 = _interopRequireDefault(_entries); | |
var _slicedToArray2 = __webpack_require__(76); | |
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); | |
var _getIterator2 = __webpack_require__(35); | |
var _getIterator3 = _interopRequireDefault(_getIterator2); | |
var _promise = __webpack_require__(5); | |
var _promise2 = _interopRequireDefault(_promise); | |
var _diskStorage = __webpack_require__(56); | |
var _diskStorage2 = _interopRequireDefault(_diskStorage); | |
var _utils = __webpack_require__(21); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
/** | |
* Syncable Requests | |
* | |
* A module that catches POST, PUT, and DELETE requests when offline, caches | |
* them, and then syncs them later when a network connection is available. | |
*/ | |
/* global Blob, fetch, Request, Response, self */ | |
var DB_NAME = 'sync'; | |
var STORE_NAME = 'queue'; | |
var DB_VERSION = 1; | |
var IS_FLUSHING = false; | |
var diskStore = void 0; | |
// Some endpoints are POST, but the application needs a full response in order to continue | |
// Allow these to fail directly | |
var SYNC_BLACKLIST = ['/1.1/account/update_profile_image.json', '/1.1/dm/new.json', '/1.1/guest/activate.json', '/1.1/device/register_complete.json', '/1.1/mobile/settings/get.json', '/1.1/mutes/keywords/create.json', '/1.1/mutes/keywords/destroy.json', '/1.1/mutes/keywords/update.json', '/1.1/statuses/update.json', '/1.1/account/settings.json', 'upload.twitter.com/i/media/upload.json']; | |
var getDiskStore = function getDiskStore() { | |
if (!diskStore) { | |
diskStore = new _diskStorage2.default(DB_NAME, STORE_NAME, DB_VERSION); | |
} | |
return diskStore; | |
}; | |
var isSyncable = function isSyncable(method, url) { | |
if (['GET', 'HEAD'].indexOf(method) !== -1) { | |
return false; | |
} | |
if (SYNC_BLACKLIST.some(function (blacklistedPath) { | |
return url.indexOf(blacklistedPath) !== -1; | |
})) { | |
return false; | |
} | |
return true; | |
}; | |
/** | |
* Serialize a Request into a plain object for storage inside of IndexedDB | |
* @param {Request} request | |
* @return {Promise} A serialized version of the request | |
*/ | |
var serializeRequest = function serializeRequest(request) { | |
var cache = request.cache, | |
credentials = request.credentials, | |
headers = request.headers, | |
method = request.method, | |
mode = request.mode, | |
redirect = request.redirect, | |
referrer = request.referrer, | |
url = request.url; | |
var serializedHeaders = {}; | |
// Headers.entries is an iterable. It cannot use map/reduce/etc. | |
var _iteratorNormalCompletion = true; | |
var _didIteratorError = false; | |
var _iteratorError = undefined; | |
try { | |
for (var _iterator = (0, _getIterator3.default)(headers.entries()), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | |
var _step$value = (0, _slicedToArray3.default)(_step.value, 2), | |
key = _step$value[0], | |
value = _step$value[1]; | |
serializedHeaders[key] = value; | |
} | |
} catch (err) { | |
_didIteratorError = true; | |
_iteratorError = err; | |
} finally { | |
try { | |
if (!_iteratorNormalCompletion && _iterator.return) { | |
_iterator.return(); | |
} | |
} finally { | |
if (_didIteratorError) { | |
throw _iteratorError; | |
} | |
} | |
} | |
var serializedRequest = { | |
url: url, | |
headers: serializedHeaders, | |
method: method, | |
mode: mode, | |
credentials: credentials, | |
cache: cache, | |
redirect: redirect, | |
referrer: referrer | |
}; | |
// Requests that send a body need to have that read and added to the serialized request | |
if (isSyncable(method, url)) { | |
return request.clone().blob().then(function (body) { | |
serializedRequest.body = body; | |
return _promise2.default.resolve(serializedRequest); | |
}); | |
} else { | |
// Otherwise, GET requests can do without a body | |
return _promise2.default.resolve(serializedRequest); | |
} | |
}; | |
/** | |
* Convert a serialized request back to a Request object. | |
* @param {Object} data Serialized representation of a Request | |
* @return {Promise} | |
*/ | |
var deserializeRequest = function deserializeRequest(data) { | |
return _promise2.default.resolve(new Request(data.url, data)); | |
}; | |
/** | |
* Enqueues a Request object. Ensures only one enqueue operation at a time. | |
* @param {Request} request | |
* @return {Promise} | |
*/ | |
var enqueue = function enqueue(request) { | |
return serializeRequest(request).then(function (serialized) { | |
return getDiskStore().set(Date.now().toString(), serialized); | |
}); | |
}; | |
/** | |
* Empty the queue of requests one at a time | |
* @return {Promise} | |
*/ | |
var flushQueue = function flushQueue() { | |
if (!IS_FLUSHING) { | |
IS_FLUSHING = true; | |
var requests = {}; | |
return getDiskStore().iterate(function (value, key) { | |
requests[key] = value; | |
}).then(function () { | |
return _promise2.default.all((0, _entries2.default)(requests).map(function (_ref) { | |
var _ref2 = (0, _slicedToArray3.default)(_ref, 2), | |
key = _ref2[0], | |
request = _ref2[1]; | |
return deserializeRequest(request).then(fetch).then(function () { | |
return diskStore.delete(key); | |
}); | |
})); | |
}).then(function () { | |
IS_FLUSHING = false; | |
}).catch(function () { | |
IS_FLUSHING = false; | |
}); | |
} else { | |
return _promise2.default.resolve(); | |
} | |
}; | |
var handleFetch = exports.handleFetch = function handleFetch(event) { | |
// If event does not implement ExtendableEvent, sync won't work. | |
// Abort and let the browser handle this on its own. | |
// Also prevents a CORS error with event.respondWith | |
if (!event || !event.waitUntil) { | |
return; | |
} | |
// If online, hold the event open after the response to flush the queue. | |
if ((0, _utils.isOnline)()) { | |
// Trigger an async flushing of the queue when any other request is made as well | |
event.waitUntil(flushQueue()); | |
} | |
if (isSyncable(event.request.method, event.request.url)) { | |
var cacheableRequest = event.request.clone(); | |
event.respondWith(fetch(event.request).catch(function () { | |
// If we're offline, enqueue for later | |
return enqueue(cacheableRequest).then(function () { | |
// Return a dummy success message to the client | |
var blob = new Blob([(0, _stringify2.default)({ success: true })], { type: 'application/json' }); | |
return _promise2.default.resolve(new Response(blob, { | |
status: 202, | |
statusText: 'CachedForSync' | |
})); | |
}); | |
})); | |
} | |
}; | |
// Forcibly empty the queue if we're installing a new SW version | |
// Prevents us from potentially running away with too much in the queue if | |
// there's a script error. | |
var handleActivate = exports.handleActivate = function handleActivate(event) { | |
event.waitUntil(getDiskStore().clear()); | |
}; | |
self.addEventListener('fetch', handleFetch); | |
self.addEventListener('activate', handleActivate); | |
/***/ }), | |
/* 66 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.handleInstall = exports.handleFetch = exports.popularEmojiUrls = undefined; | |
var _promise = __webpack_require__(5); | |
var _promise2 = _interopRequireDefault(_promise); | |
var _utils = __webpack_require__(21); | |
var _twemoji = __webpack_require__(60); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
/* global caches, Request, self */ | |
var CACHE_KEY = 'twemoji'; | |
var POPULAR_EMOJI = ['\u2764', // â¤ï¸ | |
'\uD83D\uDE02', // 😂 | |
'\uD83D\uDE12', // 😒 | |
'\uD83D\uDE0D', // 😠| |
'\u263A', // â˜ºï¸ | |
'\uD83D\uDC4C', // 👌 | |
'\uD83D\uDE18', // 😘 | |
'\uD83D\uDE0A', // 😊 | |
'\uD83D\uDE14', // 😔 | |
'\uD83D\uDE29', // 😩 | |
'\uD83D\uDE2D', // 😠| |
'\uD83D\uDE2D', // 😠| |
'\uD83D\uDE01', // 😠| |
'\uD83D\uDC95', // 💕 | |
'\uD83D\uDE33', // 😳 | |
'\uD83D\uDC4D', // 👠| |
'\uD83D\uDE4C', // 🙌 | |
'\uD83D\uDE09', // 😉 | |
'\uD83D\uDC81' // 💠| |
]; | |
var requestsByUrl = function requestsByUrl(request) { | |
return request.url; | |
}; | |
var popularEmojiUrls = exports.popularEmojiUrls = POPULAR_EMOJI.map(_twemoji.getTwemojiUrl); | |
// Pull "popular emoji" from the cache | |
// All other emoji should be restricted to network only | |
// Prevents wasting temporary storage and having the browser clear us out | |
var handleFetch = exports.handleFetch = function handleFetch(event) { | |
var request = event.request; | |
if (popularEmojiUrls.indexOf(request.url) !== -1) { | |
event.respondWith((0, _utils.cacheFirst)(CACHE_KEY, request)); | |
} | |
}; | |
// Prime the cache with the "popular emoji" that are not already cached | |
var handleInstall = exports.handleInstall = function handleInstall(event) { | |
event.waitUntil(caches.open(CACHE_KEY).then(function (cache) { | |
return cache.keys().then(function (cachedKeys) { | |
var cachedUrls = cachedKeys.map(requestsByUrl); | |
var newlyCacheable = popularEmojiUrls.filter(function (url) { | |
return cachedUrls.indexOf(url) === -1; | |
}).map(function (url) { | |
return new Request(url, { mode: 'cors' }); | |
}); | |
// Do not return this, as pre-caching emoji should be non-blocking | |
cache.addAll(newlyCacheable); | |
return _promise2.default.resolve(); | |
}); | |
})); | |
}; | |
self.addEventListener('fetch', handleFetch); | |
self.addEventListener('install', handleInstall); | |
/***/ }), | |
/* 67 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.getScribeJSON = undefined; | |
var _extends2 = __webpack_require__(11); | |
var _extends3 = _interopRequireDefault(_extends2); | |
var _stringify = __webpack_require__(20); | |
var _stringify2 = _interopRequireDefault(_stringify); | |
var _constants = __webpack_require__(34); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var SCRIBE_CLIENT = 'm5'; | |
/* | |
* Lightweight scribe interface for logging display and clicks | |
* Similar to that of Desktop SW and F5 | |
*/ | |
/* global self */ | |
exports.default = function (terms) { | |
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | |
self.fetch('/i/jot', { | |
credentials: 'include', | |
method: 'post', | |
headers: { | |
'Accept': 'application/x-www-form-urlencoded', | |
'Content-Type': 'application/x-www-form-urlencoded' | |
}, | |
body: 'log=' + encodeURIComponent((0, _stringify2.default)(getScribeJSON(terms, data))) | |
}); | |
}; | |
var getScribeJSON = exports.getScribeJSON = function getScribeJSON(terms) { | |
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | |
if (!terms || !terms.action) { | |
throw new Error('You must specify an action term in your client_event.'); | |
} | |
// http://go/clienteventnamespace for details | |
var eventNamespace = { | |
client: SCRIBE_CLIENT, | |
page: 'app', | |
section: terms.section || '', | |
component: terms.component || '', | |
element: terms.element || '', | |
action: terms.action | |
}; | |
return (0, _extends3.default)({}, data, { | |
event_namespace: eventNamespace, | |
_category_: 'client_event', | |
triggered_on: Date.now(), | |
format_version: 2, | |
client_app_id: _constants.CLIENT_APPLICATION_ID | |
}); | |
}; | |
/***/ }), | |
/* 68 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(78), __esModule: true }; | |
/***/ }), | |
/* 69 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(80), __esModule: true }; | |
/***/ }), | |
/* 70 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(82), __esModule: true }; | |
/***/ }), | |
/* 71 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(83), __esModule: true }; | |
/***/ }), | |
/* 72 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(84), __esModule: true }; | |
/***/ }), | |
/* 73 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = { "default": __webpack_require__(85), __esModule: true }; | |
/***/ }), | |
/* 74 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
exports.__esModule = true; | |
exports.default = function (instance, Constructor) { | |
if (!(instance instanceof Constructor)) { | |
throw new TypeError("Cannot call a class as a function"); | |
} | |
}; | |
/***/ }), | |
/* 75 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
exports.__esModule = true; | |
var _defineProperty = __webpack_require__(72); | |
var _defineProperty2 = _interopRequireDefault(_defineProperty); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
exports.default = function () { | |
function defineProperties(target, props) { | |
for (var i = 0; i < props.length; i++) { | |
var descriptor = props[i]; | |
descriptor.enumerable = descriptor.enumerable || false; | |
descriptor.configurable = true; | |
if ("value" in descriptor) descriptor.writable = true; | |
(0, _defineProperty2.default)(target, descriptor.key, descriptor); | |
} | |
} | |
return function (Constructor, protoProps, staticProps) { | |
if (protoProps) defineProperties(Constructor.prototype, protoProps); | |
if (staticProps) defineProperties(Constructor, staticProps); | |
return Constructor; | |
}; | |
}(); | |
/***/ }), | |
/* 76 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
exports.__esModule = true; | |
var _isIterable2 = __webpack_require__(69); | |
var _isIterable3 = _interopRequireDefault(_isIterable2); | |
var _getIterator2 = __webpack_require__(35); | |
var _getIterator3 = _interopRequireDefault(_getIterator2); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
exports.default = function () { | |
function sliceIterator(arr, i) { | |
var _arr = []; | |
var _n = true; | |
var _d = false; | |
var _e = undefined; | |
try { | |
for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { | |
_arr.push(_s.value); | |
if (i && _arr.length === i) break; | |
} | |
} catch (err) { | |
_d = true; | |
_e = err; | |
} finally { | |
try { | |
if (!_n && _i["return"]) _i["return"](); | |
} finally { | |
if (_d) throw _e; | |
} | |
} | |
return _arr; | |
} | |
return function (arr, i) { | |
if (Array.isArray(arr)) { | |
return arr; | |
} else if ((0, _isIterable3.default)(Object(arr))) { | |
return sliceIterator(arr, i); | |
} else { | |
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | |
} | |
}; | |
}(); | |
/***/ }), | |
/* 77 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
exports.__esModule = true; | |
var _from = __webpack_require__(68); | |
var _from2 = _interopRequireDefault(_from); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
exports.default = function (arr) { | |
if (Array.isArray(arr)) { | |
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { | |
arr2[i] = arr[i]; | |
} | |
return arr2; | |
} else { | |
return (0, _from2.default)(arr); | |
} | |
}; | |
/***/ }), | |
/* 78 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(19); | |
__webpack_require__(114); | |
module.exports = __webpack_require__(0).Array.from; | |
/***/ }), | |
/* 79 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(32); | |
__webpack_require__(19); | |
module.exports = __webpack_require__(112); | |
/***/ }), | |
/* 80 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(32); | |
__webpack_require__(19); | |
module.exports = __webpack_require__(113); | |
/***/ }), | |
/* 81 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var core = __webpack_require__(0) | |
, $JSON = core.JSON || (core.JSON = {stringify: JSON.stringify}); | |
module.exports = function stringify(it){ // eslint-disable-line no-unused-vars | |
return $JSON.stringify.apply($JSON, arguments); | |
}; | |
/***/ }), | |
/* 82 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(116); | |
module.exports = __webpack_require__(0).Object.assign; | |
/***/ }), | |
/* 83 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(117); | |
var $Object = __webpack_require__(0).Object; | |
module.exports = function create(P, D){ | |
return $Object.create(P, D); | |
}; | |
/***/ }), | |
/* 84 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(118); | |
var $Object = __webpack_require__(0).Object; | |
module.exports = function defineProperty(it, key, desc){ | |
return $Object.defineProperty(it, key, desc); | |
}; | |
/***/ }), | |
/* 85 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(122); | |
module.exports = __webpack_require__(0).Object.entries; | |
/***/ }), | |
/* 86 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(119); | |
module.exports = __webpack_require__(0).Object.keys; | |
/***/ }), | |
/* 87 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
__webpack_require__(120); | |
__webpack_require__(19); | |
__webpack_require__(32); | |
__webpack_require__(121); | |
module.exports = __webpack_require__(0).Promise; | |
/***/ }), | |
/* 88 */ | |
/***/ (function(module, exports) { | |
module.exports = function(){ /* empty */ }; | |
/***/ }), | |
/* 89 */ | |
/***/ (function(module, exports) { | |
module.exports = function(it, Constructor, name, forbiddenField){ | |
if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){ | |
throw TypeError(name + ': incorrect invocation!'); | |
} return it; | |
}; | |
/***/ }), | |
/* 90 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// false -> Array#indexOf | |
// true -> Array#includes | |
var toIObject = __webpack_require__(17) | |
, toLength = __webpack_require__(30) | |
, toIndex = __webpack_require__(110); | |
module.exports = function(IS_INCLUDES){ | |
return function($this, el, fromIndex){ | |
var O = toIObject($this) | |
, length = toLength(O.length) | |
, index = toIndex(fromIndex, length) | |
, value; | |
// Array#includes uses SameValueZero equality algorithm | |
if(IS_INCLUDES && el != el)while(length > index){ | |
value = O[index++]; | |
if(value != value)return true; | |
// Array#toIndex ignores holes, Array#includes - not | |
} else for(;length > index; index++)if(IS_INCLUDES || index in O){ | |
if(O[index] === el)return IS_INCLUDES || index || 0; | |
} return !IS_INCLUDES && -1; | |
}; | |
}; | |
/***/ }), | |
/* 91 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var $defineProperty = __webpack_require__(9) | |
, createDesc = __webpack_require__(26); | |
module.exports = function(object, index, value){ | |
if(index in object)$defineProperty.f(object, index, createDesc(0, value)); | |
else object[index] = value; | |
}; | |
/***/ }), | |
/* 92 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var ctx = __webpack_require__(10) | |
, call = __webpack_require__(40) | |
, isArrayIter = __webpack_require__(39) | |
, anObject = __webpack_require__(4) | |
, toLength = __webpack_require__(30) | |
, getIterFn = __webpack_require__(31) | |
, BREAK = {} | |
, RETURN = {}; | |
var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){ | |
var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable) | |
, f = ctx(fn, that, entries ? 2 : 1) | |
, index = 0 | |
, length, step, iterator, result; | |
if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!'); | |
// fast case for arrays with default iterator | |
if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){ | |
result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); | |
if(result === BREAK || result === RETURN)return result; | |
} else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){ | |
result = call(iterator, f, step.value, entries); | |
if(result === BREAK || result === RETURN)return result; | |
} | |
}; | |
exports.BREAK = BREAK; | |
exports.RETURN = RETURN; | |
/***/ }), | |
/* 93 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = !__webpack_require__(6) && !__webpack_require__(13)(function(){ | |
return Object.defineProperty(__webpack_require__(25)('div'), 'a', {get: function(){ return 7; }}).a != 7; | |
}); | |
/***/ }), | |
/* 94 */ | |
/***/ (function(module, exports) { | |
// fast apply, http://jsperf.lnkit.com/fast-apply/5 | |
module.exports = function(fn, args, that){ | |
var un = that === undefined; | |
switch(args.length){ | |
case 0: return un ? fn() | |
: fn.call(that); | |
case 1: return un ? fn(args[0]) | |
: fn.call(that, args[0]); | |
case 2: return un ? fn(args[0], args[1]) | |
: fn.call(that, args[0], args[1]); | |
case 3: return un ? fn(args[0], args[1], args[2]) | |
: fn.call(that, args[0], args[1], args[2]); | |
case 4: return un ? fn(args[0], args[1], args[2], args[3]) | |
: fn.call(that, args[0], args[1], args[2], args[3]); | |
} return fn.apply(that, args); | |
}; | |
/***/ }), | |
/* 95 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var create = __webpack_require__(44) | |
, descriptor = __webpack_require__(26) | |
, setToStringTag = __webpack_require__(27) | |
, IteratorPrototype = {}; | |
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() | |
__webpack_require__(7)(IteratorPrototype, __webpack_require__(1)('iterator'), function(){ return this; }); | |
module.exports = function(Constructor, NAME, next){ | |
Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)}); | |
setToStringTag(Constructor, NAME + ' Iterator'); | |
}; | |
/***/ }), | |
/* 96 */ | |
/***/ (function(module, exports) { | |
module.exports = function(done, value){ | |
return {value: value, done: !!done}; | |
}; | |
/***/ }), | |
/* 97 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var global = __webpack_require__(2) | |
, macrotask = __webpack_require__(47).set | |
, Observer = global.MutationObserver || global.WebKitMutationObserver | |
, process = global.process | |
, Promise = global.Promise | |
, isNode = __webpack_require__(12)(process) == 'process'; | |
module.exports = function(){ | |
var head, last, notify; | |
var flush = function(){ | |
var parent, fn; | |
if(isNode && (parent = process.domain))parent.exit(); | |
while(head){ | |
fn = head.fn; | |
head = head.next; | |
try { | |
fn(); | |
} catch(e){ | |
if(head)notify(); | |
else last = undefined; | |
throw e; | |
} | |
} last = undefined; | |
if(parent)parent.enter(); | |
}; | |
// Node.js | |
if(isNode){ | |
notify = function(){ | |
process.nextTick(flush); | |
}; | |
// browsers with MutationObserver | |
} else if(Observer){ | |
var toggle = true | |
, node = document.createTextNode(''); | |
new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new | |
notify = function(){ | |
node.data = toggle = !toggle; | |
}; | |
// environments with maybe non-completely correct, but existent Promise | |
} else if(Promise && Promise.resolve){ | |
var promise = Promise.resolve(); | |
notify = function(){ | |
promise.then(flush); | |
}; | |
// for other environments - macrotask based on: | |
// - setImmediate | |
// - MessageChannel | |
// - window.postMessag | |
// - onreadystatechange | |
// - setTimeout | |
} else { | |
notify = function(){ | |
// strange IE + webpack dev server bug - use .call(global) | |
macrotask.call(global, flush); | |
}; | |
} | |
return function(fn){ | |
var task = {fn: fn, next: undefined}; | |
if(last)last.next = task; | |
if(!head){ | |
head = task; | |
notify(); | |
} last = task; | |
}; | |
}; | |
/***/ }), | |
/* 98 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
// 19.1.2.1 Object.assign(target, source, ...) | |
var getKeys = __webpack_require__(16) | |
, gOPS = __webpack_require__(100) | |
, pIE = __webpack_require__(45) | |
, toObject = __webpack_require__(18) | |
, IObject = __webpack_require__(38) | |
, $assign = Object.assign; | |
// should work with symbols and should have deterministic property order (V8 bug) | |
module.exports = !$assign || __webpack_require__(13)(function(){ | |
var A = {} | |
, B = {} | |
, S = Symbol() | |
, K = 'abcdefghijklmnopqrst'; | |
A[S] = 7; | |
K.split('').forEach(function(k){ B[k] = k; }); | |
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; | |
}) ? function assign(target, source){ // eslint-disable-line no-unused-vars | |
var T = toObject(target) | |
, aLen = arguments.length | |
, index = 1 | |
, getSymbols = gOPS.f | |
, isEnum = pIE.f; | |
while(aLen > index){ | |
var S = IObject(arguments[index++]) | |
, keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) | |
, length = keys.length | |
, j = 0 | |
, key; | |
while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; | |
} return T; | |
} : $assign; | |
/***/ }), | |
/* 99 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var dP = __webpack_require__(9) | |
, anObject = __webpack_require__(4) | |
, getKeys = __webpack_require__(16); | |
module.exports = __webpack_require__(6) ? Object.defineProperties : function defineProperties(O, Properties){ | |
anObject(O); | |
var keys = getKeys(Properties) | |
, length = keys.length | |
, i = 0 | |
, P; | |
while(length > i)dP.f(O, P = keys[i++], Properties[P]); | |
return O; | |
}; | |
/***/ }), | |
/* 100 */ | |
/***/ (function(module, exports) { | |
exports.f = Object.getOwnPropertySymbols; | |
/***/ }), | |
/* 101 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) | |
var has = __webpack_require__(14) | |
, toObject = __webpack_require__(18) | |
, IE_PROTO = __webpack_require__(28)('IE_PROTO') | |
, ObjectProto = Object.prototype; | |
module.exports = Object.getPrototypeOf || function(O){ | |
O = toObject(O); | |
if(has(O, IE_PROTO))return O[IE_PROTO]; | |
if(typeof O.constructor == 'function' && O instanceof O.constructor){ | |
return O.constructor.prototype; | |
} return O instanceof Object ? ObjectProto : null; | |
}; | |
/***/ }), | |
/* 102 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var has = __webpack_require__(14) | |
, toIObject = __webpack_require__(17) | |
, arrayIndexOf = __webpack_require__(90)(false) | |
, IE_PROTO = __webpack_require__(28)('IE_PROTO'); | |
module.exports = function(object, names){ | |
var O = toIObject(object) | |
, i = 0 | |
, result = [] | |
, key; | |
for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key); | |
// Don't enum bug & hidden keys | |
while(names.length > i)if(has(O, key = names[i++])){ | |
~arrayIndexOf(result, key) || result.push(key); | |
} | |
return result; | |
}; | |
/***/ }), | |
/* 103 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// most Object methods by ES6 should accept primitives | |
var $export = __webpack_require__(3) | |
, core = __webpack_require__(0) | |
, fails = __webpack_require__(13); | |
module.exports = function(KEY, exec){ | |
var fn = (core.Object || {})[KEY] || Object[KEY] | |
, exp = {}; | |
exp[KEY] = exec(fn); | |
$export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp); | |
}; | |
/***/ }), | |
/* 104 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var getKeys = __webpack_require__(16) | |
, toIObject = __webpack_require__(17) | |
, isEnum = __webpack_require__(45).f; | |
module.exports = function(isEntries){ | |
return function(it){ | |
var O = toIObject(it) | |
, keys = getKeys(O) | |
, length = keys.length | |
, i = 0 | |
, result = [] | |
, key; | |
while(length > i)if(isEnum.call(O, key = keys[i++])){ | |
result.push(isEntries ? [key, O[key]] : O[key]); | |
} return result; | |
}; | |
}; | |
/***/ }), | |
/* 105 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var hide = __webpack_require__(7); | |
module.exports = function(target, src, safe){ | |
for(var key in src){ | |
if(safe && target[key])target[key] = src[key]; | |
else hide(target, key, src[key]); | |
} return target; | |
}; | |
/***/ }), | |
/* 106 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = __webpack_require__(7); | |
/***/ }), | |
/* 107 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var global = __webpack_require__(2) | |
, core = __webpack_require__(0) | |
, dP = __webpack_require__(9) | |
, DESCRIPTORS = __webpack_require__(6) | |
, SPECIES = __webpack_require__(1)('species'); | |
module.exports = function(KEY){ | |
var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY]; | |
if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, { | |
configurable: true, | |
get: function(){ return this; } | |
}); | |
}; | |
/***/ }), | |
/* 108 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 7.3.20 SpeciesConstructor(O, defaultConstructor) | |
var anObject = __webpack_require__(4) | |
, aFunction = __webpack_require__(22) | |
, SPECIES = __webpack_require__(1)('species'); | |
module.exports = function(O, D){ | |
var C = anObject(O).constructor, S; | |
return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); | |
}; | |
/***/ }), | |
/* 109 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var toInteger = __webpack_require__(29) | |
, defined = __webpack_require__(24); | |
// true -> String#at | |
// false -> String#codePointAt | |
module.exports = function(TO_STRING){ | |
return function(that, pos){ | |
var s = String(defined(that)) | |
, i = toInteger(pos) | |
, l = s.length | |
, a, b; | |
if(i < 0 || i >= l)return TO_STRING ? '' : undefined; | |
a = s.charCodeAt(i); | |
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff | |
? TO_STRING ? s.charAt(i) : a | |
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; | |
}; | |
}; | |
/***/ }), | |
/* 110 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var toInteger = __webpack_require__(29) | |
, max = Math.max | |
, min = Math.min; | |
module.exports = function(index, length){ | |
index = toInteger(index); | |
return index < 0 ? max(index + length, 0) : min(index, length); | |
}; | |
/***/ }), | |
/* 111 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 7.1.1 ToPrimitive(input [, PreferredType]) | |
var isObject = __webpack_require__(15); | |
// instead of the ES6 spec version, we didn't implement @@toPrimitive case | |
// and the second argument - flag - preferred type is a string | |
module.exports = function(it, S){ | |
if(!isObject(it))return it; | |
var fn, val; | |
if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; | |
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val; | |
if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; | |
throw TypeError("Can't convert object to primitive value"); | |
}; | |
/***/ }), | |
/* 112 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var anObject = __webpack_require__(4) | |
, get = __webpack_require__(31); | |
module.exports = __webpack_require__(0).getIterator = function(it){ | |
var iterFn = get(it); | |
if(typeof iterFn != 'function')throw TypeError(it + ' is not iterable!'); | |
return anObject(iterFn.call(it)); | |
}; | |
/***/ }), | |
/* 113 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var classof = __webpack_require__(23) | |
, ITERATOR = __webpack_require__(1)('iterator') | |
, Iterators = __webpack_require__(8); | |
module.exports = __webpack_require__(0).isIterable = function(it){ | |
var O = Object(it); | |
return O[ITERATOR] !== undefined | |
|| '@@iterator' in O | |
|| Iterators.hasOwnProperty(classof(O)); | |
}; | |
/***/ }), | |
/* 114 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var ctx = __webpack_require__(10) | |
, $export = __webpack_require__(3) | |
, toObject = __webpack_require__(18) | |
, call = __webpack_require__(40) | |
, isArrayIter = __webpack_require__(39) | |
, toLength = __webpack_require__(30) | |
, createProperty = __webpack_require__(91) | |
, getIterFn = __webpack_require__(31); | |
$export($export.S + $export.F * !__webpack_require__(42)(function(iter){ Array.from(iter); }), 'Array', { | |
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) | |
from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ | |
var O = toObject(arrayLike) | |
, C = typeof this == 'function' ? this : Array | |
, aLen = arguments.length | |
, mapfn = aLen > 1 ? arguments[1] : undefined | |
, mapping = mapfn !== undefined | |
, index = 0 | |
, iterFn = getIterFn(O) | |
, length, result, step, iterator; | |
if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); | |
// if object isn't iterable or it's array with default iterator - use simple case | |
if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ | |
for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ | |
createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value); | |
} | |
} else { | |
length = toLength(O.length); | |
for(result = new C(length); length > index; index++){ | |
createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); | |
} | |
} | |
result.length = index; | |
return result; | |
} | |
}); | |
/***/ }), | |
/* 115 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var addToUnscopables = __webpack_require__(88) | |
, step = __webpack_require__(96) | |
, Iterators = __webpack_require__(8) | |
, toIObject = __webpack_require__(17); | |
// 22.1.3.4 Array.prototype.entries() | |
// 22.1.3.13 Array.prototype.keys() | |
// 22.1.3.29 Array.prototype.values() | |
// 22.1.3.30 Array.prototype[@@iterator]() | |
module.exports = __webpack_require__(41)(Array, 'Array', function(iterated, kind){ | |
this._t = toIObject(iterated); // target | |
this._i = 0; // next index | |
this._k = kind; // kind | |
// 22.1.5.2.1 %ArrayIteratorPrototype%.next() | |
}, function(){ | |
var O = this._t | |
, kind = this._k | |
, index = this._i++; | |
if(!O || index >= O.length){ | |
this._t = undefined; | |
return step(1); | |
} | |
if(kind == 'keys' )return step(0, index); | |
if(kind == 'values')return step(0, O[index]); | |
return step(0, [index, O[index]]); | |
}, 'values'); | |
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) | |
Iterators.Arguments = Iterators.Array; | |
addToUnscopables('keys'); | |
addToUnscopables('values'); | |
addToUnscopables('entries'); | |
/***/ }), | |
/* 116 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 19.1.3.1 Object.assign(target, source) | |
var $export = __webpack_require__(3); | |
$export($export.S + $export.F, 'Object', {assign: __webpack_require__(98)}); | |
/***/ }), | |
/* 117 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var $export = __webpack_require__(3) | |
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) | |
$export($export.S, 'Object', {create: __webpack_require__(44)}); | |
/***/ }), | |
/* 118 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
var $export = __webpack_require__(3); | |
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) | |
$export($export.S + $export.F * !__webpack_require__(6), 'Object', {defineProperty: __webpack_require__(9).f}); | |
/***/ }), | |
/* 119 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// 19.1.2.14 Object.keys(O) | |
var toObject = __webpack_require__(18) | |
, $keys = __webpack_require__(16); | |
__webpack_require__(103)('keys', function(){ | |
return function keys(it){ | |
return $keys(toObject(it)); | |
}; | |
}); | |
/***/ }), | |
/* 120 */ | |
/***/ (function(module, exports) { | |
/***/ }), | |
/* 121 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var LIBRARY = __webpack_require__(43) | |
, global = __webpack_require__(2) | |
, ctx = __webpack_require__(10) | |
, classof = __webpack_require__(23) | |
, $export = __webpack_require__(3) | |
, isObject = __webpack_require__(15) | |
, aFunction = __webpack_require__(22) | |
, anInstance = __webpack_require__(89) | |
, forOf = __webpack_require__(92) | |
, speciesConstructor = __webpack_require__(108) | |
, task = __webpack_require__(47).set | |
, microtask = __webpack_require__(97)() | |
, PROMISE = 'Promise' | |
, TypeError = global.TypeError | |
, process = global.process | |
, $Promise = global[PROMISE] | |
, process = global.process | |
, isNode = classof(process) == 'process' | |
, empty = function(){ /* empty */ } | |
, Internal, GenericPromiseCapability, Wrapper; | |
var USE_NATIVE = !!function(){ | |
try { | |
// correct subclassing with @@species support | |
var promise = $Promise.resolve(1) | |
, FakePromise = (promise.constructor = {})[__webpack_require__(1)('species')] = function(exec){ exec(empty, empty); }; | |
// unhandled rejections tracking support, NodeJS Promise without it fails @@species test | |
return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise; | |
} catch(e){ /* empty */ } | |
}(); | |
// helpers | |
var sameConstructor = function(a, b){ | |
// with library wrapper special case | |
return a === b || a === $Promise && b === Wrapper; | |
}; | |
var isThenable = function(it){ | |
var then; | |
return isObject(it) && typeof (then = it.then) == 'function' ? then : false; | |
}; | |
var newPromiseCapability = function(C){ | |
return sameConstructor($Promise, C) | |
? new PromiseCapability(C) | |
: new GenericPromiseCapability(C); | |
}; | |
var PromiseCapability = GenericPromiseCapability = function(C){ | |
var resolve, reject; | |
this.promise = new C(function($$resolve, $$reject){ | |
if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor'); | |
resolve = $$resolve; | |
reject = $$reject; | |
}); | |
this.resolve = aFunction(resolve); | |
this.reject = aFunction(reject); | |
}; | |
var perform = function(exec){ | |
try { | |
exec(); | |
} catch(e){ | |
return {error: e}; | |
} | |
}; | |
var notify = function(promise, isReject){ | |
if(promise._n)return; | |
promise._n = true; | |
var chain = promise._c; | |
microtask(function(){ | |
var value = promise._v | |
, ok = promise._s == 1 | |
, i = 0; | |
var run = function(reaction){ | |
var handler = ok ? reaction.ok : reaction.fail | |
, resolve = reaction.resolve | |
, reject = reaction.reject | |
, domain = reaction.domain | |
, result, then; | |
try { | |
if(handler){ | |
if(!ok){ | |
if(promise._h == 2)onHandleUnhandled(promise); | |
promise._h = 1; | |
} | |
if(handler === true)result = value; | |
else { | |
if(domain)domain.enter(); | |
result = handler(value); | |
if(domain)domain.exit(); | |
} | |
if(result === reaction.promise){ | |
reject(TypeError('Promise-chain cycle')); | |
} else if(then = isThenable(result)){ | |
then.call(result, resolve, reject); | |
} else resolve(result); | |
} else reject(value); | |
} catch(e){ | |
reject(e); | |
} | |
}; | |
while(chain.length > i)run(chain[i++]); // variable length - can't use forEach | |
promise._c = []; | |
promise._n = false; | |
if(isReject && !promise._h)onUnhandled(promise); | |
}); | |
}; | |
var onUnhandled = function(promise){ | |
task.call(global, function(){ | |
var value = promise._v | |
, abrupt, handler, console; | |
if(isUnhandled(promise)){ | |
abrupt = perform(function(){ | |
if(isNode){ | |
process.emit('unhandledRejection', value, promise); | |
} else if(handler = global.onunhandledrejection){ | |
handler({promise: promise, reason: value}); | |
} else if((console = global.console) && console.error){ | |
console.error('Unhandled promise rejection', value); | |
} | |
}); | |
// Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should | |
promise._h = isNode || isUnhandled(promise) ? 2 : 1; | |
} promise._a = undefined; | |
if(abrupt)throw abrupt.error; | |
}); | |
}; | |
var isUnhandled = function(promise){ | |
if(promise._h == 1)return false; | |
var chain = promise._a || promise._c | |
, i = 0 | |
, reaction; | |
while(chain.length > i){ | |
reaction = chain[i++]; | |
if(reaction.fail || !isUnhandled(reaction.promise))return false; | |
} return true; | |
}; | |
var onHandleUnhandled = function(promise){ | |
task.call(global, function(){ | |
var handler; | |
if(isNode){ | |
process.emit('rejectionHandled', promise); | |
} else if(handler = global.onrejectionhandled){ | |
handler({promise: promise, reason: promise._v}); | |
} | |
}); | |
}; | |
var $reject = function(value){ | |
var promise = this; | |
if(promise._d)return; | |
promise._d = true; | |
promise = promise._w || promise; // unwrap | |
promise._v = value; | |
promise._s = 2; | |
if(!promise._a)promise._a = promise._c.slice(); | |
notify(promise, true); | |
}; | |
var $resolve = function(value){ | |
var promise = this | |
, then; | |
if(promise._d)return; | |
promise._d = true; | |
promise = promise._w || promise; // unwrap | |
try { | |
if(promise === value)throw TypeError("Promise can't be resolved itself"); | |
if(then = isThenable(value)){ | |
microtask(function(){ | |
var wrapper = {_w: promise, _d: false}; // wrap | |
try { | |
then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); | |
} catch(e){ | |
$reject.call(wrapper, e); | |
} | |
}); | |
} else { | |
promise._v = value; | |
promise._s = 1; | |
notify(promise, false); | |
} | |
} catch(e){ | |
$reject.call({_w: promise, _d: false}, e); // wrap | |
} | |
}; | |
// constructor polyfill | |
if(!USE_NATIVE){ | |
// 25.4.3.1 Promise(executor) | |
$Promise = function Promise(executor){ | |
anInstance(this, $Promise, PROMISE, '_h'); | |
aFunction(executor); | |
Internal.call(this); | |
try { | |
executor(ctx($resolve, this, 1), ctx($reject, this, 1)); | |
} catch(err){ | |
$reject.call(this, err); | |
} | |
}; | |
Internal = function Promise(executor){ | |
this._c = []; // <- awaiting reactions | |
this._a = undefined; // <- checked in isUnhandled reactions | |
this._s = 0; // <- state | |
this._d = false; // <- done | |
this._v = undefined; // <- value | |
this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled | |
this._n = false; // <- notify | |
}; | |
Internal.prototype = __webpack_require__(105)($Promise.prototype, { | |
// 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) | |
then: function then(onFulfilled, onRejected){ | |
var reaction = newPromiseCapability(speciesConstructor(this, $Promise)); | |
reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; | |
reaction.fail = typeof onRejected == 'function' && onRejected; | |
reaction.domain = isNode ? process.domain : undefined; | |
this._c.push(reaction); | |
if(this._a)this._a.push(reaction); | |
if(this._s)notify(this, false); | |
return reaction.promise; | |
}, | |
// 25.4.5.1 Promise.prototype.catch(onRejected) | |
'catch': function(onRejected){ | |
return this.then(undefined, onRejected); | |
} | |
}); | |
PromiseCapability = function(){ | |
var promise = new Internal; | |
this.promise = promise; | |
this.resolve = ctx($resolve, promise, 1); | |
this.reject = ctx($reject, promise, 1); | |
}; | |
} | |
$export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise}); | |
__webpack_require__(27)($Promise, PROMISE); | |
__webpack_require__(107)(PROMISE); | |
Wrapper = __webpack_require__(0)[PROMISE]; | |
// statics | |
$export($export.S + $export.F * !USE_NATIVE, PROMISE, { | |
// 25.4.4.5 Promise.reject(r) | |
reject: function reject(r){ | |
var capability = newPromiseCapability(this) | |
, $$reject = capability.reject; | |
$$reject(r); | |
return capability.promise; | |
} | |
}); | |
$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { | |
// 25.4.4.6 Promise.resolve(x) | |
resolve: function resolve(x){ | |
// instanceof instead of internal slot check because we should fix it without replacement native Promise core | |
if(x instanceof $Promise && sameConstructor(x.constructor, this))return x; | |
var capability = newPromiseCapability(this) | |
, $$resolve = capability.resolve; | |
$$resolve(x); | |
return capability.promise; | |
} | |
}); | |
$export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(42)(function(iter){ | |
$Promise.all(iter)['catch'](empty); | |
})), PROMISE, { | |
// 25.4.4.1 Promise.all(iterable) | |
all: function all(iterable){ | |
var C = this | |
, capability = newPromiseCapability(C) | |
, resolve = capability.resolve | |
, reject = capability.reject; | |
var abrupt = perform(function(){ | |
var values = [] | |
, index = 0 | |
, remaining = 1; | |
forOf(iterable, false, function(promise){ | |
var $index = index++ | |
, alreadyCalled = false; | |
values.push(undefined); | |
remaining++; | |
C.resolve(promise).then(function(value){ | |
if(alreadyCalled)return; | |
alreadyCalled = true; | |
values[$index] = value; | |
--remaining || resolve(values); | |
}, reject); | |
}); | |
--remaining || resolve(values); | |
}); | |
if(abrupt)reject(abrupt.error); | |
return capability.promise; | |
}, | |
// 25.4.4.4 Promise.race(iterable) | |
race: function race(iterable){ | |
var C = this | |
, capability = newPromiseCapability(C) | |
, reject = capability.reject; | |
var abrupt = perform(function(){ | |
forOf(iterable, false, function(promise){ | |
C.resolve(promise).then(capability.resolve, reject); | |
}); | |
}); | |
if(abrupt)reject(abrupt.error); | |
return capability.promise; | |
} | |
}); | |
/***/ }), | |
/* 122 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
// https://github.com/tc39/proposal-object-values-entries | |
var $export = __webpack_require__(3) | |
, $entries = __webpack_require__(104)(true); | |
$export($export.S, 'Object', { | |
entries: function entries(it){ | |
return $entries(it); | |
} | |
}); | |
/***/ }), | |
/* 123 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/** | |
* Copyright (c) 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
*/ | |
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); | |
/** | |
* Simple, lightweight module assisting with the detection and context of | |
* Worker. Helps avoid circular dependencies and allows code to reason about | |
* whether or not they are in a Worker, even if they never include the main | |
* `ReactWorker` dependency. | |
*/ | |
var ExecutionEnvironment = { | |
canUseDOM: canUseDOM, | |
canUseWorkers: typeof Worker !== 'undefined', | |
canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), | |
canUseViewport: canUseDOM && !!window.screen, | |
isInWorker: !canUseDOM // For now, this is true - might change in the future. | |
}; | |
module.exports = ExecutionEnvironment; | |
/***/ }), | |
/* 124 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
exports = module.exports = __webpack_require__(125)['default']; | |
exports['default'] = exports; | |
/***/ }), | |
/* 125 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
exports["default"] = (function() { | |
/* | |
* Generated by PEG.js 0.8.0. | |
* | |
* http://pegjs.majda.cz/ | |
*/ | |
function peg$subclass(child, parent) { | |
function ctor() { this.constructor = child; } | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor(); | |
} | |
function SyntaxError(message, expected, found, offset, line, column) { | |
this.message = message; | |
this.expected = expected; | |
this.found = found; | |
this.offset = offset; | |
this.line = line; | |
this.column = column; | |
this.name = "SyntaxError"; | |
} | |
peg$subclass(SyntaxError, Error); | |
function parse(input) { | |
var options = arguments.length > 1 ? arguments[1] : {}, | |
peg$FAILED = {}, | |
peg$startRuleFunctions = { start: peg$parsestart }, | |
peg$startRuleFunction = peg$parsestart, | |
peg$c0 = [], | |
peg$c1 = function(elements) { | |
return { | |
type : 'messageFormatPattern', | |
elements: elements | |
}; | |
}, | |
peg$c2 = peg$FAILED, | |
peg$c3 = function(text) { | |
var string = '', | |
i, j, outerLen, inner, innerLen; | |
for (i = 0, outerLen = text.length; i < outerLen; i += 1) { | |
inner = text[i]; | |
for (j = 0, innerLen = inner.length; j < innerLen; j += 1) { | |
string += inner[j]; | |
} | |
} | |
return string; | |
}, | |
peg$c4 = function(messageText) { | |
return { | |
type : 'messageTextElement', | |
value: messageText | |
}; | |
}, | |
peg$c5 = /^[^ \t\n\r,.+={}#]/, | |
peg$c6 = { type: "class", value: "[^ \\t\\n\\r,.+={}#]", description: "[^ \\t\\n\\r,.+={}#]" }, | |
peg$c7 = "{", | |
peg$c8 = { type: "literal", value: "{", description: "\"{\"" }, | |
peg$c9 = null, | |
peg$c10 = ",", | |
peg$c11 = { type: "literal", value: ",", description: "\",\"" }, | |
peg$c12 = "}", | |
peg$c13 = { type: "literal", value: "}", description: "\"}\"" }, | |
peg$c14 = function(id, format) { | |
return { | |
type : 'argumentElement', | |
id : id, | |
format: format && format[2] | |
}; | |
}, | |
peg$c15 = "number", | |
peg$c16 = { type: "literal", value: "number", description: "\"number\"" }, | |
peg$c17 = "date", | |
peg$c18 = { type: "literal", value: "date", description: "\"date\"" }, | |
peg$c19 = "time", | |
peg$c20 = { type: "literal", value: "time", description: "\"time\"" }, | |
peg$c21 = function(type, style) { | |
return { | |
type : type + 'Format', | |
style: style && style[2] | |
}; | |
}, | |
peg$c22 = "plural", | |
peg$c23 = { type: "literal", value: "plural", description: "\"plural\"" }, | |
peg$c24 = function(pluralStyle) { | |
return { | |
type : pluralStyle.type, | |
ordinal: false, | |
offset : pluralStyle.offset || 0, | |
options: pluralStyle.options | |
}; | |
}, | |
peg$c25 = "selectordinal", | |
peg$c26 = { type: "literal", value: "selectordinal", description: "\"selectordinal\"" }, | |
peg$c27 = function(pluralStyle) { | |
return { | |
type : pluralStyle.type, | |
ordinal: true, | |
offset : pluralStyle.offset || 0, | |
options: pluralStyle.options | |
} | |
}, | |
peg$c28 = "select", | |
peg$c29 = { type: "literal", value: "select", description: "\"select\"" }, | |
peg$c30 = function(options) { | |
return { | |
type : 'selectFormat', | |
options: options | |
}; | |
}, | |
peg$c31 = "=", | |
peg$c32 = { type: "literal", value: "=", description: "\"=\"" }, | |
peg$c33 = function(selector, pattern) { | |
return { | |
type : 'optionalFormatPattern', | |
selector: selector, | |
value : pattern | |
}; | |
}, | |
peg$c34 = "offset:", | |
peg$c35 = { type: "literal", value: "offset:", description: "\"offset:\"" }, | |
peg$c36 = function(number) { | |
return number; | |
}, | |
peg$c37 = function(offset, options) { | |
return { | |
type : 'pluralFormat', | |
offset : offset, | |
options: options | |
}; | |
}, | |
peg$c38 = { type: "other", description: "whitespace" }, | |
peg$c39 = /^[ \t\n\r]/, | |
peg$c40 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" }, | |
peg$c41 = { type: "other", description: "optionalWhitespace" }, | |
peg$c42 = /^[0-9]/, | |
peg$c43 = { type: "class", value: "[0-9]", description: "[0-9]" }, | |
peg$c44 = /^[0-9a-f]/i, | |
peg$c45 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" }, | |
peg$c46 = "0", | |
peg$c47 = { type: "literal", value: "0", description: "\"0\"" }, | |
peg$c48 = /^[1-9]/, | |
peg$c49 = { type: "class", value: "[1-9]", description: "[1-9]" }, | |
peg$c50 = function(digits) { | |
return parseInt(digits, 10); | |
}, | |
peg$c51 = /^[^{}\\\0-\x1F \t\n\r]/, | |
peg$c52 = { type: "class", value: "[^{}\\\\\\0-\\x1F \\t\\n\\r]", description: "[^{}\\\\\\0-\\x1F \\t\\n\\r]" }, | |
peg$c53 = "\\\\", | |
peg$c54 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" }, | |
peg$c55 = function() { return '\\'; }, | |
peg$c56 = "\\#", | |
peg$c57 = { type: "literal", value: "\\#", description: "\"\\\\#\"" }, | |
peg$c58 = function() { return '\\#'; }, | |
peg$c59 = "\\{", | |
peg$c60 = { type: "literal", value: "\\{", description: "\"\\\\{\"" }, | |
peg$c61 = function() { return '\u007B'; }, | |
peg$c62 = "\\}", | |
peg$c63 = { type: "literal", value: "\\}", description: "\"\\\\}\"" }, | |
peg$c64 = function() { return '\u007D'; }, | |
peg$c65 = "\\u", | |
peg$c66 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, | |
peg$c67 = function(digits) { | |
return String.fromCharCode(parseInt(digits, 16)); | |
}, | |
peg$c68 = function(chars) { return chars.join(''); }, | |
peg$currPos = 0, | |
peg$reportedPos = 0, | |
peg$cachedPos = 0, | |
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, | |
peg$maxFailPos = 0, | |
peg$maxFailExpected = [], | |
peg$silentFails = 0, | |
peg$result; | |
if ("startRule" in options) { | |
if (!(options.startRule in peg$startRuleFunctions)) { | |
throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); | |
} | |
peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; | |
} | |
function text() { | |
return input.substring(peg$reportedPos, peg$currPos); | |
} | |
function offset() { | |
return peg$reportedPos; | |
} | |
function line() { | |
return peg$computePosDetails(peg$reportedPos).line; | |
} | |
function column() { | |
return peg$computePosDetails(peg$reportedPos).column; | |
} | |
function expected(description) { | |
throw peg$buildException( | |
null, | |
[{ type: "other", description: description }], | |
peg$reportedPos | |
); | |
} | |
function error(message) { | |
throw peg$buildException(message, null, peg$reportedPos); | |
} | |
function peg$computePosDetails(pos) { | |
function advance(details, startPos, endPos) { | |
var p, ch; | |
for (p = startPos; p < endPos; p++) { | |
ch = input.charAt(p); | |
if (ch === "\n") { | |
if (!details.seenCR) { details.line++; } | |
details.column = 1; | |
details.seenCR = false; | |
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { | |
details.line++; | |
details.column = 1; | |
details.seenCR = true; | |
} else { | |
details.column++; | |
details.seenCR = false; | |
} | |
} | |
} | |
if (peg$cachedPos !== pos) { | |
if (peg$cachedPos > pos) { | |
peg$cachedPos = 0; | |
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; | |
} | |
advance(peg$cachedPosDetails, peg$cachedPos, pos); | |
peg$cachedPos = pos; | |
} | |
return peg$cachedPosDetails; | |
} | |
function peg$fail(expected) { | |
if (peg$currPos < peg$maxFailPos) { return; } | |
if (peg$currPos > peg$maxFailPos) { | |
peg$maxFailPos = peg$currPos; | |
peg$maxFailExpected = []; | |
} | |
peg$maxFailExpected.push(expected); | |
} | |
function peg$buildException(message, expected, pos) { | |
function cleanupExpected(expected) { | |
var i = 1; | |
expected.sort(function(a, b) { | |
if (a.description < b.description) { | |
return -1; | |
} else if (a.description > b.description) { | |
return 1; | |
} else { | |
return 0; | |
} | |
}); | |
while (i < expected.length) { | |
if (expected[i - 1] === expected[i]) { | |
expected.splice(i, 1); | |
} else { | |
i++; | |
} | |
} | |
} | |
function buildMessage(expected, found) { | |
function stringEscape(s) { | |
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } | |
return s | |
.replace(/\\/g, '\\\\') | |
.replace(/"/g, '\\"') | |
.replace(/\x08/g, '\\b') | |
.replace(/\t/g, '\\t') | |
.replace(/\n/g, '\\n') | |
.replace(/\f/g, '\\f') | |
.replace(/\r/g, '\\r') | |
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) | |
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) | |
.replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) | |
.replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); | |
} | |
var expectedDescs = new Array(expected.length), | |
expectedDesc, foundDesc, i; | |
for (i = 0; i < expected.length; i++) { | |
expectedDescs[i] = expected[i].description; | |
} | |
expectedDesc = expected.length > 1 | |
? expectedDescs.slice(0, -1).join(", ") | |
+ " or " | |
+ expectedDescs[expected.length - 1] | |
: expectedDescs[0]; | |
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; | |
return "Expected " + expectedDesc + " but " + foundDesc + " found."; | |
} | |
var posDetails = peg$computePosDetails(pos), | |
found = pos < input.length ? input.charAt(pos) : null; | |
if (expected !== null) { | |
cleanupExpected(expected); | |
} | |
return new SyntaxError( | |
message !== null ? message : buildMessage(expected, found), | |
expected, | |
found, | |
pos, | |
posDetails.line, | |
posDetails.column | |
); | |
} | |
function peg$parsestart() { | |
var s0; | |
s0 = peg$parsemessageFormatPattern(); | |
return s0; | |
} | |
function peg$parsemessageFormatPattern() { | |
var s0, s1, s2; | |
s0 = peg$currPos; | |
s1 = []; | |
s2 = peg$parsemessageFormatElement(); | |
while (s2 !== peg$FAILED) { | |
s1.push(s2); | |
s2 = peg$parsemessageFormatElement(); | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c1(s1); | |
} | |
s0 = s1; | |
return s0; | |
} | |
function peg$parsemessageFormatElement() { | |
var s0; | |
s0 = peg$parsemessageTextElement(); | |
if (s0 === peg$FAILED) { | |
s0 = peg$parseargumentElement(); | |
} | |
return s0; | |
} | |
function peg$parsemessageText() { | |
var s0, s1, s2, s3, s4, s5; | |
s0 = peg$currPos; | |
s1 = []; | |
s2 = peg$currPos; | |
s3 = peg$parse_(); | |
if (s3 !== peg$FAILED) { | |
s4 = peg$parsechars(); | |
if (s4 !== peg$FAILED) { | |
s5 = peg$parse_(); | |
if (s5 !== peg$FAILED) { | |
s3 = [s3, s4, s5]; | |
s2 = s3; | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
if (s2 !== peg$FAILED) { | |
while (s2 !== peg$FAILED) { | |
s1.push(s2); | |
s2 = peg$currPos; | |
s3 = peg$parse_(); | |
if (s3 !== peg$FAILED) { | |
s4 = peg$parsechars(); | |
if (s4 !== peg$FAILED) { | |
s5 = peg$parse_(); | |
if (s5 !== peg$FAILED) { | |
s3 = [s3, s4, s5]; | |
s2 = s3; | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
} | |
} else { | |
s1 = peg$c2; | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c3(s1); | |
} | |
s0 = s1; | |
if (s0 === peg$FAILED) { | |
s0 = peg$currPos; | |
s1 = peg$parsews(); | |
if (s1 !== peg$FAILED) { | |
s1 = input.substring(s0, peg$currPos); | |
} | |
s0 = s1; | |
} | |
return s0; | |
} | |
function peg$parsemessageTextElement() { | |
var s0, s1; | |
s0 = peg$currPos; | |
s1 = peg$parsemessageText(); | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c4(s1); | |
} | |
s0 = s1; | |
return s0; | |
} | |
function peg$parseargument() { | |
var s0, s1, s2; | |
s0 = peg$parsenumber(); | |
if (s0 === peg$FAILED) { | |
s0 = peg$currPos; | |
s1 = []; | |
if (peg$c5.test(input.charAt(peg$currPos))) { | |
s2 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s2 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c6); } | |
} | |
if (s2 !== peg$FAILED) { | |
while (s2 !== peg$FAILED) { | |
s1.push(s2); | |
if (peg$c5.test(input.charAt(peg$currPos))) { | |
s2 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s2 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c6); } | |
} | |
} | |
} else { | |
s1 = peg$c2; | |
} | |
if (s1 !== peg$FAILED) { | |
s1 = input.substring(s0, peg$currPos); | |
} | |
s0 = s1; | |
} | |
return s0; | |
} | |
function peg$parseargumentElement() { | |
var s0, s1, s2, s3, s4, s5, s6, s7, s8; | |
s0 = peg$currPos; | |
if (input.charCodeAt(peg$currPos) === 123) { | |
s1 = peg$c7; | |
peg$currPos++; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c8); } | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parse_(); | |
if (s2 !== peg$FAILED) { | |
s3 = peg$parseargument(); | |
if (s3 !== peg$FAILED) { | |
s4 = peg$parse_(); | |
if (s4 !== peg$FAILED) { | |
s5 = peg$currPos; | |
if (input.charCodeAt(peg$currPos) === 44) { | |
s6 = peg$c10; | |
peg$currPos++; | |
} else { | |
s6 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c11); } | |
} | |
if (s6 !== peg$FAILED) { | |
s7 = peg$parse_(); | |
if (s7 !== peg$FAILED) { | |
s8 = peg$parseelementFormat(); | |
if (s8 !== peg$FAILED) { | |
s6 = [s6, s7, s8]; | |
s5 = s6; | |
} else { | |
peg$currPos = s5; | |
s5 = peg$c2; | |
} | |
} else { | |
peg$currPos = s5; | |
s5 = peg$c2; | |
} | |
} else { | |
peg$currPos = s5; | |
s5 = peg$c2; | |
} | |
if (s5 === peg$FAILED) { | |
s5 = peg$c9; | |
} | |
if (s5 !== peg$FAILED) { | |
s6 = peg$parse_(); | |
if (s6 !== peg$FAILED) { | |
if (input.charCodeAt(peg$currPos) === 125) { | |
s7 = peg$c12; | |
peg$currPos++; | |
} else { | |
s7 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c13); } | |
} | |
if (s7 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c14(s3, s5); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parseelementFormat() { | |
var s0; | |
s0 = peg$parsesimpleFormat(); | |
if (s0 === peg$FAILED) { | |
s0 = peg$parsepluralFormat(); | |
if (s0 === peg$FAILED) { | |
s0 = peg$parseselectOrdinalFormat(); | |
if (s0 === peg$FAILED) { | |
s0 = peg$parseselectFormat(); | |
} | |
} | |
} | |
return s0; | |
} | |
function peg$parsesimpleFormat() { | |
var s0, s1, s2, s3, s4, s5, s6; | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 6) === peg$c15) { | |
s1 = peg$c15; | |
peg$currPos += 6; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c16); } | |
} | |
if (s1 === peg$FAILED) { | |
if (input.substr(peg$currPos, 4) === peg$c17) { | |
s1 = peg$c17; | |
peg$currPos += 4; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c18); } | |
} | |
if (s1 === peg$FAILED) { | |
if (input.substr(peg$currPos, 4) === peg$c19) { | |
s1 = peg$c19; | |
peg$currPos += 4; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c20); } | |
} | |
} | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parse_(); | |
if (s2 !== peg$FAILED) { | |
s3 = peg$currPos; | |
if (input.charCodeAt(peg$currPos) === 44) { | |
s4 = peg$c10; | |
peg$currPos++; | |
} else { | |
s4 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c11); } | |
} | |
if (s4 !== peg$FAILED) { | |
s5 = peg$parse_(); | |
if (s5 !== peg$FAILED) { | |
s6 = peg$parsechars(); | |
if (s6 !== peg$FAILED) { | |
s4 = [s4, s5, s6]; | |
s3 = s4; | |
} else { | |
peg$currPos = s3; | |
s3 = peg$c2; | |
} | |
} else { | |
peg$currPos = s3; | |
s3 = peg$c2; | |
} | |
} else { | |
peg$currPos = s3; | |
s3 = peg$c2; | |
} | |
if (s3 === peg$FAILED) { | |
s3 = peg$c9; | |
} | |
if (s3 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c21(s1, s3); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parsepluralFormat() { | |
var s0, s1, s2, s3, s4, s5; | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 6) === peg$c22) { | |
s1 = peg$c22; | |
peg$currPos += 6; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c23); } | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parse_(); | |
if (s2 !== peg$FAILED) { | |
if (input.charCodeAt(peg$currPos) === 44) { | |
s3 = peg$c10; | |
peg$currPos++; | |
} else { | |
s3 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c11); } | |
} | |
if (s3 !== peg$FAILED) { | |
s4 = peg$parse_(); | |
if (s4 !== peg$FAILED) { | |
s5 = peg$parsepluralStyle(); | |
if (s5 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c24(s5); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parseselectOrdinalFormat() { | |
var s0, s1, s2, s3, s4, s5; | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 13) === peg$c25) { | |
s1 = peg$c25; | |
peg$currPos += 13; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c26); } | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parse_(); | |
if (s2 !== peg$FAILED) { | |
if (input.charCodeAt(peg$currPos) === 44) { | |
s3 = peg$c10; | |
peg$currPos++; | |
} else { | |
s3 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c11); } | |
} | |
if (s3 !== peg$FAILED) { | |
s4 = peg$parse_(); | |
if (s4 !== peg$FAILED) { | |
s5 = peg$parsepluralStyle(); | |
if (s5 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c27(s5); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parseselectFormat() { | |
var s0, s1, s2, s3, s4, s5, s6; | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 6) === peg$c28) { | |
s1 = peg$c28; | |
peg$currPos += 6; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c29); } | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parse_(); | |
if (s2 !== peg$FAILED) { | |
if (input.charCodeAt(peg$currPos) === 44) { | |
s3 = peg$c10; | |
peg$currPos++; | |
} else { | |
s3 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c11); } | |
} | |
if (s3 !== peg$FAILED) { | |
s4 = peg$parse_(); | |
if (s4 !== peg$FAILED) { | |
s5 = []; | |
s6 = peg$parseoptionalFormatPattern(); | |
if (s6 !== peg$FAILED) { | |
while (s6 !== peg$FAILED) { | |
s5.push(s6); | |
s6 = peg$parseoptionalFormatPattern(); | |
} | |
} else { | |
s5 = peg$c2; | |
} | |
if (s5 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c30(s5); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parseselector() { | |
var s0, s1, s2, s3; | |
s0 = peg$currPos; | |
s1 = peg$currPos; | |
if (input.charCodeAt(peg$currPos) === 61) { | |
s2 = peg$c31; | |
peg$currPos++; | |
} else { | |
s2 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c32); } | |
} | |
if (s2 !== peg$FAILED) { | |
s3 = peg$parsenumber(); | |
if (s3 !== peg$FAILED) { | |
s2 = [s2, s3]; | |
s1 = s2; | |
} else { | |
peg$currPos = s1; | |
s1 = peg$c2; | |
} | |
} else { | |
peg$currPos = s1; | |
s1 = peg$c2; | |
} | |
if (s1 !== peg$FAILED) { | |
s1 = input.substring(s0, peg$currPos); | |
} | |
s0 = s1; | |
if (s0 === peg$FAILED) { | |
s0 = peg$parsechars(); | |
} | |
return s0; | |
} | |
function peg$parseoptionalFormatPattern() { | |
var s0, s1, s2, s3, s4, s5, s6, s7, s8; | |
s0 = peg$currPos; | |
s1 = peg$parse_(); | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parseselector(); | |
if (s2 !== peg$FAILED) { | |
s3 = peg$parse_(); | |
if (s3 !== peg$FAILED) { | |
if (input.charCodeAt(peg$currPos) === 123) { | |
s4 = peg$c7; | |
peg$currPos++; | |
} else { | |
s4 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c8); } | |
} | |
if (s4 !== peg$FAILED) { | |
s5 = peg$parse_(); | |
if (s5 !== peg$FAILED) { | |
s6 = peg$parsemessageFormatPattern(); | |
if (s6 !== peg$FAILED) { | |
s7 = peg$parse_(); | |
if (s7 !== peg$FAILED) { | |
if (input.charCodeAt(peg$currPos) === 125) { | |
s8 = peg$c12; | |
peg$currPos++; | |
} else { | |
s8 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c13); } | |
} | |
if (s8 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c33(s2, s6); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parseoffset() { | |
var s0, s1, s2, s3; | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 7) === peg$c34) { | |
s1 = peg$c34; | |
peg$currPos += 7; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c35); } | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parse_(); | |
if (s2 !== peg$FAILED) { | |
s3 = peg$parsenumber(); | |
if (s3 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c36(s3); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parsepluralStyle() { | |
var s0, s1, s2, s3, s4; | |
s0 = peg$currPos; | |
s1 = peg$parseoffset(); | |
if (s1 === peg$FAILED) { | |
s1 = peg$c9; | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$parse_(); | |
if (s2 !== peg$FAILED) { | |
s3 = []; | |
s4 = peg$parseoptionalFormatPattern(); | |
if (s4 !== peg$FAILED) { | |
while (s4 !== peg$FAILED) { | |
s3.push(s4); | |
s4 = peg$parseoptionalFormatPattern(); | |
} | |
} else { | |
s3 = peg$c2; | |
} | |
if (s3 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c37(s1, s3); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
return s0; | |
} | |
function peg$parsews() { | |
var s0, s1; | |
peg$silentFails++; | |
s0 = []; | |
if (peg$c39.test(input.charAt(peg$currPos))) { | |
s1 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c40); } | |
} | |
if (s1 !== peg$FAILED) { | |
while (s1 !== peg$FAILED) { | |
s0.push(s1); | |
if (peg$c39.test(input.charAt(peg$currPos))) { | |
s1 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c40); } | |
} | |
} | |
} else { | |
s0 = peg$c2; | |
} | |
peg$silentFails--; | |
if (s0 === peg$FAILED) { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c38); } | |
} | |
return s0; | |
} | |
function peg$parse_() { | |
var s0, s1, s2; | |
peg$silentFails++; | |
s0 = peg$currPos; | |
s1 = []; | |
s2 = peg$parsews(); | |
while (s2 !== peg$FAILED) { | |
s1.push(s2); | |
s2 = peg$parsews(); | |
} | |
if (s1 !== peg$FAILED) { | |
s1 = input.substring(s0, peg$currPos); | |
} | |
s0 = s1; | |
peg$silentFails--; | |
if (s0 === peg$FAILED) { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c41); } | |
} | |
return s0; | |
} | |
function peg$parsedigit() { | |
var s0; | |
if (peg$c42.test(input.charAt(peg$currPos))) { | |
s0 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s0 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c43); } | |
} | |
return s0; | |
} | |
function peg$parsehexDigit() { | |
var s0; | |
if (peg$c44.test(input.charAt(peg$currPos))) { | |
s0 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s0 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c45); } | |
} | |
return s0; | |
} | |
function peg$parsenumber() { | |
var s0, s1, s2, s3, s4, s5; | |
s0 = peg$currPos; | |
if (input.charCodeAt(peg$currPos) === 48) { | |
s1 = peg$c46; | |
peg$currPos++; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c47); } | |
} | |
if (s1 === peg$FAILED) { | |
s1 = peg$currPos; | |
s2 = peg$currPos; | |
if (peg$c48.test(input.charAt(peg$currPos))) { | |
s3 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s3 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c49); } | |
} | |
if (s3 !== peg$FAILED) { | |
s4 = []; | |
s5 = peg$parsedigit(); | |
while (s5 !== peg$FAILED) { | |
s4.push(s5); | |
s5 = peg$parsedigit(); | |
} | |
if (s4 !== peg$FAILED) { | |
s3 = [s3, s4]; | |
s2 = s3; | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
} else { | |
peg$currPos = s2; | |
s2 = peg$c2; | |
} | |
if (s2 !== peg$FAILED) { | |
s2 = input.substring(s1, peg$currPos); | |
} | |
s1 = s2; | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c50(s1); | |
} | |
s0 = s1; | |
return s0; | |
} | |
function peg$parsechar() { | |
var s0, s1, s2, s3, s4, s5, s6, s7; | |
if (peg$c51.test(input.charAt(peg$currPos))) { | |
s0 = input.charAt(peg$currPos); | |
peg$currPos++; | |
} else { | |
s0 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c52); } | |
} | |
if (s0 === peg$FAILED) { | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 2) === peg$c53) { | |
s1 = peg$c53; | |
peg$currPos += 2; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c54); } | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c55(); | |
} | |
s0 = s1; | |
if (s0 === peg$FAILED) { | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 2) === peg$c56) { | |
s1 = peg$c56; | |
peg$currPos += 2; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c57); } | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c58(); | |
} | |
s0 = s1; | |
if (s0 === peg$FAILED) { | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 2) === peg$c59) { | |
s1 = peg$c59; | |
peg$currPos += 2; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c60); } | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c61(); | |
} | |
s0 = s1; | |
if (s0 === peg$FAILED) { | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 2) === peg$c62) { | |
s1 = peg$c62; | |
peg$currPos += 2; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c63); } | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c64(); | |
} | |
s0 = s1; | |
if (s0 === peg$FAILED) { | |
s0 = peg$currPos; | |
if (input.substr(peg$currPos, 2) === peg$c65) { | |
s1 = peg$c65; | |
peg$currPos += 2; | |
} else { | |
s1 = peg$FAILED; | |
if (peg$silentFails === 0) { peg$fail(peg$c66); } | |
} | |
if (s1 !== peg$FAILED) { | |
s2 = peg$currPos; | |
s3 = peg$currPos; | |
s4 = peg$parsehexDigit(); | |
if (s4 !== peg$FAILED) { | |
s5 = peg$parsehexDigit(); | |
if (s5 !== peg$FAILED) { | |
s6 = peg$parsehexDigit(); | |
if (s6 !== peg$FAILED) { | |
s7 = peg$parsehexDigit(); | |
if (s7 !== peg$FAILED) { | |
s4 = [s4, s5, s6, s7]; | |
s3 = s4; | |
} else { | |
peg$currPos = s3; | |
s3 = peg$c2; | |
} | |
} else { | |
peg$currPos = s3; | |
s3 = peg$c2; | |
} | |
} else { | |
peg$currPos = s3; | |
s3 = peg$c2; | |
} | |
} else { | |
peg$currPos = s3; | |
s3 = peg$c2; | |
} | |
if (s3 !== peg$FAILED) { | |
s3 = input.substring(s2, peg$currPos); | |
} | |
s2 = s3; | |
if (s2 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c67(s2); | |
s0 = s1; | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} else { | |
peg$currPos = s0; | |
s0 = peg$c2; | |
} | |
} | |
} | |
} | |
} | |
} | |
return s0; | |
} | |
function peg$parsechars() { | |
var s0, s1, s2; | |
s0 = peg$currPos; | |
s1 = []; | |
s2 = peg$parsechar(); | |
if (s2 !== peg$FAILED) { | |
while (s2 !== peg$FAILED) { | |
s1.push(s2); | |
s2 = peg$parsechar(); | |
} | |
} else { | |
s1 = peg$c2; | |
} | |
if (s1 !== peg$FAILED) { | |
peg$reportedPos = s0; | |
s1 = peg$c68(s1); | |
} | |
s0 = s1; | |
return s0; | |
} | |
peg$result = peg$startRuleFunction(); | |
if (peg$result !== peg$FAILED && peg$currPos === input.length) { | |
return peg$result; | |
} else { | |
if (peg$result !== peg$FAILED && peg$currPos < input.length) { | |
peg$fail({ type: "end", description: "end of input" }); | |
} | |
throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); | |
} | |
} | |
return { | |
SyntaxError: SyntaxError, | |
parse: parse | |
}; | |
})(); | |
//# sourceMappingURL=parser.js.map | |
/***/ }), | |
/* 126 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* jshint node:true */ | |
var IntlMessageFormat = __webpack_require__(131)['default']; | |
// Add all locale data to `IntlMessageFormat`. This module will be ignored when | |
// bundling for the browser with Browserify/Webpack. | |
__webpack_require__(140); | |
// Re-export `IntlMessageFormat` as the CommonJS default exports with all the | |
// locale data registered, and with English set as the default locale. Define | |
// the `default` prop for use with other compiled ES6 Modules. | |
exports = module.exports = IntlMessageFormat; | |
exports['default'] = exports; | |
/***/ }), | |
/* 127 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* | |
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | |
Copyrights licensed under the New BSD License. | |
See the accompanying LICENSE file for terms. | |
*/ | |
/* jslint esnext: true */ | |
exports["default"] = Compiler; | |
function Compiler(locales, formats, pluralFn) { | |
this.locales = locales; | |
this.formats = formats; | |
this.pluralFn = pluralFn; | |
} | |
Compiler.prototype.compile = function (ast) { | |
this.pluralStack = []; | |
this.currentPlural = null; | |
this.pluralNumberFormat = null; | |
return this.compileMessage(ast); | |
}; | |
Compiler.prototype.compileMessage = function (ast) { | |
if (!(ast && ast.type === 'messageFormatPattern')) { | |
throw new Error('Message AST is not of type: "messageFormatPattern"'); | |
} | |
var elements = ast.elements, | |
pattern = []; | |
var i, len, element; | |
for (i = 0, len = elements.length; i < len; i += 1) { | |
element = elements[i]; | |
switch (element.type) { | |
case 'messageTextElement': | |
pattern.push(this.compileMessageText(element)); | |
break; | |
case 'argumentElement': | |
pattern.push(this.compileArgument(element)); | |
break; | |
default: | |
throw new Error('Message element does not have a valid type'); | |
} | |
} | |
return pattern; | |
}; | |
Compiler.prototype.compileMessageText = function (element) { | |
// When this `element` is part of plural sub-pattern and its value contains | |
// an unescaped '#', use a `PluralOffsetString` helper to properly output | |
// the number with the correct offset in the string. | |
if (this.currentPlural && /(^|[^\\])#/g.test(element.value)) { | |
// Create a cache a NumberFormat instance that can be reused for any | |
// PluralOffsetString instance in this message. | |
if (!this.pluralNumberFormat) { | |
this.pluralNumberFormat = new Intl.NumberFormat(this.locales); | |
} | |
return new PluralOffsetString( | |
this.currentPlural.id, | |
this.currentPlural.format.offset, | |
this.pluralNumberFormat, | |
element.value); | |
} | |
// Unescape the escaped '#'s in the message text. | |
return element.value.replace(/\\#/g, '#'); | |
}; | |
Compiler.prototype.compileArgument = function (element) { | |
var format = element.format; | |
if (!format) { | |
return new StringFormat(element.id); | |
} | |
var formats = this.formats, | |
locales = this.locales, | |
pluralFn = this.pluralFn, | |
options; | |
switch (format.type) { | |
case 'numberFormat': | |
options = formats.number[format.style]; | |
return { | |
id : element.id, | |
format: new Intl.NumberFormat(locales, options).format | |
}; | |
case 'dateFormat': | |
options = formats.date[format.style]; | |
return { | |
id : element.id, | |
format: new Intl.DateTimeFormat(locales, options).format | |
}; | |
case 'timeFormat': | |
options = formats.time[format.style]; | |
return { | |
id : element.id, | |
format: new Intl.DateTimeFormat(locales, options).format | |
}; | |
case 'pluralFormat': | |
options = this.compileOptions(element); | |
return new PluralFormat( | |
element.id, format.ordinal, format.offset, options, pluralFn | |
); | |
case 'selectFormat': | |
options = this.compileOptions(element); | |
return new SelectFormat(element.id, options); | |
default: | |
throw new Error('Message element does not have a valid format type'); | |
} | |
}; | |
Compiler.prototype.compileOptions = function (element) { | |
var format = element.format, | |
options = format.options, | |
optionsHash = {}; | |
// Save the current plural element, if any, then set it to a new value when | |
// compiling the options sub-patterns. This conforms the spec's algorithm | |
// for handling `"#"` syntax in message text. | |
this.pluralStack.push(this.currentPlural); | |
this.currentPlural = format.type === 'pluralFormat' ? element : null; | |
var i, len, option; | |
for (i = 0, len = options.length; i < len; i += 1) { | |
option = options[i]; | |
// Compile the sub-pattern and save it under the options's selector. | |
optionsHash[option.selector] = this.compileMessage(option.value); | |
} | |
// Pop the plural stack to put back the original current plural value. | |
this.currentPlural = this.pluralStack.pop(); | |
return optionsHash; | |
}; | |
// -- Compiler Helper Classes -------------------------------------------------- | |
function StringFormat(id) { | |
this.id = id; | |
} | |
StringFormat.prototype.format = function (value) { | |
if (!value) { | |
return ''; | |
} | |
return typeof value === 'string' ? value : String(value); | |
}; | |
function PluralFormat(id, useOrdinal, offset, options, pluralFn) { | |
this.id = id; | |
this.useOrdinal = useOrdinal; | |
this.offset = offset; | |
this.options = options; | |
this.pluralFn = pluralFn; | |
} | |
PluralFormat.prototype.getOption = function (value) { | |
var options = this.options; | |
var option = options['=' + value] || | |
options[this.pluralFn(value - this.offset, this.useOrdinal)]; | |
return option || options.other; | |
}; | |
function PluralOffsetString(id, offset, numberFormat, string) { | |
this.id = id; | |
this.offset = offset; | |
this.numberFormat = numberFormat; | |
this.string = string; | |
} | |
PluralOffsetString.prototype.format = function (value) { | |
var number = this.numberFormat.format(value - this.offset); | |
return this.string | |
.replace(/(^|[^\\])#/g, '$1' + number) | |
.replace(/\\#/g, '#'); | |
}; | |
function SelectFormat(id, options) { | |
this.id = id; | |
this.options = options; | |
} | |
SelectFormat.prototype.getOption = function (value) { | |
var options = this.options; | |
return options[value] || options.other; | |
}; | |
//# sourceMappingURL=compiler.js.map | |
/***/ }), | |
/* 128 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* | |
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | |
Copyrights licensed under the New BSD License. | |
See the accompanying LICENSE file for terms. | |
*/ | |
/* jslint esnext: true */ | |
var src$utils$$ = __webpack_require__(49), src$es5$$ = __webpack_require__(130), src$compiler$$ = __webpack_require__(127), intl$messageformat$parser$$ = __webpack_require__(124); | |
exports["default"] = MessageFormat; | |
// -- MessageFormat -------------------------------------------------------- | |
function MessageFormat(message, locales, formats) { | |
// Parse string messages into an AST. | |
var ast = typeof message === 'string' ? | |
MessageFormat.__parse(message) : message; | |
if (!(ast && ast.type === 'messageFormatPattern')) { | |
throw new TypeError('A message must be provided as a String or AST.'); | |
} | |
// Creates a new object with the specified `formats` merged with the default | |
// formats. | |
formats = this._mergeFormats(MessageFormat.formats, formats); | |
// Defined first because it's used to build the format pattern. | |
src$es5$$.defineProperty(this, '_locale', {value: this._resolveLocale(locales)}); | |
// Compile the `ast` to a pattern that is highly optimized for repeated | |
// `format()` invocations. **Note:** This passes the `locales` set provided | |
// to the constructor instead of just the resolved locale. | |
var pluralFn = this._findPluralRuleFunction(this._locale); | |
var pattern = this._compilePattern(ast, locales, formats, pluralFn); | |
// "Bind" `format()` method to `this` so it can be passed by reference like | |
// the other `Intl` APIs. | |
var messageFormat = this; | |
this.format = function (values) { | |
return messageFormat._format(pattern, values); | |
}; | |
} | |
// Default format options used as the prototype of the `formats` provided to the | |
// constructor. These are used when constructing the internal Intl.NumberFormat | |
// and Intl.DateTimeFormat instances. | |
src$es5$$.defineProperty(MessageFormat, 'formats', { | |
enumerable: true, | |
value: { | |
number: { | |
'currency': { | |
style: 'currency' | |
}, | |
'percent': { | |
style: 'percent' | |
} | |
}, | |
date: { | |
'short': { | |
month: 'numeric', | |
day : 'numeric', | |
year : '2-digit' | |
}, | |
'medium': { | |
month: 'short', | |
day : 'numeric', | |
year : 'numeric' | |
}, | |
'long': { | |
month: 'long', | |
day : 'numeric', | |
year : 'numeric' | |
}, | |
'full': { | |
weekday: 'long', | |
month : 'long', | |
day : 'numeric', | |
year : 'numeric' | |
} | |
}, | |
time: { | |
'short': { | |
hour : 'numeric', | |
minute: 'numeric' | |
}, | |
'medium': { | |
hour : 'numeric', | |
minute: 'numeric', | |
second: 'numeric' | |
}, | |
'long': { | |
hour : 'numeric', | |
minute : 'numeric', | |
second : 'numeric', | |
timeZoneName: 'short' | |
}, | |
'full': { | |
hour : 'numeric', | |
minute : 'numeric', | |
second : 'numeric', | |
timeZoneName: 'short' | |
} | |
} | |
} | |
}); | |
// Define internal private properties for dealing with locale data. | |
src$es5$$.defineProperty(MessageFormat, '__localeData__', {value: src$es5$$.objCreate(null)}); | |
src$es5$$.defineProperty(MessageFormat, '__addLocaleData', {value: function (data) { | |
if (!(data && data.locale)) { | |
throw new Error( | |
'Locale data provided to IntlMessageFormat is missing a ' + | |
'`locale` property' | |
); | |
} | |
MessageFormat.__localeData__[data.locale.toLowerCase()] = data; | |
}}); | |
// Defines `__parse()` static method as an exposed private. | |
src$es5$$.defineProperty(MessageFormat, '__parse', {value: intl$messageformat$parser$$["default"].parse}); | |
// Define public `defaultLocale` property which defaults to English, but can be | |
// set by the developer. | |
src$es5$$.defineProperty(MessageFormat, 'defaultLocale', { | |
enumerable: true, | |
writable : true, | |
value : undefined | |
}); | |
MessageFormat.prototype.resolvedOptions = function () { | |
// TODO: Provide anything else? | |
return { | |
locale: this._locale | |
}; | |
}; | |
MessageFormat.prototype._compilePattern = function (ast, locales, formats, pluralFn) { | |
var compiler = new src$compiler$$["default"](locales, formats, pluralFn); | |
return compiler.compile(ast); | |
}; | |
MessageFormat.prototype._findPluralRuleFunction = function (locale) { | |
var localeData = MessageFormat.__localeData__; | |
var data = localeData[locale.toLowerCase()]; | |
// The locale data is de-duplicated, so we have to traverse the locale's | |
// hierarchy until we find a `pluralRuleFunction` to return. | |
while (data) { | |
if (data.pluralRuleFunction) { | |
return data.pluralRuleFunction; | |
} | |
data = data.parentLocale && localeData[data.parentLocale.toLowerCase()]; | |
} | |
throw new Error( | |
'Locale data added to IntlMessageFormat is missing a ' + | |
'`pluralRuleFunction` for :' + locale | |
); | |
}; | |
MessageFormat.prototype._format = function (pattern, values) { | |
var result = '', | |
i, len, part, id, value; | |
for (i = 0, len = pattern.length; i < len; i += 1) { | |
part = pattern[i]; | |
// Exist early for string parts. | |
if (typeof part === 'string') { | |
result += part; | |
continue; | |
} | |
id = part.id; | |
// Enforce that all required values are provided by the caller. | |
if (!(values && src$utils$$.hop.call(values, id))) { | |
throw new Error('A value must be provided for: ' + id); | |
} | |
value = values[id]; | |
// Recursively format plural and select parts' option — which can be a | |
// nested pattern structure. The choosing of the option to use is | |
// abstracted-by and delegated-to the part helper object. | |
if (part.options) { | |
result += this._format(part.getOption(value), values); | |
} else { | |
result += part.format(value); | |
} | |
} | |
return result; | |
}; | |
MessageFormat.prototype._mergeFormats = function (defaults, formats) { | |
var mergedFormats = {}, | |
type, mergedType; | |
for (type in defaults) { | |
if (!src$utils$$.hop.call(defaults, type)) { continue; } | |
mergedFormats[type] = mergedType = src$es5$$.objCreate(defaults[type]); | |
if (formats && src$utils$$.hop.call(formats, type)) { | |
src$utils$$.extend(mergedType, formats[type]); | |
} | |
} | |
return mergedFormats; | |
}; | |
MessageFormat.prototype._resolveLocale = function (locales) { | |
if (typeof locales === 'string') { | |
locales = [locales]; | |
} | |
// Create a copy of the array so we can push on the default locale. | |
locales = (locales || []).concat(MessageFormat.defaultLocale); | |
var localeData = MessageFormat.__localeData__; | |
var i, len, localeParts, data; | |
// Using the set of locales + the default locale, we look for the first one | |
// which that has been registered. When data does not exist for a locale, we | |
// traverse its ancestors to find something that's been registered within | |
// its hierarchy of locales. Since we lack the proper `parentLocale` data | |
// here, we must take a naive approach to traversal. | |
for (i = 0, len = locales.length; i < len; i += 1) { | |
localeParts = locales[i].toLowerCase().split('-'); | |
while (localeParts.length) { | |
data = localeData[localeParts.join('-')]; | |
if (data) { | |
// Return the normalized locale string; e.g., we return "en-US", | |
// instead of "en-us". | |
return data.locale; | |
} | |
localeParts.pop(); | |
} | |
} | |
var defaultLocale = locales.pop(); | |
throw new Error( | |
'No locale data has been added to IntlMessageFormat for: ' + | |
locales.join(', ') + ', or the default locale: ' + defaultLocale | |
); | |
}; | |
//# sourceMappingURL=core.js.map | |
/***/ }), | |
/* 129 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
// GENERATED FILE | |
exports["default"] = {"locale":"en","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1],t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2);if(ord)return n10==1&&n100!=11?"one":n10==2&&n100!=12?"two":n10==3&&n100!=13?"few":"other";return n==1&&v0?"one":"other"}}; | |
//# sourceMappingURL=en.js.map | |
/***/ }), | |
/* 130 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* | |
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | |
Copyrights licensed under the New BSD License. | |
See the accompanying LICENSE file for terms. | |
*/ | |
/* jslint esnext: true */ | |
var src$utils$$ = __webpack_require__(49); | |
// Purposely using the same implementation as the Intl.js `Intl` polyfill. | |
// Copyright 2013 Andy Earnshaw, MIT License | |
var realDefineProp = (function () { | |
try { return !!Object.defineProperty({}, 'a', {}); } | |
catch (e) { return false; } | |
})(); | |
var es3 = !realDefineProp && !Object.prototype.__defineGetter__; | |
var defineProperty = realDefineProp ? Object.defineProperty : | |
function (obj, name, desc) { | |
if ('get' in desc && obj.__defineGetter__) { | |
obj.__defineGetter__(name, desc.get); | |
} else if (!src$utils$$.hop.call(obj, name) || 'value' in desc) { | |
obj[name] = desc.value; | |
} | |
}; | |
var objCreate = Object.create || function (proto, props) { | |
var obj, k; | |
function F() {} | |
F.prototype = proto; | |
obj = new F(); | |
for (k in props) { | |
if (src$utils$$.hop.call(props, k)) { | |
defineProperty(obj, k, props[k]); | |
} | |
} | |
return obj; | |
}; | |
exports.defineProperty = defineProperty, exports.objCreate = objCreate; | |
//# sourceMappingURL=es5.js.map | |
/***/ }), | |
/* 131 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* jslint esnext: true */ | |
var src$core$$ = __webpack_require__(128), src$en$$ = __webpack_require__(129); | |
src$core$$["default"].__addLocaleData(src$en$$["default"]); | |
src$core$$["default"].defaultLocale = 'en'; | |
exports["default"] = src$core$$["default"]; | |
//# sourceMappingURL=main.js.map | |
/***/ }), | |
/* 132 */ | |
/***/ (function(module, exports) { | |
exports = module.exports = stringify | |
exports.getSerialize = serializer | |
function stringify(obj, replacer, spaces, cycleReplacer) { | |
return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces) | |
} | |
function serializer(replacer, cycleReplacer) { | |
var stack = [], keys = [] | |
if (cycleReplacer == null) cycleReplacer = function(key, value) { | |
if (stack[0] === value) return "[Circular ~]" | |
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]" | |
} | |
return function(key, value) { | |
if (stack.length > 0) { | |
var thisPos = stack.indexOf(this) | |
~thisPos ? stack.splice(thisPos + 1) : stack.push(this) | |
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key) | |
if (~stack.indexOf(value)) value = cycleReplacer.call(this, key, value) | |
} | |
else stack.push(value) | |
return replacer == null ? value : replacer.call(this, key, value) | |
} | |
} | |
/***/ }), | |
/* 133 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
function RavenConfigError(message) { | |
this.name = 'RavenConfigError'; | |
this.message = message; | |
} | |
RavenConfigError.prototype = new Error(); | |
RavenConfigError.prototype.constructor = RavenConfigError; | |
module.exports = RavenConfigError; | |
/***/ }), | |
/* 134 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
var wrapMethod = function(console, level, callback) { | |
var originalConsoleLevel = console[level]; | |
var originalConsole = console; | |
if (!(level in console)) { | |
return; | |
} | |
var sentryLevel = level === 'warn' | |
? 'warning' | |
: level; | |
console[level] = function () { | |
var args = [].slice.call(arguments); | |
var msg = '' + args.join(' '); | |
var data = {level: sentryLevel, logger: 'console', extra: {'arguments': args}}; | |
callback && callback(msg, data); | |
// this fails for some browsers. :( | |
if (originalConsoleLevel) { | |
// IE9 doesn't allow calling apply on console functions directly | |
// See: https://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function#answer-5473193 | |
Function.prototype.apply.call( | |
originalConsoleLevel, | |
originalConsole, | |
args | |
); | |
} | |
}; | |
}; | |
module.exports = { | |
wrapMethod: wrapMethod | |
}; | |
/***/ }), | |
/* 135 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* WEBPACK VAR INJECTION */(function(global) {/*global XDomainRequest:false, __DEV__:false*/ | |
var TraceKit = __webpack_require__(136); | |
var RavenConfigError = __webpack_require__(133); | |
var stringify = __webpack_require__(132); | |
var wrapConsoleMethod = __webpack_require__(134).wrapMethod; | |
var dsnKeys = 'source protocol user pass host port path'.split(' '), | |
dsnPattern = /^(?:(\w+):)?\/\/(?:(\w+)(:\w+)?@)?([\w\.-]+)(?::(\d+))?(\/.*)/; | |
function now() { | |
return +new Date(); | |
} | |
// This is to be defensive in environments where window does not exist (see https://github.com/getsentry/raven-js/pull/785) | |
var _window = typeof window !== 'undefined' ? window | |
: typeof global !== 'undefined' ? global | |
: typeof self !== 'undefined' ? self | |
: {}; | |
var _document = _window.document; | |
// First, check for JSON support | |
// If there is no JSON, we no-op the core features of Raven | |
// since JSON is required to encode the payload | |
function Raven() { | |
this._hasJSON = !!(typeof JSON === 'object' && JSON.stringify); | |
// Raven can run in contexts where there's no document (react-native) | |
this._hasDocument = !isUndefined(_document); | |
this._lastCapturedException = null; | |
this._lastEventId = null; | |
this._globalServer = null; | |
this._globalKey = null; | |
this._globalProject = null; | |
this._globalContext = {}; | |
this._globalOptions = { | |
logger: 'javascript', | |
ignoreErrors: [], | |
ignoreUrls: [], | |
whitelistUrls: [], | |
includePaths: [], | |
crossOrigin: 'anonymous', | |
collectWindowErrors: true, | |
maxMessageLength: 0, | |
stackTraceLimit: 50, | |
autoBreadcrumbs: true | |
}; | |
this._ignoreOnError = 0; | |
this._isRavenInstalled = false; | |
this._originalErrorStackTraceLimit = Error.stackTraceLimit; | |
// capture references to window.console *and* all its methods first | |
// before the console plugin has a chance to monkey patch | |
this._originalConsole = _window.console || {}; | |
this._originalConsoleMethods = {}; | |
this._plugins = []; | |
this._startTime = now(); | |
this._wrappedBuiltIns = []; | |
this._breadcrumbs = []; | |
this._lastCapturedEvent = null; | |
this._keypressTimeout; | |
this._location = _window.location; | |
this._lastHref = this._location && this._location.href; | |
for (var method in this._originalConsole) { // eslint-disable-line guard-for-in | |
this._originalConsoleMethods[method] = this._originalConsole[method]; | |
} | |
} | |
/* | |
* The core Raven singleton | |
* | |
* @this {Raven} | |
*/ | |
Raven.prototype = { | |
// Hardcode version string so that raven source can be loaded directly via | |
// webpack (using a build step causes webpack #1617). Grunt verifies that | |
// this value matches package.json during build. | |
// See: https://github.com/getsentry/raven-js/issues/465 | |
VERSION: '3.9.1', | |
debug: false, | |
TraceKit: TraceKit, // alias to TraceKit | |
/* | |
* Configure Raven with a DSN and extra options | |
* | |
* @param {string} dsn The public Sentry DSN | |
* @param {object} options Optional set of of global options [optional] | |
* @return {Raven} | |
*/ | |
config: function(dsn, options) { | |
var self = this; | |
if (self._globalServer) { | |
this._logDebug('error', 'Error: Raven has already been configured'); | |
return self; | |
} | |
if (!dsn) return self; | |
var globalOptions = self._globalOptions; | |
// merge in options | |
if (options) { | |
each(options, function(key, value){ | |
// tags and extra are special and need to be put into context | |
if (key === 'tags' || key === 'extra' || key === 'user') { | |
self._globalContext[key] = value; | |
} else { | |
globalOptions[key] = value; | |
} | |
}); | |
} | |
self.setDSN(dsn); | |
// "Script error." is hard coded into browsers for errors that it can't read. | |
// this is the result of a script being pulled in from an external domain and CORS. | |
globalOptions.ignoreErrors.push(/^Script error\.?$/); | |
globalOptions.ignoreErrors.push(/^Javascript error: Script error\.? on line 0$/); | |
// join regexp rules into one big rule | |
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors); | |
globalOptions.ignoreUrls = globalOptions.ignoreUrls.length ? joinRegExp(globalOptions.ignoreUrls) : false; | |
globalOptions.whitelistUrls = globalOptions.whitelistUrls.length ? joinRegExp(globalOptions.whitelistUrls) : false; | |
globalOptions.includePaths = joinRegExp(globalOptions.includePaths); | |
globalOptions.maxBreadcrumbs = Math.max(0, Math.min(globalOptions.maxBreadcrumbs || 100, 100)); // default and hard limit is 100 | |
var autoBreadcrumbDefaults = { | |
xhr: true, | |
console: true, | |
dom: true, | |
location: true | |
}; | |
var autoBreadcrumbs = globalOptions.autoBreadcrumbs; | |
if ({}.toString.call(autoBreadcrumbs) === '[object Object]') { | |
autoBreadcrumbs = objectMerge(autoBreadcrumbDefaults, autoBreadcrumbs); | |
} else if (autoBreadcrumbs !== false) { | |
autoBreadcrumbs = autoBreadcrumbDefaults; | |
} | |
globalOptions.autoBreadcrumbs = autoBreadcrumbs; | |
TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors; | |
// return for chaining | |
return self; | |
}, | |
/* | |
* Installs a global window.onerror error handler | |
* to capture and report uncaught exceptions. | |
* At this point, install() is required to be called due | |
* to the way TraceKit is set up. | |
* | |
* @return {Raven} | |
*/ | |
install: function() { | |
var self = this; | |
if (self.isSetup() && !self._isRavenInstalled) { | |
TraceKit.report.subscribe(function () { | |
self._handleOnErrorStackInfo.apply(self, arguments); | |
}); | |
self._instrumentTryCatch(); | |
if (self._globalOptions.autoBreadcrumbs) | |
self._instrumentBreadcrumbs(); | |
// Install all of the plugins | |
self._drainPlugins(); | |
self._isRavenInstalled = true; | |
} | |
Error.stackTraceLimit = self._globalOptions.stackTraceLimit; | |
return this; | |
}, | |
/* | |
* Set the DSN (can be called multiple time unlike config) | |
* | |
* @param {string} dsn The public Sentry DSN | |
*/ | |
setDSN: function(dsn) { | |
var self = this, | |
uri = self._parseDSN(dsn), | |
lastSlash = uri.path.lastIndexOf('/'), | |
path = uri.path.substr(1, lastSlash); | |
self._dsn = dsn; | |
self._globalKey = uri.user; | |
self._globalSecret = uri.pass && uri.pass.substr(1); | |
self._globalProject = uri.path.substr(lastSlash + 1); | |
self._globalServer = self._getGlobalServer(uri); | |
self._globalEndpoint = self._globalServer + | |
'/' + path + 'api/' + self._globalProject + '/store/'; | |
}, | |
/* | |
* Wrap code within a context so Raven can capture errors | |
* reliably across domains that is executed immediately. | |
* | |
* @param {object} options A specific set of options for this context [optional] | |
* @param {function} func The callback to be immediately executed within the context | |
* @param {array} args An array of arguments to be called with the callback [optional] | |
*/ | |
context: function(options, func, args) { | |
if (isFunction(options)) { | |
args = func || []; | |
func = options; | |
options = undefined; | |
} | |
return this.wrap(options, func).apply(this, args); | |
}, | |
/* | |
* Wrap code within a context and returns back a new function to be executed | |
* | |
* @param {object} options A specific set of options for this context [optional] | |
* @param {function} func The function to be wrapped in a new context | |
* @param {function} func A function to call before the try/catch wrapper [optional, private] | |
* @return {function} The newly wrapped functions with a context | |
*/ | |
wrap: function(options, func, _before) { | |
var self = this; | |
// 1 argument has been passed, and it's not a function | |
// so just return it | |
if (isUndefined(func) && !isFunction(options)) { | |
return options; | |
} | |
// options is optional | |
if (isFunction(options)) { | |
func = options; | |
options = undefined; | |
} | |
// At this point, we've passed along 2 arguments, and the second one | |
// is not a function either, so we'll just return the second argument. | |
if (!isFunction(func)) { | |
return func; | |
} | |
// We don't wanna wrap it twice! | |
try { | |
if (func.__raven__) { | |
return func; | |
} | |
// If this has already been wrapped in the past, return that | |
if (func.__raven_wrapper__ ){ | |
return func.__raven_wrapper__ ; | |
} | |
} catch (e) { | |
// Just accessing custom props in some Selenium environments | |
// can cause a "Permission denied" exception (see raven-js#495). | |
// Bail on wrapping and return the function as-is (defers to window.onerror). | |
return func; | |
} | |
function wrapped() { | |
var args = [], i = arguments.length, | |
deep = !options || options && options.deep !== false; | |
if (_before && isFunction(_before)) { | |
_before.apply(this, arguments); | |
} | |
// Recursively wrap all of a function's arguments that are | |
// functions themselves. | |
while(i--) args[i] = deep ? self.wrap(options, arguments[i]) : arguments[i]; | |
try { | |
return func.apply(this, args); | |
} catch(e) { | |
self._ignoreNextOnError(); | |
self.captureException(e, options); | |
throw e; | |
} | |
} | |
// copy over properties of the old function | |
for (var property in func) { | |
if (hasKey(func, property)) { | |
wrapped[property] = func[property]; | |
} | |
} | |
wrapped.prototype = func.prototype; | |
func.__raven_wrapper__ = wrapped; | |
// Signal that this function has been wrapped already | |
// for both debugging and to prevent it to being wrapped twice | |
wrapped.__raven__ = true; | |
wrapped.__inner__ = func; | |
return wrapped; | |
}, | |
/* | |
* Uninstalls the global error handler. | |
* | |
* @return {Raven} | |
*/ | |
uninstall: function() { | |
TraceKit.report.uninstall(); | |
this._restoreBuiltIns(); | |
Error.stackTraceLimit = this._originalErrorStackTraceLimit; | |
this._isRavenInstalled = false; | |
return this; | |
}, | |
/* | |
* Manually capture an exception and send it over to Sentry | |
* | |
* @param {error} ex An exception to be logged | |
* @param {object} options A specific set of options for this error [optional] | |
* @return {Raven} | |
*/ | |
captureException: function(ex, options) { | |
// If not an Error is passed through, recall as a message instead | |
if (!isError(ex)) { | |
return this.captureMessage(ex, objectMerge({ | |
trimHeadFrames: 1, | |
stacktrace: true // if we fall back to captureMessage, default to attempting a new trace | |
}, options)); | |
} | |
// Store the raw exception object for potential debugging and introspection | |
this._lastCapturedException = ex; | |
// TraceKit.report will re-raise any exception passed to it, | |
// which means you have to wrap it in try/catch. Instead, we | |
// can wrap it here and only re-raise if TraceKit.report | |
// raises an exception different from the one we asked to | |
// report on. | |
try { | |
var stack = TraceKit.computeStackTrace(ex); | |
this._handleStackInfo(stack, options); | |
} catch(ex1) { | |
if(ex !== ex1) { | |
throw ex1; | |
} | |
} | |
return this; | |
}, | |
/* | |
* Manually send a message to Sentry | |
* | |
* @param {string} msg A plain message to be captured in Sentry | |
* @param {object} options A specific set of options for this message [optional] | |
* @return {Raven} | |
*/ | |
captureMessage: function(msg, options) { | |
// config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an | |
// early call; we'll error on the side of logging anything called before configuration since it's | |
// probably something you should see: | |
if (!!this._globalOptions.ignoreErrors.test && this._globalOptions.ignoreErrors.test(msg)) { | |
return; | |
} | |
options = options || {}; | |
var data = objectMerge({ | |
message: msg + '' // Make sure it's actually a string | |
}, options); | |
if (this._globalOptions.stacktrace || (options && options.stacktrace)) { | |
var ex; | |
// create a stack trace from this point; just trim | |
// off extra frames so they don't include this function call (or | |
// earlier Raven.js library fn calls) | |
try { | |
throw new Error(msg); | |
} catch (ex1) { | |
ex = ex1; | |
} | |
// null exception name so `Error` isn't prefixed to msg | |
ex.name = null; | |
options = objectMerge({ | |
// fingerprint on msg, not stack trace (legacy behavior, could be | |
// revisited) | |
fingerprint: msg, | |
trimHeadFrames: (options.trimHeadFrames || 0) + 1 | |
}, options); | |
var stack = TraceKit.computeStackTrace(ex); | |
var frames = this._prepareFrames(stack, options); | |
data.stacktrace = { | |
// Sentry expects frames oldest to newest | |
frames: frames.reverse() | |
} | |
} | |
// Fire away! | |
this._send(data); | |
return this; | |
}, | |
captureBreadcrumb: function (obj) { | |
var crumb = objectMerge({ | |
timestamp: now() / 1000 | |
}, obj); | |
if (isFunction(this._globalOptions.breadcrumbCallback)) { | |
var result = this._globalOptions.breadcrumbCallback(crumb); | |
if (isObject(result) && !isEmptyObject(result)) { | |
crumb = result; | |
} else if (result === false) { | |
return this; | |
} | |
} | |
this._breadcrumbs.push(crumb); | |
if (this._breadcrumbs.length > this._globalOptions.maxBreadcrumbs) { | |
this._breadcrumbs.shift(); | |
} | |
return this; | |
}, | |
addPlugin: function(plugin /*arg1, arg2, ... argN*/) { | |
var pluginArgs = [].slice.call(arguments, 1); | |
this._plugins.push([plugin, pluginArgs]); | |
if (this._isRavenInstalled) { | |
this._drainPlugins(); | |
} | |
return this; | |
}, | |
/* | |
* Set/clear a user to be sent along with the payload. | |
* | |
* @param {object} user An object representing user data [optional] | |
* @return {Raven} | |
*/ | |
setUserContext: function(user) { | |
// Intentionally do not merge here since that's an unexpected behavior. | |
this._globalContext.user = user; | |
return this; | |
}, | |
/* | |
* Merge extra attributes to be sent along with the payload. | |
* | |
* @param {object} extra An object representing extra data [optional] | |
* @return {Raven} | |
*/ | |
setExtraContext: function(extra) { | |
this._mergeContext('extra', extra); | |
return this; | |
}, | |
/* | |
* Merge tags to be sent along with the payload. | |
* | |
* @param {object} tags An object representing tags [optional] | |
* @return {Raven} | |
*/ | |
setTagsContext: function(tags) { | |
this._mergeContext('tags', tags); | |
return this; | |
}, | |
/* | |
* Clear all of the context. | |
* | |
* @return {Raven} | |
*/ | |
clearContext: function() { | |
this._globalContext = {}; | |
return this; | |
}, | |
/* | |
* Get a copy of the current context. This cannot be mutated. | |
* | |
* @return {object} copy of context | |
*/ | |
getContext: function() { | |
// lol javascript | |
return JSON.parse(stringify(this._globalContext)); | |
}, | |
/* | |
* Set environment of application | |
* | |
* @param {string} environment Typically something like 'production'. | |
* @return {Raven} | |
*/ | |
setEnvironment: function(environment) { | |
this._globalOptions.environment = environment; | |
return this; | |
}, | |
/* | |
* Set release version of application | |
* | |
* @param {string} release Typically something like a git SHA to identify version | |
* @return {Raven} | |
*/ | |
setRelease: function(release) { | |
this._globalOptions.release = release; | |
return this; | |
}, | |
/* | |
* Set the dataCallback option | |
* | |
* @param {function} callback The callback to run which allows the | |
* data blob to be mutated before sending | |
* @return {Raven} | |
*/ | |
setDataCallback: function(callback) { | |
var original = this._globalOptions.dataCallback; | |
this._globalOptions.dataCallback = isFunction(callback) | |
? function (data) { return callback(data, original); } | |
: callback; | |
return this; | |
}, | |
/* | |
* Set the breadcrumbCallback option | |
* | |
* @param {function} callback The callback to run which allows filtering | |
* or mutating breadcrumbs | |
* @return {Raven} | |
*/ | |
setBreadcrumbCallback: function(callback) { | |
var original = this._globalOptions.breadcrumbCallback; | |
this._globalOptions.breadcrumbCallback = isFunction(callback) | |
? function (data) { return callback(data, original); } | |
: callback; | |
return this; | |
}, | |
/* | |
* Set the shouldSendCallback option | |
* | |
* @param {function} callback The callback to run which allows | |
* introspecting the blob before sending | |
* @return {Raven} | |
*/ | |
setShouldSendCallback: function(callback) { | |
var original = this._globalOptions.shouldSendCallback; | |
this._globalOptions.shouldSendCallback = isFunction(callback) | |
? function (data) { return callback(data, original); } | |
: callback; | |
return this; | |
}, | |
/** | |
* Override the default HTTP transport mechanism that transmits data | |
* to the Sentry server. | |
* | |
* @param {function} transport Function invoked instead of the default | |
* `makeRequest` handler. | |
* | |
* @return {Raven} | |
*/ | |
setTransport: function(transport) { | |
this._globalOptions.transport = transport; | |
return this; | |
}, | |
/* | |
* Get the latest raw exception that was captured by Raven. | |
* | |
* @return {error} | |
*/ | |
lastException: function() { | |
return this._lastCapturedException; | |
}, | |
/* | |
* Get the last event id | |
* | |
* @return {string} | |
*/ | |
lastEventId: function() { | |
return this._lastEventId; | |
}, | |
/* | |
* Determine if Raven is setup and ready to go. | |
* | |
* @return {boolean} | |
*/ | |
isSetup: function() { | |
if (!this._hasJSON) return false; // needs JSON support | |
if (!this._globalServer) { | |
if (!this.ravenNotConfiguredError) { | |
this.ravenNotConfiguredError = true; | |
this._logDebug('error', 'Error: Raven has not been configured.'); | |
} | |
return false; | |
} | |
return true; | |
}, | |
afterLoad: function () { | |
// TODO: remove window dependence? | |
// Attempt to initialize Raven on load | |
var RavenConfig = _window.RavenConfig; | |
if (RavenConfig) { | |
this.config(RavenConfig.dsn, RavenConfig.config).install(); | |
} | |
}, | |
showReportDialog: function (options) { | |
if (!_document) // doesn't work without a document (React native) | |
return; | |
options = options || {}; | |
var lastEventId = options.eventId || this.lastEventId(); | |
if (!lastEventId) { | |
throw new RavenConfigError('Missing eventId'); | |
} | |
var dsn = options.dsn || this._dsn; | |
if (!dsn) { | |
throw new RavenConfigError('Missing DSN'); | |
} | |
var encode = encodeURIComponent; | |
var qs = ''; | |
qs += '?eventId=' + encode(lastEventId); | |
qs += '&dsn=' + encode(dsn); | |
var user = options.user || this._globalContext.user; | |
if (user) { | |
if (user.name) qs += '&name=' + encode(user.name); | |
if (user.email) qs += '&email=' + encode(user.email); | |
} | |
var globalServer = this._getGlobalServer(this._parseDSN(dsn)); | |
var script = _document.createElement('script'); | |
script.async = true; | |
script.src = globalServer + '/api/embed/error-page/' + qs; | |
(_document.head || _document.body).appendChild(script); | |
}, | |
/**** Private functions ****/ | |
_ignoreNextOnError: function () { | |
var self = this; | |
this._ignoreOnError += 1; | |
setTimeout(function () { | |
// onerror should trigger before setTimeout | |
self._ignoreOnError -= 1; | |
}); | |
}, | |
_triggerEvent: function(eventType, options) { | |
// NOTE: `event` is a native browser thing, so let's avoid conflicting wiht it | |
var evt, key; | |
if (!this._hasDocument) | |
return; | |
options = options || {}; | |
eventType = 'raven' + eventType.substr(0,1).toUpperCase() + eventType.substr(1); | |
if (_document.createEvent) { | |
evt = _document.createEvent('HTMLEvents'); | |
evt.initEvent(eventType, true, true); | |
} else { | |
evt = _document.createEventObject(); | |
evt.eventType = eventType; | |
} | |
for (key in options) if (hasKey(options, key)) { | |
evt[key] = options[key]; | |
} | |
if (_document.createEvent) { | |
// IE9 if standards | |
_document.dispatchEvent(evt); | |
} else { | |
// IE8 regardless of Quirks or Standards | |
// IE9 if quirks | |
try { | |
_document.fireEvent('on' + evt.eventType.toLowerCase(), evt); | |
} catch(e) { | |
// Do nothing | |
} | |
} | |
}, | |
/** | |
* Wraps addEventListener to capture UI breadcrumbs | |
* @param evtName the event name (e.g. "click") | |
* @returns {Function} | |
* @private | |
*/ | |
_breadcrumbEventHandler: function(evtName) { | |
var self = this; | |
return function (evt) { | |
// reset keypress timeout; e.g. triggering a 'click' after | |
// a 'keypress' will reset the keypress debounce so that a new | |
// set of keypresses can be recorded | |
self._keypressTimeout = null; | |
// It's possible this handler might trigger multiple times for the same | |
// event (e.g. event propagation through node ancestors). Ignore if we've | |
// already captured the event. | |
if (self._lastCapturedEvent === evt) | |
return; | |
self._lastCapturedEvent = evt; | |
var elem = evt.target; | |
var target; | |
// try/catch htmlTreeAsString because it's particularly complicated, and | |
// just accessing the DOM incorrectly can throw an exception in some circumstances. | |
try { | |
target = htmlTreeAsString(elem); | |
} catch (e) { | |
target = '<unknown>'; | |
} | |
self.captureBreadcrumb({ | |
category: 'ui.' + evtName, // e.g. ui.click, ui.input | |
message: target | |
}); | |
}; | |
}, | |
/** | |
* Wraps addEventListener to capture keypress UI events | |
* @returns {Function} | |
* @private | |
*/ | |
_keypressEventHandler: function() { | |
var self = this, | |
debounceDuration = 1000; // milliseconds | |
// TODO: if somehow user switches keypress target before | |
// debounce timeout is triggered, we will only capture | |
// a single breadcrumb from the FIRST target (acceptable?) | |
return function (evt) { | |
var target = evt.target, | |
tagName = target && target.tagName; | |
// only consider keypress events on actual input elements | |
// this will disregard keypresses targeting body (e.g. tabbing | |
// through elements, hotkeys, etc) | |
if (!tagName || tagName !== 'INPUT' && tagName !== 'TEXTAREA' && !target.isContentEditable) | |
return; | |
// record first keypress in a series, but ignore subsequent | |
// keypresses until debounce clears | |
var timeout = self._keypressTimeout; | |
if (!timeout) { | |
self._breadcrumbEventHandler('input')(evt); | |
} | |
clearTimeout(timeout); | |
self._keypressTimeout = setTimeout(function () { | |
self._keypressTimeout = null; | |
}, debounceDuration); | |
}; | |
}, | |
/** | |
* Captures a breadcrumb of type "navigation", normalizing input URLs | |
* @param to the originating URL | |
* @param from the target URL | |
* @private | |
*/ | |
_captureUrlChange: function(from, to) { | |
var parsedLoc = parseUrl(this._location.href); | |
var parsedTo = parseUrl(to); | |
var parsedFrom = parseUrl(from); | |
// because onpopstate only tells you the "new" (to) value of location.href, and | |
// not the previous (from) value, we need to track the value of the current URL | |
// state ourselves | |
this._lastHref = to; | |
// Use only the path component of the URL if the URL matches the current | |
// document (almost all the time when using pushState) | |
if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) | |
to = parsedTo.relative; | |
if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) | |
from = parsedFrom.relative; | |
this.captureBreadcrumb({ | |
category: 'navigation', | |
data: { | |
to: to, | |
from: from | |
} | |
}); | |
}, | |
/** | |
* Install any queued plugins | |
*/ | |
_instrumentTryCatch: function() { | |
var self = this; | |
var wrappedBuiltIns = self._wrappedBuiltIns; | |
function wrapTimeFn(orig) { | |
return function (fn, t) { // preserve arity | |
// Make a copy of the arguments to prevent deoptimization | |
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments | |
var args = new Array(arguments.length); | |
for(var i = 0; i < args.length; ++i) { | |
args[i] = arguments[i]; | |
} | |
var originalCallback = args[0]; | |
if (isFunction(originalCallback)) { | |
args[0] = self.wrap(originalCallback); | |
} | |
// IE < 9 doesn't support .call/.apply on setInterval/setTimeout, but it | |
// also supports only two arguments and doesn't care what this is, so we | |
// can just call the original function directly. | |
if (orig.apply) { | |
return orig.apply(this, args); | |
} else { | |
return orig(args[0], args[1]); | |
} | |
}; | |
} | |
var autoBreadcrumbs = this._globalOptions.autoBreadcrumbs; | |
function wrapEventTarget(global) { | |
var proto = _window[global] && _window[global].prototype; | |
if (proto && proto.hasOwnProperty && proto.hasOwnProperty('addEventListener')) { | |
fill(proto, 'addEventListener', function(orig) { | |
return function (evtName, fn, capture, secure) { // preserve arity | |
try { | |
if (fn && fn.handleEvent) { | |
fn.handleEvent = self.wrap(fn.handleEvent); | |
} | |
} catch (err) { | |
// can sometimes get 'Permission denied to access property "handle Event' | |
} | |
// More breadcrumb DOM capture ... done here and not in `_instrumentBreadcrumbs` | |
// so that we don't have more than one wrapper function | |
var before, | |
clickHandler, | |
keypressHandler; | |
if (autoBreadcrumbs && autoBreadcrumbs.dom && (global === 'EventTarget' || global === 'Node')) { | |
// NOTE: generating multiple handlers per addEventListener invocation, should | |
// revisit and verify we can just use one (almost certainly) | |
clickHandler = self._breadcrumbEventHandler('click'); | |
keypressHandler = self._keypressEventHandler(); | |
before = function (evt) { | |
// need to intercept every DOM event in `before` argument, in case that | |
// same wrapped method is re-used for different events (e.g. mousemove THEN click) | |
// see #724 | |
if (!evt) return; | |
if (evt.type === 'click') | |
return clickHandler(evt); | |
else if (evt.type === 'keypress') | |
return keypressHandler(evt); | |
}; | |
} | |
return orig.call(this, evtName, self.wrap(fn, undefined, before), capture, secure); | |
}; | |
}, wrappedBuiltIns); | |
fill(proto, 'removeEventListener', function (orig) { | |
return function (evt, fn, capture, secure) { | |
try { | |
fn = fn && (fn.__raven_wrapper__ ? fn.__raven_wrapper__ : fn); | |
} catch (e) { | |
// ignore, accessing __raven_wrapper__ will throw in some Selenium environments | |
} | |
return orig.call(this, evt, fn, capture, secure); | |
}; | |
}, wrappedBuiltIns); | |
} | |
} | |
fill(_window, 'setTimeout', wrapTimeFn, wrappedBuiltIns); | |
fill(_window, 'setInterval', wrapTimeFn, wrappedBuiltIns); | |
if (_window.requestAnimationFrame) { | |
fill(_window, 'requestAnimationFrame', function (orig) { | |
return function (cb) { | |
return orig(self.wrap(cb)); | |
}; | |
}, wrappedBuiltIns); | |
} | |
// event targets borrowed from bugsnag-js: | |
// https://github.com/bugsnag/bugsnag-js/blob/master/src/bugsnag.js#L666 | |
var eventTargets = ['EventTarget', 'Window', 'Node', 'ApplicationCache', 'AudioTrackList', 'ChannelMergerNode', 'CryptoOperation', 'EventSource', 'FileReader', 'HTMLUnknownElement', 'IDBDatabase', 'IDBRequest', 'IDBTransaction', 'KeyOperation', 'MediaController', 'MessagePort', 'ModalWindow', 'Notification', 'SVGElementInstance', 'Screen', 'TextTrack', 'TextTrackCue', 'TextTrackList', 'WebSocket', 'WebSocketWorker', 'Worker', 'XMLHttpRequest', 'XMLHttpRequestEventTarget', 'XMLHttpRequestUpload']; | |
for (var i = 0; i < eventTargets.length; i++) { | |
wrapEventTarget(eventTargets[i]); | |
} | |
var $ = _window.jQuery || _window.$; | |
if ($ && $.fn && $.fn.ready) { | |
fill($.fn, 'ready', function (orig) { | |
return function (fn) { | |
return orig.call(this, self.wrap(fn)); | |
}; | |
}, wrappedBuiltIns); | |
} | |
}, | |
/** | |
* Instrument browser built-ins w/ breadcrumb capturing | |
* - XMLHttpRequests | |
* - DOM interactions (click/typing) | |
* - window.location changes | |
* - console | |
* | |
* Can be disabled or individually configured via the `autoBreadcrumbs` config option | |
*/ | |
_instrumentBreadcrumbs: function () { | |
var self = this; | |
var autoBreadcrumbs = this._globalOptions.autoBreadcrumbs; | |
var wrappedBuiltIns = self._wrappedBuiltIns; | |
function wrapProp(prop, xhr) { | |
if (prop in xhr && isFunction(xhr[prop])) { | |
fill(xhr, prop, function (orig) { | |
return self.wrap(orig); | |
}); // intentionally don't track filled methods on XHR instances | |
} | |
} | |
if (autoBreadcrumbs.xhr && 'XMLHttpRequest' in _window) { | |
var xhrproto = XMLHttpRequest.prototype; | |
fill(xhrproto, 'open', function(origOpen) { | |
return function (method, url) { // preserve arity | |
// if Sentry key appears in URL, don't capture | |
if (isString(url) && url.indexOf(self._globalKey) === -1) { | |
this.__raven_xhr = { | |
method: method, | |
url: url, | |
status_code: null | |
}; | |
} | |
return origOpen.apply(this, arguments); | |
}; | |
}, wrappedBuiltIns); | |
fill(xhrproto, 'send', function(origSend) { | |
return function (data) { // preserve arity | |
var xhr = this; | |
function onreadystatechangeHandler() { | |
if (xhr.__raven_xhr && (xhr.readyState === 1 || xhr.readyState === 4)) { | |
try { | |
// touching statusCode in some platforms throws | |
// an exception | |
xhr.__raven_xhr.status_code = xhr.status; | |
} catch (e) { /* do nothing */ } | |
self.captureBreadcrumb({ | |
type: 'http', | |
category: 'xhr', | |
data: xhr.__raven_xhr | |
}); | |
} | |
} | |
var props = ['onload', 'onerror', 'onprogress']; | |
for (var j = 0; j < props.length; j++) { | |
wrapProp(props[j], xhr); | |
} | |
if ('onreadystatechange' in xhr && isFunction(xhr.onreadystatechange)) { | |
fill(xhr, 'onreadystatechange', function (orig) { | |
return self.wrap(orig, undefined, onreadystatechangeHandler); | |
} /* intentionally don't track this instrumentation */); | |
} else { | |
// if onreadystatechange wasn't actually set by the page on this xhr, we | |
// are free to set our own and capture the breadcrumb | |
xhr.onreadystatechange = onreadystatechangeHandler; | |
} | |
return origSend.apply(this, arguments); | |
}; | |
}, wrappedBuiltIns); | |
} | |
if (autoBreadcrumbs.xhr && 'fetch' in _window) { | |
fill(_window, 'fetch', function(origFetch) { | |
return function (fn, t) { // preserve arity | |
// Make a copy of the arguments to prevent deoptimization | |
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments | |
var args = new Array(arguments.length); | |
for(var i = 0; i < args.length; ++i) { | |
args[i] = arguments[i]; | |
} | |
var method = 'GET'; | |
if (args[1] && args[1].method) { | |
method = args[1].method; | |
} | |
var fetchData = { | |
method: method, | |
url: args[0], | |
status_code: null | |
}; | |
self.captureBreadcrumb({ | |
type: 'http', | |
category: 'fetch', | |
data: fetchData | |
}); | |
return origFetch.apply(this, args).then(function (response) { | |
fetchData.status_code = response.status; | |
return response; | |
}); | |
}; | |
}, wrappedBuiltIns); | |
} | |
// Capture breadcrumbs from any click that is unhandled / bubbled up all the way | |
// to the document. Do this before we instrument addEventListener. | |
if (autoBreadcrumbs.dom && this._hasDocument) { | |
if (_document.addEventListener) { | |
_document.addEventListener('click', self._breadcrumbEventHandler('click'), false); | |
_document.addEventListener('keypress', self._keypressEventHandler(), false); | |
} | |
else { | |
// IE8 Compatibility | |
_document.attachEvent('onclick', self._breadcrumbEventHandler('click')); | |
_document.attachEvent('onkeypress', self._keypressEventHandler()); | |
} | |
} | |
// record navigation (URL) changes | |
// NOTE: in Chrome App environment, touching history.pushState, *even inside | |
// a try/catch block*, will cause Chrome to output an error to console.error | |
// borrowed from: https://github.com/angular/angular.js/pull/13945/files | |
var chrome = _window.chrome; | |
var isChromePackagedApp = chrome && chrome.app && chrome.app.runtime; | |
var hasPushState = !isChromePackagedApp && _window.history && history.pushState; | |
if (autoBreadcrumbs.location && hasPushState) { | |
// TODO: remove onpopstate handler on uninstall() | |
var oldOnPopState = _window.onpopstate; | |
_window.onpopstate = function () { | |
var currentHref = self._location.href; | |
self._captureUrlChange(self._lastHref, currentHref); | |
if (oldOnPopState) { | |
return oldOnPopState.apply(this, arguments); | |
} | |
}; | |
fill(history, 'pushState', function (origPushState) { | |
// note history.pushState.length is 0; intentionally not declaring | |
// params to preserve 0 arity | |
return function (/* state, title, url */) { | |
var url = arguments.length > 2 ? arguments[2] : undefined; | |
// url argument is optional | |
if (url) { | |
// coerce to string (this is what pushState does) | |
self._captureUrlChange(self._lastHref, url + ''); | |
} | |
return origPushState.apply(this, arguments); | |
}; | |
}, wrappedBuiltIns); | |
} | |
if (autoBreadcrumbs.console && 'console' in _window && console.log) { | |
// console | |
var consoleMethodCallback = function (msg, data) { | |
self.captureBreadcrumb({ | |
message: msg, | |
level: data.level, | |
category: 'console' | |
}); | |
}; | |
each(['debug', 'info', 'warn', 'error', 'log'], function (_, level) { | |
wrapConsoleMethod(console, level, consoleMethodCallback); | |
}); | |
} | |
}, | |
_restoreBuiltIns: function () { | |
// restore any wrapped builtins | |
var builtin; | |
while (this._wrappedBuiltIns.length) { | |
builtin = this._wrappedBuiltIns.shift(); | |
var obj = builtin[0], | |
name = builtin[1], | |
orig = builtin[2]; | |
obj[name] = orig; | |
} | |
}, | |
_drainPlugins: function() { | |
var self = this; | |
// FIX ME TODO | |
each(this._plugins, function(_, plugin) { | |
var installer = plugin[0]; | |
var args = plugin[1]; | |
installer.apply(self, [self].concat(args)); | |
}); | |
}, | |
_parseDSN: function(str) { | |
var m = dsnPattern.exec(str), | |
dsn = {}, | |
i = 7; | |
try { | |
while (i--) dsn[dsnKeys[i]] = m[i] || ''; | |
} catch(e) { | |
throw new RavenConfigError('Invalid DSN: ' + str); | |
} | |
if (dsn.pass && !this._globalOptions.allowSecretKey) { | |
throw new RavenConfigError('Do not specify your secret key in the DSN. See: http://bit.ly/raven-secret-key'); | |
} | |
return dsn; | |
}, | |
_getGlobalServer: function(uri) { | |
// assemble the endpoint from the uri pieces | |
var globalServer = '//' + uri.host + | |
(uri.port ? ':' + uri.port : ''); | |
if (uri.protocol) { | |
globalServer = uri.protocol + ':' + globalServer; | |
} | |
return globalServer; | |
}, | |
_handleOnErrorStackInfo: function() { | |
// if we are intentionally ignoring errors via onerror, bail out | |
if (!this._ignoreOnError) { | |
this._handleStackInfo.apply(this, arguments); | |
} | |
}, | |
_handleStackInfo: function(stackInfo, options) { | |
var frames = this._prepareFrames(stackInfo, options); | |
this._triggerEvent('handle', { | |
stackInfo: stackInfo, | |
options: options | |
}); | |
this._processException( | |
stackInfo.name, | |
stackInfo.message, | |
stackInfo.url, | |
stackInfo.lineno, | |
frames, | |
options | |
); | |
}, | |
_prepareFrames: function(stackInfo, options) { | |
var self = this; | |
var frames = []; | |
if (stackInfo.stack && stackInfo.stack.length) { | |
each(stackInfo.stack, function(i, stack) { | |
var frame = self._normalizeFrame(stack); | |
if (frame) { | |
frames.push(frame); | |
} | |
}); | |
// e.g. frames captured via captureMessage throw | |
if (options && options.trimHeadFrames) { | |
for (var j = 0; j < options.trimHeadFrames && j < frames.length; j++) { | |
frames[j].in_app = false; | |
} | |
} | |
} | |
frames = frames.slice(0, this._globalOptions.stackTraceLimit); | |
return frames; | |
}, | |
_normalizeFrame: function(frame) { | |
if (!frame.url) return; | |
// normalize the frames data | |
var normalized = { | |
filename: frame.url, | |
lineno: frame.line, | |
colno: frame.column, | |
'function': frame.func || '?' | |
}; | |
normalized.in_app = !( // determine if an exception came from outside of our app | |
// first we check the global includePaths list. | |
!!this._globalOptions.includePaths.test && !this._globalOptions.includePaths.test(normalized.filename) || | |
// Now we check for fun, if the function name is Raven or TraceKit | |
/(Raven|TraceKit)\./.test(normalized['function']) || | |
// finally, we do a last ditch effort and check for raven.min.js | |
/raven\.(min\.)?js$/.test(normalized.filename) | |
); | |
return normalized; | |
}, | |
_processException: function(type, message, fileurl, lineno, frames, options) { | |
var stacktrace; | |
if (!!this._globalOptions.ignoreErrors.test && this._globalOptions.ignoreErrors.test(message)) return; | |
message += ''; | |
if (frames && frames.length) { | |
fileurl = frames[0].filename || fileurl; | |
// Sentry expects frames oldest to newest | |
// and JS sends them as newest to oldest | |
frames.reverse(); | |
stacktrace = {frames: frames}; | |
} else if (fileurl) { | |
stacktrace = { | |
frames: [{ | |
filename: fileurl, | |
lineno: lineno, | |
in_app: true | |
}] | |
}; | |
} | |
if (!!this._globalOptions.ignoreUrls.test && this._globalOptions.ignoreUrls.test(fileurl)) return; | |
if (!!this._globalOptions.whitelistUrls.test && !this._globalOptions.whitelistUrls.test(fileurl)) return; | |
var data = objectMerge({ | |
// sentry.interfaces.Exception | |
exception: { | |
values: [{ | |
type: type, | |
value: message, | |
stacktrace: stacktrace | |
}] | |
}, | |
culprit: fileurl | |
}, options); | |
// Fire away! | |
this._send(data); | |
}, | |
_trimPacket: function(data) { | |
// For now, we only want to truncate the two different messages | |
// but this could/should be expanded to just trim everything | |
var max = this._globalOptions.maxMessageLength; | |
if (data.message) { | |
data.message = truncate(data.message, max); | |
} | |
if (data.exception) { | |
var exception = data.exception.values[0]; | |
exception.value = truncate(exception.value, max); | |
} | |
return data; | |
}, | |
_getHttpData: function() { | |
if (!this._hasDocument || !_document.location || !_document.location.href) { | |
return; | |
} | |
var httpData = { | |
headers: { | |
'User-Agent': navigator.userAgent | |
} | |
}; | |
httpData.url = _document.location.href; | |
if (_document.referrer) { | |
httpData.headers.Referer = _document.referrer; | |
} | |
return httpData; | |
}, | |
_send: function(data) { | |
var globalOptions = this._globalOptions; | |
var baseData = { | |
project: this._globalProject, | |
logger: globalOptions.logger, | |
platform: 'javascript' | |
}, httpData = this._getHttpData(); | |
if (httpData) { | |
baseData.request = httpData; | |
} | |
// HACK: delete `trimHeadFrames` to prevent from appearing in outbound payload | |
if (data.trimHeadFrames) delete data.trimHeadFrames; | |
data = objectMerge(baseData, data); | |
// Merge in the tags and extra separately since objectMerge doesn't handle a deep merge | |
data.tags = objectMerge(objectMerge({}, this._globalContext.tags), data.tags); | |
data.extra = objectMerge(objectMerge({}, this._globalContext.extra), data.extra); | |
// Send along our own collected metadata with extra | |
data.extra['session:duration'] = now() - this._startTime; | |
if (this._breadcrumbs && this._breadcrumbs.length > 0) { | |
// intentionally make shallow copy so that additions | |
// to breadcrumbs aren't accidentally sent in this request | |
data.breadcrumbs = { | |
values: [].slice.call(this._breadcrumbs, 0) | |
}; | |
} | |
// If there are no tags/extra, strip the key from the payload alltogther. | |
if (isEmptyObject(data.tags)) delete data.tags; | |
if (this._globalContext.user) { | |
// sentry.interfaces.User | |
data.user = this._globalContext.user; | |
} | |
// Include the environment if it's defined in globalOptions | |
if (globalOptions.environment) data.environment = globalOptions.environment; | |
// Include the release if it's defined in globalOptions | |
if (globalOptions.release) data.release = globalOptions.release; | |
// Include server_name if it's defined in globalOptions | |
if (globalOptions.serverName) data.server_name = globalOptions.serverName; | |
if (isFunction(globalOptions.dataCallback)) { | |
data = globalOptions.dataCallback(data) || data; | |
} | |
// Why?????????? | |
if (!data || isEmptyObject(data)) { | |
return; | |
} | |
// Check if the request should be filtered or not | |
if (isFunction(globalOptions.shouldSendCallback) && !globalOptions.shouldSendCallback(data)) { | |
return; | |
} | |
this._sendProcessedPayload(data); | |
}, | |
_getUuid: function () { | |
return uuid4(); | |
}, | |
_sendProcessedPayload: function(data, callback) { | |
var self = this; | |
var globalOptions = this._globalOptions; | |
// Send along an event_id if not explicitly passed. | |
// This event_id can be used to reference the error within Sentry itself. | |
// Set lastEventId after we know the error should actually be sent | |
this._lastEventId = data.event_id || (data.event_id = this._getUuid()); | |
// Try and clean up the packet before sending by truncating long values | |
data = this._trimPacket(data); | |
this._logDebug('debug', 'Raven about to send:', data); | |
if (!this.isSetup()) return; | |
var auth = { | |
sentry_version: '7', | |
sentry_client: 'raven-js/' + this.VERSION, | |
sentry_key: this._globalKey | |
}; | |
if (this._globalSecret) { | |
auth.sentry_secret = this._globalSecret; | |
} | |
var exception = data.exception && data.exception.values[0]; | |
this.captureBreadcrumb({ | |
category: 'sentry', | |
message: exception | |
? (exception.type ? exception.type + ': ' : '') + exception.value | |
: data.message, | |
event_id: data.event_id, | |
level: data.level || 'error' // presume error unless specified | |
}); | |
var url = this._globalEndpoint; | |
(globalOptions.transport || this._makeRequest).call(this, { | |
url: url, | |
auth: auth, | |
data: data, | |
options: globalOptions, | |
onSuccess: function success() { | |
self._triggerEvent('success', { | |
data: data, | |
src: url | |
}); | |
callback && callback(); | |
}, | |
onError: function failure(error) { | |
self._triggerEvent('failure', { | |
data: data, | |
src: url | |
}); | |
error = error || new Error('Raven send failed (no additional details provided)'); | |
callback && callback(error); | |
} | |
}); | |
}, | |
_makeRequest: function(opts) { | |
var request = new XMLHttpRequest(); | |
// if browser doesn't support CORS (e.g. IE7), we are out of luck | |
var hasCORS = | |
'withCredentials' in request || | |
typeof XDomainRequest !== 'undefined'; | |
if (!hasCORS) return; | |
var url = opts.url; | |
function handler() { | |
if (request.status === 200) { | |
if (opts.onSuccess) { | |
opts.onSuccess(); | |
} | |
} else if (opts.onError) { | |
opts.onError(new Error('Sentry error code: ' + request.status)); | |
} | |
} | |
if ('withCredentials' in request) { | |
request.onreadystatechange = function () { | |
if (request.readyState !== 4) { | |
return; | |
} | |
handler(); | |
}; | |
} else { | |
request = new XDomainRequest(); | |
// xdomainrequest cannot go http -> https (or vice versa), | |
// so always use protocol relative | |
url = url.replace(/^https?:/, ''); | |
// onreadystatechange not supported by XDomainRequest | |
request.onload = handler; | |
} | |
// NOTE: auth is intentionally sent as part of query string (NOT as custom | |
// HTTP header) so as to avoid preflight CORS requests | |
request.open('POST', url + '?' + urlencode(opts.auth)); | |
request.send(stringify(opts.data)); | |
}, | |
_logDebug: function(level) { | |
if (this._originalConsoleMethods[level] && this.debug) { | |
// In IE<10 console methods do not have their own 'apply' method | |
Function.prototype.apply.call( | |
this._originalConsoleMethods[level], | |
this._originalConsole, | |
[].slice.call(arguments, 1) | |
); | |
} | |
}, | |
_mergeContext: function(key, context) { | |
if (isUndefined(context)) { | |
delete this._globalContext[key]; | |
} else { | |
this._globalContext[key] = objectMerge(this._globalContext[key] || {}, context); | |
} | |
} | |
}; | |
/*------------------------------------------------ | |
* utils | |
* | |
* conditionally exported for test via Raven.utils | |
================================================= | |
*/ | |
var objectPrototype = Object.prototype; | |
function isUndefined(what) { | |
return what === void 0; | |
} | |
function isFunction(what) { | |
return typeof what === 'function'; | |
} | |
function isString(what) { | |
return objectPrototype.toString.call(what) === '[object String]'; | |
} | |
function isObject(what) { | |
return typeof what === 'object' && what !== null; | |
} | |
function isEmptyObject(what) { | |
for (var _ in what) return false; // eslint-disable-line guard-for-in, no-unused-vars | |
return true; | |
} | |
// Sorta yanked from https://github.com/joyent/node/blob/aa3b4b4/lib/util.js#L560 | |
// with some tiny modifications | |
function isError(what) { | |
var toString = objectPrototype.toString.call(what); | |
return isObject(what) && | |
toString === '[object Error]' || | |
toString === '[object Exception]' || // Firefox NS_ERROR_FAILURE Exceptions | |
what instanceof Error; | |
} | |
function each(obj, callback) { | |
var i, j; | |
if (isUndefined(obj.length)) { | |
for (i in obj) { | |
if (hasKey(obj, i)) { | |
callback.call(null, i, obj[i]); | |
} | |
} | |
} else { | |
j = obj.length; | |
if (j) { | |
for (i = 0; i < j; i++) { | |
callback.call(null, i, obj[i]); | |
} | |
} | |
} | |
} | |
function objectMerge(obj1, obj2) { | |
if (!obj2) { | |
return obj1; | |
} | |
each(obj2, function(key, value){ | |
obj1[key] = value; | |
}); | |
return obj1; | |
} | |
function truncate(str, max) { | |
return !max || str.length <= max ? str : str.substr(0, max) + '\u2026'; | |
} | |
/** | |
* hasKey, a better form of hasOwnProperty | |
* Example: hasKey(MainHostObject, property) === true/false | |
* | |
* @param {Object} host object to check property | |
* @param {string} key to check | |
*/ | |
function hasKey(object, key) { | |
return objectPrototype.hasOwnProperty.call(object, key); | |
} | |
function joinRegExp(patterns) { | |
// Combine an array of regular expressions and strings into one large regexp | |
// Be mad. | |
var sources = [], | |
i = 0, len = patterns.length, | |
pattern; | |
for (; i < len; i++) { | |
pattern = patterns[i]; | |
if (isString(pattern)) { | |
// If it's a string, we need to escape it | |
// Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions | |
sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1')); | |
} else if (pattern && pattern.source) { | |
// If it's a regexp already, we want to extract the source | |
sources.push(pattern.source); | |
} | |
// Intentionally skip other cases | |
} | |
return new RegExp(sources.join('|'), 'i'); | |
} | |
function urlencode(o) { | |
var pairs = []; | |
each(o, function(key, value) { | |
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); | |
}); | |
return pairs.join('&'); | |
} | |
// borrowed from https://tools.ietf.org/html/rfc3986#appendix-B | |
// intentionally using regex and not <a/> href parsing trick because React Native and other | |
// environments where DOM might not be available | |
function parseUrl(url) { | |
var match = url.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/); | |
if (!match) return {}; | |
// coerce to undefined values to empty string so we don't get 'undefined' | |
var query = match[6] || ''; | |
var fragment = match[8] || ''; | |
return { | |
protocol: match[2], | |
host: match[4], | |
path: match[5], | |
relative: match[5] + query + fragment // everything minus origin | |
}; | |
} | |
function uuid4() { | |
var crypto = _window.crypto || _window.msCrypto; | |
if (!isUndefined(crypto) && crypto.getRandomValues) { | |
// Use window.crypto API if available | |
var arr = new Uint16Array(8); | |
crypto.getRandomValues(arr); | |
// set 4 in byte 7 | |
arr[3] = arr[3] & 0xFFF | 0x4000; | |
// set 2 most significant bits of byte 9 to '10' | |
arr[4] = arr[4] & 0x3FFF | 0x8000; | |
var pad = function(num) { | |
var v = num.toString(16); | |
while (v.length < 4) { | |
v = '0' + v; | |
} | |
return v; | |
}; | |
return pad(arr[0]) + pad(arr[1]) + pad(arr[2]) + pad(arr[3]) + pad(arr[4]) + | |
pad(arr[5]) + pad(arr[6]) + pad(arr[7]); | |
} else { | |
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523 | |
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random()*16|0, | |
v = c === 'x' ? r : r&0x3|0x8; | |
return v.toString(16); | |
}); | |
} | |
} | |
/** | |
* Given a child DOM element, returns a query-selector statement describing that | |
* and its ancestors | |
* e.g. [HTMLElement] => body > div > input#foo.btn[name=baz] | |
* @param elem | |
* @returns {string} | |
*/ | |
function htmlTreeAsString(elem) { | |
/* eslint no-extra-parens:0*/ | |
var MAX_TRAVERSE_HEIGHT = 5, | |
MAX_OUTPUT_LEN = 80, | |
out = [], | |
height = 0, | |
len = 0, | |
separator = ' > ', | |
sepLength = separator.length, | |
nextStr; | |
while (elem && height++ < MAX_TRAVERSE_HEIGHT) { | |
nextStr = htmlElementAsString(elem); | |
// bail out if | |
// - nextStr is the 'html' element | |
// - the length of the string that would be created exceeds MAX_OUTPUT_LEN | |
// (ignore this limit if we are on the first iteration) | |
if (nextStr === 'html' || height > 1 && len + (out.length * sepLength) + nextStr.length >= MAX_OUTPUT_LEN) { | |
break; | |
} | |
out.push(nextStr); | |
len += nextStr.length; | |
elem = elem.parentNode; | |
} | |
return out.reverse().join(separator); | |
} | |
/** | |
* Returns a simple, query-selector representation of a DOM element | |
* e.g. [HTMLElement] => input#foo.btn[name=baz] | |
* @param HTMLElement | |
* @returns {string} | |
*/ | |
function htmlElementAsString(elem) { | |
var out = [], | |
className, | |
classes, | |
key, | |
attr, | |
i; | |
if (!elem || !elem.tagName) { | |
return ''; | |
} | |
out.push(elem.tagName.toLowerCase()); | |
if (elem.id) { | |
out.push('#' + elem.id); | |
} | |
className = elem.className; | |
if (className && isString(className)) { | |
classes = className.split(' '); | |
for (i = 0; i < classes.length; i++) { | |
out.push('.' + classes[i]); | |
} | |
} | |
var attrWhitelist = ['type', 'name', 'title', 'alt']; | |
for (i = 0; i < attrWhitelist.length; i++) { | |
key = attrWhitelist[i]; | |
attr = elem.getAttribute(key); | |
if (attr) { | |
out.push('[' + key + '="' + attr + '"]'); | |
} | |
} | |
return out.join(''); | |
} | |
/** | |
* Polyfill a method | |
* @param obj object e.g. `document` | |
* @param name method name present on object e.g. `addEventListener` | |
* @param replacement replacement function | |
* @param track {optional} record instrumentation to an array | |
*/ | |
function fill(obj, name, replacement, track) { | |
var orig = obj[name]; | |
obj[name] = replacement(orig); | |
if (track) { | |
track.push([obj, name, orig]); | |
} | |
} | |
if (typeof __DEV__ !== 'undefined' && __DEV__) { | |
Raven.utils = { | |
isUndefined: isUndefined, | |
isFunction: isFunction, | |
isString: isString, | |
isObject: isObject, | |
isEmptyObject: isEmptyObject, | |
isError: isError, | |
each: each, | |
objectMerge: objectMerge, | |
truncate: truncate, | |
hasKey: hasKey, | |
joinRegExp: joinRegExp, | |
urlencode: urlencode, | |
uuid4: uuid4, | |
htmlTreeAsString: htmlTreeAsString, | |
htmlElementAsString: htmlElementAsString, | |
parseUrl: parseUrl, | |
fill: fill | |
}; | |
}; | |
// Deprecations | |
Raven.prototype.setUser = Raven.prototype.setUserContext; | |
Raven.prototype.setReleaseContext = Raven.prototype.setRelease; | |
module.exports = Raven; | |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33))) | |
/***/ }), | |
/* 136 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
/* WEBPACK VAR INJECTION */(function(global) { | |
/* | |
TraceKit - Cross brower stack traces - github.com/occ/TraceKit | |
MIT license | |
*/ | |
var TraceKit = { | |
collectWindowErrors: true, | |
debug: false | |
}; | |
// This is to be defensive in environments where window does not exist (see https://github.com/getsentry/raven-js/pull/785) | |
var _window = typeof window !== 'undefined' ? window | |
: typeof global !== 'undefined' ? global | |
: typeof self !== 'undefined' ? self | |
: {}; | |
// global reference to slice | |
var _slice = [].slice; | |
var UNKNOWN_FUNCTION = '?'; | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types | |
var ERROR_TYPES_RE = /^(?:Uncaught (?:exception: )?)?((?:Eval|Internal|Range|Reference|Syntax|Type|URI)Error): ?(.*)$/; | |
function getLocationHref() { | |
if (typeof document === 'undefined') | |
return ''; | |
return document.location.href; | |
} | |
/** | |
* TraceKit.report: cross-browser processing of unhandled exceptions | |
* | |
* Syntax: | |
* TraceKit.report.subscribe(function(stackInfo) { ... }) | |
* TraceKit.report.unsubscribe(function(stackInfo) { ... }) | |
* TraceKit.report(exception) | |
* try { ...code... } catch(ex) { TraceKit.report(ex); } | |
* | |
* Supports: | |
* - Firefox: full stack trace with line numbers, plus column number | |
* on top frame; column number is not guaranteed | |
* - Opera: full stack trace with line and column numbers | |
* - Chrome: full stack trace with line and column numbers | |
* - Safari: line and column number for the top frame only; some frames | |
* may be missing, and column number is not guaranteed | |
* - IE: line and column number for the top frame only; some frames | |
* may be missing, and column number is not guaranteed | |
* | |
* In theory, TraceKit should work on all of the following versions: | |
* - IE5.5+ (only 8.0 tested) | |
* - Firefox 0.9+ (only 3.5+ tested) | |
* - Opera 7+ (only 10.50 tested; versions 9 and earlier may require | |
* Exceptions Have Stacktrace to be enabled in opera:config) | |
* - Safari 3+ (only 4+ tested) | |
* - Chrome 1+ (only 5+ tested) | |
* - Konqueror 3.5+ (untested) | |
* | |
* Requires TraceKit.computeStackTrace. | |
* | |
* Tries to catch all unhandled exceptions and report them to the | |
* subscribed handlers. Please note that TraceKit.report will rethrow the | |
* exception. This is REQUIRED in order to get a useful stack trace in IE. | |
* If the exception does not reach the top of the browser, you will only | |
* get a stack trace from the point where TraceKit.report was called. | |
* | |
* Handlers receive a stackInfo object as described in the | |
* TraceKit.computeStackTrace docs. | |
*/ | |
TraceKit.report = (function reportModuleWrapper() { | |
var handlers = [], | |
lastArgs = null, | |
lastException = null, | |
lastExceptionStack = null; | |
/** | |
* Add a crash handler. | |
* @param {Function} handler | |
*/ | |
function subscribe(handler) { | |
installGlobalHandler(); | |
handlers.push(handler); | |
} | |
/** | |
* Remove a crash handler. | |
* @param {Function} handler | |
*/ | |
function unsubscribe(handler) { | |
for (var i = handlers.length - 1; i >= 0; --i) { | |
if (handlers[i] === handler) { | |
handlers.splice(i, 1); | |
} | |
} | |
} | |
/** | |
* Remove all crash handlers. | |
*/ | |
function unsubscribeAll() { | |
uninstallGlobalHandler(); | |
handlers = []; | |
} | |
/** | |
* Dispatch stack information to all handlers. | |
* @param {Object.<string, *>} stack | |
*/ | |
function notifyHandlers(stack, isWindowError) { | |
var exception = null; | |
if (isWindowError && !TraceKit.collectWindowErrors) { | |
return; | |
} | |
for (var i in handlers) { | |
if (handlers.hasOwnProperty(i)) { | |
try { | |
handlers[i].apply(null, [stack].concat(_slice.call(arguments, 2))); | |
} catch (inner) { | |
exception = inner; | |
} | |
} | |
} | |
if (exception) { | |
throw exception; | |
} | |
} | |
var _oldOnerrorHandler, _onErrorHandlerInstalled; | |
/** | |
* Ensures all global unhandled exceptions are recorded. | |
* Supported by Gecko and IE. | |
* @param {string} message Error message. | |
* @param {string} url URL of script that generated the exception. | |
* @param {(number|string)} lineNo The line number at which the error | |
* occurred. | |
* @param {?(number|string)} colNo The column number at which the error | |
* occurred. | |
* @param {?Error} ex The actual Error object. | |
*/ | |
function traceKitWindowOnError(message, url, lineNo, colNo, ex) { | |
var stack = null; | |
if (lastExceptionStack) { | |
TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message); | |
processLastException(); | |
} else if (ex) { | |
// New chrome and blink send along a real error object | |
// Let's just report that like a normal error. | |
// See: https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror | |
stack = TraceKit.computeStackTrace(ex); | |
notifyHandlers(stack, true); | |
} else { | |
var location = { | |
'url': url, | |
'line': lineNo, | |
'column': colNo | |
}; | |
var name = undefined; | |
var msg = message; // must be new var or will modify original `arguments` | |
var groups; | |
if ({}.toString.call(message) === '[object String]') { | |
var groups = message.match(ERROR_TYPES_RE); | |
if (groups) { | |
name = groups[1]; | |
msg = groups[2]; | |
} | |
} | |
location.func = UNKNOWN_FUNCTION; | |
stack = { | |
'name': name, | |
'message': msg, | |
'url': getLocationHref(), | |
'stack': [location] | |
}; | |
notifyHandlers(stack, true); | |
} | |
if (_oldOnerrorHandler) { | |
return _oldOnerrorHandler.apply(this, arguments); | |
} | |
return false; | |
} | |
function installGlobalHandler () | |
{ | |
if (_onErrorHandlerInstalled) { | |
return; | |
} | |
_oldOnerrorHandler = _window.onerror; | |
_window.onerror = traceKitWindowOnError; | |
_onErrorHandlerInstalled = true; | |
} | |
function uninstallGlobalHandler () | |
{ | |
if (!_onErrorHandlerInstalled) { | |
return; | |
} | |
_window.onerror = _oldOnerrorHandler; | |
_onErrorHandlerInstalled = false; | |
_oldOnerrorHandler = undefined; | |
} | |
function processLastException() { | |
var _lastExceptionStack = lastExceptionStack, | |
_lastArgs = lastArgs; | |
lastArgs = null; | |
lastExceptionStack = null; | |
lastException = null; | |
notifyHandlers.apply(null, [_lastExceptionStack, false].concat(_lastArgs)); | |
} | |
/** | |
* Reports an unhandled Error to TraceKit. | |
* @param {Error} ex | |
* @param {?boolean} rethrow If false, do not re-throw the exception. | |
* Only used for window.onerror to not cause an infinite loop of | |
* rethrowing. | |
*/ | |
function report(ex, rethrow) { | |
var args = _slice.call(arguments, 1); | |
if (lastExceptionStack) { | |
if (lastException === ex) { | |
return; // already caught by an inner catch block, ignore | |
} else { | |
processLastException(); | |
} | |
} | |
var stack = TraceKit.computeStackTrace(ex); | |
lastExceptionStack = stack; | |
lastException = ex; | |
lastArgs = args; | |
// If the stack trace is incomplete, wait for 2 seconds for | |
// slow slow IE to see if onerror occurs or not before reporting | |
// this exception; otherwise, we will end up with an incomplete | |
// stack trace | |
setTimeout(function () { | |
if (lastException === ex) { | |
processLastException(); | |
} | |
}, (stack.incomplete ? 2000 : 0)); | |
if (rethrow !== false) { | |
throw ex; // re-throw to propagate to the top level (and cause window.onerror) | |
} | |
} | |
report.subscribe = subscribe; | |
report.unsubscribe = unsubscribe; | |
report.uninstall = unsubscribeAll; | |
return report; | |
}()); | |
/** | |
* TraceKit.computeStackTrace: cross-browser stack traces in JavaScript | |
* | |
* Syntax: | |
* s = TraceKit.computeStackTrace(exception) // consider using TraceKit.report instead (see below) | |
* Returns: | |
* s.name - exception name | |
* s.message - exception message | |
* s.stack[i].url - JavaScript or HTML file URL | |
* s.stack[i].func - function name, or empty for anonymous functions (if guessing did not work) | |
* s.stack[i].args - arguments passed to the function, if known | |
* s.stack[i].line - line number, if known | |
* s.stack[i].column - column number, if known | |
* | |
* Supports: | |
* - Firefox: full stack trace with line numbers and unreliable column | |
* number on top frame | |
* - Opera 10: full stack trace with line and column numbers | |
* - Opera 9-: full stack trace with line numbers | |
* - Chrome: full stack trace with line and column numbers | |
* - Safari: line and column number for the topmost stacktrace element | |
* only | |
* - IE: no line numbers whatsoever | |
* | |
* Tries to guess names of anonymous functions by looking for assignments | |
* in the source code. In IE and Safari, we have to guess source file names | |
* by searching for function bodies inside all page scripts. This will not | |
* work for scripts that are loaded cross-domain. | |
* Here be dragons: some function names may be guessed incorrectly, and | |
* duplicate functions may be mismatched. | |
* | |
* TraceKit.computeStackTrace should only be used for tracing purposes. | |
* Logging of unhandled exceptions should be done with TraceKit.report, | |
* which builds on top of TraceKit.computeStackTrace and provides better | |
* IE support by utilizing the window.onerror event to retrieve information | |
* about the top of the stack. | |
* | |
* Note: In IE and Safari, no stack trace is recorded on the Error object, | |
* so computeStackTrace instead walks its *own* chain of callers. | |
* This means that: | |
* * in Safari, some methods may be missing from the stack trace; | |
* * in IE, the topmost function in the stack trace will always be the | |
* caller of computeStackTrace. | |
* | |
* This is okay for tracing (because you are likely to be calling | |
* computeStackTrace from the function you want to be the topmost element | |
* of the stack trace anyway), but not okay for logging unhandled | |
* exceptions (because your catch block will likely be far away from the | |
* inner function that actually caused the exception). | |
* | |
*/ | |
TraceKit.computeStackTrace = (function computeStackTraceWrapper() { | |
/** | |
* Escapes special characters, except for whitespace, in a string to be | |
* used inside a regular expression as a string literal. | |
* @param {string} text The string. | |
* @return {string} The escaped string literal. | |
*/ | |
function escapeRegExp(text) { | |
return text.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g, '\\$&'); | |
} | |
/** | |
* Escapes special characters in a string to be used inside a regular | |
* expression as a string literal. Also ensures that HTML entities will | |
* be matched the same as their literal friends. | |
* @param {string} body The string. | |
* @return {string} The escaped string. | |
*/ | |
function escapeCodeAsRegExpForMatchingInsideHTML(body) { | |
return escapeRegExp(body).replace('<', '(?:<|<)').replace('>', '(?:>|>)').replace('&', '(?:&|&)').replace('"', '(?:"|")').replace(/\s+/g, '\\s+'); | |
} | |
// Contents of Exception in various browsers. | |
// | |
// SAFARI: | |
// ex.message = Can't find variable: qq | |
// ex.line = 59 | |
// ex.sourceId = 580238192 | |
// ex.sourceURL = http://... | |
// ex.expressionBeginOffset = 96 | |
// ex.expressionCaretOffset = 98 | |
// ex.expressionEndOffset = 98 | |
// ex.name = ReferenceError | |
// | |
// FIREFOX: | |
// ex.message = qq is not defined | |
// ex.fileName = http://... | |
// ex.lineNumber = 59 | |
// ex.columnNumber = 69 | |
// ex.stack = ...stack trace... (see the example below) | |
// ex.name = ReferenceError | |
// | |
// CHROME: | |
// ex.message = qq is not defined | |
// ex.name = ReferenceError | |
// ex.type = not_defined | |
// ex.arguments = ['aa'] | |
// ex.stack = ...stack trace... | |
// | |
// INTERNET EXPLORER: | |
// ex.message = ... | |
// ex.name = ReferenceError | |
// | |
// OPERA: | |
// ex.message = ...message... (see the example below) | |
// ex.name = ReferenceError | |
// ex.opera#sourceloc = 11 (pretty much useless, duplicates the info in ex.message) | |
// ex.stacktrace = n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace' | |
/** | |
* Computes stack trace information from the stack property. | |
* Chrome and Gecko use this property. | |
* @param {Error} ex | |
* @return {?Object.<string, *>} Stack trace information. | |
*/ | |
function computeStackTraceFromStackProp(ex) { | |
if (typeof ex.stack === 'undefined' || !ex.stack) return; | |
var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, | |
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i, | |
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, | |
lines = ex.stack.split('\n'), | |
stack = [], | |
parts, | |
element, | |
reference = /^(.*) is undefined$/.exec(ex.message); | |
for (var i = 0, j = lines.length; i < j; ++i) { | |
if ((parts = chrome.exec(lines[i]))) { | |
var isNative = parts[2] && parts[2].indexOf('native') !== -1; | |
element = { | |
'url': !isNative ? parts[2] : null, | |
'func': parts[1] || UNKNOWN_FUNCTION, | |
'args': isNative ? [parts[2]] : [], | |
'line': parts[3] ? +parts[3] : null, | |
'column': parts[4] ? +parts[4] : null | |
}; | |
} else if ( parts = winjs.exec(lines[i]) ) { | |
element = { | |
'url': parts[2], | |
'func': parts[1] || UNKNOWN_FUNCTION, | |
'args': [], | |
'line': +parts[3], | |
'column': parts[4] ? +parts[4] : null | |
}; | |
} else if ((parts = gecko.exec(lines[i]))) { | |
element = { | |
'url': parts[3], | |
'func': parts[1] || UNKNOWN_FUNCTION, | |
'args': parts[2] ? parts[2].split(',') : [], | |
'line': parts[4] ? +parts[4] : null, | |
'column': parts[5] ? +parts[5] : null | |
}; | |
} else { | |
continue; | |
} | |
if (!element.func && element.line) { | |
element.func = UNKNOWN_FUNCTION; | |
} | |
stack.push(element); | |
} | |
if (!stack.length) { | |
return null; | |
} | |
if (!stack[0].column && typeof ex.columnNumber !== 'undefined') { | |
// FireFox uses this awesome columnNumber property for its top frame | |
// Also note, Firefox's column number is 0-based and everything else expects 1-based, | |
// so adding 1 | |
stack[0].column = ex.columnNumber + 1; | |
} | |
return { | |
'name': ex.name, | |
'message': ex.message, | |
'url': getLocationHref(), | |
'stack': stack | |
}; | |
} | |
/** | |
* Adds information about the first frame to incomplete stack traces. | |
* Safari and IE require this to get complete data on the first frame. | |
* @param {Object.<string, *>} stackInfo Stack trace information from | |
* one of the compute* methods. | |
* @param {string} url The URL of the script that caused an error. | |
* @param {(number|string)} lineNo The line number of the script that | |
* caused an error. | |
* @param {string=} message The error generated by the browser, which | |
* hopefully contains the name of the object that caused the error. | |
* @return {boolean} Whether or not the stack information was | |
* augmented. | |
*/ | |
function augmentStackTraceWithInitialElement(stackInfo, url, lineNo, message) { | |
var initial = { | |
'url': url, | |
'line': lineNo | |
}; | |
if (initial.url && initial.line) { | |
stackInfo.incomplete = false; | |
if (!initial.func) { | |
initial.func = UNKNOWN_FUNCTION; | |
} | |
if (stackInfo.stack.length > 0) { | |
if (stackInfo.stack[0].url === initial.url) { | |
if (stackInfo.stack[0].line === initial.line) { | |
return false; // already in stack trace | |
} else if (!stackInfo.stack[0].line && stackInfo.stack[0].func === initial.func) { | |
stackInfo.stack[0].line = initial.line; | |
return false; | |
} | |
} | |
} | |
stackInfo.stack.unshift(initial); | |
stackInfo.partial = true; | |
return true; | |
} else { | |
stackInfo.incomplete = true; | |
} | |
return false; | |
} | |
/** | |
* Computes stack trace information by walking the arguments.caller | |
* chain at the time the exception occurred. This will cause earlier | |
* frames to be missed but is the only way to get any stack trace in | |
* Safari and IE. The top frame is restored by | |
* {@link augmentStackTraceWithInitialElement}. | |
* @param {Error} ex | |
* @return {?Object.<string, *>} Stack trace information. | |
*/ | |
function computeStackTraceByWalkingCallerChain(ex, depth) { | |
var functionName = /function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i, | |
stack = [], | |
funcs = {}, | |
recursion = false, | |
parts, | |
item, | |
source; | |
for (var curr = computeStackTraceByWalkingCallerChain.caller; curr && !recursion; curr = curr.caller) { | |
if (curr === computeStackTrace || curr === TraceKit.report) { | |
// console.log('skipping internal function'); | |
continue; | |
} | |
item = { | |
'url': null, | |
'func': UNKNOWN_FUNCTION, | |
'line': null, | |
'column': null | |
}; | |
if (curr.name) { | |
item.func = curr.name; | |
} else if ((parts = functionName.exec(curr.toString()))) { | |
item.func = parts[1]; | |
} | |
if (typeof item.func === 'undefined') { | |
try { | |
item.func = parts.input.substring(0, parts.input.indexOf('{')); | |
} catch (e) { } | |
} | |
if (funcs['' + curr]) { | |
recursion = true; | |
}else{ | |
funcs['' + curr] = true; | |
} | |
stack.push(item); | |
} | |
if (depth) { | |
// console.log('depth is ' + depth); | |
// console.log('stack is ' + stack.length); | |
stack.splice(0, depth); | |
} | |
var result = { | |
'name': ex.name, | |
'message': ex.message, | |
'url': getLocationHref(), | |
'stack': stack | |
}; | |
augmentStackTraceWithInitialElement(result, ex.sourceURL || ex.fileName, ex.line || ex.lineNumber, ex.message || ex.description); | |
return result; | |
} | |
/** | |
* Computes a stack trace for an exception. | |
* @param {Error} ex | |
* @param {(string|number)=} depth | |
*/ | |
function computeStackTrace(ex, depth) { | |
var stack = null; | |
depth = (depth == null ? 0 : +depth); | |
try { | |
stack = computeStackTraceFromStackProp(ex); | |
if (stack) { | |
return stack; | |
} | |
} catch (e) { | |
if (TraceKit.debug) { | |
throw e; | |
} | |
} | |
try { | |
stack = computeStackTraceByWalkingCallerChain(ex, depth + 1); | |
if (stack) { | |
return stack; | |
} | |
} catch (e) { | |
if (TraceKit.debug) { | |
throw e; | |
} | |
} | |
return { | |
'name': ex.name, | |
'message': ex.message, | |
'url': getLocationHref() | |
}; | |
} | |
computeStackTrace.augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement; | |
computeStackTrace.computeStackTraceFromStackProp = computeStackTraceFromStackProp; | |
return computeStackTrace; | |
}()); | |
module.exports = TraceKit; | |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33))) | |
/***/ }), | |
/* 137 */ | |
/***/ (function(module, exports) { | |
/** | |
* Copyright 2015 Google Inc. All rights reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
* | |
*/ | |
(function() { | |
var nativeAddAll = Cache.prototype.addAll; | |
var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/); | |
// Has nice behavior of `var` which everyone hates | |
if (userAgent) { | |
var agent = userAgent[1]; | |
var version = parseInt(userAgent[2]); | |
} | |
if ( | |
nativeAddAll && (!userAgent || | |
(agent === 'Firefox' && version >= 46) || | |
(agent === 'Chrome' && version >= 50) | |
) | |
) { | |
return; | |
} | |
Cache.prototype.addAll = function addAll(requests) { | |
var cache = this; | |
// Since DOMExceptions are not constructable: | |
function NetworkError(message) { | |
this.name = 'NetworkError'; | |
this.code = 19; | |
this.message = message; | |
} | |
NetworkError.prototype = Object.create(Error.prototype); | |
return Promise.resolve().then(function() { | |
if (arguments.length < 1) throw new TypeError(); | |
// Simulate sequence<(Request or USVString)> binding: | |
var sequence = []; | |
requests = requests.map(function(request) { | |
if (request instanceof Request) { | |
return request; | |
} | |
else { | |
return String(request); // may throw TypeError | |
} | |
}); | |
return Promise.all( | |
requests.map(function(request) { | |
if (typeof request === 'string') { | |
request = new Request(request); | |
} | |
var scheme = new URL(request.url).protocol; | |
if (scheme !== 'http:' && scheme !== 'https:') { | |
throw new NetworkError("Invalid scheme"); | |
} | |
return fetch(request.clone()); | |
}) | |
); | |
}).then(function(responses) { | |
// If some of the responses has not OK-eish status, | |
// then whole operation should reject | |
if (responses.some(function(response) { | |
return !response.ok; | |
})) { | |
throw new NetworkError('Incorrect response status'); | |
} | |
// TODO: check that requests don't overwrite one another | |
// (don't think this is possible to polyfill due to opaque responses) | |
return Promise.all( | |
responses.map(function(response, i) { | |
return cache.put(requests[i], response); | |
}) | |
); | |
}).then(function() { | |
return undefined; | |
}); | |
}; | |
Cache.prototype.add = function add(request) { | |
return this.addAll([request]); | |
}; | |
}()); | |
/***/ }), | |
/* 138 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = __webpack_require__.p + "icon-default.882fa4ccf6539401.png"; | |
/***/ }), | |
/* 139 */ | |
/***/ (function(module, exports, __webpack_require__) { | |
module.exports = __webpack_require__.p + "logo.9d0ec6feeefcbe03.png"; | |
/***/ }), | |
/* 140 */ | |
/***/ (function(module, exports) { | |
/* (ignored) */ | |
/***/ }) | |
/******/ ]); | |
//# sourceMappingURL=main.8e4dadf1516a79ed.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Status Code: 202 CachedForSync (from ServiceWorker)