@@ -162,6 +162,9 @@ TraceKit.report = (function reportModuleWrapper() {
162
162
* @memberof TraceKit.report
163
163
*/
164
164
function subscribe ( handler ) {
165
+ // NOTE: We call both handlers manually in browser/integrations/globalhandler.ts
166
+ // So user can choose which one he wants to attach
167
+
165
168
// installGlobalHandler();
166
169
// installGlobalUnhandledRejectionHandler();
167
170
handlers . push ( handler ) ;
@@ -234,12 +237,7 @@ TraceKit.report = (function reportModuleWrapper() {
234
237
message = isErrorEvent ( message ) ? message . message : message ;
235
238
236
239
if ( lastExceptionStack ) {
237
- TraceKit . computeStackTrace . augmentStackTraceWithInitialElement (
238
- lastExceptionStack ,
239
- url ,
240
- lineNo ,
241
- message ,
242
- ) ;
240
+ TraceKit . computeStackTrace . augmentStackTraceWithInitialElement ( lastExceptionStack , url , lineNo , message ) ;
243
241
processLastException ( ) ;
244
242
} else if ( errorObj && isError ( errorObj ) ) {
245
243
stack = TraceKit . computeStackTrace ( errorObj ) ;
@@ -261,14 +259,8 @@ TraceKit.report = (function reportModuleWrapper() {
261
259
}
262
260
}
263
261
264
- location . func = TraceKit . computeStackTrace . guessFunctionName (
265
- location . url ,
266
- location . line ,
267
- ) ;
268
- location . context = TraceKit . computeStackTrace . gatherContext (
269
- location . url ,
270
- location . line ,
271
- ) ;
262
+ location . func = TraceKit . computeStackTrace . guessFunctionName ( location . url , location . line ) ;
263
+ location . context = TraceKit . computeStackTrace . gatherContext ( location . url , location . line ) ;
272
264
stack = {
273
265
name : name ,
274
266
message : msg ,
@@ -748,15 +740,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
748
740
args = parts [ 2 ] . split ( ',' ) . join ( '\\s*,\\s*' ) ;
749
741
750
742
body = escapeRegExp ( parts [ 3 ] ) . replace ( / ; $ / , ';?' ) ; // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+');
751
- re = new RegExp (
752
- 'function' +
753
- name +
754
- '\\s*\\(\\s*' +
755
- args +
756
- '\\s*\\)\\s*{\\s*' +
757
- body +
758
- '\\s*}' ,
759
- ) ;
743
+ re = new RegExp ( 'function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}' ) ;
760
744
}
761
745
762
746
// look for a normal function definition
@@ -770,10 +754,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
770
754
body = escapeCodeAsRegExpForMatchingInsideHTML ( parts [ 2 ] ) ;
771
755
772
756
// look for a function defined in HTML as an onXXX handler
773
- re = new RegExp (
774
- 'on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]' ,
775
- 'i' ,
776
- ) ;
<
6D40
/code>
757
+ re = new RegExp ( 'on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]' , 'i' ) ;
777
758
778
759
if ( ( result = findSourceInUrls ( re , urls [ 0 ] ) ) ) {
779
760
return result ;
@@ -935,8 +916,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
935
916
// Now we check to see if it's a relative URL.
936
917
// If it is, convert it to an absolute one.
937
918
if ( sourceMapAddress . charAt ( 0 ) === '~' ) {
938
- sourceMapAddress =
939
- getLocationOrigin ( ) + sourceMapAddress . slice ( 1 ) ;
919
+ sourceMapAddress = getLocationOrigin ( ) + sourceMapAddress . slice ( 1 ) ;
940
920
}
941
921
942
922
// Now we strip the '.map' off of the end of the URL and update the
@@ -946,9 +926,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
946
926
}
947
927
}
948
928
949
- element . context = element . line
950
- ? gatherContext ( element . url , element . line )
951
- : null ;
929
+ element . context = element . line ? gatherContext ( element . url , element . line ) : null ;
952
930
953
931
stack . push ( element ) ;
954
932
}
@@ -958,11 +936,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
958
936
}
959
937
960
938
if ( stack [ 0 ] && stack [ 0 ] . line && ! stack [ 0 ] . column && reference ) {
961
- stack [ 0 ] . column = findSourceInLine (
962
- reference [ 1 ] ,
963
- stack [ 0 ] . url ,
964
- stack [ 0 ] . line ,
965
- ) ;
939
+ stack [ 0 ] . column = findSourceInLine ( reference [ 1 ] , stack [ 0 ] . url , stack [ 0 ] . line ) ;
966
940
}
967
941
968
942
return {
@@ -1080,10 +1054,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1080
1054
lineRE2 = / ^ \s * L i n e ( \d + ) o f i n l i n e # ( \d + ) s c r i p t i n ( (?: f i l e | h t t p s ? | b l o b ) \S + ) (?: : i n f u n c t i o n ( \S + ) ) ? \s * $ / i,
1081
1055
lineRE3 = / ^ \s * L i n e ( \d + ) o f f u n c t i o n s c r i p t \s * $ / i,
1082
1056
stack = [ ] ,
1083
- scripts =
1084
- window &&
1085
- window . document &&
1086
- window . document . getElementsByTagName ( 'script' ) ,
1057
+ scripts = window && window . document && window . document . getElementsByTagName ( 'script' ) ,
1087
1058
inlineScriptBlocks = [ ] ,
1088
1059
parts ;
1089
1060
@@ -1119,16 +1090,13 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1119
1090
source = source . join ( '\n' ) ;
1120
1091
var pos = source . indexOf ( script . innerText ) ;
1121
1092
if ( pos >= 0 ) {
1122
- item . line =
1123
- relativeLine + source . substring ( 0 , pos ) . split ( '\n' ) . length ;
1093
+ item . line = relativeLine + source . substring ( 0 , pos ) . split ( '\n' ) . length ;
1124
1094
}
1125
1095
}
1126
1096
}
1127
1097
} else if ( ( parts = lineRE3 . exec ( lines [ line ] ) ) ) {
1128
1098
var url = getLocationHref ( ) . replace ( / # .* $ / , '' ) ;
1129
- var re = new RegExp (
1130
- escapeCodeAsRegExpForMatchingInsideHTML ( lines [ line + 1 ] ) ,
1131
- ) ;
1099
+ var re = new RegExp ( escapeCodeAsRegExpForMatchingInsideHTML ( lines [ line + 1 ] ) ) ;
1132
1100
var src = findSourceInUrls ( re , [ url ] ) ;
1133
1101
item = {
1134
1102
url : url ,
@@ -1145,10 +1113,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1145
1113
}
1146
1114
var context = gatherContext ( item . url , item . line ) ;
1147
1115
var midline = context ? context [ Math . floor ( context . length / 2 ) ] : null ;
1148
- if (
1149
- context &&
1150
- midline . replace ( / ^ \s * / , '' ) === lines [ line + 1 ] . replace ( / ^ \s * / , '' )
1151
- ) {
1116
+ if ( context && midline . replace ( / ^ \s * / , '' ) === lines [ line + 1 ] . replace ( / ^ \s * / , '' ) ) {
1152
1117
item . context = context ;
1153
1118
} else {
1154
1119
// if (context) alert("Context mismatch. Correct midline:\n" + lines[i+1] + "\n\nMidline:\n" + midline + "\n\nContext:\n" + context.join("\n") + "\n\nURL:\n" + item.url);
@@ -1183,12 +1148,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1183
1148
* augmented.
1184
1149
* @memberof TraceKit.computeStackTrace
1185
1150
*/
1186
- function augmentStackTraceWithInitialElement (
1187
- stackInfo ,
1188
- url ,
1189
- lineNo ,
1190
- message ,
1191
- ) {
1151
+ function augmentStackTraceWithInitialElement ( stackInfo , url , lineNo , message ) {
1192
1152
var initial = {
1193
1153
url : url ,
1194
1154
line : lineNo ,
@@ -1207,21 +1167,14 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1207
1167
1208
1168
var reference = / ' ( [ ^ ' ] + ) ' / . exec ( message ) ;
1209
1169
if ( reference ) {
1210
- initial . column = findSourceInLine (
1211
- reference [ 1 ] ,
1212
- initial . url ,
1213
- initial . line ,
1214
- ) ;
1170
+ initial . column = findSourceInLine ( reference [ 1 ] , initial . url , initial . line ) ;
1215
1171
}
1216
1172
1217
1173
if ( stackInfo . stack . length > 0 ) {
1218
1174
if ( stackInfo . stack [ 0 ] . url === initial . url ) {
1219
1175
if ( stackInfo . stack [ 0 ] . line === initial . line ) {
1220
1176
return false ; // already in stack trace
1221
- } else if (
1222
- ! stackInfo . stack [ 0 ] . line &&
1223
- stackInfo . stack [ 0 ] . func === initial . func
1224
- ) {
1177
+ } else if ( ! stackInfo . stack [ 0 ] . line && stackInfo . stack [ 0 ] . func === initial . func ) {
1225
1178
stackInfo . stack [ 0 ] . line = initial . line ;
1226
1179
stackInfo . stack [ 0 ] . context = initial . context ;
1227
1180
return false ;
@@ -1258,11 +1211,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
1258
1211
item ,
1259
1212
source ;
1260
1213
1261
- for (
1262
- var curr = computeStackTraceByWalkingCallerChain . caller ;
1263
- curr && ! recursion ;
1264
- curr = curr . caller
1265
- ) {
1214
+ for ( var curr = computeStackTraceByWalkingCallerChain . caller ; curr && ! recursion ; curr = curr . caller ) {
1266
1215
if ( curr === computeStackTrace || curr === TraceKit . report ) {
1267
1216
continue ;
1268
1217
}
@@ -1462,13 +1411,7 @@ if (!TraceKit.linesOfContext || TraceKit.linesOfContext < 1) {
1462
1411
1463
1412
const subscribe = TraceKit . report . subscribe ;
1464
1413
const installGlobalHandler = TraceKit . report . installGlobalHandler ;
1465
- const installGlobalUnhandledRejectionHandler =
1466
- TraceKit . report . installGlobalUnhandledRejectionHandler ;
1414
+ const installGlobalUnhandledRejectionHandler = TraceKit . report . installGlobalUnhandledRejectionHandler ;
1467
1415
const computeStackTrace = TraceKit . computeStackTrace ;
1468
1416
1469
- export {
1470
- subscribe ,
1471
- installGlobalHandler ,
1472
- installGlobalUnhandledRejectionHandler ,
1473
- computeStackTrace ,
1474
- } ;
1417
+ export { subscribe , installGlobalHandler , installGlobalUnhandledRejectionHandler , computeStackTrace } ;
0 commit comments