oxc-coverage-instrument 0.2.15 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/vitest.d.ts +2 -0
- package/vitest.js +38 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-coverage-instrument",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Istanbul-compatible JavaScript/TypeScript coverage instrumentation using the Oxc AST. 8-48x faster than istanbul-lib-instrument.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"test": "node test.mjs"
|
|
62
62
|
},
|
|
63
63
|
"optionalDependencies": {
|
|
64
|
-
"@oxc-coverage-instrument/binding-darwin-arm64": "0.
|
|
65
|
-
"@oxc-coverage-instrument/binding-darwin-x64": "0.
|
|
66
|
-
"@oxc-coverage-instrument/binding-linux-x64-gnu": "0.
|
|
67
|
-
"@oxc-coverage-instrument/binding-linux-arm64-gnu": "0.
|
|
68
|
-
"@oxc-coverage-instrument/binding-linux-x64-musl": "0.
|
|
69
|
-
"@oxc-coverage-instrument/binding-win32-x64-msvc": "0.
|
|
70
|
-
"@oxc-coverage-instrument/binding-win32-arm64-msvc": "0.
|
|
64
|
+
"@oxc-coverage-instrument/binding-darwin-arm64": "0.3.0",
|
|
65
|
+
"@oxc-coverage-instrument/binding-darwin-x64": "0.3.0",
|
|
66
|
+
"@oxc-coverage-instrument/binding-linux-x64-gnu": "0.3.0",
|
|
67
|
+
"@oxc-coverage-instrument/binding-linux-arm64-gnu": "0.3.0",
|
|
68
|
+
"@oxc-coverage-instrument/binding-linux-x64-musl": "0.3.0",
|
|
69
|
+
"@oxc-coverage-instrument/binding-win32-x64-msvc": "0.3.0",
|
|
70
|
+
"@oxc-coverage-instrument/binding-win32-arm64-msvc": "0.3.0"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/vitest.d.ts
CHANGED
|
@@ -36,4 +36,6 @@ export declare function createOxcInstrumenter(options?: OxcInstrumenterOptions):
|
|
|
36
36
|
instrumentSync(code: string, filename: string, inputSourceMap?: any): string
|
|
37
37
|
lastSourceMap(): any
|
|
38
38
|
lastFileCoverage(): any
|
|
39
|
+
/** Property alias for compatibility with vite-plugin-istanbul. */
|
|
40
|
+
readonly fileCoverage: any
|
|
39
41
|
}
|
package/vitest.js
CHANGED
|
@@ -40,8 +40,29 @@ function createOxcInstrumenter(options) {
|
|
|
40
40
|
const ignoreClassMethods = options.ignoreClassMethods || [];
|
|
41
41
|
const reportLogic = options.reportLogic || false;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// Raw JSON strings from the last instrument call — parsed lazily on first access.
|
|
44
|
+
let _lastCoverageMapJson = null;
|
|
45
|
+
let _lastSourceMapJson = null;
|
|
46
|
+
// Parsed objects — null until actually read via lastFileCoverage()/lastSourceMap().
|
|
44
47
|
let _lastFileCoverage = null;
|
|
48
|
+
let _lastSourceMap = null;
|
|
49
|
+
// Dirty flags — set to true after each instrumentSync to invalidate cached parses.
|
|
50
|
+
let _coverageDirty = false;
|
|
51
|
+
let _sourceMapDirty = false;
|
|
52
|
+
|
|
53
|
+
function ensureCoverageParsed() {
|
|
54
|
+
if (_coverageDirty && _lastCoverageMapJson !== null) {
|
|
55
|
+
_lastFileCoverage = JSON.parse(_lastCoverageMapJson);
|
|
56
|
+
_coverageDirty = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function ensureSourceMapParsed() {
|
|
61
|
+
if (_sourceMapDirty && _lastSourceMapJson !== null) {
|
|
62
|
+
_lastSourceMap = JSON.parse(_lastSourceMapJson);
|
|
63
|
+
_sourceMapDirty = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
45
66
|
|
|
46
67
|
return {
|
|
47
68
|
instrumentSync(code, filename, inputSourceMap) {
|
|
@@ -53,17 +74,30 @@ function createOxcInstrumenter(options) {
|
|
|
53
74
|
ignoreClassMethods,
|
|
54
75
|
});
|
|
55
76
|
|
|
56
|
-
|
|
57
|
-
|
|
77
|
+
// Store raw JSON — defer parsing until actually needed.
|
|
78
|
+
_lastCoverageMapJson = result.coverageMap;
|
|
79
|
+
_lastSourceMapJson = result.sourceMap || null;
|
|
80
|
+
_coverageDirty = true;
|
|
81
|
+
_sourceMapDirty = true;
|
|
58
82
|
|
|
59
|
-
|
|
83
|
+
// result.code is a Buffer (zero-copy from Rust); convert to string for
|
|
84
|
+
// istanbul-lib-instrument compatibility (instrumentSync must return string).
|
|
85
|
+
return result.code.toString();
|
|
60
86
|
},
|
|
61
87
|
|
|
62
88
|
lastSourceMap() {
|
|
89
|
+
ensureSourceMapParsed();
|
|
63
90
|
return _lastSourceMap;
|
|
64
91
|
},
|
|
65
92
|
|
|
66
93
|
lastFileCoverage() {
|
|
94
|
+
ensureCoverageParsed();
|
|
95
|
+
return _lastFileCoverage;
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// Property alias used by vite-plugin-istanbul (vs lastFileCoverage() method used by Vitest)
|
|
99
|
+
get fileCoverage() {
|
|
100
|
+
ensureCoverageParsed();
|
|
67
101
|
return _lastFileCoverage;
|
|
68
102
|
},
|
|
69
103
|
};
|