@recursica/adapter-tester 5.2.1 → 5.3.1

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/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sources":["../src/portDiscovery.ts","../src/devServer.ts","../src/validateFileConfig.ts","../src/fileConfig.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport net from \"node:net\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Boots a target's Storybook and discovers the real port it ends up on,\n * instead of pinning one via `-p`/`--port`. Storybook silently falls back to\n * an OS-assigned port whenever its default/configured one is taken (this is\n * what caused the flaky `webServer` timeouts noted in @recursica/adapter-mui-v7), so the\n * only reliable source of truth is the URL it prints in its own startup\n * banner. Used by both the automated/headless run (cli.ts) and Dev Mode\n * (devServer.ts) — neither pins a port anymore.\n */\n\nexport interface LaunchTarget {\n /** Human-readable name used in log lines. */\n name: string;\n command: string;\n cwd: string;\n /** Reuse an already-running instance (detected via the last-known-port\n * cache) instead of spawning a new one. Mirrors the old `reuseExistingServer`\n * behavior, which used to just probe the one fixed configured port. */\n reuseExistingServer: boolean;\n /** File the discovered port is cached in between runs, so a later\n * `reuseExistingServer` run knows where to look. One per target. */\n cacheFile: string;\n timeoutMs?: number;\n}\n\nexport interface DiscoveredServer {\n url: string;\n port: number;\n /** The process we spawned, or `null` if an already-running instance was\n * reused — callers should only kill what they started. */\n process: ChildProcess | null;\n}\n\n// Storybook prints its bound address in its startup banner wrapped in ANSI\n// color codes and box-drawing chars, e.g.:\n// │ │ - Local: http://localhost:57496/ │ │\n// Strip ANSI first, then match the URL itself.\nconst ANSI_PATTERN = /\\x1b\\[[0-9;]*m/g;\nconst LOCAL_URL_PATTERN = /Local:\\s*(https?:\\/\\/localhost:\\d+)/;\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nfunction readCachedPort(cacheFile: string): number | undefined {\n try {\n const port = JSON.parse(readFileSync(cacheFile, \"utf8\")).port;\n return typeof port === \"number\" ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeCachedPort(cacheFile: string, port: number): void {\n mkdirSync(dirname(cacheFile), { recursive: true });\n writeFileSync(cacheFile, JSON.stringify({ port }));\n}\n\n/** Spawns `target.command`, streaming its output to the console like before,\n * and resolves once it reports the URL it actually bound to. */\nfunction spawnAndDetect(\n target: LaunchTarget,\n timeoutMs: number,\n): Promise<DiscoveredServer> {\n return new Promise((resolve, reject) => {\n const child = spawn(target.command, {\n cwd: target.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n child.kill();\n reject(\n new Error(\n `Timed out after ${timeoutMs}ms waiting for ${target.name}'s Storybook to report its URL (no \"Local: http://localhost:<port>\" line seen in its output).`,\n ),\n );\n }, timeoutMs);\n\n const handleOutput = (data: Buffer, isError: boolean) => {\n const text = data.toString();\n for (const line of text.split(\"\\n\")) {\n if (line.trim()) {\n const label = isError\n ? `${target.name} SB ERROR`\n : `${target.name} SB`;\n (isError ? console.error : console.log)(`[${label}] ${line.trim()}`);\n }\n }\n if (settled) return;\n const match = text.replace(ANSI_PATTERN, \"\").match(LOCAL_URL_PATTERN);\n if (match) {\n settled = true;\n clearTimeout(timer);\n // Non-null: LOCAL_URL_PATTERN has exactly one capture group, and a\n // match only happens when it participated.\n const url = match[1]!;\n const port = Number(new URL(url).port);\n writeCachedPort(target.cacheFile, port);\n resolve({ url, port, process: child });\n }\n };\n child.stdout?.on(\"data\", (data: Buffer) => handleOutput(data, false));\n child.stderr?.on(\"data\", (data: Buffer) => handleOutput(data, true));\n child.on(\"error\", (err) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(err);\n });\n child.on(\"exit\", (code) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new Error(\n `${target.name}'s Storybook exited (code ${code}) before reporting its URL.`,\n ),\n );\n });\n });\n}\n\n/** Adapts a resolved `HarnessWebServerConfig` into a `LaunchTarget`. */\nexport function toLaunchTarget(\n name: string,\n server: HarnessWebServerConfig,\n): LaunchTarget {\n return {\n name,\n command: server.command,\n cwd: server.cwd,\n reuseExistingServer: server.reuseExistingServer,\n cacheFile: server.cacheFile,\n timeoutMs: server.timeout,\n };\n}\n\n/** Reuses an already-running Storybook if `reuseExistingServer` is set and\n * the last-known-port cache points at something still listening; otherwise\n * spawns `target.command` fresh and detects the real port from its output. */\nexport async function launchAndDetectStorybook(\n target: LaunchTarget,\n): Promise<DiscoveredServer> {\n if (target.reuseExistingServer) {\n const cachedPort = readCachedPort(target.cacheFile);\n if (cachedPort !== undefined && (await isPortActive(cachedPort))) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${cachedPort} (reused).`,\n );\n return {\n url: `http://localhost:${cachedPort}`,\n port: cachedPort,\n process: null,\n };\n }\n }\n console.log(`[Dev Launcher] Launching Storybook for ${target.name}...`);\n return spawnAndDetect(target, target.timeoutMs ?? 120 * 1000);\n}\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport async function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): Promise<void> {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n\n // Neither Storybook is pinned to a specific port — each one silently\n // falls back to an OS-assigned port whenever its default/configured one is\n // taken, so the real port is only known once it reports it (see\n // portDiscovery.ts). Booted concurrently since neither depends on the other.\n console.log(\n `[Dev Launcher] Resolving ${sourceOfTruth.name} and ${target.name} Storybooks...`,\n );\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n launchAndDetectStorybook(\n toLaunchTarget(sourceOfTruth.name, sourceOfTruthServer),\n ),\n launchAndDetectStorybook(toLaunchTarget(target.name, targetServer)),\n ]);\n console.log(`[Dev Launcher] Both Storybooks are active and responsive!`);\n\n const spawned = [sourceOfTruthRunning.process, targetRunning.process].filter(\n (child): child is ChildProcess => child !== null,\n );\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort: sourceOfTruthRunning.port,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n // `reportHeader` in adapter-tester.config.json overrides the file entirely.\n app.get(\"/report-header.txt\", (req, res) => {\n if (engineConfig.reportHeader !== undefined) {\n res.type(\"text/plain\").send(engineConfig.reportHeader);\n return;\n }\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: targetRunning.url,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type {\n HarnessWebServerConfig,\n MantineSourceOfTruthTokensSource,\n} from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/adapter-mantine-v8\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_GOLDEN_THRESHOLD_PIXELS = 10;\nconst DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** First-guess port only, not authoritative — the real port is\n * auto-detected from this Storybook's own startup output, since Storybook\n * silently falls back to an OS-assigned port whenever this one is taken.\n * Auto-detected from this project's own `scripts.storybook` (a `-p\n * <port>`/`--port <port>` flag) when omitted, falling back to 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/adapter-mantine-v8` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`. */\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n /** See `MantineSourceOfTruthTokensSource`. Defaults to `\"target\"` — the\n * harness renders Mantine's components with *this* project's own\n * committed Recursica tokens, not Mantine's own bundled snapshot or (the\n * one thing neither ever means) the deprecated `@recursica/official-release`\n * package. Set to `\"mantine-package\"` to test against\n * `@recursica/adapter-mantine-v8`'s own bundled tokens instead. */\n tokensSource?: MantineSourceOfTruthTokensSource;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`.\n * Defaults to 6011. */\n port?: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/adapter-mui-v7\" -> \"adapter-mui-v7\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n goldenThresholdPixels?: number;\n sourceOfTruthThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /** Overrides the AI report header text shown in Dev Mode's \"Full Report\"\n * export. Defaults to the contents of `report-header.txt`. */\n reportHeader?: string;\n /**\n * True only for the source-of-truth adapter's own config (@recursica/adapter-mantine-v8).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-own.json\"),\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n goldenThresholdPixels:\n file.goldenThresholdPixels ?? DEFAULT_GOLDEN_THRESHOLD_PIXELS,\n sourceOfTruthThresholdPixels:\n file.sourceOfTruthThresholdPixels ??\n DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n reportHeader: file.reportHeader,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruthPort,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-source-of-truth.json\"),\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n const tokensSource: MantineSourceOfTruthTokensSource =\n sourceOfTruth.tokensSource ?? \"target\";\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n tokensSource,\n // `ownCwd`, not `cwd` — the project actually being tested (same\n // reasoning `goldenDir` above uses), source of the 4 token files\n // copied into the harness when `tokensSource` is \"target\".\n targetDir: ownCwd,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\n// `--story <story-id>` scopes a run to exactly one story — pulled out the\n// same way, ahead of the passthrough logic, since it's consumed here (to\n// filter the generated spec) rather than forwarded to Playwright. Equivalent\n// to `--grep \"<story-id>\"`, but exact-match and easier to reach for when\n// iterating on a single component.\nlet storyId: string | undefined;\nconst storyFlagIndex = args.indexOf(\"--story\");\nif (storyFlagIndex !== -1) {\n const value = args[storyFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--story requires a story id, e.g. --story ui-kit-button--loading\",\n );\n }\n storyId = value;\n args.splice(storyFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\n// The bundled build target doesn't support top-level await, so the async\n// work (launching Storybook and detecting its real port) lives in main().\nmain().catch((err) => {\n console.error(err);\n process.exitCode = 1;\n});\n\nasync function main(): Promise<void> {\n if (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n await startDevServer(engineConfig, webServers);\n } else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n const ownWebServer = webServers.at(-1);\n if (!ownWebServer) {\n throw new Error(\"resolveConfig() returned no webServers to boot.\");\n }\n await runAutomated(ownWebServer, engineConfig);\n }\n}\n\n/**\n * Boots this project's own Storybook (auto-detecting the port it actually\n * lands on — see portDiscovery.ts), generates a throwaway Playwright config\n * + spec under `.adapter-tester/run/`, and runs the automated pixel-diff\n * suite against it. Used by the `adapter-tester:automated` npm script.\n *\n * Playwright's own `webServer` option can't be used here — it only knows how\n * to poll a port/URL decided *before* the command it spawns runs, but\n * Storybook silently falls back to a different, OS-assigned port whenever\n * its configured one is taken. So this boots and waits for Storybook itself,\n * then points the generated config straight at whatever URL it actually\n * reports.\n */\nasync function runAutomated(\n server: HarnessWebServerConfig,\n config: AdapterTesterConfig,\n): Promise<void> {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n const ownTarget = config.targets.at(-1);\n if (!ownTarget) {\n throw new Error(\"resolveConfig() returned no targets to check.\");\n }\n const { url, process: spawned } = await launchAndDetectStorybook(\n toLaunchTarget(ownTarget.name, server),\n );\n ownTarget.url = url;\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Each golden check only reads/writes its own story's manifest.json entry,\n // under a lock, so concurrent workers never race each other (see\n // \\`updateManifestEntry\\`). Defaults to 1 worker (1 Chromium instance) to\n // avoid exhausting memory running the full suite; override with\n // \\`--workers <n>\\` (forwarded straight through to Playwright) to parallelize.\n workers: 1,\n fullyParallel: true,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n // No webServer entry — this project's own Storybook is already running by\n // the time this config is used (see runAutomated() in cli.ts).\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test, expect } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\n// Set from \\`--story <story-id>\\` — scopes this run to exactly one story and\n// skips the (suite-wide) parity check, which has nothing to do with it.\nconst storyId = ${JSON.stringify(storyId ?? null)};\nconst scopedStories = storyId\n ? stories.filter((story) => story.id === storyId)\n : stories;\nif (storyId && scopedStories.length === 0) {\n throw new Error(\\`--story \"\\${storyId}\" matched no story in this Storybook.\\`);\n}\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (!storyId && missingFromSourceOfTruth.length > 0) {\n test(\"story parity with source of truth\", () => {\n expect(\n missingFromSourceOfTruth,\n \\`\\${missingFromSourceOfTruth.length} stor(y/ies) exist in the source of truth but are missing here. Add the missing story, or mark it \\\\\\`exclude: true\\\\\\` under \\\\\\`stories\\\\\\` in adapter-tester.config.json if intentional.\\`,\n ).toEqual([]);\n });\n }\n for (const story of scopedStories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n try {\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n process.exitCode = result.status ?? 1;\n } finally {\n // Only tear down the Storybook we spawned — an instance we reused via\n // the last-known-port cache was already running before we got here, and\n // should stay running after.\n spawned?.kill(\"SIGTERM\");\n }\n}\n"],"names":["ANSI_PATTERN","LOCAL_URL_PATTERN","isPortActive","port","resolve","socket","net","readCachedPort","cacheFile","readFileSync","writeCachedPort","mkdirSync","dirname","writeFileSync","spawnAndDetect","target","timeoutMs","reject","child","spawn","settled","timer","handleOutput","data","isError","text","line","label","match","url","_a","_b","err","code","toLaunchTarget","name","server","launchAndDetectStorybook","cachedPort","distDir","fileURLToPath","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","sourceOfTruthServer","targetServer","devPort","sourceOfTruthRunning","targetRunning","spawned","app","express","publicDir","join","headerPath","req","res","next","html","createProxyMiddleware","cleaningUp","cleanup","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_GOLDEN_THRESHOLD_PIXELS","DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthPort","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","tokensSource","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","storyId","storyFlagIndex","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","result","spawnSync"],"mappings":";;;;;;;;;;AA2CA,MAAMA,KAAe,mBACfC,KAAoB;AAE1B,SAASC,GAAaC,GAAgC;AACpD,SAAO,IAAI,QAAQ,CAACC,MAAY;AAC9B,UAAMC,IAAS,IAAIC,EAAI,OAAA;AACvB,IAAAD,EAAO,WAAW,GAAG,GACrBA,EAAO,KAAK,WAAW,MAAM;AAC3B,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAI;AAAA,IACd,CAAC,GACDC,EAAO,KAAK,WAAW,MAAM;AAC3B,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAK;AAAA,IACf,CAAC,GACDC,EAAO,KAAK,SAAS,MAAM;AACzB,MAAAA,EAAO,QAAA,GACPD,EAAQ,EAAK;AAAA,IACf,CAAC,GACDC,EAAO,QAAQF,GAAM,WAAW;AAAA,EAClC,CAAC;AACH;AAEA,SAASI,GAAeC,GAAuC;AAC7D,MAAI;AACF,UAAML,IAAO,KAAK,MAAMM,EAAaD,GAAW,MAAM,CAAC,EAAE;AACzD,WAAO,OAAOL,KAAS,WAAWA,IAAO;AAAA,EAC3C,QAAQ;AACN;AAAA,EACF;AACF;AAEA,SAASO,GAAgBF,GAAmBL,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Config.ts","../src/cli.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport net from \"node:net\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\n\n/**\n * Boots a target's Storybook and discovers the real port it ends up on,\n * instead of pinning one via `-p`/`--port`. Storybook silently falls back to\n * an OS-assigned port whenever its default/configured one is taken (this is\n * what caused the flaky `webServer` timeouts noted in @recursica/adapter-mui-v7), so the\n * only reliable source of truth is the URL it prints in its own startup\n * banner. Used by both the automated/headless run (cli.ts) and Dev Mode\n * (devServer.ts) — neither pins a port anymore.\n */\n\nexport interface LaunchTarget {\n /** Human-readable name used in log lines. */\n name: string;\n command: string;\n cwd: string;\n /** Reuse an already-running instance (detected via the last-known-port\n * cache) instead of spawning a new one. Mirrors the old `reuseExistingServer`\n * behavior, which used to just probe the one fixed configured port. */\n reuseExistingServer: boolean;\n /** File the discovered port is cached in between runs, so a later\n * `reuseExistingServer` run knows where to look. One per target. */\n cacheFile: string;\n timeoutMs?: number;\n}\n\nexport interface DiscoveredServer {\n url: string;\n port: number;\n /** The process we spawned, or `null` if an already-running instance was\n * reused — callers should only kill what they started. */\n process: ChildProcess | null;\n}\n\n// Storybook prints its bound address in its startup banner wrapped in ANSI\n// color codes and box-drawing chars, e.g.:\n// │ │ - Local: http://localhost:57496/ │ │\n// Strip ANSI first, then match the URL itself.\nconst ANSI_PATTERN = /\\x1b\\[[0-9;]*m/g;\nconst LOCAL_URL_PATTERN = /Local:\\s*(https?:\\/\\/localhost:\\d+)/;\n\nfunction isPortActive(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new net.Socket();\n socket.setTimeout(200);\n socket.once(\"connect\", () => {\n socket.destroy();\n resolve(true);\n });\n socket.once(\"timeout\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.once(\"error\", () => {\n socket.destroy();\n resolve(false);\n });\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nfunction readCachedPort(cacheFile: string): number | undefined {\n try {\n const port = JSON.parse(readFileSync(cacheFile, \"utf8\")).port;\n return typeof port === \"number\" ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeCachedPort(cacheFile: string, port: number): void {\n mkdirSync(dirname(cacheFile), { recursive: true });\n writeFileSync(cacheFile, JSON.stringify({ port }));\n}\n\n/** Spawns `target.command`, streaming its output to the console like before,\n * and resolves once it reports the URL it actually bound to. */\nfunction spawnAndDetect(\n target: LaunchTarget,\n timeoutMs: number,\n): Promise<DiscoveredServer> {\n return new Promise((resolve, reject) => {\n const child = spawn(target.command, {\n cwd: target.cwd,\n stdio: \"pipe\",\n shell: true,\n });\n\n let settled = false;\n const timer = setTimeout(() => {\n if (settled) return;\n settled = true;\n child.kill();\n reject(\n new Error(\n `Timed out after ${timeoutMs}ms waiting for ${target.name}'s Storybook to report its URL (no \"Local: http://localhost:<port>\" line seen in its output).`,\n ),\n );\n }, timeoutMs);\n\n const handleOutput = (data: Buffer, isError: boolean) => {\n const text = data.toString();\n for (const line of text.split(\"\\n\")) {\n if (line.trim()) {\n const label = isError\n ? `${target.name} SB ERROR`\n : `${target.name} SB`;\n (isError ? console.error : console.log)(`[${label}] ${line.trim()}`);\n }\n }\n if (settled) return;\n const match = text.replace(ANSI_PATTERN, \"\").match(LOCAL_URL_PATTERN);\n if (match) {\n settled = true;\n clearTimeout(timer);\n // Non-null: LOCAL_URL_PATTERN has exactly one capture group, and a\n // match only happens when it participated.\n const url = match[1]!;\n const port = Number(new URL(url).port);\n writeCachedPort(target.cacheFile, port);\n resolve({ url, port, process: child });\n }\n };\n child.stdout?.on(\"data\", (data: Buffer) => handleOutput(data, false));\n child.stderr?.on(\"data\", (data: Buffer) => handleOutput(data, true));\n child.on(\"error\", (err) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(err);\n });\n child.on(\"exit\", (code) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n reject(\n new Error(\n `${target.name}'s Storybook exited (code ${code}) before reporting its URL.`,\n ),\n );\n });\n });\n}\n\n/** Adapts a resolved `HarnessWebServerConfig` into a `LaunchTarget`. */\nexport function toLaunchTarget(\n name: string,\n server: HarnessWebServerConfig,\n): LaunchTarget {\n return {\n name,\n command: server.command,\n cwd: server.cwd,\n reuseExistingServer: server.reuseExistingServer,\n cacheFile: server.cacheFile,\n timeoutMs: server.timeout,\n };\n}\n\n/** Reuses an already-running Storybook if `reuseExistingServer` is set and\n * the last-known-port cache points at something still listening; otherwise\n * spawns `target.command` fresh and detects the real port from its output. */\nexport async function launchAndDetectStorybook(\n target: LaunchTarget,\n): Promise<DiscoveredServer> {\n if (target.reuseExistingServer) {\n const cachedPort = readCachedPort(target.cacheFile);\n if (cachedPort !== undefined && (await isPortActive(cachedPort))) {\n console.log(\n `[Dev Launcher] ${target.name} is already running on port ${cachedPort} (reused).`,\n );\n return {\n url: `http://localhost:${cachedPort}`,\n port: cachedPort,\n process: null,\n };\n }\n }\n console.log(`[Dev Launcher] Launching Storybook for ${target.name}...`);\n return spawnAndDetect(target, target.timeoutMs ?? 120 * 1000);\n}\n","import { spawn, type ChildProcess } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport express from \"express\";\nimport { createProxyMiddleware } from \"http-proxy-middleware\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n/**\n * Interactive Dev Mode: a synced, side-by-side browser view of this\n * project's own Storybook and the source of truth, with per-story note\n * taking and an AI-report export. Boots both Storybooks (reusing them if\n * already running) behind a proxy so the own/target pane — which drives\n * the sync and carries Storybook's nav sidebar — loads same-origin on the\n * left, with the source of truth following along as a bare preview on the\n * right.\n *\n * Config-driven — takes the same `{ engineConfig, webServers }` shape\n * `resolveConfig()` produces, in the same [sourceOfTruth, target] order.\n */\n\nconst distDir = dirname(fileURLToPath(import.meta.url));\n\nfunction openBrowser(url: string): void {\n const startCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n console.log(`[Dev Launcher] Auto-launching browser: ${url}`);\n spawn(startCmd, [url], { shell: process.platform === \"win32\" }).on(\n \"error\",\n (err) => {\n console.error(`[Dev Launcher] Failed to auto-launch browser:`, err);\n },\n );\n}\n\nexport interface DevServerOptions {\n /** Port the dev-mode proxy UI itself listens on. Defaults to 6010. */\n port?: number;\n}\n\nexport async function startDevServer(\n engineConfig: AdapterTesterConfig,\n webServers: HarnessWebServerConfig[],\n options: DevServerOptions = {},\n): Promise<void> {\n const [sourceOfTruth, target] = engineConfig.targets;\n const [sourceOfTruthServer, targetServer] = webServers;\n if (\n !sourceOfTruth?.sourceOfTruth ||\n !target ||\n target.sourceOfTruth ||\n !sourceOfTruthServer ||\n !targetServer\n ) {\n throw new Error(\n \"adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.\",\n );\n }\n\n const devPort = options.port ?? 6010;\n\n // Neither Storybook is pinned to a specific port — each one silently\n // falls back to an OS-assigned port whenever its default/configured one is\n // taken, so the real port is only known once it reports it (see\n // portDiscovery.ts). Booted concurrently since neither depends on the other.\n console.log(\n `[Dev Launcher] Resolving ${sourceOfTruth.name} and ${target.name} Storybooks...`,\n );\n const [sourceOfTruthRunning, targetRunning] = await Promise.all([\n launchAndDetectStorybook(\n toLaunchTarget(sourceOfTruth.name, sourceOfTruthServer),\n ),\n launchAndDetectStorybook(toLaunchTarget(target.name, targetServer)),\n ]);\n console.log(`[Dev Launcher] Both Storybooks are active and responsive!`);\n\n const spawned = [sourceOfTruthRunning.process, targetRunning.process].filter(\n (child): child is ChildProcess => child !== null,\n );\n\n const app = express();\n const publicDir = join(distDir, \"../public\");\n const headerPath = join(distDir, \"../report-header.txt\");\n\n // Serve the Dev Mode UI at the root path ONLY if there is no query string.\n // This allows the iframe (which loads with ?path=/story/...) to pass\n // through to the proxy, avoiding an infinite loop of nested wrappers.\n app.get(\"/\", (req, res, next) => {\n if (req.query.path) {\n next();\n return;\n }\n const html = readFileSync(join(publicDir, \"index.html\"), \"utf8\").replace(\n \"<head>\",\n `<head>\\n <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({\n ownName: target.name,\n sourceOfTruthName: sourceOfTruth.name,\n sourceOfTruthPort: sourceOfTruthRunning.port,\n })};</script>`,\n );\n res.send(html);\n });\n\n // Serve the AI prompt header dynamically so it can be edited externally.\n // `reportHeader` in adapter-tester.config.json overrides the file entirely.\n app.get(\"/report-header.txt\", (req, res) => {\n if (engineConfig.reportHeader !== undefined) {\n res.type(\"text/plain\").send(engineConfig.reportHeader);\n return;\n }\n try {\n res.type(\"text/plain\").send(readFileSync(headerPath, \"utf8\"));\n } catch {\n res.status(500).send(\"Error loading report-header.txt\");\n }\n });\n\n // Proxy everything else to this project's own Storybook, preserving\n // absolute paths (e.g. /@vite/client) so HMR keeps working same-origin.\n // This is the pane that drives the sync and shows Storybook's nav sidebar.\n app.use(\n \"/\",\n createProxyMiddleware({\n target: targetRunning.url,\n changeOrigin: true,\n ws: true,\n }),\n );\n\n let cleaningUp = false;\n const cleanup = () => {\n if (cleaningUp) return;\n cleaningUp = true;\n console.log(\n \"\\n[Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...\",\n );\n for (const child of spawned) child.kill(\"SIGINT\");\n process.exit(0);\n };\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n app.listen(devPort, () => {\n console.log(`\n====================================================\n🚀 Adapter Dev Mode proxy running at:\n http://localhost:${devPort}\n====================================================\n`);\n openBrowser(`http://localhost:${devPort}`);\n });\n}\n","import { Ajv } from \"ajv\";\nimport * as ajvFormatsModule from \"ajv-formats\";\nimport type { FormatsPlugin } from \"ajv-formats\";\nimport schema from \"./adapter-tester.schema.json\" with { type: \"json\" };\n\n// ajv-formats ships an ESM-style `export default` on a CJS build with no\n// `\"type\"` field, which under `moduleResolution: NodeNext` TS resolves to\n// the raw module namespace instead of unwrapping the default — a known\n// ajv-formats/TS interop gap, not a version mismatch.\nconst addFormats = (ajvFormatsModule as unknown as { default: FormatsPlugin })\n .default;\n\nconst ajv = new Ajv({ allErrors: true, strict: true });\naddFormats(ajv);\nconst validate = ajv.compile(schema);\n\n/**\n * Validates a parsed `adapter-tester.config.json` against\n * `adapter-tester.schema.json`. Throws with every violation listed — callers\n * must not silently coerce or drop invalid fields.\n */\nexport function validateFileConfig(data: unknown, path: string): void {\n if (validate(data)) return;\n\n const errors = (validate.errors ?? [])\n .map((error) => {\n const extra = error.params?.additionalProperty\n ? ` '${error.params.additionalProperty}'`\n : \"\";\n return ` - ${error.instancePath || \"root\"} ${error.message}${extra}`;\n })\n .join(\"\\n\");\n throw new Error(`Invalid ${path}:\\n${errors}`);\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type {\n AdapterTesterConfig,\n SourceOfTruthGoldenLocation,\n StoryOverride,\n} from \"./config.js\";\nimport type {\n HarnessWebServerConfig,\n MantineSourceOfTruthTokensSource,\n} from \"./harness/mantineSourceOfTruth.js\";\nimport { mantineSourceOfTruthWebServer } from \"./harness/mantineSourceOfTruth.js\";\nimport { validateFileConfig } from \"./validateFileConfig.js\";\n\nconst MANTINE_ADAPTER_PACKAGE_NAME = \"@recursica/adapter-mantine-v8\";\n\nexport const CONFIG_FILE_NAME = \"adapter-tester.config.json\";\nconst DEFAULT_STORYBOOK_COMMAND = \"npm run storybook\";\nconst DEFAULT_STORYBOOK_PORT = 6006;\nconst DEFAULT_SOURCE_OF_TRUTH_PORT = 6011;\nconst DEFAULT_SOURCE_OF_TRUTH_NAME = \"Mantine\";\nconst DEFAULT_GOLDEN_THRESHOLD_PIXELS = 10;\nconst DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS = 3500;\n\ninterface StorybookTargetFileConfig {\n /** First-guess port only, not authoritative — the real port is\n * auto-detected from this Storybook's own startup output, since Storybook\n * silently falls back to an OS-assigned port whenever this one is taken.\n * Auto-detected from this project's own `scripts.storybook` (a `-p\n * <port>`/`--port <port>` flag) when omitted, falling back to 6006. */\n port?: number;\n /** Command that boots the target's Storybook. Defaults to `npm run storybook`. */\n command?: string;\n /** Directory the command runs in, relative to the config file. Defaults to \".\" */\n cwd?: string;\n}\n\ninterface MantineHarnessSourceOfTruthFileConfig {\n /** Default mode: boots a throwaway harness that installs the published\n * `@recursica/adapter-mantine-v8` from npm — no monorepo checkout required. */\n type?: \"mantine-harness\";\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`. */\n port?: number;\n mantineAdapterVersion?: string;\n storybookTemplateVersion?: string;\n /** See `MantineSourceOfTruthTokensSource`. Defaults to `\"target\"` — the\n * harness renders Mantine's components with *this* project's own\n * committed Recursica tokens, not Mantine's own bundled snapshot or (the\n * one thing neither ever means) the retired `@recursica/official-release`\n * package. Set to `\"mantine-package\"` to test against\n * `@recursica/adapter-mantine-v8`'s own bundled tokens instead. */\n tokensSource?: MantineSourceOfTruthTokensSource;\n}\n\ninterface UrlSourceOfTruthFileConfig {\n /** Non-standard mode: points at an already-addressable Storybook — e.g. a\n * sibling workspace package's own Storybook inside this monorepo. */\n type: \"url\";\n name?: string;\n /** First-guess port only, not authoritative — see `HarnessWebServerConfig.port`.\n * Defaults to 6011. */\n port?: number;\n command?: string;\n cwd?: string;\n}\n\ntype SourceOfTruthFileConfig =\n | MantineHarnessSourceOfTruthFileConfig\n | UrlSourceOfTruthFileConfig;\n\nexport interface AdapterTesterFileConfig {\n /** Label for this project's own target. Defaults to the unscoped name in\n * this project's package.json (e.g. \"@recursica/adapter-mui-v7\" -> \"adapter-mui-v7\"). */\n name?: string;\n storybook?: StorybookTargetFileConfig;\n sourceOfTruth?: SourceOfTruthFileConfig;\n goldenThresholdPixels?: number;\n sourceOfTruthThresholdPixels?: number;\n stories?: Record<string, StoryOverride>;\n excludeTitlePrefixes?: string[];\n /** Overrides the AI report header text shown in Dev Mode's \"Full Report\"\n * export. Defaults to the contents of `report-header.txt`. */\n reportHeader?: string;\n /**\n * True only for the source-of-truth adapter's own config (@recursica/adapter-mantine-v8).\n * Skips `sourceOfTruth` entirely — there's nothing above it to diverge\n * from — and runs the own-drift golden check standalone, against just this\n * project's own Storybook. Defaults to false.\n */\n isSourceOfTruthAdapter?: boolean;\n}\n\nexport interface ResolvedAdapterTesterConfig {\n engineConfig: AdapterTesterConfig;\n webServers: HarnessWebServerConfig[];\n}\n\nexport interface ResolveConfigOverrides {\n /** From `--source-of-truth-version`. Overrides `sourceOfTruth.mantineAdapterVersion`. */\n mantineAdapterVersion?: string;\n}\n\nfunction readOwnPackageJson(cwd: string): any {\n const path = join(cwd, \"package.json\");\n if (!existsSync(path)) {\n throw new Error(\n `No package.json found in ${cwd} — run adapter-tester from the root of the project being tested.`,\n );\n }\n return JSON.parse(readFileSync(path, \"utf8\"));\n}\n\nfunction detectOwnPort(cwd: string): number {\n const pkg = readOwnPackageJson(cwd);\n const storybookScript = pkg.scripts?.storybook as string | undefined;\n const match = storybookScript?.match(/(?:-p|--port)[ =](\\d+)/);\n return match ? Number(match[1]) : DEFAULT_STORYBOOK_PORT;\n}\n\nfunction detectOwnName(cwd: string): string {\n const pkg = readOwnPackageJson(cwd);\n const name = pkg.name as string | undefined;\n return name ? name.split(\"/\").pop()! : \"Adapter\";\n}\n\nfunction loadFileConfig(cwd: string): AdapterTesterFileConfig {\n const path = join(cwd, CONFIG_FILE_NAME);\n if (!existsSync(path)) {\n return {};\n }\n const data = JSON.parse(readFileSync(path, \"utf8\"));\n validateFileConfig(data, path);\n return data;\n}\n\n/**\n * Loads `adapter-tester.config.json` from `cwd` (or falls back to defaults\n * when the file doesn't exist) and resolves it into the engine config\n * `resolveVisualRegressionPlan` consumes plus the Playwright `webServer` entries\n * needed to boot both sides of the comparison.\n *\n * Default mode (no `sourceOfTruth`/`storybook` set): compares this project's\n * own Storybook against a throwaway Mantine harness — no monorepo checkout\n * required. Set `sourceOfTruth.type: \"url\"` for the non-standard mode used\n * to compare sibling workspace packages inside this monorepo.\n *\n * `overrides.mantineAdapterVersion` (from `--source-of-truth-version`) pins\n * the mantine-harness install/golden-fetch version for this run, overriding\n * `sourceOfTruth.mantineAdapterVersion`. Throws if passed together with\n * `isSourceOfTruthAdapter` or `sourceOfTruth.type: \"url\"` — neither has a\n * version to pin.\n */\nexport function resolveConfig(\n cwd: string,\n overrides: ResolveConfigOverrides = {},\n): ResolvedAdapterTesterConfig {\n const file = loadFileConfig(cwd);\n const isSourceOfTruthAdapter = file.isSourceOfTruthAdapter ?? false;\n\n if (overrides.mantineAdapterVersion && isSourceOfTruthAdapter) {\n throw new Error(\n \"--source-of-truth-version has no effect on the source-of-truth adapter's own config (isSourceOfTruthAdapter: true) — there's nothing to pin a version for.\",\n );\n }\n\n const ownName = file.name ?? detectOwnName(cwd);\n const ownPort = file.storybook?.port ?? detectOwnPort(cwd);\n const ownCommand = file.storybook?.command ?? DEFAULT_STORYBOOK_COMMAND;\n const ownCwd = resolve(cwd, file.storybook?.cwd ?? \".\");\n const ownWebServer: HarnessWebServerConfig = {\n command: ownCommand,\n port: ownPort,\n cwd: ownCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-own.json\"),\n timeout: 120 * 1000,\n };\n\n const sharedEngineConfig = {\n goldenThresholdPixels:\n file.goldenThresholdPixels ?? DEFAULT_GOLDEN_THRESHOLD_PIXELS,\n sourceOfTruthThresholdPixels:\n file.sourceOfTruthThresholdPixels ??\n DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS,\n stories: file.stories,\n excludeTitlePrefixes: file.excludeTitlePrefixes,\n reportHeader: file.reportHeader,\n // Keyed off `ownCwd`, not `cwd` — the project actually being tested, not\n // wherever the config file happens to live. Matters whenever\n // `storybook.cwd` points at a sibling package: its goldens must resolve\n // to that package's own `test/golden/` (the same directory used when\n // that package runs adapter-tester directly), not a directory under\n // wherever this config file lives.\n goldenDir: join(ownCwd, \"test\", \"golden\"),\n isSourceOfTruthAdapter,\n // Overwritten by the CLI from --update-golden/--approve-divergence.\n goldenMode: \"check\" as const,\n // Overwritten by the CLI from --divergence-only.\n checkMode: \"own\" as const,\n };\n\n // The source-of-truth adapter's own config has nothing above it to\n // diverge from — no second target, no harness/webServer for it at all.\n if (isSourceOfTruthAdapter) {\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [{ name: ownName, url: `http://localhost:${ownPort}` }],\n },\n webServers: [ownWebServer],\n };\n }\n\n const sourceOfTruth = file.sourceOfTruth ?? {\n type: \"mantine-harness\" as const,\n };\n\n let sourceOfTruthName: string;\n let sourceOfTruthPort: number;\n let sourceOfTruthWebServer: HarnessWebServerConfig;\n let sourceOfTruthGolden: SourceOfTruthGoldenLocation;\n\n if (sourceOfTruth.type === \"url\") {\n if (overrides.mantineAdapterVersion) {\n throw new Error(\n '--source-of-truth-version has no effect with sourceOfTruth.type: \"url\" — that mode reads a sibling package\\'s local checkout directly, not a published version.',\n );\n }\n sourceOfTruthName = sourceOfTruth.name ?? DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const sourceOfTruthCwd = resolve(cwd, sourceOfTruth.cwd ?? \".\");\n sourceOfTruthWebServer = {\n command: sourceOfTruth.command ?? DEFAULT_STORYBOOK_COMMAND,\n port: sourceOfTruthPort,\n cwd: sourceOfTruthCwd,\n reuseExistingServer: !process.env.CI,\n cacheFile: join(cwd, \".adapter-tester\", \"last-port-source-of-truth.json\"),\n timeout: 120 * 1000,\n };\n // Sibling package already checked out locally — read its golden files\n // directly, including any uncommitted local changes. No install, no\n // network call.\n sourceOfTruthGolden = {\n type: \"local\",\n dir: join(sourceOfTruthCwd, \"test\", \"golden\"),\n };\n } else {\n sourceOfTruthName = DEFAULT_SOURCE_OF_TRUTH_NAME;\n sourceOfTruthPort = sourceOfTruth.port ?? DEFAULT_SOURCE_OF_TRUTH_PORT;\n const mantineAdapterVersion =\n overrides.mantineAdapterVersion ?? sourceOfTruth.mantineAdapterVersion;\n const tokensSource: MantineSourceOfTruthTokensSource =\n sourceOfTruth.tokensSource ?? \"target\";\n sourceOfTruthWebServer = mantineSourceOfTruthWebServer({\n dir: join(cwd, \".adapter-tester/mantine-harness\"),\n port: sourceOfTruthPort,\n mantineAdapterVersion,\n storybookTemplateVersion: sourceOfTruth.storybookTemplateVersion,\n tokensSource,\n // `ownCwd`, not `cwd` — the project actually being tested (same\n // reasoning `goldenDir` above uses), source of the 4 token files\n // copied into the harness when `tokensSource` is \"target\".\n targetDir: ownCwd,\n });\n // No local checkout — resolve the installed version against the npm\n // registry and fetch that version's golden files from the public repo.\n // Never needs `sourceOfTruthWebServer` above; the golden check on its\n // own doesn't boot a second Storybook at all (see cli.ts).\n sourceOfTruthGolden = {\n type: \"npm\",\n packageName: MANTINE_ADAPTER_PACKAGE_NAME,\n versionSpec: mantineAdapterVersion ?? \"latest\",\n cacheDir: join(cwd, \".adapter-tester/mantine-golden-cache\"),\n };\n }\n\n return {\n engineConfig: {\n ...sharedEngineConfig,\n targets: [\n {\n name: sourceOfTruthName,\n url: `http://localhost:${sourceOfTruthPort}`,\n sourceOfTruth: true,\n },\n { name: ownName, url: `http://localhost:${ownPort}` },\n ],\n sourceOfTruthGolden,\n },\n // [sourceOfTruth, own] — Dev Mode needs both; the automated golden run\n // (cli.ts) only ever boots the last entry, since its divergence check\n // reads stored golden files, not a live source-of-truth page.\n webServers: [sourceOfTruthWebServer, ownWebServer],\n };\n}\n","import { spawnSync } from \"node:child_process\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AdapterTesterConfig } from \"./config.js\";\nimport { startDevServer } from \"./devServer.js\";\nimport { resolveConfig } from \"./fileConfig.js\";\nimport type { HarnessWebServerConfig } from \"./harness/mantineSourceOfTruth.js\";\nimport { launchAndDetectStorybook, toLaunchTarget } from \"./portDiscovery.js\";\n\n// `dist/testing.js` is always a sibling of this file — both inside a\n// consumer's node_modules/@recursica/adapter-tester/dist and inside this\n// monorepo's own packages/adapter-tester/dist when self-hosting — so the\n// generated spec below can reach it without depending on how the package\n// itself resolves at import time.\nconst distDir = dirname(fileURLToPath(import.meta.url));\nconst testingEntry = pathToFileURL(join(distDir, \"testing.js\")).href;\n\n// `--source-of-truth-version <value>` takes a value, unlike every other own\n// flag below — pulled out of argv first so the boolean flags/passthrough\n// logic never has to know it exists.\nconst args = process.argv.slice(2);\nlet sourceOfTruthVersion: string | undefined;\nconst sourceOfTruthVersionFlagIndex = args.indexOf(\"--source-of-truth-version\");\nif (sourceOfTruthVersionFlagIndex !== -1) {\n const value = args[sourceOfTruthVersionFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--source-of-truth-version requires a value, e.g. --source-of-truth-version 0.53.0\",\n );\n }\n sourceOfTruthVersion = value;\n args.splice(sourceOfTruthVersionFlagIndex, 2);\n}\n\n// `--story <story-id>` scopes a run to exactly one story — pulled out the\n// same way, ahead of the passthrough logic, since it's consumed here (to\n// filter the generated spec) rather than forwarded to Playwright. Equivalent\n// to `--grep \"<story-id>\"`, but exact-match and easier to reach for when\n// iterating on a single component.\nlet storyId: string | undefined;\nconst storyFlagIndex = args.indexOf(\"--story\");\nif (storyFlagIndex !== -1) {\n const value = args[storyFlagIndex + 1];\n if (value === undefined || value.startsWith(\"--\")) {\n throw new Error(\n \"--story requires a story id, e.g. --story ui-kit-button--loading\",\n );\n }\n storyId = value;\n args.splice(storyFlagIndex, 2);\n}\n\nconst cwd = process.cwd();\nconst { engineConfig, webServers } = resolveConfig(cwd, {\n mantineAdapterVersion: sourceOfTruthVersion,\n});\n\nif (args.includes(\"--update-golden\")) {\n engineConfig.goldenMode = \"update-golden\";\n} else if (args.includes(\"--approve-divergence\")) {\n engineConfig.goldenMode = \"approve-divergence\";\n}\n\nif (args.includes(\"--divergence-only\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"--divergence-only has nothing to diverge from — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n engineConfig.checkMode = \"divergence\";\n} else if (engineConfig.goldenMode === \"approve-divergence\") {\n throw new Error(\n \"--approve-divergence only makes sense with --divergence-only — there's nothing to approve without the divergence check running.\",\n );\n}\n\nif (args.includes(\"--dry-run\")) {\n console.log(JSON.stringify({ engineConfig, webServers }, null, 2));\n process.exit(0);\n}\n\n// Any arg besides our own flags is passed straight through to `playwright\n// test` — e.g. `npm run adapter-tester:automated -- --grep \"Toast\"` to scope\n// a run to matching stories, instead of every invocation running the full\n// suite. Our own flags are consumed above, not forwarded — Playwright itself\n// doesn't know about them.\nconst OWN_FLAGS = new Set([\n \"--dry-run\",\n \"--serve\",\n \"--update-golden\",\n \"--approve-divergence\",\n \"--divergence-only\",\n]);\nconst passthroughArgs = args.filter((arg) => !OWN_FLAGS.has(arg));\n\n// The bundled build target doesn't support top-level await, so the async\n// work (launching Storybook and detecting its real port) lives in main().\nmain().catch((err) => {\n console.error(err);\n process.exitCode = 1;\n});\n\nasync function main(): Promise<void> {\n if (args.includes(\"--serve\")) {\n if (engineConfig.isSourceOfTruthAdapter) {\n throw new Error(\n \"Dev Mode (--serve) has nothing to sync this project's Storybook against — isSourceOfTruthAdapter is true in this project's adapter-tester.config.json.\",\n );\n }\n // Dual-Storybook interactive Dev Mode — no Playwright, no screenshots.\n // Used by the `adapter-tester` npm script.\n await startDevServer(engineConfig, webServers);\n } else {\n // The golden-image checks never need the source-of-truth adapter's own\n // Storybook running — the divergence check reads its stored golden files,\n // not a live page — so only the last (own) webServer is booted here. Dev\n // Mode above is the one thing that still needs both.\n const ownWebServer = webServers.at(-1);\n if (!ownWebServer) {\n throw new Error(\"resolveConfig() returned no webServers to boot.\");\n }\n await runAutomated(ownWebServer, engineConfig);\n }\n}\n\n/**\n * Boots this project's own Storybook (auto-detecting the port it actually\n * lands on — see portDiscovery.ts), generates a throwaway Playwright config\n * + spec under `.adapter-tester/run/`, and runs the automated pixel-diff\n * suite against it. Used by the `adapter-tester:automated` npm script.\n *\n * Playwright's own `webServer` option can't be used here — it only knows how\n * to poll a port/URL decided *before* the command it spawns runs, but\n * Storybook silently falls back to a different, OS-assigned port whenever\n * its configured one is taken. So this boots and waits for Storybook itself,\n * then points the generated config straight at whatever URL it actually\n * reports.\n */\nasync function runAutomated(\n server: HarnessWebServerConfig,\n config: AdapterTesterConfig,\n): Promise<void> {\n const runDir = join(cwd, \".adapter-tester/run\");\n mkdirSync(runDir, { recursive: true });\n\n const ownTarget = config.targets.at(-1);\n if (!ownTarget) {\n throw new Error(\"resolveConfig() returned no targets to check.\");\n }\n const { url, process: spawned } = await launchAndDetectStorybook(\n toLaunchTarget(ownTarget.name, server),\n );\n ownTarget.url = url;\n\n writeFileSync(\n join(runDir, \"playwright.config.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { defineConfig, devices } from \"@playwright/test\";\n\nexport default defineConfig({\n testDir: ${JSON.stringify(runDir)},\n // Each golden check only reads/writes its own story's manifest.json entry,\n // under a lock, so concurrent workers never race each other (see\n // \\`updateManifestEntry\\`). Defaults to 1 worker (1 Chromium instance) to\n // avoid exhausting memory running the full suite; override with\n // \\`--workers <n>\\` (forwarded straight through to Playwright) to parallelize.\n workers: 1,\n fullyParallel: true,\n forbidOnly: !!process.env.CI,\n retries: process.env.CI ? 2 : 0,\n reporter: [[\"html\", { open: \"never\" }], [\"list\"]],\n use: { trace: \"on-first-retry\" },\n projects: [{ name: \"chromium\", use: { ...devices[\"Desktop Chrome\"] } }],\n // No webServer entry — this project's own Storybook is already running by\n // the time this config is used (see runAutomated() in cli.ts).\n});\n`,\n );\n\n writeFileSync(\n join(runDir, \"visual-regression.spec.js\"),\n `// Generated by \\`adapter-tester\\` — do not edit, regenerated on every run.\nimport { test, expect } from \"@playwright/test\";\nimport { resolveVisualRegressionPlan } from ${JSON.stringify(testingEntry)};\n\n// \\`test.describe\\`/\\`test\\` are called here, not inside resolveVisualRegressionPlan,\n// so Playwright's HTML report groups the suite under this file instead of a\n// sourcemapped path into adapter-tester's own library code.\nconst { ownTargetName, suiteLabel, stories, missingFromSourceOfTruth, checkStory } =\n await resolveVisualRegressionPlan(${JSON.stringify(config, null, 2)});\n\n// Set from \\`--story <story-id>\\` — scopes this run to exactly one story and\n// skips the (suite-wide) parity check, which has nothing to do with it.\nconst storyId = ${JSON.stringify(storyId ?? null)};\nconst scopedStories = storyId\n ? stories.filter((story) => story.id === storyId)\n : stories;\nif (storyId && scopedStories.length === 0) {\n throw new Error(\\`--story \"\\${storyId}\" matched no story in this Storybook.\\`);\n}\n\ntest.describe(\\`\\${ownTargetName} — \\${suiteLabel}\\`, () => {\n if (!storyId && missingFromSourceOfTruth.length > 0) {\n test(\"story parity with source of truth\", () => {\n expect(\n missingFromSourceOfTruth,\n \\`\\${missingFromSourceOfTruth.length} stor(y/ies) exist in the source of truth but are missing here. Add the missing story, or mark it \\\\\\`exclude: true\\\\\\` under \\\\\\`stories\\\\\\` in adapter-tester.config.json if intentional.\\`,\n ).toEqual([]);\n });\n }\n for (const story of scopedStories) {\n test(story.id, async ({ browser }, testInfo) => {\n await checkStory(story, browser, testInfo);\n });\n }\n});\n`,\n );\n\n try {\n const result = spawnSync(\n \"npx\",\n [\n \"playwright\",\n \"test\",\n \"--config\",\n join(runDir, \"playwright.config.js\"),\n ...passthroughArgs,\n ],\n { stdio: \"inherit\", cwd, shell: process.platform === \"win32\" },\n );\n process.exitCode = result.status ?? 1;\n } finally {\n // Only tear down the Storybook we spawned — an instance we reused via\n // the last-known-port cache was already running before we got here, and\n // should stay running after.\n spawned?.kill(\"SIGTERM\");\n }\n}\n"],"names":["ANSI_PATTERN","LOCAL_URL_PATTERN","isPortActive","port","resolve","socket","net","readCachedPort","cacheFile","readFileSync","writeCachedPort","mkdirSync","dirname","writeFileSync","spawnAndDetect","target","timeoutMs","reject","child","spawn","settled","timer","handleOutput","data","isError","text","line","label","match","url","_a","_b","err","code","toLaunchTarget","name","server","launchAndDetectStorybook","cachedPort","distDir","fileURLToPath","openBrowser","startCmd","startDevServer","engineConfig","webServers","options","sourceOfTruth","sourceOfTruthServer","targetServer","devPort","sourceOfTruthRunning","targetRunning","spawned","app","express","publicDir","join","headerPath","req","res","next","html","createProxyMiddleware","cleaningUp","cleanup","addFormats","ajvFormatsModule.default","ajv","Ajv","validate","schema","validateFileConfig","path","errors","error","extra","MANTINE_ADAPTER_PACKAGE_NAME","CONFIG_FILE_NAME","DEFAULT_STORYBOOK_COMMAND","DEFAULT_STORYBOOK_PORT","DEFAULT_SOURCE_OF_TRUTH_PORT","DEFAULT_SOURCE_OF_TRUTH_NAME","DEFAULT_GOLDEN_THRESHOLD_PIXELS","DEFAULT_SOURCE_OF_TRUTH_THRESHOLD_PIXELS","readOwnPackageJson","cwd","existsSync","detectOwnPort","storybookScript","detectOwnName","loadFileConfig","resolveConfig","overrides","file","isSourceOfTruthAdapter","ownName","ownPort","ownCommand","ownCwd","_c","ownWebServer","sharedEngineConfig","sourceOfTruthName","sourceOfTruthPort","sourceOfTruthWebServer","sourceOfTruthGolden","sourceOfTruthCwd","mantineAdapterVersion","tokensSource","mantineSourceOfTruthWebServer","testingEntry","pathToFileURL","args","sourceOfTruthVersion","sourceOfTruthVersionFlagIndex","value","storyId","storyFlagIndex","OWN_FLAGS","passthroughArgs","arg","main","runAutomated","config","runDir","ownTarget","result","spawnSync"],"mappings":";;;;;;;;;;AA2CA,MAAMA,KAAe,mBACfC,KAAoB;AAE1B,SAASC,GAAaC,GAAgC;AACpD,SAAO,IAAI,QAAQ,CAACC,MAAY;AAC9B,UAAMC,IAAS,IAAIC,EAAI,OAAA;AACvB,IAAAD,EAAO,WAAW,GAAG,GACrBA,EAAO,KAAK,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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AA0B/C,MAAI;AACF,UAAMU,IAASC;AAAA,MACb;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACAvE,EAAKoE,GAAQ,sBAAsB;AAAA,QACnC,GAAGL;AAAA,MAAA;AAAA,MAEL,EAAE,OAAO,WAAW,KAAAlC,GAAK,OAAO,QAAQ,aAAa,QAAA;AAAA,IAAQ;AAE/D,YAAQ,WAAWyC,EAAO,UAAU;AAAA,EACtC,UAAA;AAIE,IAAA1E,KAAA,QAAAA,EAAS,KAAK;AAAA,EAChB;AACF;"}
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,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;;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"}
@@ -24,7 +24,7 @@ interface MantineHarnessSourceOfTruthFileConfig {
24
24
  /** See `MantineSourceOfTruthTokensSource`. Defaults to `"target"` — the
25
25
  * harness renders Mantine's components with *this* project's own
26
26
  * committed Recursica tokens, not Mantine's own bundled snapshot or (the
27
- * one thing neither ever means) the deprecated `@recursica/official-release`
27
+ * one thing neither ever means) the retired `@recursica/official-release`
28
28
  * package. Set to `"mantine-package"` to test against
29
29
  * `@recursica/adapter-mantine-v8`'s own bundled tokens instead. */
30
30
  tokensSource?: MantineSourceOfTruthTokensSource;
@@ -31,7 +31,7 @@
31
31
  * stale relative to Mantine's.
32
32
  *
33
33
  * Never `@recursica/official-release` — confirmed live (not a theoretical
34
- * concern) to be a stale, deprecated, generic token snapshot unrelated to
34
+ * concern) to be a stale, retired, generic token snapshot unrelated to
35
35
  * either adapter's real ones: it resolves the brand's primary/secondary
36
36
  * fonts to Lexend/Bellota Text, not this design system's actual Dongle/
37
37
  * Nunito Sans. An earlier version of this harness imported from it
@@ -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"}