@@ -578,7 +578,7 @@ function retrieveSourceMapURL(source) {
578
578
579
579
// Get the URL of the source map
580
580
fileData = retrieveFile ( source ) ;
581
- var re = / (?: \/ \/ [ @ # ] [ \s ] * s o u r c e M a p p i n g U R L = ( [ ^ \s ' " ] + ) [ \s ] * $ ) | (?: \/ \* [ @ # ] [ \s ] * s o u r c e M a p p i n g U R L = ( [ ^ \s * ' " ] + ) [ \s ] * (?: \* \/ ) [ \s ] * $ ) / mg;
581
+ var re = / (?: \/ \/ [ @ # ] [ \t ] + s o u r c e M a p p i n g U R L = ( [ ^ \s ' " ] + ? ) [ \t ] * $ ) | (?: \/ \* [ @ # ] [ \t ] + s o u r c e M a p p i n g U R L = ( [ ^ \* ] + ? ) [ \t ] * (?: \* \/ ) [ \t ] * $ ) / mg;
582
582
// Keep executing the search to find the *last* sourceMappingURL to avoid
583
583
// picking up sourceMappingURLs from comments, strings, etc.
584
584
var lastMatch , match ;
@@ -651,7 +651,7 @@ function mapSourcePosition(position) {
651
651
}
652
652
653
653
// Resolve the source URL relative to the URL of the source map
654
- if ( sourceMap && sourceMap . map && typeof sourceMap . map . originalPositionFor === 'function' ) {
654
+ if ( sourceMap && sourceMap . map ) {
655
655
var originalPosition = sourceMap . map . originalPositionFor ( position ) ;
656
656
657
657
// Only return the original position if a matching line was found. If no
@@ -776,13 +776,8 @@ function cloneCallSite(frame) {
776
776
return object ;
777
777
}
778
778
779
- function wrapCallSite ( frame , state ) {
780
- // provides interface backward compatibility
781
- if ( state === undefined ) {
782
- state = { nextPosition : null , curPosition : null }
783
- }
779
+ function wrapCallSite ( frame ) {
784
780
if ( frame . isNative ( ) ) {
785
- state . curPosition = null ;
786
781
return frame ;
787
782
}
788
783
@@ -796,11 +791,7 @@ function wrapCallSite(frame, state) {
796
791
797
792
// Fix position in Node where some (internal) code is prepended.
798
793
// See https://github.com/evanw/node-source-map-support/issues/36
799
- // Header removed in node at ^10.16 || >=11.11.0
800
- // v11 is not an LTS candidate, we can just test the one version with it.
801
- // Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
802
- var noHeader = / ^ v ( 1 0 \. 1 [ 6 - 9 ] | 1 0 \. [ 2 - 9 ] [ 0 - 9 ] | 1 0 \. [ 0 - 9 ] { 3 , } | 1 [ 2 - 9 ] \d * | [ 2 - 9 ] \d | \d { 3 , } | 1 1 \. 1 1 ) / ;
803
- var headerLength = noHeader . test ( process . version ) ? 0 : 62 ;
794
+ var headerLength = 62 ;
804
795
if ( line === 1 && column > headerLength && ! isInBrowser ( ) && ! frame . isEval ( ) ) {
805
796
column -= headerLength ;
806
797
}
@@ -810,15 +801,9 @@ function wrapCallSite(frame, state) {
810
801
line : line ,
811
802
column : column
812
803
} ) ;
813
- state . curPosition = position ;
814
804
frame = cloneCallSite ( frame ) ;
815
805
var originalFunctionName = frame . getFunctionName ;
816
- frame . getFunctionName = function ( ) {
817
- if ( state . nextPosition == null ) {
818
- return originalFunctionName ( ) ;
819
- }
820
- return state . nextPosition . name || originalFunctionName ( ) ;
821
- } ;
806
+ frame . getFunctionName = function ( ) { return position . name || originalFunctionName ( ) ; } ;
822
807
frame . getFileName = function ( ) { return position . source ; } ;
823
808
frame . getLineNumber = function ( ) { return position . line ; } ;
824
809
frame . getColumnNumber = function ( ) { return position . column + 1 ; } ;
@@ -840,25 +825,16 @@ function wrapCallSite(frame, state) {
840
825
}
841
826
842
827
// This function is part of the V8 stack trace API, for more info see:
843
- // https ://v8.dev/docs/stack-trace-api
828
+ // http ://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
844
829
function prepareStackTrace ( error , stack ) {
845
830
if ( emptyCacheBetweenOperations ) {
846
831
fileContentsCache = { } ;
847
832
sourceMapCache = { } ;
848
833
}
849
834
850
- var name = error . name || 'Error' ;
851
- var message = error . message || '' ;
852
- var errorString = name + ": " + message ;
853
-
854
- var state = { nextPosition : null , curPosition : null } ;
855
- var processedStack = [ ] ;
856
- for ( var i = stack . length - 1 ; i >= 0 ; i -- ) {
857
- processedStack . push ( '\n at ' + wrapCallSite ( stack [ i ] , state ) ) ;
858
- state . nextPosition = state . curPosition ;
859
- }
860
- state . curPosition = state . nextPosition = null ;
861
- return errorString + processedStack . reverse ( ) . join ( '' ) ;
835
+ return error + stack . map ( function ( frame ) {
836
+ return '\n at ' + wrapCallSite ( frame ) ;
837
+ } ) . join ( '' ) ;
862
838
}
863
839
864
840
// Generate position and snippet of original source with pointer
@@ -1022,9 +998,6 @@ exports.resetRetrieveHandlers = function() {
1022
998
1023
999
retrieveFileHandlers = originalRetrieveFileHandlers . slice ( 0 ) ;
1024
1000
retrieveMapHandlers = originalRetrieveMapHandlers . slice ( 0 ) ;
1025
-
1026
- retrieveSourceMap = handlerExec ( retrieveMapHandlers ) ;
1027
- retrieveFile = handlerExec ( retrieveFileHandlers ) ;
1028
1001
}
1029
1002
1030
1003
0 commit comments