@recursica/adapter-tester 5.2.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -41,32 +41,32 @@ function ne(e, t) {
41
41
  shell: !0
42
42
  });
43
43
  let n = !1;
44
- const l = setTimeout(() => {
44
+ const p = setTimeout(() => {
45
45
  n || (n = !0, s.kill(), o(
46
46
  new Error(
47
47
  `Timed out after ${t}ms waiting for ${e.name}'s Storybook to report its URL (no "Local: http://localhost:<port>" line seen in its output).`
48
48
  )
49
49
  ));
50
- }, t), p = (i, u) => {
50
+ }, t), l = (i, u) => {
51
51
  const h = i.toString();
52
52
  for (const c of h.split(`
53
53
  `))
54
54
  if (c.trim()) {
55
- const f = u ? `${e.name} SB ERROR` : `${e.name} SB`;
56
- (u ? console.error : console.log)(`[${f}] ${c.trim()}`);
55
+ const m = u ? `${e.name} SB ERROR` : `${e.name} SB`;
56
+ (u ? console.error : console.log)(`[${m}] ${c.trim()}`);
57
57
  }
58
58
  if (n) return;
59
59
  const v = h.replace(ee, "").match(te);
60
60
  if (v) {
61
- n = !0, clearTimeout(l);
62
- const c = v[1], f = Number(new URL(c).port);
63
- se(e.cacheFile, f), r({ url: c, port: f, process: s });
61
+ n = !0, clearTimeout(p);
62
+ const c = v[1], m = Number(new URL(c).port);
63
+ se(e.cacheFile, m), r({ url: c, port: m, process: s });
64
64
  }
65
65
  };
66
- (y = s.stdout) == null || y.on("data", (i) => p(i, !1)), (w = s.stderr) == null || w.on("data", (i) => p(i, !0)), s.on("error", (i) => {
67
- n || (n = !0, clearTimeout(l), o(i));
66
+ (y = s.stdout) == null || y.on("data", (i) => l(i, !1)), (w = s.stderr) == null || w.on("data", (i) => l(i, !0)), s.on("error", (i) => {
67
+ n || (n = !0, clearTimeout(p), o(i));
68
68
  }), s.on("exit", (i) => {
69
- n || (n = !0, clearTimeout(l), o(
69
+ n || (n = !0, clearTimeout(p), o(
70
70
  new Error(
71
71
  `${e.name}'s Storybook exited (code ${i}) before reporting its URL.`
72
72
  )
@@ -109,12 +109,12 @@ function ie(e) {
109
109
  );
110
110
  }
111
111
  async function ae(e, t, r = {}) {
112
- const [o, s] = e.targets, [n, l] = t;
113
- if (!(o != null && o.sourceOfTruth) || !s || s.sourceOfTruth || !n || !l)
112
+ const [o, s] = e.targets, [n, p] = t;
113
+ if (!(o != null && o.sourceOfTruth) || !s || s.sourceOfTruth || !n || !p)
114
114
  throw new Error(
115
115
  "adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json."
116
116
  );
117
- const p = r.port ?? 6010;
117
+ const l = r.port ?? 6010;
118
118
  console.log(
119
119
  `[Dev Launcher] Resolving ${o.name} and ${s.name} Storybooks...`
120
120
  );
@@ -122,14 +122,14 @@ async function ae(e, t, r = {}) {
122
122
  D(
123
123
  A(o.name, n)
124
124
  ),
125
- D(A(s.name, l))
125
+ D(A(s.name, p))
126
126
  ]);
127
127
  console.log("[Dev Launcher] Both Storybooks are active and responsive!");
128
128
  const i = [y.process, w.process].filter(
129
- (m) => m !== null
129
+ (f) => f !== null
130
130
  ), u = K(), h = a(_, "../public"), v = a(_, "../report-header.txt");
131
- u.get("/", (m, b, k) => {
132
- if (m.query.path) {
131
+ u.get("/", (f, b, k) => {
132
+ if (f.query.path) {
133
133
  k();
134
134
  return;
135
135
  }
@@ -143,7 +143,7 @@ async function ae(e, t, r = {}) {
143
143
  })};<\/script>`
144
144
  );
145
145
  b.send(S);
146
- }), u.get("/report-header.txt", (m, b) => {
146
+ }), u.get("/report-header.txt", (f, b) => {
147
147
  if (e.reportHeader !== void 0) {
148
148
  b.type("text/plain").send(e.reportHeader);
149
149
  return;
@@ -162,36 +162,36 @@ async function ae(e, t, r = {}) {
162
162
  })
163
163
  );
164
164
  let c = !1;
165
- const f = () => {
165
+ const m = () => {
166
166
  if (!c) {
167
167
  c = !0, console.log(
168
168
  `
169
169
  [Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`
170
170
  );
171
- for (const m of i) m.kill("SIGINT");
171
+ for (const f of i) f.kill("SIGINT");
172
172
  process.exit(0);
173
173
  }
174
174
  };
175
- process.on("SIGINT", f), process.on("SIGTERM", f), u.listen(p, () => {
175
+ process.on("SIGINT", m), process.on("SIGTERM", m), u.listen(l, () => {
176
176
  console.log(`
177
177
  ====================================================
178
178
  🚀 Adapter Dev Mode proxy running at:
179
- http://localhost:${p}
179
+ http://localhost:${l}
180
180
  ====================================================
181
- `), ie(`http://localhost:${p}`);
181
+ `), ie(`http://localhost:${l}`);
182
182
  });
183
183
  }
184
- const ce = "http://json-schema.org/draft-07/schema#", de = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json", ue = "adapter-tester.config.json", le = "Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.", pe = "object", he = !1, fe = { $schema: { type: "string", description: 'Optional pointer to this schema for editor autocomplete, e.g. "https://raw.githubusercontent.com/borderux/recursica/main/packages/adapter-tester/src/adapter-tester.schema.json".' }, name: { type: "string", description: `Label for this project's own target. Defaults to the unscoped name in this project's package.json (e.g. "@recursica/some-adapter" -> "some-adapter").` }, storybook: { type: "object", additionalProperties: !1, description: "This project's own Storybook target.", properties: { port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from this Storybook's own startup output, since Storybook silently falls back to an OS-assigned port whenever this one is taken. Auto-detected from this project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag) when omitted, falling back to 6006." }, command: { type: "string", description: "Command that boots the target's Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }, sourceOfTruth: { description: 'The comparison target. Defaults to `{ "type": "mantine-harness" }`.', oneOf: [{ type: "object", additionalProperties: !1, description: "Default mode: boots a throwaway harness that installs the published @recursica/adapter-mantine-v8 from npm — no monorepo checkout required.", properties: { type: { const: "mantine-harness" }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the throwaway harness's Storybook's own startup output." }, mantineAdapterVersion: { type: "string", description: "npm version/tag of @recursica/adapter-mantine-v8 to install in the harness. Defaults to `latest`." }, storybookTemplateVersion: { type: "string", description: "npm version/tag of @recursica/storybook-template to install in the harness. Defaults to `latest`." }, tokensSource: { type: "string", enum: ["target", "mantine-package"], description: `Which Recursica token snapshot the harness's Mantine components render with. "target" (default): this project's own committed recursica_variables_scoped.css/recursica_tokens.json/recursica_brand.json/recursica_ui-kit.json — makes the divergence check mean exactly "given the same tokens this project is using, does it render the same as Mantine's own components," isolating adapter-mapping correctness from any token-snapshot drift between repos. "mantine-package": @recursica/adapter-mantine-v8's own bundled token files instead (whatever it was last published with) — also flags, as a side effect, a project whose own committed tokens have gone stale relative to Mantine's. Never the deprecated @recursica/official-release package.` } } }, { type: "object", additionalProperties: !1, description: "Non-standard mode: points at an already-addressable Storybook — e.g. a sibling workspace package's own Storybook inside this monorepo.", required: ["type"], properties: { type: { const: "url" }, name: { type: "string", description: 'Label for the source-of-truth target. Defaults to "Mantine".' }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the source-of-truth Storybook's own startup output. Defaults to 6011." }, command: { type: "string", description: "Command that boots the source-of-truth Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }] }, isSourceOfTruthAdapter: { type: "boolean", description: "True only for the source-of-truth adapter's own config (@recursica/adapter-mantine-v8). Skips `sourceOfTruth` entirely — there's nothing above it to diverge from — and runs the own-drift golden check standalone, against just this project's own Storybook. Defaults to false." }, goldenThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the own-drift check (this project's live render vs. its own committed `test/golden/` image), in mismatched pixels, before a story is considered a failure. Same library/component on both sides, so this should stay tight. Defaults to 10. AI agents must not modify this field — see AGENT.md.", default: 10 }, sourceOfTruthThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the source-of-truth divergence check (this project's golden vs. the source-of-truth adapter's golden), in mismatched pixels, before a difference is flagged. Comparing across two different component libraries has legitimate structural variation (native control widgets, font rendering, etc.), so this is expected to be set much higher than `goldenThresholdPixels`. Ignored on the source-of-truth adapter's own config (`isSourceOfTruthAdapter: true`), which has no divergence check. Defaults to 3500. AI agents must not modify this field — see AGENT.md.", default: 3500 }, stories: { type: "object", additionalProperties: { type: "object", additionalProperties: !1, properties: { goldenThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' own-drift check, in mismatched pixels. Overrides `goldenThresholdPixels`." }, sourceOfTruthThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' source-of-truth divergence check, in mismatched pixels. Overrides `sourceOfTruthThresholdPixels`." }, exclude: { type: "boolean", description: "Skip matching stories entirely — no own-drift check, no divergence check, no golden captured. For stories that don't have a cross-adapter counterpart; use `excludeTitlePrefixes` to drop a whole title instead." } } }, description: "Per-story overrides, keyed by story id prefix (a story matches if its id equals the key or starts with it). When more than one key matches a story, the longest (most specific) key wins." }, excludeTitlePrefixes: { type: "array", items: { type: "string" }, description: "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)." }, reportHeader: { type: "string", description: 'Overrides the AI report header text shown in Dev Mode\'s "Full Report" export. Defaults to the contents of `report-header.txt`.' } }, me = {
184
+ const ce = "http://json-schema.org/draft-07/schema#", de = "https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/adapter-tester.schema.json", ue = "adapter-tester.config.json", pe = "Configuration for @recursica/adapter-tester. All fields are optional — an adapter repo with a normal `storybook` npm script needs no config file at all.", le = "object", he = !1, me = { $schema: { type: "string", description: 'Optional pointer to this schema for editor autocomplete, e.g. "https://raw.githubusercontent.com/borderux/recursica/main/packages/adapter-tester/src/adapter-tester.schema.json".' }, name: { type: "string", description: `Label for this project's own target. Defaults to the unscoped name in this project's package.json (e.g. "@recursica/some-adapter" -> "some-adapter").` }, storybook: { type: "object", additionalProperties: !1, description: "This project's own Storybook target.", properties: { port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from this Storybook's own startup output, since Storybook silently falls back to an OS-assigned port whenever this one is taken. Auto-detected from this project's own `scripts.storybook` (a `-p <port>`/`--port <port>` flag) when omitted, falling back to 6006." }, command: { type: "string", description: "Command that boots the target's Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }, sourceOfTruth: { description: 'The comparison target. Defaults to `{ "type": "mantine-harness" }`.', oneOf: [{ type: "object", additionalProperties: !1, description: "Default mode: boots a throwaway harness that installs the published @recursica/adapter-mantine-v8 from npm — no monorepo checkout required.", properties: { type: { const: "mantine-harness" }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the throwaway harness's Storybook's own startup output." }, mantineAdapterVersion: { type: "string", description: "npm version/tag of @recursica/adapter-mantine-v8 to install in the harness. Defaults to `latest`." }, storybookTemplateVersion: { type: "string", description: "npm version/tag of @recursica/storybook-template to install in the harness. Defaults to `latest`." }, tokensSource: { type: "string", enum: ["target", "mantine-package"], description: `Which Recursica token snapshot the harness's Mantine components render with. "target" (default): this project's own committed recursica_variables_scoped.css/recursica_tokens.json/recursica_brand.json/recursica_ui-kit.json — makes the divergence check mean exactly "given the same tokens this project is using, does it render the same as Mantine's own components," isolating adapter-mapping correctness from any token-snapshot drift between repos. "mantine-package": @recursica/adapter-mantine-v8's own bundled token files instead (whatever it was last published with) — also flags, as a side effect, a project whose own committed tokens have gone stale relative to Mantine's. Never the deprecated @recursica/official-release package.` } } }, { type: "object", additionalProperties: !1, description: "Non-standard mode: points at an already-addressable Storybook — e.g. a sibling workspace package's own Storybook inside this monorepo.", required: ["type"], properties: { type: { const: "url" }, name: { type: "string", description: 'Label for the source-of-truth target. Defaults to "Mantine".' }, port: { type: "integer", minimum: 1, maximum: 65535, description: "First-guess port only, not authoritative — the real port is auto-detected from the source-of-truth Storybook's own startup output. Defaults to 6011." }, command: { type: "string", description: "Command that boots the source-of-truth Storybook. Defaults to `npm run storybook`." }, cwd: { type: "string", description: 'Directory the command runs in, relative to the config file. Defaults to ".".' } } }] }, isSourceOfTruthAdapter: { type: "boolean", description: "True only for the source-of-truth adapter's own config (@recursica/adapter-mantine-v8). Skips `sourceOfTruth` entirely — there's nothing above it to diverge from — and runs the own-drift golden check standalone, against just this project's own Storybook. Defaults to false." }, goldenThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the own-drift check (this project's live render vs. its own committed `test/golden/` image), in mismatched pixels, before a story is considered a failure. Same library/component on both sides, so this should stay tight. Defaults to 10. AI agents must not modify this field — see AGENT.md.", default: 10 }, sourceOfTruthThresholdPixels: { type: "number", minimum: 0, description: "Global visual diff threshold for the source-of-truth divergence check (this project's golden vs. the source-of-truth adapter's golden), in mismatched pixels, before a difference is flagged. Comparing across two different component libraries has legitimate structural variation (native control widgets, font rendering, etc.), so this is expected to be set much higher than `goldenThresholdPixels`. Ignored on the source-of-truth adapter's own config (`isSourceOfTruthAdapter: true`), which has no divergence check. Defaults to 3500. AI agents must not modify this field — see AGENT.md.", default: 3500 }, stories: { type: "object", additionalProperties: { type: "object", additionalProperties: !1, properties: { goldenThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' own-drift check, in mismatched pixels. Overrides `goldenThresholdPixels`." }, sourceOfTruthThreshold: { type: "number", minimum: 0, description: "Diff threshold override for matching stories' source-of-truth divergence check, in mismatched pixels. Overrides `sourceOfTruthThresholdPixels`." }, viewport: { type: "object", additionalProperties: !1, required: ["width", "height"], description: "Browser viewport (CSS pixels) matching stories are captured at, instead of the default 800x600. For stories whose rendering depends on the page width itself, such as `@media` breakpoints, which a story can't change from inside.", properties: { width: { type: "integer", minimum: 1 }, height: { type: "integer", minimum: 1 } } }, exclude: { type: "boolean", description: "Skip matching stories entirely — no own-drift check, no divergence check, no golden captured. For stories that don't have a cross-adapter counterpart; use `excludeTitlePrefixes` to drop a whole title instead." } } }, description: "Per-story overrides, keyed by story id prefix (a story matches if its id equals the key or starts with it). When more than one key matches a story, the longest (most specific) key wins." }, excludeTitlePrefixes: { type: "array", items: { type: "string" }, description: "Storybook title prefixes to exclude from comparison, in addition to the built-in denylist (`Theme/*`, `Tokens/*`, `Introduction`)." }, reportHeader: { type: "string", description: 'Overrides the AI report header text shown in Dev Mode\'s "Full Report" export. Defaults to the contents of `report-header.txt`.' } }, fe = {
185
185
  $schema: ce,
186
186
  $id: de,
187
187
  title: ue,
188
- description: le,
189
- type: pe,
188
+ description: pe,
189
+ type: le,
190
190
  additionalProperties: he,
191
- properties: fe
191
+ properties: me
192
192
  }, ge = Z, V = new Q.Ajv({ allErrors: !0, strict: !0 });
193
193
  ge(V);
194
- const L = V.compile(me);
194
+ const L = V.compile(fe);
195
195
  function ye(e, t) {
196
196
  if (L(e)) return;
197
197
  const r = (L.errors ?? []).map((o) => {
@@ -203,7 +203,7 @@ function ye(e, t) {
203
203
  throw new Error(`Invalid ${t}:
204
204
  ${r}`);
205
205
  }
206
- const we = "@recursica/adapter-mantine-v8", ve = "adapter-tester.config.json", R = "npm run storybook", be = 6006, F = 6011, C = "Mantine", ke = 10, Te = 3500;
206
+ const we = "@recursica/adapter-mantine-v8", ve = "adapter-tester.config.json", F = "npm run storybook", be = 6006, R = 6011, C = "Mantine", ke = 10, Te = 3500;
207
207
  function H(e) {
208
208
  const t = a(e, "package.json");
209
209
  if (!U(t))
@@ -229,16 +229,16 @@ function xe(e) {
229
229
  return ye(r, t), r;
230
230
  }
231
231
  function Ee(e, t = {}) {
232
- var f, m, b;
232
+ var m, f, b;
233
233
  const r = xe(e), o = r.isSourceOfTruthAdapter ?? !1;
234
234
  if (t.mantineAdapterVersion && o)
235
235
  throw new Error(
236
236
  "--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for."
237
237
  );
238
- const s = r.name ?? Oe(e), n = ((f = r.storybook) == null ? void 0 : f.port) ?? Se(e), l = ((m = r.storybook) == null ? void 0 : m.command) ?? R, p = $(e, ((b = r.storybook) == null ? void 0 : b.cwd) ?? "."), y = {
239
- command: l,
238
+ const s = r.name ?? Oe(e), n = ((m = r.storybook) == null ? void 0 : m.port) ?? Se(e), p = ((f = r.storybook) == null ? void 0 : f.command) ?? F, l = $(e, ((b = r.storybook) == null ? void 0 : b.cwd) ?? "."), y = {
239
+ command: p,
240
240
  port: n,
241
- cwd: p,
241
+ cwd: l,
242
242
  reuseExistingServer: !process.env.CI,
243
243
  cacheFile: a(e, ".adapter-tester", "last-port-own.json"),
244
244
  timeout: 120 * 1e3
@@ -254,7 +254,7 @@ function Ee(e, t = {}) {
254
254
  // to that package's own `test/golden/` (the same directory used when
255
255
  // that package runs adapter-tester directly), not a directory under
256
256
  // wherever this config file lives.
257
- goldenDir: a(p, "test", "golden"),
257
+ goldenDir: a(l, "test", "golden"),
258
258
  isSourceOfTruthAdapter: o,
259
259
  // Overwritten by the CLI from --update-golden/--approve-divergence.
260
260
  goldenMode: "check",
@@ -278,10 +278,10 @@ function Ee(e, t = {}) {
278
278
  throw new Error(
279
279
  `--source-of-truth-version has no effect with sourceOfTruth.type: "url" — that mode reads a sibling package's local checkout directly, not a published version.`
280
280
  );
281
- u = i.name ?? C, h = i.port ?? F;
281
+ u = i.name ?? C, h = i.port ?? R;
282
282
  const k = $(e, i.cwd ?? ".");
283
283
  v = {
284
- command: i.command ?? R,
284
+ command: i.command ?? F,
285
285
  port: h,
286
286
  cwd: k,
287
287
  reuseExistingServer: !process.env.CI,
@@ -292,7 +292,7 @@ function Ee(e, t = {}) {
292
292
  dir: a(k, "test", "golden")
293
293
  };
294
294
  } else {
295
- u = C, h = i.port ?? F;
295
+ u = C, h = i.port ?? R;
296
296
  const k = t.mantineAdapterVersion ?? i.mantineAdapterVersion, S = i.tokensSource ?? "target";
297
297
  v = z({
298
298
  dir: a(e, ".adapter-tester/mantine-harness"),
@@ -303,7 +303,7 @@ function Ee(e, t = {}) {
303
303
  // `ownCwd`, not `cwd` — the project actually being tested (same
304
304
  // reasoning `goldenDir` above uses), source of the 4 token files
305
305
  // copied into the harness when `tokensSource` is "target".
306
- targetDir: p
306
+ targetDir: l
307
307
  }), c = {
308
308
  type: "npm",
309
309
  packageName: we,
@@ -462,7 +462,7 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
462
462
  `
463
463
  );
464
464
  try {
465
- const l = W(
465
+ const p = W(
466
466
  "npx",
467
467
  [
468
468
  "playwright",
@@ -473,7 +473,7 @@ test.describe(\`\${ownTargetName} — \${suiteLabel}\`, () => {
473
473
  ],
474
474
  { stdio: "inherit", cwd: P, shell: process.platform === "win32" }
475
475
  );
476
- process.exitCode = l.status ?? 1;
476
+ process.exitCode = p.status ?? 1;
477
477
  } finally {
478
478
  n == null || n.kill("SIGTERM");
479
479
  }
package/dist/config.d.ts CHANGED
@@ -50,6 +50,13 @@ export interface StoryOverride {
50
50
  /** Skip this story entirely — no own-drift check, no divergence check, no
51
51
  * golden captured. For stories with no meaningful cross-adapter counterpart. */
52
52
  exclude?: boolean;
53
+ /** Browser viewport this story is captured at, in CSS pixels. Defaults to
54
+ * 800x600. For stories whose rendering depends on the page width itself
55
+ * (e.g. `@media` breakpoints), which a story can't change from inside. */
56
+ viewport?: {
57
+ width: number;
58
+ height: number;
59
+ };
53
60
  }
54
61
  export interface AdapterTesterConfig {
55
62
  targets: AdapterTarget[];
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;mEAEmE;AACnE,MAAM,MAAM,2BAA2B,GACnC;IACE;+EAC2E;IAC3E,IAAI,EAAE,OAAO,CAAC;IACd,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE;;gFAE4E;IAC5E,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B;kCAC8B;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;mBAGe;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;oFACgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB;;4BAEwB;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;;;;kDAK8C;IAC9C,4BAA4B,EAAE,MAAM,CAAC;IACrC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;uEACmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;2CACuC;IACvC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,2FAA2F;IAC3F,UAAU,EAAE,UAAU,CAAC;IACvB,oEAAoE;IACpE,SAAS,EAAE,SAAS,CAAC;IACrB;wEACoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAUrB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAM3E"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;mEAEmE;AACnE,MAAM,MAAM,2BAA2B,GACnC;IACE;+EAC2E;IAC3E,IAAI,EAAE,OAAO,CAAC;IACd,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE;;gFAE4E;IAC5E,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B;kCAC8B;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;mBAGe;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;oFACgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;8EAE0E;IAC1E,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB;;4BAEwB;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;;;;kDAK8C;IAC9C,4BAA4B,EAAE,MAAM,CAAC;IACrC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACxC;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC;uEACmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;2CACuC;IACvC,mBAAmB,CAAC,EAAE,2BAA2B,CAAC;IAClD,2FAA2F;IAC3F,UAAU,EAAE,UAAU,CAAC;IACvB,oEAAoE;IACpE,SAAS,EAAE,SAAS,CAAC;IACrB;wEACoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAUrB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAM3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check:\n * this project's own live render vs. the source-of-truth adapter's\n * published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's live render vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n /** Overrides the AI report header text (normally read from\n * `report-header.txt`) shown in Dev Mode's \"Full Report\" export. */\n reportHeader?: string;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":"uIA8GO,SAASA,EACdC,EACqB,CACrB,MAAMC,EAAqBD,EAAO,QAAQ,OACvCE,GAAWA,EAAO,aAAA,EACnB,OACF,GAAID,IAAuB,EACzB,MAAM,IAAI,MACR,8EAA8EA,CAAkB,GAAA,EAGpG,OAAOD,CACT,CAEO,SAASG,EAAiBH,EAA4C,CAC3E,MAAMI,EAAgBJ,EAAO,QAAQ,KAAME,GAAWA,EAAO,aAAa,EAC1E,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,0DAA0D,EAE5E,OAAOA,CACT"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check:\n * this project's own live render vs. the source-of-truth adapter's\n * published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n /** Browser viewport this story is captured at, in CSS pixels. Defaults to\n * 800x600. For stories whose rendering depends on the page width itself\n * (e.g. `@media` breakpoints), which a story can't change from inside. */\n viewport?: { width: number; height: number };\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's live render vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n /** Overrides the AI report header text (normally read from\n * `report-header.txt`) shown in Dev Mode's \"Full Report\" export. */\n reportHeader?: string;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":"uIAkHO,SAASA,EACdC,EACqB,CACrB,MAAMC,EAAqBD,EAAO,QAAQ,OACvCE,GAAWA,EAAO,aAAA,EACnB,OACF,GAAID,IAAuB,EACzB,MAAM,IAAI,MACR,8EAA8EA,CAAkB,GAAA,EAGpG,OAAOD,CACT,CAEO,SAASG,EAAiBH,EAA4C,CAC3E,MAAMI,EAAgBJ,EAAO,QAAQ,KAAME,GAAWA,EAAO,aAAa,EAC1E,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,0DAA0D,EAE5E,OAAOA,CACT"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check:\n * this project's own live render vs. the source-of-truth adapter's\n * published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's live render vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n /** Overrides the AI report header text (normally read from\n * `report-header.txt`) shown in Dev Mode's \"Full Report\" export. */\n reportHeader?: string;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":";AA8GO,SAASA,EACdC,GACqB;AACrB,QAAMC,IAAqBD,EAAO,QAAQ;AAAA,IACxC,CAACE,MAAWA,EAAO;AAAA,EAAA,EACnB;AACF,MAAID,MAAuB;AACzB,UAAM,IAAI;AAAA,MACR,8EAA8EA,CAAkB;AAAA,IAAA;AAGpG,SAAOD;AACT;AAEO,SAASG,EAAiBH,GAA4C;AAC3E,QAAMI,IAAgBJ,EAAO,QAAQ,KAAK,CAACE,MAAWA,EAAO,aAAa;AAC1E,MAAI,CAACE;AACH,UAAM,IAAI,MAAM,0DAA0D;AAE5E,SAAOA;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../src/config.ts"],"sourcesContent":["export interface AdapterTarget {\n /** Human-readable name used in test titles, report labels, and artifact filenames. */\n name: string;\n /** Base URL the target's Storybook instance is served from. */\n url: string;\n /**\n * Marks this target as the visual/token source of truth every other target\n * is compared against. Exactly one target in a config must set this true.\n */\n sourceOfTruth?: boolean;\n}\n\n/** How `resolveVisualRegressionPlan` reaches the source-of-truth adapter's (mantine)\n * own golden images, for the divergence check. Never involves booting a\n * Storybook — both `readImage` targets are plain files on disk. */\nexport type SourceOfTruthGoldenLocation =\n | {\n /** Sibling package already checked out locally (this monorepo's own\n * `sourceOfTruth.type: \"url\"` mode) — read its `test/golden/` directly. */\n type: \"local\";\n /** Absolute path to the source-of-truth adapter's `test/golden/` directory. */\n dir: string;\n }\n | {\n /** No local checkout (the default, standalone-repo mode) — resolve the\n * installed version against the npm registry, then fetch that git tag's\n * `test/golden/` from the public GitHub repo, caching what's downloaded. */\n type: \"npm\";\n packageName: string;\n /** npm version/dist-tag to resolve, e.g. \"latest\" or a pinned version. */\n versionSpec: string;\n /** Directory downloaded manifest/images are cached in between runs. */\n cacheDir: string;\n };\n\nexport type GoldenMode = \"check\" | \"update-golden\" | \"approve-divergence\";\n\n/**\n * Which check(s) a run performs. `\"own\"` (the default) is what a normal,\n * fast, no-network run does: this project's own live render vs. its own\n * committed golden images. `\"divergence\"` is the separate, opt-in check:\n * this project's own live render vs. the source-of-truth adapter's\n * published golden images.\n */\nexport type CheckMode = \"own\" | \"divergence\";\n\nexport interface StoryOverride {\n /** Diff threshold override for this story's own-drift check. Overrides\n * `goldenThresholdPixels`. */\n goldenThreshold?: number;\n /** Diff threshold override for this story's source-of-truth divergence\n * check. Overrides `sourceOfTruthThresholdPixels` for components with\n * acceptable cross-library structural variation (e.g. native control\n * widgets). */\n sourceOfTruthThreshold?: number;\n /** Skip this story entirely — no own-drift check, no divergence check, no\n * golden captured. For stories with no meaningful cross-adapter counterpart. */\n exclude?: boolean;\n /** Browser viewport this story is captured at, in CSS pixels. Defaults to\n * 800x600. For stories whose rendering depends on the page width itself\n * (e.g. `@media` breakpoints), which a story can't change from inside. */\n viewport?: { width: number; height: number };\n}\n\nexport interface AdapterTesterConfig {\n targets: AdapterTarget[];\n /** Global pixel-diff threshold for the own-drift check (this project's live\n * render vs. its own committed golden). Same library on both sides, so this\n * should stay tight. */\n goldenThresholdPixels: number;\n /** Global pixel-diff threshold for the source-of-truth divergence check\n * (this project's live render vs. the source-of-truth adapter's golden).\n * Comparing across two different component libraries has legitimate\n * structural variation, so this is expected to be much higher than\n * `goldenThresholdPixels`. Unused on the source-of-truth adapter's own\n * config (`isSourceOfTruthAdapter: true`). */\n sourceOfTruthThresholdPixels: number;\n /**\n * Per-story overrides, keyed by story id prefix (a story matches if its id\n * equals the key or starts with it). When more than one key matches, the\n * longest (most specific) key wins.\n */\n stories?: Record<string, StoryOverride>;\n /**\n * Storybook entry title categories excluded from the comparison — an\n * entry is excluded if its title equals one of these or starts with\n * `\"<value>/\"`. Defaults to [\"Theme\", \"Tokens\", \"Introduction\"]:\n * `@recursica/storybook-template`'s own default token/theme demo stories\n * (which every adapter's Storybook inherits automatically) plus each\n * adapter's own onboarding \"Introduction\" stories — neither has a\n * cross-adapter counterpart to diff against.\n */\n excludeTitlePrefixes?: string[];\n /** Absolute path to this project's own `test/golden/` directory — where\n * golden PNGs and `manifest.json` are stored, committed to git. */\n goldenDir: string;\n /**\n * True only for the source-of-truth adapter's own config (mantine). It has\n * nothing above it to diverge from, so the divergence check is skipped\n * entirely and `sourceOfTruthGolden` is ignored.\n */\n isSourceOfTruthAdapter: boolean;\n /** How to reach the source-of-truth's golden images. Required unless\n * `isSourceOfTruthAdapter` is true. */\n sourceOfTruthGolden?: SourceOfTruthGoldenLocation;\n /** Set by the CLI from `--update-golden`/`--approve-divergence`. Defaults to `\"check\"`. */\n goldenMode: GoldenMode;\n /** Set by the CLI from `--divergence-only`. Defaults to `\"own\"`. */\n checkMode: CheckMode;\n /** Overrides the AI report header text (normally read from\n * `report-header.txt`) shown in Dev Mode's \"Full Report\" export. */\n reportHeader?: string;\n}\n\nexport function defineAdapterTesterConfig(\n config: AdapterTesterConfig,\n): AdapterTesterConfig {\n const sourceOfTruthCount = config.targets.filter(\n (target) => target.sourceOfTruth,\n ).length;\n if (sourceOfTruthCount !== 1) {\n throw new Error(\n `adapter-tester config must mark exactly one target as sourceOfTruth (found ${sourceOfTruthCount})`,\n );\n }\n return config;\n}\n\nexport function getSourceOfTruth(config: AdapterTesterConfig): AdapterTarget {\n const sourceOfTruth = config.targets.find((target) => target.sourceOfTruth);\n if (!sourceOfTruth) {\n throw new Error(\"adapter-tester config has no target marked sourceOfTruth\");\n }\n return sourceOfTruth;\n}\n"],"names":["defineAdapterTesterConfig","config","sourceOfTruthCount","target","getSourceOfTruth","sourceOfTruth"],"mappings":";AAkHO,SAASA,EACdC,GACqB;AACrB,QAAMC,IAAqBD,EAAO,QAAQ;AAAA,IACxC,CAACE,MAAWA,EAAO;AAAA,EAAA,EACnB;AACF,MAAID,MAAuB;AACzB,UAAM,IAAI;AAAA,MACR,8EAA8EA,CAAkB;AAAA,IAAA;AAGpG,SAAOD;AACT;AAEO,SAASG,EAAiBH,GAA4C;AAC3E,QAAMI,IAAgBJ,EAAO,QAAQ,KAAK,CAACE,MAAWA,EAAO,aAAa;AAC1E,MAAI,CAACE;AACH,UAAM,IAAI,MAAM,0DAA0D;AAE5E,SAAOA;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"runVisualRegression.d.ts","sourceRoot":"","sources":["../../src/testing/runVisualRegression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAcxD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAmED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;+EAG2E;IAC3E,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA8R/B"}
1
+ {"version":3,"file":"runVisualRegression.d.ts","sourceRoot":"","sources":["../../src/testing/runVisualRegression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,cAAc,CAAC;AAcvE,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AA0FD;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;+EAG2E;IAC3E,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;wEAIwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B;;;;uDAImD;IACnD,UAAU,EAAE,CACV,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA8R/B"}
package/dist/testing.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@playwright/test"),i=require("node:fs"),z=require("pixelmatch"),P=require("pngjs"),E=require("node:path"),D=require("./index-C6uYPRmx.cjs");function B(e,t){const n=P.PNG.sync.read(e),r=P.PNG.sync.read(t);if(n.width!==r.width||n.height!==r.height)return{diffPixels:1/0,diffImage:null};const s=new P.PNG({width:n.width,height:n.height});return{diffPixels:z(n.data,r.data,s.data,n.width,n.height,{threshold:.1}),diffImage:P.PNG.sync.write(s)}}const H="http://json-schema.org/draft-07/schema#",Y="https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/golden/manifest.schema.json",Q="test/golden/manifest.json",Z="Tracks golden (baseline) image metadata for @recursica/adapter-tester's golden-image visual regression checks. One manifest lives alongside its adapter's test/golden/<story-id>.png files, keyed by story id.",ee="object",te={type:"object",additionalProperties:!1,required:["createdAt"],properties:{createdAt:{type:"string",format:"date-time",description:"When this story's own golden PNG was last captured, via --update-golden, --approve-divergence, or first-run auto-create."},sourceOfTruthCreatedAt:{type:"string",format:"date-time",description:"The source-of-truth adapter's (mantine) manifest `createdAt` for this story at the time this adapter's divergence from it was last reviewed via --approve-divergence. Omitted on the source-of-truth adapter's own manifest, and omitted here until the first approval. If mantine's current `createdAt` for this story is newer than this value, the divergence is flagged again for re-review."}}},re={$schema:H,$id:Y,title:Q,description:Z,type:ee,additionalProperties:te},ne=D.index,U=new D.ajvExports.Ajv({allErrors:!0,strict:!0});ne(U);const _=U.compile(re);function C(e,t){if(_(e))return;const n=(_.errors??[]).map(r=>{var c;const s=(c=r.params)!=null&&c.additionalProperty?` '${r.params.additionalProperty}'`:"";return` - ${r.instancePath||"root"} ${r.message}${s}`}).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@playwright/test"),i=require("node:fs"),z=require("pixelmatch"),P=require("pngjs"),A=require("node:path"),D=require("./index-C6uYPRmx.cjs");function _(e,t){const n=P.PNG.sync.read(e),r=P.PNG.sync.read(t);if(n.width!==r.width||n.height!==r.height)return{diffPixels:1/0,diffImage:null};const s=new P.PNG({width:n.width,height:n.height});return{diffPixels:z(n.data,r.data,s.data,n.width,n.height,{threshold:.1}),diffImage:P.PNG.sync.write(s)}}const H="http://json-schema.org/draft-07/schema#",Y="https://github.com/borderux/recursica/tree/main/packages/adapter-tester/src/golden/manifest.schema.json",Q="test/golden/manifest.json",Z="Tracks golden (baseline) image metadata for @recursica/adapter-tester's golden-image visual regression checks. One manifest lives alongside its adapter's test/golden/<story-id>.png files, keyed by story id.",ee="object",te={type:"object",additionalProperties:!1,required:["createdAt"],properties:{createdAt:{type:"string",format:"date-time",description:"When this story's own golden PNG was last captured, via --update-golden, --approve-divergence, or first-run auto-create."},sourceOfTruthCreatedAt:{type:"string",format:"date-time",description:"The source-of-truth adapter's (mantine) manifest `createdAt` for this story at the time this adapter's divergence from it was last reviewed via --approve-divergence. Omitted on the source-of-truth adapter's own manifest, and omitted here until the first approval. If mantine's current `createdAt` for this story is newer than this value, the divergence is flagged again for re-review."}}},re={$schema:H,$id:Y,title:Q,description:Z,type:ee,additionalProperties:te},ne=D.index,U=new D.ajvExports.Ajv({allErrors:!0,strict:!0});ne(U);const B=U.compile(re);function I(e,t){if(B(e))return;const n=(B.errors??[]).map(r=>{var c;const s=(c=r.params)!=null&&c.additionalProperty?` '${r.params.additionalProperty}'`:"";return` - ${r.instancePath||"root"} ${r.message}${s}`}).join(`
2
2
  `);throw new Error(`Invalid ${t}:
3
- ${n}`)}function j(e){return E.join(e,"manifest.json")}function J(e){return E.join(e,"manifest.json.lock")}function k(e,t){return E.join(e,`${t}.png`)}function b(e){const t=j(e);if(!i.existsSync(t))return{};const n=JSON.parse(i.readFileSync(t,"utf8"));return C(n,t),n}function oe(e,t){const n=j(e);C(t,n);const r={};for(const c of Object.keys(t).sort())r[c]=t[c];i.mkdirSync(e,{recursive:!0});const s=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;i.writeFileSync(s,JSON.stringify(r,null,2)+`
4
- `),i.renameSync(s,n)}const se=25,ie=15e3;function ae(e){return new Promise(t=>setTimeout(t,e))}async function ce(e){i.mkdirSync(e,{recursive:!0});const t=J(e),n=Date.now()+ie;for(;;)try{i.closeSync(i.openSync(t,"wx"));return}catch(r){if(r.code!=="EEXIST")throw r;if(Date.now()>=n)throw new Error(`Timed out waiting for the manifest lock at "${t}" — delete it if a previous run crashed while holding it.`);await ae(se)}}function de(e){i.rmSync(J(e),{force:!0})}async function K(e,t,n){await ce(e);try{const r=b(e),s=n(r[t]);return s===void 0?delete r[t]:r[t]=s,oe(e,r),s}finally{de(e)}}function he(e,t,n){i.mkdirSync(e,{recursive:!0}),i.writeFileSync(k(e,t),n)}async function ue(e,t){const n=b(e),r=Object.keys(n).filter(s=>!t.has(s));for(const s of r){const c=k(e,s);i.existsSync(c)&&i.unlinkSync(c),await K(e,s,()=>{})}return r}const q="borderux/recursica-adapter-mantine-v8";async function le(e,t){var c,h;const n=await fetch(`https://registry.npmjs.org/${e}`);if(!n.ok)throw new Error(`Could not reach npm registry for ${e}: ${n.statusText}`);const r=await n.json(),s=((c=r["dist-tags"])==null?void 0:c[t])??((h=r.versions)!=null&&h[t]?t:void 0);if(!s)throw new Error(`${e} has no version or dist-tag "${t}" on the npm registry.`);return s}async function fe(e){if(e.type==="local"){if(!i.existsSync(j(e.dir)))throw new Error(`No golden baseline found at ${e.dir} — the source-of-truth divergence check has nothing to compare against. Capture one there first (--update-golden), or fix sourceOfTruth.dir if it's pointing at the wrong checkout.`);return{manifest:b(e.dir),async readImage(u){const d=k(e.dir,u);return i.existsSync(d)?i.readFileSync(d):null}}}let t;try{t=await le(e.packageName,e.versionSpec)}catch(a){throw new Error(`Could not resolve ${e.packageName}@${e.versionSpec} on the npm registry — the source-of-truth divergence check has nothing to compare against.`,{cause:a})}const n=E.join(e.cacheDir,t),r=`v${t}`,s=`https://raw.githubusercontent.com/${q}/${r}/test/golden`;let c;const h=j(n);if(i.existsSync(h))c=b(n);else{let a;try{a=await fetch(`${s}/manifest.json`)}catch(m){throw new Error(`Could not reach GitHub to fetch ${r}'s golden baseline (${s}/manifest.json) — the source-of-truth divergence check has nothing to compare against.`,{cause:m})}if(!a.ok)throw new Error(`No golden baseline published for tag "${r}" in ${q} (${s}/manifest.json returned ${a.status}) — the source-of-truth divergence check has nothing to compare against. Confirm that tag exists and its release actually published test/golden/.`);const u=await a.text(),d=JSON.parse(u);C(d,`${s}/manifest.json`),i.mkdirSync(n,{recursive:!0}),i.writeFileSync(h,u),c=d}return{manifest:c,async readImage(a){const u=k(n,a);if(i.existsSync(u))return i.readFileSync(u);const d=await fetch(`${s}/${a}.png`);if(!d.ok)return null;const m=Buffer.from(await d.arrayBuffer());return i.mkdirSync(n,{recursive:!0}),i.writeFileSync(u,m),m}}}const pe=["Theme","Tokens","Introduction"];function M(e,t){return e===t||e.startsWith(t)}async function ge(e,t){let n;try{const r=await fetch(`${e.url}/index.json`);if(!r.ok)throw new Error(`Failed to fetch Storybook index: ${r.statusText}`);const c=(await r.json()).entries||{};n=Object.values(c).filter(h=>h.type==="story"&&!t.some(a=>h.title===a||h.title.startsWith(`${a}/`))),n.sort((h,a)=>h.id.localeCompare(a.id))}catch(r){throw console.error("Failed to load Storybook index from",`${e.url}/index.json`,r),new Error(`Storybook target "${e.name}" is not responsive or index.json is missing. Please ensure its Storybook is running.`)}return n}function R(e,t,n){let r;for(const s of Object.keys(t))M(e,s)&&(!r||s.length>r.length)&&(r=s);return r!==void 0?t[r]:n}async function me(e){const t=e.isSourceOfTruthAdapter?e.targets[0]:e.targets.find(o=>!o.sourceOfTruth);if(!t)throw new Error("adapter-tester config has no non-sourceOfTruth target to run the golden check against.");const n=e.excludeTitlePrefixes??pe,r=e.stories??{},s=Object.keys(r).filter(o=>r[o].exclude),c=Object.fromEntries(Object.entries(r).filter(([,o])=>o.goldenThreshold!==void 0).map(([o,l])=>[o,l.goldenThreshold])),h=Object.fromEntries(Object.entries(r).filter(([,o])=>o.sourceOfTruthThreshold!==void 0).map(([o,l])=>[o,l.sourceOfTruthThreshold])),a=e.goldenDir,u=e.goldenMode,d=e.checkMode,m=await ge(t,n),A=m.filter(o=>!s.some(l=>M(o.id,l)));if(u==="update-golden"){const o=await ue(a,new Set(A.map(l=>l.id)));o.length>0&&console.warn(`Pruned ${o.length} orphaned golden(s) no longer in Storybook: ${o.join(", ")}`)}const v=d!=="divergence"||e.isSourceOfTruthAdapter||!e.sourceOfTruthGolden?null:await fe(e.sourceOfTruthGolden),V=new Set(m.map(o=>o.id)),T=v?Object.keys(v.manifest).filter(o=>!V.has(o)&&!s.some(l=>M(o,l))).sort():[];T.length>0&&console.error(`[adapter-tester] ${T.length} stor(y/ies) exist in the source of truth but are missing here: ${T.join(", ")}. Add the missing story, or mark it \`exclude: true\` under \`stories\` in adapter-tester.config.json if intentional.`),console.log([`[adapter-tester] target: "${t.name}" (${t.url})`,`[adapter-tester] checkMode: "${d}" (${d==="divergence"?"live render vs source-of-truth's golden":"live render vs this project's own golden"})`,`[adapter-tester] goldenMode: "${u}"`,`[adapter-tester] goldenThresholdPixels: ${e.goldenThresholdPixels}`,`[adapter-tester] sourceOfTruthThresholdPixels: ${e.sourceOfTruthThresholdPixels}`,d==="divergence"?e.isSourceOfTruthAdapter?"[adapter-tester] sourceOfTruthGolden: skipped — this is the source-of-truth adapter, nothing to diverge from":e.sourceOfTruthGolden?`[adapter-tester] sourceOfTruthGolden: resolved, ${Object.keys(v.manifest).length} golden(s) available (config: ${JSON.stringify(e.sourceOfTruthGolden)})`:"[adapter-tester] sourceOfTruthGolden: skipped — no sourceOfTruthGolden configured":'[adapter-tester] sourceOfTruthGolden: not used in "own" checkMode',`[adapter-tester] stories: ${A.length} to check (excluded: ${s.length}, title prefixes excluded: ${n.join(", ")||"none"})`,`[adapter-tester] story parity with source of truth: ${T.length===0?"OK":`${T.length} missing (see error above)`}`].join(`
5
- `));const W=d==="divergence"?"Source-of-Truth Divergence Check":"Own-Drift Golden Image Check";return{ownTargetName:t.name,suiteLabel:W,stories:A,missingFromSourceOfTruth:T,checkStory:async(o,l,g)=>{const w=await l.newPage();await w.setViewportSize({width:800,height:600}),await w.goto(`${t.url}/iframe.html?id=${o.id}&viewMode=story`,{waitUntil:"networkidle"}),await w.waitForSelector("#storybook-root"),await w.addStyleTag({content:"* { -webkit-font-smoothing: antialiased !important; -moz-osx-font-smoothing: grayscale !important; }"}),await w.evaluate(()=>Promise.all(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).map(f=>f.sheet?Promise.resolve():new Promise(p=>{f.addEventListener("load",()=>p(),{once:!0}),f.addEventListener("error",()=>p(),{once:!0})}))).then(()=>document.fonts.ready)),await w.waitForTimeout(300);const O=await w.screenshot(),I=k(a,o.id),y=b(a)[o.id],X=u!=="check"||!y||!i.existsSync(I);let $;if(X)he(a,o.id,O),$=y!=null&&y.sourceOfTruthCreatedAt?{createdAt:new Date().toISOString(),sourceOfTruthCreatedAt:y.sourceOfTruthCreatedAt}:{createdAt:new Date().toISOString()},y||g.annotations.push({type:"golden-created",description:`No golden existed yet for "${o.id}" — captured one from this run.`});else if($=y,d==="own"){const f=i.readFileSync(I),{diffPixels:p,diffImage:S}=B(O,f),x=R(o.id,c,e.goldenThresholdPixels);p>=x&&(await g.attach("expected",{body:f,contentType:"image/png"}),await g.attach("actual",{body:O,contentType:"image/png"}),S&&await g.attach("diff",{body:S,contentType:"image/png"})),L.expect.soft(p,`"${o.id}" has drifted from its own golden image (${p} mismatched pixels, threshold ${x})`).toBeLessThan(x)}if(v){const f=v.manifest[o.id],p=f?await v.readImage(o.id):null;if(f&&p)if(u==="approve-divergence")$={...$,sourceOfTruthCreatedAt:f.createdAt};else{const{diffPixels:S,diffImage:x}=B(O,p),G=R(o.id,h,e.sourceOfTruthThresholdPixels),F=$.sourceOfTruthCreatedAt,N=S<G||F!==void 0&&F>=f.createdAt;N||(await g.attach("expected",{body:p,contentType:"image/png"}),await g.attach("actual",{body:O,contentType:"image/png"}),x&&await g.attach("diff",{body:x,contentType:"image/png"}),g.annotations.push({type:"source-of-truth-divergence",description:`"${o.id}" differs from the source of truth's golden by ${S} mismatched pixels (threshold ${G}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`})),L.expect.soft(N,`"${o.id}" differs from the source of truth's golden by ${S} mismatched pixels (threshold ${G}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`).toBe(!0)}}await K(a,o.id,()=>$)}}}exports.resolveVisualRegressionPlan=me;
3
+ ${n}`)}function j(e){return A.join(e,"manifest.json")}function V(e){return A.join(e,"manifest.json.lock")}function k(e,t){return A.join(e,`${t}.png`)}function b(e){const t=j(e);if(!i.existsSync(t))return{};const n=JSON.parse(i.readFileSync(t,"utf8"));return I(n,t),n}function oe(e,t){const n=j(e);I(t,n);const r={};for(const c of Object.keys(t).sort())r[c]=t[c];i.mkdirSync(e,{recursive:!0});const s=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;i.writeFileSync(s,JSON.stringify(r,null,2)+`
4
+ `),i.renameSync(s,n)}const se=25,ie=15e3;function ae(e){return new Promise(t=>setTimeout(t,e))}async function ce(e){i.mkdirSync(e,{recursive:!0});const t=V(e),n=Date.now()+ie;for(;;)try{i.closeSync(i.openSync(t,"wx"));return}catch(r){if(r.code!=="EEXIST")throw r;if(Date.now()>=n)throw new Error(`Timed out waiting for the manifest lock at "${t}" — delete it if a previous run crashed while holding it.`);await ae(se)}}function de(e){i.rmSync(V(e),{force:!0})}async function J(e,t,n){await ce(e);try{const r=b(e),s=n(r[t]);return s===void 0?delete r[t]:r[t]=s,oe(e,r),s}finally{de(e)}}function he(e,t,n){i.mkdirSync(e,{recursive:!0}),i.writeFileSync(k(e,t),n)}async function ue(e,t){const n=b(e),r=Object.keys(n).filter(s=>!t.has(s));for(const s of r){const c=k(e,s);i.existsSync(c)&&i.unlinkSync(c),await J(e,s,()=>{})}return r}const q="borderux/recursica-adapter-mantine-v8";async function le(e,t){var c,h;const n=await fetch(`https://registry.npmjs.org/${e}`);if(!n.ok)throw new Error(`Could not reach npm registry for ${e}: ${n.statusText}`);const r=await n.json(),s=((c=r["dist-tags"])==null?void 0:c[t])??((h=r.versions)!=null&&h[t]?t:void 0);if(!s)throw new Error(`${e} has no version or dist-tag "${t}" on the npm registry.`);return s}async function fe(e){if(e.type==="local"){if(!i.existsSync(j(e.dir)))throw new Error(`No golden baseline found at ${e.dir} — the source-of-truth divergence check has nothing to compare against. Capture one there first (--update-golden), or fix sourceOfTruth.dir if it's pointing at the wrong checkout.`);return{manifest:b(e.dir),async readImage(u){const d=k(e.dir,u);return i.existsSync(d)?i.readFileSync(d):null}}}let t;try{t=await le(e.packageName,e.versionSpec)}catch(a){throw new Error(`Could not resolve ${e.packageName}@${e.versionSpec} on the npm registry — the source-of-truth divergence check has nothing to compare against.`,{cause:a})}const n=A.join(e.cacheDir,t),r=`v${t}`,s=`https://raw.githubusercontent.com/${q}/${r}/test/golden`;let c;const h=j(n);if(i.existsSync(h))c=b(n);else{let a;try{a=await fetch(`${s}/manifest.json`)}catch(m){throw new Error(`Could not reach GitHub to fetch ${r}'s golden baseline (${s}/manifest.json) — the source-of-truth divergence check has nothing to compare against.`,{cause:m})}if(!a.ok)throw new Error(`No golden baseline published for tag "${r}" in ${q} (${s}/manifest.json returned ${a.status}) — the source-of-truth divergence check has nothing to compare against. Confirm that tag exists and its release actually published test/golden/.`);const u=await a.text(),d=JSON.parse(u);I(d,`${s}/manifest.json`),i.mkdirSync(n,{recursive:!0}),i.writeFileSync(h,u),c=d}return{manifest:c,async readImage(a){const u=k(n,a);if(i.existsSync(u))return i.readFileSync(u);const d=await fetch(`${s}/${a}.png`);if(!d.ok)return null;const m=Buffer.from(await d.arrayBuffer());return i.mkdirSync(n,{recursive:!0}),i.writeFileSync(u,m),m}}}const pe=["Theme","Tokens","Introduction"];function E(e,t){return e===t||e.startsWith(t)}async function ge(e,t){let n;try{const r=await fetch(`${e.url}/index.json`);if(!r.ok)throw new Error(`Failed to fetch Storybook index: ${r.statusText}`);const c=(await r.json()).entries||{};n=Object.values(c).filter(h=>h.type==="story"&&!t.some(a=>h.title===a||h.title.startsWith(`${a}/`))),n.sort((h,a)=>h.id.localeCompare(a.id))}catch(r){throw console.error("Failed to load Storybook index from",`${e.url}/index.json`,r),new Error(`Storybook target "${e.name}" is not responsive or index.json is missing. Please ensure its Storybook is running.`)}return n}const me={width:800,height:600};function we(e,t){let n;for(const r of Object.keys(t))t[r].viewport&&E(e,r)&&(!n||r.length>n.length)&&(n=r);return n!==void 0?t[n].viewport:me}function R(e,t,n){let r;for(const s of Object.keys(t))E(e,s)&&(!r||s.length>r.length)&&(r=s);return r!==void 0?t[r]:n}async function ye(e){const t=e.isSourceOfTruthAdapter?e.targets[0]:e.targets.find(o=>!o.sourceOfTruth);if(!t)throw new Error("adapter-tester config has no non-sourceOfTruth target to run the golden check against.");const n=e.excludeTitlePrefixes??pe,r=e.stories??{},s=Object.keys(r).filter(o=>r[o].exclude),c=Object.fromEntries(Object.entries(r).filter(([,o])=>o.goldenThreshold!==void 0).map(([o,l])=>[o,l.goldenThreshold])),h=Object.fromEntries(Object.entries(r).filter(([,o])=>o.sourceOfTruthThreshold!==void 0).map(([o,l])=>[o,l.sourceOfTruthThreshold])),a=e.goldenDir,u=e.goldenMode,d=e.checkMode,m=await ge(t,n),G=m.filter(o=>!s.some(l=>E(o.id,l)));if(u==="update-golden"){const o=await ue(a,new Set(G.map(l=>l.id)));o.length>0&&console.warn(`Pruned ${o.length} orphaned golden(s) no longer in Storybook: ${o.join(", ")}`)}const v=d!=="divergence"||e.isSourceOfTruthAdapter||!e.sourceOfTruthGolden?null:await fe(e.sourceOfTruthGolden),K=new Set(m.map(o=>o.id)),T=v?Object.keys(v.manifest).filter(o=>!K.has(o)&&!s.some(l=>E(o,l))).sort():[];T.length>0&&console.error(`[adapter-tester] ${T.length} stor(y/ies) exist in the source of truth but are missing here: ${T.join(", ")}. Add the missing story, or mark it \`exclude: true\` under \`stories\` in adapter-tester.config.json if intentional.`),console.log([`[adapter-tester] target: "${t.name}" (${t.url})`,`[adapter-tester] checkMode: "${d}" (${d==="divergence"?"live render vs source-of-truth's golden":"live render vs this project's own golden"})`,`[adapter-tester] goldenMode: "${u}"`,`[adapter-tester] goldenThresholdPixels: ${e.goldenThresholdPixels}`,`[adapter-tester] sourceOfTruthThresholdPixels: ${e.sourceOfTruthThresholdPixels}`,d==="divergence"?e.isSourceOfTruthAdapter?"[adapter-tester] sourceOfTruthGolden: skipped — this is the source-of-truth adapter, nothing to diverge from":e.sourceOfTruthGolden?`[adapter-tester] sourceOfTruthGolden: resolved, ${Object.keys(v.manifest).length} golden(s) available (config: ${JSON.stringify(e.sourceOfTruthGolden)})`:"[adapter-tester] sourceOfTruthGolden: skipped — no sourceOfTruthGolden configured":'[adapter-tester] sourceOfTruthGolden: not used in "own" checkMode',`[adapter-tester] stories: ${G.length} to check (excluded: ${s.length}, title prefixes excluded: ${n.join(", ")||"none"})`,`[adapter-tester] story parity with source of truth: ${T.length===0?"OK":`${T.length} missing (see error above)`}`].join(`
5
+ `));const W=d==="divergence"?"Source-of-Truth Divergence Check":"Own-Drift Golden Image Check";return{ownTargetName:t.name,suiteLabel:W,stories:G,missingFromSourceOfTruth:T,checkStory:async(o,l,g)=>{const w=await l.newPage();await w.setViewportSize(we(o.id,r)),await w.goto(`${t.url}/iframe.html?id=${o.id}&viewMode=story`,{waitUntil:"networkidle"}),await w.waitForSelector("#storybook-root"),await w.addStyleTag({content:"* { -webkit-font-smoothing: antialiased !important; -moz-osx-font-smoothing: grayscale !important; }"}),await w.evaluate(()=>Promise.all(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).map(f=>f.sheet?Promise.resolve():new Promise(p=>{f.addEventListener("load",()=>p(),{once:!0}),f.addEventListener("error",()=>p(),{once:!0})}))).then(()=>document.fonts.ready)),await w.waitForTimeout(300);const O=await w.screenshot(),C=k(a,o.id),y=b(a)[o.id],X=u!=="check"||!y||!i.existsSync(C);let $;if(X)he(a,o.id,O),$=y!=null&&y.sourceOfTruthCreatedAt?{createdAt:new Date().toISOString(),sourceOfTruthCreatedAt:y.sourceOfTruthCreatedAt}:{createdAt:new Date().toISOString()},y||g.annotations.push({type:"golden-created",description:`No golden existed yet for "${o.id}" — captured one from this run.`});else if($=y,d==="own"){const f=i.readFileSync(C),{diffPixels:p,diffImage:S}=_(O,f),x=R(o.id,c,e.goldenThresholdPixels);p>=x&&(await g.attach("expected",{body:f,contentType:"image/png"}),await g.attach("actual",{body:O,contentType:"image/png"}),S&&await g.attach("diff",{body:S,contentType:"image/png"})),L.expect.soft(p,`"${o.id}" has drifted from its own golden image (${p} mismatched pixels, threshold ${x})`).toBeLessThan(x)}if(v){const f=v.manifest[o.id],p=f?await v.readImage(o.id):null;if(f&&p)if(u==="approve-divergence")$={...$,sourceOfTruthCreatedAt:f.createdAt};else{const{diffPixels:S,diffImage:x}=_(O,p),M=R(o.id,h,e.sourceOfTruthThresholdPixels),F=$.sourceOfTruthCreatedAt,N=S<M||F!==void 0&&F>=f.createdAt;N||(await g.attach("expected",{body:p,contentType:"image/png"}),await g.attach("actual",{body:O,contentType:"image/png"}),x&&await g.attach("diff",{body:x,contentType:"image/png"}),g.annotations.push({type:"source-of-truth-divergence",description:`"${o.id}" differs from the source of truth's golden by ${S} mismatched pixels (threshold ${M}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`})),L.expect.soft(N,`"${o.id}" differs from the source of truth's golden by ${S} mismatched pixels (threshold ${M}) and hasn't been reviewed — run with --approve-divergence if this is intentional, or fix the adapter styling.`).toBe(!0)}}await J(a,o.id,()=>$)}}}exports.resolveVisualRegressionPlan=ye;
6
6
  //# sourceMappingURL=testing.cjs.map