@recursica/adapter-tester 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sources":["../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport net from \"node:net\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nasync function waitForPort(port: number, timeoutMs = 60000): Promise<boolean> {\n const start = Date.now();\n while (Date.now() - start < timeoutMs) {\n if (await isPortActive(port)) return true;\n await new Promise((resolve) => setTimeout(resolve, 500));\n }\n return false;\n}\n\nfunction portOf(url: string): number {\n return Number(new URL(url).port);\n}\n\nfunction launchStorybook(\n name: string,\n server: HarnessWebServerConfig,\n): ChildProcess {\n console.log(\n `[Dev Launcher] Port ${server.port} is inactive. Launching Storybook for ${name}...`,\n );\n const child = spawn(server.command, {\n cwd: server.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n child.stdout?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.log(`[${name} SB] ${line.trim()}`);\n }\n });\n child.stderr?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.error(`[${name} SB ERROR] ${line.trim()}`);\n }\n });\n child.on(\"error\", (err) => {\n console.error(`[${name} SB ERROR] Failed to start process:`, err);\n });\n\n return child;\n}\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): void {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n const sourceOfTruthPort = portOf(sourceOfTruth.url);\n const targetPort = portOf(target.url);\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n app.get(\"/report-header.txt\", (req, res) => {\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: `http://localhost:${targetPort}`,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n const spawned: ChildProcess[] = [];\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, async () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n isPortActive(sourceOfTruthPort),\n isPortActive(targetPort),\n ]);\n\n if (sourceOfTruthRunning) {\n console.log(\n `[Dev Launcher] ${sourceOfTruth.name} is already running on port ${sourceOfTruthPort}.`,\n );\n } else {\n spawned.push(launchStorybook(sourceOfTruth.name, sourceOfTruthServer));\n }\n if (targetRunning) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${targetPort}.`,\n );\n } else {\n spawned.push(launchStorybook(target.name, targetServer));\n }\n\n const waits: Promise<boolean>[] = [];\n if (!sourceOfTruthRunning) waits.push(waitForPort(sourceOfTruthPort));\n if (!targetRunning) waits.push(waitForPort(targetPort));\n\n if (waits.length > 0) {\n console.log(`[Dev Launcher] Waiting for Storybooks to be responsive...`);\n const results = await Promise.all(waits);\n if (results.every(Boolean)) {\n console.log(`[Dev Launcher] All Storybooks are active and responsive!`);\n } else {\n console.warn(\n `[Dev Launcher] Warning: some Storybooks timed out during startup, but proceeding...`,\n );\n }\n } else {\n console.log(`[Dev Launcher] Both Storybooks already active.`);\n }\n\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_DIFF_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** Port the target's Storybook is served on. Auto-detected from this\n * project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag)\n * when omitted, falling back to Storybook's own default of 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n port: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n diffThresholdPixels?: number;\n storyThresholds?: Record<string, number>;\n excludeTitlePrefixes?: string[];\n excludeStoryIds?: string[];\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `runVisualRegression` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n */\nexport function resolveConfig(cwd: string): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n diffThresholdPixels:\n file.diffThresholdPixels ?? DEFAULT_DIFF_THRESHOLD_PIXELS,\n storyThresholds: file.storyThresholds,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n excludeStoryIds: file.excludeStoryIds,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters for this monorepo's\n // own non-standard config, whose `storybook.cwd` points at a sibling\n // package: its goldens must resolve to that package's own `test/golden/`\n // (the same directory used when that package runs adapter-tester\n // directly), not a directory under `packages/adapter-tester/`.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruth.port,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion: sourceOfTruth.mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: sourceOfTruth.mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd);\n\nif (process.argv.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (process.argv.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (process.argv.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. `--update-golden`/`--approve-divergence` are consumed above, not\n// forwarded — Playwright itself doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n]);\nconst passthroughArgs = process.argv\n .slice(2)\n .filter((arg) => !OWN_FLAGS.has(arg));\n\nif (process.argv.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n startDevServer(engineConfig, webServers);\n} else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n runAutomated(webServers.slice(-1), engineConfig);\n}\n\n/**\n * Generates a throwaway Playwright config + spec under `.adapter-tester/run/`\n * and runs the automated pixel-diff suite. Used by the\n * `adapter-tester:automated` npm script.\n */\nfunction runAutomated(\n servers: HarnessWebServerConfig[],\n config: AdapterTesterConfig,\n): void {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Golden checks read-modify-write the same manifest.json across every\n // story's test body — forced sequential (no worker parallelism) so those\n // writes never race each other.\n fullyParallel: false,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n workers: 1,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n webServer: ${JSON.stringify(servers, null, 2)},\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { runVisualRegression } from ${JSON.stringify(testingEntry)};\n\nawait runVisualRegression(${JSON.stringify(config, null, 2)});\n`,\n );\n\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n\n process.exit(result.status ?? 1);\n}\n"],"names":["distDir","dirname","fileURLToPath","isPortActive","port","resolve","socket","net","waitForPort","timeoutMs","start","portOf","url","launchStorybook","name","server","child","spawn","_a","data","line","_b","err","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","target","sourceOfTruthServer","targetServer","devPort","sourceOfTruthPort","targetPort","app","express","publicDir","join","headerPath","req","res","next","html","readFileSync","createProxyMiddleware","spawned","cleaningUp","cleanup","sourceOfTruthRunning","targetRunning","waits","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_DIFF_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","match","detectOwnName","loadFileConfig","resolveConfig","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","OWN_FLAGS","passthroughArgs","arg","runAutomated","servers","config","runDir","mkdirSync","writeFileSync","result","spawnSync"],"mappings":";;;;;;;;;;AAuBA,MAAMA,IAAUC,EAAQC,EAAc,YAAY,GAAG,CAAC;AAEtD,SAASC,EAAaC,GAAgC;AACpD,SAAO,IAAI,QAAQ,CAACC,MAAY;AAC9B,UAAMC,IAAS,IAAIC,EAAI,OAAA;AACvB,IAAAD,EAAO,WAAW,GAAG,GACrBA,EAAO,KAAK,WAAW,MAAM;AAC3B,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAI;AAAA,IACd,CAAC,GACDC,EAAO,KAAK,WAAW,MAAM;AAC3B,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAK;AAAA,IACf,CAAC,GACDC,EAAO,KAAK,SAAS,MAAM;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EAAA+B,EAAUD,GAAQ,EAAE,WAAW,GAAA,CAAM,GAErCE;AAAA,IACEjE,EAAK+D,GAAQ,sBAAsB;AAAA,IACnC;AAAA;AAAA;AAAA;AAAA,aAIS,KAAK,UAAUA,CAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAWpB,KAAK,UAAUF,GAAS,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA,EAAA,GAK7CI;AAAA,IACEjE,EAAK+D,GAAQ,2BAA2B;AAAA,IACxC;AAAA,sCACkC,KAAK,UAAUR,EAAY,CAAC;AAAA;AAAA,4BAEtC,KAAK,UAAUO,GAAQ,MAAM,CAAC,CAAC;AAAA;AAAA,EAAA;AAIzD,QAAMI,IAASC;AAAA,IACb;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACAnE,EAAK+D,GAAQ,sBAAsB;AAAA,MACnC,GAAGL;AAAA,IAAA;AAAA,IAEL,EAAE,OAAO,WAAW,KAAAzB,GAAK,OAAO,QAAQ,aAAa,QAAA;AAAA,EAAQ;AAG/D,UAAQ,KAAKiC,EAAO,UAAU,CAAC;AACjC;"}
1
+ {"version":3,"file":"cli.js","sources":["../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport net from \"node:net\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nasync function waitForPort(port: number, timeoutMs = 60000): Promise<boolean> {\n const start = Date.now();\n while (Date.now() - start < timeoutMs) {\n if (await isPortActive(port)) return true;\n await new Promise((resolve) => setTimeout(resolve, 500));\n }\n return false;\n}\n\nfunction portOf(url: string): number {\n return Number(new URL(url).port);\n}\n\nfunction launchStorybook(\n name: string,\n server: HarnessWebServerConfig,\n): ChildProcess {\n console.log(\n `[Dev Launcher] Port ${server.port} is inactive. Launching Storybook for ${name}...`,\n );\n const child = spawn(server.command, {\n cwd: server.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n child.stdout?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.log(`[${name} SB] ${line.trim()}`);\n }\n });\n child.stderr?.on(\"data\", (data: Buffer) => {\n for (const line of data.toString().split(\"\\n\")) {\n if (line.trim()) console.error(`[${name} SB ERROR] ${line.trim()}`);\n }\n });\n child.on(\"error\", (err) => {\n console.error(`[${name} SB ERROR] Failed to start process:`, err);\n });\n\n return child;\n}\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): void {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n const sourceOfTruthPort = portOf(sourceOfTruth.url);\n const targetPort = portOf(target.url);\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n app.get(\"/report-header.txt\", (req, res) => {\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: `http://localhost:${targetPort}`,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n const spawned: ChildProcess[] = [];\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, async () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n isPortActive(sourceOfTruthPort),\n isPortActive(targetPort),\n ]);\n\n if (sourceOfTruthRunning) {\n console.log(\n `[Dev Launcher] ${sourceOfTruth.name} is already running on port ${sourceOfTruthPort}.`,\n );\n } else {\n spawned.push(launchStorybook(sourceOfTruth.name, sourceOfTruthServer));\n }\n if (targetRunning) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${targetPort}.`,\n );\n } else {\n spawned.push(launchStorybook(target.name, targetServer));\n }\n\n const waits: Promise<boolean>[] = [];\n if (!sourceOfTruthRunning) waits.push(waitForPort(sourceOfTruthPort));\n if (!targetRunning) waits.push(waitForPort(targetPort));\n\n if (waits.length > 0) {\n console.log(`[Dev Launcher] Waiting for Storybooks to be responsive...`);\n const results = await Promise.all(waits);\n if (results.every(Boolean)) {\n console.log(`[Dev Launcher] All Storybooks are active and responsive!`);\n } else {\n console.warn(\n `[Dev Launcher] Warning: some Storybooks timed out during startup, but proceeding...`,\n );\n }\n } else {\n console.log(`[Dev Launcher] Both Storybooks already active.`);\n }\n\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/mantine-adapter\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_DIFF_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** Port the target's Storybook is served on. Auto-detected from this\n * project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag)\n * when omitted, falling back to Storybook's own default of 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/mantine-adapter` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n port: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/mui-adapter\" -> \"mui-adapter\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n diffThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /**\n * True only for the source-of-truth adapter's own config (mantine-adapter).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n diffThresholdPixels:\n file.diffThresholdPixels ?? DEFAULT_DIFF_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruth.port,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\nif (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n startDevServer(engineConfig, webServers);\n} else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n runAutomated(webServers.slice(-1), engineConfig);\n}\n\n/**\n * Generates a throwaway Playwright config + spec under `.adapter-tester/run/`\n * and runs the automated pixel-diff suite. Used by the\n * `adapter-tester:automated` npm script.\n */\nfunction runAutomated(\n servers: HarnessWebServerConfig[],\n config: AdapterTesterConfig,\n): void {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Stories run across Playwright's default worker pool — each golden check\n // only reads/writes its own story's manifest.json entry, under a lock, so\n // concurrent workers never race each other (see \\`updateManifestEntry\\`).\n // Override with \\`--workers <n>\\` (forwarded straight through to Playwright).\n fullyParallel: true,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n webServer: ${JSON.stringify(servers, null, 2)},\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n for (const story of stories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n\n process.exit(result.status ?? 1);\n}\n"],"names":["distDir","dirname","fileURLToPath","isPortActive","port","resolve","socket","net","waitForPort","timeoutMs","start","portOf","url","launchStorybook","name","server","child","spawn","_a","data","line","_b","err","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","target","sourceOfTruthServer","targetServer","devPort","sourceOfTruthPort","targetPort","app","express","publicDir","join","headerPath","req","res","next","html","readFileSync","createProxyMiddleware","spawned","cleaningUp","cleanup","sourceOfTruthRunning","targetRunning","waits","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_DIFF_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","match","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","OWN_FLAGS","passthroughArgs","arg","runAutomated","servers","config","runDir","mkdirSync","writeFileSync","result","spawnSync"],"mappings":";;;;;;;;;;AAuBA,MAAMA,IAAUC,EAAQC,EAAc,YAAY,GAAG,CAAC;AAEtD,SAASC,EAAaC,GAAgC;AACpD,SAAO,IAAI,QAAQ,CAACC,MAAY;AAC9B,UAAMC,IAAS,IAAIC,EAAI,OAAA;AACvB,IAAAD,EAAO,WAAW,GAAG,GACrBA,EAAO,KAAK,WAAW,MAAM;AAC3B,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAI;AAAA,IACd,CAAC,GACDC,EAAO,KAAK,WAAW,MAAM;AAC3B,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAK;AAAA,IACf,CAAC,GACDC,EAAO,KAAK,SAAS,MAAM;AACzB,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAK;AAAA,IACf,CAAC,GACDC,EAAO,QAAQF,GAAM,WAAW;AAAA,EAClC,CAAC;AACH;AAEA,eAAeI,EAAYJ,GAAcK,IAAY,KAAyB;AAC5E,QAAMC,IAAQ,KAAK,IAAA;AACnB,SAAO,KAAK,QAAQA,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GAAK,OAAO,QAAQ,aAAa,QAAA;AAAA,EAAQ;AAG/D,UAAQ,KAAKuC,EAAO,UAAU,CAAC;AACjC;"}
package/dist/config.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface AdapterTarget {
9
9
  */
10
10
  sourceOfTruth?: boolean;
11
11
  }
12
- /** How `runVisualRegression` reaches the source-of-truth adapter's (mantine)
12
+ /** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)
13
13
  * own golden images, for the divergence check. Never involves booting a
14
14
  * Storybook — both `readImage` targets are plain files on disk. */
15
15
  export type SourceOfTruthGoldenLocation = {
@@ -30,23 +30,32 @@ export type SourceOfTruthGoldenLocation = {
30
30
  cacheDir: string;
31
31
  };
32
32
  export type GoldenMode = "check" | "update-golden" | "approve-divergence";
33
+ /**
34
+ * Which check(s) a run performs. `"own"` (the default) is what a normal,
35
+ * fast, no-network run does: this project's own live render vs. its own
36
+ * committed golden images. `"divergence"` is the separate, opt-in check
37
+ * against the source-of-truth adapter's published golden images.
38
+ */
39
+ export type CheckMode = "own" | "divergence";
40
+ export interface StoryOverride {
41
+ /** Diff threshold override for this story. Overrides `diffThresholdPixels`
42
+ * for components with acceptable cross-library structural variation (e.g.
43
+ * native control widgets). */
44
+ threshold?: number;
45
+ /** Skip this story entirely — no own-drift check, no divergence check, no
46
+ * golden captured. For stories with no meaningful cross-adapter counterpart. */
47
+ exclude?: boolean;
48
+ }
33
49
  export interface AdapterTesterConfig {
34
50
  targets: AdapterTarget[];
35
51
  /** Global pixel-diff threshold applied to every story comparison. */
36
52
  diffThresholdPixels: number;
37
53
  /**
38
- * Per-story diff threshold overrides, keyed by story id prefix (a story
39
- * matches if its id equals the key or starts with it). Overrides
40
- * `diffThresholdPixels` for components with acceptable cross-library
41
- * structural variation (e.g. native control widgets). When more than one
42
- * key matches, the longest (most specific) key wins.
43
- */
44
- storyThresholds?: Record<string, number>;
45
- /**
46
- * Story id prefixes (same matching rule as `storyThresholds`) skipped
47
- * entirely — no own-drift check, no divergence check, no golden captured.
54
+ * Per-story overrides, keyed by story id prefix (a story matches if its id
55
+ * equals the key or starts with it). When more than one key matches, the
56
+ * longest (most specific) key wins.
48
57
  */
49
- excludeStoryIds?: string[];
58
+ stories?: Record<string, StoryOverride>;
50
59
  /**
51
60
  * Storybook entry title categories excluded from the comparison — an
52
61
  * entry is excluded if its title equals one of these or starts with
@@ -71,6 +80,8 @@ export interface AdapterTesterConfig {
71
80
  sourceOfTruthGolden?: SourceOfTruthGoldenLocation;
72
81
  /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `"check"`. */
73
82
  goldenMode: GoldenMode;
83
+ /** Set by the CLI from `--divergence-only`. Defaults to `"own"`. */
84
+ checkMode: CheckMode;
74
85
  }
75
86
  export declare function defineAdapterTesterConfig(config: AdapterTesterConfig): AdapterTesterConfig;
76
87
  export declare function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;mEAEmE;AACnE,MAAM,MAAM,2BAA2B,GACnC;IACE;+EAC2E;IAC3E,IAAI,EAAE,OAAO,CAAC;IACd,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE;;gFAE4E;IAC5E,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAE1E,MAAM,WAAW,mB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eAAe,GAAG,oBAAoB,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B;;kCAE8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;oFACgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,qEAAqE;IACrE,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;uEACmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;2CACuC;IACvC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,2FAA2F;IAC3F,UAAU,EAAE,UAAU,CAAC;IACvB,oEAAoE;IACpE,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAUrB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAM3E"}
@@ -1,4 +1,4 @@
1
- import { AdapterTesterConfig } from './config.js';
1
+ import { AdapterTesterConfig, StoryOverride } from './config.js';
2
2
  import { HarnessWebServerConfig } from './harness/mantineSourceOfTruth.js';
3
3
  export declare const CONFIG_FILE_NAME = "adapter-tester.config.json";
4
4
  interface StorybookTargetFileConfig {
@@ -36,9 +36,8 @@ export interface AdapterTesterFileConfig {
36
36
  storybook?: StorybookTargetFileConfig;
37
37
  sourceOfTruth?: SourceOfTruthFileConfig;
38
38
  diffThresholdPixels?: number;
39
- storyThresholds?: Record<string, number>;
39
+ stories?: Record<string, StoryOverride>;
40
40
  excludeTitlePrefixes?: string[];
41
- excludeStoryIds?: string[];
42
41
  /**
43
42
  * True only for the source-of-truth adapter's own config (mantine-adapter).
44
43
  * Skips `sourceOfTruth` entirely — there's nothing above it to diverge
@@ -51,17 +50,27 @@ export interface ResolvedAdapterTesterConfig {
51
50
  engineConfig: AdapterTesterConfig;
52
51
  webServers: HarnessWebServerConfig[];
53
52
  }
53
+ export interface ResolveConfigOverrides {
54
+ /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */
55
+ mantineAdapterVersion?: string;
56
+ }
54
57
  /**
55
58
  * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults
56
59
  * when the file doesn't exist) and resolves it into the engine config
57
- * `runVisualRegression` consumes plus the Playwright `webServer` entries
60
+ * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries
58
61
  * needed to boot both sides of the comparison.
59
62
  *
60
63
  * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's
61
64
  * own Storybook against a throwaway Mantine harness — no monorepo checkout
62
65
  * required. Set `sourceOfTruth.type: "url"` for the non-standard mode used
63
66
  * to compare sibling workspace packages inside this monorepo.
67
+ *
68
+ * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins
69
+ * the mantine-harness install/golden-fetch version for this run, overriding
70
+ * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with
71
+ * `isSourceOfTruthAdapter` or `sourceOfTruth.type: "url"` — neither has a
72
+ * version to pin.
64
73
  */
65
- export declare function resolveConfig(cwd: string): ResolvedAdapterTesterConfig;
74
+ export declare function resolveConfig(cwd: string, overrides?: ResolveConfigOverrides): ResolvedAdapterTesterConfig;
66
75
  export {};
67
76
  //# sourceMappingURL=fileConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileConfig.d.ts","sourceRoot":"","sources":["../src/fileConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,aAAa,CAA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C;IACxC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,mBAAmB,CAAC;IAClC,UAAU,EAAE,sBAAsB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,yFAAyF;IACzF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAmCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,sBAA2B,GACrC,2BAA2B,CA8H7B"}
@@ -1,8 +1,13 @@
1
- /**
2
- * Pixel-diffs two PNG buffers. Returns the mismatched-pixel count, or
3
- * `Infinity` if the two images aren't even the same dimensions pixelmatch
4
- * itself throws on a size mismatch, and a size mismatch is itself a real
5
- * difference, not something to swallow.
6
- */
7
- export declare function diffPngBuffers(a: Buffer, b: Buffer): number;
1
+ export interface PngDiffResult {
2
+ /** Mismatched-pixel count, or `Infinity` if the two images aren't even the
3
+ * same dimensions pixelmatch itself throws on a size mismatch, and a size
4
+ * mismatch is itself a real difference, not something to swallow. */
5
+ diffPixels: number;
6
+ /** Visual highlight of the mismatched pixels, encoded as a PNG buffer.
7
+ * `null` when `diffPixels` is `Infinity` there's no pixel-aligned diff to
8
+ * render across two different-sized images. */
9
+ diffImage: Buffer | null;
10
+ }
11
+ /** Pixel-diffs two PNG buffers. */
12
+ export declare function diffPngBuffers(a: Buffer, b: Buffer): PngDiffResult;
8
13
  //# sourceMappingURL=diffPng.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diffPng.d.ts","sourceRoot":"","sources":["../../src/golden/diffPng.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAU3D"}
1
+ {"version":3,"file":"diffPng.d.ts","sourceRoot":"","sources":["../../src/golden/diffPng.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B;;yEAEqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB;;mDAE+C;IAC/C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,mCAAmC;AACnC,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,CAgBlE"}
@@ -9,7 +9,25 @@ export declare function goldenImagePath(goldenDir: string, storyId: string): str
9
9
  * captured is the normal starting state, not an error. */
10
10
  export declare function loadManifest(goldenDir: string): GoldenManifest;
11
11
  /** Validates before writing, and sorts keys so the diff on a reviewed PR is
12
- * stable regardless of the order stories happened to run in. */
12
+ * stable regardless of the order stories happened to run in. Writes to a
13
+ * temp file and renames over the real one — `rename` is atomic, so a
14
+ * concurrent `loadManifest` (running in another Playwright worker) never
15
+ * observes a half-written file. */
13
16
  export declare function saveManifest(goldenDir: string, manifest: GoldenManifest): void;
17
+ /** Runs `updater` against this story's manifest entry under an exclusive
18
+ * lock on `manifest.json`: reloads the manifest fresh, applies `updater`,
19
+ * and saves it back, all before releasing the lock. Concurrent Playwright
20
+ * workers each own a different story, so this is the only section that
21
+ * needs to serialize — everything else about a story (its screenshot, its
22
+ * golden image file, its diff) is independent of every other story. */
23
+ export declare function updateManifestEntry(goldenDir: string, storyId: string, updater: (entry: GoldenManifestEntry | undefined) => GoldenManifestEntry | undefined): Promise<GoldenManifestEntry | undefined>;
14
24
  export declare function saveGoldenImage(goldenDir: string, storyId: string, buffer: Buffer): void;
25
+ /** Removes the golden `.png` + manifest entry for every story id in the
26
+ * manifest that isn't in `currentStoryIds` (e.g. a story renamed or deleted
27
+ * from Storybook) — otherwise those never get cleaned up on their own,
28
+ * since a run only ever adds/updates entries for stories it actually saw.
29
+ * Returns the pruned ids, for the caller to report. Both the file removal
30
+ * and the manifest delete are idempotent, so it's safe for this to run
31
+ * redundantly from more than one Playwright worker. */
32
+ export declare function pruneOrphanedGoldens(goldenDir: string, currentStoryIds: ReadonlySet<string>): Promise<string[]>;
15
33
  //# sourceMappingURL=manifestStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifestStore.d.ts","sourceRoot":"","sources":["../../src/golden/manifestStore.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEjE,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;0DAC0D;AAC1D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAM9D;AAED;gEACgE;AAChE,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,cAAc,GACvB,IAAI,CASN;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,IAAI,CAGN"}
1
+ {"version":3,"file":"manifestStore.d.ts","sourceRoot":"","sources":["../../src/golden/manifestStore.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEjE,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtD;AAMD,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;0DAC0D;AAC1D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAM9D;AAED;;;;mCAImC;AACnC,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,cAAc,GACvB,IAAI,CAWN;AAqCD;;;;;uEAKuE;AACvE,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CACP,KAAK,EAAE,mBAAmB,GAAG,SAAS,KACnC,mBAAmB,GAAG,SAAS,GACnC,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAe1C;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,IAAI,CAGN;AAED;;;;;;uDAMuD;AACvD,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `runVisualRegression` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold applied to every story comparison. */\n diffThresholdPixels: number;\n /**\n * Per-story diff threshold overrides, keyed by story id prefix (a story\n * matches if its id equals the key or starts with it). Overrides\n * `diffThresholdPixels` for components with acceptable cross-library\n * structural variation (e.g. native control widgets). When more than one\n * key matches, the longest (most specific) key wins.\n */\n storyThresholds?: Record<string, number>;\n /**\n * Story id prefixes (same matching rule as `storyThresholds`) skipped\n * entirely no own-drift check, no divergence check, no golden captured.\n */\n excludeStoryIds?: string[];\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":"uIAgFO,SAASA,EACdC,EACqB,CACrB,MAAMC,EAAqBD,EAAO,QAAQ,OACvCE,GAAWA,EAAO,aAAA,EACnB,OACF,GAAID,IAAuB,EACzB,MAAM,IAAI,MACR,8EAA8EA,CAAkB,GAAA,EAGpG,OAAOD,CACT,CAEO,SAASG,EAAiBH,EAA4C,CAC3E,MAAMI,EAAgBJ,EAAO,QAAQ,KAAME,GAAWA,EAAO,aAAa,EAC1E,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,0DAA0D,EAE5E,OAAOA,CACT"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check\n * against the source-of-truth adapter's published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story. Overrides `diffThresholdPixels`\n * for components with acceptable cross-library structural variation (e.g.\n * native control widgets). */\n threshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold applied to every story comparison. */\n diffThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":"uIA6FO,SAASA,EACdC,EACqB,CACrB,MAAMC,EAAqBD,EAAO,QAAQ,OACvCE,GAAWA,EAAO,aAAA,EACnB,OACF,GAAID,IAAuB,EACzB,MAAM,IAAI,MACR,8EAA8EA,CAAkB,GAAA,EAGpG,OAAOD,CACT,CAEO,SAASG,EAAiBH,EAA4C,CAC3E,MAAMI,EAAgBJ,EAAO,QAAQ,KAAME,GAAWA,EAAO,aAAa,EAC1E,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,0DAA0D,EAE5E,OAAOA,CACT"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `runVisualRegression` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold applied to every story comparison. */\n diffThresholdPixels: number;\n /**\n * Per-story diff threshold overrides, keyed by story id prefix (a story\n * matches if its id equals the key or starts with it). Overrides\n * `diffThresholdPixels` for components with acceptable cross-library\n * structural variation (e.g. native control widgets). When more than one\n * key matches, the longest (most specific) key wins.\n */\n storyThresholds?: Record<string, number>;\n /**\n * Story id prefixes (same matching rule as `storyThresholds`) skipped\n * entirely no own-drift check, no divergence check, no golden captured.\n */\n excludeStoryIds?: string[];\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":";AAgFO,SAASA,EACdC,GACqB;AACrB,QAAMC,IAAqBD,EAAO,QAAQ;AAAA,IACxC,CAACE,MAAWA,EAAO;AAAA,EAAA,EACnB;AACF,MAAID,MAAuB;AACzB,UAAM,IAAI;AAAA,MACR,8EAA8EA,CAAkB;AAAA,IAAA;AAGpG,SAAOD;AACT;AAEO,SAASG,EAAiBH,GAA4C;AAC3E,QAAMI,IAAgBJ,EAAO,QAAQ,KAAK,CAACE,MAAWA,EAAO,aAAa;AAC1E,MAAI,CAACE;AACH,UAAM,IAAI,MAAM,0DAA0D;AAE5E,SAAOA;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check\n * against the source-of-truth adapter's published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story. Overrides `diffThresholdPixels`\n * for components with acceptable cross-library structural variation (e.g.\n * native control widgets). */\n threshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold applied to every story comparison. */\n diffThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":";AA6FO,SAASA,EACdC,GACqB;AACrB,QAAMC,IAAqBD,EAAO,QAAQ;AAAA,IACxC,CAACE,MAAWA,EAAO;AAAA,EAAA,EACnB;AACF,MAAID,MAAuB;AACzB,UAAM,IAAI;AAAA,MACR,8EAA8EA,CAAkB;AAAA,IAAA;AAGpG,SAAOD;AACT;AAEO,SAASG,EAAiBH,GAA4C;AAC3E,QAAMI,IAAgBJ,EAAO,QAAQ,KAAK,CAACE,MAAWA,EAAO,aAAa;AAC1E,MAAI,CAACE;AACH,UAAM,IAAI,MAAM,0DAA0D;AAE5E,SAAOA;AACT;"}
@@ -1,27 +1,52 @@
1
+ import { Browser, TestInfo } from '@playwright/test';
1
2
  import { AdapterTesterConfig } from '../config.js';
3
+ interface StorybookEntry {
4
+ type: string;
5
+ id: string;
6
+ name: string;
7
+ title: string;
8
+ }
9
+ /** Everything a generated Playwright spec needs to register the golden-image
10
+ * suite itself. Split out from the actual `test.describe`/`test` calls so
11
+ * those calls execute in the spec file that imports this, not in this
12
+ * library file — otherwise Playwright's HTML report groups every story under
13
+ * this file's own (sourcemapped) path instead of a stable spec name. */
14
+ export interface VisualRegressionPlan {
15
+ /** `config`'s own (non-source-of-truth) target name, for the suite title. */
16
+ ownTargetName: string;
17
+ /** Suite title suffix describing which check mode is running. */
18
+ suiteLabel: string;
19
+ /** Stories to check, already filtered and sorted by id. */
20
+ stories: StorybookEntry[];
21
+ /** Golden-checks one story. Call this from inside a `test(story.id, ...)`
22
+ * body — safe to run concurrently across Playwright workers, since each
23
+ * call only ever reads/writes its own story's manifest entry (locked at
24
+ * the point it writes it back, so concurrent workers never race each
25
+ * other's entries — see `updateManifestEntry`). */
26
+ checkStory: (story: StorybookEntry, browser: Browser, testInfo: TestInfo) => Promise<void>;
27
+ }
2
28
  /**
3
- * Defines a Playwright suite that golden-image-tests every story in
4
- * `config`'s own target (the one target in `config.targets` not marked
5
- * `sourceOfTruth`). Call this with a top-level `await` from a Playwright
6
- * `*.spec.ts` file — it calls `test.describe` at module scope, so it must
7
- * run inside Playwright's test runner during test-graph compilation.
29
+ * Resolves the golden-image plan for `config`'s own target (the one target
30
+ * in `config.targets` not marked `sourceOfTruth`).
8
31
  *
9
- * Two independent checks per story, neither of which boots the
10
- * source-of-truth adapter's own Storybook — the divergence check below
11
- * compares stored golden files, not live pages:
32
+ * Two independent checks per story, gated by `config.checkMode`, neither of
33
+ * which boots the source-of-truth adapter's own Storybook — the divergence
34
+ * check below compares stored golden files, not live pages:
12
35
  *
13
- * 1. **Own-drift (hard fail):** this run's live render vs this project's own
14
- * stored `test/golden/<story-id>.png`. No golden yet for a story is not a
15
- * failure — one is captured from this run instead (same as
16
- * `--update-golden`, scoped to just that story).
17
- * 2. **Source-of-truth divergence (soft flag, never fails the run):** this
18
- * project's own golden vs the source-of-truth's golden (`config`'s
19
- * `sourceOfTruthGolden`). Skipped entirely when
20
- * `config.isSourceOfTruthAdapter` is true — the source-of-truth adapter
21
- * has nothing above it to diverge from and skipped per-story when
22
- * neither side has a baseline yet. A once-flagged divergence stays quiet
23
- * after `--approve-divergence`, until the source of truth's own golden
24
- * changes again.
36
+ * 1. **Own-drift (`checkMode: "own"`, the default; hard fail):** this run's
37
+ * live render vs this project's own stored `test/golden/<story-id>.png`.
38
+ * No golden yet for a story is not a failure — one is captured from this
39
+ * run instead (same as `--update-golden`, scoped to just that story), in
40
+ * either mode.
41
+ * 2. **Source-of-truth divergence (`checkMode: "divergence"`; soft flag,
42
+ * never fails the run):** this project's own golden vs the
43
+ * source-of-truth's golden (`config`'s `sourceOfTruthGolden`). Skipped
44
+ * entirely when `config.isSourceOfTruthAdapter` is truethe
45
+ * source-of-truth adapter has nothing above it to diverge from and
46
+ * skipped per-story when neither side has a baseline yet. A
47
+ * once-flagged divergence stays quiet after `--approve-divergence`,
48
+ * until the source of truth's own golden changes again.
25
49
  */
26
- export declare function runVisualRegression(config: AdapterTesterConfig): Promise<void>;
50
+ export declare function resolveVisualRegressionPlan(config: AdapterTesterConfig): Promise<VisualRegressionPlan>;
51
+ export {};
27
52
  //# sourceMappingURL=runVisualRegression.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runVisualRegression.d.ts","sourceRoot":"","sources":["../../src/testing/runVisualRegression.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAmFxD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA0Hf"}
1
+ {"version":3,"file":"runVisualRegression.d.ts","sourceRoot":"","sources":["../../src/testing/runVisualRegression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAcxD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAkED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA6L/B"}
package/dist/testing.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@playwright/test"),a=require("node:fs"),D=require("pixelmatch"),k=require("pngjs"),T=require("node:path"),G=require("./index-C6uYPRmx.cjs");function A(e,t){const r=k.PNG.sync.read(e),s=k.PNG.sync.read(t);if(r.width!==s.width||r.height!==s.height)return 1/0;const n=new k.PNG({width:r.width,height:r.height});return D(r.data,s.data,n.data,r.width,r.height,{threshold:.1})}const B="http://json-schema.org/draft-07/schema#",M="https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/golden/manifest.schema.json",q="test/golden/manifest.json",_="Tracks golden (baseline) image metadata for @recursica/adapter-tester's golden-image visual regression checks. One manifest lives alongside its adapter's test/golden/<story-id>.png files, keyed by story id.",L="object",R={type:"object",additionalProperties:!1,required:["createdAt"],properties:{createdAt:{type:"string",format:"date-time",description:"When this story's own golden PNG was last captured, via --update-golden, --approve-divergence, or first-run auto-create."},sourceOfTruthCreatedAt:{type:"string",format:"date-time",description:"The source-of-truth adapter's (mantine) manifest `createdAt` for this story at the time this adapter's divergence from it was last reviewed via --approve-divergence. Omitted on the source-of-truth adapter's own manifest, and omitted here until the first approval. If mantine's current `createdAt` for this story is newer than this value, the divergence is flagged again for re-review."}}},V={$schema:B,$id:M,title:q,description:_,type:L,additionalProperties:R},U=G.index,I=new G.ajvExports.Ajv({allErrors:!0,strict:!0});U(I);const E=I.compile(V);function b(e,t){if(E(e))return;const r=(E.errors??[]).map(s=>{var d;const n=(d=s.params)!=null&&d.additionalProperty?` '${s.params.additionalProperty}'`:"";return` - ${s.instancePath||"root"} ${s.message}${n}`}).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("@playwright/test"),s=require("node:fs"),R=require("pixelmatch"),x=require("pngjs"),O=require("node:path"),G=require("./index-C6uYPRmx.cjs");function I(e,t){const n=x.PNG.sync.read(e),r=x.PNG.sync.read(t);if(n.width!==r.width||n.height!==r.height)return{diffPixels:1/0,diffImage:null};const i=new x.PNG({width:n.width,height:n.height});return{diffPixels:R(n.data,r.data,i.data,n.width,n.height,{threshold:.1}),diffImage:x.PNG.sync.write(i)}}const U="http://json-schema.org/draft-07/schema#",K="https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/golden/manifest.schema.json",V="test/golden/manifest.json",J="Tracks golden (baseline) image metadata for @recursica/adapter-tester's golden-image visual regression checks. One manifest lives alongside its adapter's test/golden/<story-id>.png files, keyed by story id.",W="object",X={type:"object",additionalProperties:!1,required:["createdAt"],properties:{createdAt:{type:"string",format:"date-time",description:"When this story's own golden PNG was last captured, via --update-golden, --approve-divergence, or first-run auto-create."},sourceOfTruthCreatedAt:{type:"string",format:"date-time",description:"The source-of-truth adapter's (mantine) manifest `createdAt` for this story at the time this adapter's divergence from it was last reviewed via --approve-divergence. Omitted on the source-of-truth adapter's own manifest, and omitted here until the first approval. If mantine's current `createdAt` for this story is newer than this value, the divergence is flagged again for re-review."}}},H={$schema:U,$id:K,title:V,description:J,type:W,additionalProperties:X},z=G.index,N=new G.ajvExports.Ajv({allErrors:!0,strict:!0});z(N);const F=N.compile(H);function E(e,t){if(F(e))return;const n=(F.errors??[]).map(r=>{var c;const i=(c=r.params)!=null&&c.additionalProperty?` '${r.params.additionalProperty}'`:"";return` - ${r.instancePath||"root"} ${r.message}${i}`}).join(`
2
2
  `);throw new Error(`Invalid ${t}:
3
- ${r}`)}function m(e){return T.join(e,"manifest.json")}function w(e,t){return T.join(e,`${t}.png`)}function x(e){const t=m(e);if(!a.existsSync(t))return{};const r=JSON.parse(a.readFileSync(t,"utf8"));return b(r,t),r}function J(e,t){const r=m(e);b(t,r);const s={};for(const n of Object.keys(t).sort())s[n]=t[n];a.mkdirSync(e,{recursive:!0}),a.writeFileSync(r,JSON.stringify(s,null,2)+`
4
- `)}function W(e,t,r){a.mkdirSync(e,{recursive:!0}),a.writeFileSync(w(e,t),r)}const H="borderux/recursica";async function K(e,t){var d,h;const r=await fetch(`https://registry.npmjs.org/${e}`);if(!r.ok)throw new Error(`Could not reach npm registry for ${e}: ${r.statusText}`);const s=await r.json(),n=((d=s["dist-tags"])==null?void 0:d[t])??((h=s.versions)!=null&&h[t]?t:void 0);if(!n)throw new Error(`${e} has no version or dist-tag "${t}" on the npm registry.`);return n}function X(e){return`packages/${e.split("/").pop()}`}async function z(e){if(e.type==="local")return a.existsSync(m(e.dir))?{manifest:x(e.dir),async readImage(i){const u=w(e.dir,i);return a.existsSync(u)?a.readFileSync(u):null}}:(console.warn(`No golden baseline found yet at ${e.dir} — source-of-truth divergence check skipped for this run.`),null);let t;try{t=await K(e.packageName,e.versionSpec)}catch(c){return console.warn(`Could not resolve ${e.packageName}@${e.versionSpec} — source-of-truth divergence check skipped for this run.`,c),null}const r=T.join(e.cacheDir,t),s=`${e.packageName}@${t}`,n=`https://raw.githubusercontent.com/${H}/${s}/${X(e.packageName)}/test/golden`;let d;const h=m(r);if(a.existsSync(h))d=x(r);else{let c;try{c=await fetch(`${n}/manifest.json`)}catch(o){return console.warn(`Could not reach GitHub to fetch ${s}'s golden baseline — source-of-truth divergence check skipped for this run.`,o),null}if(!c.ok)return console.warn(`No golden baseline published for ${s} — source-of-truth divergence check skipped for this run.`),null;const i=await c.text(),u=JSON.parse(i);b(u,`${n}/manifest.json`),a.mkdirSync(r,{recursive:!0}),a.writeFileSync(h,i),d=u}return{manifest:d,async readImage(c){const i=w(r,c);if(a.existsSync(i))return a.readFileSync(i);const u=await fetch(`${n}/${c}.png`);if(!u.ok)return null;const o=Buffer.from(await u.arrayBuffer());return a.mkdirSync(r,{recursive:!0}),a.writeFileSync(i,o),o}}}const Q=["Theme","Tokens","Introduction"];function F(e,t){return e===t||e.startsWith(t)}async function Y(e,t,r){let s;try{const n=await fetch(`${e.url}/index.json`);if(!n.ok)throw new Error(`Failed to fetch Storybook index: ${n.statusText}`);const h=(await n.json()).entries||{};s=Object.values(h).filter(c=>c.type==="story"&&!t.some(i=>c.title===i||c.title.startsWith(`${i}/`))&&!r.some(i=>F(c.id,i))),s.sort((c,i)=>c.id.localeCompare(i.id))}catch(n){throw console.error("Failed to load Storybook index from",`${e.url}/index.json`,n),new Error(`Storybook target "${e.name}" is not responsive or index.json is missing. Please ensure its Storybook is running.`)}return s}function Z(e,t,r){let s;for(const n of Object.keys(t))F(e,n)&&(!s||n.length>s.length)&&(s=n);return s!==void 0?t[s]:r}async function ee(e){const t=e.isSourceOfTruthAdapter?e.targets[0]:e.targets.find(o=>!o.sourceOfTruth);if(!t)throw new Error("adapter-tester config has no non-sourceOfTruth target to run the golden check against.");const r=e.excludeTitlePrefixes??Q,s=e.excludeStoryIds??[],n=e.storyThresholds??{},d=e.goldenDir,h=e.goldenMode,c=await Y(t,r,s),i=x(d),u=e.isSourceOfTruthAdapter||!e.sourceOfTruthGolden?null:await z(e.sourceOfTruthGolden);S.test.describe(`${t.name} Golden Image Visual Regression`,()=>{for(const o of c)S.test(`Golden regression for: ${o.title} - ${o.name} (${o.id})`,async({browser:N},y)=>{const p=await N.newPage();await p.setViewportSize({width:800,height:600}),await p.goto(`${t.url}/iframe.html?id=${o.id}&viewMode=story`,{waitUntil:"networkidle"}),await p.waitForSelector("#storybook-root"),await p.waitForTimeout(300);const O=await p.screenshot(),v=w(d,o.id),l=i[o.id];if(h!=="check"||!l||!a.existsSync(v))W(d,o.id,O),i[o.id]=l!=null&&l.sourceOfTruthCreatedAt?{createdAt:new Date().toISOString(),sourceOfTruthCreatedAt:l.sourceOfTruthCreatedAt}:{createdAt:new Date().toISOString()},l||y.annotations.push({type:"golden-created",description:`No golden existed yet for "${o.id}" — captured one from this run.`});else{const f=a.readFileSync(v),g=A(O,f);await y.attach("Live vs Golden Diff",{body:`${g} mismatched pixels`,contentType:"text/plain"});const $=Z(o.id,n,e.diffThresholdPixels);S.expect.soft(g,`"${o.id}" has drifted from its own golden image`).toBeLessThan($)}const j=i[o.id];if(u){const f=u.manifest[o.id],g=f?await u.readImage(o.id):null;if(f&&g)if(h==="approve-divergence")i[o.id]={...j,sourceOfTruthCreatedAt:f.createdAt};else{const $=a.readFileSync(v),C=A($,g),P=j.sourceOfTruthCreatedAt;C===0||P!==void 0&&P>=f.createdAt||y.annotations.push({type:"source-of-truth-divergence",description:`"${o.id}" differs from the source of truth's golden and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`})}}J(d,i)})})}exports.runVisualRegression=ee;
3
+ ${n}`)}function b(e){return O.join(e,"manifest.json")}function C(e){return O.join(e,"manifest.json.lock")}function T(e,t){return O.join(e,`${t}.png`)}function $(e){const t=b(e);if(!s.existsSync(t))return{};const n=JSON.parse(s.readFileSync(t,"utf8"));return E(n,t),n}function Y(e,t){const n=b(e);E(t,n);const r={};for(const c of Object.keys(t).sort())r[c]=t[c];s.mkdirSync(e,{recursive:!0});const i=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;s.writeFileSync(i,JSON.stringify(r,null,2)+`
4
+ `),s.renameSync(i,n)}const Q=25,Z=15e3;function ee(e){return new Promise(t=>setTimeout(t,e))}async function te(e){s.mkdirSync(e,{recursive:!0});const t=C(e),n=Date.now()+Z;for(;;)try{s.closeSync(s.openSync(t,"wx"));return}catch(r){if(r.code!=="EEXIST")throw r;if(Date.now()>=n)throw new Error(`Timed out waiting for the manifest lock at "${t}" — delete it if a previous run crashed while holding it.`);await ee(Q)}}function re(e){s.rmSync(C(e),{force:!0})}async function L(e,t,n){await te(e);try{const r=$(e),i=n(r[t]);return i===void 0?delete r[t]:r[t]=i,Y(e,r),i}finally{re(e)}}function ne(e,t,n){s.mkdirSync(e,{recursive:!0}),s.writeFileSync(T(e,t),n)}async function ie(e,t){const n=$(e),r=Object.keys(n).filter(i=>!t.has(i));for(const i of r){const c=T(e,i);s.existsSync(c)&&s.unlinkSync(c),await L(e,i,()=>{})}return r}const se="borderux/recursica";async function oe(e,t){var c,u;const n=await fetch(`https://registry.npmjs.org/${e}`);if(!n.ok)throw new Error(`Could not reach npm registry for ${e}: ${n.statusText}`);const r=await n.json(),i=((c=r["dist-tags"])==null?void 0:c[t])??((u=r.versions)!=null&&u[t]?t:void 0);if(!i)throw new Error(`${e} has no version or dist-tag "${t}" on the npm registry.`);return i}function ae(e){return`packages/${e.split("/").pop()}`}async function ce(e){if(e.type==="local")return s.existsSync(b(e.dir))?{manifest:$(e.dir),async readImage(d){const f=T(e.dir,d);return s.existsSync(f)?s.readFileSync(f):null}}:(console.warn(`No golden baseline found yet at ${e.dir} — source-of-truth divergence check skipped for this run.`),null);let t;try{t=await oe(e.packageName,e.versionSpec)}catch(a){return console.warn(`Could not resolve ${e.packageName}@${e.versionSpec} — source-of-truth divergence check skipped for this run.`,a),null}const n=O.join(e.cacheDir,t),r=`${e.packageName}@${t}`,i=`https://raw.githubusercontent.com/${se}/${r}/${ae(e.packageName)}/test/golden`;let c;const u=b(n);if(s.existsSync(u))c=$(n);else{let a;try{a=await fetch(`${i}/manifest.json`)}catch(h){return console.warn(`Could not reach GitHub to fetch ${r}'s golden baseline — source-of-truth divergence check skipped for this run.`,h),null}if(!a.ok)return console.warn(`No golden baseline published for ${r} — source-of-truth divergence check skipped for this run.`),null;const d=await a.text(),f=JSON.parse(d);E(f,`${i}/manifest.json`),s.mkdirSync(n,{recursive:!0}),s.writeFileSync(u,d),c=f}return{manifest:c,async readImage(a){const d=T(n,a);if(s.existsSync(d))return s.readFileSync(d);const f=await fetch(`${i}/${a}.png`);if(!f.ok)return null;const h=Buffer.from(await f.arrayBuffer());return s.mkdirSync(n,{recursive:!0}),s.writeFileSync(d,h),h}}}const de=["Theme","Tokens","Introduction"];function _(e,t){return e===t||e.startsWith(t)}async function ue(e,t,n){let r;try{const i=await fetch(`${e.url}/index.json`);if(!i.ok)throw new Error(`Failed to fetch Storybook index: ${i.statusText}`);const u=(await i.json()).entries||{};r=Object.values(u).filter(a=>a.type==="story"&&!t.some(d=>a.title===d||a.title.startsWith(`${d}/`))&&!n.some(d=>_(a.id,d))),r.sort((a,d)=>a.id.localeCompare(d.id))}catch(i){throw console.error("Failed to load Storybook index from",`${e.url}/index.json`,i),new Error(`Storybook target "${e.name}" is not responsive or index.json is missing. Please ensure its Storybook is running.`)}return r}function fe(e,t,n){let r;for(const i of Object.keys(t))_(e,i)&&(!r||i.length>r.length)&&(r=i);return r!==void 0?t[r]:n}async function he(e){const t=e.isSourceOfTruthAdapter?e.targets[0]:e.targets.find(o=>!o.sourceOfTruth);if(!t)throw new Error("adapter-tester config has no non-sourceOfTruth target to run the golden check against.");const n=e.excludeTitlePrefixes??de,r=e.stories??{},i=Object.keys(r).filter(o=>r[o].exclude),c=Object.fromEntries(Object.entries(r).filter(([,o])=>o.threshold!==void 0).map(([o,y])=>[o,y.threshold])),u=e.goldenDir,a=e.goldenMode,d=e.checkMode,f=await ue(t,n,i);if(a==="update-golden"){const o=await ie(u,new Set(f.map(y=>y.id)));o.length>0&&console.warn(`Pruned ${o.length} orphaned golden(s) no longer in Storybook: ${o.join(", ")}`)}const h=d!=="divergence"||e.isSourceOfTruthAdapter||!e.sourceOfTruthGolden?null:await ce(e.sourceOfTruthGolden),B=d==="divergence"?"Source-of-Truth Divergence Check":"Own-Drift Golden Image Check";return{ownTargetName:t.name,suiteLabel:B,stories:f,checkStory:async(o,y,l)=>{const v=await y.newPage();await v.setViewportSize({width:800,height:600}),await v.goto(`${t.url}/iframe.html?id=${o.id}&viewMode=story`,{waitUntil:"networkidle"}),await v.waitForSelector("#storybook-root"),await v.waitForTimeout(300);const P=await v.screenshot(),j=T(u,o.id),p=$(u)[o.id],q=a!=="check"||!p||!s.existsSync(j);let w;if(q)ne(u,o.id,P),w=p!=null&&p.sourceOfTruthCreatedAt?{createdAt:new Date().toISOString(),sourceOfTruthCreatedAt:p.sourceOfTruthCreatedAt}:{createdAt:new Date().toISOString()},p||l.annotations.push({type:"golden-created",description:`No golden existed yet for "${o.id}" — captured one from this run.`});else if(w=p,d==="own"){const g=s.readFileSync(j),{diffPixels:m,diffImage:S}=I(P,g),k=fe(o.id,c,e.diffThresholdPixels);m>=k&&(await l.attach("expected",{body:g,contentType:"image/png"}),await l.attach("actual",{body:P,contentType:"image/png"}),S&&await l.attach("diff",{body:S,contentType:"image/png"})),D.expect.soft(m,`"${o.id}" has drifted from its own golden image (${m} mismatched pixels, threshold ${k})`).toBeLessThan(k)}if(h){const g=h.manifest[o.id],m=g?await h.readImage(o.id):null;if(g&&m)if(a==="approve-divergence")w={...w,sourceOfTruthCreatedAt:g.createdAt};else{const S=s.readFileSync(j),{diffPixels:k,diffImage:A}=I(S,m),M=w.sourceOfTruthCreatedAt;k===0||M!==void 0&&M>=g.createdAt||(await l.attach("expected",{body:m,contentType:"image/png"}),await l.attach("actual",{body:S,contentType:"image/png"}),A&&await l.attach("diff",{body:A,contentType:"image/png"}),l.annotations.push({type:"source-of-truth-divergence",description:`"${o.id}" differs from the source of truth's golden and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`}))}}await L(u,o.id,()=>w)}}}exports.resolveVisualRegressionPlan=he;
5
5
  //# sourceMappingURL=testing.cjs.map