vue-giveworks-form
Version:
This plugin provides Vue.js component for the open [http://giveworks.net](Giveworks Platform).
1,484 lines (1,283 loc) • 181 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("axios"));
else if(typeof define === 'function' && define.amd)
define(["axios"], factory);
else if(typeof exports === 'object')
exports["GiveworksForm"] = factory(require("axios"));
else
root["GiveworksForm"] = factory(root["axios"]);
})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE_cebe__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/
/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ }
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // object to store loaded CSS chunks
/******/ var installedCssChunks = {
/******/ 2: 0
/******/ }
/******/
/******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ // Promise = chunk loading, 0 = chunk loaded
/******/ var installedChunks = {
/******/ 2: 0
/******/ };
/******/
/******/
/******/
/******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "GiveworksForm.umd." + ({"0":"vendors~donation-type~vue-interface","1":"vendors~vue-credit-card-field~vue-interface","3":"contact-info-fieldset","4":"donation-type","5":"employment-info-fieldset","6":"go-to-webinar","7":"petition-type","8":"signup-type","9":"survey-type","10":"vendors~donation-type","11":"vendors~vue-credit-card-field","12":"vendors~vue-interface"}[chunkId]||chunkId) + ".js"
/******/ }
/******/
/******/ // 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;
/******/ }
/******/
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
/******/ var promises = [];
/******/
/******/
/******/ // mini-css-extract-plugin CSS loading
/******/ var cssChunks = {"1":1,"4":1,"11":1,"12":1};
/******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);
/******/ else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {
/******/ promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) {
/******/ var href = "css/" + ({"0":"vendors~donation-type~vue-interface","1":"vendors~vue-credit-card-field~vue-interface","3":"contact-info-fieldset","4":"donation-type","5":"employment-info-fieldset","6":"go-to-webinar","7":"petition-type","8":"signup-type","9":"survey-type","10":"vendors~donation-type","11":"vendors~vue-credit-card-field","12":"vendors~vue-interface"}[chunkId]||chunkId) + "." + {"0":"31d6cfe0","1":"b2c407a3","3":"31d6cfe0","4":"6783790e","5":"31d6cfe0","6":"31d6cfe0","7":"31d6cfe0","8":"31d6cfe0","9":"31d6cfe0","10":"31d6cfe0","11":"69901a0a","12":"e064bf35","13":"31d6cfe0"}[chunkId] + ".css";
/******/ var fullhref = __webpack_require__.p + href;
/******/ var existingLinkTags = document.getElementsByTagName("link");
/******/ for(var i = 0; i < existingLinkTags.length; i++) {
/******/ var tag = existingLinkTags[i];
/******/ var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href");
/******/ if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return resolve();
/******/ }
/******/ var existingStyleTags = document.getElementsByTagName("style");
/******/ for(var i = 0; i < existingStyleTags.length; i++) {
/******/ var tag = existingStyleTags[i];
/******/ var dataHref = tag.getAttribute("data-href");
/******/ if(dataHref === href || dataHref === fullhref) return resolve();
/******/ }
/******/ var linkTag = document.createElement("link");
/******/ linkTag.rel = "stylesheet";
/******/ linkTag.type = "text/css";
/******/ linkTag.onload = resolve;
/******/ linkTag.onerror = function(event) {
/******/ var request = event && event.target && event.target.src || fullhref;
/******/ var err = new Error("Loading CSS chunk " + chunkId + " failed.\n(" + request + ")");
/******/ err.code = "CSS_CHUNK_LOAD_FAILED";
/******/ err.request = request;
/******/ delete installedCssChunks[chunkId]
/******/ linkTag.parentNode.removeChild(linkTag)
/******/ reject(err);
/******/ };
/******/ linkTag.href = fullhref;
/******/
/******/ var head = document.getElementsByTagName("head")[0];
/******/ head.appendChild(linkTag);
/******/ }).then(function() {
/******/ installedCssChunks[chunkId] = 0;
/******/ }));
/******/ }
/******/
/******/ // JSONP chunk loading for javascript
/******/
/******/ var installedChunkData = installedChunks[chunkId];
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
/******/ // a Promise means "currently loading".
/******/ if(installedChunkData) {
/******/ promises.push(installedChunkData[2]);
/******/ } else {
/******/ // setup Promise in chunk cache
/******/ var promise = new Promise(function(resolve, reject) {
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
/******/ });
/******/ promises.push(installedChunkData[2] = promise);
/******/
/******/ // start chunk loading
/******/ var script = document.createElement('script');
/******/ var onScriptComplete;
/******/
/******/ script.charset = 'utf-8';
/******/ script.timeout = 120;
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = jsonpScriptSrc(chunkId);
/******/
/******/ // create error before stack unwound to get useful stacktrace later
/******/ var error = new Error();
/******/ onScriptComplete = function (event) {
/******/ // avoid mem leaks in IE.
/******/ script.onerror = script.onload = null;
/******/ clearTimeout(timeout);
/******/ var chunk = installedChunks[chunkId];
/******/ if(chunk !== 0) {
/******/ if(chunk) {
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
/******/ var realSrc = event && event.target && event.target.src;
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
/******/ error.name = 'ChunkLoadError';
/******/ error.type = errorType;
/******/ error.request = realSrc;
/******/ chunk[1](error);
/******/ }
/******/ installedChunks[chunkId] = undefined;
/******/ }
/******/ };
/******/ var timeout = setTimeout(function(){
/******/ onScriptComplete({ type: 'timeout', target: script });
/******/ }, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ document.head.appendChild(script);
/******/ }
/******/ }
/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // 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 = "";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
/******/ var jsonpArray = (typeof self !== 'undefined' ? self : this)["webpackJsonpGiveworksForm"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpGiveworksForm"] || [];
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
/******/ jsonpArray.push = webpackJsonpCallback;
/******/ jsonpArray = jsonpArray.slice();
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
/******/ var parentJsonpFunction = oldJsonpFunction;
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "fb15");
/******/ })
/************************************************************************/
/******/ ({
/***/ "012c":
/***/ (function(module, exports, __webpack_require__) {
(function(f){if(true){module.exports=f()}else { var g; }})(function(){var define,module,exports;
// minimal implementations of useful ES functionality
// all we really need for arrays is reduce – everything else is just sugar!
// Array#reduce
var reduce = function (arr, fn, accum) {
var val = accum;
for (var i = 0, len = arr.length; i < len; i++) {
val = fn(val, arr[i], i, arr);
}
return val;
}; // Array#filter
var filter = function (arr, fn) {
return reduce(arr, function (accum, item, i, arr) {
return !fn(item, i, arr) ? accum : accum.concat(item);
}, []);
}; // Array#map
var map = function (arr, fn) {
return reduce(arr, function (accum, item, i, arr) {
return accum.concat(fn(item, i, arr));
}, []);
}; // Array#includes
var includes = function (arr, x) {
return reduce(arr, function (accum, item, i, arr) {
return accum === true || item === x;
}, false);
};
var _hasDontEnumBug = !{
toString: null
}.propertyIsEnumerable('toString');
var _dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor']; // Object#keys
var keys = function (obj) {
// stripped down version of
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/Keys
var result = [];
var prop;
for (prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) result.push(prop);
}
if (!_hasDontEnumBug) return result;
for (var i = 0, len = _dontEnums.length; i < len; i++) {
if (Object.prototype.hasOwnProperty.call(obj, _dontEnums[i])) result.push(_dontEnums[i]);
}
return result;
}; // Array#isArray
var isArray = function (obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
var _pad = function (n) {
return n < 10 ? "0" + n : n;
}; // Date#toISOString
var isoDate = function () {
// from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
var d = new Date();
return d.getUTCFullYear() + '-' + _pad(d.getUTCMonth() + 1) + '-' + _pad(d.getUTCDate()) + 'T' + _pad(d.getUTCHours()) + ':' + _pad(d.getUTCMinutes()) + ':' + _pad(d.getUTCSeconds()) + '.' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z';
};
var _$esUtils_8 = {
map: map,
reduce: reduce,
filter: filter,
includes: includes,
keys: keys,
isArray: isArray,
isoDate: isoDate
};
var _$validators_15 = {};
_$validators_15.intRange = function (min, max) {
if (min === void 0) {
min = 1;
}
if (max === void 0) {
max = Infinity;
}
return function (value) {
return typeof value === 'number' && parseInt('' + value, 10) === value && value >= min && value <= max;
};
};
_$validators_15.stringWithLength = function (value) {
return typeof value === 'string' && !!value.length;
};
var _$config_5 = {};
var __filter_5 = _$esUtils_8.filter,
__reduce_5 = _$esUtils_8.reduce,
__keys_5 = _$esUtils_8.keys,
__isArray_5 = _$esUtils_8.isArray,
__includes_5 = _$esUtils_8.includes;
var intRange = _$validators_15.intRange,
stringWithLength = _$validators_15.stringWithLength;
_$config_5.schema = {
apiKey: {
defaultValue: function () {
return null;
},
message: 'is required',
validate: stringWithLength
},
appVersion: {
defaultValue: function () {
return null;
},
message: 'should be a string',
validate: function (value) {
return value === null || stringWithLength(value);
}
},
appType: {
defaultValue: function () {
return null;
},
message: 'should be a string',
validate: function (value) {
return value === null || stringWithLength(value);
}
},
autoNotify: {
defaultValue: function () {
return true;
},
message: 'should be true|false',
validate: function (value) {
return value === true || value === false;
}
},
beforeSend: {
defaultValue: function () {
return [];
},
message: 'should be a function or array of functions',
validate: function (value) {
return typeof value === 'function' || __isArray_5(value) && __filter_5(value, function (f) {
return typeof f === 'function';
}).length === value.length;
}
},
endpoints: {
defaultValue: function () {
return {
notify: 'https://notify.bugsnag.com',
sessions: 'https://sessions.bugsnag.com'
};
},
message: 'should be an object containing endpoint URLs { notify, sessions }. sessions is optional if autoCaptureSessions=false',
validate: function (val, obj) {
return (// first, ensure it's an object
val && typeof val === 'object' && // endpoints.notify must always be set
stringWithLength(val.notify) && ( // endpoints.sessions must be set unless session tracking is explicitly off
obj.autoCaptureSessions === false || stringWithLength(val.sessions)) && // ensure no keys other than notify/session are set on endpoints object
__filter_5(__keys_5(val), function (k) {
return !__includes_5(['notify', 'sessions'], k);
}).length === 0
);
}
},
autoCaptureSessions: {
defaultValue: function (val, opts) {
return opts.endpoints === undefined || !!opts.endpoints && !!opts.endpoints.sessions;
},
message: 'should be true|false',
validate: function (val) {
return val === true || val === false;
}
},
notifyReleaseStages: {
defaultValue: function () {
return null;
},
message: 'should be an array of strings',
validate: function (value) {
return value === null || __isArray_5(value) && __filter_5(value, function (f) {
return typeof f === 'string';
}).length === value.length;
}
},
releaseStage: {
defaultValue: function () {
return 'production';
},
message: 'should be a string',
validate: function (value) {
return typeof value === 'string' && value.length;
}
},
maxBreadcrumbs: {
defaultValue: function () {
return 20;
},
message: 'should be a number ≤40',
validate: function (value) {
return intRange(0, 40)(value);
}
},
autoBreadcrumbs: {
defaultValue: function () {
return true;
},
message: 'should be true|false',
validate: function (value) {
return typeof value === 'boolean';
}
},
user: {
defaultValue: function () {
return null;
},
message: '(object) user should be an object',
validate: function (value) {
return typeof value === 'object';
}
},
metaData: {
defaultValue: function () {
return null;
},
message: 'should be an object',
validate: function (value) {
return typeof value === 'object';
}
},
logger: {
defaultValue: function () {
return undefined;
},
message: 'should be null or an object with methods { debug, info, warn, error }',
validate: function (value) {
return !value || value && __reduce_5(['debug', 'info', 'warn', 'error'], function (accum, method) {
return accum && typeof value[method] === 'function';
}, true);
}
},
filters: {
defaultValue: function () {
return ['password'];
},
message: 'should be an array of strings|regexes',
validate: function (value) {
return __isArray_5(value) && value.length === __filter_5(value, function (s) {
return typeof s === 'string' || s && typeof s.test === 'function';
}).length;
}
}
};
_$config_5.mergeDefaults = function (opts, schema) {
if (!opts || !schema) throw new Error('opts and schema objects are required');
return __reduce_5(__keys_5(schema), function (accum, key) {
accum[key] = opts[key] !== undefined ? opts[key] : schema[key].defaultValue(opts[key], opts);
return accum;
}, {});
};
_$config_5.validate = function (opts, schema) {
if (!opts || !schema) throw new Error('opts and schema objects are required');
var errors = __reduce_5(__keys_5(schema), function (accum, key) {
if (schema[key].validate(opts[key], opts)) return accum;
return accum.concat({
key: key,
message: schema[key].message,
value: opts[key]
});
}, []);
return {
valid: !errors.length,
errors: errors
};
};
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var schema = _$config_5.schema;
var __map_1 = _$esUtils_8.map;
var __stringWithLength_1 = _$validators_15.stringWithLength;
var _$config_1 = {
releaseStage: {
defaultValue: function () {
if (/^localhost(:\d+)?$/.test(window.location.host)) return 'development';
return 'production';
},
message: 'should be set',
validate: __stringWithLength_1
},
logger: _extends({}, schema.logger, {
defaultValue: function () {
return (// set logger based on browser capability
typeof console !== 'undefined' && typeof console.debug === 'function' ? getPrefixedConsole() : undefined
);
}
})
};
var getPrefixedConsole = function () {
var logger = {};
var consoleLog = console['log'];
__map_1(['debug', 'info', 'warn', 'error'], function (method) {
var consoleMethod = console[method];
logger[method] = typeof consoleMethod === 'function' ? consoleMethod.bind(console, '[bugsnag]') : consoleLog.bind(console, '[bugsnag]');
});
return logger;
};
var __isoDate_3 = _$esUtils_8.isoDate;
var BugsnagBreadcrumb =
/*#__PURE__*/
function () {
function BugsnagBreadcrumb(name, metaData, type, timestamp) {
if (name === void 0) {
name = '[anonymous]';
}
if (metaData === void 0) {
metaData = {};
}
if (type === void 0) {
type = 'manual';
}
if (timestamp === void 0) {
timestamp = __isoDate_3();
}
this.type = type;
this.name = name;
this.metaData = metaData;
this.timestamp = timestamp;
}
var _proto = BugsnagBreadcrumb.prototype;
_proto.toJSON = function toJSON() {
return {
type: this.type,
name: this.name,
timestamp: this.timestamp,
metaData: this.metaData
};
};
return BugsnagBreadcrumb;
}();
var _$BugsnagBreadcrumb_3 = BugsnagBreadcrumb;
// This is a heavily modified/simplified version of
// https://github.com/othiym23/async-some
//
// We can't use that because:
// a) it inflates the bundle size to over 10kB
// b) it depends on a module that uses Object.keys()
// (which we can't use due to ie8 support)
// run the asynchronous test function (fn) over each item in the array (arr)
// in series until:
// - fn(item, cb) => calls cb(null, true)
// - or the end of the array is reached
// the callback (cb) will be passed true if any of the items resulted in a true
// callback, otherwise false
var _$asyncSome_6 = function (arr, fn, cb) {
var length = arr.length;
var index = 0;
var next = function () {
if (index >= length) return cb(null, false);
fn(arr[index], function (err, result) {
if (err) return cb(err, false);
if (result === true) return cb(null, true);
index++;
next();
});
};
next();
};
var _$inferReleaseStage_10 = function (client) {
return client.app && typeof client.app.releaseStage === 'string' ? client.app.releaseStage : client.config.releaseStage;
};
/**
* Expose `isError`.
*/
var _$isError_21 = isError;
/**
* Test whether `value` is error object.
*
* @param {*} value
* @returns {boolean}
*/
function isError(value) {
switch (Object.prototype.toString.call(value)) {
case '[object Error]':
return true;
case '[object Exception]':
return true;
case '[object DOMException]':
return true;
default:
return value instanceof Error;
}
}
var _$iserror_11 = _$isError_21;
var _$runBeforeSend_14 = function (report, onError) {
return function (fn, cb) {
if (typeof fn !== 'function') return cb(null, false);
try {
// if function appears sync…
if (fn.length !== 2) {
var ret = fn(report); // check if it returned a "thenable" (promise)
if (ret && typeof ret.then === 'function') {
return ret.then( // resolve
function (val) {
return setTimeout(function () {
return cb(null, shouldPreventSend(report, val));
}, 0);
}, // reject
function (err) {
setTimeout(function () {
onError(err);
return cb(null, false);
});
});
}
return cb(null, shouldPreventSend(report, ret));
} // if function is async…
fn(report, function (err, result) {
if (err) {
onError(err);
return cb(null, false);
}
cb(null, shouldPreventSend(report, result));
});
} catch (e) {
onError(e);
cb(null, false);
}
};
};
var shouldPreventSend = function (report, value) {
return report.isIgnored() || value === false;
};
var _$stackframe_23 = {};
(function (root, factory) {
'use strict'; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
define('stackframe', [], factory);
} else if (typeof _$stackframe_23 === 'object') {
_$stackframe_23 = factory();
} else {
root.StackFrame = factory();
}
})(this, function () {
'use strict';
function _isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function _capitalize(str) {
return str.charAt(0).toUpperCase() + str.substring(1);
}
function _getter(p) {
return function () {
return this[p];
};
}
var booleanProps = ['isConstructor', 'isEval', 'isNative', 'isToplevel'];
var numericProps = ['columnNumber', 'lineNumber'];
var stringProps = ['fileName', 'functionName', 'source'];
var arrayProps = ['args'];
var props = booleanProps.concat(numericProps, stringProps, arrayProps);
function StackFrame(obj) {
if (obj instanceof Object) {
for (var i = 0; i < props.length; i++) {
if (obj.hasOwnProperty(props[i]) && obj[props[i]] !== undefined) {
this['set' + _capitalize(props[i])](obj[props[i]]);
}
}
}
}
StackFrame.prototype = {
getArgs: function () {
return this.args;
},
setArgs: function (v) {
if (Object.prototype.toString.call(v) !== '[object Array]') {
throw new TypeError('Args must be an Array');
}
this.args = v;
},
getEvalOrigin: function () {
return this.evalOrigin;
},
setEvalOrigin: function (v) {
if (v instanceof StackFrame) {
this.evalOrigin = v;
} else if (v instanceof Object) {
this.evalOrigin = new StackFrame(v);
} else {
throw new TypeError('Eval Origin must be an Object or StackFrame');
}
},
toString: function () {
var functionName = this.getFunctionName() || '{anonymous}';
var args = '(' + (this.getArgs() || []).join(',') + ')';
var fileName = this.getFileName() ? '@' + this.getFileName() : '';
var lineNumber = _isNumber(this.getLineNumber()) ? ':' + this.getLineNumber() : '';
var columnNumber = _isNumber(this.getColumnNumber()) ? ':' + this.getColumnNumber() : '';
return functionName + args + fileName + lineNumber + columnNumber;
}
};
for (var i = 0; i < booleanProps.length; i++) {
StackFrame.prototype['get' + _capitalize(booleanProps[i])] = _getter(booleanProps[i]);
StackFrame.prototype['set' + _capitalize(booleanProps[i])] = function (p) {
return function (v) {
this[p] = Boolean(v);
};
}(booleanProps[i]);
}
for (var j = 0; j < numericProps.length; j++) {
StackFrame.prototype['get' + _capitalize(numericProps[j])] = _getter(numericProps[j]);
StackFrame.prototype['set' + _capitalize(numericProps[j])] = function (p) {
return function (v) {
if (!_isNumber(v)) {
throw new TypeError(p + ' must be a Number');
}
this[p] = Number(v);
};
}(numericProps[j]);
}
for (var k = 0; k < stringProps.length; k++) {
StackFrame.prototype['get' + _capitalize(stringProps[k])] = _getter(stringProps[k]);
StackFrame.prototype['set' + _capitalize(stringProps[k])] = function (p) {
return function (v) {
this[p] = String(v);
};
}(stringProps[k]);
}
return StackFrame;
});
var _$errorStackParser_20 = {};
(function (root, factory) {
'use strict'; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
define('error-stack-parser', ['stackframe'], factory);
} else if (typeof _$errorStackParser_20 === 'object') {
_$errorStackParser_20 = factory(_$stackframe_23);
} else {
root.ErrorStackParser = factory(root.StackFrame);
}
})(this, function ErrorStackParser(StackFrame) {
'use strict';
var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+\:\d+/;
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+\:\d+|\(native\))/m;
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
return {
/**
* Given an Error object, extract the most information from it.
*
* @param {Error} error object
* @return {Array} of StackFrames
*/
parse: function ErrorStackParser$$parse(error) {
if (typeof error.stacktrace !== 'undefined' || typeof error['opera#sourceloc'] !== 'undefined') {
return this.parseOpera(error);
} else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
return this.parseV8OrIE(error);
} else if (error.stack) {
return this.parseFFOrSafari(error);
} else {
throw new Error('Cannot parse given Error object');
}
},
// Separate line and column numbers from a string of the form: (URI:Line:Column)
extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
// Fail-fast but return locations like "(native)"
if (urlLike.indexOf(':') === -1) {
return [urlLike];
}
var regExp = /(.+?)(?:\:(\d+))?(?:\:(\d+))?$/;
var parts = regExp.exec(urlLike.replace(/[\(\)]/g, ''));
return [parts[1], parts[2] || undefined, parts[3] || undefined];
},
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
var filtered = error.stack.split('\n').filter(function (line) {
return !!line.match(CHROME_IE_STACK_REGEXP);
}, this);
return filtered.map(function (line) {
if (line.indexOf('(eval ') > -1) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^\()]*)|(\)\,.*$)/g, '');
}
var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '('); // capture and preseve the parenthesized location "(/foo/my bar.js:12:87)" in
// case it has spaces in it, as the string is split on \s+ later on
var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/); // remove the parenthesized location from the line, if it was matched
sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;
var tokens = sanitizedLine.split(/\s+/).slice(1); // if a location was matched, pass it to extractLocation() otherwise pop the last token
var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
var functionName = tokens.join(' ') || undefined;
var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
return new StackFrame({
functionName: functionName,
fileName: fileName,
lineNumber: locationParts[1],
columnNumber: locationParts[2],
source: line
});
}, this);
},
parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
var filtered = error.stack.split('\n').filter(function (line) {
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
}, this);
return filtered.map(function (line) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
if (line.indexOf(' > eval') > -1) {
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g, ':$1');
}
if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
// Safari eval frames only have function names and nothing else
return new StackFrame({
functionName: line
});
} else {
var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
var matches = line.match(functionNameRegex);
var functionName = matches && matches[1] ? matches[1] : undefined;
var locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
return new StackFrame({
functionName: functionName,
fileName: locationParts[0],
lineNumber: locationParts[1],
columnNumber: locationParts[2],
source: line
});
}
}, this);
},
parseOpera: function ErrorStackParser$$parseOpera(e) {
if (!e.stacktrace || e.message.indexOf('\n') > -1 && e.message.split('\n').length > e.stacktrace.split('\n').length) {
return this.parseOpera9(e);
} else if (!e.stack) {
return this.parseOpera10(e);
} else {
return this.parseOpera11(e);
}
},
parseOpera9: function ErrorStackParser$$parseOpera9(e) {
var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
var lines = e.message.split('\n');
var result = [];
for (var i = 2, len = lines.length; i < len; i += 2) {
var match = lineRE.exec(lines[i]);
if (match) {
result.push(new StackFrame({
fileName: match[2],
lineNumber: match[1],
source: lines[i]
}));
}
}
return result;
},
parseOpera10: function ErrorStackParser$$parseOpera10(e) {
var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
var lines = e.stacktrace.split('\n');
var result = [];
for (var i = 0, len = lines.length; i < len; i += 2) {
var match = lineRE.exec(lines[i]);
if (match) {
result.push(new StackFrame({
functionName: match[3] || undefined,
fileName: match[2],
lineNumber: match[1],
source: lines[i]
}));
}
}
return result;
},
// Opera 10.65+ Error.stack very similar to FF/Safari
parseOpera11: function ErrorStackParser$$parseOpera11(error) {
var filtered = error.stack.split('\n').filter(function (line) {
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
}, this);
return filtered.map(function (line) {
var tokens = line.split('@');
var locationParts = this.extractLocation(tokens.pop());
var functionCall = tokens.shift() || '';
var functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, '$2').replace(/\([^\)]*\)/g, '') || undefined;
var argsRaw;
if (functionCall.match(/\(([^\)]*)\)/)) {
argsRaw = functionCall.replace(/^[^\(]+\(([^\)]*)\)$/, '$1');
}
var args = argsRaw === undefined || argsRaw === '[arguments not available]' ? undefined : argsRaw.split(',');
return new StackFrame({
functionName: functionName,
args: args,
fileName: locationParts[0],
lineNumber: locationParts[1],
columnNumber: locationParts[2],
source: line
});
}, this);
}
};
});
var _$errorStackParser_7 = _$errorStackParser_20;
// Given `err` which may be an error, does it have a stack property which is a string?
var _$hasStack_9 = function (err) {
return !!err && (!!err.stack || !!err.stacktrace || !!err['opera#sourceloc']) && typeof (err.stack || err.stacktrace || err['opera#sourceloc']) === 'string' && err.stack !== err.name + ": " + err.message;
};
var _$jsRuntime_12 = "yes" ? 'browserjs' : undefined;
var _$stackGenerator_22 = {};
(function (root, factory) {
'use strict'; // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
/* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
define('stack-generator', ['stackframe'], factory);
} else if (typeof _$stackGenerator_22 === 'object') {
_$stackGenerator_22 = factory(_$stackframe_23);
} else {
root.StackGenerator = factory(root.StackFrame);
}
})(this, function (StackFrame) {
return {
backtrace: function StackGenerator$$backtrace(opts) {
var stack = [];
var maxStackSize = 10;
if (typeof opts === 'object' && typeof opts.maxStackSize === 'number') {
maxStackSize = opts.maxStackSize;
}
var curr = arguments.callee;
while (curr && stack.length < maxStackSize && curr['arguments']) {
// Allow V8 optimizations
var args = new Array(curr['arguments'].length);
for (var i = 0; i < args.length; ++i) {
args[i] = curr['arguments'][i];
}
if (/function(?:\s+([\w$]+))+\s*\(/.test(curr.toString())) {
stack.push(new StackFrame({
functionName: RegExp.$1 || undefined,
args: args
}));
} else {
stack.push(new StackFrame({
args: args
}));
}
try {
curr = curr.caller;
} catch (e) {
break;
}
}
return stack;
}
};
});
function ___extends_24() { ___extends_24 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_24.apply(this, arguments); }
/* removed: var _$errorStackParser_7 = require('./lib/error-stack-parser'); */;
/* removed: var _$stackGenerator_22 = require('stack-generator'); */;
/* removed: var _$hasStack_9 = require('./lib/has-stack'); */;
var __reduce_24 = _$esUtils_8.reduce,
__filter_24 = _$esUtils_8.filter;
/* removed: var _$jsRuntime_12 = require('./lib/js-runtime'); */;
var BugsnagReport =
/*#__PURE__*/
function () {
function BugsnagReport(errorClass, errorMessage, stacktrace, handledState, originalError) {
if (stacktrace === void 0) {
stacktrace = [];
}
if (handledState === void 0) {
handledState = defaultHandledState();
}
// duck-typing ftw >_<
this.__isBugsnagReport = true;
this._ignored = false; // private (un)handled state
this._handledState = handledState; // setable props
this.app = undefined;
this.apiKey = undefined;
this.breadcrumbs = [];
this.context = undefined;
this.device = undefined;
this.errorClass = stringOrFallback(errorClass, '[no error class]');
this.errorMessage = stringOrFallback(errorMessage, '[no error message]');
this.groupingHash = undefined;
this.metaData = {};
this.request = undefined;
this.severity = this._handledState.severity;
this.stacktrace = __reduce_24(stacktrace, function (accum, frame) {
var f = formatStackframe(frame); // don't include a stackframe if none of its properties are defined
try {
if (JSON.stringify(f) === '{}') return accum;
return accum.concat(f);
} catch (e) {
return accum;
}
}, []);
this.user = undefined;
this.session = undefined;
this.originalError = originalError; // Flags.
// Note these are not initialised unless they are used
// to save unnecessary bytes in the browser bundle
/* this.attemptImmediateDelivery, default: true */
}
var _proto = BugsnagReport.prototype;
_proto.ignore = function ignore() {
this._ignored = true;
};
_proto.isIgnored = function isIgnored() {
return this._ignored;
};
_proto.updateMetaData = function updateMetaData(section) {
var _updates;
if (!section) return this;
var updates; // updateMetaData("section", null) -> removes section
if ((arguments.length <= 1 ? undefined : arguments[1]) === null) return this.removeMetaData(section); // updateMetaData("section", "property", null) -> removes property from section
if ((arguments.length <= 2 ? undefined : arguments[2]) === null) return this.removeMetaData(section, arguments.length <= 1 ? undefined : arguments[1], arguments.length <= 2 ? undefined : arguments[2]); // normalise the two supported input types into object form
if (typeof (arguments.length <= 1 ? undefined : arguments[1]) === 'object') updates = arguments.length <= 1 ? undefined : arguments[1];
if (typeof (arguments.length <= 1 ? undefined : arguments[1]) === 'string') updates = (_updates = {}, _updates[arguments.length <= 1 ? undefined : arguments[1]] = arguments.length <= 2 ? undefined : arguments[2], _updates); // exit if we don't have an updates object at this point
if (!updates) return this; // ensure a section with this name exists
if (!this.metaData[section]) this.metaData[section] = {}; // merge the updates with the existing section
this.metaData[section] = ___extends_24({}, this.metaData[section], updates);
return this;
};
_proto.removeMetaData = function removeMetaData(section, property) {
if (typeof section !== 'string') return this; // remove an entire section
if (!property) {
delete this.metaData[section];
return this;
} // remove a single property from a section
if (this.metaData[section]) {
delete this.metaData[section][property];
return this;
}
return this;
};
_proto.toJSON = function toJSON() {
return {
payloadVersion: '4',
exceptions: [{
errorClass: this.errorClass,
message: this.errorMessage,
stacktrace: this.stacktrace,
type: _$jsRuntime_12
}],
severity: this.severity,
unhandled: this._handledState.unhandled,
severityReason: this._handledState.severityReason,
app: this.app,
device: this.device,
breadcrumbs: this.breadcrumbs,
context: this.context,
user: this.user,
metaData: this.metaData,
groupingHash: this.groupingHash,
request: this.request,
session: this.session
};
};
return BugsnagReport;
}(); // takes a stacktrace.js style stackframe (https://github.com/stacktracejs/stackframe)
// and returns a Bugsnag compatible stackframe (https://docs.bugsnag.com/api/error-reporting/#json-payload)
var formatStackframe = function (frame) {
var f = {
file: frame.fileName,
method: normaliseFunctionName(frame.functionName),
lineNumber: frame.lineNumber,
columnNumber: frame.columnNumber,
code: undefined,
inProject: undefined // Some instances result in no file:
// - calling notify() from chrome's terminal results in no file/method.
// - non-error exception thrown from global code in FF
// This adds one.
};
if (f.lineNumber > -1 && !f.file && !f.method) {
f.file = 'global code';
}
return f;
};
var normaliseFunctionName = function (name) {
return /^global code$/i.test(name) ? 'global code' : name;
};
var defaultHandledState = function () {
return {
unhandled: false,
severity: 'warning',
severityReason: {
type: 'handledException'
}
};
};
var stringOrFallback = function (str, fallback) {
return typeof str === 'string' && str ? str : fallback;
}; // Helpers
BugsnagReport.getStacktrace = function (error, errorFramesToSkip, generatedFramesToSkip) {
if (errorFramesToSkip === void 0) {
errorFramesToSkip = 0;
}
if (generatedFramesToSkip === void 0) {
generatedFramesToSkip = 0;
}
if (_$hasStack_9(error)) return _$errorStackParser_7.parse(error).slice(errorFramesToSkip); // in IE11 a new Error() doesn't have a stacktrace until you throw it, so try that here
try {
throw error;
} catch (e) {
if (_$hasStack_9(e)) return _$errorStackParser_7.parse(error).slice(1 + generatedFramesToSkip); // error wasn't provided or didn't have a stacktrace so try to walk the callstack
try {
return __filter_24(_$stackGenerator_22.backtrace(), function (frame) {
return (frame.functionName || '').indexOf('StackGenerator$$') === -1;
}).slice(1 + generatedFramesToSkip);
} catch (e) {
return [];
}
}
};
BugsnagReport.ensureReport = function (reportOrError, errorFramesToSkip, generatedFramesToSkip) {
if (errorFramesToSkip === void 0) {
errorFramesToSkip = 0;
}
if (generatedFramesToSkip === void 0) {
generatedFramesToSkip = 0;
}
// notify() can be called with a Report object. In this case no action is required
if (reportOrError.__isBugsnagReport) return reportOrError;
try {
var stacktrace = BugsnagReport.getStacktrace(reportOrError, errorFramesToSkip, 1 + generatedFramesToSkip);
return new BugsnagReport(reportOrError.name, reportOrError.message, stacktrace, undefined, reportOrError);
} catch (e) {
return new BugsnagReport(reportOrError.name, reportOrError.message, [], undefined, reportOrError);
}
};
var _$BugsnagReport_24 = BugsnagReport;
var _$pad_18 = function pad(num, size) {
var s = '000000000' + num;
return s.substr(s.length - size);
};
/* removed: var _$pad_18 = require('./pad.js'); */;
var env = typeof window === 'object' ? window : self;
var globalCount = 0;
for (var prop in env) {
if (Object.hasOwnProperty.call(env, prop)) globalCount++;
}
var mimeTypesLength = navigator.mimeTypes ? navigator.mimeTypes.length : 0;
var clientId = _$pad_18((mimeTypesLength + navigator.userAgent.length).toString(36) + globalCount.toString(36), 4);
var _$fingerprint_17 = function fingerprint() {
return clientId;
};
/**
* cuid.js
* Collision-resistant UID generator for browsers and node.
* Sequential for fast db lookups and recency sorting.
* Safe for element IDs and server-side lookups.
*
* Extracted from CLCTR
*
* Copyright (c) Eric Elliott 2012
* MIT License
*/
/* removed: var _$fingerprint_17 = require('./lib/fingerprint.js'); */;
/* removed: var _$pad_18 = require('./lib/pad.js'); */;
var c = 0,
blockSize = 4,
base = 36,
discreteValues = Math.pow(base, blockSize);
function randomBlock() {
return _$pad_18((Math.random() * discreteValues << 0).toString(base), blockSize);
}
function safeCounter() {
c = c < discreteValues ? c : 0;
c++; // this is not subliminal
return c - 1;
}
function cuid() {
// Starting with a lowercase letter makes
// it HTML element ID friendly.
var letter = 'c',
// hard-coded allows for sequential access
// timestamp
// warning: this exposes the exact date and time
// that the uid was created.
timestamp = new Date().getTime().toString(base),
// Prevent same-machine collisions.
counter = _$pad_18(safeCounter().toString(base), blockSize),
// A few chars to generate distinct ids for different
// clients (so different computers are far less
// likely to generate the same id)
print = _$fingerprint_17(),
// Grab some more chars from Math.random()
random = randomBlock() + randomBlock();
return letter + timestamp + counter + print + random;
}
cuid.fingerprint = _$fingerprint_17;
var _$cuid_16 = cuid;
var __isoDate_25 = _$esUtils_8.isoDate;
/* removed: var _$cuid_16 = require('@bugsnag/cuid'); */;
var Session =
/*#__PURE__*/
function () {
function Session() {
this.id = _$cuid_16();
this.startedAt = __isoDate_25();
this._handled = 0;
this._unhandled = 0;
}
var _proto = Session.prototype;
_proto.toJSON = function toJSON() {
return {
id: this.id,
startedAt: this.startedAt,
events: {
handled: this._handled,
unhandled: this._unhandled
}
};
};
_proto.trackError = function trackError(report) {
this[report._handledState.unhandled ? '_unhandled' : '_handled'] += 1;
};
return Session;
}();
var _$Session_25 = Session;
function ___extends_4() { ___extends_4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return ___extends_4.apply(this, arguments); }
/* removed: var _$config_5 = require('./config'); */;
/* removed: var _$BugsnagReport_24 = require('./report'); */;
/* removed: var _$BugsnagBreadcrumb_3 = require('./breadcrumb'); */;
/* removed: var _$Session_25 = require('./session'); */;
var __map_4 = _$esUtils_8.map,
__includes_4 = _$esUtils_8.includes,
__isArray_4 = _$esUtils_8.isArray;
/* removed: var _$inferReleaseStage_10 = require('./lib/infer-release-stage'); */;
/* removed: var _$iserror_11 = require('./lib/iserror'); */;
/* removed: var _$asyncSome_6 = require('./lib/async-some'); */;
/* removed: var _$runBeforeSend_14 = require('./lib/run-before-send'); */;
var LOG_USAGE_ERR_PREFIX = "Usage error.";
var REPORT_USAGE_ERR_PREFIX = "Bugsnag usage error.";
var BugsnagClient =
/*#__PURE__*/
function () {
function BugsnagClient(notifier) {
if (!notifier || !notifier.name || !notifier.version || !notifier.url) {
throw new Error('`notifier` argument is required');
} // notifier id
this.notifier = notifier; // conf