@piwitests/reporter 0.64.0 → 0.66.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.
@@ -61,7 +61,7 @@ __export(capture_fixtures_exports, {
61
61
  stopResourceLedger: () => stopResourceLedger
62
62
  });
63
63
  module.exports = __toCommonJS(capture_fixtures_exports);
64
- var path17 = __toESM(require("path"));
64
+ var path18 = __toESM(require("path"));
65
65
  var import_node_zlib2 = require("zlib");
66
66
 
67
67
  // ../picker-dom/src/probe.ts
@@ -520,8 +520,8 @@ function installPickerOverlay(arg) {
520
520
  return root && root !== doc && root.host ? root.host : null;
521
521
  };
522
522
  const targetOf = (e) => {
523
- const path18 = typeof e.composedPath === "function" ? e.composedPath() : null;
524
- const first = path18 && path18.length ? path18[0] : null;
523
+ const path19 = typeof e.composedPath === "function" ? e.composedPath() : null;
524
+ const first = path19 && path19.length ? path19[0] : null;
525
525
  return first && first.nodeType === 1 ? first : e.target;
526
526
  };
527
527
  const buildChain = (raw) => {
@@ -1223,8 +1223,8 @@ function showPauseBar(arg) {
1223
1223
  g.__piwiPauseState = choice;
1224
1224
  };
1225
1225
  const pageTakesEscape = (e) => {
1226
- const path18 = typeof e.composedPath === "function" ? e.composedPath() : [e.target];
1227
- const el = path18.find((node) => node && node.nodeType === 1);
1226
+ const path19 = typeof e.composedPath === "function" ? e.composedPath() : [e.target];
1227
+ const el = path19.find((node) => node && node.nodeType === 1);
1228
1228
  if (el && !bar.contains(el) && typeof el.closest === "function") {
1229
1229
  if (el.closest('dialog[open],[role="dialog"],[role="alertdialog"],[role="listbox"],[role="menu"]')) return true;
1230
1230
  const popup = '[aria-expanded="true"]:is([role="combobox"],[aria-haspopup]:not([aria-haspopup="false"]))';
@@ -2116,21 +2116,21 @@ var MAX_INDETERMINATE = 20;
2116
2116
  var STEP = String.raw`[a-zA-Z][\w.-]*:[1-9]\d*`;
2117
2117
  var LEVEL = `${STEP}(?:/${STEP})*`;
2118
2118
  var ELEMENT_PATH_RE = new RegExp(`^${LEVEL}(?:\\|${LEVEL})*$`);
2119
- function isElementPath(path18) {
2120
- return typeof path18 === "string" && path18.length <= ELEMENT_PATH_MAX_CHARS && ELEMENT_PATH_RE.test(path18);
2119
+ function isElementPath(path19) {
2120
+ return typeof path19 === "string" && path19.length <= ELEMENT_PATH_MAX_CHARS && ELEMENT_PATH_RE.test(path19);
2121
2121
  }
2122
2122
  var offsetOf = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 && v <= 1e7 ? v : null;
2123
2123
  function elementRef(v) {
2124
2124
  if (!v || typeof v !== "object") return null;
2125
- const { path: path18, label } = v;
2126
- if (!isElementPath(path18)) return null;
2127
- return { path: path18, label: typeof label === "string" ? label.slice(0, ELEMENT_LABEL_MAX_CHARS) : "" };
2125
+ const { path: path19, label } = v;
2126
+ if (!isElementPath(path19)) return null;
2127
+ return { path: path19, label: typeof label === "string" ? label.slice(0, ELEMENT_LABEL_MAX_CHARS) : "" };
2128
2128
  }
2129
2129
  function textPoint(v) {
2130
2130
  if (!v || typeof v !== "object") return null;
2131
- const { path: path18, offset } = v;
2131
+ const { path: path19, offset } = v;
2132
2132
  const at = offsetOf(offset);
2133
- return isElementPath(path18) && at !== null ? { path: path18, offset: at } : null;
2133
+ return isElementPath(path19) && at !== null ? { path: path19, offset: at } : null;
2134
2134
  }
2135
2135
  function sanitizePageInteraction(raw) {
2136
2136
  if (!raw || typeof raw !== "object") return {};
@@ -2537,6 +2537,7 @@ var ATTACHMENT_NAMES = {
2537
2537
  codeReach: "piwi-code-reach",
2538
2538
  browserCoverage: "piwi-browser-coverage",
2539
2539
  browserFunctions: "piwi-browser-functions",
2540
+ browserLines: "piwi-browser-lines",
2540
2541
  cssCoverage: "piwi-css-coverage",
2541
2542
  cssRules: "piwi-css-rules",
2542
2543
  serverCoverageRequests: "piwi-server-coverage-requests",
@@ -2952,16 +2953,68 @@ function relativeTestPath(file, base) {
2952
2953
  return path4.relative(base, file).split(path4.sep).join("/");
2953
2954
  }
2954
2955
 
2956
+ // ../core/src/glob.ts
2957
+ function dotTakes(char) {
2958
+ return char !== "\n" && char !== "\r" && char !== "\u2028" && char !== "\u2029";
2959
+ }
2960
+ function canonicalize(char) {
2961
+ const upper = char.toUpperCase();
2962
+ if (upper.length !== 1) return char;
2963
+ return char.charCodeAt(0) >= 128 && upper.charCodeAt(0) < 128 ? char : upper;
2964
+ }
2965
+ function compileGlob(tokens, ignoreCase = false) {
2966
+ const steps = ignoreCase ? tokens.map((token) => token.kind === "char" ? { ...token, char: canonicalize(token.char) } : token) : tokens;
2967
+ const end = steps.length;
2968
+ return (text) => {
2969
+ const seen = new Int32Array(end + 1).fill(-1);
2970
+ let current = [];
2971
+ let next = [];
2972
+ const reach = (list, from, step) => {
2973
+ for (let state = from; seen[state] !== step; state++) {
2974
+ seen[state] = step;
2975
+ list.push(state);
2976
+ if (state === end || steps[state].kind !== "run") break;
2977
+ }
2978
+ };
2979
+ reach(current, 0, 0);
2980
+ for (let i = 0; i < text.length; i++) {
2981
+ const char = ignoreCase ? canonicalize(text[i]) : text[i];
2982
+ const dot = dotTakes(char);
2983
+ for (const state of current) {
2984
+ if (state === end) continue;
2985
+ const token = steps[state];
2986
+ const takes = token.kind === "char" ? token.char === char : token.slash ? dot : char !== "/";
2987
+ if (takes) reach(next, token.kind === "run" ? state : state + 1, i + 1);
2988
+ }
2989
+ if (next.length === 0) return false;
2990
+ [current, next] = [next, current];
2991
+ next.length = 0;
2992
+ }
2993
+ return seen[end] === text.length;
2994
+ };
2995
+ }
2996
+
2955
2997
  // src/internal/probe/plan.ts
2956
2998
  function parseRouteKey(routeKey2) {
2957
2999
  const space = routeKey2.indexOf(" ");
2958
3000
  if (space < 0) return { method: "", pattern: routeKey2 };
2959
3001
  return { method: routeKey2.slice(0, space).toUpperCase(), pattern: routeKey2.slice(space + 1) };
2960
3002
  }
2961
- function patternToRegex(pattern) {
2962
- const path18 = pattern.split("?")[0] ?? pattern;
2963
- const escaped = path18.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/:[A-Za-z0-9_]+/g, "[^/]+");
2964
- return new RegExp(`^${escaped}$`);
3003
+ var ROUTE_PARAM = /:[A-Za-z0-9_]+/y;
3004
+ function routePatternMatcher(pattern) {
3005
+ const path19 = pattern.split("?")[0] ?? pattern;
3006
+ const tokens = [];
3007
+ for (let i = 0; i < path19.length; i++) {
3008
+ ROUTE_PARAM.lastIndex = i;
3009
+ const param = ROUTE_PARAM.exec(path19);
3010
+ if (param) {
3011
+ tokens.push({ kind: "one", slash: false }, { kind: "run", slash: false });
3012
+ i += param[0].length - 1;
3013
+ } else {
3014
+ tokens.push({ kind: "char", char: path19[i] });
3015
+ }
3016
+ }
3017
+ return compileGlob(tokens);
2965
3018
  }
2966
3019
  function suitePathEqual(a, b) {
2967
3020
  if (!a || !b || a.length !== b.length) return false;
@@ -2983,13 +3036,13 @@ function matchProbeItem(plan, test) {
2983
3036
  function requestMatchesRoute(method, url, routeKey2) {
2984
3037
  const { method: rm, pattern } = parseRouteKey(routeKey2);
2985
3038
  if (rm && rm !== method.toUpperCase()) return false;
2986
- let path18;
3039
+ let path19;
2987
3040
  try {
2988
- path18 = new URL(url).pathname;
3041
+ path19 = new URL(url).pathname;
2989
3042
  } catch {
2990
- path18 = url.split("?")[0] ?? url;
3043
+ path19 = url.split("?")[0] ?? url;
2991
3044
  }
2992
- return patternToRegex(pattern).test(path18);
3045
+ return routePatternMatcher(pattern)(path19);
2993
3046
  }
2994
3047
  function createProbeState() {
2995
3048
  return { navigated: false, matches: 0 };
@@ -3011,10 +3064,10 @@ function isProbeMode() {
3011
3064
  function loadPlan() {
3012
3065
  if (planCache !== void 0) return planCache;
3013
3066
  planCache = null;
3014
- const path18 = process.env[PIWI_PROBE_ENV.plan];
3015
- if (path18) {
3067
+ const path19 = process.env[PIWI_PROBE_ENV.plan];
3068
+ if (path19) {
3016
3069
  try {
3017
- planCache = JSON.parse(fs3.readFileSync(path18, "utf8"));
3070
+ planCache = JSON.parse(fs3.readFileSync(path19, "utf8"));
3018
3071
  } catch {
3019
3072
  planCache = null;
3020
3073
  }
@@ -3048,10 +3101,10 @@ function outcomeFromStatus(status, applied) {
3048
3101
  return status === "passed" ? "not-noticed" : "inconclusive";
3049
3102
  }
3050
3103
  function recordProbeOutcome(line) {
3051
- const path18 = process.env[PIWI_PROBE_ENV.results];
3052
- if (!path18) return;
3104
+ const path19 = process.env[PIWI_PROBE_ENV.results];
3105
+ if (!path19) return;
3053
3106
  try {
3054
- fs3.appendFileSync(path18, `${JSON.stringify(line)}
3107
+ fs3.appendFileSync(path19, `${JSON.stringify(line)}
3055
3108
  `);
3056
3109
  } catch {
3057
3110
  }
@@ -3383,6 +3436,11 @@ var LONG_HEX_RE = /\b[0-9a-f]{8,}\b/gi;
3383
3436
  var SHORT_HEX_RE = /\b(?=[0-9a-f]*[a-f])(?=[0-9a-f]*[0-9])[0-9a-f]{6,7}\b/gi;
3384
3437
  var URL_RE = /\bhttps?:\/\/[^\s'"`)]+/gi;
3385
3438
  var EMAIL_RE = /\b[\w.+-]+@[\w-]+(?:\.[\w-]+)+\b/gi;
3439
+ var STRICT_MODE_ELEMENTS_RE = /(resolved to \d+ elements?:)(?:\n[ \t]*(?:\d+\) [^\n]*|\.\.\.))+/g;
3440
+ var ISO_TIMESTAMP_RE = /\b\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:[.,]\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?/g;
3441
+ var ABSOLUTE_PATH_RE = /(^|[^\w.~-])(?:\/(?:home|Users|root|__w|builds|github\/workspace|(?:private\/)?var\/folders)\/|[A-Za-z]:[\\/])(?:[^\s'"`()<>,;]*[\\/])?/gm;
3442
+ var TEMP_SUFFIX_RE = /([\\/][^\\/\s'"`()<>,;]*?[-_])(?=[a-z]{0,5}[A-Z0-9])[A-Za-z0-9]{6}(?![\w.-])/g;
3443
+ var UNDERSCORE_TOKEN_RE = /_([A-Za-z0-9]{8,})/g;
3386
3444
  var SELECTOR_OPTION_KEY_RE = /\b(name|hasText|hasNotText|has|placeholder|label|title|alt|exact)\s*:\s*(['"`])/gi;
3387
3445
  var LINE_TERMINATORS = /* @__PURE__ */ new Set(["\n", "\r", "\u2028", "\u2029"]);
3388
3446
  function closingQuoteIndex(text, quote) {
@@ -3429,8 +3487,15 @@ function classifyError(text) {
3429
3487
  if (/Timeout \d+m?s exceeded|TimeoutError|Timed out \d+m?s/i.test(text)) return "timeout";
3430
3488
  return "unknown";
3431
3489
  }
3490
+ function maskUnderscoreId(whole, token) {
3491
+ return /\d/.test(token) && /[A-Za-z]/.test(token) && !/^[A-Za-z]+\d+$/.test(token) ? "_<ID>" : whole;
3492
+ }
3493
+ function maskPaths(text) {
3494
+ return text.replace(ABSOLUTE_PATH_RE, "$1<PATH>/").replace(TEMP_SUFFIX_RE, "$1<TMP>");
3495
+ }
3432
3496
  function maskVolatile(text) {
3433
- return text.replace(/^(\s*(?:Received|Expected)[^:\n]*:).*$/gm, "$1 <VALUE>").replace(URL_RE, "<URL>").replace(EMAIL_RE, "<EMAIL>").replace(UUID_RE, "<UUID>").replace(LONG_HEX_RE, "<HASH>").replace(SHORT_HEX_RE, "<HASH>").replace(/([A-Za-z])?(\d+)/g, (whole, letter) => letter ? whole : "<N>");
3497
+ const structured = text.replace(STRICT_MODE_ELEMENTS_RE, "$1").replace(/^(\s*(?:Received|Expected)[^:\n]*:).*$/gm, "$1 <VALUE>").replace(URL_RE, "<URL>").replace(EMAIL_RE, "<EMAIL>").replace(ISO_TIMESTAMP_RE, "<TIMESTAMP>");
3498
+ return maskPaths(structured).replace(UUID_RE, "<UUID>").replace(UNDERSCORE_TOKEN_RE, maskUnderscoreId).replace(LONG_HEX_RE, "<HASH>").replace(SHORT_HEX_RE, "<HASH>").replace(/([A-Za-z])?(\d+)/g, (whole, letter) => letter ? whole : "<N>");
3434
3499
  }
3435
3500
  function extractErrorSignature(rawError) {
3436
3501
  const text = stripAnsi(rawError);
@@ -3851,21 +3916,38 @@ function isSecretName(name) {
3851
3916
  return secret;
3852
3917
  }
3853
3918
  var namesRead = /* @__PURE__ */ new Map();
3854
- var SECRET_SHAPES = [
3855
- /\beyJ[\w-]{5,}\.[\w-]{5,}\.[\w-]*/g,
3856
- /\bBearer(?:\s+|%20)[\w.~+/-]{8,}=*/gi,
3857
- /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{8,}/g,
3858
- /\bwhsec_[A-Za-z0-9]{20,}/g,
3859
- /\bsk-(?=[\w-]{0,200}\d)(?=[\w-]{0,200}[A-Z])[\w-]{32,}/g,
3860
- /\bglpat-[\w-]{20,}/g,
3861
- /\bnpm_[A-Za-z0-9]{36}\b/g,
3862
- /\bSK[0-9a-f]{32}\b/g,
3863
- /\bAKIA[0-9A-Z]{16}\b/g,
3864
- /\bAIza[\w-]{30,}/g,
3865
- /\bgh[opsu]_[A-Za-z0-9]{20,}/g,
3866
- /\bgithub_pat_\w{20,}/g,
3867
- /\bxox[abprs]-[\w-]{8,}/g
3919
+ var SHAPES = [
3920
+ { re: /\beyJ[\w-]{5,}\.[\w-]{5,}\.[\w-]*/g, starts: ["eyJ"] },
3921
+ { re: /\bBearer(?:\s+|%20)[\w.~+/-]{8,}=*/gi, starts: ["Bearer"] },
3922
+ {
3923
+ re: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{8,}/g,
3924
+ starts: ["sk_live_", "sk_test_", "rk_live_", "rk_test_"]
3925
+ },
3926
+ { re: /\bwhsec_[A-Za-z0-9]{20,}/g, starts: ["whsec_"] },
3927
+ { re: /\bsk-(?=[\w-]{0,200}\d)(?=[\w-]{0,200}[A-Z])[\w-]{32,}/g, starts: ["sk-"] },
3928
+ { re: /\bglpat-[\w-]{20,}/g, starts: ["glpat-"] },
3929
+ { re: /\bnpm_[A-Za-z0-9]{36}\b/g, starts: ["npm_"] },
3930
+ { re: /\bSK[0-9a-f]{32}\b/g, starts: ["SK"] },
3931
+ { re: /\bAKIA[0-9A-Z]{16}\b/g, starts: ["AKIA"] },
3932
+ { re: /\bAIza[\w-]{30,}/g, starts: ["AIza"] },
3933
+ { re: /\bgh[opsu]_[A-Za-z0-9]{20,}/g, starts: ["gho_", "ghp_", "ghs_", "ghu_"] },
3934
+ { re: /\bgithub_pat_\w{20,}/g, starts: ["github_pat_"] },
3935
+ { re: /\bxox[abprs]-[\w-]{8,}/g, starts: ["xoxa-", "xoxb-", "xoxp-", "xoxr-", "xoxs-"] },
3936
+ // Piwi's: an API key or the desktop app's token, an extension's device code, an MCP client's secret, authorization
3937
+ // code, access and refresh tokens, a share link's and an assistant turn's token; a live view's key.
3938
+ {
3939
+ re: /\b(?:pd[acor]?|mcps|psl|pwt)_[0-9a-f]{32,}/g,
3940
+ starts: ["pd_", "pda_", "pdc_", "pdo_", "pdr_", "mcps_", "psl_", "pwt_"]
3941
+ },
3942
+ { re: /\bpdl_[\w-]{40,}/g, starts: ["pdl_"] }
3868
3943
  ];
3944
+ var SECRET_SHAPES = SHAPES.map((shape) => shape.re);
3945
+ var SECRET_SHAPE_STARTS = SHAPES.flatMap(
3946
+ ({ re, starts }) => starts.map((start) => ({ start, anyCase: re.flags.includes("i") }))
3947
+ );
3948
+ var COLORED_SHAPES = SECRET_SHAPES.map(
3949
+ (re) => new RegExp(`(\\u001b\\[[\\d;]*m)${re.source.replace(/^\\b/, "")}`, re.flags)
3950
+ );
3869
3951
  var WHOLE_SHAPES = SECRET_SHAPES.map(
3870
3952
  (re) => new RegExp(`^(?:${re.source})$`, re.flags.replace("g", ""))
3871
3953
  );
@@ -3951,6 +4033,15 @@ function hider(count) {
3951
4033
  return HIDDEN_VALUE;
3952
4034
  };
3953
4035
  }
4036
+ function hideSecretShapes(text, count = { n: 0 }) {
4037
+ const hide = hider(count);
4038
+ let out = text;
4039
+ for (const shape of SECRET_SHAPES) out = out.replace(shape, () => hide());
4040
+ if (out.includes("\x1B[")) {
4041
+ for (const shape of COLORED_SHAPES) out = out.replace(shape, (_all, color) => `${color}${hide()}`);
4042
+ }
4043
+ return out;
4044
+ }
3954
4045
  function hideParams(params, count) {
3955
4046
  const hide = hider(count);
3956
4047
  return params.split(/([&;])/).map((part, i) => {
@@ -3963,9 +4054,9 @@ function hideParams(params, count) {
3963
4054
  return isSecretName(decodeSafe(name)) || isSecretValue(decoded) ? `${name}=${hide()}` : part;
3964
4055
  }).join("");
3965
4056
  }
3966
- function hidePath(path18, count) {
4057
+ function hidePath(path19, count) {
3967
4058
  const hide = hider(count);
3968
- return path18.split("/").map((segment) => {
4059
+ return path19.split("/").map((segment) => {
3969
4060
  const [own = "", ...params] = segment.split(";");
3970
4061
  const decoded = decodeSafe(own);
3971
4062
  const kept = decoded !== HIDDEN_VALUE && isSecretValue(decoded) ? hide() : own;
@@ -3975,14 +4066,14 @@ function hidePath(path18, count) {
3975
4066
  function hideSecretsInUrl(url, count = { n: 0 }) {
3976
4067
  const parts = URL_PARTS.exec(url);
3977
4068
  if (!parts) return url;
3978
- const [, scheme = "", authority, path18 = "", query = "", fragment = ""] = parts;
4069
+ const [, scheme = "", authority, path19 = "", query = "", fragment = ""] = parts;
3979
4070
  let out = "";
3980
4071
  if (authority !== void 0) {
3981
4072
  const at = authority.lastIndexOf("@");
3982
4073
  const colon = at >= 0 ? authority.slice(0, at).indexOf(":") : -1;
3983
4074
  out += colon >= 0 && colon < at - 1 ? `${scheme}//${authority.slice(0, colon + 1)}${hider(count)()}${authority.slice(at)}` : `${scheme}//${authority}`;
3984
4075
  }
3985
- out += hidePath(path18, count);
4076
+ out += hidePath(path19, count);
3986
4077
  if (query) out += `?${hideParams(query.slice(1), count)}`;
3987
4078
  if (fragment) {
3988
4079
  const body = fragment.slice(1);
@@ -4031,8 +4122,10 @@ function hideInText(text, count) {
4031
4122
  JSON_FIELD,
4032
4123
  (all, before, name, value) => isSecretName(name) && value !== HIDDEN_VALUE ? `${before}${hide()}"` : all
4033
4124
  );
4034
- out = out.replace(BASIC, (all, encoded) => isBasicCredential(encoded) ? hide() : all);
4035
- for (const shape of SECRET_SHAPES) out = out.replace(shape, () => hide());
4125
+ out = hideSecretShapes(
4126
+ out.replace(BASIC, (all, encoded) => isBasicCredential(encoded) ? hide() : all),
4127
+ count
4128
+ );
4036
4129
  return out.replace(
4037
4130
  TOKEN_RUN,
4038
4131
  (run) => run.includes("/") && !/[+=]/.test(run) ? run.split("/").map((part) => looksRandom(part) ? hide() : part).join("/") : looksRandom(run) ? hide() : run
@@ -4179,7 +4272,7 @@ function hideSecretsInError(text) {
4179
4272
  const log = text.indexOf(CALL_LOG, from);
4180
4273
  const message = text.slice(from, log === -1 ? text.length : log);
4181
4274
  out += secretField ? hideReadValues(message) : message;
4182
- if (log === -1) return out;
4275
+ if (log === -1) return hideSecretShapes(out);
4183
4276
  const start = log + CALL_LOG.length;
4184
4277
  CALL_LOG_END.lastIndex = start;
4185
4278
  const end = CALL_LOG_END.exec(text)?.index ?? text.length;
@@ -4194,7 +4287,7 @@ function joinErrorMessages(errors) {
4194
4287
  const seen = /* @__PURE__ */ new Set();
4195
4288
  const parts = [];
4196
4289
  for (const err of errors) {
4197
- const msg = err.message ?? "";
4290
+ const msg = err.message || err.value || "";
4198
4291
  if (!msg) continue;
4199
4292
  const dedupeKey = msg.trim().slice(0, 200);
4200
4293
  if (seen.has(dedupeKey)) continue;
@@ -4248,13 +4341,13 @@ function normalizeFunctionRanges(ranges) {
4248
4341
  }
4249
4342
  function normalizeCoveragePath(raw) {
4250
4343
  if (typeof raw !== "string" || raw.length > MAX_PATH_LENGTH || raw.includes("\0")) return null;
4251
- const path18 = raw.replace(/\\/g, "/").replace(/^\.\//, "");
4252
- if (!path18 || path18.startsWith("../") || path18.startsWith("/") || /^[A-Za-z]:\//.test(path18)) return null;
4253
- if (/(^|\/)node_modules\//.test(path18)) return null;
4254
- return path18;
4344
+ const path19 = raw.replace(/\\/g, "/").replace(/^\.\//, "");
4345
+ if (!path19 || path19.startsWith("../") || path19.startsWith("/") || /^[A-Za-z]:\//.test(path19)) return null;
4346
+ if (/(^|\/)node_modules\//.test(path19)) return null;
4347
+ return path19;
4255
4348
  }
4256
- function fileEntry(path18, runtime, blob, functions = [], lines = []) {
4257
- const file = { path: path18, runtime };
4349
+ function fileEntry(path19, runtime, blob, functions = [], lines = []) {
4350
+ const file = { path: path19, runtime };
4258
4351
  if (blob && (functions.length > 0 || lines.length > 0)) file.blob = blob;
4259
4352
  if (functions.length > 0) file.functions = functions;
4260
4353
  if (lines.length > 0) file.lines = lines;
@@ -4273,11 +4366,11 @@ function sanitizeCoverage(raw) {
4273
4366
  const files = [];
4274
4367
  for (const item of raw.files) {
4275
4368
  if (!isRecord(item) || !isRuntime(item.runtime)) continue;
4276
- const path18 = normalizeCoveragePath(item.path);
4277
- if (path18 === null) continue;
4369
+ const path19 = normalizeCoveragePath(item.path);
4370
+ if (path19 === null) continue;
4278
4371
  const blob = typeof item.blob === "string" && BLOB_ID.test(item.blob) ? item.blob : void 0;
4279
4372
  files.push(
4280
- fileEntry(path18, item.runtime, blob, normalizeFunctionRanges(item.functions), normalizeLineRanges(item.lines))
4373
+ fileEntry(path19, item.runtime, blob, normalizeFunctionRanges(item.functions), normalizeLineRanges(item.lines))
4281
4374
  );
4282
4375
  }
4283
4376
  const merged = mergeCoverage(captureOf(files, raw.incomplete === true));
@@ -4478,6 +4571,14 @@ function decodeSourceMap(raw) {
4478
4571
  });
4479
4572
  return first;
4480
4573
  },
4574
+ forEachMapping(visit) {
4575
+ for (let line = 0; line < lineCount; line++) {
4576
+ for (let i = segments.lineStarts[line]; i < segments.lineStarts[line + 1]; i++) {
4577
+ const source = segments.sources[i];
4578
+ if (source >= 0) visit(line, segments.columns[i], source, segments.originalLines[i]);
4579
+ }
4580
+ }
4581
+ },
4481
4582
  originalLinesBetween(source, start, end, fromLine = 0) {
4482
4583
  let first = Number.POSITIVE_INFINITY;
4483
4584
  let last = -1;
@@ -4565,8 +4666,24 @@ function normalizeSourcePath(source) {
4565
4666
 
4566
4667
  // ../core/src/code-reach.ts
4567
4668
  var MAX_CODE_REACH_FILES = 2e3;
4568
- function scriptText(source) {
4569
- return { length: source.length, starts: Uint32Array.from(lineStarts(source)) };
4669
+ var isSpace = (ch) => ch === 32 || ch === 9 || ch === 13 || ch === 11 || ch === 12 || ch === 65279;
4670
+ function scriptText(source, options = {}) {
4671
+ const starts = Uint32Array.from(lineStarts(source));
4672
+ if (!options.code) return { length: source.length, starts };
4673
+ const codeStarts = new Int32Array(starts.length).fill(-1);
4674
+ const codeEnds = new Int32Array(starts.length).fill(-1);
4675
+ for (let line = 0; line < starts.length; line++) {
4676
+ const from = starts[line];
4677
+ let to = line + 1 < starts.length ? starts[line + 1] - 1 : source.length;
4678
+ let first = from;
4679
+ while (first < to && isSpace(source.charCodeAt(first))) first++;
4680
+ while (to > first && isSpace(source.charCodeAt(to - 1))) to--;
4681
+ if (first < to) {
4682
+ codeStarts[line] = first - from;
4683
+ codeEnds[line] = to - from;
4684
+ }
4685
+ }
4686
+ return { length: source.length, starts, code: { starts: codeStarts, ends: codeEnds } };
4570
4687
  }
4571
4688
  var textOf = (entry, text) => text ?? (entry.source === void 0 ? void 0 : scriptText(entry.source));
4572
4689
  function executedFunctionRanges(entry, length, all = false) {
@@ -4627,14 +4744,122 @@ function finalizeCodeReach(files) {
4627
4744
  }
4628
4745
  return [...out].sort().slice(0, MAX_CODE_REACH_FILES);
4629
4746
  }
4747
+ function executedOffsets(functions) {
4748
+ const ranges = [];
4749
+ for (const fn of functions)
4750
+ for (const range of fn.ranges) if (range.endOffset > range.startOffset) ranges.push(range);
4751
+ ranges.sort((a, b) => a.startOffset - b.startOffset || b.endOffset - a.endOffset);
4752
+ const out = [];
4753
+ const emit = (from, to, count) => {
4754
+ if (to <= from || count <= 0) return;
4755
+ const last = out[out.length - 1];
4756
+ if (last && from <= last[1]) last[1] = Math.max(last[1], to);
4757
+ else out.push([from, to]);
4758
+ };
4759
+ const open = [];
4760
+ let at = 0;
4761
+ const close = (until) => {
4762
+ while (open.length > 0 && open[open.length - 1].endOffset <= until) {
4763
+ const top = open.pop();
4764
+ emit(at, top.endOffset, top.count);
4765
+ at = Math.max(at, top.endOffset);
4766
+ }
4767
+ };
4768
+ for (const range of ranges) {
4769
+ close(range.startOffset);
4770
+ const parent = open[open.length - 1];
4771
+ const end = parent ? Math.min(range.endOffset, parent.endOffset) : range.endOffset;
4772
+ if (parent) emit(at, range.startOffset, parent.count);
4773
+ at = Math.max(at, range.startOffset);
4774
+ open.push(end === range.endOffset ? range : { ...range, endOffset: end });
4775
+ }
4776
+ close(Number.POSITIVE_INFINITY);
4777
+ return out;
4778
+ }
4779
+ function unionOffsets(a, b) {
4780
+ const all = [...a, ...b].sort((x, y) => x[0] - y[0] || x[1] - y[1]);
4781
+ const out = [];
4782
+ for (const [start, end] of all) {
4783
+ const last = out[out.length - 1];
4784
+ if (last && start <= last[1]) last[1] = Math.max(last[1], end);
4785
+ else out.push([start, end]);
4786
+ }
4787
+ return out;
4788
+ }
4789
+ function ranBetween(executed, from, to) {
4790
+ let low = 0;
4791
+ let high = executed.length - 1;
4792
+ while (low <= high) {
4793
+ const mid = low + high >> 1;
4794
+ const [start, end] = executed[mid];
4795
+ if (end <= from) low = mid + 1;
4796
+ else if (start >= to) high = mid - 1;
4797
+ else return true;
4798
+ }
4799
+ return false;
4800
+ }
4801
+ function toLineRanges(lines) {
4802
+ const sorted = [...lines].sort((a, b) => a - b);
4803
+ const out = [];
4804
+ for (const line of sorted) {
4805
+ const last = out[out.length - 1];
4806
+ if (last && line + 1 <= last[1] + 1) last[1] = Math.max(last[1], line + 1);
4807
+ else out.push([line + 1, line + 1]);
4808
+ }
4809
+ return out;
4810
+ }
4811
+ function scriptLines(entry, executed, map, text) {
4812
+ const out = /* @__PURE__ */ new Map();
4813
+ const read = textOf(entry, text);
4814
+ if (!read) return out;
4815
+ const starts = read.starts;
4816
+ if (map) {
4817
+ const executable2 = /* @__PURE__ */ new Map();
4818
+ const ran2 = /* @__PURE__ */ new Map();
4819
+ const add2 = (into, source, line) => {
4820
+ let set = into.get(source);
4821
+ if (!set) into.set(source, set = /* @__PURE__ */ new Set());
4822
+ set.add(line);
4823
+ };
4824
+ map.forEachMapping((line, column, source, originalLine) => {
4825
+ if (line >= starts.length || originalLine < 0) return;
4826
+ add2(executable2, source, originalLine);
4827
+ const offset = starts[line] + column;
4828
+ if (offset < read.length && ranBetween(executed, offset, offset + 1)) add2(ran2, source, originalLine);
4829
+ });
4830
+ for (const [source, lines] of executable2) {
4831
+ out.set(source, { executable: toLineRanges(lines), lines: toLineRanges(ran2.get(source) ?? []) });
4832
+ }
4833
+ return out;
4834
+ }
4835
+ const code = read.code ?? (entry.source !== void 0 ? scriptText(entry.source, { code: true }).code : void 0);
4836
+ if (!code) return out;
4837
+ const executable = /* @__PURE__ */ new Map();
4838
+ for (const range of executedFunctionRanges(entry, read.length, true)) {
4839
+ const first = offsetToPosition(starts, range.start).line;
4840
+ const last = offsetToPosition(starts, Math.max(range.start, range.end - 1)).line;
4841
+ for (let line = first; line <= last; line++) {
4842
+ if (code.starts[line] < 0) continue;
4843
+ const from = Math.max(starts[line] + code.starts[line], range.start);
4844
+ const to = Math.min(starts[line] + code.ends[line], range.end);
4845
+ if (from >= to) continue;
4846
+ const parts = executable.get(line);
4847
+ if (parts) parts.push([from, to]);
4848
+ else executable.set(line, [[from, to]]);
4849
+ }
4850
+ }
4851
+ const ran = [];
4852
+ for (const [line, parts] of executable) {
4853
+ if (parts.some(([from, to]) => ranBetween(executed, from, to))) ran.push(line);
4854
+ }
4855
+ if (executable.size > 0) out.set(-1, { executable: toLineRanges(executable.keys()), lines: toLineRanges(ran) });
4856
+ return out;
4857
+ }
4630
4858
 
4631
4859
  // src/internal/capture/inspect-on-failure.ts
4632
- function isCi(ci) {
4633
- return ci !== void 0 && ci !== "" && ci !== "false";
4634
- }
4635
4860
  function shouldInspectOnFailure(gate) {
4636
4861
  if (gate.enabled !== "true") return false;
4637
- if (isCi(gate.ci)) return false;
4862
+ if (gate.ci) return false;
4638
4863
  if (gate.headless !== false) return false;
4639
4864
  if (gate.status !== "failed" && gate.status !== "timedOut") return false;
4640
4865
  if (gate.status === gate.expectedStatus) return false;
@@ -4644,7 +4869,7 @@ function environmentalSkipReason(gate) {
4644
4869
  if (gate.enabled !== "true") return null;
4645
4870
  if (gate.status !== "failed" && gate.status !== "timedOut") return null;
4646
4871
  if (gate.status === gate.expectedStatus) return null;
4647
- if (isCi(gate.ci)) return "running under CI \u2014 this is a headed, local-only feature";
4872
+ if (gate.ci) return "running under CI \u2014 this is a headed, local-only feature";
4648
4873
  if (gate.headless !== false) {
4649
4874
  return "the browser is headless \u2014 re-run with --headed (or set use: { headless: false })";
4650
4875
  }
@@ -4654,7 +4879,7 @@ function inspectionGateFromTestInfo(testInfo, enabled = process.env.PIWI_INSPECT
4654
4879
  const use = testInfo.project?.use ?? {};
4655
4880
  return {
4656
4881
  enabled,
4657
- ci: process.env.CI,
4882
+ ci: detectCi(process.env),
4658
4883
  status: testInfo.status,
4659
4884
  expectedStatus: testInfo.expectedStatus,
4660
4885
  headless: use.headless,
@@ -5092,7 +5317,7 @@ function pauseGateFromTestInfo(testInfo, headless) {
5092
5317
  const use = testInfo.project?.use ?? {};
5093
5318
  const debug = testInfo._configInternal?.configCLIOverrides?.debug;
5094
5319
  return {
5095
- ci: process.env.CI,
5320
+ ci: detectCi(process.env),
5096
5321
  headless: headless !== void 0 ? headless : use.headless,
5097
5322
  pwdebug: process.env.PWDEBUG,
5098
5323
  debug
@@ -5104,7 +5329,7 @@ function mayPause(gate) {
5104
5329
  return typeof gate.debug === "string" && gate.debug.length > 0;
5105
5330
  }
5106
5331
  function pauseSkipReason(gate) {
5107
- if (isCi(gate.ci)) return "running under CI \u2014 breakpoints pause local runs only";
5332
+ if (gate.ci) return "running under CI \u2014 breakpoints pause local runs only";
5108
5333
  if (gate.headless !== false && !gate.channel)
5109
5334
  return "the browser is headless \u2014 re-run with --headed (or set use: { headless: false })";
5110
5335
  if (gate.pwdebug && !["0", "false", "console"].includes(gate.pwdebug))
@@ -6824,8 +7049,8 @@ function parseRecordChannel(value) {
6824
7049
  const hash = text.lastIndexOf("#");
6825
7050
  if (hash <= 0) return null;
6826
7051
  const token = text.slice(hash + 1);
6827
- const path18 = text.slice(0, hash);
6828
- return /^[A-Za-z0-9_-]{16,}$/.test(token) && !path18.includes("\0") ? { path: path18, token } : null;
7052
+ const path19 = text.slice(0, hash);
7053
+ return /^[A-Za-z0-9_-]{16,}$/.test(token) && !path19.includes("\0") ? { path: path19, token } : null;
6829
7054
  }
6830
7055
  function isObject4(value) {
6831
7056
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -8940,53 +9165,87 @@ function cssCoverageInWorker() {
8940
9165
  }
8941
9166
  function browserCoverageInWorker() {
8942
9167
  const browser = process.env[PIWI_ENV_KEYS.coverageBrowser];
8943
- return process.env[PIWI_ENV_KEYS.captureCodeReach] === "true" || browser === "files" || browser === "functions";
9168
+ return process.env[PIWI_ENV_KEYS.captureCodeReach] === "true" || browser === "files" || browser === "functions" || browser === "lines";
8944
9169
  }
8945
9170
  function browserFunctionsInWorker() {
8946
- return process.env[PIWI_ENV_KEYS.coverageBrowser] === "functions";
9171
+ const browser = process.env[PIWI_ENV_KEYS.coverageBrowser];
9172
+ return browser === "functions" || browser === "lines";
8947
9173
  }
8948
- function browserFunctionCoverage(files) {
9174
+ function browserLinesInWorker() {
9175
+ return process.env[PIWI_ENV_KEYS.coverageBrowser] === "lines";
9176
+ }
9177
+ function browserFunctionCoverage(files, lines) {
9178
+ const entries = [...files].map(([path19, functions]) => ({ path: path19, functions: normalizeFunctionRanges(functions) }));
9179
+ let budget = MAX_COVERAGE_RANGES - entries.reduce((n, entry) => n + entry.functions.length, 0);
9180
+ let incomplete = false;
8949
9181
  return sanitizeCoverage({
8950
9182
  v: 1,
8951
- files: [...files].map(([path18, functions]) => ({ path: path18, runtime: "browser", functions }))
9183
+ files: entries.map(({ path: path19, functions }) => {
9184
+ const ran = normalizeLineRanges(lines?.get(path19) ?? []);
9185
+ if (ran.length === 0) return { path: path19, runtime: "browser", functions };
9186
+ if (ran.length > budget) {
9187
+ incomplete = true;
9188
+ return { path: path19, runtime: "browser", functions };
9189
+ }
9190
+ budget -= ran.length;
9191
+ return { path: path19, runtime: "browser", functions, lines: ran };
9192
+ }),
9193
+ ...incomplete ? { incomplete: true } : {}
8952
9194
  });
8953
9195
  }
8954
- function newKnownFunctions(known, sent2) {
9196
+ function newRangeParts(known, sent2, normalize2) {
8955
9197
  const parts = [];
8956
9198
  let files = [];
8957
9199
  let budget = MAX_COVERAGE_RANGES;
8958
9200
  const close = () => {
8959
- if (files.length > 0) parts.push({ v: 1, files: files.sort((a, b) => a.path < b.path ? -1 : 1) });
9201
+ if (files.length > 0) parts.push(files.sort((a, b) => a.path < b.path ? -1 : 1));
8960
9202
  files = [];
8961
9203
  budget = MAX_COVERAGE_RANGES;
8962
9204
  };
8963
9205
  for (const [raw, ranges] of known) {
8964
- const path18 = normalizeCoveragePath(raw);
8965
- if (path18 === null) continue;
8966
- let named = sent2.get(path18);
8967
- let fresh = normalizeFunctionRanges(ranges).filter((range) => !named?.has(`${range[0]}:${range[1]}`));
9206
+ const path19 = normalizeCoveragePath(raw);
9207
+ if (path19 === null) continue;
9208
+ let named = sent2.get(path19);
9209
+ let fresh = normalize2(ranges).filter((range) => !named?.has(`${range[0]}:${range[1]}`));
8968
9210
  if (fresh.length === 0) continue;
8969
- if (!named) sent2.set(path18, named = /* @__PURE__ */ new Set());
9211
+ if (!named) sent2.set(path19, named = /* @__PURE__ */ new Set());
8970
9212
  for (const range of fresh) named.add(`${range[0]}:${range[1]}`);
8971
9213
  while (fresh.length > 0) {
8972
9214
  if (budget === 0 || files.length >= MAX_COVERAGE_FILES) close();
8973
9215
  const part = fresh.slice(0, budget);
8974
9216
  fresh = fresh.slice(part.length);
8975
9217
  budget -= part.length;
8976
- files.push({ path: path18, allFunctions: part });
9218
+ files.push({ path: path19, ranges: part });
8977
9219
  }
8978
9220
  }
8979
9221
  close();
8980
9222
  return parts;
8981
9223
  }
9224
+ function newKnownFunctions(known, sent2) {
9225
+ return newRangeParts(known, sent2, normalizeFunctionRanges).map((files) => ({
9226
+ v: 1,
9227
+ files: files.map(({ path: path19, ranges }) => ({ path: path19, allFunctions: ranges }))
9228
+ }));
9229
+ }
9230
+ function newBrowserLines(executable, lines, sentExecutable, sentLines) {
9231
+ return [
9232
+ ...newRangeParts(executable, sentExecutable, normalizeLineRanges).map((files) => ({
9233
+ v: 1,
9234
+ files: files.map(({ path: path19, ranges }) => ({ path: path19, executable: ranges }))
9235
+ })),
9236
+ ...newRangeParts(lines, sentLines, normalizeLineRanges).map((files) => ({
9237
+ v: 1,
9238
+ files: files.map(({ path: path19, ranges }) => ({ path: path19, lines: ranges }))
9239
+ }))
9240
+ ];
9241
+ }
8982
9242
  function serverCoverageInWorker() {
8983
9243
  return isServerGranularity(process.env[PIWI_ENV_KEYS.coverageServer]);
8984
9244
  }
8985
9245
 
8986
9246
  // src/internal/support/aria-sampling.ts
8987
- var path13 = __toESM(require("path"));
8988
- var os4 = __toESM(require("os"));
8989
- var fs9 = __toESM(require("fs"));
9247
+ var path14 = __toESM(require("path"));
9248
+ var fs10 = __toESM(require("fs"));
8990
9249
 
8991
9250
  // src/internal/support/instance-id.ts
8992
9251
  var crypto2 = __toESM(require("crypto"));
@@ -8995,21 +9254,79 @@ function hashForProject(projectName) {
8995
9254
  return crypto2.createHash("sha1").update(projectName).digest("hex").slice(0, 16);
8996
9255
  }
8997
9256
 
9257
+ // src/internal/support/private-file.ts
9258
+ var crypto3 = __toESM(require("crypto"));
9259
+ var fs9 = __toESM(require("fs"));
9260
+ var os4 = __toESM(require("os"));
9261
+ var path13 = __toESM(require("path"));
9262
+ function privateTempDir() {
9263
+ if (process.platform !== "win32") return os4.tmpdir();
9264
+ const dir = path13.join(process.env.LOCALAPPDATA || path13.join(os4.homedir(), "AppData", "Local"), "piwi", "tmp");
9265
+ try {
9266
+ fs9.mkdirSync(dir, { recursive: true });
9267
+ } catch {
9268
+ }
9269
+ return dir;
9270
+ }
9271
+ var NO_FOLLOW = fs9.constants.O_NOFOLLOW ?? 0;
9272
+ var NO_WAIT = fs9.constants.O_NONBLOCK ?? 0;
9273
+ function untrustedReason(stat) {
9274
+ if (stat.isSymbolicLink()) return "it is a symbolic link";
9275
+ if (!stat.isFile()) return "it is not a regular file";
9276
+ if (typeof process.getuid === "function") {
9277
+ if (stat.uid !== process.getuid()) return "another user owns it";
9278
+ if (stat.mode & 18) return "other users may write to it";
9279
+ if (stat.nlink > 1) return "it has another name";
9280
+ }
9281
+ return null;
9282
+ }
9283
+ function appendPrivateFile(file, text) {
9284
+ const found = fs9.lstatSync(file, { throwIfNoEntry: false });
9285
+ const refused = found && untrustedReason(found);
9286
+ if (refused) throw new Error(`${file} is not written: ${refused}`);
9287
+ const fd = fs9.openSync(
9288
+ file,
9289
+ fs9.constants.O_WRONLY | fs9.constants.O_APPEND | fs9.constants.O_CREAT | NO_FOLLOW | NO_WAIT,
9290
+ 384
9291
+ );
9292
+ try {
9293
+ const reason = untrustedReason(fs9.fstatSync(fd));
9294
+ if (reason) throw new Error(`${file} is not written: ${reason}`);
9295
+ fs9.appendFileSync(fd, text, "utf8");
9296
+ } finally {
9297
+ fs9.closeSync(fd);
9298
+ }
9299
+ }
9300
+ function readPrivateFile(file) {
9301
+ const found = fs9.lstatSync(file, { throwIfNoEntry: false });
9302
+ if (!found) return null;
9303
+ const reason = untrustedReason(found);
9304
+ if (reason) return { untrusted: reason };
9305
+ const fd = fs9.openSync(file, fs9.constants.O_RDONLY | NO_FOLLOW | NO_WAIT);
9306
+ try {
9307
+ const opened = untrustedReason(fs9.fstatSync(fd));
9308
+ if (opened) return { untrusted: opened };
9309
+ return { text: fs9.readFileSync(fd, "utf8") };
9310
+ } finally {
9311
+ fs9.closeSync(fd);
9312
+ }
9313
+ }
9314
+
8998
9315
  // src/internal/support/aria-sampling.ts
8999
9316
  function ariaSampleIdentity(filePath2, title) {
9000
9317
  return `${filePath2}\0${title}`;
9001
9318
  }
9002
9319
  function getAriaSampleFilePath(projectName) {
9003
- return path13.join(os4.tmpdir(), `piwi-dashboard-aria-sample-${hashForProject(projectName)}.json`);
9320
+ return path14.join(privateTempDir(), `piwi-dashboard-aria-sample-${hashForProject(projectName)}.json`);
9004
9321
  }
9005
9322
  var cachedSets = /* @__PURE__ */ new Map();
9006
9323
  function loadAriaSampleSet(projectName) {
9007
9324
  if (cachedSets.has(projectName)) return cachedSets.get(projectName);
9008
9325
  let set = null;
9009
9326
  try {
9010
- const raw = fs9.readFileSync(getAriaSampleFilePath(projectName), "utf8");
9011
- const parsed2 = JSON.parse(raw);
9012
- if (parsed2.projectName === projectName && Array.isArray(parsed2.identities)) {
9327
+ const read = readPrivateFile(getAriaSampleFilePath(projectName));
9328
+ const parsed2 = read && "text" in read ? JSON.parse(read.text) : null;
9329
+ if (parsed2?.projectName === projectName && Array.isArray(parsed2.identities)) {
9013
9330
  set = new Set(parsed2.identities.filter((x) => typeof x === "string"));
9014
9331
  }
9015
9332
  } catch {
@@ -9029,9 +9346,9 @@ function isDueForAriaSample(testInfo) {
9029
9346
  }
9030
9347
 
9031
9348
  // src/internal/capture/code-reach.ts
9032
- var crypto3 = __toESM(require("crypto"));
9033
- var fs10 = __toESM(require("fs"));
9034
- var path14 = __toESM(require("path"));
9349
+ var crypto4 = __toESM(require("crypto"));
9350
+ var fs11 = __toESM(require("fs"));
9351
+ var path15 = __toESM(require("path"));
9035
9352
  var import_node_child_process = require("child_process");
9036
9353
  var MAX_MAP_BYTES = 20 * 1024 * 1024;
9037
9354
  var MAP_TIMEOUT_MS = 5e3;
@@ -9074,12 +9391,12 @@ function repositoryRoot(from) {
9074
9391
  }).trim();
9075
9392
  } catch {
9076
9393
  }
9077
- cachedRepoRoot = { from, root: path14.resolve(root) };
9394
+ cachedRepoRoot = { from, root: path15.resolve(root) };
9078
9395
  return cachedRepoRoot.root;
9079
9396
  }
9080
9397
  function codeReachRoots(configDir, configured) {
9081
9398
  const repoRoot = repositoryRoot(configDir);
9082
- const resolve6 = (dirs) => (Array.isArray(dirs) ? dirs : dirs ? [dirs] : []).filter(Boolean).map((r) => path14.resolve(configDir, r));
9399
+ const resolve6 = (dirs) => (Array.isArray(dirs) ? dirs : dirs ? [dirs] : []).filter(Boolean).map((r) => path15.resolve(configDir, r));
9083
9400
  const global = Array.isArray(configured) ? resolve6(configured) : resolve6(configured?.["*"]);
9084
9401
  const byOrigin = /* @__PURE__ */ new Map();
9085
9402
  if (configured && !Array.isArray(configured)) {
@@ -9108,7 +9425,7 @@ function scriptRoots(roots, scriptUrl, pageUrl) {
9108
9425
  }
9109
9426
  function isFile(file) {
9110
9427
  try {
9111
- return fs10.statSync(file).isFile();
9428
+ return fs11.statSync(file).isFile();
9112
9429
  } catch {
9113
9430
  return false;
9114
9431
  }
@@ -9116,10 +9433,10 @@ function isFile(file) {
9116
9433
  function resolveSourcePath(source, roots) {
9117
9434
  const normalized = normalizeSourcePath(source);
9118
9435
  if (!normalized || /(?:^|\/)node_modules\//.test(normalized)) return null;
9119
- if (path14.isAbsolute(normalized) && isFile(normalized)) return path14.resolve(normalized);
9436
+ if (path15.isAbsolute(normalized) && isFile(normalized)) return path15.resolve(normalized);
9120
9437
  const relative7 = normalized.replace(/^\/+/, "");
9121
9438
  for (const root of roots) {
9122
- const candidate = path14.resolve(root, relative7);
9439
+ const candidate = path15.resolve(root, relative7);
9123
9440
  if (isFile(candidate)) return candidate;
9124
9441
  }
9125
9442
  return null;
@@ -9151,10 +9468,18 @@ function fileForUrl(url, roots, bases) {
9151
9468
  return file;
9152
9469
  }
9153
9470
  function relativeToRepo(file, repoRoot) {
9154
- return path14.relative(repoRoot, file).split(path14.sep).join("/");
9471
+ return path15.relative(repoRoot, file).split(path15.sep).join("/");
9472
+ }
9473
+ var SERVED_AS_WRITTEN_PARAMS = /* @__PURE__ */ new Set(["t", "v", "import"]);
9474
+ function servedAsWritten(url) {
9475
+ try {
9476
+ return [...new URL(url).searchParams.keys()].every((key) => SERVED_AS_WRITTEN_PARAMS.has(key));
9477
+ } catch {
9478
+ return false;
9479
+ }
9155
9480
  }
9156
9481
  function scriptVersion(entry) {
9157
- return entry.hash ?? crypto3.createHash("sha1").update(entry.source ?? "").digest("hex");
9482
+ return entry.hash ?? crypto4.createHash("sha1").update(entry.source ?? "").digest("hex");
9158
9483
  }
9159
9484
  async function loadMap(entry, fetchMap) {
9160
9485
  const ref = entry.source ? sourceMappingUrl(entry.source) : null;
@@ -9191,7 +9516,8 @@ async function resolveScript(entry, roots, bases, fetchMap) {
9191
9516
  const file = fileForUrl(entry.url, roots, bases);
9192
9517
  const lookup = await loadMap(entry, fetchMap);
9193
9518
  let resolution;
9194
- const text = entry.source === void 0 ? void 0 : scriptText(entry.source);
9519
+ const code = !!file && !lookup && browserLinesInWorker() && servedAsWritten(entry.url);
9520
+ const text = entry.source === void 0 ? void 0 : scriptText(entry.source, { code });
9195
9521
  if (file) resolution = { kind: "file", file, lookup, text };
9196
9522
  else resolution = lookup ? { kind: "map", lookup, files: [], text } : { kind: "none" };
9197
9523
  if (text) scriptCache.set(entry.url, version, resolution);
@@ -9204,20 +9530,26 @@ async function resolveCodeReach(entries, roots, fetchMap, pageUrl) {
9204
9530
  return finalizeCodeReach((await resolveReach(entries, roots, fetchMap, pageUrl)).keys());
9205
9531
  }
9206
9532
  async function resolveCodeReachFunctions(entries, roots, fetchMap, pageUrl, options = {}) {
9207
- return resolveFunctions(entries, roots, fetchMap, pageUrl, options.known === true);
9533
+ return resolveFunctions(entries, roots, fetchMap, pageUrl, options.known === true, options.lines === true);
9208
9534
  }
9209
9535
  async function resolveReach(entries, roots, fetchMap, pageUrl) {
9210
- return (await resolveFunctions(entries, roots, fetchMap, pageUrl, false)).reached;
9536
+ return (await resolveFunctions(entries, roots, fetchMap, pageUrl, false, false)).reached;
9211
9537
  }
9212
9538
  var knownCache = new LatestByUrl();
9213
- async function resolveFunctions(entries, roots, fetchMap, pageUrl, withKnown) {
9539
+ async function resolveFunctions(entries, roots, fetchMap, pageUrl, withKnown, withLines) {
9214
9540
  const files = /* @__PURE__ */ new Map();
9215
9541
  const known = /* @__PURE__ */ new Map();
9542
+ const lines = /* @__PURE__ */ new Map();
9543
+ const executable = /* @__PURE__ */ new Map();
9544
+ const addLines = (into, file, ranges) => {
9545
+ const path19 = relativeToRepo(file, roots.repoRoot);
9546
+ into.set(path19, normalizeLineRanges([...into.get(path19) ?? [], ...ranges]));
9547
+ };
9216
9548
  const addTo = (into, file, functions) => {
9217
- const path18 = relativeToRepo(file, roots.repoRoot);
9218
- const listed = into.get(path18);
9549
+ const path19 = relativeToRepo(file, roots.repoRoot);
9550
+ const listed = into.get(path19);
9219
9551
  if (listed) listed.push(...functions);
9220
- else into.set(path18, [...functions]);
9552
+ else into.set(path19, [...functions]);
9221
9553
  };
9222
9554
  const add2 = (file, functions) => addTo(files, file, functions);
9223
9555
  const bases = viteBases(entries);
@@ -9256,6 +9588,17 @@ async function resolveFunctions(entries, roots, fetchMap, pageUrl, withKnown) {
9256
9588
  if (file) add2(file, functions);
9257
9589
  }
9258
9590
  }
9591
+ const ownLines = resolution.kind === "map" || resolution.kind === "file" && (!!resolution.lookup || servedAsWritten(covered.url));
9592
+ if (withLines && covered.executed && resolution.kind !== "none" && ownLines) {
9593
+ const text = textOf3(covered, resolution);
9594
+ const lookup = resolution.lookup;
9595
+ for (const [index, sourceLines] of scriptLines(covered, covered.executed, lookup, text)) {
9596
+ const file = resolution.kind === "file" ? resolution.file : mapFile(resolution, index);
9597
+ if (!file) continue;
9598
+ addLines(executable, file, sourceLines.executable);
9599
+ addLines(lines, file, sourceLines.lines);
9600
+ }
9601
+ }
9259
9602
  if (!withKnown || resolution.kind === "none") continue;
9260
9603
  const version = scriptVersion(covered);
9261
9604
  let listed = knownCache.get(covered.url, version);
@@ -9263,8 +9606,8 @@ async function resolveFunctions(entries, roots, fetchMap, pageUrl, withKnown) {
9263
9606
  const byFile = /* @__PURE__ */ new Map();
9264
9607
  const text = textOf3(covered, resolution);
9265
9608
  if (resolution.kind === "file" && resolution.file) {
9266
- const lines = knownFunctionLines(covered, resolution.lookup, text);
9267
- const all = resolution.lookup ? [...lines.values()].flat() : lines.get(-1) ?? [];
9609
+ const lines2 = knownFunctionLines(covered, resolution.lookup, text);
9610
+ const all = resolution.lookup ? [...lines2.values()].flat() : lines2.get(-1) ?? [];
9268
9611
  if (all.length > 0) byFile.set(resolution.file, all);
9269
9612
  } else if (resolution.kind === "map") {
9270
9613
  for (const [index, functions] of knownFunctionLines(covered, resolution.lookup, text)) {
@@ -9277,7 +9620,7 @@ async function resolveFunctions(entries, roots, fetchMap, pageUrl, withKnown) {
9277
9620
  }
9278
9621
  for (const [file, functions] of listed.files) addTo(known, file, functions);
9279
9622
  }
9280
- return { reached: files, known };
9623
+ return { reached: files, known, lines, executable };
9281
9624
  }
9282
9625
  function pageMapFetcher(page) {
9283
9626
  return async (url) => {
@@ -9338,7 +9681,7 @@ function onPaused(page, capture, event) {
9338
9681
  ]) : null;
9339
9682
  if (read) {
9340
9683
  const merging = read.then(
9341
- ([coverage]) => mergeCoverageRead(capture.ran, capture.scripts, coverage, capture.keepIdle)
9684
+ ([coverage]) => mergeCoverageRead(capture.ran, capture.scripts, coverage, capture.keepIdle, capture.blocks)
9342
9685
  );
9343
9686
  capture.reading.add(merging);
9344
9687
  void merging.finally(() => capture.reading.delete(merging));
@@ -9428,7 +9771,7 @@ async function readCssUsage(page, cdp, css) {
9428
9771
  } catch {
9429
9772
  }
9430
9773
  }
9431
- function mergeCoverageRead(ran, scripts, read, keepIdle = true) {
9774
+ function mergeCoverageRead(ran, scripts, read, keepIdle = true, blocks = false) {
9432
9775
  for (const covered of read) {
9433
9776
  const script = scripts.get(covered.scriptId);
9434
9777
  if (!script) continue;
@@ -9438,6 +9781,7 @@ function mergeCoverageRead(ran, scripts, read, keepIdle = true) {
9438
9781
  known = { script, functions: [], byRange: /* @__PURE__ */ new Map() };
9439
9782
  ran.set(key, known);
9440
9783
  }
9784
+ if (blocks) known.executed = unionOffsets(known.executed ?? [], executedOffsets(covered.functions));
9441
9785
  for (const fn of covered.functions) {
9442
9786
  const whole = fn.ranges[0];
9443
9787
  if (!whole) continue;
@@ -9448,7 +9792,7 @@ function mergeCoverageRead(ran, scripts, read, keepIdle = true) {
9448
9792
  if (whole.count > 0 && seen.ranges[0].count <= 0) seen.ranges[0].count = whole.count;
9449
9793
  continue;
9450
9794
  }
9451
- const copy = { ...fn, ranges: fn.ranges.map((r) => ({ ...r })) };
9795
+ const copy = { ...fn, ranges: [{ ...whole }] };
9452
9796
  known.byRange.set(range, copy);
9453
9797
  known.functions.push(copy);
9454
9798
  }
@@ -9464,6 +9808,7 @@ async function startCodeReach(page) {
9464
9808
  if (!isChromiumPage(page) || captures.has(page)) return false;
9465
9809
  const withCss = cssCoverageInWorker();
9466
9810
  const js = browserCoverageInWorker() || !withCss;
9811
+ const blocks = js && browserLinesInWorker();
9467
9812
  let cdp = null;
9468
9813
  try {
9469
9814
  cdp = await internalCall(page, () => page.context().newCDPSession(page));
@@ -9475,6 +9820,7 @@ async function startCodeReach(page) {
9475
9820
  sources: /* @__PURE__ */ new Map(),
9476
9821
  ran: /* @__PURE__ */ new Map(),
9477
9822
  keepIdle: browserFunctionsInWorker(),
9823
+ blocks,
9478
9824
  reading: /* @__PURE__ */ new Set(),
9479
9825
  pageUrl: page.url()
9480
9826
  };
@@ -9495,7 +9841,7 @@ async function startCodeReach(page) {
9495
9841
  capture.cdp.send("Debugger.enable"),
9496
9842
  ...js ? [
9497
9843
  capture.cdp.send("Profiler.enable"),
9498
- capture.cdp.send("Profiler.startPreciseCoverage", { callCount: false, detailed: false })
9844
+ capture.cdp.send("Profiler.startPreciseCoverage", { callCount: blocks, detailed: blocks })
9499
9845
  ] : [],
9500
9846
  // The style sheets' rule usage records nothing without the DOM and CSS domains. A failure there leaves the
9501
9847
  // scripts' coverage running.
@@ -9540,10 +9886,11 @@ async function stopPageCoverage(page) {
9540
9886
  await cdp.send("Profiler.stopPreciseCoverage");
9541
9887
  return taken.result;
9542
9888
  });
9543
- mergeCoverageRead(capture.ran, capture.scripts, last, capture.keepIdle);
9889
+ mergeCoverageRead(capture.ran, capture.scripts, last, capture.keepIdle, capture.blocks);
9544
9890
  const entries = [];
9545
- for (const [key, { script, functions }] of capture.ran) {
9891
+ for (const [key, { script, functions, executed }] of capture.ran) {
9546
9892
  const entry = { url: script.url, hash: script.hash, functions, pageUrl: script.pageUrl };
9893
+ if (executed) entry.executed = executed;
9547
9894
  const source = await capture.sources.get(key);
9548
9895
  if (source != null) entry.source = source;
9549
9896
  entries.push(entry);
@@ -9560,8 +9907,8 @@ async function stopPageCoverage(page) {
9560
9907
  }
9561
9908
 
9562
9909
  // src/internal/capture/css-coverage.ts
9563
- var crypto4 = __toESM(require("crypto"));
9564
- var fs11 = __toESM(require("fs"));
9910
+ var crypto5 = __toESM(require("crypto"));
9911
+ var fs12 = __toESM(require("fs"));
9565
9912
 
9566
9913
  // ../core/src/css-rules.ts
9567
9914
  var GROUPING = /* @__PURE__ */ new Set(["media", "supports", "layer", "container", "scope", "starting-style", "document"]);
@@ -9701,7 +10048,7 @@ function sourceFile(source, roots) {
9701
10048
  function styleBlockLine(file, index) {
9702
10049
  let text;
9703
10050
  try {
9704
- text = fs11.readFileSync(file, "utf-8");
10051
+ text = fs12.readFileSync(file, "utf-8");
9705
10052
  } catch {
9706
10053
  return 0;
9707
10054
  }
@@ -9732,7 +10079,7 @@ async function sheetMap(sheet, text, fetchMap) {
9732
10079
  function sameLines2(text, rules, file, lineOffset) {
9733
10080
  let source;
9734
10081
  try {
9735
- source = fs11.readFileSync(file, "utf-8");
10082
+ source = fs12.readFileSync(file, "utf-8");
9736
10083
  } catch {
9737
10084
  return false;
9738
10085
  }
@@ -9775,7 +10122,7 @@ async function resolveSheet(sheet, text, dirs, fetchMap) {
9775
10122
  return { rules, lookup: null, file, lineOffset, sources: [], exact: sameLines2(text, rules, file, lineOffset) };
9776
10123
  }
9777
10124
  function cachedResolution(sheet, text, dirs, fetchMap) {
9778
- const version = crypto4.createHash("sha1").update(text).digest("hex");
10125
+ const version = crypto5.createHash("sha1").update(text).digest("hex");
9779
10126
  const key = [sheet.devId ?? sheet.sourceURL, sheet.isInline ? sheet.startLine : "", dirs.join("\0"), version].join(
9780
10127
  " "
9781
10128
  );
@@ -9822,21 +10169,21 @@ async function resolveCssCoverage(sheets, roots, fetchMap) {
9822
10169
 
9823
10170
  // src/internal/capture/resource-ledger.ts
9824
10171
  var childProcess = __toESM(require("child_process"));
9825
- var fs13 = __toESM(require("fs"));
10172
+ var fs14 = __toESM(require("fs"));
9826
10173
  var net3 = __toESM(require("net"));
9827
- var path16 = __toESM(require("path"));
10174
+ var path17 = __toESM(require("path"));
9828
10175
  var import_node_module3 = require("module");
9829
10176
 
9830
10177
  // src/internal/capture/worker-metrics.ts
9831
10178
  var import_node_perf_hooks = require("perf_hooks");
9832
10179
 
9833
10180
  // src/internal/support/system-readers.ts
9834
- var fs12 = __toESM(require("fs"));
9835
- var path15 = __toESM(require("path"));
10181
+ var fs13 = __toESM(require("fs"));
10182
+ var path16 = __toESM(require("path"));
9836
10183
  var CLK_TCK = 100;
9837
10184
  function readText(file) {
9838
10185
  try {
9839
- return fs12.readFileSync(file, "utf8");
10186
+ return fs13.readFileSync(file, "utf8");
9840
10187
  } catch {
9841
10188
  return null;
9842
10189
  }
@@ -9918,45 +10265,45 @@ var ProcFs = class {
9918
10265
  }
9919
10266
  /** Whether this looks like a Linux `/proc` at all. */
9920
10267
  available() {
9921
- return fs12.existsSync(path15.join(this.root, "stat"));
10268
+ return fs13.existsSync(path16.join(this.root, "stat"));
9922
10269
  }
9923
10270
  /** Every process, keyed by pid. */
9924
10271
  table() {
9925
10272
  const out = /* @__PURE__ */ new Map();
9926
10273
  let names;
9927
10274
  try {
9928
- names = fs12.readdirSync(this.root);
10275
+ names = fs13.readdirSync(this.root);
9929
10276
  } catch {
9930
10277
  return out;
9931
10278
  }
9932
10279
  for (const name of names) {
9933
10280
  if (!/^\d+$/.test(name)) continue;
9934
- const text = readText(path15.join(this.root, name, "stat"));
10281
+ const text = readText(path16.join(this.root, name, "stat"));
9935
10282
  const stat = text ? parseProcStat(Number(name), text) : null;
9936
10283
  if (stat) out.set(stat.pid, stat);
9937
10284
  }
9938
10285
  return out;
9939
10286
  }
9940
10287
  stat(pid) {
9941
- const text = readText(path15.join(this.root, String(pid), "stat"));
10288
+ const text = readText(path16.join(this.root, String(pid), "stat"));
9942
10289
  return text ? parseProcStat(pid, text) : null;
9943
10290
  }
9944
10291
  runWaitMs(pid) {
9945
- const text = readText(path15.join(this.root, String(pid), "schedstat"));
10292
+ const text = readText(path16.join(this.root, String(pid), "schedstat"));
9946
10293
  return text ? parseSchedstat(text) : null;
9947
10294
  }
9948
10295
  cmdline(pid) {
9949
- return (readText(path15.join(this.root, String(pid), "cmdline")) ?? "").split("\0").join(" ").trim();
10296
+ return (readText(path16.join(this.root, String(pid), "cmdline")) ?? "").split("\0").join(" ").trim();
9950
10297
  }
9951
10298
  /** A field of `/proc/<pid>/status`, in kB: `VmRSS`, `VmHWM`. */
9952
10299
  statusKb(pid, key) {
9953
- const text = readText(path15.join(this.root, String(pid), "status"));
10300
+ const text = readText(path16.join(this.root, String(pid), "status"));
9954
10301
  return text ? parseKbField(text, key) : null;
9955
10302
  }
9956
10303
  /** Proportional set size: shared pages split between the processes sharing them, so a sum counts them once. */
9957
10304
  async pssKb(pid) {
9958
10305
  try {
9959
- return parseKbField(await fs12.promises.readFile(path15.join(this.root, String(pid), "smaps_rollup"), "utf8"), "Pss");
10306
+ return parseKbField(await fs13.promises.readFile(path16.join(this.root, String(pid), "smaps_rollup"), "utf8"), "Pss");
9960
10307
  } catch {
9961
10308
  return null;
9962
10309
  }
@@ -9964,29 +10311,29 @@ var ProcFs = class {
9964
10311
  /** Reset a process's peak RSS (`VmHWM`) to its current RSS. */
9965
10312
  resetPeakRss(pid) {
9966
10313
  try {
9967
- fs12.writeFileSync(path15.join(this.root, String(pid), "clear_refs"), "5");
10314
+ fs13.writeFileSync(path16.join(this.root, String(pid), "clear_refs"), "5");
9968
10315
  return true;
9969
10316
  } catch {
9970
10317
  return false;
9971
10318
  }
9972
10319
  }
9973
10320
  cpuTicks() {
9974
- const text = readText(path15.join(this.root, "stat"));
10321
+ const text = readText(path16.join(this.root, "stat"));
9975
10322
  return text ? parseCpuTicks(text) : null;
9976
10323
  }
9977
10324
  /** Total stall time of a resource's pressure file, in µs. */
9978
10325
  pressureUs(resource) {
9979
- const text = readText(path15.join(this.root, "pressure", resource));
10326
+ const text = readText(path16.join(this.root, "pressure", resource));
9980
10327
  return text ? parsePsiTotal(text) : null;
9981
10328
  }
9982
10329
  memAvailableKb() {
9983
- const text = readText(path15.join(this.root, "meminfo"));
10330
+ const text = readText(path16.join(this.root, "meminfo"));
9984
10331
  return text ? parseKbField(text, "MemAvailable") : null;
9985
10332
  }
9986
10333
  /** Open file descriptors of a process. */
9987
10334
  fdCount(pid) {
9988
10335
  try {
9989
- return fs12.readdirSync(path15.join(this.root, String(pid), "fd")).length;
10336
+ return fs13.readdirSync(path16.join(this.root, String(pid), "fd")).length;
9990
10337
  } catch {
9991
10338
  return null;
9992
10339
  }
@@ -10256,8 +10603,8 @@ var GLOBALS_FILES = [
10256
10603
  function playwrightGlobalsFile() {
10257
10604
  const packageJson = resolvePlaywrightPackageJson();
10258
10605
  if (!packageJson) return null;
10259
- const root = path16.dirname(packageJson);
10260
- return GLOBALS_FILES.map((parts) => path16.join(root, ...parts)).find((file) => fs13.existsSync(file)) ?? null;
10606
+ const root = path17.dirname(packageJson);
10607
+ return GLOBALS_FILES.map((parts) => path17.join(root, ...parts)).find((file) => fs14.existsSync(file)) ?? null;
10261
10608
  }
10262
10609
  function playwrightTestInfoSource() {
10263
10610
  try {
@@ -10306,7 +10653,7 @@ function deepUserSite() {
10306
10653
  }
10307
10654
  var SHELLS = /^(?:sh|bash|dash|zsh|cmd|cmd\.exe|powershell|powershell\.exe|pwsh)$/i;
10308
10655
  function commandOf(spawnfile, spawnargs) {
10309
- const name = (file) => path16.basename(file.replace(/\\/g, "/").replace(/^["']|["']$/g, ""));
10656
+ const name = (file) => path17.basename(file.replace(/\\/g, "/").replace(/^["']|["']$/g, ""));
10310
10657
  const program = typeof spawnfile === "string" ? name(spawnfile) : "";
10311
10658
  const args = Array.isArray(spawnargs) ? spawnargs.map(String) : [];
10312
10659
  const script = args.findIndex((arg) => arg === "-c" || /^\/c$/i.test(arg));
@@ -10555,7 +10902,7 @@ var ResourceLedger = class {
10555
10902
  const census = this.census(null);
10556
10903
  if (this.resultsFile) {
10557
10904
  try {
10558
- fs13.appendFileSync(this.resultsFile, `${JSON.stringify(census)}
10905
+ appendPrivateFile(this.resultsFile, `${JSON.stringify(census)}
10559
10906
  `);
10560
10907
  } catch {
10561
10908
  }
@@ -11195,7 +11542,15 @@ function createSink() {
11195
11542
  releasedQuietSince: 0,
11196
11543
  releasedUntil: null,
11197
11544
  locatorPages: new LocatorPageLog(),
11198
- codeReach: { sessions: /* @__PURE__ */ new Map(), files: /* @__PURE__ */ new Map(), known: /* @__PURE__ */ new Map(), cssFiles: /* @__PURE__ */ new Map(), cssKnown: /* @__PURE__ */ new Map() },
11545
+ codeReach: {
11546
+ sessions: /* @__PURE__ */ new Map(),
11547
+ files: /* @__PURE__ */ new Map(),
11548
+ known: /* @__PURE__ */ new Map(),
11549
+ lines: /* @__PURE__ */ new Map(),
11550
+ executable: /* @__PURE__ */ new Map(),
11551
+ cssFiles: /* @__PURE__ */ new Map(),
11552
+ cssKnown: /* @__PURE__ */ new Map()
11553
+ },
11199
11554
  serverCoverage: /* @__PURE__ */ new Map(),
11200
11555
  baseURL: null,
11201
11556
  headless: void 0
@@ -11237,7 +11592,7 @@ function configuredCodeReachRoots() {
11237
11592
  }
11238
11593
  } catch {
11239
11594
  }
11240
- return raw.split(path17.delimiter).filter(Boolean);
11595
+ return raw.split(path18.delimiter).filter(Boolean);
11241
11596
  }
11242
11597
  async function stopSinkCodeReach(sink, closing) {
11243
11598
  const stopping = [];
@@ -11275,16 +11630,24 @@ async function stopPageCodeReach(sink, page, session, roots) {
11275
11630
  append(sink.codeReach.cssKnown, rules.known);
11276
11631
  }
11277
11632
  if (!scripts) return;
11278
- const { reached, known } = await resolveCodeReachFunctions(scripts, roots, fetchMap, page.url(), {
11279
- known: browserFunctionsInWorker()
11280
- });
11633
+ const { reached, known, lines, executable } = await resolveCodeReachFunctions(
11634
+ scripts,
11635
+ roots,
11636
+ fetchMap,
11637
+ page.url(),
11638
+ { known: browserFunctionsInWorker(), lines: browserLinesInWorker() }
11639
+ );
11281
11640
  append(sink.codeReach.files, reached);
11282
11641
  append(sink.codeReach.known, known);
11642
+ append(sink.codeReach.lines, lines);
11643
+ append(sink.codeReach.executable, executable);
11283
11644
  } catch {
11284
11645
  }
11285
11646
  }
11286
11647
  var currentSink = null;
11287
11648
  var KNOWN_FUNCTIONS_SENT = /* @__PURE__ */ new Map();
11649
+ var EXECUTABLE_LINES_SENT = /* @__PURE__ */ new Map();
11650
+ var RAN_LINES_SENT = /* @__PURE__ */ new Map();
11288
11651
  var KNOWN_CSS_RULES_SENT = /* @__PURE__ */ new Map();
11289
11652
  var PENDING_PROBES = /* @__PURE__ */ new Set();
11290
11653
  async function drainPendingProbes(capMs) {
@@ -11878,7 +12241,7 @@ function endedWaiting(sink, call) {
11878
12241
  return "finish";
11879
12242
  }
11880
12243
  function stopSite(sink, location) {
11881
- if (path17.dirname(path17.resolve(location.file)) !== __dirname) return stopCallSite(location);
12244
+ if (path18.dirname(path18.resolve(location.file)) !== __dirname) return stopCallSite(location);
11882
12245
  return inFlightCallSite([...sink.locatorCalls.values()].map((call) => call.location));
11883
12246
  }
11884
12247
  function stopBarPage(sink, context, of) {
@@ -12223,8 +12586,8 @@ function errorPlace(error, windows = process.platform === "win32") {
12223
12586
  for (const line of typeof stack === "string" ? stack.split("\n") : []) {
12224
12587
  const frame = /^\s*at\s+(?:.*?\s+\()?(.+?):(\d+):(\d+)\)?$/.exec(line);
12225
12588
  const file = frame ? framePath(frame[1], windows) : null;
12226
- if (!frame || !file || !(windows ? path17.win32 : path17.posix).isAbsolute(file)) continue;
12227
- if (/[\\/]node_modules[\\/]/.test(file) || path17.dirname(path17.resolve(file)) === __dirname) continue;
12589
+ if (!frame || !file || !(windows ? path18.win32 : path18.posix).isAbsolute(file)) continue;
12590
+ if (/[\\/]node_modules[\\/]/.test(file) || path18.dirname(path18.resolve(file)) === __dirname) continue;
12228
12591
  return { file, line: Number(frame[2]), column: Number(frame[3]) };
12229
12592
  }
12230
12593
  return null;
@@ -12255,7 +12618,7 @@ function stepInProgress(testInfo) {
12255
12618
  function runningCall(testInfo) {
12256
12619
  const call = callInProgress(testInfo);
12257
12620
  if (!call?.title) return null;
12258
- const file = path17.relative(process.cwd(), call.place.file).split(path17.sep).join("/");
12621
+ const file = path18.relative(process.cwd(), call.place.file).split(path18.sep).join("/");
12259
12622
  return { title: call.title, file, line: call.place.line };
12260
12623
  }
12261
12624
  function abortion(signal) {
@@ -12910,7 +13273,7 @@ async function flushSink(sink, testInfo) {
12910
13273
  contentType: "application/json",
12911
13274
  body: Buffer.from(JSON.stringify(finalizeCodeReach(sink.codeReach.files.keys())))
12912
13275
  });
12913
- const functions = browserFunctionsInWorker() ? browserFunctionCoverage(sink.codeReach.files) : null;
13276
+ const functions = browserFunctionsInWorker() ? browserFunctionCoverage(sink.codeReach.files, browserLinesInWorker() ? sink.codeReach.lines : void 0) : null;
12914
13277
  if (functions) {
12915
13278
  await testInfo.attach(ATTACHMENT_NAMES.browserCoverage, {
12916
13279
  contentType: "application/json",
@@ -12925,6 +13288,13 @@ async function flushSink(sink, testInfo) {
12925
13288
  body: Buffer.from(JSON.stringify(part))
12926
13289
  });
12927
13290
  }
13291
+ const fileLines = browserLinesInWorker() ? newBrowserLines(sink.codeReach.executable, sink.codeReach.lines, EXECUTABLE_LINES_SENT, RAN_LINES_SENT) : [];
13292
+ for (const part of fileLines) {
13293
+ await testInfo.attach(ATTACHMENT_NAMES.browserLines, {
13294
+ contentType: "application/json",
13295
+ body: Buffer.from(JSON.stringify(part))
13296
+ });
13297
+ }
12928
13298
  if (cssCoverageInWorker()) {
12929
13299
  const rules = sink.codeReach.cssFiles.size > 0 ? browserFunctionCoverage(sink.codeReach.cssFiles) : null;
12930
13300
  if (rules) {
@@ -13107,7 +13477,7 @@ var runControl = {
13107
13477
  }
13108
13478
  };
13109
13479
  function runFile(file) {
13110
- return path17.relative(process.cwd(), file).split(path17.sep).join("/") || file;
13480
+ return path18.relative(process.cwd(), file).split(path18.sep).join("/") || file;
13111
13481
  }
13112
13482
  function testBegin(testInfo, cannotPause) {
13113
13483
  const title = testInfo.titlePath.slice(1);
@@ -13215,7 +13585,8 @@ var piwiFixtures = {
13215
13585
  project: testInfo.project.name
13216
13586
  });
13217
13587
  if (role) {
13218
- const browserName = testInfo.project.use?.browserName ?? null;
13588
+ const use2 = testInfo.project.use;
13589
+ const browserName = use2?.browserName ?? use2?.defaultBrowserType ?? null;
13219
13590
  sink.flake = { plan, role, startedAt: Date.now(), browserName, conditions: null };
13220
13591
  }
13221
13592
  }