@getchomp/mcp 0.0.0-stage → 0.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -2
  3. package/dist/conventionsReference.d.ts +84 -0
  4. package/dist/conventionsReference.js +313 -0
  5. package/dist/designSystem/astScanner.d.ts +153 -0
  6. package/dist/designSystem/astScanner.js +2014 -0
  7. package/dist/designSystem/baseline.d.ts +65 -0
  8. package/dist/designSystem/baseline.js +136 -0
  9. package/dist/designSystem/color.d.ts +35 -0
  10. package/dist/designSystem/color.js +265 -0
  11. package/dist/designSystem/config.d.ts +183 -0
  12. package/dist/designSystem/config.js +469 -0
  13. package/dist/designSystem/contrast.d.ts +55 -0
  14. package/dist/designSystem/contrast.js +377 -0
  15. package/dist/designSystem/cssParser.d.ts +63 -0
  16. package/dist/designSystem/cssParser.js +469 -0
  17. package/dist/designSystem/merges.d.ts +57 -0
  18. package/dist/designSystem/merges.js +94 -0
  19. package/dist/designSystem/preprocessors.d.ts +46 -0
  20. package/dist/designSystem/preprocessors.js +1108 -0
  21. package/dist/designSystem/presentation.d.ts +45 -0
  22. package/dist/designSystem/presentation.js +796 -0
  23. package/dist/designSystem/styleVectors.d.ts +27 -0
  24. package/dist/designSystem/styleVectors.js +484 -0
  25. package/dist/designSystem/tokens.d.ts +39 -0
  26. package/dist/designSystem/tokens.js +409 -0
  27. package/dist/designSystem/topology.d.ts +64 -0
  28. package/dist/designSystem/topology.js +254 -0
  29. package/dist/designSystem/types.d.ts +857 -0
  30. package/dist/designSystem/types.js +113 -0
  31. package/dist/designSystem/typography.d.ts +25 -0
  32. package/dist/designSystem/typography.js +244 -0
  33. package/dist/designSystem/uiShapes.d.ts +74 -0
  34. package/dist/designSystem/uiShapes.js +285 -0
  35. package/dist/designSystem/valueClusters.d.ts +76 -0
  36. package/dist/designSystem/valueClusters.js +281 -0
  37. package/dist/designSystemPlugin.d.ts +321 -0
  38. package/dist/designSystemPlugin.js +4730 -0
  39. package/dist/enrichNodesPlugin.d.ts +160 -0
  40. package/dist/enrichNodesPlugin.js +957 -0
  41. package/dist/index.d.ts +65 -0
  42. package/dist/index.js +1298 -0
  43. package/dist/intelligence.d.ts +502 -0
  44. package/dist/intelligence.js +3058 -0
  45. package/dist/pluginRunner.d.ts +364 -0
  46. package/dist/pluginRunner.js +1096 -0
  47. package/dist/plugins/design-system/index.d.ts +14 -0
  48. package/dist/plugins/design-system/index.js +241 -0
  49. package/dist/plugins/enrich-nodes/index.d.ts +388 -0
  50. package/dist/plugins/enrich-nodes/index.js +697 -0
  51. package/dist/plugins/index.d.ts +15 -0
  52. package/dist/plugins/index.js +20 -0
  53. package/dist/plugins/local-shims/index.d.ts +121 -0
  54. package/dist/plugins/local-shims/index.js +237 -0
  55. package/dist/shimsPlugin.d.ts +134 -0
  56. package/dist/shimsPlugin.js +1392 -0
  57. package/package.json +39 -3
@@ -0,0 +1,469 @@
1
+ /**
2
+ * packages/mcp/src/designSystem/config.ts
3
+ *
4
+ * Configuration for the `design-system` plugin. Nothing in the plugin core may assume a
5
+ * particular repo's naming (`--surface-*`, `sg-*`, `<Drawer>` …). Repo-specific knowledge lives
6
+ * here, supplied via the `designSystem` key of `chomp.config.json` at the repo root, and is
7
+ * otherwise *derived* from the code ("extract" mode).
8
+ *
9
+ * Modes
10
+ * - `extract` (default when no system is declared): tiers, theme contexts, atoms and
11
+ * conventions are derived from the code itself.
12
+ * - `adhere`: a declared system (`tokens.sources` and/or `atoms.definitions`) is the single
13
+ * source of truth; anything outside it is reported as drift.
14
+ * - `auto`: `adhere` if the config declares a system, else `extract`.
15
+ */
16
+ import { existsSync, readFileSync } from "node:fs";
17
+ import { dirname, resolve } from "node:path";
18
+ export const DEFAULT_FRONTEND_DEPENDENCIES = [
19
+ "react",
20
+ "react-dom",
21
+ "preact",
22
+ "next",
23
+ "vue",
24
+ "nuxt",
25
+ "svelte",
26
+ "@sveltejs/kit",
27
+ "solid-js",
28
+ "astro",
29
+ "@remix-run/react",
30
+ "react-router",
31
+ "react-router-dom",
32
+ "@angular/core",
33
+ "lit",
34
+ "tailwindcss",
35
+ "styled-components",
36
+ "@emotion/react",
37
+ "@emotion/styled",
38
+ "@stitches/react",
39
+ "@vanilla-extract/css",
40
+ "pixi.js",
41
+ ];
42
+ /** Generic, HTML-semantic atom catalog. Order matters: first matching definition wins per element. */
43
+ export const DEFAULT_ATOM_CATALOG = [
44
+ {
45
+ name: "Switch",
46
+ description: "Accessible boolean toggle (`role=\"switch\"`).",
47
+ matchers: [{ role: "switch" }],
48
+ },
49
+ {
50
+ name: "Checkbox",
51
+ description: "Checkbox input (`<input type=\"checkbox\">`).",
52
+ matchers: [{ tag: "input", attrs: { type: "checkbox" } }],
53
+ },
54
+ {
55
+ name: "Tooltip",
56
+ description: "Hover/focus hint (`role=\"tooltip\"`).",
57
+ matchers: [{ role: "tooltip" }],
58
+ },
59
+ {
60
+ name: "Dialog",
61
+ description: "Modal / drawer / sheet surface (`<dialog>`, `role=\"dialog\"`).",
62
+ matchers: [{ tag: "dialog" }, { role: "dialog" }, { role: "alertdialog" }],
63
+ sharedComponentNames: ["Dialog", "Modal", "Drawer", "Sheet", "SharedDialog"],
64
+ },
65
+ {
66
+ name: "Alert",
67
+ description: "Contextual message (`role=\"alert\"` / `role=\"status\"`).",
68
+ matchers: [{ role: "alert" }, { role: "status" }],
69
+ sharedComponentNames: ["Alert", "Banner", "Callout", "Notice", "SharedAlert"],
70
+ },
71
+ {
72
+ name: "Select",
73
+ matchers: [{ tag: "select" }],
74
+ },
75
+ {
76
+ name: "Textarea",
77
+ matchers: [{ tag: "textarea" }],
78
+ },
79
+ {
80
+ name: "Input",
81
+ matchers: [{ tag: "input" }],
82
+ sharedComponentNames: ["Input", "TextField", "TextInput", "SharedInput"],
83
+ },
84
+ {
85
+ name: "DescriptionList",
86
+ description: "Key/value metadata grid (`<dl>`).",
87
+ matchers: [{ tag: "dl" }],
88
+ sharedComponentNames: ["DescriptionList", "KeyValueList", "KeyValue", "DefinitionList"],
89
+ },
90
+ {
91
+ name: "Tabs",
92
+ description: "Accessible tabbed navigation (`role=\"tablist\"` or stateful tab group).",
93
+ matchers: [{ role: "tablist" }],
94
+ sharedComponentNames: ["Tabs", "TabList", "SharedTabs"],
95
+ },
96
+ {
97
+ name: "SegmentedControl",
98
+ description: "Exclusive segmented mode toggle (`role=\"radiogroup\"` or track toggle group).",
99
+ matchers: [{ role: "radiogroup" }],
100
+ sharedComponentNames: ["SegmentedControl", "ToggleGroup", "SharedSegmentedControl"],
101
+ },
102
+ {
103
+ name: "Button",
104
+ description: "Interactive action (`<button>`, `role=\"button\"`).",
105
+ matchers: [{ tag: "button" }, { role: "button" }],
106
+ sharedComponentNames: ["Button", "Btn", "SharedButton"],
107
+ },
108
+ ];
109
+ export const DEFAULT_DARK_THEME_PATTERNS = [
110
+ "\\[data-theme\\s*=\\s*[\"']?dark[\"']?\\]",
111
+ "\\[data-mode\\s*=\\s*[\"']?dark[\"']?\\]",
112
+ "\\[data-color-scheme\\s*=\\s*[\"']?dark[\"']?\\]",
113
+ "(?:^|[\\s,>+~(])\\.dark\\b",
114
+ "\\.theme-dark\\b",
115
+ "prefers-color-scheme\\s*:\\s*dark",
116
+ ];
117
+ export const DEFAULT_LIGHT_THEME_PATTERNS = [
118
+ "\\[data-theme\\s*=\\s*[\"']?light[\"']?\\]",
119
+ "\\[data-mode\\s*=\\s*[\"']?light[\"']?\\]",
120
+ "\\[data-color-scheme\\s*=\\s*[\"']?light[\"']?\\]",
121
+ "(?:^|[\\s,>+~(])\\.light\\b",
122
+ "\\.theme-light\\b",
123
+ "prefers-color-scheme\\s*:\\s*light",
124
+ ];
125
+ export const DEFAULT_PROP_FAMILIES = [
126
+ {
127
+ semanticRole: "Dismiss / Close Callback",
128
+ propNames: ["onClose", "onDismiss", "onCancel", "handleClose"],
129
+ canonicalRecommendation: "Standardize dismissal callbacks on one name (e.g. `onClose`).",
130
+ },
131
+ {
132
+ semanticRole: "Overlay Open State",
133
+ propNames: ["open", "isOpen"],
134
+ canonicalRecommendation: "Standardize overlay visibility on one boolean prop (e.g. `open`).",
135
+ },
136
+ {
137
+ semanticRole: "Checked State",
138
+ propNames: ["checked", "isChecked"],
139
+ canonicalRecommendation: "Standardize checked state on one boolean prop (e.g. `checked`).",
140
+ },
141
+ {
142
+ semanticRole: "Active / Selected State",
143
+ propNames: ["active", "isActive", "selected", "isSelected"],
144
+ canonicalRecommendation: "Standardize active/selected state on one boolean prop.",
145
+ },
146
+ {
147
+ semanticRole: "Disabled State",
148
+ propNames: ["disabled", "isDisabled"],
149
+ canonicalRecommendation: "Standardize disabled state on one boolean prop (e.g. `disabled`).",
150
+ },
151
+ ];
152
+ export const DEFAULT_DESIGN_SYSTEM_CONFIG = {
153
+ mode: "auto",
154
+ scope: {
155
+ packages: "auto",
156
+ exclude: [],
157
+ frontendDependencies: [...DEFAULT_FRONTEND_DEPENDENCIES],
158
+ excludeFiles: [
159
+ "\\.(?:test|spec|stories|story)\\.[a-z]+$",
160
+ "(?:^|/)__(?:tests|mocks|snapshots)__/",
161
+ ],
162
+ },
163
+ tokens: {
164
+ sources: [],
165
+ tiers: { primitive: [], semantic: [], component: [] },
166
+ externalPrefixes: [
167
+ "--tw-",
168
+ "--radix-",
169
+ "--rsbuild-",
170
+ "--next-",
171
+ "--mui-",
172
+ "--chakra-",
173
+ "--mantine-",
174
+ "--ant-",
175
+ "--shiki-",
176
+ ],
177
+ },
178
+ themes: {
179
+ dark: [...DEFAULT_DARK_THEME_PATTERNS],
180
+ light: [...DEFAULT_LIGHT_THEME_PATTERNS],
181
+ },
182
+ contrast: {
183
+ minRatio: 4.5,
184
+ pairs: [],
185
+ discoverFromRules: true,
186
+ discoverFromNaming: true,
187
+ },
188
+ styling: {
189
+ cssClassPrefixes: [],
190
+ canvas: { slotRecorderFactories: [], cssValueHelpers: [], tokenReaderHelpers: [] },
191
+ tailwind: { defaultPalette: "allow", rawPalettes: [], allowedPalettes: [] },
192
+ },
193
+ atoms: { catalog: "defaults", definitions: [], minUnsharedInstances: 3 },
194
+ concepts: {
195
+ abbreviations: {
196
+ Btn: "Button",
197
+ Dlg: "Dialog",
198
+ Img: "Image",
199
+ Nav: "Navigation",
200
+ Pnl: "Panel",
201
+ Tbl: "Table",
202
+ },
203
+ minGroupSize: 2,
204
+ minSimilarity: 0.34,
205
+ },
206
+ propFamilies: [...DEFAULT_PROP_FAMILIES],
207
+ clustering: {
208
+ colorThreshold: 0.035,
209
+ tokenMatchThreshold: 0.045,
210
+ lengthTolerancePx: 1,
211
+ minOccurrences: 2,
212
+ maxClusters: 40,
213
+ },
214
+ composability: {
215
+ forbiddenImports: [
216
+ "next/router",
217
+ "next/navigation",
218
+ "react-router",
219
+ "react-router-dom",
220
+ "@tanstack/react-query",
221
+ "swr",
222
+ "redux",
223
+ "react-redux",
224
+ "zustand",
225
+ "axios",
226
+ ],
227
+ flagRootMargin: true,
228
+ flagFixedWidth: true,
229
+ },
230
+ invariants: {
231
+ colorPropPattern: "(?:^|[a-z])(?:[Cc]olor|[Cc]olour|[Bb]g|[Bb]ackground|[Ff]ill|[Ss]troke|[Tt]int)$",
232
+ },
233
+ baseline: { path: ".chomp/plugins/design-system/baseline.json" },
234
+ };
235
+ function isPlainObject(v) {
236
+ return typeof v === "object" && v !== null && !Array.isArray(v);
237
+ }
238
+ function mergeDeep(base, override) {
239
+ if (!isPlainObject(base) || !isPlainObject(override)) {
240
+ return (override === undefined ? base : override);
241
+ }
242
+ const out = { ...base };
243
+ for (const [k, v] of Object.entries(override)) {
244
+ if (v === undefined)
245
+ continue;
246
+ const b = base[k];
247
+ out[k] = isPlainObject(b) && isPlainObject(v) ? mergeDeep(b, v) : v;
248
+ }
249
+ return out;
250
+ }
251
+ export function validateRegexSources(label, sources, warnings) {
252
+ const valid = [];
253
+ for (const s of sources) {
254
+ try {
255
+ new RegExp(s);
256
+ valid.push(s);
257
+ }
258
+ catch {
259
+ warnings.push(`designSystem config: ignoring invalid regex in ${label}: ${s}`);
260
+ }
261
+ }
262
+ return valid;
263
+ }
264
+ export function compileRegexes(sources, flags = "i") {
265
+ const out = [];
266
+ for (const s of sources) {
267
+ try {
268
+ out.push(new RegExp(s, flags));
269
+ }
270
+ catch {
271
+ /* invalid sources are reported by validateRegexSources */
272
+ }
273
+ }
274
+ return out;
275
+ }
276
+ /** Converts a repo-relative glob (`*`, `**`) or plain prefix to a RegExp. */
277
+ export function globToRegExp(glob) {
278
+ const clean = glob.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
279
+ const escaped = clean
280
+ .replace(/[.+^${}()|[\]]/g, "\\$&")
281
+ .replace(/\*\*/g, "\u0000")
282
+ .replace(/\*/g, "[^/]*")
283
+ .replace(/\u0000/g, ".*");
284
+ return new RegExp(`^${escaped}(?:/.*)?$`);
285
+ }
286
+ export function resolveDesignSystemConfig(repoPath, overrides) {
287
+ const warnings = [];
288
+ let configPath = null;
289
+ let userConfig;
290
+ const candidate = resolve(repoPath, "chomp.config.json");
291
+ if (existsSync(candidate)) {
292
+ try {
293
+ const parsed = JSON.parse(readFileSync(candidate, "utf8"));
294
+ if (isPlainObject(parsed) && isPlainObject(parsed.designSystem)) {
295
+ userConfig = parsed.designSystem;
296
+ configPath = candidate;
297
+ }
298
+ }
299
+ catch (err) {
300
+ warnings.push(`designSystem config: could not parse chomp.config.json (${err.message})`);
301
+ }
302
+ }
303
+ if (!userConfig) {
304
+ const stealthCandidate = resolve(repoPath, ".chomp", "plugins", "design-system", "config.json");
305
+ if (existsSync(stealthCandidate)) {
306
+ try {
307
+ const parsed = JSON.parse(readFileSync(stealthCandidate, "utf8"));
308
+ if (isPlainObject(parsed)) {
309
+ userConfig = isPlainObject(parsed.designSystem) ? parsed.designSystem : parsed;
310
+ configPath = stealthCandidate;
311
+ }
312
+ }
313
+ catch (err) {
314
+ warnings.push(`designSystem config: could not parse .chomp/plugins/design-system/config.json (${err.message})`);
315
+ }
316
+ }
317
+ }
318
+ let config = mergeDeep(DEFAULT_DESIGN_SYSTEM_CONFIG, userConfig);
319
+ if (overrides)
320
+ config = mergeDeep(config, overrides);
321
+ config.tokens.tiers = {
322
+ primitive: validateRegexSources("tokens.tiers.primitive", config.tokens.tiers.primitive, warnings),
323
+ semantic: validateRegexSources("tokens.tiers.semantic", config.tokens.tiers.semantic, warnings),
324
+ component: validateRegexSources("tokens.tiers.component", config.tokens.tiers.component, warnings),
325
+ };
326
+ config.themes = {
327
+ dark: validateRegexSources("themes.dark", config.themes.dark, warnings),
328
+ light: validateRegexSources("themes.light", config.themes.light, warnings),
329
+ };
330
+ config.scope.excludeFiles = validateRegexSources("scope.excludeFiles", config.scope.excludeFiles, warnings);
331
+ for (const def of config.atoms.definitions) {
332
+ for (const m of def.matchers ?? []) {
333
+ if (m.classPattern) {
334
+ validateRegexSources(`atoms.definitions[${def.name}].classPattern`, [m.classPattern], warnings);
335
+ }
336
+ }
337
+ }
338
+ const declaresSystem = config.tokens.sources.length > 0 || config.atoms.definitions.length > 0;
339
+ let mode;
340
+ let modeReason;
341
+ if (config.mode === "adhere") {
342
+ mode = "adhere";
343
+ modeReason = declaresSystem
344
+ ? "config.mode = adhere"
345
+ : "config.mode = adhere but no tokens.sources / atoms.definitions declared; nothing to adhere to, so token/atom drift checks are limited";
346
+ }
347
+ else if (config.mode === "extract") {
348
+ mode = "extract";
349
+ modeReason = "config.mode = extract";
350
+ }
351
+ else if (declaresSystem) {
352
+ mode = "adhere";
353
+ modeReason = "auto: a system is declared in chomp.config.json (tokens.sources / atoms.definitions)";
354
+ }
355
+ else {
356
+ mode = "extract";
357
+ modeReason = "auto: no system declared; deriving the system from the code";
358
+ }
359
+ return { config, configPath, declaresSystem, mode, modeReason, warnings };
360
+ }
361
+ export function detectFrontendScope(files, readFile, config) {
362
+ const pkgCache = new Map();
363
+ const readPkg = (dir) => {
364
+ if (pkgCache.has(dir))
365
+ return pkgCache.get(dir) ?? null;
366
+ const raw = readFile(dir === "." ? "package.json" : `${dir}/package.json`);
367
+ let parsed = null;
368
+ if (raw) {
369
+ try {
370
+ parsed = JSON.parse(raw);
371
+ }
372
+ catch {
373
+ parsed = null;
374
+ }
375
+ }
376
+ pkgCache.set(dir, parsed);
377
+ return parsed;
378
+ };
379
+ const owningDirCache = new Map();
380
+ const owningDir = (relPath) => {
381
+ const startDir = dirname(relPath).replace(/\\/g, "/");
382
+ if (owningDirCache.has(startDir))
383
+ return owningDirCache.get(startDir);
384
+ let dir = startDir === "" ? "." : startDir;
385
+ const visited = [];
386
+ let found = ".";
387
+ for (;;) {
388
+ visited.push(dir);
389
+ if (readPkg(dir)) {
390
+ found = dir;
391
+ break;
392
+ }
393
+ if (dir === ".")
394
+ break;
395
+ const parent = dirname(dir).replace(/\\/g, "/");
396
+ dir = parent === "" ? "." : parent;
397
+ }
398
+ for (const v of visited)
399
+ owningDirCache.set(v, found);
400
+ return found;
401
+ };
402
+ const explicit = config.scope.packages === "auto" ? null : config.scope.packages;
403
+ const explicitRes = explicit?.map((p) => ({ raw: p, re: globToRegExp(p) })) ?? null;
404
+ const excludeRes = config.scope.exclude.map((p) => ({ raw: p, re: globToRegExp(p) }));
405
+ const frontendDeps = new Set(config.scope.frontendDependencies);
406
+ const uiExt = /\.(?:tsx|jsx|vue|svelte|astro|mdx|css|scss|sass|less)$/i;
407
+ const dirsWithFiles = new Map();
408
+ for (const f of files) {
409
+ const d = owningDir(f);
410
+ let list = dirsWithFiles.get(d);
411
+ if (!list) {
412
+ list = [];
413
+ dirsWithFiles.set(d, list);
414
+ }
415
+ list.push(f);
416
+ }
417
+ const packages = [];
418
+ for (const [dir, dirFiles] of dirsWithFiles.entries()) {
419
+ const pkg = readPkg(dir);
420
+ const name = pkg?.name;
421
+ const matchesRef = (re, raw) => re.test(dir) || (name !== undefined && (name === raw || re.test(name)));
422
+ const excluded = excludeRes.find((e) => matchesRef(e.re, e.raw));
423
+ if (excluded) {
424
+ packages.push({ dir, name, frontend: false, reason: `excluded by scope.exclude (${excluded.raw})` });
425
+ continue;
426
+ }
427
+ if (explicitRes) {
428
+ const hit = explicitRes.find((e) => matchesRef(e.re, e.raw));
429
+ packages.push(hit
430
+ ? { dir, name, frontend: true, reason: `listed in scope.packages (${hit.raw})` }
431
+ : { dir, name, frontend: false, reason: "not listed in scope.packages" });
432
+ continue;
433
+ }
434
+ const deps = {
435
+ ...(pkg?.dependencies ?? {}),
436
+ ...(pkg?.devDependencies ?? {}),
437
+ ...(pkg?.peerDependencies ?? {}),
438
+ };
439
+ const matchedDep = Object.keys(deps).find((d) => frontendDeps.has(d));
440
+ if (matchedDep) {
441
+ packages.push({ dir, name, frontend: true, reason: `depends on ${matchedDep}` });
442
+ }
443
+ else if (!pkg && dirFiles.some((f) => uiExt.test(f))) {
444
+ packages.push({
445
+ dir,
446
+ name,
447
+ frontend: true,
448
+ reason: "no package.json; contains UI source files (tsx/jsx/css/…)",
449
+ });
450
+ }
451
+ else {
452
+ packages.push({
453
+ dir,
454
+ name,
455
+ frontend: false,
456
+ reason: pkg
457
+ ? "no UI framework dependency (backend / library package)"
458
+ : "no package.json and no UI source files",
459
+ });
460
+ }
461
+ }
462
+ packages.sort((a, b) => a.dir.localeCompare(b.dir));
463
+ const includedSet = new Set(packages.filter((p) => p.frontend).map((p) => p.dir));
464
+ return {
465
+ packages,
466
+ includedDirs: [...includedSet].sort(),
467
+ includeFile: (relPath) => includedSet.has(owningDir(relPath)),
468
+ };
469
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * packages/mcp/src/designSystem/contrast.ts
3
+ *
4
+ * WCAG 2.1 Color & Theme Contrast Engine (`dark` vs `light`, or single-theme `root`),
5
+ * discovering foreground/background pairs from config, CSS rules, naming conventions,
6
+ * and JSX Tailwind classes (with `@theme --text-*` font-size guard).
7
+ */
8
+ import { computeRelativeLuminance, computeWcagContrastRatio, parseCssColorString, type RgbaColor } from "./color.js";
9
+ import type { ParsedCssRule } from "./cssParser.js";
10
+ import type { ContrastAuditItem, ContrastUnresolvedItem, CssTokenDeclaration } from "./types.js";
11
+ export { computeRelativeLuminance, computeWcagContrastRatio, parseCssColorString, type RgbaColor, };
12
+ export declare const CANVAS_TOKEN_PROBES: string[];
13
+ export declare const VAR_EXPR_RE: RegExp;
14
+ /** Resolves `var(--x)` chains textually; returns `null` when a token has no value and no fallback. */
15
+ export declare function substituteVars(value: string, themeMap: Map<string, CssTokenDeclaration>, rootMap: Map<string, CssTokenDeclaration>, bridgeMap?: Map<string, CssTokenDeclaration>, depth?: number): string | null;
16
+ /** shadcn-style bare HSL triplets (`--background: 0 0% 100%`) are colors consumed as `hsl(var(--background))`. */
17
+ export declare function normalizeBareHsl(value: string): string;
18
+ type TokenColorResolution = {
19
+ ok: true;
20
+ color: RgbaColor;
21
+ } | {
22
+ ok: false;
23
+ reason: "undefined" | "unsupported";
24
+ detail?: string;
25
+ };
26
+ export declare const TW_ALPHA_RE: RegExp;
27
+ export declare function parseColorWithAlphaSyntax(value: string | null): RgbaColor | null;
28
+ export declare function resolveThemeTokenColor(tokenName: string, themeMap: Map<string, CssTokenDeclaration>, rootMap: Map<string, CssTokenDeclaration>, bridgeMap?: Map<string, CssTokenDeclaration>): TokenColorResolution;
29
+ export interface TailwindClassPairCandidate {
30
+ fgSlug: string;
31
+ bgSlug: string;
32
+ filePath?: string;
33
+ lineNumber?: number;
34
+ }
35
+ export interface ContrastEvaluationOptions {
36
+ pairs?: Array<{
37
+ fg: string;
38
+ bg: string;
39
+ label?: string;
40
+ minRatio?: number;
41
+ }>;
42
+ minRatio?: number;
43
+ discoverFromRules?: boolean;
44
+ discoverFromNaming?: boolean;
45
+ discoverFromTailwindClasses?: boolean;
46
+ tailwindClassPairs?: TailwindClassPairCandidate[];
47
+ canvasToken?: string;
48
+ }
49
+ export interface ContrastEvaluation {
50
+ audits: ContrastAuditItem[];
51
+ unresolved: ContrastUnresolvedItem[];
52
+ }
53
+ export declare function evaluateContrast(tokenDeclarations: CssTokenDeclaration[], styleRules: ParsedCssRule[], options?: ContrastEvaluationOptions): ContrastEvaluation;
54
+ /** Back-compat wrapper returning only evaluated audits. */
55
+ export declare function evaluateThemeContrastPairs(tokenDeclarations: CssTokenDeclaration[], styleRules: ParsedCssRule[], options?: ContrastEvaluationOptions): ContrastAuditItem[];