oxc_coverage_v8 0.1.0

V8 inspector coverage to Istanbul FileCoverage conversion (port of v8-to-istanbul)
Documentation

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 byte offsets into the V8-visible source. This crate walks each location's UTF-16 column into a byte offset, then intersects against the V8 ranges.

CJS wrapper offset

Node wraps every CommonJS module in (function(exports,require,module,...){ before V8 sees it. V8 byte offsets are relative to that wrapped source. Pass the wrapper length (62 by default on stock Node CJS) so this crate can shift offsets back into the user's source. ESM modules and bare eval sources have a wrapper length of 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.