@storywright/cli 0.5.7 → 0.5.9

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.
@@ -35,22 +35,35 @@ var StorywrightReporter = class {
35
35
  const failed = allResults.filter((r) => r.status === "failed").length;
36
36
  const skipped = allResults.filter((r) => r.status === "skipped").length;
37
37
  const browsers = [...new Set(allResults.map((r) => r.project))];
38
- const failures = [];
38
+ const entries = [];
39
39
  const assetsDir = path.join(this.outputDir, "assets");
40
40
  for (const dir of ["expected", "actual", "diff"]) {
41
41
  fs.mkdirSync(path.join(assetsDir, dir), { recursive: true });
42
42
  }
43
43
  for (const testResult of allResults) {
44
- if (testResult.status !== "failed") continue;
44
+ if (testResult.status === "skipped") continue;
45
45
  const titleParts = testResult.title.split(": ");
46
46
  const storyTitle = titleParts[0] ?? testResult.title;
47
47
  const variant = titleParts.slice(1).join(": ") || "default";
48
+ if (testResult.status === "passed") {
49
+ entries.push({
50
+ type: "pass",
51
+ story: storyTitle,
52
+ variant,
53
+ browser: testResult.project,
54
+ diffRatio: 0,
55
+ expected: "",
56
+ actual: "",
57
+ diff: ""
58
+ });
59
+ continue;
60
+ }
48
61
  const sanitizedName = testResult.title.replace(/[^a-zA-Z0-9-_]/g, "-").toLowerCase();
49
62
  const imageAttachments = testResult.attachments.filter(
50
63
  (a) => a.path && a.contentType.startsWith("image/")
51
64
  );
52
65
  const hasDiff = imageAttachments.some((a) => a.name.includes("diff"));
53
- const failure = {
66
+ const entry = {
54
67
  type: hasDiff ? "diff" : "new",
55
68
  story: storyTitle,
56
69
  variant,
@@ -67,18 +80,18 @@ var StorywrightReporter = class {
67
80
  if (attachment.name.includes("expected")) {
68
81
  const dest = path.join(assetsDir, "expected", destName);
69
82
  copyFileIfExists(attachment.path, dest);
70
- failure.expected = `assets/expected/${destName}`;
83
+ entry.expected = `assets/expected/${destName}`;
71
84
  } else if (attachment.name.includes("actual")) {
72
85
  const dest = path.join(assetsDir, "actual", destName);
73
86
  copyFileIfExists(attachment.path, dest);
74
- failure.actual = `assets/actual/${destName}`;
87
+ entry.actual = `assets/actual/${destName}`;
75
88
  } else if (attachment.name.includes("diff")) {
76
89
  const dest = path.join(assetsDir, "diff", destName);
77
90
  copyFileIfExists(attachment.path, dest);
78
- failure.diff = `assets/diff/${destName}`;
91
+ entry.diff = `assets/diff/${destName}`;
79
92
  }
80
93
  }
81
- failures.push(failure);
94
+ entries.push(entry);
82
95
  }
83
96
  const summary = {
84
97
  total: allResults.length,
@@ -88,7 +101,7 @@ var StorywrightReporter = class {
88
101
  duration,
89
102
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
90
103
  browsers,
91
- failures
104
+ entries
92
105
  };
93
106
  fs.mkdirSync(this.outputDir, { recursive: true });
94
107
  fs.writeFileSync(path.join(this.outputDir, "summary.json"), JSON.stringify(summary, null, 2));
@@ -136,4 +149,4 @@ export {
136
149
  generateHtmlReport,
137
150
  reporter_default
138
151
  };
139
- //# sourceMappingURL=chunk-HPK2VJXG.js.map
152
+ //# sourceMappingURL=chunk-JDHVDQIC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/playwright/reporter.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport type {\n\tFullConfig,\n\tFullResult,\n\tTestResult as PwTestResult,\n\tReporter,\n\tSuite,\n\tTestCase,\n} from '@playwright/test/reporter';\nimport type { TestEntry, TestSummary } from '../core/types.js';\n\ninterface StorywrightReporterOptions {\n\toutputDir?: string;\n}\n\nclass StorywrightReporter implements Reporter {\n\tprivate outputDir: string;\n\tprivate results = new Map<\n\t\tstring,\n\t\t{\n\t\t\ttitle: string;\n\t\t\tproject: string;\n\t\t\tstatus: 'passed' | 'failed' | 'skipped';\n\t\t\tduration: number;\n\t\t\tattachments: { name: string; path?: string; contentType: string }[];\n\t\t}\n\t>();\n\tprivate startTime = 0;\n\n\tconstructor(options: StorywrightReporterOptions = {}) {\n\t\tthis.outputDir = options.outputDir || path.resolve('.storywright', 'report');\n\t}\n\n\tonBegin(_config: FullConfig, _suite: Suite): void {\n\t\tthis.startTime = Date.now();\n\t}\n\n\tonTestEnd(test: TestCase, result: PwTestResult): void {\n\t\tconst project = test.parent?.project()?.name ?? 'unknown';\n\t\tconst key = `${test.title}::${project}`;\n\t\tconst status =\n\t\t\tresult.status === 'passed' ? 'passed' : result.status === 'skipped' ? 'skipped' : 'failed';\n\n\t\t// Overwrite previous attempts so only the final retry result is kept\n\t\tthis.results.set(key, {\n\t\t\ttitle: test.title,\n\t\t\tproject,\n\t\t\tstatus,\n\t\t\tduration: result.duration,\n\t\t\tattachments: result.attachments.map((a) => ({\n\t\t\t\tname: a.name,\n\t\t\t\tpath: a.path,\n\t\t\t\tcontentType: a.contentType,\n\t\t\t})),\n\t\t});\n\t}\n\n\tasync onEnd(_result: FullResult): Promise<void> {\n\t\tconst duration = Date.now() - this.startTime;\n\t\tconst allResults = [...this.results.values()];\n\t\tconst passed = allResults.filter((r) => r.status === 'passed').length;\n\t\tconst failed = allResults.filter((r) => r.status === 'failed').length;\n\t\tconst skipped = allResults.filter((r) => r.status === 'skipped').length;\n\n\t\tconst browsers = [...new Set(allResults.map((r) => r.project))];\n\t\tconst entries: TestEntry[] = [];\n\n\t\t// Collect failure images\n\t\tconst assetsDir = path.join(this.outputDir, 'assets');\n\t\tfor (const dir of ['expected', 'actual', 'diff']) {\n\t\t\tfs.mkdirSync(path.join(assetsDir, dir), { recursive: true });\n\t\t}\n\n\t\tfor (const testResult of allResults) {\n\t\t\tif (testResult.status === 'skipped') continue;\n\n\t\t\tconst titleParts = testResult.title.split(': ');\n\t\t\tconst storyTitle = titleParts[0] ?? testResult.title;\n\t\t\tconst variant = titleParts.slice(1).join(': ') || 'default';\n\n\t\t\tif (testResult.status === 'passed') {\n\t\t\t\tentries.push({\n\t\t\t\t\ttype: 'pass',\n\t\t\t\t\tstory: storyTitle,\n\t\t\t\t\tvariant,\n\t\t\t\t\tbrowser: testResult.project,\n\t\t\t\t\tdiffRatio: 0,\n\t\t\t\t\texpected: '',\n\t\t\t\t\tactual: '',\n\t\t\t\t\tdiff: '',\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst sanitizedName = testResult.title.replace(/[^a-zA-Z0-9-_]/g, '-').toLowerCase();\n\n\t\t\tconst imageAttachments = testResult.attachments.filter(\n\t\t\t\t(a) => a.path && a.contentType.startsWith('image/'),\n\t\t\t);\n\t\t\tconst hasDiff = imageAttachments.some((a) => a.name.includes('diff'));\n\n\t\t\tconst entry: TestEntry = {\n\t\t\t\ttype: hasDiff ? 'diff' : 'new',\n\t\t\t\tstory: storyTitle,\n\t\t\t\tvariant,\n\t\t\t\tbrowser: testResult.project,\n\t\t\t\tdiffRatio: 0,\n\t\t\t\texpected: '',\n\t\t\t\tactual: '',\n\t\t\t\tdiff: '',\n\t\t\t};\n\n\t\t\tfor (const attachment of testResult.attachments) {\n\t\t\t\tif (!attachment.path) continue;\n\t\t\t\tconst ext = path.extname(attachment.path);\n\t\t\t\tconst destName = `${sanitizedName}-${testResult.project}${ext}`;\n\n\t\t\t\tif (attachment.name.includes('expected')) {\n\t\t\t\t\tconst dest = path.join(assetsDir, 'expected', destName);\n\t\t\t\t\tcopyFileIfExists(attachment.path, dest);\n\t\t\t\t\tentry.expected = `assets/expected/${destName}`;\n\t\t\t\t} else if (attachment.name.includes('actual')) {\n\t\t\t\t\tconst dest = path.join(assetsDir, 'actual', destName);\n\t\t\t\t\tcopyFileIfExists(attachment.path, dest);\n\t\t\t\t\tentry.actual = `assets/actual/${destName}`;\n\t\t\t\t} else if (attachment.name.includes('diff')) {\n\t\t\t\t\tconst dest = path.join(assetsDir, 'diff', destName);\n\t\t\t\t\tcopyFileIfExists(attachment.path, dest);\n\t\t\t\t\tentry.diff = `assets/diff/${destName}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tentries.push(entry);\n\t\t}\n\n\t\tconst summary: TestSummary = {\n\t\t\ttotal: allResults.length,\n\t\t\tpassed,\n\t\t\tfailed,\n\t\t\tskipped,\n\t\t\tduration,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tbrowsers,\n\t\t\tentries,\n\t\t};\n\n\t\tfs.mkdirSync(this.outputDir, { recursive: true });\n\t\tfs.writeFileSync(path.join(this.outputDir, 'summary.json'), JSON.stringify(summary, null, 2));\n\n\t\t// Generate HTML report\n\t\tconst html = generateHtmlReport(summary);\n\t\tfs.writeFileSync(path.join(this.outputDir, 'index.html'), html);\n\t}\n}\n\nfunction copyFileIfExists(src: string, dest: string): void {\n\ttry {\n\t\tfs.copyFileSync(src, dest);\n\t} catch {\n\t\t// source may not exist\n\t}\n}\n\nexport function generateHtmlReport(summary: TestSummary): string {\n\tconst require = createRequire(import.meta.url);\n\tconst bundlePath = require.resolve('@storywright/report');\n\tconst bundleJs = fs.readFileSync(bundlePath, 'utf-8');\n\n\t// Load CSS if it exists as a separate file\n\tconst bundleDir = path.dirname(bundlePath);\n\tconst assetsDir = path.join(bundleDir, 'assets');\n\tlet cssContent = '';\n\tif (fs.existsSync(assetsDir)) {\n\t\tconst cssFiles = fs.readdirSync(assetsDir).filter((f) => f.endsWith('.css'));\n\t\tfor (const cssFile of cssFiles) {\n\t\t\tcssContent += fs.readFileSync(path.join(assetsDir, cssFile), 'utf-8');\n\t\t}\n\t}\n\n\treturn `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Storywright Report</title>\n${cssContent ? `<style>${cssContent}</style>` : ''}\n</head>\n<body>\n<div id=\"app\"></div>\n<script>window.__STORYWRIGHT_SUMMARY__ = ${JSON.stringify(summary).replace(/</g, '\\\\u003c')};</script>\n<script>${bundleJs}</script>\n</body>\n</html>`;\n}\n\nexport default StorywrightReporter;\n"],"mappings":";AAAA,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAej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AK,WAAW,QAAQ;AAC/C,MAAI,aAAa;AACjB,MAAI,GAAG,WAAW,SAAS,GAAG;AAC7B,UAAM,WAAW,GAAG,YAAY,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,CAAC;AAC3E,eAAW,WAAW,UAAU;AAC/B,oBAAc,GAAG,aAAa,KAAK,KAAK,WAAW,OAAO,GAAG,OAAO;AAAA,IACrE;AAAA,EACD;AAEA,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMN,aAAa,UAAU,UAAU,aAAa,EAAE;AAAA;AAAA;AAAA;AAAA,2CAIP,KAAK,UAAU,OAAO,EAAE,QAAQ,MAAM,SAAS,CAAC;AAAA,UACjF,QAAQ;AAAA;AAAA;AAGlB;AAEA,IAAO,mBAAQ;","names":["require"]}
@@ -142,8 +142,8 @@ function formatSummary(summary, options) {
142
142
  ` Duration: ${durationStr}`,
143
143
  ` Browsers: ${summary.browsers.join(", ")}`
144
144
  ];
145
- const newFailures = summary.failures.filter((f) => f.type === "new");
146
- const diffFailures = summary.failures.filter((f) => f.type !== "new");
145
+ const newFailures = summary.entries.filter((f) => f.type === "new");
146
+ const diffFailures = summary.entries.filter((f) => f.type === "diff");
147
147
  if (newFailures.length > 0) {
148
148
  lines.push("");
149
149
  lines.push(" New (no baseline):");
@@ -378,11 +378,18 @@ function generateTestFile(config, options) {
378
378
  const disableAnimations = config.animations === "disabled";
379
379
  return `import { test, expect } from '@playwright/test';
380
380
  import { readFileSync } from 'node:fs';
381
+ import { initPage, stabilizePage } from '@storywright/cli/playwright/stabilize';
381
382
 
382
383
  const targetList = JSON.parse(
383
384
  readFileSync('${escapeBackslash2(options.targetStoriesPath)}', 'utf-8'),
384
385
  );
385
386
 
387
+ const stabilizeOptions = {
388
+ freezeTime: '${config.freezeTime}',
389
+ seed: ${config.seed},
390
+ disableAnimations: ${disableAnimations},
391
+ };
392
+
386
393
  test.describe.parallel('visual regression testing', () => {
387
394
  if (Object.keys(targetList.entries).length === 0) {
388
395
  test('no stories to test', () => {
@@ -392,89 +399,13 @@ test.describe.parallel('visual regression testing', () => {
392
399
 
393
400
  for (const story of Object.values(targetList.entries)) {
394
401
  test(\`\${story.title}: \${story.name}\`, async ({ page }) => {
395
- // Freeze time for reproducibility
396
- await page.clock.install({ time: new Date('${config.freezeTime}') });
397
-
398
- // Seed Math.random for reproducibility
399
- await page.addInitScript((seed) => {
400
- let s = seed;
401
- Math.random = () => {
402
- s = (s * 16807 + 0) % 2147483647;
403
- return (s - 1) / 2147483646;
404
- };
405
- }, ${config.seed});
402
+ await initPage(page, stabilizeOptions);
406
403
 
407
404
  await page.goto(\`/iframe.html?id=\${story.id}\`, {
408
405
  waitUntil: 'domcontentloaded',
409
406
  });
410
- ${disableAnimations ? `
411
- // Force-disable all CSS animations and transitions
412
- await page.addStyleTag({
413
- content: '*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }',
414
- });
415
- ` : ""}
416
- // Wait for story to render: content inside #storybook-root OR portal content on body
417
- await page.waitForFunction(() => {
418
- const root = document.getElementById('storybook-root');
419
- if (!root) return false;
420
- if (root.childElementCount > 0) return true;
421
- // Portal: check for elements on body that aren't part of Storybook's skeleton
422
- for (const el of document.body.children) {
423
- if (el.tagName === 'SCRIPT' || el.id === 'storybook-root' || el.id === 'storybook-docs') continue;
424
- return true;
425
- }
426
- return false;
427
- }, { timeout: 10000 });
428
-
429
- // Wait for web fonts to finish loading
430
- await page.waitForFunction(() => document.fonts.ready);
431
407
 
432
- // Allow async renders to settle (multiple animation frames)
433
- // This must run BEFORE image checks so the framework has finished adding
434
- // all <img> elements to the DOM
435
- await page.waitForFunction(
436
- () =>
437
- new Promise((resolve) => {
438
- let count = 0;
439
- const tick = () => {
440
- if (++count >= 3) return resolve(true);
441
- requestAnimationFrame(tick);
442
- };
443
- requestAnimationFrame(tick);
444
- }),
445
- );
446
-
447
- // Force lazy-loaded images to eager and wait for load
448
- await page.evaluate(async () => {
449
- const lazyImages = document.querySelectorAll('img[loading="lazy"]');
450
- for (const img of lazyImages) {
451
- (img as HTMLImageElement).loading = 'eager';
452
- }
453
-
454
- const images = Array.from(document.images).filter((img) => !img.complete);
455
- await Promise.all(
456
- images.map(
457
- (img) =>
458
- new Promise<void>((resolve) => {
459
- const timeout = setTimeout(resolve, 5000);
460
- img.onload = img.onerror = () => {
461
- clearTimeout(timeout);
462
- resolve();
463
- };
464
- }),
465
- ),
466
- );
467
- });
468
- ${disableAnimations ? `
469
- // Force opacity:1 on images to counteract fade-in effects
470
- await page.evaluate(() => {
471
- document.querySelectorAll('img').forEach((img) => {
472
- img.style.setProperty('opacity', '1', 'important');
473
- });
474
- });
475
- ` : ""}
476
- // Final stabilization delay for layout shifts
477
- await page.waitForTimeout(200);
408
+ await stabilizePage(page, stabilizeOptions);
478
409
 
479
410
  await expect(page).toHaveScreenshot(
480
411
  [story.title, \`\${story.id}.png\`],
@@ -987,4 +918,4 @@ export {
987
918
  runTests,
988
919
  updateBaselines
989
920
  };
990
- //# sourceMappingURL=chunk-2HQSZU3R.js.map
921
+ //# sourceMappingURL=chunk-XAQTUCH5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/index.ts","../src/config/defaults.ts","../src/config/types.ts","../src/reporter/cli-reporter.ts","../src/storage/local.ts","../src/storage/index.ts","../src/utils/logger.ts","../src/core/engine.ts","../src/playwright/config-generator.ts","../src/playwright/test-generator.ts","../src/resolver/index.ts","../src/utils/path.ts","../src/utils/process.ts","../src/core/storybook.ts"],"sourcesContent":["import { loadConfig as unconfigLoad } from 'unconfig';\nimport { DEFAULT_CONFIG } from './defaults.js';\nimport { STANDARD_BROWSERS } from './types.js';\nimport type { DeepPartial, StorywrightConfig } from './types.js';\n\nexport function defineConfig(\n\tconfig: DeepPartial<StorywrightConfig>,\n): DeepPartial<StorywrightConfig> {\n\treturn config;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction deepMerge(\n\ttarget: Record<string, unknown>,\n\tsource: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst result: Record<string, unknown> = { ...target };\n\tfor (const key of Object.keys(source)) {\n\t\tconst sourceVal = source[key];\n\t\tconst targetVal = result[key];\n\t\tif (isPlainObject(sourceVal) && isPlainObject(targetVal)) {\n\t\t\tresult[key] = deepMerge(targetVal, sourceVal);\n\t\t} else if (sourceVal !== undefined) {\n\t\t\tresult[key] = sourceVal;\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function loadConfig(\n\tcwd: string = process.cwd(),\n\toverrides?: DeepPartial<StorywrightConfig>,\n): Promise<StorywrightConfig> {\n\tconst { config: userConfig } = await unconfigLoad<DeepPartial<StorywrightConfig>>({\n\t\tsources: [\n\t\t\t{\n\t\t\t\tfiles: 'storywright.config',\n\t\t\t\textensions: ['ts', 'js', 'mjs'],\n\t\t\t},\n\t\t],\n\t\tcwd,\n\t});\n\n\tlet merged = DEFAULT_CONFIG as unknown as Record<string, unknown>;\n\tif (userConfig) {\n\t\tmerged = deepMerge(merged, userConfig as Record<string, unknown>);\n\t}\n\tif (overrides) {\n\t\tmerged = deepMerge(merged, overrides as Record<string, unknown>);\n\t}\n\tconst result = merged as unknown as StorywrightConfig;\n\tvalidateConfig(result);\n\treturn result;\n}\n\nfunction validateConfig(config: StorywrightConfig): void {\n\tfor (const browser of config.browsers) {\n\t\tconst options = config.browserOptions[browser];\n\n\t\tif (!STANDARD_BROWSERS.has(browser) && !options?.browserName) {\n\t\t\tthrow new Error(\n\t\t\t\t`Custom browser project '${browser}' requires 'browserName' in browserOptions.\\nExample:\\n browserOptions: {\\n '${browser}': { browserName: 'webkit', ... }\\n }\\nValid browserName values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_MISSING_BROWSER_NAME`,\n\t\t\t);\n\t\t}\n\n\t\tif (options?.browserName && !STANDARD_BROWSERS.has(options.browserName)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid browserName '${options.browserName}' for browser project '${browser}'.\\nValid values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_INVALID_BROWSER_NAME`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport type { StorywrightConfig, DeepPartial } from './types.js';\n","import type { StorywrightConfig } from './types.js';\n\nexport const DEFAULT_CONFIG: StorywrightConfig = {\n\tstorybook: {\n\t\tstaticDir: 'storybook-static',\n\t\tbuildCommand: 'npx storybook build --stats-json',\n\t\turl: undefined,\n\t\tcompatibility: 'auto',\n\t},\n\n\tbrowsers: ['chromium'],\n\tbrowserOptions: {},\n\n\tscreenshot: {\n\t\tfullPage: true,\n\t\tanimations: 'disabled',\n\t\tthreshold: 0.02,\n\t\tmaxDiffPixelRatio: 0.02,\n\t\tfreezeTime: '2024-01-01T00:00:00',\n\t\ttimezone: 'UTC',\n\t\tlocale: 'en-US',\n\t\tseed: 1,\n\t},\n\n\tdiffDetection: {\n\t\tenabled: true,\n\t\twatchFiles: ['package.json', 'package-lock.json', '.storybook/**/*'],\n\t\tbaseBranch: 'main',\n\t},\n\n\tstorage: {\n\t\tprovider: 'local',\n\t\tlocal: {\n\t\t\tbaselineDir: '.storywright/baselines',\n\t\t},\n\t\ts3: {\n\t\t\tbucket: '',\n\t\t\tprefix: 'storywright/baselines',\n\t\t\tregion: 'ap-northeast-1',\n\t\t\tcompression: 'zstd',\n\t\t},\n\t},\n\n\treport: {\n\t\toutputDir: '.storywright/report',\n\t\ttitle: 'Storywright Report',\n\t},\n\n\tworkers: 'auto',\n\tretries: 0,\n\n\ttimeout: {\n\t\ttest: 30000,\n\t\tnavigation: 20000,\n\t\texpect: 10000,\n\t},\n\n\tinclude: ['**'],\n\texclude: [],\n\n\thooks: {},\n};\n","import type { Page } from '@playwright/test';\n\nexport interface StorywrightConfig {\n\tstorybook: StorybookConfig;\n\tbrowsers: BrowserName[];\n\tbrowserOptions: Record<string, BrowserOption>;\n\tscreenshot: ScreenshotConfig;\n\tdiffDetection: DiffDetectionConfig;\n\tstorage: StorageConfig;\n\treport: ReportConfig;\n\tworkers: number | 'auto';\n\tretries: number;\n\ttimeout: TimeoutConfig;\n\tinclude: string[];\n\texclude: string[];\n\thooks: HooksConfig;\n}\n\nexport type BrowserName = 'chromium' | 'firefox' | 'webkit' | (string & {});\n\nexport type PlaywrightBrowserName = 'chromium' | 'firefox' | 'webkit';\n\nexport const STANDARD_BROWSERS: ReadonlySet<string> = new Set<PlaywrightBrowserName>([\n\t'chromium',\n\t'firefox',\n\t'webkit',\n]);\n\nexport interface BrowserOption {\n\tbrowserName?: PlaywrightBrowserName;\n\tviewport?: { width: number; height: number };\n\tdeviceScaleFactor?: number;\n\tisMobile?: boolean;\n\thasTouch?: boolean;\n\tuserAgent?: string;\n\texclude?: string[];\n}\n\nexport interface StorybookConfig {\n\tstaticDir: string;\n\tbuildCommand: string;\n\turl?: string;\n\tcompatibility: 'auto' | 'v8';\n}\n\nexport interface ScreenshotConfig {\n\tfullPage: boolean;\n\tanimations: 'disabled' | 'allow';\n\tthreshold: number;\n\tmaxDiffPixelRatio: number;\n\tfreezeTime: string;\n\ttimezone: string;\n\tlocale: string;\n\tseed: number;\n}\n\nexport interface DiffDetectionConfig {\n\tenabled: boolean;\n\twatchFiles: string[];\n\tbaseBranch: string;\n}\n\nexport interface StorageConfig {\n\tprovider: 'local' | 's3';\n\tlocal: LocalStorageConfig;\n\ts3: S3StorageConfig;\n}\n\nexport interface LocalStorageConfig {\n\tbaselineDir: string;\n}\n\nexport interface S3StorageConfig {\n\tbucket: string;\n\tprefix: string;\n\tregion: string;\n\tcompression: 'zstd' | 'gzip' | 'none';\n}\n\nexport interface ReportConfig {\n\toutputDir: string;\n\ttitle: string;\n}\n\nexport interface TimeoutConfig {\n\ttest: number;\n\tnavigation: number;\n\texpect: number;\n}\n\nexport interface StoryContext {\n\tid: string;\n\ttitle: string;\n\tname: string;\n}\n\nexport interface HooksConfig {\n\tbeforeScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n\tafterScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n}\n\nexport type DeepPartial<T> = {\n\t[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n","import type { TestSummary } from '../core/types.js';\n\nexport function formatSummary(summary: TestSummary, options?: { reportPath?: string }): string {\n\tconst durationSec = Math.round(summary.duration / 1000);\n\tconst minutes = Math.floor(durationSec / 60);\n\tconst seconds = durationSec % 60;\n\tconst durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n\n\tconst lines: string[] = [\n\t\t'',\n\t\t'Storywright Results',\n\t\t'\\u2550'.repeat(42),\n\t\t` Total: ${summary.total} Passed: ${summary.passed} Failed: ${summary.failed} Skipped: ${summary.skipped}`,\n\t\t` Duration: ${durationStr}`,\n\t\t` Browsers: ${summary.browsers.join(', ')}`,\n\t];\n\n\tconst newFailures = summary.entries.filter((f) => f.type === 'new');\n\tconst diffFailures = summary.entries.filter((f) => f.type === 'diff');\n\n\tif (newFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' New (no baseline):');\n\t\tfor (const failure of newFailures) {\n\t\t\tlines.push(` \\u25cb ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t}\n\t}\n\n\tif (diffFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' Failed:');\n\t\tfor (const failure of diffFailures) {\n\t\t\tlines.push(` \\u2717 ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t\tif (failure.diffRatio > 0) {\n\t\t\t\tconst pct = (failure.diffRatio * 100).toFixed(1);\n\t\t\t\tlines.push(` \\u2192 Diff: ${pct}% pixels changed`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst reportPath = options?.reportPath ?? '.storywright/report/index.html';\n\tlines.push('');\n\tlines.push(` Report: ${reportPath}`);\n\tlines.push('\\u2550'.repeat(42));\n\tlines.push('');\n\n\treturn lines.join('\\n');\n}\n","import { execFile } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { DownloadOptions, StorageAdapter, UploadOptions } from './types.js';\n\nconst execFileAsync = promisify(execFile);\n\nexport class LocalStorageAdapter implements StorageAdapter {\n\tconstructor(private readonly baselineDir: string) {}\n\n\tasync download(options: DownloadOptions): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.cp(this.baselineDir, options.destDir, { recursive: true });\n\t}\n\n\tasync upload(options: UploadOptions): Promise<void> {\n\t\tconst resolvedSource = path.resolve(options.sourceDir);\n\t\tconst resolvedDest = path.resolve(this.baselineDir);\n\t\tif (resolvedSource === resolvedDest) {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.mkdir(this.baselineDir, { recursive: true });\n\t\tawait fs.cp(options.sourceDir, this.baselineDir, { recursive: true });\n\t}\n\n\tasync exists(_branch: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t\tconst entries = await fs.readdir(this.baselineDir);\n\t\t\treturn entries.length > 0;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Extract baselines from a git branch using `git ls-tree` + `git show`.\n\t * Binary-safe (PNG files) via `encoding: 'buffer'`.\n\t */\n\tasync downloadFromGit(branch: string, destDir: string, cwd: string): Promise<void> {\n\t\tconst gitPath = this.baselineDir.split(path.sep).join('/');\n\n\t\tlet lsOutput: string;\n\t\ttry {\n\t\t\tconst result = await execFileAsync(\n\t\t\t\t'git',\n\t\t\t\t['ls-tree', '-r', '--name-only', branch, '--', gitPath],\n\t\t\t\t{ cwd },\n\t\t\t);\n\t\t\tlsOutput = result.stdout;\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to list baselines from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t);\n\t\t}\n\n\t\tconst files = lsOutput.trim().split('\\n').filter(Boolean);\n\t\tif (files.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait fs.mkdir(destDir, { recursive: true });\n\n\t\tconst posixBaselineDir = this.baselineDir.split(path.sep).join('/').replace(/\\/+$/, '');\n\n\t\tfor (const file of files) {\n\t\t\tlet content: Buffer;\n\t\t\ttry {\n\t\t\t\tconst result = await execFileAsync('git', ['show', `${branch}:${file}`], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tencoding: 'buffer' as unknown as BufferEncoding,\n\t\t\t\t\tmaxBuffer: 50 * 1024 * 1024,\n\t\t\t\t});\n\t\t\t\tcontent = result.stdout as unknown as Buffer;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to extract '${file}' from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst relativePath = file.slice(posixBaselineDir.length + 1);\n\t\t\tconst destPath = path.join(destDir, ...relativePath.split('/'));\n\t\t\tawait fs.mkdir(path.dirname(destPath), { recursive: true });\n\t\t\tawait fs.writeFile(destPath, content);\n\t\t}\n\t}\n}\n","import type { StorageConfig } from '../config/types.js';\nimport { LocalStorageAdapter } from './local.js';\nimport type { StorageAdapter } from './types.js';\n\nexport async function createStorageAdapter(config: StorageConfig): Promise<StorageAdapter> {\n\tswitch (config.provider) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageAdapter(config.local.baselineDir);\n\t\tcase 's3':\n\t\t\treturn await loadS3Adapter(config);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown storage provider: ${config.provider}`);\n\t}\n}\n\nasync function loadS3Adapter(config: StorageConfig): Promise<StorageAdapter> {\n\ttry {\n\t\tconst { S3StorageAdapter } = await import('@storywright/storage-s3');\n\t\treturn new S3StorageAdapter(config.s3) as StorageAdapter;\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'S3 storage adapter requires the @storywright/storage-s3 package.\\nInstall it with: pnpm add @storywright/storage-s3',\n\t\t);\n\t}\n}\n\nexport type { StorageAdapter, DownloadOptions, UploadOptions } from './types.js';\n","import { createConsola } from 'consola';\n\nconst isCI = !!(\n\tprocess.env.CI ||\n\tprocess.env.GITHUB_ACTIONS ||\n\tprocess.env.CIRCLECI ||\n\tprocess.env.GITLAB_CI\n);\n\nexport const logger = createConsola({\n\tlevel: process.env.STORYWRIGHT_DEBUG ? 5 : 3,\n});\n\nexport { isCI };\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { generatePlaywrightConfig } from '../playwright/config-generator.js';\nimport { generateTestFile } from '../playwright/test-generator.js';\nimport { resolveAffectedStories } from '../resolver/index.js';\nimport { createStorageAdapter } from '../storage/index.js';\nimport { logger } from '../utils/logger.js';\nimport { resolveOutputDir } from '../utils/path.js';\nimport { exec } from '../utils/process.js';\nimport {\n\tbuildStorybook,\n\tdiscoverStories,\n\texcludeStoriesForBrowser,\n\tfilterStories,\n} from './storybook.js';\nimport type { Story, StoryIndex, TestSummary } from './types.js';\n\nexport interface TestOptions {\n\tdiffOnly?: boolean;\n\tshard?: string;\n\tupdateSnapshots?: boolean;\n\tfilter?: string;\n\toutputDir?: string;\n\treporters?: string[];\n}\n\nexport interface TestRunResult {\n\texitCode: number;\n\tsummary?: TestSummary;\n\treportDir?: string;\n\tsnapshotDir?: string;\n}\n\nconst STORIES_PER_FILE = 50;\n\nfunction resolveReporterPath(): string {\n\t// Resolve relative to this file's dist location\n\tconst thisDir = new URL('.', import.meta.url).pathname;\n\treturn path.resolve(thisDir, 'playwright', 'reporter.js');\n}\n\nfunction chunkStories(entries: Record<string, Story>): Record<string, Story>[] {\n\tconst keys = Object.keys(entries);\n\tif (keys.length === 0) return [{}];\n\tconst chunks: Record<string, Story>[] = [];\n\tfor (let i = 0; i < keys.length; i += STORIES_PER_FILE) {\n\t\tconst chunk: Record<string, Story> = {};\n\t\tfor (const key of keys.slice(i, i + STORIES_PER_FILE)) {\n\t\t\tchunk[key] = entries[key];\n\t\t}\n\t\tchunks.push(chunk);\n\t}\n\treturn chunks;\n}\n\nexport async function runTests(\n\tconfig: StorywrightConfig,\n\toptions: TestOptions = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst outputRoot = options.outputDir\n\t\t? path.resolve(cwd, options.outputDir)\n\t\t: resolveOutputDir(cwd, '.storywright');\n\tconst tmpDir = path.join(outputRoot, 'tmp');\n\tconst reportDir = options.outputDir\n\t\t? path.join(outputRoot, 'report')\n\t\t: path.resolve(cwd, config.report.outputDir);\n\tconst storybookDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst snapshotDir = path.join(tmpDir, 'snapshots');\n\n\t// Prepare directories early for parallel operations\n\tawait fs.mkdir(snapshotDir, { recursive: true });\n\n\t// Start baseline download in parallel with Storybook build\n\t// Skip download when updating snapshots (update command) — baselines are regenerated\n\tlet baselinePromise: Promise<void> | undefined;\n\tif (!options.updateSnapshots) {\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tbaselinePromise = storage\n\t\t\t.download({ branch: 'current', destDir: snapshotDir, onProgress: (msg) => logger.info(msg) })\n\t\t\t.catch(() => {\n\t\t\t\tlogger.info('No existing baselines found');\n\t\t\t});\n\t}\n\n\t// 1. Build Storybook if needed\n\tawait buildStorybook(config, cwd);\n\n\t// 2. Discover & filter stories\n\tlogger.start('Discovering stories...');\n\tconst allStories = await discoverStories(config, cwd);\n\tlet targetStories = filterStories(allStories, config);\n\n\t// Apply --filter option\n\tif (options.filter) {\n\t\ttargetStories = applyFilter(targetStories, options.filter);\n\t}\n\n\tlogger.info(`${Object.keys(targetStories.entries).length} stories found`);\n\n\t// 3. Diff-only: resolve affected stories (default in CI)\n\tconst effectiveDiffOnly = options.diffOnly ?? !!process.env.CI;\n\tif (effectiveDiffOnly && config.diffDetection.enabled) {\n\t\tlogger.start('Resolving dependencies...');\n\t\tconst diffResult = await resolveAffectedStories(\n\t\t\ttargetStories,\n\t\t\tconfig.diffDetection,\n\t\t\tstorybookDir,\n\t\t\tcwd,\n\t\t);\n\t\tif (!diffResult.allStories) {\n\t\t\ttargetStories = diffResult.targetStories;\n\t\t}\n\t\tlogger.info(`${Object.keys(targetStories.entries).length} stories affected by changes`);\n\t}\n\n\t// 4. Wait for baseline download to complete\n\tawait baselinePromise;\n\n\t// 5. Generate split test files for better worker distribution\n\tlet testFilePattern: string;\n\tlet testMatchByBrowser: Record<string, string> | undefined;\n\n\tconst browserExcludesExist = config.browsers.some(\n\t\t(b) => (config.browserOptions[b]?.exclude ?? []).length > 0,\n\t);\n\n\tif (browserExcludesExist) {\n\t\t// Generate per-browser test files when any browser has specific excludes\n\t\ttestMatchByBrowser = {};\n\n\t\tfor (const browser of config.browsers) {\n\t\t\tconst browserExclude = config.browserOptions[browser]?.exclude ?? [];\n\t\t\tconst browserStories = excludeStoriesForBrowser(targetStories, browserExclude);\n\n\t\t\tif (Object.keys(browserStories.entries).length === 0) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t`${browser}: All stories excluded by browser-specific 'exclude' patterns. No tests will run for this browser.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst browserChunks = chunkStories(browserStories.entries);\n\n\t\t\ttestMatchByBrowser[browser] =\n\t\t\t\tbrowserChunks.length === 1\n\t\t\t\t\t? `storywright-${browser}-0.spec.ts`\n\t\t\t\t\t: `storywright-${browser}-*.spec.ts`;\n\n\t\t\tfor (let i = 0; i < browserChunks.length; i++) {\n\t\t\t\tconst chunkIndex: StoryIndex = { ...browserStories, entries: browserChunks[i] };\n\t\t\t\tconst chunkPath = path.join(tmpDir, `target-stories-${browser}-${i}.json`);\n\t\t\t\tawait fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n\t\t\t\tconst testContent = generateTestFile(config.screenshot, {\n\t\t\t\t\ttargetStoriesPath: chunkPath.replace(/\\\\/g, '/'),\n\t\t\t\t});\n\t\t\t\tawait fs.writeFile(path.join(tmpDir, `storywright-${browser}-${i}.spec.ts`), testContent);\n\t\t\t}\n\n\t\t\tlogger.info(\n\t\t\t\t`${browser}: ${Object.keys(browserStories.entries).length} stories, ${browserChunks.length} test file(s)`,\n\t\t\t);\n\t\t}\n\n\t\ttestFilePattern = 'storywright-*.spec.ts';\n\t} else {\n\t\t// Default: shared test files for all browsers\n\t\tconst chunks = chunkStories(targetStories.entries);\n\t\ttestFilePattern = chunks.length === 1 ? 'storywright-0.spec.ts' : 'storywright-*.spec.ts';\n\n\t\tfor (let i = 0; i < chunks.length; i++) {\n\t\t\tconst chunkIndex: StoryIndex = { ...targetStories, entries: chunks[i] };\n\t\t\tconst chunkPath = path.join(tmpDir, `target-stories-${i}.json`);\n\t\t\tawait fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n\t\t\tconst testContent = generateTestFile(config.screenshot, {\n\t\t\t\ttargetStoriesPath: chunkPath.replace(/\\\\/g, '/'),\n\t\t\t});\n\t\t\tawait fs.writeFile(path.join(tmpDir, `storywright-${i}.spec.ts`), testContent);\n\t\t}\n\n\t\tlogger.info(`${chunks.length} test file(s) generated`);\n\t}\n\n\t// 6. Generate Playwright config\n\tconst reporterWrapperPath = path.join(tmpDir, 'reporter.mjs');\n\tconst resolvedReporterPath = resolveReporterPath().replace(/\\\\/g, '/');\n\tconst reporterOutputDir = reportDir.replace(/\\\\/g, '/');\n\n\tawait fs.writeFile(\n\t\treporterWrapperPath,\n\t\t`import StorywrightReporter from '${resolvedReporterPath}';\\nexport default class extends StorywrightReporter {\\n constructor() { super({ outputDir: '${reporterOutputDir}' }); }\\n}\\n`,\n\t);\n\n\t// Determine Storybook URL\n\tlet actualStorybookUrl = config.storybook.url;\n\tconst needsServer = !actualStorybookUrl;\n\n\tif (needsServer) {\n\t\tactualStorybookUrl = 'http://localhost:6007';\n\t}\n\n\tconst playwrightConfig = generatePlaywrightConfig(config, {\n\t\ttmpDir: tmpDir.replace(/\\\\/g, '/'),\n\t\tstorybookUrl: actualStorybookUrl ?? 'http://localhost:6007',\n\t\tsnapshotDir: snapshotDir.replace(/\\\\/g, '/'),\n\t\treporterPath: reporterWrapperPath.replace(/\\\\/g, '/'),\n\t\ttestMatch: testFilePattern,\n\t\ttestMatchByBrowser,\n\t\tshard: options.shard,\n\t\treporters: options.reporters,\n\t});\n\n\tconst configPath = path.join(tmpDir, 'playwright.config.ts');\n\tawait fs.writeFile(configPath, playwrightConfig);\n\n\t// 7. Run Playwright tests\n\tlogger.start('Running tests...');\n\tconst args = ['playwright', 'test', '--config', configPath];\n\n\tif (options.updateSnapshots) {\n\t\targs.push('--update-snapshots');\n\t}\n\n\t// Start static server if needed\n\tlet serverProc: { kill: () => void } | undefined;\n\tif (needsServer) {\n\t\tserverProc = await startStaticServer(storybookDir, 6007);\n\t}\n\n\ttry {\n\t\tconst result = await exec('npx', args, { cwd, inherit: true });\n\n\t\t// 8. Read results\n\t\tlet summary: TestSummary | undefined;\n\t\ttry {\n\t\t\tconst summaryPath = path.join(reportDir, 'summary.json');\n\t\t\tconst summaryContent = await fs.readFile(summaryPath, 'utf-8');\n\t\t\tsummary = JSON.parse(summaryContent);\n\t\t} catch {\n\t\t\t// summary may not exist if no tests ran\n\t\t}\n\n\t\t// 9. Map exit codes per SPEC §14.2\n\t\tconst exitCode = mapExitCode(result.exitCode, summary);\n\n\t\treturn { exitCode, summary, reportDir, snapshotDir };\n\t} finally {\n\t\tserverProc?.kill();\n\t}\n}\n\nexport async function updateBaselines(\n\tconfig: StorywrightConfig,\n\toptions: { all?: boolean; upload?: boolean; shard?: string; filter?: string } = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst result = await runTests(\n\t\tconfig,\n\t\t{\n\t\t\tupdateSnapshots: true,\n\t\t\tdiffOnly: !options.all,\n\t\t\tshard: options.shard,\n\t\t\tfilter: options.filter,\n\t\t},\n\t\tcwd,\n\t);\n\n\tif (result.exitCode !== 0) {\n\t\tlogger.warn('Some tests failed during baseline update');\n\t}\n\n\t// Save updated snapshots back to baselineDir (local disk operation)\n\tif (result.snapshotDir) {\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait fs.mkdir(baselineDir, { recursive: true });\n\t\tawait fs.cp(result.snapshotDir, baselineDir, { recursive: true });\n\t\tlogger.success(`Baselines saved to ${config.storage.local.baselineDir}`);\n\t}\n\n\t// --upload: upload to remote storage (S3 etc.) only when explicitly requested\n\tif (options.upload) {\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: baselineDir,\n\t\t\tshard: options.shard,\n\t\t\tonProgress: (msg) => logger.info(msg),\n\t\t});\n\t\tlogger.success('Baselines uploaded to remote storage');\n\t}\n\n\treturn result;\n}\n\nfunction applyFilter(storyIndex: StoryIndex, filter: string): StoryIndex {\n\tconst matcher = picomatch(filter);\n\tconst entries: Record<string, StoryIndex['entries'][string]> = {};\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tif (matcher(fullName) || matcher(story.title) || matcher(story.id)) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\treturn { ...storyIndex, entries };\n}\n\nfunction mapExitCode(playwrightCode: number, summary?: TestSummary): number {\n\t// SPEC §14.2: 0 = success (no diff), 1 = success (diff found), 2 = execution error, 130 = SIGINT\n\tif (playwrightCode === 130 || playwrightCode === 143) {\n\t\treturn 130; // SIGINT / SIGTERM\n\t}\n\tif (summary) {\n\t\tif (summary.failed > 0) return 1;\n\t\tif (summary.total === 0 && playwrightCode !== 0) return 2;\n\t\treturn 0;\n\t}\n\t// No summary = likely execution error\n\treturn playwrightCode === 0 ? 0 : 2;\n}\n\nasync function startStaticServer(dir: string, port: number): Promise<{ kill: () => void }> {\n\tconst { createServer } = await import('node:http');\n\tconst sirv = (await import('sirv')).default;\n\n\tconst handler = sirv(dir, { single: false, dev: false });\n\tconst server = createServer(handler);\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.on('error', reject);\n\t\tserver.listen(port, () => resolve());\n\t});\n\n\treturn { kill: () => server.close() };\n}\n","import { STANDARD_BROWSERS } from '../config/types.js';\nimport type { BrowserOption, StorywrightConfig } from '../config/types.js';\n\nexport function generatePlaywrightConfig(\n\tconfig: StorywrightConfig,\n\toptions: {\n\t\ttmpDir: string;\n\t\tstorybookUrl: string;\n\t\tsnapshotDir: string;\n\t\treporterPath: string;\n\t\ttestMatch: string;\n\t\ttestMatchByBrowser?: Record<string, string>;\n\t\tshard?: string;\n\t\treporters?: string[];\n\t},\n): string {\n\tconst projects = config.browsers.map((browser) => {\n\t\tconst rawOptions = config.browserOptions[browser];\n\t\tconst useObj = buildBrowserUseObject(browser, rawOptions);\n\t\tconst useStr = JSON.stringify(useObj, null, '\\t\\t');\n\t\tconst testMatch = options.testMatchByBrowser?.[browser];\n\t\tconst testMatchLine = testMatch ? `\\n\\t\\t\\ttestMatch: '${escapeBackslash(testMatch)}',` : '';\n\t\treturn `\\t\\t{\n\\t\\t\\tname: '${browser}',${testMatchLine}\n\\t\\t\\tuse: ${useStr},\n\\t\\t}`;\n\t});\n\n\tconst workers = config.workers === 'auto' ? \"'100%'\" : String(config.workers);\n\n\tconst shard = options.shard\n\t\t? `\\tshard: { current: ${options.shard.split('/')[0]}, total: ${options.shard.split('/')[1]} },`\n\t\t: '';\n\n\t// Build reporter list: always include custom reporter, plus user-requested ones\n\tconst reporterEntries: string[] = [];\n\tconst requestedReporters = options.reporters ?? ['default', 'html'];\n\tfor (const r of requestedReporters) {\n\t\tif (r === 'default' || r === 'list') {\n\t\t\treporterEntries.push(\"\\t\\t['list']\");\n\t\t} else if (r !== 'html') {\n\t\t\t// Pass through other built-in Playwright reporters (dot, json, junit, etc.)\n\t\t\treporterEntries.push(`\\t\\t['${r}']`);\n\t\t}\n\t}\n\t// Always include custom storywright reporter\n\treporterEntries.push(`\\t\\t['${escapeBackslash(options.reporterPath)}']`);\n\n\tconst testMatchLine = options.testMatchByBrowser\n\t\t? ''\n\t\t: `\\ttestMatch: '${escapeBackslash(options.testMatch)}',\\n`;\n\n\treturn `import { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\\ttestDir: '${escapeBackslash(options.tmpDir)}',\n${testMatchLine}\\tsnapshotDir: '${escapeBackslash(options.snapshotDir)}',\n\\tsnapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}{ext}',\n\\ttimeout: ${config.timeout.test},\n\\texpect: {\n\\t\\ttoHaveScreenshot: {\n\\t\\t\\tmaxDiffPixelRatio: ${config.screenshot.maxDiffPixelRatio},\n\\t\\t\\tthreshold: ${config.screenshot.threshold},\n\\t\\t},\n\\t\\ttimeout: ${config.timeout.expect},\n\\t},\n\\tfullyParallel: true,\n\\tforbidOnly: !!process.env.CI,\n\\tretries: ${config.retries},\n\\tworkers: ${workers},\n${shard}\n\\treporter: [\n${reporterEntries.join(',\\n')}\n\\t],\n\\tuse: {\n\\t\\tbaseURL: '${options.storybookUrl}',\n\\t\\tnavigationTimeout: ${config.timeout.navigation},\n\\t\\ttimezoneId: '${config.screenshot.timezone}',\n\\t\\tlocale: '${config.screenshot.locale}',\n\\t},\n\\tprojects: [\n${projects.join(',\\n')}\n\\t],\n});\n`;\n}\n\nfunction buildBrowserUseObject(\n\tbrowser: string,\n\trawOptions?: BrowserOption,\n): Record<string, unknown> {\n\tlet browserName: string;\n\tif (rawOptions?.browserName) {\n\t\tbrowserName = rawOptions.browserName;\n\t} else if (STANDARD_BROWSERS.has(browser)) {\n\t\tbrowserName = browser;\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Cannot resolve browserName for custom browser project '${browser}'.\\n\\nError code: SW_E_INTERNAL_BROWSER_RESOLVE`,\n\t\t);\n\t}\n\tconst useObj: Record<string, unknown> = { browserName };\n\n\tif (rawOptions) {\n\t\tconst { browserName: _, exclude: __, ...rest } = rawOptions;\n\t\tObject.assign(useObj, rest);\n\t}\n\n\treturn useObj;\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import type { ScreenshotConfig } from '../config/types.js';\n\nexport function generateTestFile(\n\tconfig: ScreenshotConfig,\n\toptions: {\n\t\ttargetStoriesPath: string;\n\t},\n): string {\n\tconst disableAnimations = config.animations === 'disabled';\n\n\treturn `import { test, expect } from '@playwright/test';\nimport { readFileSync } from 'node:fs';\nimport { initPage, stabilizePage } from '@storywright/cli/playwright/stabilize';\n\nconst targetList = JSON.parse(\n\\treadFileSync('${escapeBackslash(options.targetStoriesPath)}', 'utf-8'),\n);\n\nconst stabilizeOptions = {\n\\tfreezeTime: '${config.freezeTime}',\n\\tseed: ${config.seed},\n\\tdisableAnimations: ${disableAnimations},\n};\n\ntest.describe.parallel('visual regression testing', () => {\n\\tif (Object.keys(targetList.entries).length === 0) {\n\\t\\ttest('no stories to test', () => {\n\\t\\t\\texpect(true).toBeTruthy();\n\\t\\t});\n\\t}\n\n\\tfor (const story of Object.values(targetList.entries)) {\n\\t\\ttest(\\`\\${story.title}: \\${story.name}\\`, async ({ page }) => {\n\\t\\t\\tawait initPage(page, stabilizeOptions);\n\n\\t\\t\\tawait page.goto(\\`/iframe.html?id=\\${story.id}\\`, {\n\\t\\t\\t\\twaitUntil: 'domcontentloaded',\n\\t\\t\\t});\n\n\\t\\t\\tawait stabilizePage(page, stabilizeOptions);\n\n\\t\\t\\tawait expect(page).toHaveScreenshot(\n\\t\\t\\t\\t[story.title, \\`\\${story.id}.png\\`],\n\\t\\t\\t\\t{\n\\t\\t\\t\\t\\tanimations: '${config.animations}',\n\\t\\t\\t\\t\\tfullPage: ${config.fullPage},\n\\t\\t\\t\\t\\tthreshold: ${config.threshold},\n\\t\\t\\t\\t\\tmaxDiffPixelRatio: ${config.maxDiffPixelRatio},\n\\t\\t\\t\\t},\n\\t\\t\\t);\n\\t\\t});\n\\t}\n});\n`;\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport { simpleGit } from 'simple-git';\nimport type { DiffDetectionConfig } from '../config/types.js';\nimport type { StatsIndex, StatsModule, StoryIndex } from '../core/types.js';\nimport { logger } from '../utils/logger.js';\nimport { normalizePath, stripLeadingDotSlash } from '../utils/path.js';\n\nexport interface DependencyResolver {\n\tgetDependencies(filePath: string): string[];\n\tgetStoriesForFiles(pathList: string[]): StoryIndex;\n}\n\nconst STORY_FILE_PATTERNS = ['.stories.', '.mdx'];\n\nfunction isStoryFile(moduleName: string): boolean {\n\treturn STORY_FILE_PATTERNS.some((p) => moduleName.includes(p));\n}\n\nexport class StorybookStatsDependencyResolver implements DependencyResolver {\n\tprivate moduleMap: Record<string, StatsModule>;\n\n\tconstructor(\n\t\tprivate statsJson: StatsIndex,\n\t\tprivate storiesJson: StoryIndex,\n\t) {\n\t\tthis.moduleMap = {};\n\t\tfor (const mod of statsJson.modules) {\n\t\t\t// Key by normalized name (primary) and normalized id (fallback)\n\t\t\tconst normalizedName = normalizePath(mod.name);\n\t\t\tthis.moduleMap[normalizedName] = mod;\n\t\t\tconst normalizedId = normalizePath(mod.id);\n\t\t\tif (normalizedId !== normalizedName) {\n\t\t\t\tthis.moduleMap[normalizedId] ??= mod;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetDependencies(filePath: string): string[] {\n\t\tconst normalizedPath = normalizePath(filePath);\n\t\tconst dependencies = this.collectDependencies(normalizedPath);\n\n\t\tif (this.moduleMap[normalizedPath]) {\n\t\t\tdependencies.add(normalizedPath);\n\t\t}\n\n\t\treturn [...dependencies];\n\t}\n\n\tgetStoriesForFiles(pathList: string[]): StoryIndex {\n\t\tconst result: StoryIndex = { v: this.storiesJson.v, entries: {} };\n\n\t\tfor (const filePath of pathList) {\n\t\t\t// Finding #2 + #3: lookup via normalized moduleMap (name primary, id fallback)\n\t\t\tconst normalizedPath = normalizePath(filePath);\n\t\t\tconst stats = this.moduleMap[normalizedPath];\n\t\t\tif (!stats) continue;\n\n\t\t\t// Finding #1: collect ALL story reasons, not just first\n\t\t\tconst storyReasons = stats.reasons.filter((r) => isStoryFile(r.moduleName));\n\t\t\tfor (const reason of storyReasons) {\n\t\t\t\tconst normalizedImportPath = normalizePath(reason.moduleName);\n\t\t\t\t// Collect ALL matching story entries per reason\n\t\t\t\tfor (const storyObj of Object.values(this.storiesJson.entries)) {\n\t\t\t\t\tif (storyObj.type !== 'story') continue;\n\t\t\t\t\tif (normalizePath(storyObj.importPath) === normalizedImportPath) {\n\t\t\t\t\t\tresult.entries[storyObj.id] = storyObj;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate collectDependencies(name: string, result = new Set<string>()): Set<string> {\n\t\tconst mod = this.moduleMap[normalizePath(name)];\n\t\tif (mod) {\n\t\t\tfor (const reason of mod.reasons) {\n\t\t\t\tif (!result.has(reason.moduleName)) {\n\t\t\t\t\tresult.add(reason.moduleName);\n\t\t\t\t\tthis.collectDependencies(reason.moduleName, result);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n}\n\nexport interface DiffResult {\n\tallStories: boolean;\n\ttargetStories: StoryIndex;\n}\n\ninterface DiffFileEntry {\n\tfile: string;\n\tfrom?: string;\n}\n\nexport async function resolveAffectedStories(\n\tstoriesJson: StoryIndex,\n\tconfig: DiffDetectionConfig,\n\tstorybookStaticDir: string,\n\tcwd: string,\n): Promise<DiffResult> {\n\tconst git = simpleGit({ baseDir: cwd });\n\n\t// Get diff summary\n\tlet diffEntries: DiffFileEntry[];\n\ttry {\n\t\tconst mergeBase = await git.raw(['merge-base', config.baseBranch, 'HEAD']);\n\t\tconst diff = await git.diffSummary([mergeBase.trim(), 'HEAD']);\n\t\tdiffEntries = diff.files.map((f) => ({\n\t\t\tfile: f.file,\n\t\t\t// Handle renames: include both old and new paths\n\t\t\tfrom: 'from' in f ? (f as { from: string }).from : undefined,\n\t\t}));\n\t} catch {\n\t\tlogger.warn('Failed to resolve git diff, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tif (diffEntries.length === 0) {\n\t\tlogger.info('No changed files detected');\n\t\treturn { allStories: false, targetStories: { v: storiesJson.v, entries: {} } };\n\t}\n\n\t// Collect all affected paths (including rename sources)\n\tconst allPaths: string[] = [];\n\tfor (const entry of diffEntries) {\n\t\tallPaths.push(entry.file);\n\t\tif (entry.from) {\n\t\t\tallPaths.push(entry.from);\n\t\t}\n\t}\n\n\t// Check watchFiles\n\tfor (const file of allPaths) {\n\t\tfor (const pattern of config.watchFiles) {\n\t\t\tif (picomatch(pattern)(file)) {\n\t\t\t\tlogger.info(`Watch file changed: ${file}, running all stories`);\n\t\t\t\treturn { allStories: true, targetStories: storiesJson };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Load stats json for dependency resolution\n\tconst statsPath = path.resolve(storybookStaticDir, 'preview-stats.json');\n\tlet statsJson: StatsIndex;\n\ttry {\n\t\tstatsJson = JSON.parse(await fs.readFile(statsPath, 'utf-8'));\n\t} catch {\n\t\tlogger.warn('preview-stats.json not found, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tconst resolver = new StorybookStatsDependencyResolver(statsJson, storiesJson);\n\tconst targetStories: StoryIndex = { v: storiesJson.v, entries: {} };\n\n\t// Direct story file matches (both .stories.* and .mdx)\n\tfor (const file of allPaths) {\n\t\tconst matchedStories = Object.values(storiesJson.entries).filter(\n\t\t\t(story) => stripLeadingDotSlash(story.importPath) === file,\n\t\t);\n\t\tfor (const story of matchedStories) {\n\t\t\ttargetStories.entries[story.id] = story;\n\t\t}\n\t}\n\n\t// Dependency-based matches\n\tfor (const file of allPaths) {\n\t\tconst deps = resolver.getDependencies(normalizePath(file));\n\t\tconst depStories = resolver.getStoriesForFiles(deps);\n\t\tfor (const [id, story] of Object.entries(depStories.entries)) {\n\t\t\ttargetStories.entries[id] = story;\n\t\t}\n\t}\n\n\tlogger.info(`Resolved ${Object.keys(targetStories.entries).length} affected stories`);\n\treturn { allStories: false, targetStories };\n}\n","import path from 'node:path';\n\nexport function normalizePath(filePath: string): string {\n\tconst normalized = filePath.replace(/\\\\/g, '/');\n\tif (normalized.startsWith('./')) {\n\t\treturn normalized;\n\t}\n\treturn `./${normalized}`;\n}\n\nexport function stripLeadingDotSlash(filePath: string): string {\n\treturn filePath.replace(/^\\.\\//, '');\n}\n\nexport function resolveOutputDir(outputDir: string, ...segments: string[]): string {\n\treturn path.resolve(outputDir, ...segments);\n}\n","import { spawn } from 'node:child_process';\n\nexport interface ExecResult {\n\texitCode: number;\n\tstdout: string;\n\tstderr: string;\n}\n\nexport function exec(\n\tcommand: string,\n\targs: string[],\n\toptions?: { cwd?: string; env?: Record<string, string>; inherit?: boolean },\n): Promise<ExecResult> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tenv: { ...process.env, ...options?.env },\n\t\t\tstdio: options?.inherit ? ['ignore', 'inherit', 'inherit'] : ['ignore', 'pipe', 'pipe'],\n\t\t\tshell: false,\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\n\t\tif (!options?.inherit) {\n\t\t\tproc.stdout?.on('data', (data: Buffer) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\n\t\t\tproc.stderr?.on('data', (data: Buffer) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t}\n\n\t\tproc.on('error', reject);\n\n\t\tproc.on('close', (code) => {\n\t\t\tresolve({ exitCode: code ?? 1, stdout, stderr });\n\t\t});\n\t});\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { logger } from '../utils/logger.js';\nimport { exec } from '../utils/process.js';\nimport type { Story, StoryIndex } from './types.js';\n\nexport async function buildStorybook(config: StorywrightConfig, cwd: string): Promise<void> {\n\tif (config.storybook.url) {\n\t\tlogger.info('Using running Storybook at', config.storybook.url);\n\t\treturn;\n\t}\n\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\ttry {\n\t\tawait fs.access(path.join(staticDir, 'index.json'));\n\t\tlogger.info('Storybook already built at', staticDir);\n\t\treturn;\n\t} catch {\n\t\t// need to build\n\t}\n\n\tlogger.start('Building Storybook...');\n\tconst [command, ...args] = config.storybook.buildCommand.split(' ');\n\tconst result = await exec(command, args, { cwd });\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`Storybook build failed (exit code ${result.exitCode}):\\n${result.stderr}\\n\\nError code: SW_E_STORYBOOK_BUILD_FAILED`,\n\t\t);\n\t}\n\tlogger.success('Storybook built');\n}\n\nexport async function discoverStories(config: StorywrightConfig, cwd: string): Promise<StoryIndex> {\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst indexPath = path.join(staticDir, 'index.json');\n\n\ttry {\n\t\tawait fs.access(indexPath);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`Storybook build directory not found at '${config.storybook.staticDir}/'\\n\\n Run one of the following:\\n $ npx storybook build --stats-json\\n $ npx storywright test --storybook-url http://localhost:6006\\n\\n Error code: SW_E_STORYBOOK_DIR_NOT_FOUND`,\n\t\t);\n\t}\n\n\tconst raw = JSON.parse(await fs.readFile(indexPath, 'utf-8'));\n\tconst indexJson = normalizeStoryIndex(raw, config.storybook.compatibility);\n\n\t// Version check\n\tif (indexJson.v < 4) {\n\t\tthrow new Error(\n\t\t\t'Storybook 7.x or earlier is not supported. Storywright requires Storybook 8 or later.\\n\\nError code: SW_E_STORYBOOK_UNSUPPORTED',\n\t\t);\n\t}\n\n\treturn indexJson;\n}\n\n/**\n * Parse Storybook index.json (v8+).\n */\nfunction normalizeStoryIndex(\n\traw: Record<string, unknown>,\n\t_compatibility: 'auto' | 'v8',\n): StoryIndex {\n\tconst version = typeof raw.v === 'number' ? raw.v : 0;\n\tconst entries = (raw.entries ?? {}) as Record<string, Story>;\n\n\treturn { v: version, entries };\n}\n\nexport function filterStories(storyIndex: StoryIndex, config: StorywrightConfig): StoryIndex {\n\tconst entries: Record<string, Story> = {};\n\tconst includeMatchers = config.include.map((p) => picomatch(p));\n\tconst excludeMatchers = config.exclude.map((p) => picomatch(p));\n\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\t// Skip docs entries\n\t\tif (story.type === 'docs') continue;\n\t\tif (story.name === 'Docs') continue;\n\n\t\tconst fullName = `${story.title}/${story.name}`;\n\n\t\t// Check include patterns\n\t\tconst isIncluded = includeMatchers.some((m) => m(fullName));\n\t\tif (!isIncluded) continue;\n\n\t\t// Check exclude patterns\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (isExcluded) continue;\n\n\t\tentries[id] = story;\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n\nexport function excludeStoriesForBrowser(\n\tstoryIndex: StoryIndex,\n\texcludePatterns: string[],\n): StoryIndex {\n\tif (excludePatterns.length === 0) {\n\t\treturn storyIndex;\n\t}\n\n\tconst excludeMatchers = excludePatterns.map((p) => picomatch(p));\n\tconst entries: Record<string, Story> = {};\n\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (!isExcluded) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n"],"mappings":";AAAA,SAAS,cAAc,oBAAoB;;;ACEpC,IAAM,iBAAoC;AAAA,EAChD,WAAW;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd,KAAK;AAAA,IACL,eAAe;AAAA,EAChB;AAAA,EAEA,UAAU,CAAC,UAAU;AAAA,EACrB,gBAAgB,CAAC;AAAA,EAEjB,YAAY;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,mBAAmB;AAAA,I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atch","testMatchLine","escapeBackslash","fs","path","path","path","fs","fs","path","picomatch","path","fs","picomatch","path","fs","picomatch"]}
package/dist/cli.js CHANGED
@@ -6,10 +6,10 @@ import {
6
6
  logger,
7
7
  runTests,
8
8
  updateBaselines
9
- } from "./chunk-2HQSZU3R.js";
9
+ } from "./chunk-XAQTUCH5.js";
10
10
  import {
11
11
  generateHtmlReport
12
- } from "./chunk-HPK2VJXG.js";
12
+ } from "./chunk-JDHVDQIC.js";
13
13
 
14
14
  // src/cli/index.ts
15
15
  import { defineCommand as defineCommand7, runMain } from "citty";
@@ -172,7 +172,7 @@ var reportCommand = defineCommand3({
172
172
  duration: 0,
173
173
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
174
174
  browsers: [],
175
- failures: []
175
+ entries: []
176
176
  };
177
177
  for (const file of files) {
178
178
  const content = await fs2.readFile(file, "utf-8");
@@ -183,7 +183,7 @@ var reportCommand = defineCommand3({
183
183
  merged.skipped += summary.skipped;
184
184
  merged.duration = Math.max(merged.duration, summary.duration);
185
185
  merged.browsers = [.../* @__PURE__ */ new Set([...merged.browsers, ...summary.browsers])];
186
- merged.failures.push(...summary.failures);
186
+ merged.entries.push(...summary.entries);
187
187
  const shardAssetsDir = path3.join(path3.dirname(file), "assets");
188
188
  const destAssetsDir = path3.join(reportDir, "assets");
189
189
  try {
@@ -418,7 +418,7 @@ var uploadCommand = defineCommand6({
418
418
  var main = defineCommand7({
419
419
  meta: {
420
420
  name: "storywright",
421
- version: "0.5.7",
421
+ version: "0.5.9",
422
422
  description: "Zero-config visual regression testing powered by Storybook + Playwright"
423
423
  },
424
424
  subCommands: {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/index.ts","../src/cli/commands/download.ts","../src/cli/commands/init.ts","../src/cli/commands/report.ts","../src/cli/commands/test.ts","../src/cli/commands/update.ts","../src/cli/commands/upload.ts"],"sourcesContent":["import { defineCommand, runMain } from 'citty';\nimport { downloadCommand } from './commands/download.js';\nimport { initCommand } from './commands/init.js';\nimport { reportCommand } from './commands/report.js';\nimport { testCommand } from './commands/test.js';\nimport { updateCommand } from './commands/update.js';\nimport { uploadCommand } from './commands/upload.js';\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'storywright',\n\t\tversion: __PKG_VERSION__,\n\t\tdescription: 'Zero-config visual regression testing powered by Storybook + Playwright',\n\t},\n\tsubCommands: {\n\t\ttest: testCommand,\n\t\tupdate: updateCommand,\n\t\tupload: uploadCommand,\n\t\tdownload: downloadCommand,\n\t\treport: reportCommand,\n\t\tinit: initCommand,\n\t},\n});\n\nrunMain(main);\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { LocalStorageAdapter } from '../../storage/local.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const downloadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'download',\n\t\tdescription: 'Download baselines from storage',\n\t},\n\targs: {\n\t\tbranch: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Branch to download baselines from',\n\t\t\tdefault: 'main',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tconst destDir = path.resolve(config.storage.local.baselineDir);\n\t\tconst branch = args.branch ?? 'main';\n\n\t\tif (storage instanceof LocalStorageAdapter) {\n\t\t\tlogger.start(`Extracting baselines from git branch '${branch}'...`);\n\t\t\ttry {\n\t\t\t\tawait storage.downloadFromGit(branch, destDir, process.cwd());\n\t\t\t\tlogger.success('Baselines extracted from git');\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(String(error));\n\t\t\t\tlogger.info(\n\t\t\t\t\t'Hint: ensure you are in a git repository with sufficient history (fetch-depth: 0)',\n\t\t\t\t);\n\t\t\t\tprocess.exit(2);\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.start(`Downloading baselines from ${branch}...`);\n\t\t\tawait storage.download({ branch, destDir });\n\t\t\tlogger.success('Baselines downloaded');\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { logger } from '../../utils/logger.js';\n\nconst CONFIG_TEMPLATE = `import { defineConfig } from '@storywright/cli';\n\nexport default defineConfig({\n\\t// Storybook settings\n\\tstorybook: {\n\\t\\tstaticDir: 'storybook-static',\n\\t},\n\n\\t// Browsers to test\n\\tbrowsers: ['chromium'],\n\n\\t// Screenshot settings\n\\tscreenshot: {\n\\t\\tfullPage: true,\n\\t\\tanimations: 'disabled',\n\\t\\tthreshold: 0.02,\n\\t\\tmaxDiffPixelRatio: 0.02,\n\\t},\n\n\\t// Storage settings\n\\tstorage: {\n\\t\\tprovider: 'local',\n\\t},\n});\n`;\n\nexport const initCommand = defineCommand({\n\tmeta: {\n\t\tname: 'init',\n\t\tdescription: 'Initialize storywright configuration',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst configPath = path.resolve('storywright.config.ts');\n\t\ttry {\n\t\t\tawait fs.access(configPath);\n\t\t\tlogger.warn('storywright.config.ts already exists');\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, create it\n\t\t}\n\n\t\tawait fs.writeFile(configPath, CONFIG_TEMPLATE);\n\t\tlogger.success('Created storywright.config.ts');\n\n\t\t// Add .storywright temp/report dirs to .gitignore if exists\n\t\t// Note: .storywright/baselines/ should be tracked by git\n\t\tconst gitignorePath = path.resolve('.gitignore');\n\t\ttry {\n\t\t\tconst content = await fs.readFile(gitignorePath, 'utf-8');\n\t\t\tif (!content.includes('.storywright')) {\n\t\t\t\tawait fs.appendFile(\n\t\t\t\t\tgitignorePath,\n\t\t\t\t\t'\\n# Storywright\\n.storywright/tmp/\\n.storywright/report/\\n',\n\t\t\t\t);\n\t\t\t\tlogger.info('Added .storywright/tmp/ and .storywright/report/ to .gitignore');\n\t\t\t}\n\t\t} catch {\n\t\t\t// no .gitignore\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport picomatch from 'picomatch';\nimport { loadConfig } from '../../config/index.js';\nimport type { TestSummary } from '../../core/types.js';\nimport { generateHtmlReport } from '../../playwright/reporter.js';\nimport { logger } from '../../utils/logger.js';\n\nasync function globFiles(pattern: string, cwd: string): Promise<string[]> {\n\tconst matcher = picomatch(pattern);\n\tconst results: string[] = [];\n\n\tasync function walk(dir: string): Promise<void> {\n\t\tconst entries = await fs.readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = path.join(dir, entry.name);\n\t\t\tconst relativePath = path.relative(cwd, fullPath).replace(/\\\\/g, '/');\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(fullPath);\n\t\t\t} else if (matcher(relativePath)) {\n\t\t\t\tresults.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(cwd);\n\treturn results;\n}\n\nexport const reportCommand = defineCommand({\n\tmeta: {\n\t\tname: 'report',\n\t\tdescription: 'Generate or open the report',\n\t},\n\targs: {\n\t\topen: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Open report in browser',\n\t\t\tdefault: false,\n\t\t},\n\t\tmerge: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Merge multiple summary files',\n\t\t\tdefault: false,\n\t\t},\n\t\tfrom: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Glob pattern for summary files to merge',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst reportDir = path.resolve(config.report.outputDir);\n\n\t\tif (args.merge && args.from) {\n\t\t\tlogger.start('Merging reports...');\n\t\t\tconst files = await globFiles(args.from, process.cwd());\n\n\t\t\tconst merged: TestSummary = {\n\t\t\t\ttotal: 0,\n\t\t\t\tpassed: 0,\n\t\t\t\tfailed: 0,\n\t\t\t\tskipped: 0,\n\t\t\t\tduration: 0,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tbrowsers: [],\n\t\t\t\tfailures: [],\n\t\t\t};\n\n\t\t\tfor (const file of files) {\n\t\t\t\tconst content = await fs.readFile(file, 'utf-8');\n\t\t\t\tconst summary: TestSummary = JSON.parse(content);\n\t\t\t\tmerged.total += summary.total;\n\t\t\t\tmerged.passed += summary.passed;\n\t\t\t\tmerged.failed += summary.failed;\n\t\t\t\tmerged.skipped += summary.skipped;\n\t\t\t\tmerged.duration = Math.max(merged.duration, summary.duration);\n\t\t\t\tmerged.browsers = [...new Set([...merged.browsers, ...summary.browsers])];\n\t\t\t\tmerged.failures.push(...summary.failures);\n\n\t\t\t\tconst shardAssetsDir = path.join(path.dirname(file), 'assets');\n\t\t\t\tconst destAssetsDir = path.join(reportDir, 'assets');\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.cp(shardAssetsDir, destAssetsDir, { recursive: true });\n\t\t\t\t} catch {\n\t\t\t\t\t// assets/ が存在しないシャード (全テスト pass) はスキップ\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait fs.mkdir(reportDir, { recursive: true });\n\t\t\tawait fs.writeFile(path.join(reportDir, 'summary.json'), JSON.stringify(merged, null, 2));\n\n\t\t\tconst html = generateHtmlReport(merged);\n\t\t\tawait fs.writeFile(path.join(reportDir, 'index.html'), html);\n\t\t\tlogger.success(`Merged ${files.length} reports → index.html generated`);\n\t\t}\n\n\t\tif (args.open) {\n\t\t\tconst reportPath = path.join(reportDir, 'index.html');\n\t\t\tconst { exec: execCb } = await import('node:child_process');\n\t\t\tconst platform = process.platform;\n\t\t\tconst cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'start' : 'xdg-open';\n\t\t\texecCb(`${cmd} ${reportPath}`);\n\t\t\tlogger.success('Report opened');\n\t\t}\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../../config/types.js';\nimport { runTests } from '../../core/engine.js';\nimport { formatSummary } from '../../reporter/cli-reporter.js';\n\nexport const testCommand = defineCommand({\n\tmeta: {\n\t\tname: 'test',\n\t\tdescription: 'Run visual regression tests',\n\t},\n\targs: {\n\t\tbrowsers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Browsers to test (comma-separated)',\n\t\t},\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard specification (index/total)',\n\t\t},\n\t\t'diff-only': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Only test stories affected by git changes',\n\t\t\tdefault: false,\n\t\t},\n\t\tthreshold: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Pixel color threshold (0-1)',\n\t\t},\n\t\t'max-diff-pixel-ratio': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Maximum diff pixel ratio (0-1)',\n\t\t},\n\t\t'storybook-url': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'URL of running Storybook',\n\t\t},\n\t\t'storybook-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Storybook build directory',\n\t\t},\n\t\t'update-snapshots': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Update baseline snapshots',\n\t\t\tdefault: false,\n\t\t},\n\t\t'full-page': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Take full page screenshots',\n\t\t},\n\t\tworkers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of parallel workers',\n\t\t},\n\t\tretries: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of retries for failed tests',\n\t\t},\n\t\tfilter: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Filter stories by glob pattern',\n\t\t},\n\t\t'output-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Output root directory (.storywright by default)',\n\t\t},\n\t\treporters: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Reporters (comma-separated, e.g. default,html)',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\n\t\tif (args.browsers) {\n\t\t\toverrides.browsers = args.browsers.split(',').map((b) => b.trim());\n\t\t}\n\t\tif (args.threshold) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, threshold: Number(args.threshold) };\n\t\t}\n\t\tif (args['max-diff-pixel-ratio']) {\n\t\t\toverrides.screenshot = {\n\t\t\t\t...overrides.screenshot,\n\t\t\t\tmaxDiffPixelRatio: Number(args['max-diff-pixel-ratio']),\n\t\t\t};\n\t\t}\n\t\tif (args['storybook-url']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, url: args['storybook-url'] };\n\t\t}\n\t\tif (args['storybook-dir']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, staticDir: args['storybook-dir'] };\n\t\t}\n\t\tif (args['full-page'] !== undefined) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, fullPage: args['full-page'] };\n\t\t}\n\t\tif (args.workers) {\n\t\t\toverrides.workers = args.workers === 'auto' ? 'auto' : Number(args.workers);\n\t\t}\n\t\tif (args.retries) {\n\t\t\toverrides.retries = Number(args.retries);\n\t\t}\n\n\t\tconst config = await loadConfig(process.cwd(), overrides);\n\t\tconst result = await runTests(\n\t\t\tconfig,\n\t\t\t{\n\t\t\t\tdiffOnly: args['diff-only'],\n\t\t\t\tshard: args.shard,\n\t\t\t\tupdateSnapshots: args['update-snapshots'],\n\t\t\t\tfilter: args.filter,\n\t\t\t\toutputDir: args['output-dir'],\n\t\t\t\treporters: args.reporters?.split(',').map((r) => r.trim()),\n\t\t\t},\n\t\t\tprocess.cwd(),\n\t\t);\n\n\t\tif (result.summary) {\n\t\t\tconst reportPath = result.reportDir ? `${result.reportDir}/index.html` : undefined;\n\t\t\tconsole.log(formatSummary(result.summary, { reportPath }));\n\t\t}\n\n\t\tprocess.exit(result.exitCode);\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../../config/types.js';\nimport { updateBaselines } from '../../core/engine.js';\n\nexport const updateCommand = defineCommand({\n\tmeta: {\n\t\tname: 'update',\n\t\tdescription: 'Update baseline snapshots',\n\t},\n\targs: {\n\t\tall: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Regenerate all baselines',\n\t\t\tdefault: false,\n\t\t},\n\t\tupload: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Upload baselines after update',\n\t\t\tdefault: false,\n\t\t},\n\t\tbrowsers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Browsers to test (comma-separated)',\n\t\t},\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard specification (index/total)',\n\t\t},\n\t\tworkers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of parallel workers',\n\t\t},\n\t\tfilter: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Filter stories by glob pattern',\n\t\t},\n\t\tretries: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of retries for failed tests',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\n\t\tif (args.browsers) {\n\t\t\toverrides.browsers = args.browsers.split(',').map((b) => b.trim());\n\t\t}\n\t\tif (args.workers) {\n\t\t\toverrides.workers = args.workers === 'auto' ? 'auto' : Number(args.workers);\n\t\t}\n\t\tif (args.retries) {\n\t\t\toverrides.retries = Number(args.retries);\n\t\t}\n\n\t\tconst config = await loadConfig(process.cwd(), overrides);\n\t\tconst result = await updateBaselines(config, {\n\t\t\tall: args.all,\n\t\t\tupload: args.upload,\n\t\t\tshard: args.shard,\n\t\t\tfilter: args.filter,\n\t\t});\n\n\t\tprocess.exit(result.exitCode);\n\t},\n});\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const uploadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'upload',\n\t\tdescription: 'Upload baselines to remote storage',\n\t},\n\targs: {\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard identifier (e.g. \"1/3\")',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tconst snapshotDir = path.resolve(config.storage.local.baselineDir);\n\n\t\tlogger.start('Uploading baselines...');\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: snapshotDir,\n\t\t\tshard: args.shard,\n\t\t});\n\t\tlogger.success('Baselines uploaded');\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,iBAAAA,gBAAe,eAAe;;;ACAvC,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAMvB,IAAM,kBAAkB,cAAc;AAAA,EAC5C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACL,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACV;AAAA,EACD;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AACnB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,MAAM,qBAAqB,OAAO,OAAO;AACzD,UAAM,UAAU,KAAK,QAAQ,OAAO,QAAQ,MAAM,WAAW;AAC7D,UAAM,SAAS,KAAK,UAAU;AAE9B,QAAI,mBAAmB,qBAAqB;AAC3C,aAAO,MAAM,yCAAyC,MAAM,MAAM;AAClE,UAAI;AACH,cAAM,QAAQ,gBAAgB,QAAQ,SAAS,QAAQ,IAAI,CAAC;AAC5D,eAAO,QAAQ,8BAA8B;AAAA,MAC9C,SAAS,OAAO;AACf,eAAO,MAAM,OAAO,KAAK,CAAC;AAC1B,eAAO;AAAA,UACN;AAAA,QACD;AACA,gBAAQ,KAAK,CAAC;AAAA,MACf;AAAA,IACD,OAAO;AACN,aAAO,MAAM,8BAA8B,MAAM,KAAK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KAAK;AAAA,MACZ,QAAQ,KAAK;AAAA,IACd,CAAC;AAED,YAAQ,KAAK,OAAO,QAAQ;AAAA,EAC7B;AACD,CAAC;;;ACjED,OAAOC,WAAU;AACjB,SAAS,iBAAAC,sBAAqB;AAKvB,IAAM,gBAAgBC,eAAc;AAAA,EAC1C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACL,OAAO;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AACnB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,MAAM,qBAAqB,OAAO,OAAO;AACzD,UAAM,cAAcC,MAAK,QAAQ,OAAO,QAAQ,MAAM,WAAW;AAEjE,WAAO,MAAM,wBAAwB;AACrC,UAAM,QAAQ,OAAO;AAAA,MACpB,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,OAAO,KAAK;AAAA,IACb,CAAC;AACD,WAAO,QAAQ,oBAAoB;AAAA,EACpC;AACD,CAAC;;;ANtBD,IAAM,OAAOC,eAAc;AAAA,EAC1B,MAAM;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACD,CAAC;AAED,QAAQ,IAAI;","names":["defineCommand","path","defineCommand","defineCommand","path","fs","path","defineCommand","fs","path","defineCommand","defineCommand","defineCommand","defineCommand","defineCommand","path","defineCommand","defineCommand","path","defineCommand"]}
1
+ {"version":3,"sources":["../src/cli/index.ts","../src/cli/commands/download.ts","../src/cli/commands/init.ts","../src/cli/commands/report.ts","../src/cli/commands/test.ts","../src/cli/commands/update.ts","../src/cli/commands/upload.ts"],"sourcesContent":["import { defineCommand, runMain } from 'citty';\nimport { downloadCommand } from './commands/download.js';\nimport { initCommand } from './commands/init.js';\nimport { reportCommand } from './commands/report.js';\nimport { testCommand } from './commands/test.js';\nimport { updateCommand } from './commands/update.js';\nimport { uploadCommand } from './commands/upload.js';\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'storywright',\n\t\tversion: __PKG_VERSION__,\n\t\tdescription: 'Zero-config visual regression testing powered by Storybook + Playwright',\n\t},\n\tsubCommands: {\n\t\ttest: testCommand,\n\t\tupdate: updateCommand,\n\t\tupload: uploadCommand,\n\t\tdownload: downloadCommand,\n\t\treport: reportCommand,\n\t\tinit: initCommand,\n\t},\n});\n\nrunMain(main);\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { LocalStorageAdapter } from '../../storage/local.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const downloadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'download',\n\t\tdescription: 'Download baselines from storage',\n\t},\n\targs: {\n\t\tbranch: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Branch to download baselines from',\n\t\t\tdefault: 'main',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tconst destDir = path.resolve(config.storage.local.baselineDir);\n\t\tconst branch = args.branch ?? 'main';\n\n\t\tif (storage instanceof LocalStorageAdapter) {\n\t\t\tlogger.start(`Extracting baselines from git branch '${branch}'...`);\n\t\t\ttry {\n\t\t\t\tawait storage.downloadFromGit(branch, destDir, process.cwd());\n\t\t\t\tlogger.success('Baselines extracted from git');\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(String(error));\n\t\t\t\tlogger.info(\n\t\t\t\t\t'Hint: ensure you are in a git repository with sufficient history (fetch-depth: 0)',\n\t\t\t\t);\n\t\t\t\tprocess.exit(2);\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.start(`Downloading baselines from ${branch}...`);\n\t\t\tawait storage.download({ branch, destDir });\n\t\t\tlogger.success('Baselines downloaded');\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { logger } from '../../utils/logger.js';\n\nconst CONFIG_TEMPLATE = `import { defineConfig } from '@storywright/cli';\n\nexport default defineConfig({\n\\t// Storybook settings\n\\tstorybook: {\n\\t\\tstaticDir: 'storybook-static',\n\\t},\n\n\\t// Browsers to test\n\\tbrowsers: ['chromium'],\n\n\\t// Screenshot settings\n\\tscreenshot: {\n\\t\\tfullPage: true,\n\\t\\tanimations: 'disabled',\n\\t\\tthreshold: 0.02,\n\\t\\tmaxDiffPixelRatio: 0.02,\n\\t},\n\n\\t// Storage settings\n\\tstorage: {\n\\t\\tprovider: 'local',\n\\t},\n});\n`;\n\nexport const initCommand = defineCommand({\n\tmeta: {\n\t\tname: 'init',\n\t\tdescription: 'Initialize storywright configuration',\n\t},\n\targs: {},\n\tasync run() {\n\t\tconst configPath = path.resolve('storywright.config.ts');\n\t\ttry {\n\t\t\tawait fs.access(configPath);\n\t\t\tlogger.warn('storywright.config.ts already exists');\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// file doesn't exist, create it\n\t\t}\n\n\t\tawait fs.writeFile(configPath, CONFIG_TEMPLATE);\n\t\tlogger.success('Created storywright.config.ts');\n\n\t\t// Add .storywright temp/report dirs to .gitignore if exists\n\t\t// Note: .storywright/baselines/ should be tracked by git\n\t\tconst gitignorePath = path.resolve('.gitignore');\n\t\ttry {\n\t\t\tconst content = await fs.readFile(gitignorePath, 'utf-8');\n\t\t\tif (!content.includes('.storywright')) {\n\t\t\t\tawait fs.appendFile(\n\t\t\t\t\tgitignorePath,\n\t\t\t\t\t'\\n# Storywright\\n.storywright/tmp/\\n.storywright/report/\\n',\n\t\t\t\t);\n\t\t\t\tlogger.info('Added .storywright/tmp/ and .storywright/report/ to .gitignore');\n\t\t\t}\n\t\t} catch {\n\t\t\t// no .gitignore\n\t\t}\n\t},\n});\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { defineCommand } from 'citty';\nimport picomatch from 'picomatch';\nimport { loadConfig } from '../../config/index.js';\nimport type { TestSummary } from '../../core/types.js';\nimport { generateHtmlReport } from '../../playwright/reporter.js';\nimport { logger } from '../../utils/logger.js';\n\nasync function globFiles(pattern: string, cwd: string): Promise<string[]> {\n\tconst matcher = picomatch(pattern);\n\tconst results: string[] = [];\n\n\tasync function walk(dir: string): Promise<void> {\n\t\tconst entries = await fs.readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = path.join(dir, entry.name);\n\t\t\tconst relativePath = path.relative(cwd, fullPath).replace(/\\\\/g, '/');\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(fullPath);\n\t\t\t} else if (matcher(relativePath)) {\n\t\t\t\tresults.push(fullPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tawait walk(cwd);\n\treturn results;\n}\n\nexport const reportCommand = defineCommand({\n\tmeta: {\n\t\tname: 'report',\n\t\tdescription: 'Generate or open the report',\n\t},\n\targs: {\n\t\topen: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Open report in browser',\n\t\t\tdefault: false,\n\t\t},\n\t\tmerge: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Merge multiple summary files',\n\t\t\tdefault: false,\n\t\t},\n\t\tfrom: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Glob pattern for summary files to merge',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst reportDir = path.resolve(config.report.outputDir);\n\n\t\tif (args.merge && args.from) {\n\t\t\tlogger.start('Merging reports...');\n\t\t\tconst files = await globFiles(args.from, process.cwd());\n\n\t\t\tconst merged: TestSummary = {\n\t\t\t\ttotal: 0,\n\t\t\t\tpassed: 0,\n\t\t\t\tfailed: 0,\n\t\t\t\tskipped: 0,\n\t\t\t\tduration: 0,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tbrowsers: [],\n\t\t\t\tentries: [],\n\t\t\t};\n\n\t\t\tfor (const file of files) {\n\t\t\t\tconst content = await fs.readFile(file, 'utf-8');\n\t\t\t\tconst summary: TestSummary = JSON.parse(content);\n\t\t\t\tmerged.total += summary.total;\n\t\t\t\tmerged.passed += summary.passed;\n\t\t\t\tmerged.failed += summary.failed;\n\t\t\t\tmerged.skipped += summary.skipped;\n\t\t\t\tmerged.duration = Math.max(merged.duration, summary.duration);\n\t\t\t\tmerged.browsers = [...new Set([...merged.browsers, ...summary.browsers])];\n\t\t\t\tmerged.entries.push(...summary.entries);\n\n\t\t\t\tconst shardAssetsDir = path.join(path.dirname(file), 'assets');\n\t\t\t\tconst destAssetsDir = path.join(reportDir, 'assets');\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.cp(shardAssetsDir, destAssetsDir, { recursive: true });\n\t\t\t\t} catch {\n\t\t\t\t\t// assets/ が存在しないシャード (全テスト pass) はスキップ\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait fs.mkdir(reportDir, { recursive: true });\n\t\t\tawait fs.writeFile(path.join(reportDir, 'summary.json'), JSON.stringify(merged, null, 2));\n\n\t\t\tconst html = generateHtmlReport(merged);\n\t\t\tawait fs.writeFile(path.join(reportDir, 'index.html'), html);\n\t\t\tlogger.success(`Merged ${files.length} reports → index.html generated`);\n\t\t}\n\n\t\tif (args.open) {\n\t\t\tconst reportPath = path.join(reportDir, 'index.html');\n\t\t\tconst { exec: execCb } = await import('node:child_process');\n\t\t\tconst platform = process.platform;\n\t\t\tconst cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'start' : 'xdg-open';\n\t\t\texecCb(`${cmd} ${reportPath}`);\n\t\t\tlogger.success('Report opened');\n\t\t}\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../../config/types.js';\nimport { runTests } from '../../core/engine.js';\nimport { formatSummary } from '../../reporter/cli-reporter.js';\n\nexport const testCommand = defineCommand({\n\tmeta: {\n\t\tname: 'test',\n\t\tdescription: 'Run visual regression tests',\n\t},\n\targs: {\n\t\tbrowsers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Browsers to test (comma-separated)',\n\t\t},\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard specification (index/total)',\n\t\t},\n\t\t'diff-only': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Only test stories affected by git changes',\n\t\t\tdefault: false,\n\t\t},\n\t\tthreshold: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Pixel color threshold (0-1)',\n\t\t},\n\t\t'max-diff-pixel-ratio': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Maximum diff pixel ratio (0-1)',\n\t\t},\n\t\t'storybook-url': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'URL of running Storybook',\n\t\t},\n\t\t'storybook-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Storybook build directory',\n\t\t},\n\t\t'update-snapshots': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Update baseline snapshots',\n\t\t\tdefault: false,\n\t\t},\n\t\t'full-page': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Take full page screenshots',\n\t\t},\n\t\tworkers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of parallel workers',\n\t\t},\n\t\tretries: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of retries for failed tests',\n\t\t},\n\t\tfilter: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Filter stories by glob pattern',\n\t\t},\n\t\t'output-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Output root directory (.storywright by default)',\n\t\t},\n\t\treporters: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Reporters (comma-separated, e.g. default,html)',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\n\t\tif (args.browsers) {\n\t\t\toverrides.browsers = args.browsers.split(',').map((b) => b.trim());\n\t\t}\n\t\tif (args.threshold) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, threshold: Number(args.threshold) };\n\t\t}\n\t\tif (args['max-diff-pixel-ratio']) {\n\t\t\toverrides.screenshot = {\n\t\t\t\t...overrides.screenshot,\n\t\t\t\tmaxDiffPixelRatio: Number(args['max-diff-pixel-ratio']),\n\t\t\t};\n\t\t}\n\t\tif (args['storybook-url']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, url: args['storybook-url'] };\n\t\t}\n\t\tif (args['storybook-dir']) {\n\t\t\toverrides.storybook = { ...overrides.storybook, staticDir: args['storybook-dir'] };\n\t\t}\n\t\tif (args['full-page'] !== undefined) {\n\t\t\toverrides.screenshot = { ...overrides.screenshot, fullPage: args['full-page'] };\n\t\t}\n\t\tif (args.workers) {\n\t\t\toverrides.workers = args.workers === 'auto' ? 'auto' : Number(args.workers);\n\t\t}\n\t\tif (args.retries) {\n\t\t\toverrides.retries = Number(args.retries);\n\t\t}\n\n\t\tconst config = await loadConfig(process.cwd(), overrides);\n\t\tconst result = await runTests(\n\t\t\tconfig,\n\t\t\t{\n\t\t\t\tdiffOnly: args['diff-only'],\n\t\t\t\tshard: args.shard,\n\t\t\t\tupdateSnapshots: args['update-snapshots'],\n\t\t\t\tfilter: args.filter,\n\t\t\t\toutputDir: args['output-dir'],\n\t\t\t\treporters: args.reporters?.split(',').map((r) => r.trim()),\n\t\t\t},\n\t\t\tprocess.cwd(),\n\t\t);\n\n\t\tif (result.summary) {\n\t\t\tconst reportPath = result.reportDir ? `${result.reportDir}/index.html` : undefined;\n\t\t\tconsole.log(formatSummary(result.summary, { reportPath }));\n\t\t}\n\n\t\tprocess.exit(result.exitCode);\n\t},\n});\n","import { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport type { DeepPartial, StorywrightConfig } from '../../config/types.js';\nimport { updateBaselines } from '../../core/engine.js';\n\nexport const updateCommand = defineCommand({\n\tmeta: {\n\t\tname: 'update',\n\t\tdescription: 'Update baseline snapshots',\n\t},\n\targs: {\n\t\tall: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Regenerate all baselines',\n\t\t\tdefault: false,\n\t\t},\n\t\tupload: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Upload baselines after update',\n\t\t\tdefault: false,\n\t\t},\n\t\tbrowsers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Browsers to test (comma-separated)',\n\t\t},\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard specification (index/total)',\n\t\t},\n\t\tworkers: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of parallel workers',\n\t\t},\n\t\tfilter: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Filter stories by glob pattern',\n\t\t},\n\t\tretries: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Number of retries for failed tests',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst overrides: DeepPartial<StorywrightConfig> = {};\n\n\t\tif (args.browsers) {\n\t\t\toverrides.browsers = args.browsers.split(',').map((b) => b.trim());\n\t\t}\n\t\tif (args.workers) {\n\t\t\toverrides.workers = args.workers === 'auto' ? 'auto' : Number(args.workers);\n\t\t}\n\t\tif (args.retries) {\n\t\t\toverrides.retries = Number(args.retries);\n\t\t}\n\n\t\tconst config = await loadConfig(process.cwd(), overrides);\n\t\tconst result = await updateBaselines(config, {\n\t\t\tall: args.all,\n\t\t\tupload: args.upload,\n\t\t\tshard: args.shard,\n\t\t\tfilter: args.filter,\n\t\t});\n\n\t\tprocess.exit(result.exitCode);\n\t},\n});\n","import path from 'node:path';\nimport { defineCommand } from 'citty';\nimport { loadConfig } from '../../config/index.js';\nimport { createStorageAdapter } from '../../storage/index.js';\nimport { logger } from '../../utils/logger.js';\n\nexport const uploadCommand = defineCommand({\n\tmeta: {\n\t\tname: 'upload',\n\t\tdescription: 'Upload baselines to remote storage',\n\t},\n\targs: {\n\t\tshard: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Shard identifier (e.g. \"1/3\")',\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst config = await loadConfig();\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tconst snapshotDir = path.resolve(config.storage.local.baselineDir);\n\n\t\tlogger.start('Uploading baselines...');\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: snapshotDir,\n\t\t\tshard: args.shard,\n\t\t});\n\t\tlogger.success('Baselines uploaded');\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,iBAAAA,gBAAe,eAAe;;;ACAvC,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAMvB,IAAM,kBAAkB,cAAc;AAAA,EAC5C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACL,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACV;AAAA,EACD;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AACnB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,MAAM,qBAAqB,OAAO,OAAO;AACzD,UAAM,UAAU,KAAK,QAAQ,OAAO,QAAQ,MAAM,WAAW;AAC7D,UAAM,SAAS,KAAK,UAAU;AAE9B,QAAI,mBAAmB,qBAAqB;AAC3C,aAAO,MAAM,yCAAyC,MAAM,MAAM;AAClE,UAAI;AACH,cAAM,QAAQ,gBAAgB,QAAQ,SAAS,QAAQ,IAAI,CAAC;AAC5D,eAAO,QAAQ,8BAA8B;AAAA,MAC9C,SAAS,OAAO;AACf,eAAO,MAAM,OAAO,KAAK,CAAC;AAC1B,eAAO;AAAA,UACN;AAAA,QACD;AACA,gBAAQ,KAAK,CAAC;AAAA,MACf;AAAA,IACD,OAAO;AAC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ACV,QAAQ,KAAK;AAAA,MACb,OAAO,KAAK;AAAA,MACZ,QAAQ,KAAK;AAAA,IACd,CAAC;AAED,YAAQ,KAAK,OAAO,QAAQ;AAAA,EAC7B;AACD,CAAC;;;ACjED,OAAOC,WAAU;AACjB,SAAS,iBAAAC,sBAAqB;AAKvB,IAAM,gBAAgBC,eAAc;AAAA,EAC1C,MAAM;AAAA,IACL,MAAM;AAAA,IACN,aAAa;AAAA,EACd;AAAA,EACA,MAAM;AAAA,IACL,OAAO;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EACA,MAAM,IAAI,EAAE,KAAK,GAAG;AACnB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,MAAM,qBAAqB,OAAO,OAAO;AACzD,UAAM,cAAcC,MAAK,QAAQ,OAAO,QAAQ,MAAM,WAAW;AAEjE,WAAO,MAAM,wBAAwB;AACrC,UAAM,QAAQ,OAAO;AAAA,MACpB,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,OAAO,KAAK;AAAA,IACb,CAAC;AACD,WAAO,QAAQ,oBAAoB;AAAA,EACpC;AACD,CAAC;;;ANtBD,IAAM,OAAOC,eAAc;AAAA,EAC1B,MAAM;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA,aAAa;AAAA,IACZ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM;AAAA,EACP;AACD,CAAC;AAED,QAAQ,IAAI;","names":["defineCommand","path","defineCommand","defineCommand","path","fs","path","defineCommand","fs","path","defineCommand","defineCommand","defineCommand","defineCommand","defineCommand","path","defineCommand","defineCommand","path","defineCommand"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Page } from '@playwright/test';
2
- import { T as TestSummary, a as TestResult } from './types-DqV0YrhZ.js';
3
- export { F as FailureEntry, S as Story, b as StoryIndex } from './types-DqV0YrhZ.js';
2
+ import { T as TestSummary, a as TestResult } from './types-mURj8eeS.js';
3
+ export { S as Story, b as StoryIndex, c as TestEntry } from './types-mURj8eeS.js';
4
4
 
5
5
  interface StorywrightConfig {
6
6
  storybook: StorybookConfig;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  loadConfig,
7
7
  runTests,
8
8
  updateBaselines
9
- } from "./chunk-2HQSZU3R.js";
9
+ } from "./chunk-XAQTUCH5.js";
10
10
 
11
11
  // src/core/index.ts
12
12
  import path from "path";
@@ -1,5 +1,5 @@
1
1
  import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
2
- import { T as TestSummary } from '../types-DqV0YrhZ.js';
2
+ import { T as TestSummary } from '../types-mURj8eeS.js';
3
3
 
4
4
  interface StorywrightReporterOptions {
5
5
  outputDir?: string;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  generateHtmlReport,
3
3
  reporter_default
4
- } from "../chunk-HPK2VJXG.js";
4
+ } from "../chunk-JDHVDQIC.js";
5
5
  export {
6
6
  reporter_default as default,
7
7
  generateHtmlReport
@@ -0,0 +1,19 @@
1
+ import { Page } from '@playwright/test';
2
+
3
+ interface StabilizeOptions {
4
+ freezeTime: string;
5
+ seed: number;
6
+ disableAnimations: boolean;
7
+ }
8
+ /**
9
+ * Pre-navigation page setup for reproducible screenshots.
10
+ * Must be called BEFORE page.goto().
11
+ */
12
+ declare function initPage(page: Page, options: StabilizeOptions): Promise<void>;
13
+ /**
14
+ * Post-navigation page stabilization for reproducible screenshots.
15
+ * Must be called AFTER page.goto() has resolved.
16
+ */
17
+ declare function stabilizePage(page: Page, options: StabilizeOptions): Promise<void>;
18
+
19
+ export { type StabilizeOptions, initPage, stabilizePage };
@@ -0,0 +1,74 @@
1
+ // src/playwright/stabilize.ts
2
+ async function initPage(page, options) {
3
+ await page.clock.install({ time: new Date(options.freezeTime) });
4
+ await page.addInitScript((seed) => {
5
+ let s = seed;
6
+ Math.random = () => {
7
+ s = (s * 16807 + 0) % 2147483647;
8
+ return (s - 1) / 2147483646;
9
+ };
10
+ }, options.seed);
11
+ }
12
+ async function stabilizePage(page, options) {
13
+ if (options.disableAnimations) {
14
+ await page.addStyleTag({
15
+ content: "*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }"
16
+ });
17
+ }
18
+ await page.waitForFunction(
19
+ () => {
20
+ const root = document.getElementById("storybook-root");
21
+ if (!root) return false;
22
+ if (root.childElementCount > 0) return true;
23
+ for (const el of document.body.children) {
24
+ if (el.tagName === "SCRIPT" || el.id === "storybook-root" || el.id === "storybook-docs")
25
+ continue;
26
+ return true;
27
+ }
28
+ return false;
29
+ },
30
+ { timeout: 1e4 }
31
+ );
32
+ await page.waitForFunction(() => document.fonts.ready);
33
+ await page.waitForFunction(
34
+ () => new Promise((resolve) => {
35
+ let count = 0;
36
+ const tick = () => {
37
+ if (++count >= 3) return resolve(true);
38
+ requestAnimationFrame(tick);
39
+ };
40
+ requestAnimationFrame(tick);
41
+ })
42
+ );
43
+ await page.evaluate(async () => {
44
+ const lazyImages = document.querySelectorAll('img[loading="lazy"]');
45
+ for (const img of lazyImages) {
46
+ img.loading = "eager";
47
+ }
48
+ const images = Array.from(document.images).filter((img) => !img.complete);
49
+ await Promise.all(
50
+ images.map(
51
+ (img) => new Promise((resolve) => {
52
+ const timeout = setTimeout(resolve, 5e3);
53
+ img.onload = img.onerror = () => {
54
+ clearTimeout(timeout);
55
+ resolve();
56
+ };
57
+ })
58
+ )
59
+ );
60
+ });
61
+ if (options.disableAnimations) {
62
+ await page.evaluate(() => {
63
+ for (const img of document.querySelectorAll("img")) {
64
+ img.style.setProperty("opacity", "1", "important");
65
+ }
66
+ });
67
+ }
68
+ await page.waitForTimeout(200);
69
+ }
70
+ export {
71
+ initPage,
72
+ stabilizePage
73
+ };
74
+ //# sourceMappingURL=stabilize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/playwright/stabilize.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n/// <reference lib=\"dom.iterable\" />\nimport type { Page } from '@playwright/test';\n\nexport interface StabilizeOptions {\n\tfreezeTime: string;\n\tseed: number;\n\tdisableAnimations: boolean;\n}\n\n/**\n * Pre-navigation page setup for reproducible screenshots.\n * Must be called BEFORE page.goto().\n */\nexport async function initPage(page: Page, options: StabilizeOptions): Promise<void> {\n\tawait page.clock.install({ time: new Date(options.freezeTime) });\n\n\tawait page.addInitScript((seed: number) => {\n\t\tlet s = seed;\n\t\tMath.random = () => {\n\t\t\ts = (s * 16807 + 0) % 2147483647;\n\t\t\treturn (s - 1) / 2147483646;\n\t\t};\n\t}, options.seed);\n}\n\n/**\n * Post-navigation page stabilization for reproducible screenshots.\n * Must be called AFTER page.goto() has resolved.\n */\nexport async function stabilizePage(page: Page, options: StabilizeOptions): Promise<void> {\n\tif (options.disableAnimations) {\n\t\tawait page.addStyleTag({\n\t\t\tcontent:\n\t\t\t\t'*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }',\n\t\t});\n\t}\n\n\t// Wait for story to render: content inside #storybook-root OR portal content on body\n\tawait page.waitForFunction(\n\t\t() => {\n\t\t\tconst root = document.getElementById('storybook-root');\n\t\t\tif (!root) return false;\n\t\t\tif (root.childElementCount > 0) return true;\n\t\t\tfor (const el of document.body.children) {\n\t\t\t\tif (el.tagName === 'SCRIPT' || el.id === 'storybook-root' || el.id === 'storybook-docs')\n\t\t\t\t\tcontinue;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\t{ timeout: 10000 },\n\t);\n\n\t// Wait for web fonts to finish loading\n\tawait page.waitForFunction(() => document.fonts.ready);\n\n\t// Allow async renders to settle (multiple animation frames)\n\t// This must run BEFORE image checks so the framework has finished adding\n\t// all <img> elements to the DOM\n\tawait page.waitForFunction(\n\t\t() =>\n\t\t\tnew Promise((resolve) => {\n\t\t\t\tlet count = 0;\n\t\t\t\tconst tick = () => {\n\t\t\t\t\tif (++count >= 3) return resolve(true);\n\t\t\t\t\trequestAnimationFrame(tick);\n\t\t\t\t};\n\t\t\t\trequestAnimationFrame(tick);\n\t\t\t}),\n\t);\n\n\t// Force lazy-loaded images to eager and wait for load\n\tawait page.evaluate(async () => {\n\t\tconst lazyImages = document.querySelectorAll('img[loading=\"lazy\"]');\n\t\tfor (const img of lazyImages) {\n\t\t\t(img as HTMLImageElement).loading = 'eager';\n\t\t}\n\n\t\tconst images = Array.from(document.images).filter((img) => !img.complete);\n\t\tawait Promise.all(\n\t\t\timages.map(\n\t\t\t\t(img) =>\n\t\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\t\tconst timeout = setTimeout(resolve, 5000);\n\t\t\t\t\t\timg.onload = img.onerror = () => {\n\t\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t});\n\n\tif (options.disableAnimations) {\n\t\tawait page.evaluate(() => {\n\t\t\tfor (const img of document.querySelectorAll('img')) {\n\t\t\t\timg.style.setProperty('opacity', '1', 'important');\n\t\t\t}\n\t\t});\n\t}\n\n\t// Final stabilization delay for layout shifts\n\tawait page.waitForTimeout(200);\n}\n"],"mappings":";AAcA,eAAsB,SAAS,MAAY,SAA0C;AACpF,QAAM,KAAK,MAAM,QAAQ,EAAE,MAAM,IAAI,KAAK,QAAQ,UAAU,EAAE,CAAC;AAE/D,QAAM,KAAK,cAAc,CAAC,SAAiB;AAC1C,QAAI,IAAI;AACR,SAAK,SAAS,MAAM;AACnB,WAAK,IAAI,QAAQ,KAAK;AACtB,cAAQ,IAAI,KAAK;AAAA,IAClB;AAAA,EACD,GAAG,QAAQ,IAAI;AAChB;AAMA,eAAsB,cAAc,MAAY,SAA0C;AACzF,MAAI,QAAQ,mBAAmB;AAC9B,U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,SAAS,iBAAiB,KAAK,GAAG;AACnD,YAAI,MAAM,YAAY,WAAW,KAAK,WAAW;AAAA,MAClD;AAAA,IACD,CAAC;AAAA,EACF;AAGA,QAAM,KAAK,eAAe,GAAG;AAC9B;","names":[]}
@@ -29,10 +29,10 @@ interface TestSummary {
29
29
  duration: number;
30
30
  timestamp: string;
31
31
  browsers: string[];
32
- failures: FailureEntry[];
32
+ entries: TestEntry[];
33
33
  }
34
- interface FailureEntry {
35
- type: 'diff' | 'new';
34
+ interface TestEntry {
35
+ type: 'diff' | 'new' | 'pass';
36
36
  story: string;
37
37
  variant: string;
38
38
  browser: string;
@@ -42,4 +42,4 @@ interface FailureEntry {
42
42
  diff: string;
43
43
  }
44
44
 
45
- export type { FailureEntry as F, Story as S, TestSummary as T, TestResult as a, StoryIndex as b };
45
+ export type { Story as S, TestSummary as T, TestResult as a, StoryIndex as b, TestEntry as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storywright/cli",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "description": "Zero-config visual regression testing powered by Storybook + Playwright",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -15,6 +15,10 @@
15
15
  "./playwright/reporter": {
16
16
  "import": "./dist/playwright/reporter.js",
17
17
  "types": "./dist/playwright/reporter.d.ts"
18
+ },
19
+ "./playwright/stabilize": {
20
+ "import": "./dist/playwright/stabilize.js",
21
+ "types": "./dist/playwright/stabilize.d.ts"
18
22
  }
19
23
  },
20
24
  "files": [
@@ -31,7 +35,7 @@
31
35
  "simple-git": "^3.27.0",
32
36
  "unconfig": "^0.6.0",
33
37
  "picomatch": "^4.0.2",
34
- "@storywright/report": "0.5.0"
38
+ "@storywright/report": "0.5.9"
35
39
  },
36
40
  "devDependencies": {
37
41
  "@playwright/test": "^1.50.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/config/index.ts","../src/config/defaults.ts","../src/config/types.ts","../src/reporter/cli-reporter.ts","../src/storage/local.ts","../src/storage/index.ts","../src/utils/logger.ts","../src/core/engine.ts","../src/playwright/config-generator.ts","../src/playwright/test-generator.ts","../src/resolver/index.ts","../src/utils/path.ts","../src/utils/process.ts","../src/core/storybook.ts"],"sourcesContent":["import { loadConfig as unconfigLoad } from 'unconfig';\nimport { DEFAULT_CONFIG } from './defaults.js';\nimport { STANDARD_BROWSERS } from './types.js';\nimport type { DeepPartial, StorywrightConfig } from './types.js';\n\nexport function defineConfig(\n\tconfig: DeepPartial<StorywrightConfig>,\n): DeepPartial<StorywrightConfig> {\n\treturn config;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction deepMerge(\n\ttarget: Record<string, unknown>,\n\tsource: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst result: Record<string, unknown> = { ...target };\n\tfor (const key of Object.keys(source)) {\n\t\tconst sourceVal = source[key];\n\t\tconst targetVal = result[key];\n\t\tif (isPlainObject(sourceVal) && isPlainObject(targetVal)) {\n\t\t\tresult[key] = deepMerge(targetVal, sourceVal);\n\t\t} else if (sourceVal !== undefined) {\n\t\t\tresult[key] = sourceVal;\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function loadConfig(\n\tcwd: string = process.cwd(),\n\toverrides?: DeepPartial<StorywrightConfig>,\n): Promise<StorywrightConfig> {\n\tconst { config: userConfig } = await unconfigLoad<DeepPartial<StorywrightConfig>>({\n\t\tsources: [\n\t\t\t{\n\t\t\t\tfiles: 'storywright.config',\n\t\t\t\textensions: ['ts', 'js', 'mjs'],\n\t\t\t},\n\t\t],\n\t\tcwd,\n\t});\n\n\tlet merged = DEFAULT_CONFIG as unknown as Record<string, unknown>;\n\tif (userConfig) {\n\t\tmerged = deepMerge(merged, userConfig as Record<string, unknown>);\n\t}\n\tif (overrides) {\n\t\tmerged = deepMerge(merged, overrides as Record<string, unknown>);\n\t}\n\tconst result = merged as unknown as StorywrightConfig;\n\tvalidateConfig(result);\n\treturn result;\n}\n\nfunction validateConfig(config: StorywrightConfig): void {\n\tfor (const browser of config.browsers) {\n\t\tconst options = config.browserOptions[browser];\n\n\t\tif (!STANDARD_BROWSERS.has(browser) && !options?.browserName) {\n\t\t\tthrow new Error(\n\t\t\t\t`Custom browser project '${browser}' requires 'browserName' in browserOptions.\\nExample:\\n browserOptions: {\\n '${browser}': { browserName: 'webkit', ... }\\n }\\nValid browserName values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_MISSING_BROWSER_NAME`,\n\t\t\t);\n\t\t}\n\n\t\tif (options?.browserName && !STANDARD_BROWSERS.has(options.browserName)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid browserName '${options.browserName}' for browser project '${browser}'.\\nValid values: 'chromium', 'firefox', 'webkit'.\\n\\nError code: SW_E_INVALID_BROWSER_NAME`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport type { StorywrightConfig, DeepPartial } from './types.js';\n","import type { StorywrightConfig } from './types.js';\n\nexport const DEFAULT_CONFIG: StorywrightConfig = {\n\tstorybook: {\n\t\tstaticDir: 'storybook-static',\n\t\tbuildCommand: 'npx storybook build --stats-json',\n\t\turl: undefined,\n\t\tcompatibility: 'auto',\n\t},\n\n\tbrowsers: ['chromium'],\n\tbrowserOptions: {},\n\n\tscreenshot: {\n\t\tfullPage: true,\n\t\tanimations: 'disabled',\n\t\tthreshold: 0.02,\n\t\tmaxDiffPixelRatio: 0.02,\n\t\tfreezeTime: '2024-01-01T00:00:00',\n\t\ttimezone: 'UTC',\n\t\tlocale: 'en-US',\n\t\tseed: 1,\n\t},\n\n\tdiffDetection: {\n\t\tenabled: true,\n\t\twatchFiles: ['package.json', 'package-lock.json', '.storybook/**/*'],\n\t\tbaseBranch: 'main',\n\t},\n\n\tstorage: {\n\t\tprovider: 'local',\n\t\tlocal: {\n\t\t\tbaselineDir: '.storywright/baselines',\n\t\t},\n\t\ts3: {\n\t\t\tbucket: '',\n\t\t\tprefix: 'storywright/baselines',\n\t\t\tregion: 'ap-northeast-1',\n\t\t\tcompression: 'zstd',\n\t\t},\n\t},\n\n\treport: {\n\t\toutputDir: '.storywright/report',\n\t\ttitle: 'Storywright Report',\n\t},\n\n\tworkers: 'auto',\n\tretries: 0,\n\n\ttimeout: {\n\t\ttest: 30000,\n\t\tnavigation: 20000,\n\t\texpect: 10000,\n\t},\n\n\tinclude: ['**'],\n\texclude: [],\n\n\thooks: {},\n};\n","import type { Page } from '@playwright/test';\n\nexport interface StorywrightConfig {\n\tstorybook: StorybookConfig;\n\tbrowsers: BrowserName[];\n\tbrowserOptions: Record<string, BrowserOption>;\n\tscreenshot: ScreenshotConfig;\n\tdiffDetection: DiffDetectionConfig;\n\tstorage: StorageConfig;\n\treport: ReportConfig;\n\tworkers: number | 'auto';\n\tretries: number;\n\ttimeout: TimeoutConfig;\n\tinclude: string[];\n\texclude: string[];\n\thooks: HooksConfig;\n}\n\nexport type BrowserName = 'chromium' | 'firefox' | 'webkit' | (string & {});\n\nexport type PlaywrightBrowserName = 'chromium' | 'firefox' | 'webkit';\n\nexport const STANDARD_BROWSERS: ReadonlySet<string> = new Set<PlaywrightBrowserName>([\n\t'chromium',\n\t'firefox',\n\t'webkit',\n]);\n\nexport interface BrowserOption {\n\tbrowserName?: PlaywrightBrowserName;\n\tviewport?: { width: number; height: number };\n\tdeviceScaleFactor?: number;\n\tisMobile?: boolean;\n\thasTouch?: boolean;\n\tuserAgent?: string;\n\texclude?: string[];\n}\n\nexport interface StorybookConfig {\n\tstaticDir: string;\n\tbuildCommand: string;\n\turl?: string;\n\tcompatibility: 'auto' | 'v8';\n}\n\nexport interface ScreenshotConfig {\n\tfullPage: boolean;\n\tanimations: 'disabled' | 'allow';\n\tthreshold: number;\n\tmaxDiffPixelRatio: number;\n\tfreezeTime: string;\n\ttimezone: string;\n\tlocale: string;\n\tseed: number;\n}\n\nexport interface DiffDetectionConfig {\n\tenabled: boolean;\n\twatchFiles: string[];\n\tbaseBranch: string;\n}\n\nexport interface StorageConfig {\n\tprovider: 'local' | 's3';\n\tlocal: LocalStorageConfig;\n\ts3: S3StorageConfig;\n}\n\nexport interface LocalStorageConfig {\n\tbaselineDir: string;\n}\n\nexport interface S3StorageConfig {\n\tbucket: string;\n\tprefix: string;\n\tregion: string;\n\tcompression: 'zstd' | 'gzip' | 'none';\n}\n\nexport interface ReportConfig {\n\toutputDir: string;\n\ttitle: string;\n}\n\nexport interface TimeoutConfig {\n\ttest: number;\n\tnavigation: number;\n\texpect: number;\n}\n\nexport interface StoryContext {\n\tid: string;\n\ttitle: string;\n\tname: string;\n}\n\nexport interface HooksConfig {\n\tbeforeScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n\tafterScreenshot?: (page: Page, story: StoryContext) => Promise<void>;\n}\n\nexport type DeepPartial<T> = {\n\t[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n","import type { TestSummary } from '../core/types.js';\n\nexport function formatSummary(summary: TestSummary, options?: { reportPath?: string }): string {\n\tconst durationSec = Math.round(summary.duration / 1000);\n\tconst minutes = Math.floor(durationSec / 60);\n\tconst seconds = durationSec % 60;\n\tconst durationStr = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;\n\n\tconst lines: string[] = [\n\t\t'',\n\t\t'Storywright Results',\n\t\t'\\u2550'.repeat(42),\n\t\t` Total: ${summary.total} Passed: ${summary.passed} Failed: ${summary.failed} Skipped: ${summary.skipped}`,\n\t\t` Duration: ${durationStr}`,\n\t\t` Browsers: ${summary.browsers.join(', ')}`,\n\t];\n\n\tconst newFailures = summary.failures.filter((f) => f.type === 'new');\n\tconst diffFailures = summary.failures.filter((f) => f.type !== 'new');\n\n\tif (newFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' New (no baseline):');\n\t\tfor (const failure of newFailures) {\n\t\t\tlines.push(` \\u25cb ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t}\n\t}\n\n\tif (diffFailures.length > 0) {\n\t\tlines.push('');\n\t\tlines.push(' Failed:');\n\t\tfor (const failure of diffFailures) {\n\t\t\tlines.push(` \\u2717 ${failure.story}: ${failure.variant} (${failure.browser})`);\n\t\t\tif (failure.diffRatio > 0) {\n\t\t\t\tconst pct = (failure.diffRatio * 100).toFixed(1);\n\t\t\t\tlines.push(` \\u2192 Diff: ${pct}% pixels changed`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst reportPath = options?.reportPath ?? '.storywright/report/index.html';\n\tlines.push('');\n\tlines.push(` Report: ${reportPath}`);\n\tlines.push('\\u2550'.repeat(42));\n\tlines.push('');\n\n\treturn lines.join('\\n');\n}\n","import { execFile } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { DownloadOptions, StorageAdapter, UploadOptions } from './types.js';\n\nconst execFileAsync = promisify(execFile);\n\nexport class LocalStorageAdapter implements StorageAdapter {\n\tconstructor(private readonly baselineDir: string) {}\n\n\tasync download(options: DownloadOptions): Promise<void> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.cp(this.baselineDir, options.destDir, { recursive: true });\n\t}\n\n\tasync upload(options: UploadOptions): Promise<void> {\n\t\tconst resolvedSource = path.resolve(options.sourceDir);\n\t\tconst resolvedDest = path.resolve(this.baselineDir);\n\t\tif (resolvedSource === resolvedDest) {\n\t\t\treturn;\n\t\t}\n\t\tawait fs.mkdir(this.baselineDir, { recursive: true });\n\t\tawait fs.cp(options.sourceDir, this.baselineDir, { recursive: true });\n\t}\n\n\tasync exists(_branch: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait fs.access(this.baselineDir);\n\t\t\tconst entries = await fs.readdir(this.baselineDir);\n\t\t\treturn entries.length > 0;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Extract baselines from a git branch using `git ls-tree` + `git show`.\n\t * Binary-safe (PNG files) via `encoding: 'buffer'`.\n\t */\n\tasync downloadFromGit(branch: string, destDir: string, cwd: string): Promise<void> {\n\t\tconst gitPath = this.baselineDir.split(path.sep).join('/');\n\n\t\tlet lsOutput: string;\n\t\ttry {\n\t\t\tconst result = await execFileAsync(\n\t\t\t\t'git',\n\t\t\t\t['ls-tree', '-r', '--name-only', branch, '--', gitPath],\n\t\t\t\t{ cwd },\n\t\t\t);\n\t\t\tlsOutput = result.stdout;\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to list baselines from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t);\n\t\t}\n\n\t\tconst files = lsOutput.trim().split('\\n').filter(Boolean);\n\t\tif (files.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait fs.mkdir(destDir, { recursive: true });\n\n\t\tconst posixBaselineDir = this.baselineDir.split(path.sep).join('/').replace(/\\/+$/, '');\n\n\t\tfor (const file of files) {\n\t\t\tlet content: Buffer;\n\t\t\ttry {\n\t\t\t\tconst result = await execFileAsync('git', ['show', `${branch}:${file}`], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tencoding: 'buffer' as unknown as BufferEncoding,\n\t\t\t\t\tmaxBuffer: 50 * 1024 * 1024,\n\t\t\t\t});\n\t\t\t\tcontent = result.stdout as unknown as Buffer;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to extract '${file}' from git branch '${branch}': ${error instanceof Error ? error.message : error}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst relativePath = file.slice(posixBaselineDir.length + 1);\n\t\t\tconst destPath = path.join(destDir, ...relativePath.split('/'));\n\t\t\tawait fs.mkdir(path.dirname(destPath), { recursive: true });\n\t\t\tawait fs.writeFile(destPath, content);\n\t\t}\n\t}\n}\n","import type { StorageConfig } from '../config/types.js';\nimport { LocalStorageAdapter } from './local.js';\nimport type { StorageAdapter } from './types.js';\n\nexport async function createStorageAdapter(config: StorageConfig): Promise<StorageAdapter> {\n\tswitch (config.provider) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageAdapter(config.local.baselineDir);\n\t\tcase 's3':\n\t\t\treturn await loadS3Adapter(config);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown storage provider: ${config.provider}`);\n\t}\n}\n\nasync function loadS3Adapter(config: StorageConfig): Promise<StorageAdapter> {\n\ttry {\n\t\tconst { S3StorageAdapter } = await import('@storywright/storage-s3');\n\t\treturn new S3StorageAdapter(config.s3) as StorageAdapter;\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'S3 storage adapter requires the @storywright/storage-s3 package.\\nInstall it with: pnpm add @storywright/storage-s3',\n\t\t);\n\t}\n}\n\nexport type { StorageAdapter, DownloadOptions, UploadOptions } from './types.js';\n","import { createConsola } from 'consola';\n\nconst isCI = !!(\n\tprocess.env.CI ||\n\tprocess.env.GITHUB_ACTIONS ||\n\tprocess.env.CIRCLECI ||\n\tprocess.env.GITLAB_CI\n);\n\nexport const logger = createConsola({\n\tlevel: process.env.STORYWRIGHT_DEBUG ? 5 : 3,\n});\n\nexport { isCI };\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { generatePlaywrightConfig } from '../playwright/config-generator.js';\nimport { generateTestFile } from '../playwright/test-generator.js';\nimport { resolveAffectedStories } from '../resolver/index.js';\nimport { createStorageAdapter } from '../storage/index.js';\nimport { logger } from '../utils/logger.js';\nimport { resolveOutputDir } from '../utils/path.js';\nimport { exec } from '../utils/process.js';\nimport {\n\tbuildStorybook,\n\tdiscoverStories,\n\texcludeStoriesForBrowser,\n\tfilterStories,\n} from './storybook.js';\nimport type { Story, StoryIndex, TestSummary } from './types.js';\n\nexport interface TestOptions {\n\tdiffOnly?: boolean;\n\tshard?: string;\n\tupdateSnapshots?: boolean;\n\tfilter?: string;\n\toutputDir?: string;\n\treporters?: string[];\n}\n\nexport interface TestRunResult {\n\texitCode: number;\n\tsummary?: TestSummary;\n\treportDir?: string;\n\tsnapshotDir?: string;\n}\n\nconst STORIES_PER_FILE = 50;\n\nfunction resolveReporterPath(): string {\n\t// Resolve relative to this file's dist location\n\tconst thisDir = new URL('.', import.meta.url).pathname;\n\treturn path.resolve(thisDir, 'playwright', 'reporter.js');\n}\n\nfunction chunkStories(entries: Record<string, Story>): Record<string, Story>[] {\n\tconst keys = Object.keys(entries);\n\tif (keys.length === 0) return [{}];\n\tconst chunks: Record<string, Story>[] = [];\n\tfor (let i = 0; i < keys.length; i += STORIES_PER_FILE) {\n\t\tconst chunk: Record<string, Story> = {};\n\t\tfor (const key of keys.slice(i, i + STORIES_PER_FILE)) {\n\t\t\tchunk[key] = entries[key];\n\t\t}\n\t\tchunks.push(chunk);\n\t}\n\treturn chunks;\n}\n\nexport async function runTests(\n\tconfig: StorywrightConfig,\n\toptions: TestOptions = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst outputRoot = options.outputDir\n\t\t? path.resolve(cwd, options.outputDir)\n\t\t: resolveOutputDir(cwd, '.storywright');\n\tconst tmpDir = path.join(outputRoot, 'tmp');\n\tconst reportDir = options.outputDir\n\t\t? path.join(outputRoot, 'report')\n\t\t: path.resolve(cwd, config.report.outputDir);\n\tconst storybookDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst snapshotDir = path.join(tmpDir, 'snapshots');\n\n\t// Prepare directories early for parallel operations\n\tawait fs.mkdir(snapshotDir, { recursive: true });\n\n\t// Start baseline download in parallel with Storybook build\n\t// Skip download when updating snapshots (update command) — baselines are regenerated\n\tlet baselinePromise: Promise<void> | undefined;\n\tif (!options.updateSnapshots) {\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tbaselinePromise = storage\n\t\t\t.download({ branch: 'current', destDir: snapshotDir, onProgress: (msg) => logger.info(msg) })\n\t\t\t.catch(() => {\n\t\t\t\tlogger.info('No existing baselines found');\n\t\t\t});\n\t}\n\n\t// 1. Build Storybook if needed\n\tawait buildStorybook(config, cwd);\n\n\t// 2. Discover & filter stories\n\tlogger.start('Discovering stories...');\n\tconst allStories = await discoverStories(config, cwd);\n\tlet targetStories = filterStories(allStories, config);\n\n\t// Apply --filter option\n\tif (options.filter) {\n\t\ttargetStories = applyFilter(targetStories, options.filter);\n\t}\n\n\tlogger.info(`${Object.keys(targetStories.entries).length} stories found`);\n\n\t// 3. Diff-only: resolve affected stories (default in CI)\n\tconst effectiveDiffOnly = options.diffOnly ?? !!process.env.CI;\n\tif (effectiveDiffOnly && config.diffDetection.enabled) {\n\t\tlogger.start('Resolving dependencies...');\n\t\tconst diffResult = await resolveAffectedStories(\n\t\t\ttargetStories,\n\t\t\tconfig.diffDetection,\n\t\t\tstorybookDir,\n\t\t\tcwd,\n\t\t);\n\t\tif (!diffResult.allStories) {\n\t\t\ttargetStories = diffResult.targetStories;\n\t\t}\n\t\tlogger.info(`${Object.keys(targetStories.entries).length} stories affected by changes`);\n\t}\n\n\t// 4. Wait for baseline download to complete\n\tawait baselinePromise;\n\n\t// 5. Generate split test files for better worker distribution\n\tlet testFilePattern: string;\n\tlet testMatchByBrowser: Record<string, string> | undefined;\n\n\tconst browserExcludesExist = config.browsers.some(\n\t\t(b) => (config.browserOptions[b]?.exclude ?? []).length > 0,\n\t);\n\n\tif (browserExcludesExist) {\n\t\t// Generate per-browser test files when any browser has specific excludes\n\t\ttestMatchByBrowser = {};\n\n\t\tfor (const browser of config.browsers) {\n\t\t\tconst browserExclude = config.browserOptions[browser]?.exclude ?? [];\n\t\t\tconst browserStories = excludeStoriesForBrowser(targetStories, browserExclude);\n\n\t\t\tif (Object.keys(browserStories.entries).length === 0) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t`${browser}: All stories excluded by browser-specific 'exclude' patterns. No tests will run for this browser.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst browserChunks = chunkStories(browserStories.entries);\n\n\t\t\ttestMatchByBrowser[browser] =\n\t\t\t\tbrowserChunks.length === 1\n\t\t\t\t\t? `storywright-${browser}-0.spec.ts`\n\t\t\t\t\t: `storywright-${browser}-*.spec.ts`;\n\n\t\t\tfor (let i = 0; i < browserChunks.length; i++) {\n\t\t\t\tconst chunkIndex: StoryIndex = { ...browserStories, entries: browserChunks[i] };\n\t\t\t\tconst chunkPath = path.join(tmpDir, `target-stories-${browser}-${i}.json`);\n\t\t\t\tawait fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n\t\t\t\tconst testContent = generateTestFile(config.screenshot, {\n\t\t\t\t\ttargetStoriesPath: chunkPath.replace(/\\\\/g, '/'),\n\t\t\t\t});\n\t\t\t\tawait fs.writeFile(path.join(tmpDir, `storywright-${browser}-${i}.spec.ts`), testContent);\n\t\t\t}\n\n\t\t\tlogger.info(\n\t\t\t\t`${browser}: ${Object.keys(browserStories.entries).length} stories, ${browserChunks.length} test file(s)`,\n\t\t\t);\n\t\t}\n\n\t\ttestFilePattern = 'storywright-*.spec.ts';\n\t} else {\n\t\t// Default: shared test files for all browsers\n\t\tconst chunks = chunkStories(targetStories.entries);\n\t\ttestFilePattern = chunks.length === 1 ? 'storywright-0.spec.ts' : 'storywright-*.spec.ts';\n\n\t\tfor (let i = 0; i < chunks.length; i++) {\n\t\t\tconst chunkIndex: StoryIndex = { ...targetStories, entries: chunks[i] };\n\t\t\tconst chunkPath = path.join(tmpDir, `target-stories-${i}.json`);\n\t\t\tawait fs.writeFile(chunkPath, JSON.stringify(chunkIndex));\n\n\t\t\tconst testContent = generateTestFile(config.screenshot, {\n\t\t\t\ttargetStoriesPath: chunkPath.replace(/\\\\/g, '/'),\n\t\t\t});\n\t\t\tawait fs.writeFile(path.join(tmpDir, `storywright-${i}.spec.ts`), testContent);\n\t\t}\n\n\t\tlogger.info(`${chunks.length} test file(s) generated`);\n\t}\n\n\t// 6. Generate Playwright config\n\tconst reporterWrapperPath = path.join(tmpDir, 'reporter.mjs');\n\tconst resolvedReporterPath = resolveReporterPath().replace(/\\\\/g, '/');\n\tconst reporterOutputDir = reportDir.replace(/\\\\/g, '/');\n\n\tawait fs.writeFile(\n\t\treporterWrapperPath,\n\t\t`import StorywrightReporter from '${resolvedReporterPath}';\\nexport default class extends StorywrightReporter {\\n constructor() { super({ outputDir: '${reporterOutputDir}' }); }\\n}\\n`,\n\t);\n\n\t// Determine Storybook URL\n\tlet actualStorybookUrl = config.storybook.url;\n\tconst needsServer = !actualStorybookUrl;\n\n\tif (needsServer) {\n\t\tactualStorybookUrl = 'http://localhost:6007';\n\t}\n\n\tconst playwrightConfig = generatePlaywrightConfig(config, {\n\t\ttmpDir: tmpDir.replace(/\\\\/g, '/'),\n\t\tstorybookUrl: actualStorybookUrl ?? 'http://localhost:6007',\n\t\tsnapshotDir: snapshotDir.replace(/\\\\/g, '/'),\n\t\treporterPath: reporterWrapperPath.replace(/\\\\/g, '/'),\n\t\ttestMatch: testFilePattern,\n\t\ttestMatchByBrowser,\n\t\tshard: options.shard,\n\t\treporters: options.reporters,\n\t});\n\n\tconst configPath = path.join(tmpDir, 'playwright.config.ts');\n\tawait fs.writeFile(configPath, playwrightConfig);\n\n\t// 7. Run Playwright tests\n\tlogger.start('Running tests...');\n\tconst args = ['playwright', 'test', '--config', configPath];\n\n\tif (options.updateSnapshots) {\n\t\targs.push('--update-snapshots');\n\t}\n\n\t// Start static server if needed\n\tlet serverProc: { kill: () => void } | undefined;\n\tif (needsServer) {\n\t\tserverProc = await startStaticServer(storybookDir, 6007);\n\t}\n\n\ttry {\n\t\tconst result = await exec('npx', args, { cwd, inherit: true });\n\n\t\t// 8. Read results\n\t\tlet summary: TestSummary | undefined;\n\t\ttry {\n\t\t\tconst summaryPath = path.join(reportDir, 'summary.json');\n\t\t\tconst summaryContent = await fs.readFile(summaryPath, 'utf-8');\n\t\t\tsummary = JSON.parse(summaryContent);\n\t\t} catch {\n\t\t\t// summary may not exist if no tests ran\n\t\t}\n\n\t\t// 9. Map exit codes per SPEC §14.2\n\t\tconst exitCode = mapExitCode(result.exitCode, summary);\n\n\t\treturn { exitCode, summary, reportDir, snapshotDir };\n\t} finally {\n\t\tserverProc?.kill();\n\t}\n}\n\nexport async function updateBaselines(\n\tconfig: StorywrightConfig,\n\toptions: { all?: boolean; upload?: boolean; shard?: string; filter?: string } = {},\n\tcwd: string = process.cwd(),\n): Promise<TestRunResult> {\n\tconst result = await runTests(\n\t\tconfig,\n\t\t{\n\t\t\tupdateSnapshots: true,\n\t\t\tdiffOnly: !options.all,\n\t\t\tshard: options.shard,\n\t\t\tfilter: options.filter,\n\t\t},\n\t\tcwd,\n\t);\n\n\tif (result.exitCode !== 0) {\n\t\tlogger.warn('Some tests failed during baseline update');\n\t}\n\n\t// Save updated snapshots back to baselineDir (local disk operation)\n\tif (result.snapshotDir) {\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait fs.mkdir(baselineDir, { recursive: true });\n\t\tawait fs.cp(result.snapshotDir, baselineDir, { recursive: true });\n\t\tlogger.success(`Baselines saved to ${config.storage.local.baselineDir}`);\n\t}\n\n\t// --upload: upload to remote storage (S3 etc.) only when explicitly requested\n\tif (options.upload) {\n\t\tconst storage = await createStorageAdapter(config.storage);\n\t\tconst baselineDir = path.resolve(cwd, config.storage.local.baselineDir);\n\t\tawait storage.upload({\n\t\t\tbranch: 'current',\n\t\t\tsourceDir: baselineDir,\n\t\t\tshard: options.shard,\n\t\t\tonProgress: (msg) => logger.info(msg),\n\t\t});\n\t\tlogger.success('Baselines uploaded to remote storage');\n\t}\n\n\treturn result;\n}\n\nfunction applyFilter(storyIndex: StoryIndex, filter: string): StoryIndex {\n\tconst matcher = picomatch(filter);\n\tconst entries: Record<string, StoryIndex['entries'][string]> = {};\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tif (matcher(fullName) || matcher(story.title) || matcher(story.id)) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\treturn { ...storyIndex, entries };\n}\n\nfunction mapExitCode(playwrightCode: number, summary?: TestSummary): number {\n\t// SPEC §14.2: 0 = success (no diff), 1 = success (diff found), 2 = execution error, 130 = SIGINT\n\tif (playwrightCode === 130 || playwrightCode === 143) {\n\t\treturn 130; // SIGINT / SIGTERM\n\t}\n\tif (summary) {\n\t\tif (summary.failed > 0) return 1;\n\t\tif (summary.total === 0 && playwrightCode !== 0) return 2;\n\t\treturn 0;\n\t}\n\t// No summary = likely execution error\n\treturn playwrightCode === 0 ? 0 : 2;\n}\n\nasync function startStaticServer(dir: string, port: number): Promise<{ kill: () => void }> {\n\tconst { createServer } = await import('node:http');\n\tconst sirv = (await import('sirv')).default;\n\n\tconst handler = sirv(dir, { single: false, dev: false });\n\tconst server = createServer(handler);\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.on('error', reject);\n\t\tserver.listen(port, () => resolve());\n\t});\n\n\treturn { kill: () => server.close() };\n}\n","import { STANDARD_BROWSERS } from '../config/types.js';\nimport type { BrowserOption, StorywrightConfig } from '../config/types.js';\n\nexport function generatePlaywrightConfig(\n\tconfig: StorywrightConfig,\n\toptions: {\n\t\ttmpDir: string;\n\t\tstorybookUrl: string;\n\t\tsnapshotDir: string;\n\t\treporterPath: string;\n\t\ttestMatch: string;\n\t\ttestMatchByBrowser?: Record<string, string>;\n\t\tshard?: string;\n\t\treporters?: string[];\n\t},\n): string {\n\tconst projects = config.browsers.map((browser) => {\n\t\tconst rawOptions = config.browserOptions[browser];\n\t\tconst useObj = buildBrowserUseObject(browser, rawOptions);\n\t\tconst useStr = JSON.stringify(useObj, null, '\\t\\t');\n\t\tconst testMatch = options.testMatchByBrowser?.[browser];\n\t\tconst testMatchLine = testMatch ? `\\n\\t\\t\\ttestMatch: '${escapeBackslash(testMatch)}',` : '';\n\t\treturn `\\t\\t{\n\\t\\t\\tname: '${browser}',${testMatchLine}\n\\t\\t\\tuse: ${useStr},\n\\t\\t}`;\n\t});\n\n\tconst workers = config.workers === 'auto' ? \"'100%'\" : String(config.workers);\n\n\tconst shard = options.shard\n\t\t? `\\tshard: { current: ${options.shard.split('/')[0]}, total: ${options.shard.split('/')[1]} },`\n\t\t: '';\n\n\t// Build reporter list: always include custom reporter, plus user-requested ones\n\tconst reporterEntries: string[] = [];\n\tconst requestedReporters = options.reporters ?? ['default', 'html'];\n\tfor (const r of requestedReporters) {\n\t\tif (r === 'default' || r === 'list') {\n\t\t\treporterEntries.push(\"\\t\\t['list']\");\n\t\t} else if (r !== 'html') {\n\t\t\t// Pass through other built-in Playwright reporters (dot, json, junit, etc.)\n\t\t\treporterEntries.push(`\\t\\t['${r}']`);\n\t\t}\n\t}\n\t// Always include custom storywright reporter\n\treporterEntries.push(`\\t\\t['${escapeBackslash(options.reporterPath)}']`);\n\n\tconst testMatchLine = options.testMatchByBrowser\n\t\t? ''\n\t\t: `\\ttestMatch: '${escapeBackslash(options.testMatch)}',\\n`;\n\n\treturn `import { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n\\ttestDir: '${escapeBackslash(options.tmpDir)}',\n${testMatchLine}\\tsnapshotDir: '${escapeBackslash(options.snapshotDir)}',\n\\tsnapshotPathTemplate: '{snapshotDir}/{arg}-{projectName}{ext}',\n\\ttimeout: ${config.timeout.test},\n\\texpect: {\n\\t\\ttoHaveScreenshot: {\n\\t\\t\\tmaxDiffPixelRatio: ${config.screenshot.maxDiffPixelRatio},\n\\t\\t\\tthreshold: ${config.screenshot.threshold},\n\\t\\t},\n\\t\\ttimeout: ${config.timeout.expect},\n\\t},\n\\tfullyParallel: true,\n\\tforbidOnly: !!process.env.CI,\n\\tretries: ${config.retries},\n\\tworkers: ${workers},\n${shard}\n\\treporter: [\n${reporterEntries.join(',\\n')}\n\\t],\n\\tuse: {\n\\t\\tbaseURL: '${options.storybookUrl}',\n\\t\\tnavigationTimeout: ${config.timeout.navigation},\n\\t\\ttimezoneId: '${config.screenshot.timezone}',\n\\t\\tlocale: '${config.screenshot.locale}',\n\\t},\n\\tprojects: [\n${projects.join(',\\n')}\n\\t],\n});\n`;\n}\n\nfunction buildBrowserUseObject(\n\tbrowser: string,\n\trawOptions?: BrowserOption,\n): Record<string, unknown> {\n\tlet browserName: string;\n\tif (rawOptions?.browserName) {\n\t\tbrowserName = rawOptions.browserName;\n\t} else if (STANDARD_BROWSERS.has(browser)) {\n\t\tbrowserName = browser;\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Cannot resolve browserName for custom browser project '${browser}'.\\n\\nError code: SW_E_INTERNAL_BROWSER_RESOLVE`,\n\t\t);\n\t}\n\tconst useObj: Record<string, unknown> = { browserName };\n\n\tif (rawOptions) {\n\t\tconst { browserName: _, exclude: __, ...rest } = rawOptions;\n\t\tObject.assign(useObj, rest);\n\t}\n\n\treturn useObj;\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import type { ScreenshotConfig } from '../config/types.js';\n\nexport function generateTestFile(\n\tconfig: ScreenshotConfig,\n\toptions: {\n\t\ttargetStoriesPath: string;\n\t},\n): string {\n\tconst disableAnimations = config.animations === 'disabled';\n\n\treturn `import { test, expect } from '@playwright/test';\nimport { readFileSync } from 'node:fs';\n\nconst targetList = JSON.parse(\n\\treadFileSync('${escapeBackslash(options.targetStoriesPath)}', 'utf-8'),\n);\n\ntest.describe.parallel('visual regression testing', () => {\n\\tif (Object.keys(targetList.entries).length === 0) {\n\\t\\ttest('no stories to test', () => {\n\\t\\t\\texpect(true).toBeTruthy();\n\\t\\t});\n\\t}\n\n\\tfor (const story of Object.values(targetList.entries)) {\n\\t\\ttest(\\`\\${story.title}: \\${story.name}\\`, async ({ page }) => {\n\\t\\t\\t// Freeze time for reproducibility\n\\t\\t\\tawait page.clock.install({ time: new Date('${config.freezeTime}') });\n\n\\t\\t\\t// Seed Math.random for reproducibility\n\\t\\t\\tawait page.addInitScript((seed) => {\n\\t\\t\\t\\tlet s = seed;\n\\t\\t\\t\\tMath.random = () => {\n\\t\\t\\t\\t\\ts = (s * 16807 + 0) % 2147483647;\n\\t\\t\\t\\t\\treturn (s - 1) / 2147483646;\n\\t\\t\\t\\t};\n\\t\\t\\t}, ${config.seed});\n\n\\t\\t\\tawait page.goto(\\`/iframe.html?id=\\${story.id}\\`, {\n\\t\\t\\t\\twaitUntil: 'domcontentloaded',\n\\t\\t\\t});\n${\n\tdisableAnimations\n\t\t? `\n\\t\\t\\t// Force-disable all CSS animations and transitions\n\\t\\t\\tawait page.addStyleTag({\n\\t\\t\\t\\tcontent: '*, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition-duration: 0s !important; transition-delay: 0s !important; }',\n\\t\\t\\t});\n`\n\t\t: ''\n}\n\\t\\t\\t// Wait for story to render: content inside #storybook-root OR portal content on body\n\\t\\t\\tawait page.waitForFunction(() => {\n\\t\\t\\t\\tconst root = document.getElementById('storybook-root');\n\\t\\t\\t\\tif (!root) return false;\n\\t\\t\\t\\tif (root.childElementCount > 0) return true;\n\\t\\t\\t\\t// Portal: check for elements on body that aren't part of Storybook's skeleton\n\\t\\t\\t\\tfor (const el of document.body.children) {\n\\t\\t\\t\\t\\tif (el.tagName === 'SCRIPT' || el.id === 'storybook-root' || el.id === 'storybook-docs') continue;\n\\t\\t\\t\\t\\treturn true;\n\\t\\t\\t\\t}\n\\t\\t\\t\\treturn false;\n\\t\\t\\t}, { timeout: 10000 });\n\n\\t\\t\\t// Wait for web fonts to finish loading\n\\t\\t\\tawait page.waitForFunction(() => document.fonts.ready);\n\n\\t\\t\\t// Allow async renders to settle (multiple animation frames)\n\\t\\t\\t// This must run BEFORE image checks so the framework has finished adding\n\\t\\t\\t// all <img> elements to the DOM\n\\t\\t\\tawait page.waitForFunction(\n\\t\\t\\t\\t() =>\n\\t\\t\\t\\t\\tnew Promise((resolve) => {\n\\t\\t\\t\\t\\t\\tlet count = 0;\n\\t\\t\\t\\t\\t\\tconst tick = () => {\n\\t\\t\\t\\t\\t\\t\\tif (++count >= 3) return resolve(true);\n\\t\\t\\t\\t\\t\\t\\trequestAnimationFrame(tick);\n\\t\\t\\t\\t\\t\\t};\n\\t\\t\\t\\t\\t\\trequestAnimationFrame(tick);\n\\t\\t\\t\\t\\t}),\n\\t\\t\\t);\n\n\\t\\t\\t// Force lazy-loaded images to eager and wait for load\n\\t\\t\\tawait page.evaluate(async () => {\n\\t\\t\\t\\tconst lazyImages = document.querySelectorAll('img[loading=\"lazy\"]');\n\\t\\t\\t\\tfor (const img of lazyImages) {\n\\t\\t\\t\\t\\t(img as HTMLImageElement).loading = 'eager';\n\\t\\t\\t\\t}\n\n\\t\\t\\t\\tconst images = Array.from(document.images).filter((img) => !img.complete);\n\\t\\t\\t\\tawait Promise.all(\n\\t\\t\\t\\t\\timages.map(\n\\t\\t\\t\\t\\t\\t(img) =>\n\\t\\t\\t\\t\\t\\t\\tnew Promise<void>((resolve) => {\n\\t\\t\\t\\t\\t\\t\\t\\tconst timeout = setTimeout(resolve, 5000);\n\\t\\t\\t\\t\\t\\t\\t\\timg.onload = img.onerror = () => {\n\\t\\t\\t\\t\\t\\t\\t\\t\\tclearTimeout(timeout);\n\\t\\t\\t\\t\\t\\t\\t\\t\\tresolve();\n\\t\\t\\t\\t\\t\\t\\t\\t};\n\\t\\t\\t\\t\\t\\t\\t}),\n\\t\\t\\t\\t\\t),\n\\t\\t\\t\\t);\n\\t\\t\\t});\n${\n\tdisableAnimations\n\t\t? `\n\\t\\t\\t// Force opacity:1 on images to counteract fade-in effects\n\\t\\t\\tawait page.evaluate(() => {\n\\t\\t\\t\\tdocument.querySelectorAll('img').forEach((img) => {\n\\t\\t\\t\\t\\timg.style.setProperty('opacity', '1', 'important');\n\\t\\t\\t\\t});\n\\t\\t\\t});\n`\n\t\t: ''\n}\n\\t\\t\\t// Final stabilization delay for layout shifts\n\\t\\t\\tawait page.waitForTimeout(200);\n\n\\t\\t\\tawait expect(page).toHaveScreenshot(\n\\t\\t\\t\\t[story.title, \\`\\${story.id}.png\\`],\n\\t\\t\\t\\t{\n\\t\\t\\t\\t\\tanimations: '${config.animations}',\n\\t\\t\\t\\t\\tfullPage: ${config.fullPage},\n\\t\\t\\t\\t\\tthreshold: ${config.threshold},\n\\t\\t\\t\\t\\tmaxDiffPixelRatio: ${config.maxDiffPixelRatio},\n\\t\\t\\t\\t},\n\\t\\t\\t);\n\\t\\t});\n\\t}\n});\n`;\n}\n\nfunction escapeBackslash(str: string): string {\n\treturn str.replace(/\\\\/g, '/');\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport { simpleGit } from 'simple-git';\nimport type { DiffDetectionConfig } from '../config/types.js';\nimport type { StatsIndex, StatsModule, StoryIndex } from '../core/types.js';\nimport { logger } from '../utils/logger.js';\nimport { normalizePath, stripLeadingDotSlash } from '../utils/path.js';\n\nexport interface DependencyResolver {\n\tgetDependencies(filePath: string): string[];\n\tgetStoriesForFiles(pathList: string[]): StoryIndex;\n}\n\nconst STORY_FILE_PATTERNS = ['.stories.', '.mdx'];\n\nfunction isStoryFile(moduleName: string): boolean {\n\treturn STORY_FILE_PATTERNS.some((p) => moduleName.includes(p));\n}\n\nexport class StorybookStatsDependencyResolver implements DependencyResolver {\n\tprivate moduleMap: Record<string, StatsModule>;\n\n\tconstructor(\n\t\tprivate statsJson: StatsIndex,\n\t\tprivate storiesJson: StoryIndex,\n\t) {\n\t\tthis.moduleMap = {};\n\t\tfor (const mod of statsJson.modules) {\n\t\t\t// Key by normalized name (primary) and normalized id (fallback)\n\t\t\tconst normalizedName = normalizePath(mod.name);\n\t\t\tthis.moduleMap[normalizedName] = mod;\n\t\t\tconst normalizedId = normalizePath(mod.id);\n\t\t\tif (normalizedId !== normalizedName) {\n\t\t\t\tthis.moduleMap[normalizedId] ??= mod;\n\t\t\t}\n\t\t}\n\t}\n\n\tgetDependencies(filePath: string): string[] {\n\t\tconst normalizedPath = normalizePath(filePath);\n\t\tconst dependencies = this.collectDependencies(normalizedPath);\n\n\t\tif (this.moduleMap[normalizedPath]) {\n\t\t\tdependencies.add(normalizedPath);\n\t\t}\n\n\t\treturn [...dependencies];\n\t}\n\n\tgetStoriesForFiles(pathList: string[]): StoryIndex {\n\t\tconst result: StoryIndex = { v: this.storiesJson.v, entries: {} };\n\n\t\tfor (const filePath of pathList) {\n\t\t\t// Finding #2 + #3: lookup via normalized moduleMap (name primary, id fallback)\n\t\t\tconst normalizedPath = normalizePath(filePath);\n\t\t\tconst stats = this.moduleMap[normalizedPath];\n\t\t\tif (!stats) continue;\n\n\t\t\t// Finding #1: collect ALL story reasons, not just first\n\t\t\tconst storyReasons = stats.reasons.filter((r) => isStoryFile(r.moduleName));\n\t\t\tfor (const reason of storyReasons) {\n\t\t\t\tconst normalizedImportPath = normalizePath(reason.moduleName);\n\t\t\t\t// Collect ALL matching story entries per reason\n\t\t\t\tfor (const storyObj of Object.values(this.storiesJson.entries)) {\n\t\t\t\t\tif (storyObj.type !== 'story') continue;\n\t\t\t\t\tif (normalizePath(storyObj.importPath) === normalizedImportPath) {\n\t\t\t\t\t\tresult.entries[storyObj.id] = storyObj;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate collectDependencies(name: string, result = new Set<string>()): Set<string> {\n\t\tconst mod = this.moduleMap[normalizePath(name)];\n\t\tif (mod) {\n\t\t\tfor (const reason of mod.reasons) {\n\t\t\t\tif (!result.has(reason.moduleName)) {\n\t\t\t\t\tresult.add(reason.moduleName);\n\t\t\t\t\tthis.collectDependencies(reason.moduleName, result);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n}\n\nexport interface DiffResult {\n\tallStories: boolean;\n\ttargetStories: StoryIndex;\n}\n\ninterface DiffFileEntry {\n\tfile: string;\n\tfrom?: string;\n}\n\nexport async function resolveAffectedStories(\n\tstoriesJson: StoryIndex,\n\tconfig: DiffDetectionConfig,\n\tstorybookStaticDir: string,\n\tcwd: string,\n): Promise<DiffResult> {\n\tconst git = simpleGit({ baseDir: cwd });\n\n\t// Get diff summary\n\tlet diffEntries: DiffFileEntry[];\n\ttry {\n\t\tconst mergeBase = await git.raw(['merge-base', config.baseBranch, 'HEAD']);\n\t\tconst diff = await git.diffSummary([mergeBase.trim(), 'HEAD']);\n\t\tdiffEntries = diff.files.map((f) => ({\n\t\t\tfile: f.file,\n\t\t\t// Handle renames: include both old and new paths\n\t\t\tfrom: 'from' in f ? (f as { from: string }).from : undefined,\n\t\t}));\n\t} catch {\n\t\tlogger.warn('Failed to resolve git diff, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tif (diffEntries.length === 0) {\n\t\tlogger.info('No changed files detected');\n\t\treturn { allStories: false, targetStories: { v: storiesJson.v, entries: {} } };\n\t}\n\n\t// Collect all affected paths (including rename sources)\n\tconst allPaths: string[] = [];\n\tfor (const entry of diffEntries) {\n\t\tallPaths.push(entry.file);\n\t\tif (entry.from) {\n\t\t\tallPaths.push(entry.from);\n\t\t}\n\t}\n\n\t// Check watchFiles\n\tfor (const file of allPaths) {\n\t\tfor (const pattern of config.watchFiles) {\n\t\t\tif (picomatch(pattern)(file)) {\n\t\t\t\tlogger.info(`Watch file changed: ${file}, running all stories`);\n\t\t\t\treturn { allStories: true, targetStories: storiesJson };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Load stats json for dependency resolution\n\tconst statsPath = path.resolve(storybookStaticDir, 'preview-stats.json');\n\tlet statsJson: StatsIndex;\n\ttry {\n\t\tstatsJson = JSON.parse(await fs.readFile(statsPath, 'utf-8'));\n\t} catch {\n\t\tlogger.warn('preview-stats.json not found, running all stories');\n\t\treturn { allStories: true, targetStories: storiesJson };\n\t}\n\n\tconst resolver = new StorybookStatsDependencyResolver(statsJson, storiesJson);\n\tconst targetStories: StoryIndex = { v: storiesJson.v, entries: {} };\n\n\t// Direct story file matches (both .stories.* and .mdx)\n\tfor (const file of allPaths) {\n\t\tconst matchedStories = Object.values(storiesJson.entries).filter(\n\t\t\t(story) => stripLeadingDotSlash(story.importPath) === file,\n\t\t);\n\t\tfor (const story of matchedStories) {\n\t\t\ttargetStories.entries[story.id] = story;\n\t\t}\n\t}\n\n\t// Dependency-based matches\n\tfor (const file of allPaths) {\n\t\tconst deps = resolver.getDependencies(normalizePath(file));\n\t\tconst depStories = resolver.getStoriesForFiles(deps);\n\t\tfor (const [id, story] of Object.entries(depStories.entries)) {\n\t\t\ttargetStories.entries[id] = story;\n\t\t}\n\t}\n\n\tlogger.info(`Resolved ${Object.keys(targetStories.entries).length} affected stories`);\n\treturn { allStories: false, targetStories };\n}\n","import path from 'node:path';\n\nexport function normalizePath(filePath: string): string {\n\tconst normalized = filePath.replace(/\\\\/g, '/');\n\tif (normalized.startsWith('./')) {\n\t\treturn normalized;\n\t}\n\treturn `./${normalized}`;\n}\n\nexport function stripLeadingDotSlash(filePath: string): string {\n\treturn filePath.replace(/^\\.\\//, '');\n}\n\nexport function resolveOutputDir(outputDir: string, ...segments: string[]): string {\n\treturn path.resolve(outputDir, ...segments);\n}\n","import { spawn } from 'node:child_process';\n\nexport interface ExecResult {\n\texitCode: number;\n\tstdout: string;\n\tstderr: string;\n}\n\nexport function exec(\n\tcommand: string,\n\targs: string[],\n\toptions?: { cwd?: string; env?: Record<string, string>; inherit?: boolean },\n): Promise<ExecResult> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tenv: { ...process.env, ...options?.env },\n\t\t\tstdio: options?.inherit ? ['ignore', 'inherit', 'inherit'] : ['ignore', 'pipe', 'pipe'],\n\t\t\tshell: false,\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\n\t\tif (!options?.inherit) {\n\t\t\tproc.stdout?.on('data', (data: Buffer) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\n\t\t\tproc.stderr?.on('data', (data: Buffer) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t}\n\n\t\tproc.on('error', reject);\n\n\t\tproc.on('close', (code) => {\n\t\t\tresolve({ exitCode: code ?? 1, stdout, stderr });\n\t\t});\n\t});\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport picomatch from 'picomatch';\nimport type { StorywrightConfig } from '../config/types.js';\nimport { logger } from '../utils/logger.js';\nimport { exec } from '../utils/process.js';\nimport type { Story, StoryIndex } from './types.js';\n\nexport async function buildStorybook(config: StorywrightConfig, cwd: string): Promise<void> {\n\tif (config.storybook.url) {\n\t\tlogger.info('Using running Storybook at', config.storybook.url);\n\t\treturn;\n\t}\n\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\ttry {\n\t\tawait fs.access(path.join(staticDir, 'index.json'));\n\t\tlogger.info('Storybook already built at', staticDir);\n\t\treturn;\n\t} catch {\n\t\t// need to build\n\t}\n\n\tlogger.start('Building Storybook...');\n\tconst [command, ...args] = config.storybook.buildCommand.split(' ');\n\tconst result = await exec(command, args, { cwd });\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`Storybook build failed (exit code ${result.exitCode}):\\n${result.stderr}\\n\\nError code: SW_E_STORYBOOK_BUILD_FAILED`,\n\t\t);\n\t}\n\tlogger.success('Storybook built');\n}\n\nexport async function discoverStories(config: StorywrightConfig, cwd: string): Promise<StoryIndex> {\n\tconst staticDir = path.resolve(cwd, config.storybook.staticDir);\n\tconst indexPath = path.join(staticDir, 'index.json');\n\n\ttry {\n\t\tawait fs.access(indexPath);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`Storybook build directory not found at '${config.storybook.staticDir}/'\\n\\n Run one of the following:\\n $ npx storybook build --stats-json\\n $ npx storywright test --storybook-url http://localhost:6006\\n\\n Error code: SW_E_STORYBOOK_DIR_NOT_FOUND`,\n\t\t);\n\t}\n\n\tconst raw = JSON.parse(await fs.readFile(indexPath, 'utf-8'));\n\tconst indexJson = normalizeStoryIndex(raw, config.storybook.compatibility);\n\n\t// Version check\n\tif (indexJson.v < 4) {\n\t\tthrow new Error(\n\t\t\t'Storybook 7.x or earlier is not supported. Storywright requires Storybook 8 or later.\\n\\nError code: SW_E_STORYBOOK_UNSUPPORTED',\n\t\t);\n\t}\n\n\treturn indexJson;\n}\n\n/**\n * Parse Storybook index.json (v8+).\n */\nfunction normalizeStoryIndex(\n\traw: Record<string, unknown>,\n\t_compatibility: 'auto' | 'v8',\n): StoryIndex {\n\tconst version = typeof raw.v === 'number' ? raw.v : 0;\n\tconst entries = (raw.entries ?? {}) as Record<string, Story>;\n\n\treturn { v: version, entries };\n}\n\nexport function filterStories(storyIndex: StoryIndex, config: StorywrightConfig): StoryIndex {\n\tconst entries: Record<string, Story> = {};\n\tconst includeMatchers = config.include.map((p) => picomatch(p));\n\tconst excludeMatchers = config.exclude.map((p) => picomatch(p));\n\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\t// Skip docs entries\n\t\tif (story.type === 'docs') continue;\n\t\tif (story.name === 'Docs') continue;\n\n\t\tconst fullName = `${story.title}/${story.name}`;\n\n\t\t// Check include patterns\n\t\tconst isIncluded = includeMatchers.some((m) => m(fullName));\n\t\tif (!isIncluded) continue;\n\n\t\t// Check exclude patterns\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (isExcluded) continue;\n\n\t\tentries[id] = story;\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n\nexport function excludeStoriesForBrowser(\n\tstoryIndex: StoryIndex,\n\texcludePatterns: string[],\n): StoryIndex {\n\tif (excludePatterns.length === 0) {\n\t\treturn storyIndex;\n\t}\n\n\tconst excludeMatchers = excludePatterns.map((p) => picomatch(p));\n\tconst entries: Record<string, Story> = {};\n\n\tfor (const [id, story] of Object.entries(storyIndex.entries)) {\n\t\tconst fullName = `${story.title}/${story.name}`;\n\t\tconst isExcluded = excludeMatchers.some((m) => m(fullName));\n\t\tif (!isExcluded) {\n\t\t\tentries[id] = story;\n\t\t}\n\t}\n\n\treturn { ...storyIndex, entries };\n}\n"],"mappings":";AAAA,SAAS,cAAc,oBAAoB;;;ACEpC,IAAM,iBAAoC;AAAA,EAChD,WAAW;AAAA,IACV,WAAW;AAAA,IACX,cA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AI,mBAAmB,OAAO,mBAAmB,KAAK;AACrD,WAAO;AAAA,EACR;AACA,MAAI,SAAS;AACZ,QAAI,QAAQ,SAAS,EAAG,QAAO;AAC/B,QAAI,QAAQ,UAAU,KAAK,mBAAmB,EAAG,QAAO;AACxD,WAAO;AAAA,EACR;AAEA,SAAO,mBAAmB,IAAI,IAAI;AACnC;AAEA,eAAe,kBAAkB,KAAa,MAA6C;AAC1F,QAAM,EAAE,aAAa,IAAI,MAAM,OAAO,MAAW;AACjD,QAAM,QAAQ,MAAM,OAAO,MAAM,GAAG;AAEpC,QAAM,UAAU,KAAK,KAAK,EAAE,QAAQ,OAAO,KAAK,MAAM,CAAC;AACvD,QAAM,SAAS,aAAa,OAAO;AAEnC,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC5C,WAAO,GAAG,SAAS,MAAM;AACzB,WAAO,OAAO,MAAM,MAAM,QAAQ,CAAC;AAAA,EACpC,CAAC;AAED,SAAO,EAAE,MAAM,MAAM,OAAO,MAAM,EAAE;AACrC;","names":["fs","path","picomatch","testMatchLine","escapeBackslash","fs","path","path","path","fs","fs","path","picomatch","path","fs","picomatch","path","fs","picomatch"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/playwright/reporter.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport type {\n\tFullConfig,\n\tFullResult,\n\tTestResult as PwTestResult,\n\tReporter,\n\tSuite,\n\tTestCase,\n} from '@playwright/test/reporter';\nimport type { FailureEntry, TestSummary } from '../core/types.js';\n\ninterface StorywrightReporterOptions {\n\toutputDir?: string;\n}\n\nclass StorywrightReporter implements Reporter {\n\tprivate outputDir: string;\n\tprivate results = new Map<\n\t\tstring,\n\t\t{\n\t\t\ttitle: string;\n\t\t\tproject: string;\n\t\t\tstatus: 'passed' | 'failed' | 'skipped';\n\t\t\tduration: number;\n\t\t\tattachments: { name: string; path?: string; contentType: string }[];\n\t\t}\n\t>();\n\tprivate startTime = 0;\n\n\tconstructor(options: StorywrightReporterOptions = {}) {\n\t\tthis.outputDir = options.outputDir || path.resolve('.storywright', 'report');\n\t}\n\n\tonBegin(_config: FullConfig, _suite: Suite): void {\n\t\tthis.startTime = Date.now();\n\t}\n\n\tonTestEnd(test: TestCase, result: PwTestResult): void {\n\t\tconst project = test.parent?.project()?.name ?? 'unknown';\n\t\tconst key = `${test.title}::${project}`;\n\t\tconst status =\n\t\t\tresult.status === 'passed' ? 'passed' : result.status === 'skipped' ? 'skipped' : 'failed';\n\n\t\t// Overwrite previous attempts so only the final retry result is kept\n\t\tthis.results.set(key, {\n\t\t\ttitle: test.title,\n\t\t\tproject,\n\t\t\tstatus,\n\t\t\tduration: result.duration,\n\t\t\tattachments: result.attachments.map((a) => ({\n\t\t\t\tname: a.name,\n\t\t\t\tpath: a.path,\n\t\t\t\tcontentType: a.contentType,\n\t\t\t})),\n\t\t});\n\t}\n\n\tasync onEnd(_result: FullResult): Promise<void> {\n\t\tconst duration = Date.now() - this.startTime;\n\t\tconst allResults = [...this.results.values()];\n\t\tconst passed = allResults.filter((r) => r.status === 'passed').length;\n\t\tconst failed = allResults.filter((r) => r.status === 'failed').length;\n\t\tconst skipped = allResults.filter((r) => r.status === 'skipped').length;\n\n\t\tconst browsers = [...new Set(allResults.map((r) => r.project))];\n\t\tconst failures: FailureEntry[] = [];\n\n\t\t// Collect failure images\n\t\tconst assetsDir = path.join(this.outputDir, 'assets');\n\t\tfor (const dir of ['expected', 'actual', 'diff']) {\n\t\t\tfs.mkdirSync(path.join(assetsDir, dir), { recursive: true });\n\t\t}\n\n\t\tfor (const testResult of allResults) {\n\t\t\tif (testResult.status !== 'failed') continue;\n\n\t\t\tconst titleParts = testResult.title.split(': ');\n\t\t\tconst storyTitle = titleParts[0] ?? testResult.title;\n\t\t\tconst variant = titleParts.slice(1).join(': ') || 'default';\n\t\t\tconst sanitizedName = testResult.title.replace(/[^a-zA-Z0-9-_]/g, '-').toLowerCase();\n\n\t\t\tconst imageAttachments = testResult.attachments.filter(\n\t\t\t\t(a) => a.path && a.contentType.startsWith('image/'),\n\t\t\t);\n\t\t\tconst hasDiff = imageAttachments.some((a) => a.name.includes('diff'));\n\n\t\t\tconst failure: FailureEntry = {\n\t\t\t\ttype: hasDiff ? 'diff' : 'new',\n\t\t\t\tstory: storyTitle,\n\t\t\t\tvariant,\n\t\t\t\tbrowser: testResult.project,\n\t\t\t\tdiffRatio: 0,\n\t\t\t\texpected: '',\n\t\t\t\tactual: '',\n\t\t\t\tdiff: '',\n\t\t\t};\n\n\t\t\tfor (const attachment of testResult.attachments) {\n\t\t\t\tif (!attachment.path) continue;\n\t\t\t\tconst ext = path.extname(attachment.path);\n\t\t\t\tconst destName = `${sanitizedName}-${testResult.project}${ext}`;\n\n\t\t\t\tif (attachment.name.includes('expected')) {\n\t\t\t\t\tconst dest = path.join(assetsDir, 'expected', destName);\n\t\t\t\t\tcopyFileIfExists(attachment.path, dest);\n\t\t\t\t\tfailure.expected = `assets/expected/${destName}`;\n\t\t\t\t} else if (attachment.name.includes('actual')) {\n\t\t\t\t\tconst dest = path.join(assetsDir, 'actual', destName);\n\t\t\t\t\tcopyFileIfExists(attachment.path, dest);\n\t\t\t\t\tfailure.actual = `assets/actual/${destName}`;\n\t\t\t\t} else if (attachment.name.includes('diff')) {\n\t\t\t\t\tconst dest = path.join(assetsDir, 'diff', destName);\n\t\t\t\t\tcopyFileIfExists(attachment.path, dest);\n\t\t\t\t\tfailure.diff = `assets/diff/${destName}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfailures.push(failure);\n\t\t}\n\n\t\tconst summary: TestSummary = {\n\t\t\ttotal: allResults.length,\n\t\t\tpassed,\n\t\t\tfailed,\n\t\t\tskipped,\n\t\t\tduration,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tbrowsers,\n\t\t\tfailures,\n\t\t};\n\n\t\tfs.mkdirSync(this.outputDir, { recursive: true });\n\t\tfs.writeFileSync(path.join(this.outputDir, 'summary.json'), JSON.stringify(summary, null, 2));\n\n\t\t// Generate HTML report\n\t\tconst html = generateHtmlReport(summary);\n\t\tfs.writeFileSync(path.join(this.outputDir, 'index.html'), html);\n\t}\n}\n\nfunction copyFileIfExists(src: string, dest: string): void {\n\ttry {\n\t\tfs.copyFileSync(src, dest);\n\t} catch {\n\t\t// source may not exist\n\t}\n}\n\nexport function generateHtmlReport(summary: TestSummary): string {\n\tconst require = createRequire(import.meta.url);\n\tconst bundlePath = require.resolve('@storywright/report');\n\tconst bundleJs = fs.readFileSync(bundlePath, 'utf-8');\n\n\t// Load CSS if it exists as a separate file\n\tconst bundleDir = path.dirname(bundlePath);\n\tconst assetsDir = path.join(bundleDir, 'assets');\n\tlet cssContent = '';\n\tif (fs.existsSync(assetsDir)) {\n\t\tconst cssFiles = fs.readdirSync(assetsDir).filter((f) => f.endsWith('.css'));\n\t\tfor (const cssFile of cssFiles) {\n\t\t\tcssContent += fs.readFileSync(path.join(assetsDir, cssFile), 'utf-8');\n\t\t}\n\t}\n\n\treturn `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Storywright Report</title>\n${cssContent ? `<style>${cssContent}</style>` : ''}\n</head>\n<body>\n<div id=\"app\"></div>\n<script>window.__STORYWRIGHT_SUMMARY__ = ${JSON.stringify(summary).replace(/</g, '\\\\u003c')};</script>\n<script>${bundleJs}</script>\n</body>\n</html>`;\n}\n\nexport default StorywrightReporter;\n"],"mappings":";AAAA,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAejB,IAAM,sBAAN,MAA8C;AAAA,EACrC;AAAA,EACA,UAAU,oBAAI,IASpB;AAAA,EACM,YAAY;AAAA,EAEpB,YAAY,UAAsC,CAAC,GAAG;AACrD,SAAK,YAAY,QAAQ,aAAa,KAAK,QAAQ,gBAAgB,QAAQ;AAAA,EAC5E;AAAA,EAEA,QAAQ,SAA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