Collects V8 line coverage from a page's stopJSCoverage() result and merges it into the
run's shared coverage map.
Approach (line coverage): V8 reports per-function byte-offset ranges with hit counts against
the bundle (tests.js). We paint those counts across the bundle, then walk the bundle's
source-map segments — each maps a bundle position back to an original (file, line) — and mark
that original line coverable, and covered when the painted count at the mapped position is > 0.
This reuses the same decoded source map the TAP at: resolver already builds, and attributes
coverage to the original files the user wrote rather than the concatenated bundle.
node_modules sources are dropped here; the report layer additionally drops the test entry files.
import * as Coverage from './index.ts'; const entry = { // the shape playwright's page.coverage.stopJSCoverage() returns per script url: 'http://localhost:1234/tests.js', scriptId: '5', functions: [ { functionName: 'add', isBlockCoverage: true, ranges: [{ count: 2, startOffset: 0, endOffset: 40 }] }, ], }; entry.functions[0].ranges[0].count; // 2 — V8's hit count for that byte range of the bundle