@juxtapose/core 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/agent/handoff.d.ts +8 -1
  2. package/dist/agent/handoff.js +75 -7
  3. package/dist/agent/handoff.js.map +1 -1
  4. package/dist/analysis/affected.d.ts +37 -0
  5. package/dist/analysis/affected.js +97 -22
  6. package/dist/analysis/affected.js.map +1 -1
  7. package/dist/analysis/cause.d.ts +32 -0
  8. package/dist/analysis/cause.js +187 -0
  9. package/dist/analysis/cause.js.map +1 -0
  10. package/dist/baseline/approve.d.ts +24 -0
  11. package/dist/baseline/approve.js +54 -0
  12. package/dist/baseline/approve.js.map +1 -0
  13. package/dist/baseline/git-store.d.ts +4 -0
  14. package/dist/baseline/git-store.js +22 -0
  15. package/dist/baseline/git-store.js.map +1 -1
  16. package/dist/browser/acquire.d.ts +11 -0
  17. package/dist/browser/acquire.js +15 -0
  18. package/dist/browser/acquire.js.map +1 -0
  19. package/dist/browser/browser.d.ts +53 -0
  20. package/dist/browser/browser.js +122 -0
  21. package/dist/browser/browser.js.map +1 -0
  22. package/dist/browser/cdp.d.ts +81 -0
  23. package/dist/browser/cdp.js +230 -0
  24. package/dist/browser/cdp.js.map +1 -0
  25. package/dist/browser/index.d.ts +9 -0
  26. package/dist/browser/index.js +10 -0
  27. package/dist/browser/index.js.map +1 -0
  28. package/dist/browser/install.d.ts +33 -0
  29. package/dist/browser/install.js +167 -0
  30. package/dist/browser/install.js.map +1 -0
  31. package/dist/browser/launch.d.ts +37 -0
  32. package/dist/browser/launch.js +265 -0
  33. package/dist/browser/launch.js.map +1 -0
  34. package/dist/browser/page.d.ts +125 -0
  35. package/dist/browser/page.js +564 -0
  36. package/dist/browser/page.js.map +1 -0
  37. package/dist/browser/pins.d.ts +12 -0
  38. package/dist/browser/pins.js +57 -0
  39. package/dist/browser/pins.js.map +1 -0
  40. package/dist/browser/resolve.d.ts +25 -0
  41. package/dist/browser/resolve.js +115 -0
  42. package/dist/browser/resolve.js.map +1 -0
  43. package/dist/browser/selectors.d.ts +10 -0
  44. package/dist/browser/selectors.js +60 -0
  45. package/dist/browser/selectors.js.map +1 -0
  46. package/dist/browser/transport.d.ts +39 -0
  47. package/dist/browser/transport.js +99 -0
  48. package/dist/browser/transport.js.map +1 -0
  49. package/dist/browser/zip.d.ts +27 -0
  50. package/dist/browser/zip.js +241 -0
  51. package/dist/browser/zip.js.map +1 -0
  52. package/dist/capture/capture.d.ts +7 -1
  53. package/dist/capture/capture.js +25 -8
  54. package/dist/capture/capture.js.map +1 -1
  55. package/dist/capture/env.d.ts +1 -1
  56. package/dist/capture/launch.d.ts +19 -1
  57. package/dist/capture/launch.js +91 -1
  58. package/dist/capture/launch.js.map +1 -1
  59. package/dist/capture/pool.d.ts +1 -1
  60. package/dist/capture/pool.js +41 -8
  61. package/dist/capture/pool.js.map +1 -1
  62. package/dist/capture/settle.d.ts +1 -1
  63. package/dist/capture/settle.js +2 -0
  64. package/dist/capture/settle.js.map +1 -1
  65. package/dist/capture/snap.d.ts +43 -0
  66. package/dist/capture/snap.js +103 -0
  67. package/dist/capture/snap.js.map +1 -0
  68. package/dist/capture/structure.d.ts +77 -0
  69. package/dist/capture/structure.js +498 -0
  70. package/dist/capture/structure.js.map +1 -0
  71. package/dist/diff/compare.d.ts +19 -0
  72. package/dist/diff/compare.js +19 -0
  73. package/dist/diff/compare.js.map +1 -0
  74. package/dist/diff/crops.d.ts +26 -0
  75. package/dist/diff/crops.js +92 -0
  76. package/dist/diff/crops.js.map +1 -0
  77. package/dist/diff/structural/classify.d.ts +29 -0
  78. package/dist/diff/structural/classify.js +113 -0
  79. package/dist/diff/structural/classify.js.map +1 -0
  80. package/dist/diff/structural/coverage.d.ts +11 -0
  81. package/dist/diff/structural/coverage.js +37 -0
  82. package/dist/diff/structural/coverage.js.map +1 -0
  83. package/dist/diff/structural/deltas.d.ts +29 -0
  84. package/dist/diff/structural/deltas.js +218 -0
  85. package/dist/diff/structural/deltas.js.map +1 -0
  86. package/dist/diff/structural/disambiguate.d.ts +3 -0
  87. package/dist/diff/structural/disambiguate.js +89 -0
  88. package/dist/diff/structural/disambiguate.js.map +1 -0
  89. package/dist/diff/structural/label.d.ts +15 -0
  90. package/dist/diff/structural/label.js +64 -0
  91. package/dist/diff/structural/label.js.map +1 -0
  92. package/dist/diff/structural/match.d.ts +13 -0
  93. package/dist/diff/structural/match.js +135 -0
  94. package/dist/diff/structural/match.js.map +1 -0
  95. package/dist/diff/structural/shift.d.ts +2 -0
  96. package/dist/diff/structural/shift.js +144 -0
  97. package/dist/diff/structural/shift.js.map +1 -0
  98. package/dist/diff/structural/summary.d.ts +31 -0
  99. package/dist/diff/structural/summary.js +420 -0
  100. package/dist/diff/structural/summary.js.map +1 -0
  101. package/dist/diff/structural.d.ts +40 -0
  102. package/dist/diff/structural.js +219 -0
  103. package/dist/diff/structural.js.map +1 -0
  104. package/dist/index.d.ts +25 -3
  105. package/dist/index.js +29 -2
  106. package/dist/index.js.map +1 -1
  107. package/dist/platform.d.ts +1 -1
  108. package/dist/platforms/urls.d.ts +3 -0
  109. package/dist/platforms/urls.js +89 -0
  110. package/dist/platforms/urls.js.map +1 -0
  111. package/dist/report/comment.js +9 -3
  112. package/dist/report/comment.js.map +1 -1
  113. package/dist/report/format.d.ts +18 -0
  114. package/dist/report/format.js +20 -0
  115. package/dist/report/format.js.map +1 -1
  116. package/dist/report/html.js +2 -2
  117. package/dist/report/html.js.map +1 -1
  118. package/dist/run/groups.d.ts +2 -0
  119. package/dist/run/groups.js +45 -0
  120. package/dist/run/groups.js.map +1 -0
  121. package/dist/run/run.d.ts +6 -2
  122. package/dist/run/run.js +74 -6
  123. package/dist/run/run.js.map +1 -1
  124. package/dist/shell-quote.d.ts +2 -0
  125. package/dist/shell-quote.js +10 -0
  126. package/dist/shell-quote.js.map +1 -0
  127. package/dist/types.d.ts +199 -1
  128. package/dist/url-platform.d.ts +2 -2
  129. package/dist/url-platform.js +2 -2
  130. package/dist/url-platform.js.map +1 -1
  131. package/package.json +5 -10
@@ -0,0 +1,2 @@
1
+ import type { DiffResult, RunGroup } from '../types.js';
2
+ export declare function computeGroups(results: DiffResult[]): RunGroup[];
@@ -0,0 +1,45 @@
1
+ // Which failing stories changed the same way. The verdict's signature
2
+ // already abstracts the element to role|tag and keeps the values, so "every
3
+ // button background #2563eb→#1d4ed8" hashes alike on every page that made
4
+ // that change; grouping is a bucket sort on it. Cold path: runs once per
5
+ // report, after every story is judged.
6
+ import { compareCodeUnits } from '../diff/structural/deltas.js';
7
+ export function computeGroups(results) {
8
+ const bySignature = new Map();
9
+ for (const r of results) {
10
+ // A verdict with no deltas has a signature that depends on the
11
+ // classification alone: unrelated identical, drifting or resized
12
+ // stories would "share" it, and there is no change to state.
13
+ if (r.status !== 'fail' || !r.structural || r.structural.deltaCount === 0)
14
+ continue;
15
+ const { signature, change, summary } = r.structural;
16
+ const text = change ?? summary;
17
+ const g = bySignature.get(signature);
18
+ if (!g)
19
+ bySignature.set(signature, { ids: [r.storyId], first: r.storyId, change: text });
20
+ else {
21
+ g.ids.push(r.storyId);
22
+ // The wording of the first story in code-unit order, whatever the
23
+ // input order: two verdicts of one signature can word it differently.
24
+ if (compareCodeUnits(r.storyId, g.first) < 0) {
25
+ g.first = r.storyId;
26
+ g.change = text;
27
+ }
28
+ }
29
+ }
30
+ // Collected through a Map, emitted through a sort: insertion order never
31
+ // reaches the report.
32
+ const groups = [];
33
+ for (const [signature, g] of bySignature) {
34
+ if (g.ids.length < 2)
35
+ continue;
36
+ const storyIds = [...g.ids].sort(compareCodeUnits);
37
+ groups.push({
38
+ signature,
39
+ summary: `${g.change} — ${storyIds.length} stories`,
40
+ storyIds,
41
+ });
42
+ }
43
+ return groups.sort((x, y) => y.storyIds.length - x.storyIds.length || compareCodeUnits(x.signature, y.signature));
44
+ }
45
+ //# sourceMappingURL=groups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.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,yEAAyE;IACzE,sBAAsB;IACtB,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC;QACzC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;YAAE,SAAS;QAC/B,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC;YACV,SAAS;YACT,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,MAAM,QAAQ,CAAC,MAAM,UAAU;YACnD,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAChB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CACtF,CAAC;AACJ,CAAC"}
package/dist/run/run.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { Browser } from 'playwright';
1
+ import type { Browser } from '../browser/browser.js';
2
2
  import type { Platform } from '../platform.js';
3
- import type { BaselineStore, DiffStatus, ProjectConfig, RunReport, StoryManifest, Viewport } from '../types.js';
3
+ import type { BaselineStore, DiffStatus, ProjectConfig, RunReport, StoryManifest, StructureSnapshot, Viewport } from '../types.js';
4
4
  import { type AncestryCheck } from '../baseline/status.js';
5
5
  import { type Phases } from './phases.js';
6
+ import type { CauseIndex } from '../analysis/cause.js';
6
7
  export declare const DEFAULT_VIEWPORT: Viewport;
7
8
  export interface RunOptions {
8
9
  browser: Browser;
@@ -24,11 +25,14 @@ export interface RunOptions {
24
25
  /** Collects per-phase wall time. Pass one to fold in phases the caller timed
25
26
  * itself (enumerate, affected, launch); omit and one is made internally. */
26
27
  phases?: Phases;
28
+ /** From `jux run --since`: consulted only for a story that failed. */
29
+ cause?: CauseIndex;
27
30
  }
28
31
  export interface RunArtifact {
29
32
  storyId: string;
30
33
  status: DiffStatus;
31
34
  current: Buffer;
32
35
  diff?: Buffer;
36
+ structure?: StructureSnapshot;
33
37
  }
34
38
  export declare function runCapture(opts: RunOptions): Promise<RunReport>;
package/dist/run/run.js CHANGED
@@ -7,8 +7,13 @@
7
7
  import { captureEnv } from '../capture/env.js';
8
8
  import { capturePool } from '../capture/pool.js';
9
9
  import { resolveStatus, toDiffStatus } from '../baseline/status.js';
10
- import { diffImages, resolveThreshold, resolveMinDiffPercent } from '../diff/diff.js';
10
+ import { decodeStructure } from '../capture/structure.js';
11
+ import { structuralDiff } from '../diff/structural.js';
12
+ import { compareCodeUnits } from '../diff/structural/deltas.js';
13
+ import { computeGroups } from './groups.js';
14
+ import { diffImages, resolveThreshold, resolveMinDiffPercent, } from '../diff/diff.js';
11
15
  import { phases } from './phases.js';
16
+ import { shellQuote } from '../shell-quote.js';
12
17
  export const DEFAULT_VIEWPORT = { width: 1280, height: 800 };
13
18
  export async function runCapture(opts) {
14
19
  const startedAt = new Date();
@@ -57,9 +62,14 @@ export async function runCapture(opts) {
57
62
  }
58
63
  results.push(await judge(outcome.snapshot, outcome.story, manifest, opts, p));
59
64
  }
60
- // Diffing happens inside the loop, so subtract it to leave capture alone.
61
- p.add('capture', Date.now() - captureStarted - (p.timings.diff ?? 0));
65
+ // Diffing and cause tracing happen inside the loop; subtract both to
66
+ // leave capture alone.
67
+ p.add('capture', Date.now() - captureStarted - (p.timings.diff ?? 0) - (p.timings.cause ?? 0));
62
68
  const summary = tally(results);
69
+ // Code-unit order: the report is byte-stable across machines, and
70
+ // localeCompare is not.
71
+ results.sort((a, b) => compareCodeUnits(a.storyId, b.storyId));
72
+ const groups = computeGroups(results);
63
73
  return {
64
74
  runId: opts.runId,
65
75
  branch: opts.branch,
@@ -70,8 +80,9 @@ export async function runCapture(opts) {
70
80
  env: captureEnv(opts.browser),
71
81
  capturedCount: opts.stories.length,
72
82
  totalCount: opts.totalCount,
73
- results: results.sort((a, b) => a.storyId.localeCompare(b.storyId)),
83
+ results,
74
84
  summary,
85
+ ...(groups.length > 0 ? { groups } : {}),
75
86
  durationMs: Date.now() - started,
76
87
  startedAt: startedAt.toISOString(),
77
88
  };
@@ -95,13 +106,23 @@ async function judge(snapshot, story, manifest, opts, p) {
95
106
  // pass / new / stale need no pixel work: there is either nothing to explain
96
107
  // or nothing to compare against.
97
108
  if (status !== 'fail') {
98
- await opts.onArtifact?.({ storyId: story.storyId, status, current: snapshot.image });
109
+ await opts.onArtifact?.({
110
+ storyId: story.storyId,
111
+ status,
112
+ current: snapshot.image,
113
+ structure: snapshot.structure,
114
+ });
99
115
  return base;
100
116
  }
101
117
  const baseline = await opts.store.get(story.storyId);
102
118
  if (!baseline) {
103
119
  // The manifest claimed a baseline the store can't produce.
104
- await opts.onArtifact?.({ storyId: story.storyId, status, current: snapshot.image });
120
+ await opts.onArtifact?.({
121
+ storyId: story.storyId,
122
+ status,
123
+ current: snapshot.image,
124
+ structure: snapshot.structure,
125
+ });
105
126
  return { ...base, error: 'baseline missing from store' };
106
127
  }
107
128
  // Counted as well as timed: under a byte-exact hash the number of diffs is
@@ -116,15 +137,62 @@ async function judge(snapshot, story, manifest, opts, p) {
116
137
  status,
117
138
  current: snapshot.image,
118
139
  diff: diff.diffImage,
140
+ structure: snapshot.structure,
119
141
  });
142
+ // Structure explains the failure after the pixels have decided it. The
143
+ // baseline sidecar is read only here, so a green run never touches one. A
144
+ // manifest hash is not a file: read the store, and treat anything
145
+ // unreadable as absent. This code runs only on a hash mismatch.
146
+ const structural = await tryStructural(opts, story, snapshot, diff, p);
120
147
  return {
121
148
  ...base,
122
149
  mismatchPixels: diff.mismatchPixels,
123
150
  mismatchPercent: diff.mismatchPercent,
124
151
  changedRegions: diff.changedRegions,
125
152
  error: diff.dimensionMismatch ? 'viewport size changed since baseline' : undefined,
153
+ ...(structural ? { structural } : {}),
126
154
  };
127
155
  }
156
+ /** A sidecar that is absent or unreadable is simply no baseline structure. */
157
+ async function readBaselineStructure(store, storyId) {
158
+ try {
159
+ const gz = store.getStructure ? await store.getStructure(storyId) : null;
160
+ return gz ? decodeStructure(gz) : undefined;
161
+ }
162
+ catch {
163
+ return undefined;
164
+ }
165
+ }
166
+ /** Structure explains a failure, never decides one, so nothing in here may
167
+ * fail the story: a missing, corrupt or malformed sidecar, a cause index
168
+ * that throws, or a bug in the diff, yields no verdict (or one without a
169
+ * cause) and the pixel result stands. */
170
+ async function tryStructural(opts, story, snapshot, pixels, p) {
171
+ if (!snapshot.structure)
172
+ return undefined;
173
+ let cause;
174
+ if (opts.cause) {
175
+ try {
176
+ cause = await p.time('cause', () => opts.cause.causeFor(story.componentPath));
177
+ }
178
+ catch {
179
+ cause = undefined;
180
+ }
181
+ }
182
+ try {
183
+ return structuralDiff({
184
+ baseline: await readBaselineStructure(opts.store, story.storyId),
185
+ current: snapshot.structure,
186
+ imagesIdentical: false,
187
+ pixels,
188
+ escalate: { command: `jux handoff ${shellQuote(story.storyId)}` },
189
+ ...(cause ? { cause } : {}),
190
+ });
191
+ }
192
+ catch {
193
+ return undefined;
194
+ }
195
+ }
128
196
  function tally(results) {
129
197
  const summary = {
130
198
  pass: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run/run.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,2EAA2E;AAC3E,qEAAqE;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAY/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAsB,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EA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C,OAAO,CAAC,EAAE,EAAE;YACjE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,OAAqB;IAClC,MAAM,OAAO,GAA+B;QAC1C,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,GAAG,EAAE,CAAC;QACN,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;KACR,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7C,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** Single-quote a value for a POSIX shell unless it is plainly safe. */
2
+ export declare function shellQuote(v: string): string;
@@ -0,0 +1,10 @@
1
+ // Every hint that prints a command prints one an agent can paste. A snap
2
+ // name with a space (`jux diff 'a b' x`) printed bare made the suggested
3
+ // `jux snap <url> --as a b` a different command. In core so the verdict's
4
+ // `escalate.command` and the CLI's hints share one implementation.
5
+ const SHELL_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;
6
+ /** Single-quote a value for a POSIX shell unless it is plainly safe. */
7
+ export function shellQuote(v) {
8
+ return SHELL_SAFE.test(v) ? v : `'${v.replaceAll("'", "'\\''")}'`;
9
+ }
10
+ //# sourceMappingURL=shell-quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-quote.js","sourceRoot":"","sources":["../src/shell-quote.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,yEAAyE;AACzE,0EAA0E;AAC1E,mEAAmE;AAEnE,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;AACpE,CAAC"}
package/dist/types.d.ts CHANGED
@@ -52,6 +52,49 @@ export interface Snapshot {
52
52
  capturedAt: string;
53
53
  /** Wall time for this story's capture, ms. */
54
54
  durationMs: number;
55
+ /** Visible elements and their styles, from the same frame as `image`.
56
+ * Absent when structure capture failed or was disabled — it explains a
57
+ * failure, it never decides one. */
58
+ structure?: StructureSnapshot;
59
+ }
60
+ export interface StructureRect {
61
+ x: number;
62
+ y: number;
63
+ w: number;
64
+ h: number;
65
+ }
66
+ export interface StructureElement {
67
+ /** tag + (#id | [data-testid] | :nth-of-type) chain from <html>. */
68
+ path: string;
69
+ /** Index of the nearest kept ancestor in `elements`, null at the root. */
70
+ parent: number | null;
71
+ tag: string;
72
+ id?: string;
73
+ testId?: string;
74
+ classes?: string[];
75
+ role?: string;
76
+ name?: string;
77
+ text?: string;
78
+ src?: string;
79
+ rect: StructureRect;
80
+ paintOrder: number;
81
+ /** Compact: see effectiveStyle() in capture/structure.ts. */
82
+ styles: Record<string, string>;
83
+ }
84
+ export interface StructureSnapshot {
85
+ schema: 'juxtapose.structure/v1';
86
+ viewport: Viewport;
87
+ /** sha256 of the canonical JSON of `elements`. Equal ⇒ identical structure
88
+ * and styles, so a pixel difference is render drift. */
89
+ structureHash: string;
90
+ /** Full document height, from CDP. Greater than viewport.height means part
91
+ * of the page was never captured — PR (b)'s `below-fold` flag reads this. */
92
+ contentHeight: number;
93
+ elements: StructureElement[];
94
+ truncated?: {
95
+ kept: number;
96
+ total: number;
97
+ };
55
98
  }
56
99
  export interface ChangedRegion {
57
100
  x: number;
@@ -59,6 +102,126 @@ export interface ChangedRegion {
59
102
  width: number;
60
103
  height: number;
61
104
  }
105
+ /** One changed fact between two structure snapshots. `el` is a short human
106
+ * label (`button[name="Save"]`, `div#row-1`, `div.card`, or a trimmed path). */
107
+ export type Delta = {
108
+ kind: 'text';
109
+ el: string;
110
+ from: string;
111
+ to: string;
112
+ } | {
113
+ kind: 'style';
114
+ el: string;
115
+ prop: string;
116
+ from: string;
117
+ to: string;
118
+ } | {
119
+ kind: 'attr';
120
+ el: string;
121
+ attr: 'src' | 'role' | 'name';
122
+ from: string;
123
+ to: string;
124
+ } | {
125
+ kind: 'added';
126
+ el: string;
127
+ rect: StructureRect;
128
+ } | {
129
+ kind: 'removed';
130
+ el: string;
131
+ rect: StructureRect;
132
+ } | {
133
+ kind: 'moved';
134
+ el: string;
135
+ dx: number;
136
+ dy: number;
137
+ } | {
138
+ kind: 'resized';
139
+ el: string;
140
+ dw: number;
141
+ dh: number;
142
+ }
143
+ /** ≥3 contiguous elements after `after` moved by the same (dx, dy). */
144
+ | {
145
+ kind: 'shift';
146
+ after: string;
147
+ dx: number;
148
+ dy: number;
149
+ count: number;
150
+ };
151
+ export type Classification = 'identical' | 'render-drift' | 'dimension-change' | 'element-added' | 'element-removed' | 'reflow' | 'geometry' | 'text-only' | 'style-only' | 'attr-only' | 'mixed' | 'unknown';
152
+ /** Sub-tags of `style-only`, so "colour tweak" and "spacing change" read
153
+ * differently at a glance. */
154
+ export type StyleTag = 'color' | 'typography' | 'spacing' | 'border' | 'effects';
155
+ export type Flag = 'element-removed' | 'text-changed' | 'large-reflow' | 'unexplained-pixels'
156
+ /** The images differ but the pixel diff marked nothing: the change is below
157
+ * its tolerance, and the structural deltas are the change. */
158
+ | 'sub-threshold' | 'structure-truncated' | 'no-baseline-structure' | 'no-current-structure'
159
+ /** Either side's content is taller than the viewport: changes below the
160
+ * fold are invisible to both pixels and structure. */
161
+ | 'below-fold';
162
+ export type CauseKind =
163
+ /** At least one changed file is in the story's import closure. */
164
+ 'in-closure'
165
+ /** A changed file reaches every story: a root lockfile or a platform config dir. */
166
+ | 'config'
167
+ /** The closure was traced and no changed file is in it: the strongest
168
+ * "this is not your code" the tool can give, especially beside render-drift. */
169
+ | 'none-in-closure'
170
+ /** No --since, no manifest, git failed, or the story is not in the graph. */
171
+ | 'unknown';
172
+ /** Why this story changed: the cheap link only (story → import closure →
173
+ * changed files). Matched CSS rules and source lines are later rows. */
174
+ export interface Cause {
175
+ kind: CauseKind;
176
+ /** At most 5, nearest first; posix paths relative to the project root. */
177
+ files: Array<{
178
+ path: string;
179
+ distance: number;
180
+ }>;
181
+ /** `in-closure` only: the closure was not fully traced (a bundled chunk
182
+ * with no src, or a changed file the manifest never names), so the cause
183
+ * may be a file not listed. Absent, never false, when the trace was full. */
184
+ partial?: true;
185
+ }
186
+ /** Tier-0: what changed, in a few hundred characters, with whether it
187
+ * explains every changed pixel. The whole output of `jux diff`. */
188
+ export interface StructuralVerdict {
189
+ schema: 'juxtapose.verdict/v1';
190
+ classification: Classification;
191
+ /** Empty unless classification is `style-only` or `mixed`. */
192
+ styleTags: StyleTag[];
193
+ /** Templated, deterministic, ≤ 300 chars. */
194
+ summary: string;
195
+ /** The change with every element reduced to role|tag and no per-story
196
+ * tail, ≤ 160 chars: what stories sharing a `signature` have in common.
197
+ * Absent when there are no deltas. */
198
+ change?: string;
199
+ /** At most 20, and only the prefix that keeps the whole verdict within
200
+ * 1,500 chars; `deltaCount` is the total. */
201
+ deltas: Delta[];
202
+ /** Counted after suppression: a child that only followed its parent's
203
+ * move or resize, and a style inherited from where it originated, are not
204
+ * deltas, nor is an added/removed element hidden by the other side's
205
+ * truncation; a shift run counts once. */
206
+ deltaCount: number;
207
+ /** Fraction of changed-region area intersecting some delta's element. */
208
+ coverage: number;
209
+ /** ≥ 0.98 | ≥ 0.5 | below. */
210
+ explained: 'full' | 'partial' | 'none';
211
+ /** The prefix that fits the 1,500-char verdict; `coverage` covers all. */
212
+ unexplainedRegions: ChangedRegion[];
213
+ flags: Flag[];
214
+ /** Present only in `jux run --since`; absent from `jux diff`. */
215
+ cause?: Cause;
216
+ /** sha256 over the classification and the delta set with elements
217
+ * abstracted to role|tag, so two pages with the same change share one.
218
+ * Over the same post-suppression facts `deltaCount` counts. */
219
+ signature: string;
220
+ /** The exact command for tier-3 pixels. */
221
+ escalate: {
222
+ command: string;
223
+ };
224
+ }
62
225
  export type DiffStatus = 'pass' | 'fail' | 'new' | 'stale' | 'skip';
63
226
  export interface DiffResult {
64
227
  storyId: string;
@@ -76,8 +239,22 @@ export interface DiffResult {
76
239
  viewport?: Viewport;
77
240
  /** Set when the capture or diff threw. status is 'fail' in that case. */
78
241
  error?: string;
242
+ /** Tier-0 explanation of a failure. Present only when status is 'fail' and
243
+ * the current capture produced a structure; never consulted on pass. */
244
+ structural?: StructuralVerdict;
79
245
  durationMs: number;
80
246
  }
247
+ /** One change seen on several stories: the same signature on ≥2 failing
248
+ * results. Listing them is what turns 40 handoffs into one decision;
249
+ * approving by group is a later row. */
250
+ export interface RunGroup {
251
+ signature: string;
252
+ /** The shared change, as `<change> — N stories`: the verdict's `change`
253
+ * (elements as role|tag), not one page's labelled summary. */
254
+ summary: string;
255
+ /** ≥ 2, code-unit sorted. */
256
+ storyIds: string[];
257
+ }
81
258
  export interface RunReport {
82
259
  runId: string;
83
260
  branch: string;
@@ -90,6 +267,8 @@ export interface RunReport {
90
267
  totalCount: number;
91
268
  results: DiffResult[];
92
269
  summary: Record<DiffStatus, number>;
270
+ /** Present when at least one signature is shared by ≥2 failing stories. */
271
+ groups?: RunGroup[];
93
272
  durationMs: number;
94
273
  startedAt: string;
95
274
  }
@@ -114,6 +293,9 @@ export interface ApprovalMeta {
114
293
  /** Absent on entries approved before this was recorded. Absent must not read
115
294
  * as "matches": an unknown origin is unknown, not current. */
116
295
  env?: CaptureEnv;
296
+ /** structureHash of the approved capture's sidecar. Absent when the capture
297
+ * had no structure, or was approved before sidecars existed. */
298
+ structureHash?: string;
117
299
  }
118
300
  export interface BaselineEntry extends ApprovalMeta {
119
301
  /** sha256 of the baseline image bytes. Detects drift between manifest
@@ -126,10 +308,20 @@ export interface BaselineManifest {
126
308
  version: 1;
127
309
  baselines: Record<string, BaselineEntry>;
128
310
  }
311
+ /** One page for the `urls` platform. */
312
+ export interface UrlEntry {
313
+ /** Stable id; used as the story id and for file names. */
314
+ id: string;
315
+ /** Absolute, or relative to --origin. */
316
+ url: string;
317
+ params?: StoryParams;
318
+ }
129
319
  /** Project config, from juxtapose.config.{ts,js,json} or package.json#juxtapose. */
130
320
  export interface ProjectConfig {
131
321
  /** Which workbench. Autodetected when omitted. */
132
- platform?: 'storybook' | 'ladle';
322
+ platform?: 'storybook' | 'ladle' | 'urls';
323
+ /** Pages to capture when `platform` is 'urls'. */
324
+ urls?: UrlEntry[];
133
325
  /** Where the built static workbench lives. */
134
326
  buildDir?: string;
135
327
  /** Capture against an already-running dev server instead of building. */
@@ -167,4 +359,10 @@ export interface BaselineStore {
167
359
  remove(storyId: string): Promise<void>;
168
360
  readManifest(): Promise<BaselineManifest>;
169
361
  writeManifest(manifest: BaselineManifest): Promise<void>;
362
+ /** Optional: stores that can hold the gzipped structure sidecar. */
363
+ putStructure?(storyId: string, gz: Buffer): Promise<void>;
364
+ getStructure?(storyId: string): Promise<Buffer | null>;
365
+ /** Optional: where the baseline image lives on disk, for stores that keep
366
+ * one. The handoff hands it to `jux diff … --crops`. */
367
+ locate?(storyId: string): string | undefined;
170
368
  }
@@ -1,8 +1,8 @@
1
- import type { Page } from 'playwright';
1
+ import type { Page } from './browser/page.js';
2
2
  /**
3
3
  * Build a `showStory` implementation from a URL builder.
4
4
  *
5
- * Note `waitUntil: 'load'` rather than `networkidle`: the platform's own
5
+ * `page.goto` resolves on the main frame's `load`, not network idle: the platform's own
6
6
  * render signal and core's settle pipeline decide when the page is actually
7
7
  * ready. Waiting for network idle here would be both slower and less reliable
8
8
  * — a story that polls would never satisfy it.
@@ -9,14 +9,14 @@
9
9
  /**
10
10
  * Build a `showStory` implementation from a URL builder.
11
11
  *
12
- * Note `waitUntil: 'load'` rather than `networkidle`: the platform's own
12
+ * `page.goto` resolves on the main frame's `load`, not network idle: the platform's own
13
13
  * render signal and core's settle pipeline decide when the page is actually
14
14
  * ready. Waiting for network idle here would be both slower and less reliable
15
15
  * — a story that polls would never satisfy it.
16
16
  */
17
17
  export function navigateToStory(storyUrl) {
18
18
  return async (page, storyId, baseUrl) => {
19
- await page.goto(storyUrl(baseUrl, storyId), { waitUntil: 'load' });
19
+ await page.goto(storyUrl(baseUrl, storyId));
20
20
  };
21
21
  }
22
22
  //# sourceMappingURL=url-platform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"url-platform.js","sourceRoot":"","sources":["../src/url-platform.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,8CAA8C;AAC9C,EAAE;AACF,uEAAuE;AACvE,oEAAoE;AAIpE;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAsD;IAEtD,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QACtC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"url-platform.js","sourceRoot":"","sources":["../src/url-platform.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,8CAA8C;AAC9C,EAAE;AACF,uEAAuE;AACvE,oEAAoE;AAIpE;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAsD;IAEtD,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QACtC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@juxtapose/core",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "Platform-agnostic capture, diff, baseline and analysis core for juxtapose.",
6
6
  "keywords": [
7
7
  "visual-regression",
8
8
  "screenshot-testing",
9
- "playwright",
9
+ "cdp",
10
10
  "visual-testing",
11
11
  "pixelmatch"
12
12
  ],
@@ -15,6 +15,9 @@
15
15
  "access": "public"
16
16
  },
17
17
  "license": "MIT",
18
+ "engines": {
19
+ "node": ">=22.2.0"
20
+ },
18
21
  "main": "./dist/index.js",
19
22
  "types": "./dist/index.d.ts",
20
23
  "exports": {
@@ -29,14 +32,6 @@
29
32
  "pixelmatch": "^6.0.0",
30
33
  "sharp": "^0.35.3"
31
34
  },
32
- "peerDependencies": {
33
- "playwright": "^1.48.0"
34
- },
35
- "peerDependenciesMeta": {
36
- "playwright": {
37
- "optional": true
38
- }
39
- },
40
35
  "devDependencies": {
41
36
  "@types/pixelmatch": "^5.2.6"
42
37
  },