{"version":3,"sources":["../src/index.ts","../src/metrics.ts","../src/soak.ts","../src/assert.ts","../src/format.ts","../src/typing.ts"],"sourcesContent":["export {\n  checkLeaks,\n  expectNoLeak,\n  type LeakFinding,\n  type LeakThresholds,\n} from './assert.js';\nexport { formatSoak } from './format.js';\nexport { attachCDP, getPageMetrics, type Metrics } from './metrics.js';\nexport {\n  type Halves,\n  heapHalves,\n  metricHalves,\n  metricStretches,\n  soak,\n  type SoakOptions,\n  type SoakResult,\n  type SoakSample,\n  type Stretch,\n} from './soak.js';\nexport { calibrateTypingCost, type TypingGesture } from './typing.js';\n","import type { CDPSession, Page } from '@playwright/test';\n\n/** A single reading of the renderer's retained-object counters. */\nexport type Metrics = {\n  /** `JSHeapUsedSize` — bytes of live JS heap after collection. */\n  heap: number;\n  /** `Nodes` — DOM nodes the renderer still holds, attached or not. */\n  nodes: number;\n  /** `JSEventListeners` — registered listeners across all documents. */\n  listeners: number;\n  /** `Documents` — live documents, including detached ones. */\n  documents: number;\n};\n\n/**\n * Open a CDP session for metrics collection.\n *\n * Chromium only: the counters come from the Chrome DevTools Protocol, which\n * Firefox and WebKit do not implement. Leaks are rarely engine-specific, so a\n * Chromium-only guard still catches the overwhelming majority of them.\n */\nexport async function attachCDP(page: Page): Promise<CDPSession> {\n  const client = await page.context().newCDPSession(page);\n  await client.send('Performance.enable');\n  return client;\n}\n\n/**\n * Force collection, then read the counters.\n *\n * Collection runs twice on purpose: a single pass intermittently leaves\n * detached subtrees in the node count, which shows up as a flaky reading\n * roughly one time in six.\n */\nexport async function getPageMetrics(client: CDPSession): Promise<Metrics> {\n  await client.send('HeapProfiler.collectGarbage');\n  await client.send('HeapProfiler.collectGarbage');\n\n  const { metrics } = await client.send('Performance.getMetrics');\n  const m = Object.fromEntries(metrics.map((i) => [i.name, i.value]));\n\n  return {\n    heap: m.JSHeapUsedSize,\n    nodes: m.Nodes,\n    listeners: m.JSEventListeners,\n    documents: m.Documents,\n  };\n}\n","import type { CDPSession } from '@playwright/test';\n\nimport { getPageMetrics, type Metrics } from './metrics.js';\n\nexport type SoakSample = { iteration: number; metrics: Metrics };\n\nexport type SoakResult = {\n  /** Reading taken after warmup, before the measured loop. */\n  baseline: Metrics;\n  /** Reading taken after the last iteration. */\n  after: Metrics;\n  /** Readings taken during the loop, ending with `after`. */\n  samples: SoakSample[];\n  iterations: number;\n  warmup: number;\n};\n\nexport type SoakOptions = {\n  client: CDPSession;\n  /** The user flow to repeat. Receives the zero-based iteration index. */\n  flow: (iteration: number) => Promise<void>;\n  /** Measured iterations. Default 200. */\n  iterations?: number;\n  /**\n   * Flow runs before the baseline reading. Lazy module loading, first-render\n   * caches and connection setup all allocate once; letting them happen before\n   * the baseline keeps them out of the measurement. Default 5.\n   */\n  warmup?: number;\n  /**\n   * Take an intermediate reading every N iterations. Default is an eighth of\n   * the run.\n   *\n   * Readings are cheap next to the two forced collections each one already\n   * costs, and resolution is what the counter checks run on: the more stretches\n   * between readings there are, the more clearly a leak spread across all of\n   * them separates from a step concentrated in one.\n   */\n  sampleEvery?: number;\n};\n\n/**\n * Warm up, take a baseline, run `flow` `iterations` times taking periodic\n * readings, then take a final reading.\n *\n * Nothing is asserted here — pass the result to {@link expectNoLeak} or read\n * the samples yourself. Keeping measurement and judgement separate matters\n * because sensible thresholds are app-specific.\n */\nexport async function soak({\n  client,\n  flow,\n  iterations = 200,\n  warmup = 5,\n  sampleEvery = Math.max(1, Math.floor(iterations / 8)),\n}: SoakOptions): Promise<SoakResult> {\n  for (let i = 0; i < warmup; i++) {\n    await runFlow(flow, i, 'warmup', warmup);\n  }\n\n  const baseline = await getPageMetrics(client);\n  const samples: SoakSample[] = [];\n\n  for (let i = 0; i < iterations; i++) {\n    await runFlow(flow, i, 'iteration', iterations);\n    if ((i + 1) % sampleEvery === 0 && i + 1 < iterations) {\n      samples.push({ iteration: i + 1, metrics: await getPageMetrics(client) });\n    }\n  }\n\n  const after = await getPageMetrics(client);\n  samples.push({ iteration: iterations, metrics: after });\n\n  return { baseline, after, samples, iterations, warmup };\n}\n\n/**\n * Run one round, and if it throws say *where*.\n *\n * A flow that fails on round 3 of 200 otherwise surfaces as a bare locator\n * timeout with no hint that it came from inside a loop — and, worse, no hint\n * that warmup rounds ran before the loop started, which is the usual cause\n * when a flow assumes it is the first thing to touch the page.\n */\nasync function runFlow(\n  flow: (i: number) => Promise<void>,\n  index: number,\n  phase: 'warmup' | 'iteration',\n  total: number,\n): Promise<void> {\n  try {\n    await flow(index);\n  } catch (cause) {\n    throw new Error(\n      `playwright-soak: flow threw on ${phase} ${index + 1} of ${total}` +\n        (phase === 'iteration'\n          ? ' (warmup rounds ran before this, so page state is not fresh)'\n          : ''),\n      { cause },\n    );\n  }\n}\n\n/** Growth of one metric between two consecutive readings. */\nexport type Stretch = {\n  /** Iteration the previous reading was taken at. 0 means the baseline. */\n  from: number;\n  /** Iteration this reading was taken at. */\n  to: number;\n  delta: number;\n};\n\n/**\n * Growth of one metric between each pair of consecutive readings.\n *\n * This is the series the counter checks judge. A leak repeats, so its growth is\n * spread across the whole series. A cache warming up, a global registered\n * lazily on first interaction, or one of the transient listeners Chromium\n * registers and drops a moment later all pile their growth into a single\n * stretch and leave the rest flat.\n */\nexport function metricStretches(\n  r: SoakResult,\n  metric: keyof Metrics,\n): Stretch[] {\n  const readings = [{ iteration: 0, metrics: r.baseline }, ...r.samples];\n\n  return readings.slice(1).map((reading, i) => ({\n    from: readings[i].iteration,\n    to: reading.iteration,\n    delta: reading.metrics[metric] - readings[i].metrics[metric],\n  }));\n}\n\nexport type Halves = {\n  /** Growth from baseline to the midpoint sample. */\n  first: number;\n  /** Growth from the midpoint sample to the final reading. */\n  second: number;\n  midIteration: number;\n};\n\n/**\n * Split one metric's growth at the midpoint of the run.\n *\n * This is how a leak is told apart from a one-off. A per-iteration leak keeps a\n * roughly constant slope, so it grows its second half about as much as its\n * first. Warm-up allocation, lazily registered globals and browser noise all\n * land on one side of the split and leave the other flat.\n *\n * Returns `undefined` when there are too few samples to split.\n */\nexport function metricHalves(\n  r: SoakResult,\n  metric: keyof Metrics,\n): Halves | undefined {\n  const half = r.iterations / 2;\n  const mid = r.samples.reduce((best, s) =>\n    Math.abs(s.iteration - half) < Math.abs(best.iteration - half) ? s : best,\n  );\n  if (mid === r.samples[r.samples.length - 1]) return undefined;\n\n  return {\n    first: mid.metrics[metric] - r.baseline[metric],\n    second: r.after[metric] - mid.metrics[metric],\n    midIteration: mid.iteration,\n  };\n}\n\n/**\n * Heap growth over the second half of the loop, against the first half.\n *\n * The node, listener and document counters miss retention that is none of\n * those things: a stale subscriber callback closing over a component tree, an\n * unbounded cache of plain objects. That only moves the heap, and absolute heap\n * delta is too noisy to bound directly, so {@link checkLeaks} judges the shape\n * of this split instead of the size of the delta.\n *\n * Returns `undefined` when there are too few samples to split.\n */\nexport function heapHalves(r: SoakResult): Halves | undefined {\n  return metricHalves(r, 'heap');\n}\n","import type { Metrics } from './metrics.js';\nimport {\n  type Halves,\n  metricHalves,\n  metricStretches,\n  type SoakResult,\n} from './soak.js';\n\nexport type LeakThresholds = {\n  /**\n   * DOM nodes allowed to remain above baseline. A fixed allowance behaves\n   * better than a percentage on small DOM trees. Default 100.\n   */\n  nodes?: number;\n  /**\n   * Event listeners allowed to remain above baseline. Default 0 — listeners\n   * are registered deliberately, so an unmatched one is a bug, not noise.\n   *\n   * Growth still has to appear on both sides of the run to count, so a one-off\n   * registration or a browser blip does not trip this at 0.\n   */\n  listeners?: number;\n  /** Documents allowed to remain above baseline. Default 0. */\n  documents?: number;\n  /**\n   * Nodes per iteration the browser charges for text editing, from\n   * `calibrateTypingCost`. Added to the node allowance, with 10% slack.\n   * Default 0.\n   */\n  typingCost?: number;\n  /**\n   * Fraction of first-half heap growth the second half may reach before the\n   * curve counts as linear rather than decaying. Default 0.5 — across five\n   * frameworks the worst observed healthy ratio was 0.23.\n   */\n  heapRatio?: number;\n  /**\n   * Absolute heap slack, so a flow whose heap is already flat is not judged on\n   * the ratio between two noise readings. Default 256KB.\n   *\n   * Note this floor also means the heap check only really bites once first-half\n   * growth exceeds twice it — around 200 iterations on a typical app. Shorter\n   * runs are effectively counter-only.\n   */\n  heapNoise?: number;\n};\n\nexport type LeakFinding = {\n  metric: 'nodes' | 'listeners' | 'documents' | 'heap';\n  /** Growth from baseline to the final reading. Bytes for `heap`. */\n  growth: number;\n  /** Growth per iteration. */\n  perIteration: number;\n  /** Growth either side of the midpoint, when there were samples enough to split. */\n  halves?: Halves;\n  message: string;\n};\n\nconst mb = (bytes: number) => `${(bytes / 1024 / 1024).toFixed(2)}MB`;\n\n/**\n * Is this counter's growth spread across the run, or piled into one moment?\n *\n * A leak repeats, so its growth spreads: no single stretch between readings\n * holds much of the total. Two common things are not leaks and must not read as\n * one — a global listener registered lazily on first interaction, which steps\n * once and stays, and the transient listeners Chromium registers and drops a\n * moment later — and both put all their growth in one stretch.\n *\n * So the test is concentration: no stretch may account for half the growth or\n * more. Comparing the two halves of the run does not work, because an early\n * step plus a late blip grows both halves. Counting the stretches that grow\n * does, but the bar moves with the sample rate, and a leak that fires four\n * times across nine stretches is still a leak. Concentration is scale-free:\n * sample more finely and a real leak only looks more spread out, while a step\n * stays pinned at all of it.\n *\n * The blind spot is a leak living underneath one much larger step, which stays\n * concentrated and passes. Warmup exists to take the usual such step — first\n * render, lazy imports — before the baseline is read.\n *\n * Below two stretches there is no shape to judge, so fall back to reporting.\n */\nfunction accumulates(result: SoakResult, metric: keyof Metrics): boolean {\n  const stretches = metricStretches(result, metric);\n  if (stretches.length < 2) return true;\n\n  const total = stretches.reduce((sum, s) => sum + s.delta, 0);\n  const largest = Math.max(...stretches.map((s) => s.delta));\n  return largest * 2 < total;\n}\n\n/** `+15 then +15 across the halves, split @30` */\nconst shape = (halves: Halves | undefined) =>\n  halves\n    ? `, +${halves.first} then +${halves.second} across the halves, split @${halves.midIteration}`\n    : '';\n\n/**\n * Check a soak result against the thresholds and return what failed.\n *\n * Pure — no assertion library, no throwing. Use this when you want to decide\n * for yourself, or feed the findings into your runner's reporter.\n */\nexport function checkLeaks(\n  result: SoakResult,\n  thresholds: LeakThresholds = {},\n): LeakFinding[] {\n  const {\n    nodes = 100,\n    listeners = 0,\n    documents = 0,\n    typingCost = 0,\n    heapRatio = 0.5,\n    heapNoise = 256 * 1024,\n  } = thresholds;\n\n  const findings: LeakFinding[] = [];\n  const { baseline, after, iterations } = result;\n\n  const counter = (\n    metric: 'nodes' | 'listeners' | 'documents',\n    allowance: number,\n    describe: (growth: number, halves: Halves | undefined) => string,\n  ) => {\n    const growth = after[metric] - baseline[metric];\n    if (growth <= allowance) return;\n    if (!accumulates(result, metric)) return;\n\n    const halves = metricHalves(result, metric);\n    findings.push({\n      metric,\n      growth,\n      perIteration: growth / iterations,\n      halves,\n      message: describe(growth, halves),\n    });\n  };\n\n  const typingAllowance = Math.ceil(typingCost * iterations * 1.1);\n  const nodeBudget = nodes + typingAllowance;\n  counter(\n    'nodes',\n    // Historically a `>=` boundary, kept so a flow that lands exactly on the\n    // budget is treated as spent rather than clear.\n    nodeBudget - 1,\n    (growth, halves) =>\n      `DOM nodes accumulated: +${growth} over ${iterations} iterations (${(growth / iterations).toFixed(2)}/iteration${shape(halves)}), budget ${nodeBudget}${typingCost ? ` (${nodes} + ${typingAllowance} for typing)` : ''}`,\n  );\n\n  counter(\n    'listeners',\n    listeners,\n    (growth, halves) =>\n      `event listeners accumulated: +${growth} over ${iterations} iterations (${(growth / iterations).toFixed(2)}/iteration${shape(halves)}), allowed ${listeners}`,\n  );\n\n  counter(\n    'documents',\n    documents,\n    (growth, halves) =>\n      `documents accumulated: +${growth} over ${iterations} iterations${shape(halves)}, allowed ${documents}`,\n  );\n\n  const halves = metricHalves(result, 'heap');\n  if (halves) {\n    const allowed = Math.max(halves.first * heapRatio, heapNoise);\n    if (halves.second > allowed) {\n      const growth = after.heap - baseline.heap;\n      findings.push({\n        metric: 'heap',\n        growth,\n        perIteration: growth / iterations,\n        halves,\n        message: `heap grew as fast in the second half as the first (${mb(halves.first)} then ${mb(halves.second)}, split @${halves.midIteration}), which is a linear climb rather than a settling one; allowed ${mb(allowed)}`,\n      });\n    }\n  }\n\n  return findings;\n}\n\n/**\n * Throw if a soak run accumulated DOM nodes, listeners, documents or heap.\n *\n * Throws a plain `Error`, which every test runner reports as a failure. The\n * package deliberately does not import an assertion library at runtime: doing\n * so loads a second copy of `@playwright/test` whenever the package is\n * consumed through a link, which Playwright rejects outright.\n */\nexport function expectNoLeak(\n  result: SoakResult,\n  thresholds: LeakThresholds = {},\n): void {\n  const findings = checkLeaks(result, thresholds);\n  if (!findings.length) return;\n\n  throw new Error(\n    `playwright-soak: leak detected over ${result.iterations} iterations\\n` +\n      findings.map((f) => `  - ${f.message}`).join('\\n'),\n  );\n}\n","import {\n  heapHalves,\n  metricStretches,\n  type SoakResult,\n  type Stretch,\n} from './soak.js';\n\nconst mb = (bytes: number) => `${(bytes / 1024 / 1024).toFixed(2)}MB`;\nconst signed = (n: number) => (n >= 0 ? `+${n}` : String(n));\n\nconst COUNTERS = [\n  ['nodes', 'nodes'],\n  ['listeners', 'listeners'],\n  ['documents', 'docs'],\n] as const;\n\n/** `··+··+··+` — one character per stretch between readings. */\nconst spark = (stretches: Stretch[]) =>\n  stretches.map((s) => (s.delta > 0 ? '+' : s.delta < 0 ? '-' : '·')).join('');\n\n/**\n * How each counter moved between readings, and how concentrated that movement\n * was.\n *\n * The share is what decides the verdict: growth piled into one stretch is a\n * step, growth spread thin across all of them is a leak. Printing it means a\n * failing run explains itself without anyone re-deriving the shape from the\n * rows above.\n */\nfunction stretchLines(r: SoakResult): string[] {\n  return COUNTERS.flatMap(([metric, label]) => {\n    const stretches = metricStretches(r, metric);\n    if (stretches.length < 2) return [];\n\n    const total = stretches.reduce((sum, s) => sum + s.delta, 0);\n    if (total <= 0) return [];\n\n    const largest = Math.max(...stretches.map((s) => s.delta));\n    const share = Math.round((largest / total) * 100);\n\n    return [\n      `    ${label.padEnd(9)} ${spark(stretches)}  ${signed(total)} total, biggest stretch ${share}% of it ` +\n        `(${share < 50 ? 'spread out, so accumulating' : 'concentrated, so a step'})`,\n    ];\n  });\n}\n\n/**\n * Render a soak result as a fixed-width block for the test log.\n *\n * The intermediate samples are the point: a single delta cannot tell a leak\n * from a cache warming up, but a series of readings shows which one you have.\n */\nexport function formatSoak(\n  name: string,\n  r: SoakResult,\n  extra?: { typingCost?: number },\n): string {\n  const d = {\n    heap: r.after.heap - r.baseline.heap,\n    nodes: r.after.nodes - r.baseline.nodes,\n    listeners: r.after.listeners - r.baseline.listeners,\n    documents: r.after.documents - r.baseline.documents,\n  };\n\n  const row = (label: string, m: SoakResult['baseline']) =>\n    `    ${label}  heap ${mb(m.heap).padStart(8)}  nodes ${String(m.nodes).padStart(6)}  listeners ${String(m.listeners).padStart(5)}  docs ${m.documents}`;\n\n  const lines = [\n    `\\n[soak] ${name} — ${r.iterations} iterations`,\n    row('base   ', r.baseline),\n    ...r.samples.map((s) =>\n      row(`@${String(s.iteration).padStart(5)}`, s.metrics),\n    ),\n    `    delta  heap ${d.heap >= 0 ? '+' : ''}${mb(d.heap)}  nodes ${signed(d.nodes)}  listeners ${signed(d.listeners)}  docs ${signed(d.documents)}`,\n    `    per-iteration  heap ${(d.heap / r.iterations / 1024).toFixed(2)}KB  nodes ${(d.nodes / r.iterations).toFixed(2)}  listeners ${(d.listeners / r.iterations).toFixed(3)}`,\n  ];\n\n  const halves = heapHalves(r);\n  if (halves) {\n    lines.push(\n      `    heap halves  1st ${mb(halves.first)}  2nd ${mb(halves.second)}  (split @${halves.midIteration}; a settling curve has 2nd well under 1st)`,\n    );\n  }\n  lines.push(...stretchLines(r));\n  if (extra?.typingCost) {\n    lines.push(\n      `    browser typing cost ${extra.typingCost.toFixed(2)} nodes/round (budgeted for)`,\n    );\n  }\n\n  return lines.join('\\n');\n}\n","import type { CDPSession, Locator, Page } from '@playwright/test';\n\nimport { getPageMetrics } from './metrics.js';\n\nexport type TypingGesture = (locator: Locator) => Promise<void>;\n\n/**\n * Measure how many DOM nodes the browser retains per text-editing gesture,\n * independently of the page under test.\n *\n * Chromium charges roughly one node per editing interaction — its own\n * bookkeeping, nothing to do with your framework or your components. A plain\n * `<input>` created with `document.createElement`, never bound to anything,\n * shows the same slope. At a few hundred iterations that swamps any fixed node\n * budget, which is why typing soak tests get written off as flaky.\n *\n * So measure it against exactly such a control input, and hand the number to\n * {@link expectNoLeak} as `typingCost` so it can be budgeted for rather than\n * charged to your code.\n *\n * Call this *before* the baseline reading: the control's own nodes then sit\n * inside the baseline instead of appearing as growth.\n *\n * @param gesture The same typing gesture the flow performs, so the measured\n * cost matches what the flow will incur.\n * @returns Nodes retained per gesture. Never negative.\n */\nexport async function calibrateTypingCost(\n  page: Page,\n  client: CDPSession,\n  gesture: TypingGesture,\n  rounds = 20,\n): Promise<number> {\n  await page.evaluate(() => {\n    const input = document.createElement('input');\n    input.setAttribute('data-playwright-soak-control', '');\n    document.body.appendChild(input);\n  });\n  const control = page.locator('[data-playwright-soak-control]');\n\n  // One gesture first, so the input's own one-off allocations land in `before`.\n  await gesture(control);\n  const before = await getPageMetrics(client);\n\n  for (let i = 0; i < rounds; i++) {\n    await gesture(control);\n  }\n  const after = await getPageMetrics(client);\n\n  await page.evaluate(() => {\n    document.querySelector('[data-playwright-soak-control]')?.remove();\n  });\n\n  return Math.max(0, (after.nodes - before.nodes) / rounds);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqBA,eAAsB,UAAU,MAAiC;AAC/D,QAAM,SAAS,MAAM,KAAK,QAAQ,EAAE,cAAc,IAAI;AACtD,QAAM,OAAO,KAAK,oBAAoB;AACtC,SAAO;AACT;AASA,eAAsB,eAAe,QAAsC;AACzE,QAAM,OAAO,KAAK,6BAA6B;AAC/C,QAAM,OAAO,KAAK,6BAA6B;AAE/C,QAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,KAAK,wBAAwB;AA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