afterbefore 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as child_process from 'child_process';
2
+ import * as playwright from 'playwright';
2
3
 
3
4
  type DiffStatus = "A" | "M" | "D" | "R" | "C";
4
5
  interface DiffFile {
@@ -25,24 +26,73 @@ interface AffectedRoute {
25
26
  reason: "direct" | "transitive";
26
27
  /** Depth in import graph (0 = direct change to page file) */
27
28
  depth: number;
29
+ /** Chain of files that triggered this route (source → ... → page) */
30
+ triggerChain: string[];
28
31
  }
29
32
  interface CaptureResult {
30
33
  route: string;
34
+ prefix: string;
31
35
  beforePath: string;
32
36
  afterPath: string;
33
37
  }
38
+ interface ScenarioAction {
39
+ click?: string;
40
+ scroll?: string;
41
+ wait?: number;
42
+ }
43
+ interface ScenarioConfig {
44
+ name: string;
45
+ actions: ScenarioAction[];
46
+ selector?: string;
47
+ }
48
+ interface AfterbeforeConfig {
49
+ scenarios?: Record<string, ScenarioConfig[]>;
50
+ }
51
+ interface CaptureTask {
52
+ route: string;
53
+ label: string;
54
+ prefix: string;
55
+ actions?: ScenarioAction[];
56
+ selector?: string;
57
+ skipAutoTabs?: boolean;
58
+ skipAutoSections?: boolean;
59
+ changedComponents?: string[];
60
+ }
34
61
  interface CompareResult {
35
62
  route: string;
63
+ prefix: string;
36
64
  beforePath: string;
37
65
  afterPath: string;
38
66
  diffPath: string;
39
- sideBySidePath: string;
67
+ comparePath: string;
40
68
  sliderPath: string;
41
69
  diffPixels: number;
42
70
  totalPixels: number;
43
71
  diffPercentage: number;
44
72
  changed: boolean;
45
73
  }
74
+ interface CaptureOptions {
75
+ /** Browser instance to reuse (avoids double launch) */
76
+ browser?: playwright.Browser;
77
+ /** Viewport width (default: 1280) */
78
+ width: number;
79
+ /** Viewport height (default: 720) */
80
+ height: number;
81
+ /** Playwright device descriptor name (e.g. "iPhone 14") */
82
+ device?: string;
83
+ /** Extra delay in ms after page load (default: 0) */
84
+ delay: number;
85
+ /** Auto-detect and capture ARIA tab states (default: true) */
86
+ autoTabs: boolean;
87
+ /** Maximum auto-detected tabs per route (default: 5) */
88
+ maxTabsPerRoute: number;
89
+ /** Auto-detect and capture heading-labeled sections (default: false) */
90
+ autoSections: boolean;
91
+ /** Maximum auto-detected sections per page state (default: 10) */
92
+ maxSectionsPerRoute: number;
93
+ /** Progress callback: called with (1-based index, route) for each route */
94
+ onProgress?: (index: number, route: string) => void;
95
+ }
46
96
  interface PipelineOptions {
47
97
  /** Base branch/ref to compare against (default: "main") */
48
98
  base: string;
@@ -54,6 +104,26 @@ interface PipelineOptions {
54
104
  cwd: string;
55
105
  /** Diff threshold percentage below which changes are considered negligible (default: 0.1) */
56
106
  threshold: number;
107
+ /** Maximum number of routes to capture (0 = unlimited, default: 6) */
108
+ maxRoutes: number;
109
+ /** Auto-open the HTML report in the default browser */
110
+ open: boolean;
111
+ /** Viewport width (default: 1280) */
112
+ width: number;
113
+ /** Viewport height (default: 720) */
114
+ height: number;
115
+ /** Playwright device descriptor name */
116
+ device?: string;
117
+ /** Extra delay in ms after page load (default: 0) */
118
+ delay: number;
119
+ /** Auto-detect and capture ARIA tab states (default: true) */
120
+ autoTabs: boolean;
121
+ /** Maximum auto-detected tabs per route (default: 5) */
122
+ maxTabsPerRoute: number;
123
+ /** Auto-detect and capture heading-labeled sections (default: false) */
124
+ autoSections: boolean;
125
+ /** Maximum auto-detected sections per page state (default: 10) */
126
+ maxSectionsPerRoute: number;
57
127
  }
58
128
  interface ServerInfo {
59
129
  port: number;
@@ -68,4 +138,6 @@ interface WorktreeInfo {
68
138
 
69
139
  declare function runPipeline(options: PipelineOptions): Promise<void>;
70
140
 
71
- export { type AffectedRoute, type CaptureResult, type ClassifiedFile, type CompareResult, type DiffFile, type DiffStatus, type FileCategory, type ImportGraph, type PipelineOptions, type ServerInfo, type WorktreeInfo, runPipeline };
141
+ declare function loadConfig(cwd: string): Promise<AfterbeforeConfig | null>;
142
+
143
+ export { type AffectedRoute, type AfterbeforeConfig, type CaptureOptions, type CaptureResult, type CaptureTask, type ClassifiedFile, type CompareResult, type DiffFile, type DiffStatus, type FileCategory, type ImportGraph, type PipelineOptions, type ScenarioConfig, type ServerInfo, type WorktreeInfo, loadConfig, runPipeline };