supercov 0.0.7 → 0.0.8
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/README.md +4 -0
- package/dist/agentJson.d.ts +1 -1
- package/dist/agentJson.d.ts.map +1 -1
- package/dist/agentJson.js.map +1 -1
- package/dist/cli.js +49 -9
- package/dist/cli.js.map +1 -1
- package/dist/directInstrumenter.d.ts +1 -1
- package/dist/directInstrumenter.d.ts.map +1 -1
- package/dist/directInstrumenter.js +30 -6
- package/dist/directInstrumenter.js.map +1 -1
- package/dist/nodeTest.d.ts.map +1 -1
- package/dist/nodeTest.js +5 -1
- package/dist/nodeTest.js.map +1 -1
- package/dist/playwright.d.ts.map +1 -1
- package/dist/playwright.js +8 -18
- package/dist/playwright.js.map +1 -1
- package/dist/project.d.ts +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +4 -0
- package/dist/project.js.map +1 -1
- package/dist/query.d.ts +3 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +74 -11
- package/dist/query.js.map +1 -1
- package/dist/resolve-loader.d.mts.map +1 -1
- package/dist/resolve-loader.mjs +12 -0
- package/dist/resolve-loader.mjs.map +1 -1
- package/dist/runAnalysis.d.ts.map +1 -1
- package/dist/runAnalysis.js +37 -18
- package/dist/runAnalysis.js.map +1 -1
- package/dist/runnerEvidence.d.ts +1 -1
- package/dist/runnerEvidence.d.ts.map +1 -1
- package/dist/runnerEvidence.js +2 -2
- package/dist/runnerEvidence.js.map +1 -1
- package/dist/runtime.d.ts +15 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +633 -534
- package/dist/runtime.js.map +1 -1
- package/dist/sourceDiscovery.d.ts.map +1 -1
- package/dist/sourceDiscovery.js +10 -0
- package/dist/sourceDiscovery.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/runtime.js
CHANGED
|
@@ -1,591 +1,690 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// dist/transport.js
|
|
22
|
+
var COVERAGE_SCOPE_HEADER = "x-supercov-scope";
|
|
23
|
+
var COVERAGE_PHASE_HEADER = "x-supercov-phase";
|
|
24
|
+
var COVERAGE_SCOPE_COOKIE = "__supercov_scope";
|
|
25
|
+
var COVERAGE_PHASE_COOKIE = "__supercov_phase";
|
|
26
|
+
var COVERAGE_CARRIER_ENV = "SUPERCOV_CONTEXT";
|
|
27
|
+
var DEFAULT_SERVER_EVIDENCE_ROOT = "/tmp/supercov-server-evidence";
|
|
28
|
+
function configuredServerEvidenceRoot() {
|
|
29
|
+
var _a8;
|
|
30
|
+
return typeof process !== "undefined" && ((_a8 = process.env) == null ? void 0 : _a8["SUPERCOV_SERVER_EVIDENCE_ROOT"]) ? process.env["SUPERCOV_SERVER_EVIDENCE_ROOT"] : DEFAULT_SERVER_EVIDENCE_ROOT;
|
|
31
|
+
}
|
|
32
|
+
function nonEmpty(value) {
|
|
33
|
+
return typeof value === "string" && value.length > 0;
|
|
34
|
+
}
|
|
35
|
+
function safeKey(value) {
|
|
36
|
+
return /^[a-zA-Z0-9_-]+$/.test(value);
|
|
37
|
+
}
|
|
38
|
+
function pathComponent(value) {
|
|
39
|
+
const safe = value.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
40
|
+
return safe || "unscoped";
|
|
41
|
+
}
|
|
42
|
+
function encodeCoverageScope(scope) {
|
|
43
|
+
return new URLSearchParams({
|
|
44
|
+
v: String(scope.version),
|
|
45
|
+
r: scope.runId,
|
|
46
|
+
w: scope.workerId,
|
|
47
|
+
t: scope.testId,
|
|
48
|
+
k: scope.testKey,
|
|
49
|
+
a: String(scope.retry),
|
|
50
|
+
i: scope.attemptId
|
|
51
|
+
}).toString();
|
|
52
|
+
}
|
|
53
|
+
function decodeCoverageScope(encoded) {
|
|
54
|
+
if (!encoded)
|
|
55
|
+
return void 0;
|
|
56
|
+
try {
|
|
57
|
+
const values = new URLSearchParams(encoded);
|
|
58
|
+
const runId = values.get("r");
|
|
59
|
+
const workerId = values.get("w");
|
|
60
|
+
const testId2 = values.get("t");
|
|
61
|
+
const testKey = values.get("k");
|
|
62
|
+
const attemptId = values.get("i");
|
|
63
|
+
const retry = Number(values.get("a"));
|
|
64
|
+
if (values.get("v") !== "1" || !nonEmpty(runId) || !nonEmpty(workerId) || !nonEmpty(testId2) || !nonEmpty(testKey) || !safeKey(testKey) || !nonEmpty(attemptId) || !safeKey(attemptId) || !Number.isSafeInteger(retry) || retry < 0)
|
|
65
|
+
return void 0;
|
|
66
|
+
return {
|
|
67
|
+
version: 1,
|
|
68
|
+
runId,
|
|
69
|
+
workerId,
|
|
70
|
+
testId: testId2,
|
|
71
|
+
testKey,
|
|
72
|
+
retry,
|
|
73
|
+
attemptId
|
|
74
|
+
};
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function encodeCoverageCarrier(carrier) {
|
|
80
|
+
return Buffer.from(JSON.stringify(carrier), "utf8").toString("base64url");
|
|
81
|
+
}
|
|
82
|
+
function decodeCoverageCarrier(encoded) {
|
|
83
|
+
if (!encoded)
|
|
84
|
+
return void 0;
|
|
85
|
+
try {
|
|
86
|
+
const value = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
|
|
87
|
+
if (value.version !== 1)
|
|
88
|
+
return void 0;
|
|
89
|
+
if (value.scope) {
|
|
90
|
+
const roundTrip = decodeCoverageScope(encodeCoverageScope(value.scope));
|
|
91
|
+
if (!roundTrip)
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
if (value.phaseId !== void 0 && value.phaseId.length === 0)
|
|
95
|
+
return void 0;
|
|
96
|
+
return value;
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function serverRunEvidenceDirectory(runId, root = configuredServerEvidenceRoot()) {
|
|
102
|
+
return `${root.replace(/\/+$/, "")}/${pathComponent(runId)}`;
|
|
103
|
+
}
|
|
104
|
+
function serverEvidenceDirectory(scope, root = configuredServerEvidenceRoot()) {
|
|
105
|
+
return `${serverRunEvidenceDirectory(scope.runId, root)}/${pathComponent(scope.workerId)}/${scope.testKey}/${scope.retry}`;
|
|
106
|
+
}
|
|
107
|
+
function serverEvidencePath(scope, root = configuredServerEvidenceRoot()) {
|
|
108
|
+
return `${serverEvidenceDirectory(scope, root)}/server.jsonl`;
|
|
109
|
+
}
|
|
110
|
+
function backgroundEvidenceDirectory(runId, root = configuredServerEvidenceRoot()) {
|
|
111
|
+
return `${serverRunEvidenceDirectory(runId, root)}/background`;
|
|
112
|
+
}
|
|
113
|
+
function backgroundEvidencePath(runId, processId = typeof process === "undefined" ? "unknown" : String(process.pid), root = configuredServerEvidenceRoot()) {
|
|
114
|
+
return `${backgroundEvidenceDirectory(runId, root)}/${pathComponent(processId)}.jsonl`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// dist/runtime.js
|
|
118
|
+
var runtimeGlobal = globalThis;
|
|
119
|
+
var runtimeInstanceToken = "__SUPERCOV_RUNTIME_INSTANCE__";
|
|
120
|
+
var runtimeInstance = runtimeInstanceToken === "__SUPERCOV_RUNTIME_INSTANCE__" ? "application" : runtimeInstanceToken;
|
|
121
|
+
var _a;
|
|
122
|
+
var isBrowser = !(typeof process !== "undefined" && typeof ((_a = process.versions) == null ? void 0 : _a.node) === "string");
|
|
123
|
+
var _a2;
|
|
124
|
+
var testId = (_a2 = runtimeGlobal.__SUPERCOV_MCDC_TEST_ID__) != null ? _a2 : "unscoped";
|
|
125
|
+
var storageKey = "__supercov_coverage_" + testId;
|
|
126
|
+
var phaseStorageKey = "__supercov_phase";
|
|
127
|
+
var pendingDefaults = /* @__PURE__ */ new Map();
|
|
13
128
|
function vectorKey(vector) {
|
|
14
|
-
|
|
15
|
-
.map((value) => (value === null ? "-" : value ? "T" : "F"))
|
|
16
|
-
.join("") +
|
|
17
|
-
":" +
|
|
18
|
-
(vector.outcome ? "T" : "F"));
|
|
129
|
+
return vector.values.map((value) => value === null ? "-" : value ? "T" : "F").join("") + ":" + (vector.outcome ? "T" : "F");
|
|
19
130
|
}
|
|
20
131
|
function getFs() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
132
|
+
if (isBrowser || typeof process === "undefined")
|
|
133
|
+
return void 0;
|
|
134
|
+
try {
|
|
135
|
+
const getBuiltinModule = process.getBuiltinModule;
|
|
136
|
+
return getBuiltinModule == null ? void 0 : getBuiltinModule("node:fs");
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
30
140
|
}
|
|
31
141
|
function createState() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (const event of stored.events ?? []) {
|
|
54
|
-
state.events.push(event);
|
|
55
|
-
state.eventKeys.add(eventKey(event));
|
|
56
|
-
}
|
|
142
|
+
var _a8, _b, _c, _d;
|
|
143
|
+
const state2 = {
|
|
144
|
+
decisions: /* @__PURE__ */ new Map(),
|
|
145
|
+
hits: /* @__PURE__ */ new Set(),
|
|
146
|
+
events: [],
|
|
147
|
+
eventKeys: /* @__PURE__ */ new Set(),
|
|
148
|
+
bufferedAttempts: /* @__PURE__ */ new Set(),
|
|
149
|
+
serverBuffers: /* @__PURE__ */ new Map(),
|
|
150
|
+
persistedServerRecords: /* @__PURE__ */ new Set(),
|
|
151
|
+
backgroundSequence: 0,
|
|
152
|
+
runtimeSnapshots: false
|
|
153
|
+
};
|
|
154
|
+
if (!isBrowser)
|
|
155
|
+
return state2;
|
|
156
|
+
try {
|
|
157
|
+
const stored = JSON.parse((_a8 = localStorage.getItem(storageKey)) != null ? _a8 : "{}");
|
|
158
|
+
for (const snapshot of (_b = stored.decisions) != null ? _b : []) {
|
|
159
|
+
state2.decisions.set(snapshot.meta.id, {
|
|
160
|
+
meta: snapshot.meta,
|
|
161
|
+
vectors: new Map(snapshot.vectors.map((vector) => [vectorKey(vector), vector]))
|
|
162
|
+
});
|
|
57
163
|
}
|
|
58
|
-
|
|
59
|
-
|
|
164
|
+
for (const id of (_c = stored.hits) != null ? _c : [])
|
|
165
|
+
state2.hits.add(id);
|
|
166
|
+
for (const event of (_d = stored.events) != null ? _d : []) {
|
|
167
|
+
state2.events.push(event);
|
|
168
|
+
state2.eventKeys.add(eventKey(event));
|
|
60
169
|
}
|
|
61
|
-
|
|
170
|
+
} catch (e) {
|
|
171
|
+
}
|
|
172
|
+
return state2;
|
|
62
173
|
}
|
|
63
|
-
|
|
174
|
+
var _a3;
|
|
175
|
+
var runtimeStates = (_a3 = runtimeGlobal.__SUPERCOV_MCDC_STATES__) != null ? _a3 : /* @__PURE__ */ new Map();
|
|
64
176
|
runtimeGlobal.__SUPERCOV_MCDC_STATES__ = runtimeStates;
|
|
65
|
-
|
|
177
|
+
var _a4;
|
|
178
|
+
var state = (_a4 = runtimeStates.get(runtimeInstance)) != null ? _a4 : createState();
|
|
66
179
|
runtimeStates.set(runtimeInstance, state);
|
|
67
180
|
function createServerPhaseStorage() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
181
|
+
var _a8;
|
|
182
|
+
if (isBrowser || typeof process === "undefined")
|
|
183
|
+
return void 0;
|
|
184
|
+
try {
|
|
185
|
+
const getBuiltinModule = process.getBuiltinModule;
|
|
186
|
+
const AsyncLocalStorage = (_a8 = getBuiltinModule == null ? void 0 : getBuiltinModule("node:async_hooks")) == null ? void 0 : _a8.AsyncLocalStorage;
|
|
187
|
+
return AsyncLocalStorage ? new AsyncLocalStorage() : void 0;
|
|
188
|
+
} catch (e) {
|
|
189
|
+
return void 0;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
var _a5;
|
|
193
|
+
var serverPhaseStorages = (_a5 = runtimeGlobal.__SUPERCOV_SERVER_PHASE_STORAGES__) != null ? _a5 : /* @__PURE__ */ new Map();
|
|
80
194
|
runtimeGlobal.__SUPERCOV_SERVER_PHASE_STORAGES__ = serverPhaseStorages;
|
|
81
|
-
|
|
195
|
+
var _a6;
|
|
196
|
+
var serverPhaseStorage = (_a6 = serverPhaseStorages.get(runtimeInstance)) != null ? _a6 : createServerPhaseStorage();
|
|
82
197
|
if (serverPhaseStorage)
|
|
83
|
-
|
|
198
|
+
serverPhaseStorages.set(runtimeInstance, serverPhaseStorage);
|
|
84
199
|
function decisionSnapshot() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
catch {
|
|
109
|
-
// Storage is optional in test environments.
|
|
110
|
-
}
|
|
200
|
+
return [...state.decisions.values()].map((decision) => ({
|
|
201
|
+
meta: decision.meta,
|
|
202
|
+
vectors: [...decision.vectors.values()]
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
function coverageSnapshot() {
|
|
206
|
+
return {
|
|
207
|
+
decisions: decisionSnapshot(),
|
|
208
|
+
hits: [...state.hits],
|
|
209
|
+
events: state.events
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function resetCoverage(testId2) {
|
|
213
|
+
state.decisions.clear();
|
|
214
|
+
state.hits.clear();
|
|
215
|
+
state.events.length = 0;
|
|
216
|
+
state.eventKeys.clear();
|
|
217
|
+
if (testId2)
|
|
218
|
+
runtimeGlobal.__SUPERCOV_MCDC_TEST_ID__ = testId2;
|
|
219
|
+
if (isBrowser) {
|
|
220
|
+
try {
|
|
221
|
+
localStorage.removeItem(storageKey);
|
|
222
|
+
} catch (e) {
|
|
111
223
|
}
|
|
224
|
+
}
|
|
112
225
|
}
|
|
113
226
|
runtimeGlobal.__SUPERCOV_MCDC_SNAPSHOT__ = decisionSnapshot;
|
|
114
227
|
runtimeGlobal.__SUPERCOV_COVERAGE_SNAPSHOT__ = coverageSnapshot;
|
|
115
228
|
runtimeGlobal.__SUPERCOV_RESET__ = resetCoverage;
|
|
116
229
|
function persistBrowser() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// Coverage persistence is best-effort and must never change app behavior.
|
|
124
|
-
}
|
|
230
|
+
if (!isBrowser)
|
|
231
|
+
return;
|
|
232
|
+
try {
|
|
233
|
+
localStorage.setItem(storageKey, JSON.stringify(coverageSnapshot()));
|
|
234
|
+
} catch (e) {
|
|
235
|
+
}
|
|
125
236
|
}
|
|
126
237
|
function attemptKey(scope) {
|
|
127
|
-
|
|
238
|
+
return `${scope.runId}\0${scope.workerId}\0${scope.attemptId}`;
|
|
128
239
|
}
|
|
129
240
|
function serverRecordKey(record) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
// Collection is best-effort and must never change test behavior.
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/** A local runner will persist coverageSnapshot(), so avoid duplicate files. */
|
|
165
|
-
export function enableRuntimeSnapshotEvidence() {
|
|
166
|
-
state.runtimeSnapshots = true;
|
|
241
|
+
var _a8;
|
|
242
|
+
const suffix = record.type === "decision" ? `${record.meta.id}:${vectorKey(record.vector)}` : record.id;
|
|
243
|
+
return `${(_a8 = record.phaseId) != null ? _a8 : "unscoped"}:${record.type}:${suffix}`;
|
|
244
|
+
}
|
|
245
|
+
function beginBufferedServerEvidence(scope) {
|
|
246
|
+
if (isBrowser)
|
|
247
|
+
return;
|
|
248
|
+
state.bufferedAttempts.add(attemptKey(scope));
|
|
249
|
+
}
|
|
250
|
+
function flushBufferedServerEvidence(scope) {
|
|
251
|
+
if (isBrowser)
|
|
252
|
+
return;
|
|
253
|
+
const key = attemptKey(scope);
|
|
254
|
+
state.bufferedAttempts.delete(key);
|
|
255
|
+
const buffered = state.serverBuffers.get(key);
|
|
256
|
+
if (!buffered)
|
|
257
|
+
return;
|
|
258
|
+
state.serverBuffers.delete(key);
|
|
259
|
+
const fs = getFs();
|
|
260
|
+
if (!fs || buffered.records.size === 0)
|
|
261
|
+
return;
|
|
262
|
+
try {
|
|
263
|
+
fs.mkdirSync(buffered.directory, { recursive: true });
|
|
264
|
+
fs.appendFileSync(buffered.path, [...buffered.records.values()].map((record) => JSON.stringify(record)).join("\n") + "\n");
|
|
265
|
+
} catch (e) {
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function enableRuntimeSnapshotEvidence() {
|
|
269
|
+
state.runtimeSnapshots = true;
|
|
167
270
|
}
|
|
168
271
|
function flushAllBufferedServerEvidence() {
|
|
169
|
-
|
|
170
|
-
|
|
272
|
+
for (const buffered of [...state.serverBuffers.values()])
|
|
273
|
+
flushBufferedServerEvidence(buffered.scope);
|
|
171
274
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
275
|
+
function writeExclusiveBackgroundRecord(fs, runId, writer, initialSequence, payload) {
|
|
276
|
+
let sequence = initialSequence;
|
|
277
|
+
for (let attempt = 0; attempt < 1e4; attempt += 1) {
|
|
278
|
+
const candidate = backgroundEvidencePath(runId, `${writer}-${sequence++}`);
|
|
279
|
+
try {
|
|
280
|
+
fs.writeFileSync(candidate, payload, { flag: "wx" });
|
|
281
|
+
return sequence;
|
|
282
|
+
} catch (error) {
|
|
283
|
+
if (error.code === "EEXIST")
|
|
284
|
+
continue;
|
|
285
|
+
throw error;
|
|
182
286
|
}
|
|
287
|
+
}
|
|
288
|
+
throw Object.assign(new Error("Could not allocate a collision-free Supercov background evidence record"), { code: "SUPERCOV_BACKGROUND_COLLISION_LIMIT" });
|
|
289
|
+
}
|
|
290
|
+
var _a7;
|
|
291
|
+
if (!isBrowser) {
|
|
292
|
+
const flushers = (_a7 = runtimeGlobal.__SUPERCOV_BUFFER_FLUSHERS__) != null ? _a7 : /* @__PURE__ */ new Set();
|
|
293
|
+
runtimeGlobal.__SUPERCOV_BUFFER_FLUSHERS__ = flushers;
|
|
294
|
+
flushers.add(flushAllBufferedServerEvidence);
|
|
295
|
+
if (!runtimeGlobal.__SUPERCOV_BUFFER_EXIT_INSTALLED__) {
|
|
296
|
+
process.once("exit", () => {
|
|
297
|
+
var _a8;
|
|
298
|
+
for (const flush of (_a8 = runtimeGlobal.__SUPERCOV_BUFFER_FLUSHERS__) != null ? _a8 : [])
|
|
299
|
+
flush();
|
|
300
|
+
});
|
|
301
|
+
runtimeGlobal.__SUPERCOV_BUFFER_EXIT_INSTALLED__ = true;
|
|
302
|
+
}
|
|
183
303
|
}
|
|
184
304
|
function appendServer(record) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
path,
|
|
212
|
-
records: new Map(),
|
|
213
|
-
};
|
|
214
|
-
buffered.records.set(serverRecordKey(serialized), serialized);
|
|
215
|
-
state.serverBuffers.set(key, buffered);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
fs.mkdirSync(directory, { recursive: true });
|
|
219
|
-
fs.appendFileSync(path, JSON.stringify(serialized) + "\n");
|
|
305
|
+
var _a8, _b, _c;
|
|
306
|
+
if (state.runtimeSnapshots)
|
|
307
|
+
return;
|
|
308
|
+
const fs = getFs();
|
|
309
|
+
if (!fs)
|
|
310
|
+
return;
|
|
311
|
+
const context = currentRequestContext();
|
|
312
|
+
const scope = context.scope;
|
|
313
|
+
const runId = (_a8 = scope == null ? void 0 : scope.runId) != null ? _a8 : typeof process !== "undefined" ? process.env["SUPERCOV_RUN_ID"] : void 0;
|
|
314
|
+
if (!runId)
|
|
315
|
+
return;
|
|
316
|
+
try {
|
|
317
|
+
const directory = scope ? serverEvidenceDirectory(scope) : backgroundEvidenceDirectory(runId);
|
|
318
|
+
const path = scope ? serverEvidencePath(scope) : void 0;
|
|
319
|
+
const serialized = __spreadValues(__spreadValues({}, record), scope ? { scope } : {});
|
|
320
|
+
if (scope && state.bufferedAttempts.has(attemptKey(scope))) {
|
|
321
|
+
const key = attemptKey(scope);
|
|
322
|
+
const buffered = (_b = state.serverBuffers.get(key)) != null ? _b : {
|
|
323
|
+
scope,
|
|
324
|
+
directory,
|
|
325
|
+
path,
|
|
326
|
+
records: /* @__PURE__ */ new Map()
|
|
327
|
+
};
|
|
328
|
+
buffered.records.set(serverRecordKey(serialized), serialized);
|
|
329
|
+
state.serverBuffers.set(key, buffered);
|
|
330
|
+
return;
|
|
220
331
|
}
|
|
221
|
-
|
|
222
|
-
|
|
332
|
+
const deduplicationKey = scope && serialized.phaseId ? `${attemptKey(scope)}:${serverRecordKey(serialized)}` : void 0;
|
|
333
|
+
if (deduplicationKey && state.persistedServerRecords.has(deduplicationKey))
|
|
334
|
+
return;
|
|
335
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
336
|
+
if (!path) {
|
|
337
|
+
const shard = (_c = process.env["SUPERCOV_EXECUTION_LOG_SHARD"]) != null ? _c : "process";
|
|
338
|
+
const writer = `${shard}-${process.pid}`;
|
|
339
|
+
const payload = JSON.stringify(serialized) + "\n";
|
|
340
|
+
state.backgroundSequence = writeExclusiveBackgroundRecord(fs, runId, writer, state.backgroundSequence, payload);
|
|
341
|
+
return;
|
|
223
342
|
}
|
|
343
|
+
fs.appendFileSync(path, JSON.stringify(serialized) + "\n");
|
|
344
|
+
if (deduplicationKey)
|
|
345
|
+
state.persistedServerRecords.add(deduplicationKey);
|
|
346
|
+
} catch (e) {
|
|
347
|
+
}
|
|
224
348
|
}
|
|
225
349
|
function environmentRequestContext() {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
? {
|
|
231
|
-
...(carrier.scope ? { scope: carrier.scope } : {}),
|
|
232
|
-
...(carrier.phaseId ? { phaseId: carrier.phaseId } : {}),
|
|
233
|
-
}
|
|
234
|
-
: undefined;
|
|
350
|
+
if (isBrowser || typeof process === "undefined")
|
|
351
|
+
return void 0;
|
|
352
|
+
const carrier = decodeCoverageCarrier(process.env[COVERAGE_CARRIER_ENV]);
|
|
353
|
+
return carrier ? __spreadValues(__spreadValues({}, carrier.scope ? { scope: carrier.scope } : {}), carrier.phaseId ? { phaseId: carrier.phaseId } : {}) : void 0;
|
|
235
354
|
}
|
|
236
355
|
function currentRequestContext() {
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
...(context.phaseId
|
|
268
|
-
? { [COVERAGE_PHASE_HEADER]: context.phaseId }
|
|
269
|
-
: {}),
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
export function coverageContextEnvironment() {
|
|
273
|
-
return { [COVERAGE_CARRIER_ENV]: encodeCoverageCarrier(coverageCarrier()) };
|
|
356
|
+
var _a8, _b;
|
|
357
|
+
return (_b = (_a8 = serverPhaseStorage == null ? void 0 : serverPhaseStorage.getStore()) != null ? _a8 : environmentRequestContext()) != null ? _b : {};
|
|
358
|
+
}
|
|
359
|
+
function coverageCarrier() {
|
|
360
|
+
const context = currentRequestContext();
|
|
361
|
+
return __spreadValues(__spreadValues({
|
|
362
|
+
version: 1
|
|
363
|
+
}, context.scope ? { scope: context.scope } : {}), context.phaseId ? { phaseId: context.phaseId } : {});
|
|
364
|
+
}
|
|
365
|
+
function withCoverageCarrier(carrier, callback) {
|
|
366
|
+
const decoded = typeof carrier === "string" ? decodeCoverageCarrier(carrier) : carrier;
|
|
367
|
+
if (!serverPhaseStorage || !decoded)
|
|
368
|
+
return callback();
|
|
369
|
+
return serverPhaseStorage.run(__spreadValues(__spreadValues({}, decoded.scope ? { scope: decoded.scope } : {}), decoded.phaseId ? { phaseId: decoded.phaseId } : {}), callback);
|
|
370
|
+
}
|
|
371
|
+
function bindCoverageContext(callback, carrier = coverageCarrier()) {
|
|
372
|
+
return function boundCoverageContext(...args) {
|
|
373
|
+
return withCoverageCarrier(carrier, () => Reflect.apply(callback, this, args));
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function coverageContextHeaders() {
|
|
377
|
+
const context = currentRequestContext();
|
|
378
|
+
if (!context.scope)
|
|
379
|
+
return {};
|
|
380
|
+
return __spreadValues({
|
|
381
|
+
[COVERAGE_SCOPE_HEADER]: encodeCoverageScope(context.scope)
|
|
382
|
+
}, context.phaseId ? { [COVERAGE_PHASE_HEADER]: context.phaseId } : {});
|
|
383
|
+
}
|
|
384
|
+
function coverageContextEnvironment() {
|
|
385
|
+
return { [COVERAGE_CARRIER_ENV]: encodeCoverageCarrier(coverageCarrier()) };
|
|
274
386
|
}
|
|
275
387
|
function installServerFetchPropagation() {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
runtimeGlobal.__SUPERCOV_FETCH_PATCHED__ = true;
|
|
388
|
+
if (isBrowser || runtimeGlobal.__SUPERCOV_FETCH_PATCHED__ || typeof globalThis.fetch !== "function")
|
|
389
|
+
return;
|
|
390
|
+
const originalFetch = globalThis.fetch.bind(globalThis);
|
|
391
|
+
globalThis.fetch = ((input, init) => {
|
|
392
|
+
var _a8;
|
|
393
|
+
const coverage = coverageContextHeaders();
|
|
394
|
+
if (Object.keys(coverage).length === 0)
|
|
395
|
+
return originalFetch(input, init);
|
|
396
|
+
const headers = new Headers((_a8 = init == null ? void 0 : init.headers) != null ? _a8 : input instanceof Request ? input.headers : void 0);
|
|
397
|
+
for (const [name, value] of Object.entries(coverage))
|
|
398
|
+
headers.set(name, value);
|
|
399
|
+
return originalFetch(input, __spreadProps(__spreadValues({}, init), { headers }));
|
|
400
|
+
});
|
|
401
|
+
runtimeGlobal.__SUPERCOV_FETCH_PATCHED__ = true;
|
|
291
402
|
}
|
|
292
403
|
installServerFetchPropagation();
|
|
293
404
|
function installServerChildPropagation() {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
405
|
+
var _a8;
|
|
406
|
+
if (isBrowser || runtimeGlobal.__SUPERCOV_CHILD_PATCHED__ || typeof process === "undefined")
|
|
407
|
+
return;
|
|
408
|
+
const getBuiltinModule = process.getBuiltinModule;
|
|
409
|
+
const child = getBuiltinModule == null ? void 0 : getBuiltinModule("node:child_process");
|
|
410
|
+
if (!child)
|
|
411
|
+
return;
|
|
412
|
+
const mutableChild = child;
|
|
413
|
+
const optionIndex = (method, args) => {
|
|
414
|
+
if (method === "spawn" || method === "spawnSync" || method === "fork" || method === "execFile" || method === "execFileSync")
|
|
415
|
+
return Array.isArray(args[1]) || args.length > 2 && args[2] !== void 0 ? 2 : 1;
|
|
416
|
+
return 1;
|
|
417
|
+
};
|
|
418
|
+
for (const method of [
|
|
419
|
+
"exec",
|
|
420
|
+
"execFile",
|
|
421
|
+
"execFileSync",
|
|
422
|
+
"execSync",
|
|
423
|
+
"fork",
|
|
424
|
+
"spawn",
|
|
425
|
+
"spawnSync"
|
|
426
|
+
]) {
|
|
427
|
+
const original = mutableChild[method];
|
|
428
|
+
if (typeof original !== "function")
|
|
429
|
+
continue;
|
|
430
|
+
mutableChild[method] = function(...args) {
|
|
431
|
+
var _a9;
|
|
432
|
+
const index = optionIndex(method, args);
|
|
433
|
+
const existing = args[index] && typeof args[index] === "object" ? args[index] : {};
|
|
434
|
+
const options = __spreadProps(__spreadValues({}, existing), {
|
|
435
|
+
env: __spreadValues(__spreadValues(__spreadValues({}, process.env), (_a9 = existing.env) != null ? _a9 : {}), coverageContextEnvironment())
|
|
436
|
+
});
|
|
437
|
+
const scoped = [...args];
|
|
438
|
+
if (typeof scoped[index] === "function")
|
|
439
|
+
scoped.splice(index, 0, options);
|
|
440
|
+
else
|
|
441
|
+
scoped[index] = options;
|
|
442
|
+
return Reflect.apply(original, child, scoped);
|
|
313
443
|
};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
"execSync",
|
|
319
|
-
"fork",
|
|
320
|
-
"spawn",
|
|
321
|
-
"spawnSync",
|
|
322
|
-
]) {
|
|
323
|
-
const original = mutableChild[method];
|
|
324
|
-
if (typeof original !== "function")
|
|
325
|
-
continue;
|
|
326
|
-
mutableChild[method] = function (...args) {
|
|
327
|
-
const index = optionIndex(method, args);
|
|
328
|
-
const existing = args[index] && typeof args[index] === "object"
|
|
329
|
-
? args[index]
|
|
330
|
-
: {};
|
|
331
|
-
const options = {
|
|
332
|
-
...existing,
|
|
333
|
-
env: {
|
|
334
|
-
...process.env,
|
|
335
|
-
...(existing.env ?? {}),
|
|
336
|
-
...coverageContextEnvironment(),
|
|
337
|
-
},
|
|
338
|
-
};
|
|
339
|
-
const scoped = [...args];
|
|
340
|
-
if (typeof scoped[index] === "function")
|
|
341
|
-
scoped.splice(index, 0, options);
|
|
342
|
-
else
|
|
343
|
-
scoped[index] = options;
|
|
344
|
-
return Reflect.apply(original, child, scoped);
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
const moduleBuiltin = getBuiltinModule?.("node:module");
|
|
348
|
-
moduleBuiltin?.syncBuiltinESMExports?.();
|
|
349
|
-
runtimeGlobal.__SUPERCOV_CHILD_PATCHED__ = true;
|
|
444
|
+
}
|
|
445
|
+
const moduleBuiltin = getBuiltinModule == null ? void 0 : getBuiltinModule("node:module");
|
|
446
|
+
(_a8 = moduleBuiltin == null ? void 0 : moduleBuiltin.syncBuiltinESMExports) == null ? void 0 : _a8.call(moduleBuiltin);
|
|
447
|
+
runtimeGlobal.__SUPERCOV_CHILD_PATCHED__ = true;
|
|
350
448
|
}
|
|
351
449
|
installServerChildPropagation();
|
|
352
450
|
function currentPhaseId() {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
451
|
+
if (runtimeGlobal.__SUPERCOV_PHASE_ID__)
|
|
452
|
+
return runtimeGlobal.__SUPERCOV_PHASE_ID__;
|
|
453
|
+
if (!isBrowser)
|
|
454
|
+
return currentRequestContext().phaseId;
|
|
455
|
+
try {
|
|
456
|
+
const local = localStorage.getItem(phaseStorageKey);
|
|
457
|
+
if (local)
|
|
458
|
+
return local;
|
|
459
|
+
return void 0;
|
|
460
|
+
} catch (e) {
|
|
461
|
+
return void 0;
|
|
462
|
+
}
|
|
366
463
|
}
|
|
367
464
|
function requestHeaders(value) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const get = headers.get;
|
|
380
|
-
if (typeof get === "function")
|
|
381
|
-
return {
|
|
382
|
-
get(name) {
|
|
383
|
-
return Reflect.apply(get, headers, [name]);
|
|
384
|
-
},
|
|
385
|
-
};
|
|
386
|
-
const values = headers;
|
|
387
|
-
return Object.keys(values).length > 0
|
|
388
|
-
? {
|
|
389
|
-
get(name) {
|
|
390
|
-
return values[name] ?? values[name.toLowerCase()];
|
|
391
|
-
},
|
|
392
|
-
}
|
|
393
|
-
: undefined;
|
|
394
|
-
}
|
|
395
|
-
function requestCoverageContext(value) {
|
|
396
|
-
const headers = requestHeaders(value);
|
|
397
|
-
if (!headers)
|
|
398
|
-
return {};
|
|
399
|
-
const rawCookie = headers.get("cookie");
|
|
400
|
-
const cookies = new Map();
|
|
401
|
-
if (typeof rawCookie === "string") {
|
|
402
|
-
for (const part of rawCookie.split(";")) {
|
|
403
|
-
const separator = part.indexOf("=");
|
|
404
|
-
if (separator < 0)
|
|
405
|
-
continue;
|
|
406
|
-
const name = part.slice(0, separator).trim();
|
|
407
|
-
const encoded = part.slice(separator + 1).trim();
|
|
408
|
-
try {
|
|
409
|
-
cookies.set(name, decodeURIComponent(encoded));
|
|
410
|
-
}
|
|
411
|
-
catch {
|
|
412
|
-
// Ignore a malformed unrelated cookie.
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
const encodedScope = headers.get(COVERAGE_SCOPE_HEADER) ?? cookies.get(COVERAGE_SCOPE_COOKIE);
|
|
417
|
-
const rawPhaseId = headers.get(COVERAGE_PHASE_HEADER) ?? cookies.get(COVERAGE_PHASE_COOKIE);
|
|
418
|
-
const scope = decodeCoverageScope(typeof encodedScope === "string" ? encodedScope : undefined);
|
|
419
|
-
const phaseId = typeof rawPhaseId === "string" && rawPhaseId.length > 0
|
|
420
|
-
? rawPhaseId
|
|
421
|
-
: undefined;
|
|
465
|
+
if (!value || typeof value !== "object")
|
|
466
|
+
return void 0;
|
|
467
|
+
const directHeaders = value.headers;
|
|
468
|
+
const request = directHeaders && typeof directHeaders === "object" ? value : value.request;
|
|
469
|
+
if (!request || typeof request !== "object")
|
|
470
|
+
return void 0;
|
|
471
|
+
const headers = request.headers;
|
|
472
|
+
if (!headers || typeof headers !== "object")
|
|
473
|
+
return void 0;
|
|
474
|
+
const get = headers.get;
|
|
475
|
+
if (typeof get === "function")
|
|
422
476
|
return {
|
|
423
|
-
|
|
424
|
-
|
|
477
|
+
get(name) {
|
|
478
|
+
return Reflect.apply(get, headers, [name]);
|
|
479
|
+
}
|
|
425
480
|
};
|
|
481
|
+
const values = headers;
|
|
482
|
+
return Object.keys(values).length > 0 ? {
|
|
483
|
+
get(name) {
|
|
484
|
+
var _a8;
|
|
485
|
+
return (_a8 = values[name]) != null ? _a8 : values[name.toLowerCase()];
|
|
486
|
+
}
|
|
487
|
+
} : void 0;
|
|
426
488
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
489
|
+
function requestCoverageContext(value) {
|
|
490
|
+
var _a8, _b;
|
|
491
|
+
const headers = requestHeaders(value);
|
|
492
|
+
if (!headers)
|
|
493
|
+
return {};
|
|
494
|
+
const rawCookie = headers.get("cookie");
|
|
495
|
+
const cookies = /* @__PURE__ */ new Map();
|
|
496
|
+
if (typeof rawCookie === "string") {
|
|
497
|
+
for (const part of rawCookie.split(";")) {
|
|
498
|
+
const separator = part.indexOf("=");
|
|
499
|
+
if (separator < 0)
|
|
500
|
+
continue;
|
|
501
|
+
const name = part.slice(0, separator).trim();
|
|
502
|
+
const encoded = part.slice(separator + 1).trim();
|
|
503
|
+
try {
|
|
504
|
+
cookies.set(name, decodeURIComponent(encoded));
|
|
505
|
+
} catch (e) {
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const encodedScope = (_a8 = headers.get(COVERAGE_SCOPE_HEADER)) != null ? _a8 : cookies.get(COVERAGE_SCOPE_COOKIE);
|
|
510
|
+
const rawPhaseId = (_b = headers.get(COVERAGE_PHASE_HEADER)) != null ? _b : cookies.get(COVERAGE_PHASE_COOKIE);
|
|
511
|
+
const scope = decodeCoverageScope(typeof encodedScope === "string" ? encodedScope : void 0);
|
|
512
|
+
const phaseId = typeof rawPhaseId === "string" && rawPhaseId.length > 0 ? rawPhaseId : void 0;
|
|
513
|
+
return __spreadValues(__spreadValues({}, scope ? { scope } : {}), phaseId ? { phaseId } : {});
|
|
514
|
+
}
|
|
515
|
+
function withRequestPhase(handler) {
|
|
516
|
+
if (!serverPhaseStorage)
|
|
517
|
+
return handler;
|
|
518
|
+
return function coverageRequestPhase(...args) {
|
|
519
|
+
var _a8, _b, _c, _d, _e;
|
|
520
|
+
const requestContext = (_a8 = args.map((argument) => requestCoverageContext(argument)).find((context2) => context2.scope || context2.phaseId)) != null ? _a8 : {};
|
|
521
|
+
const inheritedContext = currentRequestContext();
|
|
522
|
+
const context = __spreadValues(__spreadValues({}, ((_b = requestContext.scope) != null ? _b : inheritedContext.scope) ? { scope: (_c = requestContext.scope) != null ? _c : inheritedContext.scope } : {}), ((_d = requestContext.phaseId) != null ? _d : inheritedContext.phaseId) ? { phaseId: (_e = requestContext.phaseId) != null ? _e : inheritedContext.phaseId } : {});
|
|
523
|
+
const invoke = () => Reflect.apply(handler, this, args);
|
|
524
|
+
return context.scope || context.phaseId ? serverPhaseStorage.run(context, invoke) : invoke();
|
|
525
|
+
};
|
|
448
526
|
}
|
|
449
527
|
function eventKey(event) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
return `${event.phaseId ?? "unscoped"}:${event.type}:${suffix}`;
|
|
528
|
+
var _a8;
|
|
529
|
+
const suffix = event.type === "decision" ? `${event.id}:${vectorKey(event.vector)}` : event.id;
|
|
530
|
+
return `${(_a8 = event.phaseId) != null ? _a8 : "unscoped"}:${event.type}:${suffix}`;
|
|
454
531
|
}
|
|
455
532
|
function recordBrowserEvent(event) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
export function selectionBegin(shortId, rightId) {
|
|
489
|
-
return { shortId, rightId, rightEvaluated: false };
|
|
533
|
+
const key = eventKey(event);
|
|
534
|
+
if (state.eventKeys.has(key))
|
|
535
|
+
return false;
|
|
536
|
+
state.eventKeys.add(key);
|
|
537
|
+
state.events.push(event);
|
|
538
|
+
return true;
|
|
539
|
+
}
|
|
540
|
+
function coverageHit(id) {
|
|
541
|
+
state.hits.add(id);
|
|
542
|
+
const timestampMs = Date.now();
|
|
543
|
+
const phaseId = currentPhaseId();
|
|
544
|
+
if (isBrowser) {
|
|
545
|
+
if (recordBrowserEvent(__spreadProps(__spreadValues({
|
|
546
|
+
type: "hit",
|
|
547
|
+
id,
|
|
548
|
+
timestampMs
|
|
549
|
+
}, phaseId ? { phaseId } : {}), {
|
|
550
|
+
environment: "browser"
|
|
551
|
+
})))
|
|
552
|
+
persistBrowser();
|
|
553
|
+
} else {
|
|
554
|
+
appendServer(__spreadValues({
|
|
555
|
+
type: "hit",
|
|
556
|
+
id,
|
|
557
|
+
timestampMs
|
|
558
|
+
}, phaseId ? { phaseId } : {}));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function selectionBegin(shortId, rightId) {
|
|
562
|
+
return { shortId, rightId, rightEvaluated: false };
|
|
490
563
|
}
|
|
491
564
|
function applyInferredName(value, inferredName) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (!decision)
|
|
563
|
-
return value;
|
|
564
|
-
const vector = { values: frame.values, outcome: Boolean(value) };
|
|
565
|
-
const key = vectorKey(vector);
|
|
566
|
-
decision.vectors.set(key, vector);
|
|
567
|
-
const timestampMs = Date.now();
|
|
568
|
-
const phaseId = currentPhaseId();
|
|
569
|
-
if (isBrowser) {
|
|
570
|
-
if (recordBrowserEvent({
|
|
571
|
-
type: "decision",
|
|
572
|
-
id: decision.meta.id,
|
|
573
|
-
vector,
|
|
574
|
-
timestampMs,
|
|
575
|
-
...(phaseId ? { phaseId } : {}),
|
|
576
|
-
environment: "browser",
|
|
577
|
-
}))
|
|
578
|
-
persistBrowser();
|
|
579
|
-
}
|
|
580
|
-
else {
|
|
581
|
-
appendServer({
|
|
582
|
-
type: "decision",
|
|
583
|
-
meta: decision.meta,
|
|
584
|
-
vector,
|
|
585
|
-
timestampMs,
|
|
586
|
-
...(phaseId ? { phaseId } : {}),
|
|
587
|
-
});
|
|
588
|
-
}
|
|
565
|
+
if (inferredName && typeof value === "function" && value.name === "") {
|
|
566
|
+
Object.defineProperty(value, "name", {
|
|
567
|
+
value: inferredName,
|
|
568
|
+
configurable: true
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
return value;
|
|
572
|
+
}
|
|
573
|
+
function selectionRight(frame, value, inferredName) {
|
|
574
|
+
frame.rightEvaluated = true;
|
|
575
|
+
return applyInferredName(value, inferredName);
|
|
576
|
+
}
|
|
577
|
+
function selectionEnd(frame, value) {
|
|
578
|
+
coverageHit(frame.rightEvaluated ? frame.rightId : frame.shortId);
|
|
579
|
+
return value;
|
|
580
|
+
}
|
|
581
|
+
function optionalSelect(shortId, continuedId, value) {
|
|
582
|
+
coverageHit(value === null || value === void 0 ? shortId : continuedId);
|
|
583
|
+
return value;
|
|
584
|
+
}
|
|
585
|
+
function defaultSelected(defaultId, value, inferredName) {
|
|
586
|
+
var _a8;
|
|
587
|
+
pendingDefaults.set(defaultId, ((_a8 = pendingDefaults.get(defaultId)) != null ? _a8 : 0) + 1);
|
|
588
|
+
return applyInferredName(value, inferredName);
|
|
589
|
+
}
|
|
590
|
+
function defaultEntered(defaultId, providedId) {
|
|
591
|
+
var _a8;
|
|
592
|
+
const pending = (_a8 = pendingDefaults.get(defaultId)) != null ? _a8 : 0;
|
|
593
|
+
if (pending > 0) {
|
|
594
|
+
pendingDefaults.set(defaultId, pending - 1);
|
|
595
|
+
coverageHit(defaultId);
|
|
596
|
+
} else {
|
|
597
|
+
coverageHit(providedId);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function tryBegin(successId, catchId) {
|
|
601
|
+
return { successId, catchId, caught: false };
|
|
602
|
+
}
|
|
603
|
+
function tryCatch(frame, value) {
|
|
604
|
+
frame.caught = true;
|
|
605
|
+
return value;
|
|
606
|
+
}
|
|
607
|
+
function tryEnd(frame) {
|
|
608
|
+
coverageHit(frame.caught ? frame.catchId : frame.successId);
|
|
609
|
+
}
|
|
610
|
+
function loopBegin(zeroId, enteredId) {
|
|
611
|
+
return { zeroId, enteredId, entered: false };
|
|
612
|
+
}
|
|
613
|
+
function loopEntered(frame) {
|
|
614
|
+
frame.entered = true;
|
|
615
|
+
}
|
|
616
|
+
function loopEnd(frame) {
|
|
617
|
+
coverageHit(frame.entered ? frame.enteredId : frame.zeroId);
|
|
618
|
+
}
|
|
619
|
+
function mcdcBegin(id, meta) {
|
|
620
|
+
if (!state.decisions.has(id)) {
|
|
621
|
+
state.decisions.set(id, { meta, vectors: /* @__PURE__ */ new Map() });
|
|
622
|
+
}
|
|
623
|
+
return {
|
|
624
|
+
meta,
|
|
625
|
+
values: Array.from({ length: meta.conditions.length }, () => null)
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function mcdcCondition(frame, index, value) {
|
|
629
|
+
frame.values[index] = Boolean(value);
|
|
630
|
+
return value;
|
|
631
|
+
}
|
|
632
|
+
function mcdcEnd(frame, value) {
|
|
633
|
+
const decision = state.decisions.get(frame.meta.id);
|
|
634
|
+
if (!decision)
|
|
589
635
|
return value;
|
|
590
|
-
}
|
|
591
|
-
|
|
636
|
+
const vector = { values: frame.values, outcome: Boolean(value) };
|
|
637
|
+
const key = vectorKey(vector);
|
|
638
|
+
decision.vectors.set(key, vector);
|
|
639
|
+
const timestampMs = Date.now();
|
|
640
|
+
const phaseId = currentPhaseId();
|
|
641
|
+
if (isBrowser) {
|
|
642
|
+
if (recordBrowserEvent(__spreadProps(__spreadValues({
|
|
643
|
+
type: "decision",
|
|
644
|
+
id: decision.meta.id,
|
|
645
|
+
vector,
|
|
646
|
+
timestampMs
|
|
647
|
+
}, phaseId ? { phaseId } : {}), {
|
|
648
|
+
environment: "browser"
|
|
649
|
+
})))
|
|
650
|
+
persistBrowser();
|
|
651
|
+
} else {
|
|
652
|
+
appendServer(__spreadValues({
|
|
653
|
+
type: "decision",
|
|
654
|
+
meta: decision.meta,
|
|
655
|
+
vector,
|
|
656
|
+
timestampMs
|
|
657
|
+
}, phaseId ? { phaseId } : {}));
|
|
658
|
+
}
|
|
659
|
+
return value;
|
|
660
|
+
}
|
|
661
|
+
export {
|
|
662
|
+
beginBufferedServerEvidence,
|
|
663
|
+
bindCoverageContext,
|
|
664
|
+
coverageCarrier,
|
|
665
|
+
coverageContextEnvironment,
|
|
666
|
+
coverageContextHeaders,
|
|
667
|
+
coverageHit,
|
|
668
|
+
coverageSnapshot,
|
|
669
|
+
defaultEntered,
|
|
670
|
+
defaultSelected,
|
|
671
|
+
enableRuntimeSnapshotEvidence,
|
|
672
|
+
flushBufferedServerEvidence,
|
|
673
|
+
loopBegin,
|
|
674
|
+
loopEnd,
|
|
675
|
+
loopEntered,
|
|
676
|
+
mcdcBegin,
|
|
677
|
+
mcdcCondition,
|
|
678
|
+
mcdcEnd,
|
|
679
|
+
optionalSelect,
|
|
680
|
+
resetCoverage,
|
|
681
|
+
selectionBegin,
|
|
682
|
+
selectionEnd,
|
|
683
|
+
selectionRight,
|
|
684
|
+
tryBegin,
|
|
685
|
+
tryCatch,
|
|
686
|
+
tryEnd,
|
|
687
|
+
withCoverageCarrier,
|
|
688
|
+
withRequestPhase,
|
|
689
|
+
writeExclusiveBackgroundRecord
|
|
690
|
+
};
|