-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!(browser): print correct stacktrace (#3698)
- Loading branch information
1 parent
a90d64f
commit f56de2a
Showing
32 changed files
with
296 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './dist/source-map.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
export const lineSplitRE = /\r?\n/ | ||
|
||
export function positionToOffset( | ||
source: string, | ||
lineNumber: number, | ||
columnNumber: number, | ||
): number { | ||
const lines = source.split(lineSplitRE) | ||
const nl = /\r\n/.test(source) ? 2 : 1 | ||
let start = 0 | ||
|
||
if (lineNumber > lines.length) | ||
return source.length | ||
|
||
for (let i = 0; i < lineNumber - 1; i++) | ||
start += lines[i].length + nl | ||
|
||
return start + columnNumber | ||
} | ||
|
||
export function offsetToLineNumber( | ||
source: string, | ||
offset: number, | ||
): number { | ||
if (offset > source.length) { | ||
throw new Error( | ||
`offset is longer than source length! offset ${offset} > length ${source.length}`, | ||
) | ||
} | ||
const lines = source.split(lineSplitRE) | ||
const nl = /\r\n/.test(source) ? 2 : 1 | ||
let counted = 0 | ||
let line = 0 | ||
for (; line < lines.length; line++) { | ||
const lineLength = lines[line].length + nl | ||
if (counted + lineLength >= offset) | ||
break | ||
|
||
counted += lineLength | ||
} | ||
return line + 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.