Expand description
V8 inspector coverage to Istanbul FileCoverage conversion.
V8’s inspector protocol reports coverage as [startOffset, endOffset, count]
ranges grouped by function. Istanbul reporters consume per-statement,
per-function, and per-branch hit counts keyed by (line, column). This crate
takes a pre-built FileCoverage (typically produced by an AST-traversal
pass in an instrumenter) and fills in its hit-count vectors from V8 ranges.
§Position semantics
Istanbul’s Position is 1-based line + 0-based UTF-16 column. V8 ranges are
absolute UTF-16 code-unit offsets into the V8-visible source. Oxc branch
body spans use UTF-8 byte offsets, so this crate converts source-side
coordinates to absolute UTF-16 offsets before intersecting V8 ranges.
§Wrapper base
Node wraps every CommonJS module in (function(exports,require,module,...){.
Some coverage producers report offsets relative to a wrapped source. Pass
their wrapper prefix length in UTF-16 code units so source-side coordinates
use the same base. Node inspector coverage is normally source-relative, so
its wrapper length is zero.
§Companion helpers for inline / external source maps
V8 coverage data does not carry source-map information; the source itself
does, via a //# sourceMappingURL= trailer. extract_inline_source_map
decodes the inline data:application/json form and
extract_external_source_mapping_url reports the trailer URL when it is
not a data URL. Callers can attach the result as FileCoverage.input_source_map
and chain through oxc_coverage_source_maps::remap_coverage to resolve
positions back to the original source.
Structs§
- V8Coverage
Range - A single V8 coverage range.
- V8Function
Coverage - A function’s coverage data as reported by the V8 inspector.
Functions§
- apply_
v8_ coverage - Fill in the statement, function and branch hit counts of a pre-built
FileCoveragefrom V8’s coverage ranges. - extract_
external_ source_ mapping_ url - Read the URL of a trailing
//# sourceMappingURL=<url>comment. - extract_
inline_ source_ map - Decode the source map embedded in a trailing
//# sourceMappingURL=data:application/json,...comment.