Skip to main content

Crate oxc_coverage_v8

Crate oxc_coverage_v8 

Source
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§

V8CoverageRange
A single V8 coverage range.
V8FunctionCoverage
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 FileCoverage from 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.