@nysds/mcp-server 1.0.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/lib/cem-parser.d.ts +96 -0
- package/dist/lib/cem-parser.d.ts.map +1 -0
- package/dist/lib/cem-parser.js +82 -0
- package/dist/lib/search.d.ts +20 -0
- package/dist/lib/search.d.ts.map +1 -0
- package/dist/lib/search.js +87 -0
- package/dist/lib/token-parser.d.ts +140 -0
- package/dist/lib/token-parser.d.ts.map +1 -0
- package/dist/lib/token-parser.js +458 -0
- package/dist/prompts/nysds-mode.d.ts +8 -0
- package/dist/prompts/nysds-mode.d.ts.map +1 -0
- package/dist/prompts/nysds-mode.js +51 -0
- package/dist/resources/components.d.ts +12 -0
- package/dist/resources/components.d.ts.map +1 -0
- package/dist/resources/components.js +62 -0
- package/dist/resources/guides.d.ts +11 -0
- package/dist/resources/guides.d.ts.map +1 -0
- package/dist/resources/guides.js +80 -0
- package/dist/resources/index.d.ts +8 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +13 -0
- package/dist/resources/tokens.d.ts +17 -0
- package/dist/resources/tokens.d.ts.map +1 -0
- package/dist/resources/tokens.js +312 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +30 -0
- package/dist/tools/component-tools.d.ts +14 -0
- package/dist/tools/component-tools.d.ts.map +1 -0
- package/dist/tools/component-tools.js +127 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +13 -0
- package/dist/tools/token-tools.d.ts +17 -0
- package/dist/tools/token-tools.d.ts.map +1 -0
- package/dist/tools/token-tools.js +504 -0
- package/dist/tools/validation-tools.d.ts +12 -0
- package/dist/tools/validation-tools.d.ts.map +1 -0
- package/dist/tools/validation-tools.js +222 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* NYSDS MCP Server Entry Point
|
|
4
|
+
*
|
|
5
|
+
* Starts the MCP server with stdio transport for local execution.
|
|
6
|
+
* Run via: npx @nysds/mcp-server
|
|
7
|
+
*/
|
|
8
|
+
import { createServer } from "./server.js";
|
|
9
|
+
async function main() {
|
|
10
|
+
const server = await createServer();
|
|
11
|
+
await server.start();
|
|
12
|
+
}
|
|
13
|
+
main().catch((error) => {
|
|
14
|
+
console.error("Failed to start NYSDS MCP server:", error);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Elements Manifest Parser
|
|
3
|
+
*
|
|
4
|
+
* Reads and parses the custom-elements.json manifest from @nysds/components.
|
|
5
|
+
*/
|
|
6
|
+
export interface CEMAttribute {
|
|
7
|
+
name: string;
|
|
8
|
+
type?: {
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
11
|
+
default?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
fieldName?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CEMMember {
|
|
16
|
+
kind: "field" | "method";
|
|
17
|
+
name: string;
|
|
18
|
+
type?: {
|
|
19
|
+
text: string;
|
|
20
|
+
};
|
|
21
|
+
default?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
privacy?: "public" | "private" | "protected";
|
|
24
|
+
attribute?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CEMEvent {
|
|
27
|
+
name: string;
|
|
28
|
+
type?: {
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
description?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CEMSlot {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface CEMCssProperty {
|
|
38
|
+
name: string;
|
|
39
|
+
default?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface CEMCssPart {
|
|
43
|
+
name: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface CEMDeclaration {
|
|
47
|
+
kind: "class";
|
|
48
|
+
name: string;
|
|
49
|
+
tagName?: string;
|
|
50
|
+
summary?: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
attributes?: CEMAttribute[];
|
|
53
|
+
members?: CEMMember[];
|
|
54
|
+
events?: CEMEvent[];
|
|
55
|
+
slots?: CEMSlot[];
|
|
56
|
+
cssProperties?: CEMCssProperty[];
|
|
57
|
+
cssParts?: CEMCssPart[];
|
|
58
|
+
superclass?: {
|
|
59
|
+
name: string;
|
|
60
|
+
package?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface CEMModule {
|
|
64
|
+
kind: "javascript-module";
|
|
65
|
+
path: string;
|
|
66
|
+
declarations?: CEMDeclaration[];
|
|
67
|
+
exports?: Array<{
|
|
68
|
+
kind: string;
|
|
69
|
+
name: string;
|
|
70
|
+
declaration: {
|
|
71
|
+
name: string;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
export interface CustomElementsManifest {
|
|
76
|
+
schemaVersion: string;
|
|
77
|
+
readme?: string;
|
|
78
|
+
modules: CEMModule[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Load and parse the Custom Elements Manifest
|
|
82
|
+
*/
|
|
83
|
+
export declare function getCEM(): CustomElementsManifest;
|
|
84
|
+
/**
|
|
85
|
+
* Get all component declarations from the manifest
|
|
86
|
+
*/
|
|
87
|
+
export declare function getAllComponents(): CEMDeclaration[];
|
|
88
|
+
/**
|
|
89
|
+
* Get a specific component by tag name
|
|
90
|
+
*/
|
|
91
|
+
export declare function getComponent(tagName: string): CEMDeclaration | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Clear the cached CEM (useful for testing)
|
|
94
|
+
*/
|
|
95
|
+
export declare function clearCache(): void;
|
|
96
|
+
//# sourceMappingURL=cem-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cem-parser.d.ts","sourceRoot":"","sources":["../../src/lib/cem-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,C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B,gBAAgB,IAAI,cAAc,EAAE,CAiBnD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAKxE;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Elements Manifest Parser
|
|
3
|
+
*
|
|
4
|
+
* Reads and parses the custom-elements.json manifest from @nysds/components.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
7
|
+
import { resolve, dirname } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
let cachedCEM = null;
|
|
11
|
+
/**
|
|
12
|
+
* Get the path to the custom-elements.json file
|
|
13
|
+
*/
|
|
14
|
+
function getCEMPath() {
|
|
15
|
+
// Try multiple locations
|
|
16
|
+
const possiblePaths = [
|
|
17
|
+
// Relative to the package (when installed as dependency)
|
|
18
|
+
resolve(__dirname, "../../../node_modules/@nysds/components/dist/custom-elements.json"),
|
|
19
|
+
// Relative to monorepo root (during development)
|
|
20
|
+
resolve(__dirname, "../../../../dist/custom-elements.json"),
|
|
21
|
+
// Direct path for testing
|
|
22
|
+
resolve(process.cwd(), "dist/custom-elements.json"),
|
|
23
|
+
];
|
|
24
|
+
for (const path of possiblePaths) {
|
|
25
|
+
if (existsSync(path)) {
|
|
26
|
+
return path;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`custom-elements.json not found. Searched paths:\n${possiblePaths.join("\n")}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Load and parse the Custom Elements Manifest
|
|
33
|
+
*/
|
|
34
|
+
export function getCEM() {
|
|
35
|
+
if (cachedCEM) {
|
|
36
|
+
return cachedCEM;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const cemPath = getCEMPath();
|
|
40
|
+
const content = readFileSync(cemPath, "utf-8");
|
|
41
|
+
cachedCEM = JSON.parse(content);
|
|
42
|
+
return cachedCEM;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
// Return empty manifest if file not found (for development/testing)
|
|
46
|
+
console.error("Warning: Could not load custom-elements.json:", error);
|
|
47
|
+
return {
|
|
48
|
+
schemaVersion: "1.0.0",
|
|
49
|
+
modules: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get all component declarations from the manifest
|
|
55
|
+
*/
|
|
56
|
+
export function getAllComponents() {
|
|
57
|
+
const cem = getCEM();
|
|
58
|
+
const components = [];
|
|
59
|
+
for (const module of cem.modules) {
|
|
60
|
+
if (module.declarations) {
|
|
61
|
+
for (const declaration of module.declarations) {
|
|
62
|
+
if (declaration.kind === "class" && declaration.tagName) {
|
|
63
|
+
components.push(declaration);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return components.sort((a, b) => (a.tagName || "").localeCompare(b.tagName || ""));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get a specific component by tag name
|
|
72
|
+
*/
|
|
73
|
+
export function getComponent(tagName) {
|
|
74
|
+
const components = getAllComponents();
|
|
75
|
+
return components.find((c) => c.tagName?.toLowerCase() === tagName.toLowerCase());
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Clear the cached CEM (useful for testing)
|
|
79
|
+
*/
|
|
80
|
+
export function clearCache() {
|
|
81
|
+
cachedCEM = null;
|
|
82
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Utilities
|
|
3
|
+
*
|
|
4
|
+
* Fuzzy search functionality for components and tokens.
|
|
5
|
+
*/
|
|
6
|
+
export interface SearchResult {
|
|
7
|
+
tagName: string;
|
|
8
|
+
name: string;
|
|
9
|
+
summary: string;
|
|
10
|
+
score: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Search components by name or description
|
|
14
|
+
*/
|
|
15
|
+
export declare function searchComponents(query: string): SearchResult[];
|
|
16
|
+
/**
|
|
17
|
+
* Check if a string matches a search query
|
|
18
|
+
*/
|
|
19
|
+
export declare function matchesQuery(text: string, query: string): boolean;
|
|
20
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/lib/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAsDD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CA8B9D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Utilities
|
|
3
|
+
*
|
|
4
|
+
* Fuzzy search functionality for components and tokens.
|
|
5
|
+
*/
|
|
6
|
+
import { getAllComponents } from "./cem-parser.js";
|
|
7
|
+
/**
|
|
8
|
+
* Simple fuzzy matching score
|
|
9
|
+
* Returns a score between 0 and 1, where 1 is an exact match
|
|
10
|
+
*/
|
|
11
|
+
function fuzzyScore(query, text) {
|
|
12
|
+
const lowerQuery = query.toLowerCase();
|
|
13
|
+
const lowerText = text.toLowerCase();
|
|
14
|
+
// Exact match
|
|
15
|
+
if (lowerText === lowerQuery)
|
|
16
|
+
return 1;
|
|
17
|
+
// Contains exact query
|
|
18
|
+
if (lowerText.includes(lowerQuery)) {
|
|
19
|
+
// Bonus for matching at word boundaries
|
|
20
|
+
const wordBoundary = new RegExp(`\\b${escapeRegex(lowerQuery)}`, "i");
|
|
21
|
+
if (wordBoundary.test(lowerText)) {
|
|
22
|
+
return 0.9;
|
|
23
|
+
}
|
|
24
|
+
return 0.7;
|
|
25
|
+
}
|
|
26
|
+
// Character-by-character fuzzy match
|
|
27
|
+
let queryIndex = 0;
|
|
28
|
+
let score = 0;
|
|
29
|
+
let consecutiveBonus = 0;
|
|
30
|
+
for (let i = 0; i < lowerText.length && queryIndex < lowerQuery.length; i++) {
|
|
31
|
+
if (lowerText[i] === lowerQuery[queryIndex]) {
|
|
32
|
+
score += 1 + consecutiveBonus * 0.5;
|
|
33
|
+
consecutiveBonus++;
|
|
34
|
+
queryIndex++;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
consecutiveBonus = 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Did we match all query characters?
|
|
41
|
+
if (queryIndex < lowerQuery.length) {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
// Normalize score
|
|
45
|
+
return Math.min(score / (lowerQuery.length * 2), 0.6);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Escape special regex characters
|
|
49
|
+
*/
|
|
50
|
+
function escapeRegex(str) {
|
|
51
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Search components by name or description
|
|
55
|
+
*/
|
|
56
|
+
export function searchComponents(query) {
|
|
57
|
+
const components = getAllComponents();
|
|
58
|
+
const results = [];
|
|
59
|
+
for (const component of components) {
|
|
60
|
+
const tagName = component.tagName || "";
|
|
61
|
+
const name = component.name || "";
|
|
62
|
+
const description = component.description || "";
|
|
63
|
+
const summary = component.summary || description.split("\n")[0] || "";
|
|
64
|
+
// Calculate scores for different fields
|
|
65
|
+
const tagScore = fuzzyScore(query, tagName) * 1.2; // Boost tag matches
|
|
66
|
+
const nameScore = fuzzyScore(query, name) * 1.1;
|
|
67
|
+
const summaryScore = fuzzyScore(query, summary);
|
|
68
|
+
const descScore = fuzzyScore(query, description) * 0.8;
|
|
69
|
+
const maxScore = Math.max(tagScore, nameScore, summaryScore, descScore);
|
|
70
|
+
if (maxScore > 0) {
|
|
71
|
+
results.push({
|
|
72
|
+
tagName,
|
|
73
|
+
name,
|
|
74
|
+
summary,
|
|
75
|
+
score: maxScore,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Sort by score descending
|
|
80
|
+
return results.sort((a, b) => b.score - a.score);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if a string matches a search query
|
|
84
|
+
*/
|
|
85
|
+
export function matchesQuery(text, query) {
|
|
86
|
+
return fuzzyScore(query, text) > 0;
|
|
87
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design Token Parser
|
|
3
|
+
*
|
|
4
|
+
* Reads and parses NYSDS design tokens with a CSS-centric approach.
|
|
5
|
+
* Returns data aligned with tokens.css output (not JSON internals).
|
|
6
|
+
*
|
|
7
|
+
* Key transformations:
|
|
8
|
+
* - Token paths are converted to CSS variable names
|
|
9
|
+
* - Alias references become var() expressions
|
|
10
|
+
* - Layer prefixes (primitive, applied) are stripped
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Legacy interface for backward compatibility
|
|
14
|
+
*/
|
|
15
|
+
export interface DesignToken {
|
|
16
|
+
name: string;
|
|
17
|
+
value: string;
|
|
18
|
+
category: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* CSS-centric token info aligned with tokens.css output
|
|
23
|
+
*/
|
|
24
|
+
export interface CSSTokenInfo {
|
|
25
|
+
/** CSS variable name, e.g., "--nys-color-text" */
|
|
26
|
+
cssVariable: string;
|
|
27
|
+
/** CSS value as it appears in tokens.css, e.g., "var(--nys-color-neutral-900)" or "#1b1b1b" */
|
|
28
|
+
cssValue: string;
|
|
29
|
+
/** If this is an alias, the variable it references, e.g., "--nys-color-neutral-900" */
|
|
30
|
+
referencesVariable?: string;
|
|
31
|
+
/** Fully resolved value for previews, e.g., "#1b1b1b" */
|
|
32
|
+
resolvedValue?: string;
|
|
33
|
+
/** Token description from $description field */
|
|
34
|
+
description?: string;
|
|
35
|
+
/** Token category (color, font, space, etc.) */
|
|
36
|
+
category: string;
|
|
37
|
+
/** Token layer (primitive, applied, color, etc.) */
|
|
38
|
+
layer: string;
|
|
39
|
+
/** Original JSON path for debugging */
|
|
40
|
+
jsonPath: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Token dependency graph node
|
|
44
|
+
*/
|
|
45
|
+
export interface TokenGraphNode {
|
|
46
|
+
cssVariable: string;
|
|
47
|
+
referencesVariable?: string;
|
|
48
|
+
usedBy: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface TokenGroup {
|
|
51
|
+
category: string;
|
|
52
|
+
tokens: DesignToken[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the path to tokens.json file
|
|
56
|
+
* Uses ESM-compatible path resolution with fallbacks for different contexts
|
|
57
|
+
*/
|
|
58
|
+
export declare function getTokensPath(): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Get the path to tokens.css file
|
|
61
|
+
*/
|
|
62
|
+
export declare function getTokensCSSPath(): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Transform a JSON token path to CSS variable name
|
|
65
|
+
*
|
|
66
|
+
* Examples:
|
|
67
|
+
* - "primitive.color.neutral.900" → "--nys-color-neutral-900"
|
|
68
|
+
* - "applied.color.text.default" → "--nys-color-text"
|
|
69
|
+
* - "color.theme.default" → "--nys-color-theme"
|
|
70
|
+
* - "font.size.md" → "--nys-font-size-md"
|
|
71
|
+
*/
|
|
72
|
+
export declare function toCSSVariable(jsonPath: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Convert an alias reference to CSS var() syntax
|
|
75
|
+
*
|
|
76
|
+
* Examples:
|
|
77
|
+
* - "{primitive.color.neutral.900}" → "var(--nys-color-neutral-900)"
|
|
78
|
+
* - "{font.size.md}" → "var(--nys-font-size-md)"
|
|
79
|
+
*/
|
|
80
|
+
export declare function aliasToVarRef(aliasValue: string): {
|
|
81
|
+
cssValue: string;
|
|
82
|
+
referencesVariable: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Build a dependency graph of tokens
|
|
86
|
+
* Shows which tokens reference which, and which tokens are used by which
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildTokenGraph(): Map<string, TokenGraphNode>;
|
|
89
|
+
/**
|
|
90
|
+
* Get all tokens in CSS-centric format
|
|
91
|
+
*/
|
|
92
|
+
export declare function getCSSTokens(): CSSTokenInfo[];
|
|
93
|
+
/**
|
|
94
|
+
* Get CSS tokens filtered by category
|
|
95
|
+
*/
|
|
96
|
+
export declare function getCSSTokensByCategory(category: string): CSSTokenInfo[];
|
|
97
|
+
/**
|
|
98
|
+
* Get CSS tokens filtered by layer
|
|
99
|
+
*/
|
|
100
|
+
export declare function getCSSTokensByLayer(layer: string): CSSTokenInfo[];
|
|
101
|
+
/**
|
|
102
|
+
* Search CSS tokens by variable name, value, or description
|
|
103
|
+
*/
|
|
104
|
+
export declare function searchCSSTokens(query: string): CSSTokenInfo[];
|
|
105
|
+
/**
|
|
106
|
+
* Get a single token by CSS variable name
|
|
107
|
+
*/
|
|
108
|
+
export declare function getCSSTokenByVariable(variableName: string): CSSTokenInfo | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Get all unique categories
|
|
111
|
+
*/
|
|
112
|
+
export declare function getCSSTokenCategories(): {
|
|
113
|
+
category: string;
|
|
114
|
+
count: number;
|
|
115
|
+
}[];
|
|
116
|
+
/**
|
|
117
|
+
* Get raw tokens.css content
|
|
118
|
+
*/
|
|
119
|
+
export declare function getTokensCSS(): string | null;
|
|
120
|
+
/**
|
|
121
|
+
* Load all design tokens (legacy format)
|
|
122
|
+
*/
|
|
123
|
+
export declare function getAllTokens(): DesignToken[];
|
|
124
|
+
/**
|
|
125
|
+
* Get tokens filtered by category (legacy format)
|
|
126
|
+
*/
|
|
127
|
+
export declare function getTokensByCategory(category: string): DesignToken[];
|
|
128
|
+
/**
|
|
129
|
+
* Search tokens by name or value (legacy format)
|
|
130
|
+
*/
|
|
131
|
+
export declare function searchTokens(query: string): DesignToken[];
|
|
132
|
+
/**
|
|
133
|
+
* Get available token categories (legacy format)
|
|
134
|
+
*/
|
|
135
|
+
export declare function getTokenCategories(): string[];
|
|
136
|
+
/**
|
|
137
|
+
* Clear all cached tokens (useful for testing)
|
|
138
|
+
*/
|
|
139
|
+
export declare function clearTokenCache(): void;
|
|
140
|
+
//# sourceMappingURL=token-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-parser.d.ts","sourceRoot":"","sources":["../../src/lib/token-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,+FAA+F;IAC/F,QAAQ,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;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