@dryui/mcp 0.1.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.
@@ -0,0 +1,19 @@
1
+ import type { ComponentDef, DataAttributeDef, ForwardedPropsDef, PartDef, PropDef } from './spec-types.js';
2
+ export declare const DIR_OVERRIDES: Readonly<Record<string, string>>;
3
+ export declare function componentDir(name: string): string;
4
+ export declare function pad(str: string, width: number): string;
5
+ export declare function indent(text: string, spaces: number): string;
6
+ export declare function getSubpathImport(name: string, def: ComponentDef): string | null;
7
+ export declare function findComponent(query: string, components: Record<string, ComponentDef>): {
8
+ name: string;
9
+ def: ComponentDef;
10
+ } | null;
11
+ export declare function formatProp(propName: string, propDef: PropDef, width: number): string;
12
+ export declare function formatCssVars(cssVars: Record<string, string>): string[];
13
+ export declare function formatDataAttributes(dataAttributes: DataAttributeDef[]): string[];
14
+ export declare function formatA11yNotes(notes?: string[]): string[];
15
+ export declare function formatForwardedProps(forwardedProps?: ForwardedPropsDef | null): string[];
16
+ export declare function formatPart(name: string, partName: string, partDef: PartDef): string[];
17
+ export declare function formatStructure(name: string, def: ComponentDef): string[];
18
+ export declare function formatCompound(name: string, def: ComponentDef): string;
19
+ export declare function formatSimple(name: string, def: ComponentDef): string;
@@ -0,0 +1,256 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toESMCache_node;
10
+ var __toESMCache_esm;
11
+ var __toESM = (mod, isNodeMode, target) => {
12
+ var canCache = mod != null && typeof mod === "object";
13
+ if (canCache) {
14
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
15
+ var cached = cache.get(mod);
16
+ if (cached)
17
+ return cached;
18
+ }
19
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
20
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
21
+ for (let key of __getOwnPropNames(mod))
22
+ if (!__hasOwnProp.call(to, key))
23
+ __defProp(to, key, {
24
+ get: __accessProp.bind(mod, key),
25
+ enumerable: true
26
+ });
27
+ if (canCache)
28
+ cache.set(mod, to);
29
+ return to;
30
+ };
31
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
32
+ var __returnValue = (v) => v;
33
+ function __exportSetter(name, newValue) {
34
+ this[name] = __returnValue.bind(null, newValue);
35
+ }
36
+ var __export = (target, all) => {
37
+ for (var name in all)
38
+ __defProp(target, name, {
39
+ get: all[name],
40
+ enumerable: true,
41
+ configurable: true,
42
+ set: __exportSetter.bind(all, name)
43
+ });
44
+ };
45
+
46
+ // src/spec-formatters.ts
47
+ var DIR_OVERRIDES = {
48
+ QRCode: "qr-code"
49
+ };
50
+ function componentDir(name) {
51
+ return DIR_OVERRIDES[name] ?? name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
52
+ }
53
+ function pad(str, width) {
54
+ return str.length >= width ? str : str + " ".repeat(width - str.length);
55
+ }
56
+ function indent(text, spaces) {
57
+ const prefix = " ".repeat(spaces);
58
+ return text.split(`
59
+ `).map((line) => prefix + line).join(`
60
+ `);
61
+ }
62
+ function getSubpathImport(name, def) {
63
+ if (def.import !== "@dryui/ui")
64
+ return null;
65
+ return `import { ${name} } from '${def.import}/${componentDir(name)}'`;
66
+ }
67
+ function findComponent(query, components) {
68
+ const exact = components[query];
69
+ if (exact)
70
+ return { name: query, def: exact };
71
+ const lower = query.toLowerCase();
72
+ for (const [name, def] of Object.entries(components)) {
73
+ if (name.toLowerCase() === lower)
74
+ return { name, def };
75
+ }
76
+ return null;
77
+ }
78
+ function formatProp(propName, propDef, width) {
79
+ const flags = [propDef.type];
80
+ if (propDef.description)
81
+ flags.push(`description: ${propDef.description}`);
82
+ if (propDef.acceptedValues?.length)
83
+ flags.push(`accepted: ${propDef.acceptedValues.join(", ")}`);
84
+ if (propDef.default !== undefined)
85
+ flags.push(`default: ${propDef.default}`);
86
+ if (propDef.required)
87
+ flags.push("required");
88
+ if (propDef.bindable)
89
+ flags.push("bindable");
90
+ if (propDef.note)
91
+ flags.push(`note: ${propDef.note}`);
92
+ return ` ${pad(propName, width + 2)}${flags.join(" | ")}`;
93
+ }
94
+ function formatCssVars(cssVars) {
95
+ const entries = Object.entries(cssVars);
96
+ if (entries.length === 0)
97
+ return [" none"];
98
+ const maxLen = Math.max(...entries.map(([name]) => name.length));
99
+ return entries.map(([name, description]) => ` ${pad(name, maxLen + 2)}${description}`);
100
+ }
101
+ function formatDataAttributes(dataAttributes) {
102
+ if (dataAttributes.length === 0)
103
+ return [" none"];
104
+ const width = Math.max(...dataAttributes.map((attr) => attr.name.length));
105
+ return dataAttributes.map((attr) => {
106
+ const meta = [
107
+ attr.description,
108
+ attr.values?.length ? `values: ${attr.values.join(", ")}` : null
109
+ ].filter(Boolean).join(" | ");
110
+ return meta ? ` ${pad(attr.name, width + 2)}${meta}` : ` ${attr.name}`;
111
+ });
112
+ }
113
+ function formatA11yNotes(notes) {
114
+ if (!notes?.length)
115
+ return [" none"];
116
+ return notes.map((note) => ` - ${note}`);
117
+ }
118
+ function formatForwardedProps(forwardedProps) {
119
+ if (!forwardedProps)
120
+ return [" none"];
121
+ const lines = [` ${forwardedProps.note}`];
122
+ if (forwardedProps.examples?.length) {
123
+ lines.push(` examples: ${forwardedProps.examples.join(", ")}`);
124
+ }
125
+ if (forwardedProps.omitted?.length) {
126
+ lines.push(` omits: ${forwardedProps.omitted.join(", ")}`);
127
+ }
128
+ return lines;
129
+ }
130
+ function formatPart(name, partName, partDef) {
131
+ const lines = [` ${name}.${partName}`];
132
+ const props = Object.entries(partDef.props ?? {});
133
+ if (props.length === 0) {
134
+ lines.push(" Props: none");
135
+ } else {
136
+ const maxLen = Math.max(...props.map(([propName]) => propName.length));
137
+ for (const [propName, propDef] of props) {
138
+ lines.push(` ${formatProp(propName, propDef, maxLen).trimStart()}`);
139
+ }
140
+ }
141
+ if (partDef.forwardedProps) {
142
+ lines.push(" Native props:");
143
+ for (const detail of formatForwardedProps(partDef.forwardedProps)) {
144
+ lines.push(` ${detail.trimStart()}`);
145
+ }
146
+ }
147
+ return lines;
148
+ }
149
+ function formatStructure(name, def) {
150
+ if (!def.structure?.tree.length) {
151
+ return [" none"];
152
+ }
153
+ const lines = def.structure.tree.map((node) => ` ${node}`);
154
+ if (def.structure.note) {
155
+ lines.push(` note: ${def.structure.note}`);
156
+ }
157
+ return lines;
158
+ }
159
+ function formatCompound(name, def) {
160
+ const lines = [];
161
+ lines.push(`${name} — ${def.description}`);
162
+ lines.push(`Category: ${def.category} | Tags: ${def.tags.join(", ")}`);
163
+ lines.push(`Root import: import { ${name} } from '${def.import}'`);
164
+ const subpath = getSubpathImport(name, def);
165
+ if (subpath)
166
+ lines.push(`Subpath import: ${subpath}`);
167
+ const hasRoot = Boolean(def.parts?.Root);
168
+ lines.push(hasRoot ? `Compound: yes (use ${name}.Root, not ${name})` : `Namespace: yes (parts are used directly; no ${name}.Root wrapper)`);
169
+ if (hasRoot) {
170
+ lines.push("");
171
+ lines.push("Required structure:");
172
+ lines.push(...formatStructure(name, def));
173
+ } else if (def.structure?.note) {
174
+ lines.push("");
175
+ lines.push(`Note: ${def.structure.note}`);
176
+ }
177
+ if (def.parts) {
178
+ lines.push("");
179
+ lines.push("Parts:");
180
+ for (const [partName, partDef] of Object.entries(def.parts)) {
181
+ lines.push(...formatPart(name, partName, partDef));
182
+ }
183
+ }
184
+ lines.push("");
185
+ lines.push("CSS Variables:");
186
+ lines.push(...formatCssVars(def.cssVars));
187
+ lines.push("");
188
+ lines.push("Data Attributes:");
189
+ lines.push(...formatDataAttributes(def.dataAttributes));
190
+ lines.push("");
191
+ lines.push("Accessibility:");
192
+ lines.push(...formatA11yNotes(def.a11y));
193
+ if (def.example) {
194
+ lines.push("");
195
+ lines.push("Example:");
196
+ lines.push(indent(def.example, 2));
197
+ }
198
+ return lines.join(`
199
+ `);
200
+ }
201
+ function formatSimple(name, def) {
202
+ const lines = [];
203
+ lines.push(`${name} — ${def.description}`);
204
+ lines.push(`Category: ${def.category} | Tags: ${def.tags.join(", ")}`);
205
+ lines.push(`Root import: import { ${name} } from '${def.import}'`);
206
+ const subpath = getSubpathImport(name, def);
207
+ if (subpath)
208
+ lines.push(`Subpath import: ${subpath}`);
209
+ lines.push("");
210
+ lines.push("Props:");
211
+ if (def.props && Object.keys(def.props).length > 0) {
212
+ const propEntries = Object.entries(def.props);
213
+ const maxLen = Math.max(...propEntries.map(([p]) => p.length));
214
+ for (const [propName, propDef] of propEntries) {
215
+ lines.push(formatProp(propName, propDef, maxLen));
216
+ }
217
+ } else {
218
+ lines.push(" none");
219
+ }
220
+ lines.push("");
221
+ lines.push("Native props:");
222
+ lines.push(...formatForwardedProps(def.forwardedProps));
223
+ lines.push("");
224
+ lines.push("CSS Variables:");
225
+ lines.push(...formatCssVars(def.cssVars));
226
+ lines.push("");
227
+ lines.push("Data Attributes:");
228
+ lines.push(...formatDataAttributes(def.dataAttributes));
229
+ lines.push("");
230
+ lines.push("Accessibility:");
231
+ lines.push(...formatA11yNotes(def.a11y));
232
+ if (def.example) {
233
+ lines.push("");
234
+ lines.push("Example:");
235
+ lines.push(indent(def.example, 2));
236
+ }
237
+ return lines.join(`
238
+ `);
239
+ }
240
+ export {
241
+ pad,
242
+ indent,
243
+ getSubpathImport,
244
+ formatStructure,
245
+ formatSimple,
246
+ formatProp,
247
+ formatPart,
248
+ formatForwardedProps,
249
+ formatDataAttributes,
250
+ formatCssVars,
251
+ formatCompound,
252
+ formatA11yNotes,
253
+ findComponent,
254
+ componentDir,
255
+ DIR_OVERRIDES
256
+ };
@@ -0,0 +1,83 @@
1
+ export interface PropDef {
2
+ readonly type: string;
3
+ readonly required?: boolean;
4
+ readonly bindable?: boolean;
5
+ readonly default?: string;
6
+ readonly acceptedValues?: string[];
7
+ readonly description?: string;
8
+ readonly note?: string;
9
+ }
10
+ export interface DataAttributeDef {
11
+ readonly name: string;
12
+ readonly description?: string;
13
+ readonly values?: string[];
14
+ }
15
+ export interface ForwardedPropsDef {
16
+ readonly baseType: string;
17
+ readonly via: string;
18
+ readonly element?: string;
19
+ readonly examples?: string[];
20
+ readonly omitted?: string[];
21
+ readonly note: string;
22
+ }
23
+ export interface StructureDef {
24
+ readonly tree: string[];
25
+ readonly note?: string;
26
+ }
27
+ export interface PartDef {
28
+ readonly props: Record<string, PropDef>;
29
+ readonly forwardedProps?: ForwardedPropsDef | null;
30
+ }
31
+ export interface ComponentDef {
32
+ readonly import: string;
33
+ readonly description: string;
34
+ readonly category: string;
35
+ readonly tags: string[];
36
+ readonly compound: boolean;
37
+ readonly props?: Record<string, PropDef>;
38
+ readonly parts?: Record<string, PartDef>;
39
+ readonly forwardedProps?: ForwardedPropsDef | null;
40
+ readonly structure?: StructureDef | null;
41
+ readonly a11y?: string[];
42
+ readonly cssVars: Record<string, string>;
43
+ readonly dataAttributes: DataAttributeDef[];
44
+ readonly example: string;
45
+ }
46
+ export interface CompositionAlternativeDef {
47
+ readonly rank: number;
48
+ readonly component: string;
49
+ readonly useWhen: string;
50
+ readonly snippet: string;
51
+ }
52
+ export interface CompositionAntiPatternDef {
53
+ readonly pattern: string;
54
+ readonly reason: string;
55
+ readonly fix: string;
56
+ }
57
+ export interface CompositionComponentDef {
58
+ readonly component: string;
59
+ readonly useWhen: string;
60
+ readonly alternatives: readonly CompositionAlternativeDef[];
61
+ readonly antiPatterns: readonly CompositionAntiPatternDef[];
62
+ readonly combinesWith: readonly string[];
63
+ }
64
+ export interface CompositionRecipeDef {
65
+ readonly name: string;
66
+ readonly description: string;
67
+ readonly tags: readonly string[];
68
+ readonly components: readonly string[];
69
+ readonly snippet: string;
70
+ }
71
+ export interface Spec {
72
+ readonly version: string;
73
+ readonly package: string;
74
+ readonly themeImports: {
75
+ readonly default: string;
76
+ readonly dark: string;
77
+ };
78
+ readonly components: Record<string, ComponentDef>;
79
+ readonly composition?: {
80
+ readonly components: Record<string, CompositionComponentDef>;
81
+ readonly recipes: Record<string, CompositionRecipeDef>;
82
+ };
83
+ }
File without changes