2 lines
No EOL
24 KiB
JavaScript
2 lines
No EOL
24 KiB
JavaScript
!function(e,n){"use strict";"function"==typeof define&&define.amd?define("stackframe",[],n):"object"==typeof exports?module.exports=n():e.StackFrame=n()}(this,function(){"use strict";function r(e){return e.charAt(0).toUpperCase()+e.substring(1)}function e(e){return function(){return this[e]}}var n=["isConstructor","isEval","isNative","isToplevel"],t=["columnNumber","lineNumber"],o=["fileName","functionName","source"],i=n.concat(t,o,["args"]);function c(e){if(e)for(var n=0;n<i.length;n++)void 0!==e[i[n]]&&this["set"+r(i[n])](e[i[n]])}c.prototype={getArgs:function(){return this.args},setArgs:function(e){if("[object Array]"!==Object.prototype.toString.call(e))throw new TypeError("Args must be an Array");this.args=e},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(e){if(e instanceof c)this.evalOrigin=e;else{if(!(e instanceof Object))throw new TypeError("Eval Origin must be an Object or StackFrame");this.evalOrigin=new c(e)}},toString:function(){var e=this.getFileName()||"",n=this.getLineNumber()||"",r=this.getColumnNumber()||"",t=this.getFunctionName()||"";return this.getIsEval()?e?"[eval] ("+e+":"+n+":"+r+")":"[eval]:"+n+":"+r:t?t+" ("+e+":"+n+":"+r+")":e+":"+n+":"+r}},c.fromString=function(e){var n=e.indexOf("("),r=e.lastIndexOf(")"),t=e.substring(0,n),o=e.substring(n+1,r).split(","),i=e.substring(r+1);if(0===i.indexOf("@"))var s=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(i,""),a=s[1],u=s[2],l=s[3];return new c({functionName:t,args:o||void 0,fileName:a,lineNumber:u||void 0,columnNumber:l||void 0})};for(var s=0;s<n.length;s++)c.prototype["get"+r(n[s])]=e(n[s]),c.prototype["set"+r(n[s])]=function(n){return function(e){this[n]=Boolean(e)}}(n[s]);for(var a=0;a<t.length;a++)c.prototype["get"+r(t[a])]=e(t[a]),c.prototype["set"+r(t[a])]=function(r){return function(e){if(n=e,isNaN(parseFloat(n))||!isFinite(n))throw new TypeError(r+" must be a Number");var n;this[r]=Number(e)}}(t[a]);for(var u=0;u<o.length;u++)c.prototype["get"+r(o[u])]=e(o[u]),c.prototype["set"+r(o[u])]=function(n){return function(e){this[n]=String(e)}}(o[u]);return c});var SourceMap=function(r){var t={};function o(e){if(t[e])return t[e].exports;var n=t[e]={i:e,l:!1,exports:{}};return r[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=r,o.c=t,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(n,e){if(1&e&&(n=o(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)o.d(r,t,function(e){return n[e]}.bind(null,t));return r},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="",o(o.s=1)}([function(e,u){u.getArg=function(e,n,r){if(n in e)return e[n];if(3===arguments.length)return r;throw new Error('"'+n+'" is a required argument.')};var r=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,i=/^data:.+\,.+$/;function l(e){var n=e.match(r);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function c(e){var n="";return e.scheme&&(n+=e.scheme+":"),n+="//",e.auth&&(n+=e.auth+"@"),e.host&&(n+=e.host),e.port&&(n+=":"+e.port),e.path&&(n+=e.path),n}function s(e){var n=e,r=l(e);if(r){if(!r.path)return e;n=r.path}for(var t,o=u.isAbsolute(n),i=n.split(/\/+/),s=0,a=i.length-1;0<=a;a--)"."===(t=i[a])?i.splice(a,1):".."===t?s++:0<s&&(""===t?(i.splice(a+1,s),s=0):(i.splice(a,2),s--));return""===(n=i.join("/"))&&(n=o?"/":"."),r?(r.path=n,c(r)):n}u.urlParse=l,u.urlGenerate=c,u.normalize=s,u.join=function(e,n){""===e&&(e="."),""===n&&(n=".");var r=l(n),t=l(e);if(t&&(e=t.path||"/"),r&&!r.scheme)return t&&(r.scheme=t.scheme),c(r);if(r||n.match(i))return n;if(t&&!t.host&&!t.path)return t.host=n,c(t);var o="/"===n.charAt(0)?n:s(e.replace(/\/+$/,"")+"/"+n);return t?(t.path=o,c(t)):o},u.isAbsolute=function(e){return"/"===e.charAt(0)||!!e.match(r)},u.relative=function(e,n){""===e&&(e="."),e=e.replace(/\/$/,"");for(var r=0;0!==n.indexOf(e+"/");){var t=e.lastIndexOf("/");if(t<0)return n;if((e=e.slice(0,t)).match(/^([^\/]+:\/)?\/*$/))return n;++r}return Array(r+1).join("../")+n.substr(e.length+1)};var n=!("__proto__"in Object.create(null));function t(e){return e}function o(e){if(!e)return!1;var n=e.length;if(n<9)return!1;if(95!==e.charCodeAt(n-1)||95!==e.charCodeAt(n-2)||111!==e.charCodeAt(n-3)||116!==e.charCodeAt(n-4)||111!==e.charCodeAt(n-5)||114!==e.charCodeAt(n-6)||112!==e.charCodeAt(n-7)||95!==e.charCodeAt(n-8)||95!==e.charCodeAt(n-9))return!1;for(var r=n-10;0<=r;r--)if(36!==e.charCodeAt(r))return!1;return!0}function a(e,n){return e===n?0:n<e?1:-1}u.toSetString=n?t:function(e){return o(e)?"$"+e:e},u.fromSetString=n?t:function(e){return o(e)?e.slice(1):e},u.compareByOriginalPositions=function(e,n,r){var t=e.source-n.source;return 0!==t||0!=(t=e.originalLine-n.originalLine)||0!=(t=e.originalColumn-n.originalColumn)||r||0!=(t=e.generatedColumn-n.generatedColumn)||0!=(t=e.generatedLine-n.generatedLine)?t:e.name-n.name},u.compareByGeneratedPositionsDeflated=function(e,n,r){var t=e.generatedLine-n.generatedLine;return 0!==t||0!=(t=e.generatedColumn-n.generatedColumn)||r||0!=(t=e.source-n.source)||0!=(t=e.originalLine-n.originalLine)||0!=(t=e.originalColumn-n.originalColumn)?t:e.name-n.name},u.compareByGeneratedPositionsInflated=function(e,n){var r=e.generatedLine-n.generatedLine;return 0!==r||0!=(r=e.generatedColumn-n.generatedColumn)||0!==(r=a(e.source,n.source))||0!=(r=e.originalLine-n.originalLine)||0!=(r=e.originalColumn-n.originalColumn)?r:a(e.name,n.name)}},function(e,n,r){var y=r(0),u=r(2),g=r(3).ArraySet,b=r(4),C=r(6).quickSort;function s(e){var n=e;return"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,""))),new(null!=n.sections?t:f)(n)}function f(e){var n=e;"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,"")));var r=y.getArg(n,"version"),t=y.getArg(n,"sources"),o=y.getArg(n,"names",[]),i=y.getArg(n,"sourceRoot",null),s=y.getArg(n,"sourcesContent",null),a=y.getArg(n,"mappings"),u=y.getArg(n,"file",null);if(r!=this._version)throw new Error("Unsupported version: "+r);t=t.map(String).map(y.normalize).map(function(e){return i&&y.isAbsolute(i)&&y.isAbsolute(e)?y.relative(i,e):e}),this._names=g.fromArray(o.map(String),!0),this._sources=g.fromArray(t,!0),this.sourceRoot=i,this.sourcesContent=s,this._mappings=a,this.file=u}function w(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}function t(e){var n=e;"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,"")));var r=y.getArg(n,"version"),t=y.getArg(n,"sections");if(r!=this._version)throw new Error("Unsupported version: "+r);this._sources=new g,this._names=new g;var o={line:-1,column:0};this._sections=t.map(function(e){if(e.url)throw new Error("Support for url field in sections not implemented.");var n=y.getArg(e,"offset"),r=y.getArg(n,"line"),t=y.getArg(n,"column");if(r<o.line||r===o.line&&t<o.column)throw new Error("Section offsets must be ordered and non-overlapping.");return o=n,{generatedOffset:{generatedLine:r+1,generatedColumn:t+1},consumer:new s(y.getArg(e,"map"))}})}s.fromSourceMap=function(e){return f.fromSourceMap(e)},s.prototype._version=3,s.prototype.__generatedMappings=null,Object.defineProperty(s.prototype,"_generatedMappings",{get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),s.prototype.__originalMappings=null,Object.defineProperty(s.prototype,"_originalMappings",{get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),s.prototype._charIsMappingSeparator=function(e,n){var r=e.charAt(n);return";"===r||","===r},s.prototype._parseMappings=function(e,n){throw new Error("Subclasses must implement _parseMappings")},s.GENERATED_ORDER=1,s.ORIGINAL_ORDER=2,s.GREATEST_LOWER_BOUND=1,s.LEAST_UPPER_BOUND=2,s.prototype.eachMapping=function(e,n,r){var t,o=n||null;switch(r||s.GENERATED_ORDER){case s.GENERATED_ORDER:t=this._generatedMappings;break;case s.ORIGINAL_ORDER:t=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var i=this.sourceRoot;t.map(function(e){var n=null===e.source?null:this._sources.at(e.source);return null!=n&&null!=i&&(n=y.join(i,n)),{source:n,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:null===e.name?null:this._names.at(e.name)}},this).forEach(e,o)},s.prototype.allGeneratedPositionsFor=function(e){var n=y.getArg(e,"line"),r={source:y.getArg(e,"source"),originalLine:n,originalColumn:y.getArg(e,"column",0)};if(null!=this.sourceRoot&&(r.source=y.relative(this.sourceRoot,r.source)),!this._sources.has(r.source))return[];r.source=this._sources.indexOf(r.source);var t=[],o=this._findMapping(r,this._originalMappings,"originalLine","originalColumn",y.compareByOriginalPositions,u.LEAST_UPPER_BOUND);if(0<=o){var i=this._originalMappings[o];if(void 0===e.column)for(var s=i.originalLine;i&&i.originalLine===s;)t.push({line:y.getArg(i,"generatedLine",null),column:y.getArg(i,"generatedColumn",null),lastColumn:y.getArg(i,"lastGeneratedColumn",null)}),i=this._originalMappings[++o];else for(var a=i.originalColumn;i&&i.originalLine===n&&i.originalColumn==a;)t.push({line:y.getArg(i,"generatedLine",null),column:y.getArg(i,"generatedColumn",null),lastColumn:y.getArg(i,"lastGeneratedColumn",null)}),i=this._originalMappings[++o]}return t},n.SourceMapConsumer=s,(f.prototype=Object.create(s.prototype)).consumer=s,f.fromSourceMap=function(e){var n=Object.create(f.prototype),r=n._names=g.fromArray(e._names.toArray(),!0),t=n._sources=g.fromArray(e._sources.toArray(),!0);n.sourceRoot=e._sourceRoot,n.sourcesContent=e._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=e._file;for(var o=e._mappings.toArray().slice(),i=n.__generatedMappings=[],s=n.__originalMappings=[],a=0,u=o.length;a<u;a++){var l=o[a],c=new w;c.generatedLine=l.generatedLine,c.generatedColumn=l.generatedColumn,l.source&&(c.source=t.indexOf(l.source),c.originalLine=l.originalLine,c.originalColumn=l.originalColumn,l.name&&(c.name=r.indexOf(l.name)),s.push(c)),i.push(c)}return C(n.__originalMappings,y.compareByOriginalPositions),n},f.prototype._version=3,Object.defineProperty(f.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?y.join(this.sourceRoot,e):e},this)}}),f.prototype._parseMappings=function(e,n){for(var r,t,o,i,s,a=1,u=0,l=0,c=0,g=0,f=0,p=e.length,h=0,m={},d={},_=[],v=[];h<p;)if(";"===e.charAt(h))a++,h++,u=0;else if(","===e.charAt(h))h++;else{for((r=new w).generatedLine=a,i=h;i<p&&!this._charIsMappingSeparator(e,i);i++);if(o=m[t=e.slice(h,i)])h+=t.length;else{for(o=[];h<i;)b.decode(e,h,d),s=d.value,h=d.rest,o.push(s);if(2===o.length)throw new Error("Found a source, but no line and column");if(3===o.length)throw new Error("Found a source and line, but no column");m[t]=o}r.generatedColumn=u+o[0],u=r.generatedColumn,1<o.length&&(r.source=g+o[1],g+=o[1],r.originalLine=l+o[2],l=r.originalLine,r.originalLine+=1,r.originalColumn=c+o[3],c=r.originalColumn,4<o.length&&(r.name=f+o[4],f+=o[4])),v.push(r),"number"==typeof r.originalLine&&_.push(r)}C(v,y.compareByGeneratedPositionsDeflated),this.__generatedMappings=v,C(_,y.compareByOriginalPositions),this.__originalMappings=_},f.prototype._findMapping=function(e,n,r,t,o,i){if(e[r]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[r]);if(e[t]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[t]);return u.search(e,n,o,i)},f.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var n=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var r=this._generatedMappings[e+1];if(n.generatedLine===r.generatedLine){n.lastGeneratedColumn=r.generatedColumn-1;continue}}n.lastGeneratedColumn=1/0}},f.prototype.originalPositionFor=function(e){var n={generatedLine:y.getArg(e,"line"),generatedColumn:y.getArg(e,"column")},r=this._findMapping(n,this._generatedMappings,"generatedLine","generatedColumn",y.compareByGeneratedPositionsDeflated,y.getArg(e,"bias",s.GREATEST_LOWER_BOUND));if(0<=r){var t=this._generatedMappings[r];if(t.generatedLine===n.generatedLine){var o=y.getArg(t,"source",null);null!==o&&(o=this._sources.at(o),null!=this.sourceRoot&&(o=y.join(this.sourceRoot,o)));var i=y.getArg(t,"name",null);return null!==i&&(i=this._names.at(i)),{source:o,line:y.getArg(t,"originalLine",null),column:y.getArg(t,"originalColumn",null),name:i}}}return{source:null,line:null,column:null,name:null}},f.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return null==e})},f.prototype.sourceContentFor=function(e,n){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=y.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var r;if(null!=this.sourceRoot&&(r=y.urlParse(this.sourceRoot))){var t=e.replace(/^file:\/\//,"");if("file"==r.scheme&&this._sources.has(t))return this.sourcesContent[this._sources.indexOf(t)];if((!r.path||"/"==r.path)&&this._sources.has("/"+e))return this.sourcesContent[this._sources.indexOf("/"+e)]}if(n)return null;throw new Error('"'+e+'" is not in the SourceMap.')},f.prototype.generatedPositionFor=function(e){var n=y.getArg(e,"source");if(null!=this.sourceRoot&&(n=y.relative(this.sourceRoot,n)),!this._sources.has(n))return{line:null,column:null,lastColumn:null};var r={source:n=this._sources.indexOf(n),originalLine:y.getArg(e,"line"),originalColumn:y.getArg(e,"column")},t=this._findMapping(r,this._originalMappings,"originalLine","originalColumn",y.compareByOriginalPositions,y.getArg(e,"bias",s.GREATEST_LOWER_BOUND));if(0<=t){var o=this._originalMappings[t];if(o.source===r.source)return{line:y.getArg(o,"generatedLine",null),column:y.getArg(o,"generatedColumn",null),lastColumn:y.getArg(o,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},n.BasicSourceMapConsumer=f,(t.prototype=Object.create(s.prototype)).constructor=s,t.prototype._version=3,Object.defineProperty(t.prototype,"sources",{get:function(){for(var e=[],n=0;n<this._sections.length;n++)for(var r=0;r<this._sections[n].consumer.sources.length;r++)e.push(this._sections[n].consumer.sources[r]);return e}}),t.prototype.originalPositionFor=function(e){var n={generatedLine:y.getArg(e,"line"),generatedColumn:y.getArg(e,"column")},r=u.search(n,this._sections,function(e,n){return e.generatedLine-n.generatedOffset.generatedLine||e.generatedColumn-n.generatedOffset.generatedColumn}),t=this._sections[r];return t?t.consumer.originalPositionFor({line:n.generatedLine-(t.generatedOffset.generatedLine-1),column:n.generatedColumn-(t.generatedOffset.generatedLine===n.generatedLine?t.generatedOffset.generatedColumn-1:0),bias:e.bias}):{source:null,line:null,column:null,name:null}},t.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(e){return e.consumer.hasContentsOfAllSources()})},t.prototype.sourceContentFor=function(e,n){for(var r=0;r<this._sections.length;r++){var t=this._sections[r].consumer.sourceContentFor(e,!0);if(t)return t}if(n)return null;throw new Error('"'+e+'" is not in the SourceMap.')},t.prototype.generatedPositionFor=function(e){for(var n=0;n<this._sections.length;n++){var r=this._sections[n];if(-1!==r.consumer.sources.indexOf(y.getArg(e,"source"))){var t=r.consumer.generatedPositionFor(e);if(t)return{line:t.line+(r.generatedOffset.generatedLine-1),column:t.column+(r.generatedOffset.generatedLine===t.line?r.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},t.prototype._parseMappings=function(e,n){this.__generatedMappings=[],this.__originalMappings=[];for(var r=0;r<this._sections.length;r++)for(var t=this._sections[r],o=t.consumer._generatedMappings,i=0;i<o.length;i++){var s=o[i],a=t.consumer._sources.at(s.source);null!==t.consumer.sourceRoot&&(a=y.join(t.consumer.sourceRoot,a)),this._sources.add(a),a=this._sources.indexOf(a);var u=t.consumer._names.at(s.name);this._names.add(u),u=this._names.indexOf(u);var l={source:a,generatedLine:s.generatedLine+(t.generatedOffset.generatedLine-1),generatedColumn:s.generatedColumn+(t.generatedOffset.generatedLine===s.generatedLine?t.generatedOffset.generatedColumn-1:0),originalLine:s.originalLine,originalColumn:s.originalColumn,name:u};this.__generatedMappings.push(l),"number"==typeof l.originalLine&&this.__originalMappings.push(l)}C(this.__generatedMappings,y.compareByGeneratedPositionsDeflated),C(this.__originalMappings,y.compareByOriginalPositions)},n.IndexedSourceMapConsumer=t},function(e,l){l.GREATEST_LOWER_BOUND=1,l.LEAST_UPPER_BOUND=2,l.search=function(e,n,r,t){if(0===n.length)return-1;var o=function e(n,r,t,o,i,s){var a=Math.floor((r-n)/2)+n,u=i(t,o[a],!0);return 0===u?a:0<u?1<r-a?e(a,r,t,o,i,s):s==l.LEAST_UPPER_BOUND?r<o.length?r:-1:a:1<a-n?e(n,a,t,o,i,s):s==l.LEAST_UPPER_BOUND?a:n<0?-1:n}(-1,n.length,e,n,r,t||l.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;0<=o-1&&0===r(n[o],n[o-1],!0);)--o;return o}},function(e,n,r){var i=r(0),s=Object.prototype.hasOwnProperty;function a(){this._array=[],this._set=Object.create(null)}a.fromArray=function(e,n){for(var r=new a,t=0,o=e.length;t<o;t++)r.add(e[t],n);return r},a.prototype.size=function(){return Object.getOwnPropertyNames(this._set).length},a.prototype.add=function(e,n){var r=i.toSetString(e),t=s.call(this._set,r),o=this._array.length;t&&!n||this._array.push(e),t||(this._set[r]=o)},a.prototype.has=function(e){var n=i.toSetString(e);return s.call(this._set,n)},a.prototype.indexOf=function(e){var n=i.toSetString(e);if(s.call(this._set,n))return this._set[n];throw new Error('"'+e+'" is not in the set.')},a.prototype.at=function(e){if(0<=e&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},a.prototype.toArray=function(){return this._array.slice()},n.ArraySet=a},function(e,n,r){var l=r(5);n.encode=function(e){for(var n,r="",t=e<0?1+(-e<<1):0+(e<<1);n=31&t,0<(t>>>=5)&&(n|=32),r+=l.encode(n),0<t;);return r},n.decode=function(e,n,r){var t,o,i,s=e.length,a=0,u=0;do{if(s<=n)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(o=l.decode(e.charCodeAt(n++))))throw new Error("Invalid base64 digit: "+e.charAt(n-1));t=!!(32&o),a+=(o&=31)<<u,u+=5}while(t);r.value=(i=a>>1,1==(1&a)?-i:i),r.rest=n}},function(e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");n.encode=function(e){if(0<=e&&e<r.length)return r[e];throw new TypeError("Must be between 0 and 63: "+e)},n.decode=function(e){return 65<=e&&e<=90?e-65:97<=e&&e<=122?e-97+26:48<=e&&e<=57?e-48+52:43==e?62:47==e?63:-1}},function(e,n){function g(e,n,r){var t=e[n];e[n]=e[r],e[r]=t}n.quickSort=function(e,n){!function e(n,r,t,o){if(t<o){var i=t-1;g(n,(l=t,c=o,Math.round(l+Math.random()*(c-l))),o);for(var s=n[o],a=t;a<o;a++)r(n[a],s)<=0&&g(n,i+=1,a);g(n,i+1,a);var u=i+1;e(n,r,t,u-1),e(n,r,u+1,o)}var l,c}(e,n,0,e.length-1)}}]);!function(e,n){"use strict";"function"==typeof define&&define.amd?define("stacktrace-gps",["source-map","stackframe"],n):"object"==typeof exports?module.exports=n(require("source-map/lib/source-map-consumer"),require("stackframe")):e.StackTraceGPS=n(e.SourceMap||e.sourceMap,e.StackFrame)}(this,function(o,c){"use strict";function n(t){return new Promise(function(e,n){var r=new XMLHttpRequest;r.open("get",t),r.onerror=n,r.onreadystatechange=function(){4===r.readyState&&(200<=r.status&&r.status<300||"file://"===t.substr(0,7)&&r.responseText?e(r.responseText):n(new Error("HTTP status: "+r.status+" retrieving "+t)))},r.send()})}function r(e){if("undefined"!=typeof window&&window.atob)return window.atob(e);throw new Error("You must supply a polyfill for window.atob in this environment")}function t(e){if("object"!=typeof e)throw new TypeError("Given StackFrame is not an object");if("string"!=typeof e.fileName)throw new TypeError("Given file name is not a String");if("number"!=typeof e.lineNumber||e.lineNumber%1!=0||e.lineNumber<1)throw new TypeError("Given line number must be a positive integer");if("number"!=typeof e.columnNumber||e.columnNumber%1!=0||e.columnNumber<0)throw new TypeError("Given column number must be a non-negative integer");return!0}return function e(l){if(!(this instanceof e))return new e(l);l=l||{},this.sourceCache=l.sourceCache||{},this.sourceMapConsumerCache=l.sourceMapConsumerCache||{},this.ajax=l.ajax||n,this._atob=l.atob||r,this._get=function(u){return new Promise(function(e,n){var r="data:"===u.substr(0,5);if(this.sourceCache[u])e(this.sourceCache[u]);else if(l.offline&&!r)n(new Error("Cannot make network requests in offline mode"));else if(r){var t=u.match(/^data:application\/json;([\w=:"-]+;)*base64,/);if(t){var o=t[0].length,i=u.substr(o),s=this._atob(i);e(this.sourceCache[u]=s)}else n(new Error("The encoding of the inline sourcemap is not supported"))}else{var a=this.ajax(u,{method:"get"});(this.sourceCache[u]=a).then(e,n)}}.bind(this))},this._getSourceMapConsumer=function(r,t){return new Promise(function(e){if(this.sourceMapConsumerCache[r])e(this.sourceMapConsumerCache[r]);else{var n=new Promise(function(n,e){return this._get(r).then(function(e){"string"==typeof e&&(e=function(e){if("undefined"!=typeof JSON&&JSON.parse)return JSON.parse(e);throw new Error("You must supply a polyfill for JSON.parse in this environment")}(e.replace(/^\)\]\}'/,""))),void 0===e.sourceRoot&&(e.sourceRoot=t),n(new o.SourceMapConsumer(e))},e)}.bind(this));e(this.sourceMapConsumerCache[r]=n)}}.bind(this))},this.pinpoint=function(n){return new Promise(function(r,e){this.getMappedLocation(n).then(function(e){function n(){r(e)}this.findFunctionName(e).then(r,n).catch(n)}.bind(this),e)}.bind(this))},this.findFunctionName=function(i){return new Promise(function(o,e){t(i),this._get(i.fileName).then(function(e){var n=i.lineNumber,r=i.columnNumber,t=function(e,n){for(var r=[/['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*function\b/,/function\s+([^('"`]*?)\s*\(([^)]*)\)/,/['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*(?:eval|new Function)\b/,/\b(?!(?:if|for|switch|while|with|catch)\b)(?:(?:static)\s+)?(\S+)\s*\(.*?\)\s*\{/,/['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*\(.*?\)\s*=>/],t=e.split("\n"),o="",i=Math.min(n,20),s=0;s<i;++s){var a=t[n-s-1],u=a.indexOf("//");if(0<=u&&(a=a.substr(0,u)),a){o=a+o;for(var l=r.length,c=0;c<l;c++){var g=r[c].exec(o);if(g&&g[1])return g[1]}}}}(e,n);o(t?new c({functionName:t,args:i.args,fileName:i.fileName,lineNumber:n,columnNumber:r}):i)},e).catch(e)}.bind(this))},this.getMappedLocation=function(l){return new Promise(function(a,e){!function(){if("function"!=typeof Object.defineProperty||"function"!=typeof Object.create)throw new Error("Unable to consume source maps in older browsers")}(),t(l);var u=this.sourceCache,o=l.fileName;this._get(o).then(function(e){var n=function(e){for(var n,r,t=/\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/gm;r=t.exec(e);)n=r[1];if(n)return n;throw new Error("sourceMappingURL not found")}(e),r="data:"===n.substr(0,5),t=o.substring(0,o.lastIndexOf("/")+1);return"/"===n[0]||r||/^https?:\/\/|^\/\//i.test(n)||(n=t+n),this._getSourceMapConsumer(n,t).then(function(e){return(o=l,i=e,s=u,new Promise(function(e,n){var r=i.originalPositionFor({line:o.lineNumber,column:o.columnNumber});if(r.source){var t=i.sourceContentFor(r.source);t&&(s[r.source]=t),e(new c({functionName:r.name||o.functionName,args:o.args,fileName:r.source,lineNumber:r.line,columnNumber:r.column}))}else n(new Error("Could not get original source for given stackframe and source map"))})).then(a).catch(function(){a(l)});var o,i,s})}.bind(this),e).catch(e)}.bind(this))}}});
|
|
//# sourceMappingURL=stacktrace-gps.min.js.map
|