Release Notes
What changed in each release of @remotex-labs/xmap.
v6.0.1
- Fixed: A resolved stack frame names the original source, not the bundle.
stackSourceEntryrewrotefileNameonly where the source map declared asourceRoot, so a map without one - what most bundlers emit - left every frame pointing at the generated file. The mappedsourcenow replacesfileNamewhenever the position names one, still prefixed bysourceRootwhere the map declares it. Asourcethat is anhttp(s)URL keeps the generated name, since a root never prefixes an absolute URL. See stackSourceEntry. - Migration: Code that rebuilt the original path from a resolved frame - joining
sourceRootontofileNameby hand, or mapping the generated name back to a source - should readfileNameas it comes. Joining a root onto it again now doubles the prefix.
v6.0.0
Every line and column a position carries is now 1-based, and a position reports the generated location you looked up rather than the segment that answered.
ts
import { SourceService, Bias } from '@remotex-labs/xmap';
import { formatCode } from '@remotex-labs/xmap/formatter.component';
// a stack frame column rarely lands exactly on a mapped segment, so reach past the default bias
const position = source.getPosition(1, 3770, Bias.LOWER_BOUND);
position.generatedColumn; // 3770 - the column you looked up
position.startLine; // 1-based, counted the same way as `line`
// and formatCode/formatErrorCode take it as-is
formatCode(position.code, { startLine: position.startLine });- Changed: Stack frames survive a column the map does not hold.
stackEntryreturnedundefinedwhenevergetPositionWithCodefound nothing, dropping the frame entirely - itsformatline included - soresolveErrorsilently lost frames. The frame now comes back with itsformatline and withoutcode. See stackEntry. - Changed:
getPositionreports the generated position you looked up.generatedLineandgeneratedColumnnow echo the arguments rather than describing the segment that answered the lookup, so they line up with the column an engine reports in a stack frame.getPositionByOriginalis unaffected - there the generated position is the answer. See Retrieving Position Information. - Changed:
Bias.BOUNDanswers within one column of the column you asked for. It matched the exact column only, and a reported column commonly sits a column away from the one the bundler emitted the segment at, so a position that was in fact mapped came back as unmapped.getSegment- andgetPosition,getPositionWithCodeandresolveErrorthrough it - now returns the segment atcolumn,column - 1orcolumn + 1, preferring the lower one when both neighbours are a column away, and stillnullfor anything further. A one-sided bias is unaffected, andgetOriginalSegmentis unchanged:BOUNDstays exact there. See Bias. - Changed:
startLineandendLineonPositionWithCodeInterfaceare 1-based. They were 0-based indices sitting beside a 1-basedline, and they are now the numbers of the first and last line held incode, soline - startLineis the error's offset within it.stratLineon a formatted stack frame carriesstartLinestraight through, so it shifts by one as well. See Working with Code Snippets. - Changed:
formatCodeandformatErrorCodetake a 1-basedstartLine, matching whatgetPositionWithCodereturns.formatCodepreviously treated it as a 0-based offset and numbered its first linestartLine + 1. It now numbers itstartLine, and the default rose from0to1so the rendered output is unchanged when the option is omitted. See formatCode. - Fixed:
resolveErrorno longer returns an empty stack for a map withoutsourcesContent.stackEntrytreated a failed snippet lookup as a reason to drop the frame, so a map that carried no content - which many bundlers emit - lost every frame,formatline included. Enrichment failure now falls back to the plain formatted entry. See stackEntry. - Fixed:
SourceService.assignkeepssourcesContentaligned withsources. A merged map whose earlier input omitted its content used to shift every later map's content onto the wrong file, so code frames showed a different file's source. Content is now padded to each input'ssourceslength. - Fixed:
formatErrorCodeno longer truncates the marked line at the first|. A line containing||, a bitwise|, or a union type lost everything after it. It also now rejects alinepast the end of the snippet instead of rendering a frame with no caret. See formatErrorCode. - Fixed: A custom
highlightCodescheme no longer leaks into later calls. The overrides were merged into the shared default scheme, so one call with a custom color changed every call after it, process-wide. See Highlighter. - Fixed: A segment's
generatedLinematches the line it answers at. Decoding a structured array copied the incoming value through instead of renumbering it, so afterassigna forward lookup andgetPositionByOriginaldisagreed about the generated line of the same segment. - Fixed: A malformed segment fails instead of silently corrupting the map. An empty segment between two separators left the column accumulator
NaN, which broke the binary search for the whole line and re-encoded to a different map. It now throws. VLQ values outside the range the 32-bit chunking can carry throw as well, in both directions:encodeVLQrejects a magnitude above2^30 - 1instead of wrapping it to a different number, anddecodeVLQrejects an over-long sequence instead of wrapping the shift count. - Fixed: An empty
mappingsstring is accepted. It is what a valid v3 map carries when it maps nothing, and it used to be rejected as "contains characters outside the VLQ alphabet". - Fixed: Stack-frame flags are no longer set by the file path.
constructorandasynccame from scanning the whole line fornewandasync, sorenewSessionor a frame undernode_modules/newrelictripped them. V8 frames now match theat newandat asyncmarkers V8 actually writes, and the other engines only inspect the function name. - Fixed:
formatStackLineno longer emits#Lundefinedfor anhttp(s)frame with no line number, and a local file namedhttpClient.tsis no longer treated as a remote URL. - Migration: A resolver that relied on the default bias to enrich stack frames should pass
Bias.LOWER_BOUNDexplicitly.Bias.BOUNDreaches one column either way and no further, so a frame whose column sits further than that from any mapping still comes back withoutcode. - Migration: Drop any
+ 1applied tostartLine/endLinewhen displaying them, and drop any- 1applied before handingstartLinetoformatCode. AstartLinepassed toformatCodeas a literal needs+ 1to render the same numbers as before.stratLineon a resolved stack frame moves with them. - Migration: Code that treated a missing
stackEntryresult as "this frame has no mapping" will now see those frames come back resolved. Nothing needs changing to get the frames, so drop any workaround that re-added them by hand. - Migration: Code reading
generatedColumnto find where the matching segment sits should read it frommappings.getSegmentdirectly.
Earlier releases
Documentation for previous versions stays available in the archive:
- v5.1.x -
lineOffsetandsourceRooton resolved frames, andErrorCodeType. - v5.0.x - the mapping rewrite,
resolve.service, andpath.component. - v4.0.x - stack parser fixes and
getStackWithoutMessage.
