@zeroheight/mcp-server 2.0.0 → 2.1.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +12 -4
  3. package/dist/api/api.js +32 -6
  4. package/dist/api/api.js.map +1 -1
  5. package/dist/api/page.js +32 -6
  6. package/dist/api/page.js.map +1 -1
  7. package/dist/api/styleguide.js +6 -6
  8. package/dist/api/styleguide.js.map +1 -1
  9. package/dist/api/token.js +15 -0
  10. package/dist/api/token.js.map +1 -0
  11. package/dist/api/types/page.js +2 -2
  12. package/dist/api/types/page.js.map +1 -1
  13. package/dist/api/types/token.js +5 -0
  14. package/dist/api/types/token.js.map +1 -0
  15. package/dist/auth/introspection.js +36 -0
  16. package/dist/auth/introspection.js.map +1 -0
  17. package/dist/common/credentials.js +27 -8
  18. package/dist/common/credentials.js.map +1 -1
  19. package/dist/common/formatters/page.js +2 -2
  20. package/dist/common/formatters/page.js.map +1 -1
  21. package/dist/common/formatters/token.js +10 -0
  22. package/dist/common/formatters/token.js.map +1 -0
  23. package/dist/lint/color.js +43 -0
  24. package/dist/lint/color.js.map +1 -0
  25. package/dist/lint/dimension.js +90 -0
  26. package/dist/lint/dimension.js.map +1 -0
  27. package/dist/lint/index.js +122 -0
  28. package/dist/lint/index.js.map +1 -0
  29. package/dist/lint/parser.js +462 -0
  30. package/dist/lint/parser.js.map +1 -0
  31. package/dist/lint/tokens.js +33 -0
  32. package/dist/lint/tokens.js.map +1 -0
  33. package/dist/logging.js +129 -0
  34. package/dist/logging.js.map +1 -0
  35. package/dist/mcp-server.js +12 -6
  36. package/dist/mcp-server.js.map +1 -1
  37. package/dist/tools/lint.js +74 -0
  38. package/dist/tools/lint.js.map +1 -0
  39. package/dist/tools/page.js +111 -19
  40. package/dist/tools/page.js.map +1 -1
  41. package/dist/tools/styleguide.js +22 -11
  42. package/dist/tools/styleguide.js.map +1 -1
  43. package/dist/tools/token.js +73 -0
  44. package/dist/tools/token.js.map +1 -0
  45. package/dist/types/server.js +5 -0
  46. package/dist/types/server.js.map +1 -0
  47. package/package.json +11 -3
@@ -0,0 +1,462 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="67effa25-bb2b-5620-a751-4ab4b0157a76")}catch(e){}}();
3
+ import postcss from "postcss";
4
+ import postcssScss from "postcss-scss";
5
+ import valueParser from "postcss-value-parser";
6
+ import ts from "typescript";
7
+ import { all as knownCssProperties } from "known-css-properties";
8
+ function kebabToCamel(str) {
9
+ return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
10
+ }
11
+ function camelToKebab(str) {
12
+ return str.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
13
+ }
14
+ const CSS_STYLE_PROPERTIES = new Set(knownCssProperties.flatMap((prop) => [
15
+ prop, // kebab-case: "background-color"
16
+ kebabToCamel(prop), // camelCase: "backgroundColor"
17
+ ]));
18
+ function isCssPropertyName(name) {
19
+ return CSS_STYLE_PROPERTIES.has(name) || name.startsWith("--");
20
+ }
21
+ const PX_NUMERIC_PROPERTIES = new Set([
22
+ "padding",
23
+ "padding-top",
24
+ "padding-right",
25
+ "padding-bottom",
26
+ "padding-left",
27
+ "margin",
28
+ "margin-top",
29
+ "margin-right",
30
+ "margin-bottom",
31
+ "margin-left",
32
+ "gap",
33
+ "row-gap",
34
+ "column-gap",
35
+ "width",
36
+ "height",
37
+ "min-width",
38
+ "min-height",
39
+ "max-width",
40
+ "max-height",
41
+ "top",
42
+ "right",
43
+ "bottom",
44
+ "left",
45
+ "border-width",
46
+ "border-top-width",
47
+ "border-right-width",
48
+ "border-bottom-width",
49
+ "border-left-width",
50
+ "border-radius",
51
+ "border-top-left-radius",
52
+ "border-top-right-radius",
53
+ "border-bottom-left-radius",
54
+ "border-bottom-right-radius",
55
+ "outline-width",
56
+ "font-size",
57
+ "letter-spacing",
58
+ ]);
59
+ function isPxNumericProperty(name) {
60
+ if (name.startsWith("--"))
61
+ return false;
62
+ const normalized = name.includes("-")
63
+ ? name.toLowerCase()
64
+ : camelToKebab(name);
65
+ return PX_NUMERIC_PROPERTIES.has(normalized);
66
+ }
67
+ function isStyleVariableName(name) {
68
+ return /styles?$/i.test(name);
69
+ }
70
+ function isStyleJsxAttribute(node) {
71
+ return ts.isIdentifier(node.name) && node.name.text === "style";
72
+ }
73
+ function getPropertyName(name) {
74
+ if (ts.isIdentifier(name))
75
+ return name.text;
76
+ if (ts.isStringLiteral(name))
77
+ return name.text;
78
+ return undefined;
79
+ }
80
+ const COLOR_FUNCTIONS = new Set([
81
+ "rgb",
82
+ "rgba",
83
+ "hsl",
84
+ "hsla",
85
+ "hwb",
86
+ "lab",
87
+ "lch",
88
+ "oklch",
89
+ "oklab",
90
+ "color",
91
+ ]);
92
+ const HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
93
+ const CSS_UNITS = "px|rem|em|%|vw|vh|vmin|vmax|ch|ex|pt|pc|in|cm|mm";
94
+ const CSS_NAMED_COLORS = new Set([
95
+ "black",
96
+ "silver",
97
+ "gray",
98
+ "white",
99
+ "maroon",
100
+ "red",
101
+ "purple",
102
+ "fuchsia",
103
+ "green",
104
+ "lime",
105
+ "olive",
106
+ "yellow",
107
+ "navy",
108
+ "blue",
109
+ "teal",
110
+ "aqua",
111
+ "orange",
112
+ "aliceblue",
113
+ "antiquewhite",
114
+ "aquamarine",
115
+ "azure",
116
+ "beige",
117
+ "bisque",
118
+ "blanchedalmond",
119
+ "blueviolet",
120
+ "brown",
121
+ "burlywood",
122
+ "cadetblue",
123
+ "chartreuse",
124
+ "chocolate",
125
+ "coral",
126
+ "cornflowerblue",
127
+ "cornsilk",
128
+ "crimson",
129
+ "cyan",
130
+ "darkblue",
131
+ "darkcyan",
132
+ "darkgoldenrod",
133
+ "darkgray",
134
+ "darkgreen",
135
+ "darkgrey",
136
+ "darkkhaki",
137
+ "darkmagenta",
138
+ "darkolivegreen",
139
+ "darkorange",
140
+ "darkorchid",
141
+ "darkred",
142
+ "darksalmon",
143
+ "darkseagreen",
144
+ "darkslateblue",
145
+ "darkslategray",
146
+ "darkslategrey",
147
+ "darkturquoise",
148
+ "darkviolet",
149
+ "deeppink",
150
+ "deepskyblue",
151
+ "dimgray",
152
+ "dimgrey",
153
+ "dodgerblue",
154
+ "firebrick",
155
+ "floralwhite",
156
+ "forestgreen",
157
+ "gainsboro",
158
+ "ghostwhite",
159
+ "gold",
160
+ "goldenrod",
161
+ "greenyellow",
162
+ "grey",
163
+ "honeydew",
164
+ "hotpink",
165
+ "indianred",
166
+ "indigo",
167
+ "ivory",
168
+ "khaki",
169
+ "lavender",
170
+ "lavenderblush",
171
+ "lawngreen",
172
+ "lemonchiffon",
173
+ "lightblue",
174
+ "lightcoral",
175
+ "lightcyan",
176
+ "lightgoldenrodyellow",
177
+ "lightgray",
178
+ "lightgreen",
179
+ "lightgrey",
180
+ "lightpink",
181
+ "lightsalmon",
182
+ "lightseagreen",
183
+ "lightskyblue",
184
+ "lightslategray",
185
+ "lightslategrey",
186
+ "lightsteelblue",
187
+ "lightyellow",
188
+ "limegreen",
189
+ "linen",
190
+ "magenta",
191
+ "mediumaquamarine",
192
+ "mediumblue",
193
+ "mediumorchid",
194
+ "mediumpurple",
195
+ "mediumseagreen",
196
+ "mediumslateblue",
197
+ "mediumspringgreen",
198
+ "mediumturquoise",
199
+ "mediumvioletred",
200
+ "midnightblue",
201
+ "mintcream",
202
+ "mistyrose",
203
+ "moccasin",
204
+ "navajowhite",
205
+ "oldlace",
206
+ "olivedrab",
207
+ "orangered",
208
+ "orchid",
209
+ "palegoldenrod",
210
+ "palegreen",
211
+ "paleturquoise",
212
+ "palevioletred",
213
+ "papayawhip",
214
+ "peachpuff",
215
+ "peru",
216
+ "pink",
217
+ "plum",
218
+ "powderblue",
219
+ "rosybrown",
220
+ "royalblue",
221
+ "saddlebrown",
222
+ "salmon",
223
+ "sandybrown",
224
+ "seagreen",
225
+ "seashell",
226
+ "sienna",
227
+ "skyblue",
228
+ "slateblue",
229
+ "slategray",
230
+ "slategrey",
231
+ "snow",
232
+ "springgreen",
233
+ "steelblue",
234
+ "tan",
235
+ "thistle",
236
+ "tomato",
237
+ "turquoise",
238
+ "violet",
239
+ "wheat",
240
+ "whitesmoke",
241
+ "yellowgreen",
242
+ "rebeccapurple",
243
+ "transparent",
244
+ ]);
245
+ /**
246
+ * Parse a CSS string and extract colors and dimensions with positions.
247
+ */
248
+ export function parseCss(code, options = {}) {
249
+ const colors = [];
250
+ const dimensions = [];
251
+ try {
252
+ const root = options.syntax === "scss"
253
+ ? postcssScss.parse(code)
254
+ : postcss.parse(code);
255
+ root.walkDecls((decl) => {
256
+ const declSource = decl.source;
257
+ if (!declSource?.start)
258
+ return;
259
+ const propLength = decl.prop.length;
260
+ const betweenLength = decl.raws.between?.length ?? 1; // typically ": "
261
+ const valueStartOffset = propLength + betweenLength;
262
+ const parsed = valueParser(decl.value);
263
+ parsed.walk((node) => {
264
+ if (node.type === "function" &&
265
+ COLOR_FUNCTIONS.has(node.value.toLowerCase())) {
266
+ const fullValue = valueParser.stringify(node);
267
+ const match = createMatchFromNode(fullValue, node.sourceIndex, declSource.start.line, declSource.start.column + valueStartOffset);
268
+ colors.push(match);
269
+ return false; // Skip child nodes
270
+ }
271
+ if (node.type === "word" && HEX_COLOR_REGEX.test(node.value)) {
272
+ const match = createMatchFromNode(node.value, node.sourceIndex, declSource.start.line, declSource.start.column + valueStartOffset);
273
+ colors.push(match);
274
+ }
275
+ if (node.type === "word" &&
276
+ CSS_NAMED_COLORS.has(node.value.toLowerCase())) {
277
+ const match = createMatchFromNode(node.value, node.sourceIndex, declSource.start.line, declSource.start.column + valueStartOffset);
278
+ colors.push(match);
279
+ }
280
+ if (node.type === "word") {
281
+ const dimMatch = isDimension(node.value);
282
+ if (dimMatch) {
283
+ const match = createMatchFromNode(node.value, node.sourceIndex, declSource.start.line, declSource.start.column + valueStartOffset);
284
+ dimensions.push(match);
285
+ }
286
+ }
287
+ });
288
+ });
289
+ }
290
+ catch {
291
+ return { colors: [], dimensions: [] };
292
+ }
293
+ return { colors, dimensions };
294
+ }
295
+ /**
296
+ * Parse an SCSS string and extract colors and dimensions with positions.
297
+ */
298
+ export function parseScss(code) {
299
+ return parseCss(code, { syntax: "scss" });
300
+ }
301
+ function createMatchFromNode(value, sourceIndex, baseLine, baseColumn) {
302
+ const column = baseColumn + sourceIndex;
303
+ return {
304
+ value,
305
+ line: baseLine,
306
+ column,
307
+ endLine: baseLine,
308
+ endColumn: column + value.length,
309
+ };
310
+ }
311
+ const DIMENSION_VALUE_REGEX = new RegExp(`^(-?\\d+(?:\\.\\d+)?)(${CSS_UNITS})$`, "i");
312
+ function isDimension(value) {
313
+ return DIMENSION_VALUE_REGEX.test(value);
314
+ }
315
+ /**
316
+ * Parse a TSX/TS/JS/JSX string and extract colors and dimensions using TypeScript AST.
317
+ * Extracts values from JSX style props and style-named object literals.
318
+ */
319
+ function parseTsLike(code, scriptKind) {
320
+ const colors = [];
321
+ const dimensions = [];
322
+ let sourceFile;
323
+ try {
324
+ sourceFile = ts.createSourceFile("file.tsx", code, ts.ScriptTarget.Latest, true, scriptKind);
325
+ }
326
+ catch {
327
+ return { colors: [], dimensions: [] };
328
+ }
329
+ function visit(node) {
330
+ if (ts.isJsxAttribute(node) && isStyleJsxAttribute(node)) {
331
+ const initializer = node.initializer;
332
+ if (initializer && ts.isJsxExpression(initializer)) {
333
+ const expression = initializer.expression;
334
+ if (expression) {
335
+ extractFromExpression(expression, sourceFile, colors, dimensions);
336
+ }
337
+ }
338
+ }
339
+ if (ts.isVariableDeclaration(node) &&
340
+ node.initializer &&
341
+ ts.isIdentifier(node.name) &&
342
+ isStyleVariableName(node.name.text)) {
343
+ extractFromExpression(node.initializer, sourceFile, colors, dimensions);
344
+ }
345
+ ts.forEachChild(node, visit);
346
+ }
347
+ visit(sourceFile);
348
+ return { colors, dimensions };
349
+ }
350
+ export function parseTsx(code) {
351
+ return parseTsLike(code, ts.ScriptKind.TSX);
352
+ }
353
+ export function parseTs(code) {
354
+ return parseTsLike(code, ts.ScriptKind.TS);
355
+ }
356
+ export function parseJs(code) {
357
+ return parseTsLike(code, ts.ScriptKind.JS);
358
+ }
359
+ export function parseJsx(code) {
360
+ return parseTsLike(code, ts.ScriptKind.JSX);
361
+ }
362
+ function extractFromStyleObjectLiteral(node, sourceFile, colors, dimensions) {
363
+ for (const prop of node.properties) {
364
+ if (!ts.isPropertyAssignment(prop))
365
+ continue;
366
+ const propName = getPropertyName(prop.name);
367
+ const initializer = prop.initializer;
368
+ if (ts.isObjectLiteralExpression(initializer)) {
369
+ extractFromStyleObjectLiteral(initializer, sourceFile, colors, dimensions);
370
+ continue;
371
+ }
372
+ if (propName && isCssPropertyName(propName)) {
373
+ extractFromExpression(initializer, sourceFile, colors, dimensions, propName);
374
+ }
375
+ }
376
+ }
377
+ /**
378
+ * Extract colors and dimensions from an expression node.
379
+ * Handles string/template literals, numeric literals, object literals, and ternaries.
380
+ */
381
+ function extractFromExpression(node, sourceFile, colors, dimensions, propertyName) {
382
+ if (ts.isStringLiteral(node)) {
383
+ const value = node.text;
384
+ const startPos = node.getStart(sourceFile);
385
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(startPos);
386
+ // +1 for the opening quote, +1 for 1-based line/column
387
+ extractValuesFromString(value, line + 1, character + 2, colors, dimensions);
388
+ }
389
+ if (ts.isNoSubstitutionTemplateLiteral(node)) {
390
+ const { line, column } = getTemplateLiteralBasePosition(node, sourceFile);
391
+ extractValuesFromString(node.text, line, column, colors, dimensions);
392
+ }
393
+ if (ts.isTemplateExpression(node)) {
394
+ if (node.head.text) {
395
+ const { line, column } = getTemplateLiteralBasePosition(node.head, sourceFile);
396
+ extractValuesFromString(node.head.text, line, column, colors, dimensions);
397
+ }
398
+ for (const span of node.templateSpans) {
399
+ if (!span.literal.text)
400
+ continue;
401
+ const { line, column } = getTemplateLiteralBasePosition(span.literal, sourceFile);
402
+ extractValuesFromString(span.literal.text, line, column, colors, dimensions);
403
+ }
404
+ }
405
+ if (ts.isNumericLiteral(node) && propertyName && isPxNumericProperty(propertyName)) {
406
+ const startPos = node.getStart(sourceFile);
407
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(startPos);
408
+ const column = character + 1;
409
+ const value = `${node.text}px`;
410
+ dimensions.push({
411
+ value,
412
+ line: line + 1,
413
+ column,
414
+ endLine: line + 1,
415
+ endColumn: column + node.text.length,
416
+ });
417
+ }
418
+ if (ts.isObjectLiteralExpression(node)) {
419
+ extractFromStyleObjectLiteral(node, sourceFile, colors, dimensions);
420
+ }
421
+ if (ts.isConditionalExpression(node)) {
422
+ extractFromExpression(node.whenTrue, sourceFile, colors, dimensions, propertyName);
423
+ extractFromExpression(node.whenFalse, sourceFile, colors, dimensions, propertyName);
424
+ }
425
+ }
426
+ function getTemplateLiteralBasePosition(node, sourceFile) {
427
+ const startPos = node.getStart(sourceFile);
428
+ const nodeText = node.getText(sourceFile);
429
+ const rawText = node.text ?? "";
430
+ const offset = rawText ? nodeText.indexOf(rawText) : 0;
431
+ const pos = startPos + (offset >= 0 ? offset : 0);
432
+ const { line, character } = sourceFile.getLineAndCharacterOfPosition(pos);
433
+ return { line: line + 1, column: character + 1 };
434
+ }
435
+ /**
436
+ * Extract color and dimension values from a string value.
437
+ */
438
+ function extractValuesFromString(value, baseLine, baseColumn, colors, dimensions) {
439
+ const parsed = valueParser(value);
440
+ parsed.walk((node) => {
441
+ if (node.type === "function" && COLOR_FUNCTIONS.has(node.value.toLowerCase())) {
442
+ const fullValue = valueParser.stringify(node);
443
+ colors.push(createMatchFromNode(fullValue, node.sourceIndex, baseLine, baseColumn));
444
+ return false;
445
+ }
446
+ if (node.type !== "word")
447
+ return;
448
+ if (HEX_COLOR_REGEX.test(node.value)) {
449
+ colors.push(createMatchFromNode(node.value, node.sourceIndex, baseLine, baseColumn));
450
+ return;
451
+ }
452
+ if (CSS_NAMED_COLORS.has(node.value.toLowerCase())) {
453
+ colors.push(createMatchFromNode(node.value, node.sourceIndex, baseLine, baseColumn));
454
+ return;
455
+ }
456
+ if (isDimension(node.value)) {
457
+ dimensions.push(createMatchFromNode(node.value, node.sourceIndex, baseLine, baseColumn));
458
+ }
459
+ });
460
+ }
461
+ //# sourceMappingURL=parser.js.map
462
+ //# debugId=67effa25-bb2b-5620-a751-4ab4b0157a76
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sources":["lint/parser.ts"],"sourceRoot":"/","sourcesContent":["import postcss from \"postcss\";\nimport postcssScss from \"postcss-scss\";\nimport valueParser from \"postcss-value-parser\";\nimport ts from \"typescript\";\nimport { all as knownCssProperties } from \"known-css-properties\";\n\nfunction kebabToCamel(str: string): string {\n return str.replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n}\n\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n}\n\nconst CSS_STYLE_PROPERTIES = new Set<string>(\n knownCssProperties.flatMap((prop) => [\n prop, // kebab-case: \"background-color\"\n kebabToCamel(prop), // camelCase: \"backgroundColor\"\n ]),\n);\n\nfunction isCssPropertyName(name: string): boolean {\n return CSS_STYLE_PROPERTIES.has(name) || name.startsWith(\"--\");\n}\n\nconst PX_NUMERIC_PROPERTIES = new Set<string>([\n \"padding\",\n \"padding-top\",\n \"padding-right\",\n \"padding-bottom\",\n \"padding-left\",\n \"margin\",\n \"margin-top\",\n \"margin-right\",\n \"margin-bottom\",\n \"margin-left\",\n \"gap\",\n \"row-gap\",\n \"column-gap\",\n \"width\",\n \"height\",\n \"min-width\",\n \"min-height\",\n \"max-width\",\n \"max-height\",\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n \"border-width\",\n \"border-top-width\",\n \"border-right-width\",\n \"border-bottom-width\",\n \"border-left-width\",\n \"border-radius\",\n \"border-top-left-radius\",\n \"border-top-right-radius\",\n \"border-bottom-left-radius\",\n \"border-bottom-right-radius\",\n \"outline-width\",\n \"font-size\",\n \"letter-spacing\",\n]);\n\nfunction isPxNumericProperty(name: string): boolean {\n if (name.startsWith(\"--\")) return false;\n const normalized = name.includes(\"-\")\n ? name.toLowerCase()\n : camelToKebab(name);\n return PX_NUMERIC_PROPERTIES.has(normalized);\n}\n\nfunction isStyleVariableName(name: string): boolean {\n return /styles?$/i.test(name);\n}\n\nfunction isStyleJsxAttribute(node: ts.JsxAttribute): boolean {\n return ts.isIdentifier(node.name) && node.name.text === \"style\";\n}\n\nfunction getPropertyName(name: ts.PropertyName): string | undefined {\n if (ts.isIdentifier(name)) return name.text;\n if (ts.isStringLiteral(name)) return name.text;\n return undefined;\n}\n\n/**\n * Represents a matched value in source code with position information.\n */\nexport interface Match {\n value: string;\n line: number;\n column: number;\n endLine: number;\n endColumn: number;\n}\n\n/**\n * Result from parsing CSS/TSX code.\n */\nexport interface ParseResult {\n colors: Match[];\n dimensions: Match[];\n}\n\nconst COLOR_FUNCTIONS = new Set([\n \"rgb\",\n \"rgba\",\n \"hsl\",\n \"hsla\",\n \"hwb\",\n \"lab\",\n \"lch\",\n \"oklch\",\n \"oklab\",\n \"color\",\n]);\n\nconst HEX_COLOR_REGEX =\n /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;\n\nconst CSS_UNITS = \"px|rem|em|%|vw|vh|vmin|vmax|ch|ex|pt|pc|in|cm|mm\";\n\nconst CSS_NAMED_COLORS = new Set([\n \"black\",\n \"silver\",\n \"gray\",\n \"white\",\n \"maroon\",\n \"red\",\n \"purple\",\n \"fuchsia\",\n \"green\",\n \"lime\",\n \"olive\",\n \"yellow\",\n \"navy\",\n \"blue\",\n \"teal\",\n \"aqua\",\n \"orange\",\n \"aliceblue\",\n \"antiquewhite\",\n \"aquamarine\",\n \"azure\",\n \"beige\",\n \"bisque\",\n \"blanchedalmond\",\n \"blueviolet\",\n \"brown\",\n \"burlywood\",\n \"cadetblue\",\n \"chartreuse\",\n \"chocolate\",\n \"coral\",\n \"cornflowerblue\",\n \"cornsilk\",\n \"crimson\",\n \"cyan\",\n \"darkblue\",\n \"darkcyan\",\n \"darkgoldenrod\",\n \"darkgray\",\n \"darkgreen\",\n \"darkgrey\",\n \"darkkhaki\",\n \"darkmagenta\",\n \"darkolivegreen\",\n \"darkorange\",\n \"darkorchid\",\n \"darkred\",\n \"darksalmon\",\n \"darkseagreen\",\n \"darkslateblue\",\n \"darkslategray\",\n \"darkslategrey\",\n \"darkturquoise\",\n \"darkviolet\",\n \"deeppink\",\n \"deepskyblue\",\n \"dimgray\",\n \"dimgrey\",\n \"dodgerblue\",\n \"firebrick\",\n \"floralwhite\",\n \"forestgreen\",\n \"gainsboro\",\n \"ghostwhite\",\n \"gold\",\n \"goldenrod\",\n \"greenyellow\",\n \"grey\",\n \"honeydew\",\n \"hotpink\",\n \"indianred\",\n \"indigo\",\n \"ivory\",\n \"khaki\",\n \"lavender\",\n \"lavenderblush\",\n \"lawngreen\",\n \"lemonchiffon\",\n \"lightblue\",\n \"lightcoral\",\n \"lightcyan\",\n \"lightgoldenrodyellow\",\n \"lightgray\",\n \"lightgreen\",\n \"lightgrey\",\n \"lightpink\",\n \"lightsalmon\",\n \"lightseagreen\",\n \"lightskyblue\",\n \"lightslategray\",\n \"lightslategrey\",\n \"lightsteelblue\",\n \"lightyellow\",\n \"limegreen\",\n \"linen\",\n \"magenta\",\n \"mediumaquamarine\",\n \"mediumblue\",\n \"mediumorchid\",\n \"mediumpurple\",\n \"mediumseagreen\",\n \"mediumslateblue\",\n \"mediumspringgreen\",\n \"mediumturquoise\",\n \"mediumvioletred\",\n \"midnightblue\",\n \"mintcream\",\n \"mistyrose\",\n \"moccasin\",\n \"navajowhite\",\n \"oldlace\",\n \"olivedrab\",\n \"orangered\",\n \"orchid\",\n \"palegoldenrod\",\n \"palegreen\",\n \"paleturquoise\",\n \"palevioletred\",\n \"papayawhip\",\n \"peachpuff\",\n \"peru\",\n \"pink\",\n \"plum\",\n \"powderblue\",\n \"rosybrown\",\n \"royalblue\",\n \"saddlebrown\",\n \"salmon\",\n \"sandybrown\",\n \"seagreen\",\n \"seashell\",\n \"sienna\",\n \"skyblue\",\n \"slateblue\",\n \"slategray\",\n \"slategrey\",\n \"snow\",\n \"springgreen\",\n \"steelblue\",\n \"tan\",\n \"thistle\",\n \"tomato\",\n \"turquoise\",\n \"violet\",\n \"wheat\",\n \"whitesmoke\",\n \"yellowgreen\",\n \"rebeccapurple\",\n \"transparent\",\n]);\n\ninterface ParseCssOptions {\n syntax?: \"css\" | \"scss\";\n}\n\n/**\n * Parse a CSS string and extract colors and dimensions with positions.\n */\nexport function parseCss(\n code: string,\n options: ParseCssOptions = {},\n): ParseResult {\n const colors: Match[] = [];\n const dimensions: Match[] = [];\n\n try {\n const root =\n options.syntax === \"scss\"\n ? postcssScss.parse(code)\n : postcss.parse(code);\n\n root.walkDecls((decl) => {\n const declSource = decl.source;\n if (!declSource?.start) return;\n\n const propLength = decl.prop.length;\n const betweenLength = decl.raws.between?.length ?? 1; // typically \": \"\n const valueStartOffset = propLength + betweenLength;\n\n const parsed = valueParser(decl.value);\n\n parsed.walk((node) => {\n if (\n node.type === \"function\" &&\n COLOR_FUNCTIONS.has(node.value.toLowerCase())\n ) {\n const fullValue = valueParser.stringify(node);\n const match = createMatchFromNode(\n fullValue,\n node.sourceIndex,\n declSource.start!.line,\n declSource.start!.column + valueStartOffset,\n );\n colors.push(match);\n return false; // Skip child nodes\n }\n\n if (node.type === \"word\" && HEX_COLOR_REGEX.test(node.value)) {\n const match = createMatchFromNode(\n node.value,\n node.sourceIndex,\n declSource.start!.line,\n declSource.start!.column + valueStartOffset,\n );\n colors.push(match);\n }\n\n if (\n node.type === \"word\" &&\n CSS_NAMED_COLORS.has(node.value.toLowerCase())\n ) {\n const match = createMatchFromNode(\n node.value,\n node.sourceIndex,\n declSource.start!.line,\n declSource.start!.column + valueStartOffset,\n );\n colors.push(match);\n }\n\n if (node.type === \"word\") {\n const dimMatch = isDimension(node.value);\n if (dimMatch) {\n const match = createMatchFromNode(\n node.value,\n node.sourceIndex,\n declSource.start!.line,\n declSource.start!.column + valueStartOffset,\n );\n dimensions.push(match);\n }\n }\n });\n });\n } catch {\n return { colors: [], dimensions: [] };\n }\n\n return { colors, dimensions };\n}\n\n/**\n * Parse an SCSS string and extract colors and dimensions with positions.\n */\nexport function parseScss(code: string): ParseResult {\n return parseCss(code, { syntax: \"scss\" });\n}\n\nfunction createMatchFromNode(\n value: string,\n sourceIndex: number,\n baseLine: number,\n baseColumn: number,\n): Match {\n const column = baseColumn + sourceIndex;\n\n return {\n value,\n line: baseLine,\n column,\n endLine: baseLine,\n endColumn: column + value.length,\n };\n}\n\nconst DIMENSION_VALUE_REGEX = new RegExp(\n `^(-?\\\\d+(?:\\\\.\\\\d+)?)(${CSS_UNITS})$`,\n \"i\",\n);\n\nfunction isDimension(value: string): boolean {\n return DIMENSION_VALUE_REGEX.test(value);\n}\n\n/**\n * Parse a TSX/TS/JS/JSX string and extract colors and dimensions using TypeScript AST.\n * Extracts values from JSX style props and style-named object literals.\n */\nfunction parseTsLike(code: string, scriptKind: ts.ScriptKind): ParseResult {\n const colors: Match[] = [];\n const dimensions: Match[] = [];\n\n let sourceFile: ts.SourceFile;\n try {\n sourceFile = ts.createSourceFile(\n \"file.tsx\",\n code,\n ts.ScriptTarget.Latest,\n true,\n scriptKind,\n );\n } catch {\n return { colors: [], dimensions: [] };\n }\n\n function visit(node: ts.Node) {\n if (ts.isJsxAttribute(node) && isStyleJsxAttribute(node)) {\n const initializer = node.initializer;\n if (initializer && ts.isJsxExpression(initializer)) {\n const expression = initializer.expression;\n if (expression) {\n extractFromExpression(expression, sourceFile, colors, dimensions);\n }\n }\n }\n\n if (\n ts.isVariableDeclaration(node) &&\n node.initializer &&\n ts.isIdentifier(node.name) &&\n isStyleVariableName(node.name.text)\n ) {\n extractFromExpression(node.initializer, sourceFile, colors, dimensions);\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return { colors, dimensions };\n}\n\nexport function parseTsx(code: string): ParseResult {\n return parseTsLike(code, ts.ScriptKind.TSX);\n}\n\nexport function parseTs(code: string): ParseResult {\n return parseTsLike(code, ts.ScriptKind.TS);\n}\n\nexport function parseJs(code: string): ParseResult {\n return parseTsLike(code, ts.ScriptKind.JS);\n}\n\nexport function parseJsx(code: string): ParseResult {\n return parseTsLike(code, ts.ScriptKind.JSX);\n}\n\nfunction extractFromStyleObjectLiteral(\n node: ts.ObjectLiteralExpression,\n sourceFile: ts.SourceFile,\n colors: Match[],\n dimensions: Match[],\n): void {\n for (const prop of node.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n\n const propName = getPropertyName(prop.name);\n const initializer = prop.initializer;\n\n if (ts.isObjectLiteralExpression(initializer)) {\n extractFromStyleObjectLiteral(initializer, sourceFile, colors, dimensions);\n continue;\n }\n\n if (propName && isCssPropertyName(propName)) {\n extractFromExpression(\n initializer,\n sourceFile,\n colors,\n dimensions,\n propName,\n );\n }\n }\n}\n\n/**\n * Extract colors and dimensions from an expression node.\n * Handles string/template literals, numeric literals, object literals, and ternaries.\n */\nfunction extractFromExpression(\n node: ts.Node,\n sourceFile: ts.SourceFile,\n colors: Match[],\n dimensions: Match[],\n propertyName?: string,\n): void {\n if (ts.isStringLiteral(node)) {\n const value = node.text;\n const startPos = node.getStart(sourceFile);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(startPos);\n // +1 for the opening quote, +1 for 1-based line/column\n extractValuesFromString(value, line + 1, character + 2, colors, dimensions);\n }\n\n if (ts.isNoSubstitutionTemplateLiteral(node)) {\n const { line, column } = getTemplateLiteralBasePosition(node, sourceFile);\n extractValuesFromString(node.text, line, column, colors, dimensions);\n }\n\n if (ts.isTemplateExpression(node)) {\n if (node.head.text) {\n const { line, column } = getTemplateLiteralBasePosition(\n node.head,\n sourceFile,\n );\n extractValuesFromString(node.head.text, line, column, colors, dimensions);\n }\n\n for (const span of node.templateSpans) {\n if (!span.literal.text) continue;\n const { line, column } = getTemplateLiteralBasePosition(\n span.literal,\n sourceFile,\n );\n extractValuesFromString(\n span.literal.text,\n line,\n column,\n colors,\n dimensions,\n );\n }\n }\n\n if (ts.isNumericLiteral(node) && propertyName && isPxNumericProperty(propertyName)) {\n const startPos = node.getStart(sourceFile);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(startPos);\n const column = character + 1;\n const value = `${node.text}px`;\n dimensions.push({\n value,\n line: line + 1,\n column,\n endLine: line + 1,\n endColumn: column + node.text.length,\n });\n }\n\n if (ts.isObjectLiteralExpression(node)) {\n extractFromStyleObjectLiteral(node, sourceFile, colors, dimensions);\n }\n\n if (ts.isConditionalExpression(node)) {\n extractFromExpression(\n node.whenTrue,\n sourceFile,\n colors,\n dimensions,\n propertyName,\n );\n extractFromExpression(\n node.whenFalse,\n sourceFile,\n colors,\n dimensions,\n propertyName,\n );\n }\n}\n\nfunction getTemplateLiteralBasePosition(\n node: ts.TemplateLiteralLikeNode,\n sourceFile: ts.SourceFile,\n): { line: number; column: number } {\n const startPos = node.getStart(sourceFile);\n const nodeText = node.getText(sourceFile);\n const rawText = node.text ?? \"\";\n const offset = rawText ? nodeText.indexOf(rawText) : 0;\n const pos = startPos + (offset >= 0 ? offset : 0);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(pos);\n return { line: line + 1, column: character + 1 };\n}\n\n/**\n * Extract color and dimension values from a string value.\n */\nfunction extractValuesFromString(\n value: string,\n baseLine: number,\n baseColumn: number,\n colors: Match[],\n dimensions: Match[],\n): void {\n const parsed = valueParser(value);\n\n parsed.walk((node) => {\n if (node.type === \"function\" && COLOR_FUNCTIONS.has(node.value.toLowerCase())) {\n const fullValue = valueParser.stringify(node);\n colors.push(\n createMatchFromNode(fullValue, node.sourceIndex, baseLine, baseColumn),\n );\n return false;\n }\n\n if (node.type !== \"word\") return;\n\n if (HEX_COLOR_REGEX.test(node.value)) {\n colors.push(\n createMatchFromNode(node.value, node.sourceIndex, baseLine, baseColumn),\n );\n return;\n }\n\n if (CSS_NAMED_COLORS.has(node.value.toLowerCase())) {\n colors.push(\n createMatchFromNode(node.value, node.sourceIndex, baseLine, baseColumn),\n );\n return;\n }\n\n if (isDimension(node.value)) {\n dimensions.push(\n createMatchFromNode(node.value, node.sourceIndex, baseLine, baseColumn),\n );\n }\n });\n}\n"],"names":[],"mappings":";;AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,GAAG,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAClC,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACnC,IAAI,EAAE,iCAAiC;IACvC,YAAY,CAAC,IAAI,CAAC,EAAE,+BAA+B;CACpD,CAAC,CACH,CAAC;AAEF,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,I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b2b-5620-a751-4ab4b0157a76"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Flatten a TokenGroup into a flat map of tokens of a specific type.
3
+ * Handles nested groups and inherited $type.
4
+ */
5
+
6
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cd8b54fd-b500-53e7-ab2e-4d5de99a8463")}catch(e){}}();
7
+ export function flattenTokensByType(tokens, type, prefix = "", inheritedType) {
8
+ const result = new Map();
9
+ const groupType = tokens.$type ?? inheritedType;
10
+ for (const [key, value] of Object.entries(tokens)) {
11
+ if (key.startsWith("$"))
12
+ continue;
13
+ const fullName = prefix ? `${prefix}.${key}` : key;
14
+ if (value && typeof value === "object" && "$value" in value) {
15
+ // It's a TokenValue
16
+ const tokenValue = value;
17
+ const tokenType = tokenValue.$type ?? groupType;
18
+ if (tokenType === type && typeof tokenValue.$value === "string") {
19
+ result.set(fullName, tokenValue.$value);
20
+ }
21
+ }
22
+ else if (value && typeof value === "object") {
23
+ // It's a nested TokenGroup
24
+ const nested = flattenTokensByType(value, type, fullName, groupType);
25
+ for (const [k, v] of nested) {
26
+ result.set(k, v);
27
+ }
28
+ }
29
+ }
30
+ return result;
31
+ }
32
+ //# sourceMappingURL=tokens.js.map
33
+ //# debugId=cd8b54fd-b500-53e7-ab2e-4d5de99a8463
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sources":["lint/tokens.ts"],"sourceRoot":"/","sourcesContent":["import type { TokenGroup, TokenValue } from \"../api/types/token.js\";\n\n/**\n * Flatten a TokenGroup into a flat map of tokens of a specific type.\n * Handles nested groups and inherited $type.\n */\nexport function flattenTokensByType(\n tokens: TokenGroup,\n type: string,\n prefix: string = \"\",\n inheritedType?: string,\n): Map<string, string> {\n const result = new Map<string, string>();\n const groupType = tokens.$type ?? inheritedType;\n\n for (const [key, value] of Object.entries(tokens)) {\n if (key.startsWith(\"$\")) continue;\n\n const fullName = prefix ? `${prefix}.${key}` : key;\n\n if (value && typeof value === \"object\" && \"$value\" in value) {\n // It's a TokenValue\n const tokenValue = value as TokenValue;\n const tokenType = tokenValue.$type ?? groupType;\n if (tokenType === type && typeof tokenValue.$value === \"string\") {\n result.set(fullName, tokenValue.$value);\n }\n } else if (value && typeof value === \"object\") {\n // It's a nested TokenGroup\n const nested = flattenTokensByType(\n value as TokenGroup,\n type,\n fullName,\n groupType,\n );\n for (const [k, v] of nested) {\n result.set(k, v);\n }\n }\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAEA;;;GAGG;;;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAkB,EAClB,IAAY,EACZ,SAAiB,EAAE,EACnB,aAAsB;IAEtB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,IAAI,aAAa,CAAC;IAEhD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAElC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAEnD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;YAC5D,oBAAoB;YACpB,MAAM,UAAU,GAAG,KAAmB,CAAC;YACvC,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,IAAI,SAAS,CAAC;YAChD,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAChE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,MA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