squash_javascript 1.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,24 @@
1
- (function(){var m,f={}.hasOwnProperty,h=[].slice,e="undefined"!==typeof exports&&null!==exports?exports:this,k=function(){},v;v=void 0;k.instance=function(){return null!=v?v:v=new m};e.SquashJavascript=k;var e=function(){TraceKit.report.subscribe(function(b,d){return SquashJavascript.instance().report(b,d)})},p,s,x,g;e.prototype.configure=function(b){var d,c,a;this.options||(this.options={disabled:!1,notifyPath:"/api/1.0/notify",transmitTimeout:15E3,ignoredExceptionClasses:[],ignoredExceptionMessages:{}});
2
- a=[];for(d in b)f.call(b,d)&&(c=b[d],a.push(this.options[d]=c));return a};e.prototype.notify=function(b,d){if(b instanceof Error)return b._squash_user_data=d,TraceKit.report(b);throw b;};e.prototype.report=function(b,d){var c,a,i,l,B,G,q,j,e,k,h,g;try{if(null!=(G=this.options)&&G.disabled)return!1;if(!(null!=(q=this.options)&&q.APIKey)||!(null!=(j=this.options)&&j.environment)||!(null!=(e=this.options)&&e.revision)||!(null!=(k=this.options)&&k.APIHost))return console.error("Missing required Squash configuration keys"),
3
- !1;if(this.shouldIgnoreError(b)||!b.stack)return!1;a={};a.api_key=this.options.APIKey;a.environment=this.options.environment;a.client="javascript";a.revision=this.options.revision;a.class_name=null!=(h=b.type)?h:b.name;!b.name&&(l=b.message.match(/^(Uncaught )?(\w+): (.+)/))?(a.class_name=l[2],a.message=l[3]):a.message=b.message;null==a.class_name&&(a.class_name="Error");a.backtraces=x(b.stack);a.capture_method=b.mode;a.occurred_at=p(new Date);a.schema=window.location.protocol.replace(/:$/,"");a.host=
4
- window.location.hostname;0<window.location.port.length&&(a.port=window.location.port);a.path=window.location.pathname;a.query=window.location.search;""!==window.location.hash&&(a.fragment=window.location.hash);a.user_agent=navigator.userAgent;a.screen_width=screen.width;a.screen_height=screen.height;a.window_width=window.innerWidth;a.window_height=window.innerHeight;a.color_depth=screen.colorDepth;if(d)for(i in g=d._squash_user_data,g)f.call(g,i)&&(B=g[i],a[i]=B);c=JSON.stringify(a);this.HTTPTransmit(this.options.APIHost+
5
- this.options.notifyPath,[["Content-Type","application/json"]],c);return!0}catch(s){return console.error("Error while trying to notify Squash:",s.stack),console.error("-- original error:",b)}};e.prototype.addUserData=function(b,d){try{return d()}catch(c){throw null==c._squash_user_data&&(c._squash_user_data={}),g(c._squash_user_data,b),c;}};e.prototype.addingUserData=function(b,d){return function(){var c;c=1<=arguments.length?h.call(arguments,0):[];return SquashJavascript.instance().addUserData(b,
6
- function(){return d.apply(null,c)})}};e.prototype.ignoreExceptions=function(){var b,d;d=2<=arguments.length?h.call(arguments,0,b=arguments.length-1):(b=0,[]);b=arguments[b++];try{return b()}catch(c){throw c._squash_ignored_exceptions=(c._squash_ignored_exceptions||[]).concat(d),c;}};e.prototype.ignoringExceptions=function(){var b,d,c;d=2<=arguments.length?h.call(arguments,0,c=arguments.length-1):(c=0,[]);b=arguments[c++];return function(){var a,i;a=1<=arguments.length?h.call(arguments,0):[];return(i=
7
- SquashJavascript.instance()).ignoreExceptions.apply(i,h.call(d).concat([function(){return b.apply(null,a)}]))}};e.prototype.HTTPTransmit=function(b,d,c){var a,i,l;a=new XMLHttpRequest;a.open("POST",b,!0);a.timeout=this.options.transmitTimeout;i=0;for(l=d.length;i<l;i++)b=d[i],a.setRequestHeader(b[0],b[1]);a.send(c);return a};e.prototype.shouldIgnoreError=function(b){var d;d=this.options.ignoredExceptionClasses.concat(b._squash_ignored_exceptions||[]);return s(d,function(c){return b.name===c})?!0:
8
- s(this.options.ignoredExceptionMessages,function(c,a){return b.name===c?s(a,function(a){return b.message.match(a)}):!1})};x=function(b){var d,c,a,i,l;d=[];i=0;for(l=b.length;i<l;i++)a=b[i],(c=a.context)&&s(c,function(a){return a&&200<a.length})&&(c=null),d.push({url:a.url,line:a.line,column:a.column,symbol:a.func,context:c,type:"minified"});return[{name:"Active Thread",faulted:!0,backtrace:d}]};p=function(b){var d;d=function(b){return 10>b?"0"+b:b};return""+b.getUTCFullYear()+"-"+d(b.getUTCMonth()+
9
- 1)+"-"+d(b.getUTCDate())+"T"+d(b.getUTCHours())+":"+d(b.getUTCMinutes())+":"+d(b.getUTCSeconds())+"Z"};s=function(b,d){var c,a,i;if(b instanceof Array){a=0;for(i=b.length;a<i;a++)if(c=b[a],d(c))return!0}else for(c in b)if(f.call(b,c)&&(a=b[c],d(c,a)))return!0;return!1};g=function(b,d){var c,a,i;i=[];for(c in d)f.call(d,c)&&(a=d[c],i.push(b[c]=a));return i};m=e}).call(this);var TraceKit={};
10
- TraceKit.report=function(){function m(e,k){var f=null,g;for(g in h)if(h.hasOwnProperty(g))try{h[g](e,k)}catch(b){f=b}if(f)throw f;}function f(p){if(k){if(e===p)return;var h=k;e=k=null;m(h,p)}var f=TraceKit.computeStackTrace(p);k=f;e=p;window.setTimeout(function(){e===p&&(e=k=null,m(f,p))},f.incomplete?2E3:0);throw p;}var h=[],e=null,k=null,v=window.onerror;window.onerror=function(p,f,h){var g=null,b=null;k?(TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(k,f,h,p),g=k,b=e,e=k=null):
11
- (g={url:f,line:h},g.func=TraceKit.computeStackTrace.guessFunctionName(g.url,g.line),g.context=TraceKit.computeStackTrace.gatherContext(g.url,g.line),g={mode:"onerror",message:p,stack:[g]});m(g,b);return v?v.apply(this,arguments):!1};f.subscribe=function(e){h.push(e)};f.unsubscribe=function(e){for(var f=h.length-1;0<=f;--f)h[f]===e&&h.splice(f,1)};return f}();
12
- TraceKit.computeStackTrace=function(){function m(a){if(!c.hasOwnProperty(a)){var i,b=a.split("/");if(2<b.length&&b[2]===document.domain)try{void 0===XMLHttpRequest&&(XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(i){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(b){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(l){}throw Error("No XHR.");});var B=new XMLHttpRequest;B.open("GET",a,!1);
13
- B.send("");i=B.responseText}catch(d){i=""}else i=[];c[a]=i.length?i.split("\n"):[]}return c[a]}function f(a,i){var b=/function ([^(]*)\(([^)]*)\)/,d=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,c="",e=m(a),j;if(!e.length)return"?";for(var f=0;10>f;++f)if(c=e[i-f]+c,void 0!==c&&((j=d.exec(c))||(j=b.exec(c))))return j[1];return"?"}function h(a,b){var l=m(a),c=[],d=!1;if(!l.length)return null;for(var b=b-1,e=b-2,f=b+2;e<f;++e)c.push(l[e]),void 0!==l[e]&&(d=!0);return d?c:null}function e(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,
14
- "\\$&")}function k(a){return e(a).replace("<","(?:<|&lt;)").replace(">","(?:>|&gt;)").replace("&","(?:&|&amp;)").replace('"','(?:"|&quot;)').replace(/\s+/g,"\\s+")}function v(a,b){for(var l,c,d=0,e=b.length;d<e;++d)if((l=m(b[d])).length)if(l=l.join("\n"),c=a.exec(l))return{url:b[d],line:l.substring(0,c.index).split("\n").length,column:c.index-l.lastIndexOf("\n",c.index)-1};return null}function p(a,b,l){var b=m(b),a=RegExp("\\b"+e(a)+"\\b"),c,l=l-1;return b&&b.length>l&&(c=a.exec(b[l]))?c.index:null}
15
- function s(a){var b=[window.location.href],c=document.getElementsByTagName("script"),a=""+a,d;for(d=0;d<c.length;++d){var f=c[d];f.src&&b.push(f.src)}(c=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/.exec(a))?(d=c[1]?"\\s+"+c[1]:"",f=c[2].split(",").join("\\s*,\\s*"),c=e(c[3]).replace(/;$/,";?").replace(/\s+/g,"\\s+"),d=RegExp("function"+d+"\\s*\\(\\s*"+f+"\\s*\\)\\s*{\\s*"+c+"\\s*}")):d=RegExp(e(a).replace(/\s+/g,"\\s+"));if(d=v(d,b))return d;if(c=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/.exec(a)){a=
16
- c[1];c=k(c[2]);d=RegExp("on"+a+"=[\\'\"]\\s*"+c+"\\s*[\\'\"]","i");if(d=v(d,b[0]))return d;d=RegExp(c);if(d=v(d,b))return d}return null}function x(a,b,d,c){b={url:b,line:d};if(b.url&&b.line){a.incomplete=!1;b.func||(b.func=f(b.url,b.line));b.context||(b.context=h(b.url,b.line));if(c=/ '([^']+)' /.exec(c))b.column=p(c[1],b.url,b.line);if(0<a.stack.length&&a.stack[0].url===b.url){if(a.stack[0].line===b.line)return!1;if(!a.stack[0].line&&a.stack[0].func===b.func)return a.stack[0].line=b.line,a.stack[0].context=
17
- b.context,!1}a.stack.unshift(b);return a.partial=!0}a.incomplete=!0;return!1}function g(a,c){for(var d=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,e=[],h={},k,j,g=arguments.callee.caller;g;g=g.caller)if(!(g===b||g===TraceKit.report)){j={url:null,func:"?",line:null,column:null};if(g.name)j.func=g.name;else if(k=d.exec(g.toString()))j.func=k[1];if(k=s(g)){j.url=k.url;j.line=k.line;"?"===j.func&&(j.func=f(j.url,j.line));var m=/ '([^']+)' /.exec(a.message||a.description);m&&(j.column=
18
- p(m[1],k.url,k.line))}h[""+g]&&(j.recursion=!0);e.push(j)}c&&e.splice(0,c);d={mode:"callers",name:a.name,message:a.message,stack:e};x(d,a.sourceURL||a.fileName,a.line||a.lineNumber,a.message||a.description);return d}function b(a,b){var c=null,b=void 0===b?0:+b;try{for(var e=/ line (\d+), column (\d+) in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,s=a.stacktrace.split("\n"),q=[],j,x=0,L=s.length;x<L;x+=2)if(j=e.exec(s[x])){var w={line:+j[1],column:+j[2],func:j[3]||j[4],args:j[5]?
19
- j[5].split(","):[],url:j[6]};!w.func&&w.line&&(w.func=f(w.url,w.line));if(w.line)try{w.context=h(w.url,w.line)}catch(U){}w.context||(w.context=[s[x+1]]);q.push(w)}c=q.length?{mode:"stacktrace",name:a.name,message:a.message,stack:q}:null;if(c)return c}catch(M){if(d)throw M;}try{if(a.stack){var e=/^\s*at (?:new )?(.+) (?:\[as \S+\] )?\(((?:file|http):.*?):(\d+)(?::(\d+))?\)\s*$/i,s=/^\s*(\S*)(?:\((.*?)\))?@((?:file|http).*?):(\d+)(?::(\d+))?\s*$/i,D=a.stack.split("\n"),q=[],r,t,C=/^(.*) is undefined$/.exec(a.message);
20
- j=0;for(var F=D.length;j<F;++j){if(r=s.exec(D[j]))t={url:r[3],func:r[1],args:r[2]?r[2].split(","):"",line:+r[4],column:r[5]?+r[5]:null};else if(r=e.exec(D[j]))t={url:r[2],func:r[1],line:+r[3],column:r[4]?+r[4]:null};else continue;!t.func&&t.line&&(t.func=f(t.url,t.line));t.line&&(t.context=h(t.url,t.line));q.push(t)}q[0]&&(q[0].line&&!q[0].column&&C)&&(q[0].column=p(C[1],q[0].url,q[0].line));c=q.length?{mode:"stack",name:a.name,message:a.message,stack:q}:null}else c=null;if(c)return c}catch(N){if(d)throw N;
21
- }try{var z=a.message.split("\n");if(4>z.length)c=null;else{D=/^\s*Line (\d+) of linked script ((?:file|http)\S+)(?:: in function (\S+))?\s*$/i;r=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|http)\S+)(?:: in function (\S+))?\s*$/i;t=/^\s*Line (\d+) of function script\s*$/i;var C=[],n=document.getElementsByTagName("script"),F=[],y,u,H,A;for(u in n)n.hasOwnProperty(u)&&!n[u].src&&F.push(n[u]);u=2;for(H=z.length;u<H;u+=2){n=null;if(y=D.exec(z[u]))n={url:y[2],func:y[3],line:+y[1]};else if(y=r.exec(z[u])){var n=
22
- {url:y[3],func:y[4]},O=+y[1],I=F[y[2]-1];if(I&&(A=m(n.url))){A=A.join("\n");var J=A.indexOf(I.innerText);0<=J&&(n.line=O+A.substring(0,J).split("\n").length)}}else if(y=t.exec(z[u])){var K=window.location.href.replace(/#.*$/,""),P=y[1],Q=RegExp(k(z[u+1]));A=v(Q,[K]);n={url:K,line:A?A.line:P,func:""}}if(n){n.func||(n.func=f(n.url,n.line));var E=h(n.url,n.line),R=E?E[Math.floor(E.length/2)]:null;n.context=E&&R.replace(/^\s*/,"")===z[u+1].replace(/^\s*/,"")?E:[z[u+1]];C.push(n)}}c=C.length?{mode:"multiline",
23
- name:a.name,message:z[0],stack:C}:null}if(c)return c}catch(S){if(d)throw S;}try{if(c=g(a,b+1))return c}catch(T){if(d)throw T;}return{mode:"failed"}}var d=!1,c={};b.augmentStackTraceWithInitialElement=x;b.guessFunctionName=f;b.gatherContext=h;b.ofCaller=function(a){a=(void 0===a?0:+a)+1;try{0()}catch(c){return b(c,a+1)}return null};return b}();
24
- (function(m){var f=Array.prototype.slice,h=m.setTimeout;m.setTimeout=function(){var e=f.call(arguments,0),m=e[0];e[0]=function(){try{m.apply(this,arguments)}catch(e){throw TraceKit.report(e),e;}};return h.apply(this,e)};var e=m.setInterval;m.setInterval=function(){var k=f.call(arguments,0),h=k[0];k[0]=function(){try{h.apply(this,arguments)}catch(e){throw TraceKit.report(e),e;}};return e.apply(this,k)}})(window);
1
+ (function(){var g,f={}.hasOwnProperty,i=[].slice,e="undefined"!==typeof exports&&null!==exports?exports:this,k=function(){},r;r=void 0;k.instance=function(){return null!=r?r:r=new g};e.SquashJavascript=k;var e=function(){TraceKit.report.subscribe(function(c,b){return SquashJavascript.instance().report(c,b)})},n,m,v,A;e.prototype.configure=function(c){var b,d,a;this.options||(this.options={disabled:!1,notifyPath:"/api/1.0/notify",transmitTimeout:15E3,ignoredExceptionClasses:[],ignoredExceptionMessages:{}});
2
+ a=[];for(b in c)f.call(c,b)&&(d=c[b],a.push(this.options[b]=d));return a};e.prototype.notify=function(c,b){if(c instanceof Error)return c._squash_user_data=b,TraceKit.report(c);throw c;};e.prototype.report=function(c,b){var d,a,j,x,F,G,p,h,e,k,i,m;try{if(null!=(G=this.options)&&G.disabled)return!1;if(!(null!=(p=this.options)&&p.APIKey)||!(null!=(h=this.options)&&h.environment)||!(null!=(e=this.options)&&e.revision)||!(null!=(k=this.options)&&k.APIHost))return console.error("Missing required Squash configuration keys"),
3
+ !1;if(this.shouldIgnoreError(c)||!c.stack)return!1;a={};a.api_key=this.options.APIKey;a.environment=this.options.environment;a.client="javascript";a.revision=this.options.revision;a.class_name=null!=(i=c.type)?i:c.name;!c.name&&(x=c.message.match(/^(Uncaught )?(\w+): (.+)/))?(a.class_name=x[2],a.message=x[3]):a.message=c.message;null==a.class_name&&(a.class_name="Error");a.backtraces=v(c.stack);a.capture_method=c.mode;a.occurred_at=n(new Date);a.schema=window.location.protocol.replace(/:$/,"");a.host=
4
+ window.location.hostname;0<window.location.port.length&&(a.port=window.location.port);a.path=window.location.pathname;a.query=window.location.search;""!==window.location.hash&&(a.fragment=window.location.hash);a.user_agent=navigator.userAgent;a.screen_width=screen.width;a.screen_height=screen.height;a.window_width=window.innerWidth;a.window_height=window.innerHeight;a.color_depth=screen.colorDepth;if(b)for(j in m=b._squash_user_data,m)f.call(m,j)&&(F=m[j],a[j]=F);d=JSON.stringify(a);this.HTTPTransmit(this.options.APIHost+
5
+ this.options.notifyPath,[["Content-Type","application/json"]],d);return!0}catch(g){return console.error("Error while trying to notify Squash:",g.stack),console.error("-- original error:",c)}};e.prototype.addUserData=function(c,b){try{return b()}catch(d){throw null==d._squash_user_data&&(d._squash_user_data={}),A(d._squash_user_data,c),d;}};e.prototype.addingUserData=function(c,b){return function(){var d;d=1<=arguments.length?i.call(arguments,0):[];return SquashJavascript.instance().addUserData(c,
6
+ function(){return b.apply(null,d)})}};e.prototype.ignoreExceptions=function(){var c,b;b=2<=arguments.length?i.call(arguments,0,c=arguments.length-1):(c=0,[]);c=arguments[c++];try{return c()}catch(d){throw d._squash_ignored_exceptions=(d._squash_ignored_exceptions||[]).concat(b),d;}};e.prototype.ignoringExceptions=function(){var c,b,d;b=2<=arguments.length?i.call(arguments,0,d=arguments.length-1):(d=0,[]);c=arguments[d++];return function(){var a,j;a=1<=arguments.length?i.call(arguments,0):[];return(j=
7
+ SquashJavascript.instance()).ignoreExceptions.apply(j,i.call(b).concat([function(){return c.apply(null,a)}]))}};e.prototype.HTTPTransmit=function(c,b,d){var a,j,x;a=new XMLHttpRequest;a.open("POST",c,!0);a.timeout=this.options.transmitTimeout;j=0;for(x=b.length;j<x;j++)c=b[j],a.setRequestHeader(c[0],c[1]);a.send(d);return a};e.prototype.shouldIgnoreError=function(c){var b;b=this.options.ignoredExceptionClasses.concat(c._squash_ignored_exceptions||[]);return m(b,function(b){return c.name===b})?!0:
8
+ m(this.options.ignoredExceptionMessages,function(b,a){return c.name===b?m(a,function(a){return c.message.match(a)}):!1})};v=function(c){var b,d,a,j,x;b=[];j=0;for(x=c.length;j<x;j++)a=c[j],(d=a.context)&&m(d,function(a){return a&&200<a.length})&&(d=null),b.push({url:a.url,line:a.line,column:a.column,symbol:a.func,context:d,type:"js:hosted"});return[{name:"Active Thread",faulted:!0,backtrace:b}]};n=function(c){var b;b=function(c){return 10>c?"0"+c:c};return""+c.getUTCFullYear()+"-"+b(c.getUTCMonth()+
9
+ 1)+"-"+b(c.getUTCDate())+"T"+b(c.getUTCHours())+":"+b(c.getUTCMinutes())+":"+b(c.getUTCSeconds())+"Z"};m=function(c,b){var d,a,j;if(c instanceof Array){a=0;for(j=c.length;a<j;a++)if(d=c[a],b(d))return!0}else for(d in c)if(f.call(c,d)&&(a=c[d],b(d,a)))return!0;return!1};A=function(c,b){var d,a,j;j=[];for(d in b)f.call(b,d)&&(a=b[d],j.push(c[d]=a));return j};g=e}).call(this);var TraceKit={};
10
+ TraceKit.report=function(){function g(e,k){var g=null,f;for(f in i)if(i.hasOwnProperty(f))try{i[f](e,k)}catch(c){g=c}if(g)throw g;}function f(n){if(k){if(e===n)return;var i=k;e=k=null;g(i,n)}var f=TraceKit.computeStackTrace(n);k=f;e=n;window.setTimeout(function(){e===n&&(e=k=null,g(f,n))},f.incomplete?2E3:0);throw n;}var i=[],e=null,k=null,r=window.onerror;window.onerror=function(n,f,i,A,c){var b=null,d=null;c&&(b=TraceKit.computeStackTrace(c));b||(k?(TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(k,f,
11
+ i,A,n),b=k,d=e,e=k=null):(b={url:f,line:i,column:A},b.func=TraceKit.computeStackTrace.guessFunctionName(b.url,b.line),b.context=TraceKit.computeStackTrace.gatherContext(b.url,b.line),b={mode:"onerror",message:n,stack:[b]}));g(b,d);return r?r.apply(this,arguments):!1};f.subscribe=function(e){i.push(e)};f.unsubscribe=function(e){for(var f=i.length-1;0<=f;--f)i[f]===e&&i.splice(f,1)};return f}();
12
+ TraceKit.computeStackTrace=function(){function g(a){if(!d.hasOwnProperty(a)){var j,c=a.split("/");if(2<c.length&&c[2]===document.domain)try{void 0===XMLHttpRequest&&(XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(j){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(c){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(b){}throw Error("No XHR.");});var b=new XMLHttpRequest;b.open("GET",a,!1);
13
+ b.send("");j=b.responseText}catch(e){j=""}else j=[];d[a]=j.length?j.split("\n"):[]}return d[a]}function f(a,j){var c=/function ([^(]*)\(([^)]*)\)/,b=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,d="",e=g(a),h;if(!e.length)return"?";for(var f=0;10>f;++f)if(d=e[j-f]+d,void 0!==d&&((h=b.exec(d))||(h=c.exec(d))))return h[1];return"?"}function i(a,c){var b=g(a),d=[],e=!1;if(!b.length)return null;for(var c=c-1,f=c-2,h=c+2;f<h;++f)d.push(b[f]),void 0!==b[f]&&(e=!0);return e?d:null}function e(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,
14
+ "\\$&")}function k(a){return e(a).replace("<","(?:<|&lt;)").replace(">","(?:>|&gt;)").replace("&","(?:&|&amp;)").replace('"','(?:"|&quot;)').replace(/\s+/g,"\\s+")}function r(a,c){for(var b,d,f=0,e=c.length;f<e;++f)if((b=g(c[f])).length)if(b=b.join("\n"),d=a.exec(b))return{url:c[f],line:b.substring(0,d.index).split("\n").length,column:d.index-b.lastIndexOf("\n",d.index)-1};return null}function n(a,c,b){var c=g(c),a=RegExp("\\b"+e(a)+"\\b"),d,b=b-1;return c&&c.length>b&&(d=a.exec(c[b]))?d.index:null}
15
+ function m(a){var c=[window.location.href],b=document.getElementsByTagName("script"),a=""+a,d;for(d=0;d<b.length;++d){var f=b[d];f.src&&c.push(f.src)}(b=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/.exec(a))?(d=b[1]?"\\s+"+b[1]:"",f=b[2].split(",").join("\\s*,\\s*"),b=e(b[3]).replace(/;$/,";?").replace(/\s+/g,"\\s+"),d=RegExp("function"+d+"\\s*\\(\\s*"+f+"\\s*\\)\\s*{\\s*"+b+"\\s*}")):d=RegExp(e(a).replace(/\s+/g,"\\s+"));if(d=r(d,c))return d;if(b=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/.exec(a)){a=
16
+ b[1];b=k(b[2]);d=RegExp("on"+a+"=[\\'\"]\\s*"+b+"\\s*[\\'\"]","i");if(d=r(d,c[0]))return d;d=RegExp(b);if(d=r(d,c))return d}return null}function v(a,b,c,d,e){b={url:b,line:c,column:e};if(b.url&&b.line){a.incomplete=!1;b.func||(b.func=f(b.url,b.line));b.context||(b.context=i(b.url,b.line));if(e=/ '([^']+)' /.exec(e))b.column=n(e[1],b.url,b.line);if(0<a.stack.length&&a.stack[0].url===b.url){if(a.stack[0].line===b.line)return!1;if(!a.stack[0].line&&a.stack[0].func===b.func)return a.stack[0].line=b.line,
17
+ a.stack[0].context=b.context,!1}a.stack.unshift(b);return a.partial=!0}a.incomplete=!0;return!1}function A(a,b){for(var d=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,e=[],i={},k,h,g=arguments.callee.caller;g;g=g.caller)if(!(g===c||g===TraceKit.report)){h={url:null,func:"?",line:null,column:null};if(g.name)h.func=g.name;else if(k=d.exec(g.toString()))h.func=k[1];if(k=m(g)){h.url=k.url;h.line=k.line;"?"===h.func&&(h.func=f(h.url,h.line));var r=/ '([^']+)' /.exec(a.message||
18
+ a.description);r&&(h.column=n(r[1],k.url,k.line))}i[""+g]&&(h.recursion=!0);e.push(h)}b&&e.splice(0,b);d={mode:"callers",name:a.name,message:a.message,stack:e};v(d,a.sourceURL||a.fileName,a.line||a.lineNumber,a.message||a.description);return d}function c(a,c){var d=null,c=void 0===c?0:+c;try{for(var e=/ line (\d+), column (\d+) in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,m=a.stacktrace.split("\n"),p=[],h,v=0,L=m.length;v<L;v+=2)if(h=e.exec(m[v])){var u={line:+h[1],column:+h[2],
19
+ func:h[3]||h[4],args:h[5]?h[5].split(","):[],url:h[6]};!u.func&&u.line&&(u.func=f(u.url,u.line));if(u.line)try{u.context=i(u.url,u.line)}catch(U){}u.context||(u.context=[m[v+1]]);p.push(u)}d=p.length?{mode:"stacktrace",name:a.name,message:a.message,stack:p}:null;if(d)return d}catch(M){if(b)throw M;}try{if(a.stack){var e=/^\s*at (?:new )?(.+) (?:\[as \S+\] )?\(((?:file|https?):.*?):(\d+)(?::(\d+))?\)\s*$/i,m=/^\s*(\S*)(?:\((.*?)\))?@((?:file|http).*?):(\d+)(?::(\d+))?\s*$/i,C=a.stack.split("\n"),p=
20
+ [],q,s,B=/^(.*) is undefined$/.exec(a.message);h=0;for(var E=C.length;h<E;++h){if(q=m.exec(C[h]))s={url:q[3],func:q[1],args:q[2]?q[2].split(","):"",line:+q[4],column:q[5]?+q[5]:null};else if(q=e.exec(C[h]))s={url:q[2],func:q[1],line:+q[3],column:q[4]?+q[4]:null};else continue;!s.func&&s.line&&(s.func=f(s.url,s.line));s.line&&(s.context=i(s.url,s.line));p.push(s)}p[0]&&(p[0].line&&!p[0].column&&B)&&(p[0].column=n(B[1],p[0].url,p[0].line));d=p.length?{mode:"stack",name:a.name,message:a.message,stack:p}:
21
+ null}else d=null;if(d)return d}catch(N){if(b)throw N;}try{var y=a.message.split("\n");if(4>y.length)d=null;else{C=/^\s*Line (\d+) of linked script ((?:file|http)\S+)(?:: in function (\S+))?\s*$/i;q=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|http)\S+)(?:: in function (\S+))?\s*$/i;s=/^\s*Line (\d+) of function script\s*$/i;var B=[],l=document.getElementsByTagName("script"),E=[],w,t,H,z;for(t in l)l.hasOwnProperty(t)&&!l[t].src&&E.push(l[t]);t=2;for(H=y.length;t<H;t+=2){l=null;if(w=C.exec(y[t]))l=
22
+ {url:w[2],func:w[3],line:+w[1]};else if(w=q.exec(y[t])){var l={url:w[3],func:w[4]},O=+w[1],I=E[w[2]-1];if(I&&(z=g(l.url))){z=z.join("\n");var J=z.indexOf(I.innerText);0<=J&&(l.line=O+z.substring(0,J).split("\n").length)}}else if(w=s.exec(y[t])){var K=window.location.href.replace(/#.*$/,""),P=w[1],Q=RegExp(k(y[t+1]));z=r(Q,[K]);l={url:K,line:z?z.line:P,func:""}}if(l){l.func||(l.func=f(l.url,l.line));var D=i(l.url,l.line),R=D?D[Math.floor(D.length/2)]:null;l.context=D&&R.replace(/^\s*/,"")===y[t+1].replace(/^\s*/,
23
+ "")?D:[y[t+1]];B.push(l)}}d=B.length?{mode:"multiline",name:a.name,message:y[0],stack:B}:null}if(d)return d}catch(S){if(b)throw S;}try{if(d=A(a,c+1))return d}catch(T){if(b)throw T;}return{mode:"failed"}}var b=!1,d={};c.augmentStackTraceWithInitialElement=v;c.guessFunctionName=f;c.gatherContext=i;c.ofCaller=function(a){a=(void 0===a?0:+a)+1;try{0()}catch(b){return c(b,a+1)}return null};return c}();
24
+ (function(g){var f=Array.prototype.slice,i=g.setTimeout;g.setTimeout=function(){var e=f.call(arguments,0),g=e[0];e[0]=function(){try{g.apply(this,arguments)}catch(e){throw TraceKit.report(e),e;}};return i.apply(this,e)};var e=g.setInterval;g.setInterval=function(){var g=f.call(arguments,0),i=g[0];g[0]=function(){try{i.apply(this,arguments)}catch(e){throw TraceKit.report(e),e;}};return e.apply(this,g)}})(window);
@@ -219,7 +219,7 @@
219
219
  column: line.column,
220
220
  symbol: line.func,
221
221
  context: context,
222
- type: 'minified'
222
+ type: 'js:hosted'
223
223
  });
224
224
  }
225
225
  return [
metadata CHANGED
@@ -1,113 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squash_javascript
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: !binary |-
20
- My4x
19
+ version: '3.1'
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - ! '>='
24
+ - - '>='
26
25
  - !ruby/object:Gem::Version
27
- version: !binary |-
28
- My4x
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sprockets
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
29
41
  - !ruby/object:Gem::Dependency
30
42
  name: json
31
43
  requirement: !ruby/object:Gem::Requirement
32
44
  requirements:
33
- - - ! '>='
45
+ - - '>='
34
46
  - !ruby/object:Gem::Version
35
47
  version: '0'
36
48
  type: :runtime
37
49
  prerelease: false
38
50
  version_requirements: !ruby/object:Gem::Requirement
39
51
  requirements:
40
- - - ! '>='
52
+ - - '>='
41
53
  - !ruby/object:Gem::Version
42
54
  version: '0'
43
55
  - !ruby/object:Gem::Dependency
44
56
  name: squash_uploader
45
57
  requirement: !ruby/object:Gem::Requirement
46
58
  requirements:
47
- - - ! '>='
59
+ - - '>='
48
60
  - !ruby/object:Gem::Version
49
61
  version: '0'
50
62
  type: :runtime
51
63
  prerelease: false
52
64
  version_requirements: !ruby/object:Gem::Requirement
53
65
  requirements:
54
- - - ! '>='
66
+ - - '>='
55
67
  - !ruby/object:Gem::Version
56
68
  version: '0'
57
69
  - !ruby/object:Gem::Dependency
58
- name: yard
70
+ name: sourcemap
59
71
  requirement: !ruby/object:Gem::Requirement
60
72
  requirements:
61
- - - ! '>='
73
+ - - '>='
62
74
  - !ruby/object:Gem::Version
63
75
  version: '0'
64
- type: :development
76
+ type: :runtime
65
77
  prerelease: false
66
78
  version_requirements: !ruby/object:Gem::Requirement
67
79
  requirements:
68
- - - ! '>='
80
+ - - '>='
69
81
  - !ruby/object:Gem::Version
70
82
  version: '0'
71
83
  - !ruby/object:Gem::Dependency
72
- name: redcarpet
84
+ name: yard
73
85
  requirement: !ruby/object:Gem::Requirement
74
86
  requirements:
75
- - - ! '>='
87
+ - - '>='
76
88
  - !ruby/object:Gem::Version
77
89
  version: '0'
78
90
  type: :development
79
91
  prerelease: false
80
92
  version_requirements: !ruby/object:Gem::Requirement
81
93
  requirements:
82
- - - ! '>='
94
+ - - '>='
83
95
  - !ruby/object:Gem::Version
84
96
  version: '0'
85
97
  - !ruby/object:Gem::Dependency
86
- name: jeweler
98
+ name: redcarpet
87
99
  requirement: !ruby/object:Gem::Requirement
88
100
  requirements:
89
- - - ! '>='
101
+ - - '>='
90
102
  - !ruby/object:Gem::Version
91
103
  version: '0'
92
104
  type: :development
93
105
  prerelease: false
94
106
  version_requirements: !ruby/object:Gem::Requirement
95
107
  requirements:
96
- - - ! '>='
108
+ - - '>='
97
109
  - !ruby/object:Gem::Version
98
110
  version: '0'
99
111
  - !ruby/object:Gem::Dependency
100
- name: rspec
112
+ name: jeweler
101
113
  requirement: !ruby/object:Gem::Requirement
102
114
  requirements:
103
- - - ! '>='
115
+ - - '>='
104
116
  - !ruby/object:Gem::Version
105
117
  version: '0'
106
118
  type: :development
107
119
  prerelease: false
108
120
  version_requirements: !ruby/object:Gem::Requirement
109
121
  requirements:
110
- - - ! '>='
122
+ - - '>='
111
123
  - !ruby/object:Gem::Version
112
124
  version: '0'
113
125
  description: This client library records exceptions in front-end JavaScript code to
@@ -124,11 +136,17 @@ files:
124
136
  - README.md
125
137
  - bin/upload_source_map
126
138
  - lib/squash/javascript.rb
139
+ - lib/squash/javascript/capistrano.rb
127
140
  - lib/squash/javascript/engine.rb
128
- - lib/squash/javascript/source_map.rb
141
+ - lib/squash/javascript/patches.rb
142
+ - lib/squash/javascript/railtie.rb
143
+ - lib/squash/javascript/source_mapping_coffeescript_template.rb
144
+ - lib/squash/javascript/source_mapping_javascript_minifier.rb
145
+ - lib/squash/javascript/tasks/sourcemaps.rake
146
+ - lib/tasks/squash.cap
129
147
  - vendor/assets/javascripts/squash_javascript.min.js
130
148
  - vendor/assets/javascripts/squash_javascript.orig.js
131
- - vendor/assets/javascripts/squash_javascript/client.coffee
149
+ - vendor/assets/javascripts/squash_javascript/client.js.coffee
132
150
  - vendor/assets/javascripts/squash_javascript/index.js
133
151
  - vendor/assets/javascripts/squash_javascript/tracekit.js
134
152
  homepage: http://github.com/SquareSquash/javascript
@@ -141,12 +159,12 @@ require_paths:
141
159
  - lib
142
160
  required_ruby_version: !ruby/object:Gem::Requirement
143
161
  requirements:
144
- - - ! '>='
162
+ - - '>='
145
163
  - !ruby/object:Gem::Version
146
164
  version: '0'
147
165
  required_rubygems_version: !ruby/object:Gem::Requirement
148
166
  requirements:
149
- - - ! '>='
167
+ - - '>='
150
168
  - !ruby/object:Gem::Version
151
169
  version: '0'
152
170
  requirements: []
@@ -1,181 +0,0 @@
1
- # Copyright 2013 Square Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'json'
16
-
17
- # An in-memory representation of a JavaScript source map.
18
-
19
- class Squash::Javascript::SourceMap
20
- # @private
21
- VLQ_CONTINUATION_BIT = 1 << 5
22
-
23
- # @return [Array<Squash::Javascript::SourceMap::Mapping>] The individual
24
- # mappings in this source map.
25
- attr_reader :mappings
26
-
27
- # @private
28
- def initialize(entries=[])
29
- @mappings = entries
30
- sort!
31
- end
32
-
33
- # Parses a JSON version-3 source map file and generates a SourceMap from it.
34
- #
35
- # @param [String] source_file A path to a source map file.
36
- # @param [String] route The URL where the compiled JavaScript asset is
37
- # accessed.
38
- # @param [Hash] options Additional options.
39
- # @option options [String] :root If set, overrides the project root specified
40
- # in the `sourceRoot` field with this root. Absolute paths will be converted
41
- # into project-local paths (suitable for Git-blaming) using this root.
42
-
43
- def self.from_sourcemap(source_file, route, options={})
44
- fields = JSON.parse(File.read(source_file))
45
- raise "Only version 3 source maps are supported" unless fields['version'] == 3
46
-
47
- project_root = options[:root] || fields['sourceRoot'] or raise("Must specify a project root in the source map or method options")
48
- project_root << '/' unless project_root[-2..-1] == '/'
49
-
50
- route = route
51
- sources = fields['sources'].map { |source| source.sub(/^#{Regexp.escape project_root}/, '') }
52
- names = fields['names']
53
-
54
- mappings = fields['mappings'].split(';').map { |group| group.split ',' }
55
- entries = Array.new
56
-
57
- source_file_counter = 0
58
- source_line_counter = 0
59
- source_column_counter = 0
60
- symbol_counter = 0
61
- mappings.each_with_index do |group, compiled_line_number|
62
- compiled_column_counter = 0
63
- group.each do |segment|
64
- values = decode64vlq(segment)
65
- compiled_column_counter += values[0]
66
- source_file_counter += values[1] if values[1]
67
- source_line_counter += values[2] if values[2]
68
- source_column_counter += values[3] if values[3]
69
- symbol_counter += values[4] if values[4]
70
- entries << Mapping.new(
71
- route, compiled_line_number, compiled_column_counter,
72
- sources[source_file_counter], source_line_counter, source_column_counter,
73
- names[symbol_counter]
74
- )
75
- end
76
- end
77
-
78
- return new(entries)
79
- end
80
-
81
- # @private
82
- def <<(obj)
83
- @mappings << obj
84
- sort!
85
- end
86
-
87
- # Given the URL of a minified JavaScript asset, and a line and column number,
88
- # attempts to locate the original source file and line number.
89
- #
90
- # @param [String] route The URL of the JavaScript file.
91
- # @param [Fixnum] line The line number.
92
- # @param [Fixnum] column The character number within the line.
93
-
94
- def resolve(route, line, column)
95
- index = 0
96
- mapping = nil
97
- while index < mappings.length
98
- entry = mappings[index]
99
- mapping = entry if entry.route == route && entry.compiled_line == line && entry.compiled_column <= column
100
- break if entry.route > route || (entry.route == route && entry.compiled_line > line)
101
- index += 1
102
- end
103
-
104
- return mapping
105
- end
106
-
107
- private
108
-
109
- def sort!
110
- @mappings.sort_by! { |m| [m.route, m.compiled_line, m.compiled_column] }
111
- end
112
-
113
- def self.decode64vlq(string)
114
- bytes = string.bytes.to_a
115
- byte_index = 0
116
- result = []
117
-
118
- begin
119
- raise "Base-64 VLQ-encoded string unexpectedly terminated" if byte_index >= string.bytesize
120
-
121
- number = 0
122
- continuation = false
123
- shift = 0
124
- begin
125
- # each character corresponds to a 6-bit word
126
- digit = decode64(bytes[byte_index])
127
- byte_index += 1
128
- # the most significant bit is the continuation bit
129
- continuation = (digit & VLQ_CONTINUATION_BIT) != 0
130
- # the remaining bits are the number
131
- digit = digit & (VLQ_CONTINUATION_BIT - 1)
132
- # continuations are little-endian
133
- number += (digit << shift)
134
- shift += 5
135
- end while continuation
136
-
137
- # the LSB is the sign bit
138
- number = (number & 1 > 0) ? -(number >> 1) : (number >> 1)
139
- result << number
140
- end while byte_index < string.bytesize
141
-
142
- return result
143
- end
144
-
145
- def self.decode64(byte)
146
- case byte
147
- when 65..90 then byte - 65 # A..Z => 0..25
148
- when 97..122 then byte - 71 # a..z => 26..51
149
- when 48..57 then byte + 4 # 0..9 => 52..61
150
- when 43 then 62 # + => 62
151
- when 47 then 63 # / => 63
152
- else raise "Invalid byte #{byte} in base-64 VLQ string"
153
- end
154
- end
155
-
156
- class Mapping
157
- attr_accessor :route, :compiled_line, :compiled_column, :source_file, :source_line, :source_column, :symbol
158
-
159
- def self.from_json(obj)
160
- new *obj
161
- end
162
-
163
- def initialize(route, compiled_line, compiled_column, source_file, source_line, source_column, symbol)
164
- @route = route
165
- @compiled_line = compiled_line
166
- @compiled_column = compiled_column
167
- @source_file = source_file
168
- @source_line = source_line
169
- @source_column = source_column
170
- @symbol = symbol
171
- end
172
-
173
- def as_json(options=nil)
174
- [route, compiled_line, compiled_column, source_file, source_line, source_column, symbol]
175
- end
176
-
177
- def to_json(options=nil)
178
- as_json.to_json
179
- end
180
- end
181
- end