mozaic-mcp-server 2.1.1 → 2.3.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/README.md +15 -7
- package/SKILLS.md +75 -5
- package/bin/install-skills.js +2 -0
- package/data/mozaic.db +0 -0
- package/dist/__tests__/tools.integration.test.js +85 -0
- package/dist/__tests__/tools.integration.test.js.map +1 -1
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -1
- package/dist/parsers/freemarker-parser.d.ts +25 -0
- package/dist/parsers/freemarker-parser.d.ts.map +1 -0
- package/dist/parsers/freemarker-parser.js +299 -0
- package/dist/parsers/freemarker-parser.js.map +1 -0
- package/dist/parsers/web-components-parser.d.ts +3 -0
- package/dist/parsers/web-components-parser.d.ts.map +1 -0
- package/dist/parsers/web-components-parser.js +503 -0
- package/dist/parsers/web-components-parser.js.map +1 -0
- package/dist/tools/generate-freemarker.d.ts +32 -0
- package/dist/tools/generate-freemarker.d.ts.map +1 -0
- package/dist/tools/generate-freemarker.js +146 -0
- package/dist/tools/generate-freemarker.js.map +1 -0
- package/dist/tools/generate-webcomponent.d.ts +38 -0
- package/dist/tools/generate-webcomponent.d.ts.map +1 -0
- package/dist/tools/generate-webcomponent.js +83 -0
- package/dist/tools/generate-webcomponent.js.map +1 -0
- package/dist/tools/get-component-info.d.ts +1 -1
- package/dist/tools/get-component-info.d.ts.map +1 -1
- package/dist/tools/get-component-info.js +9 -1
- package/dist/tools/get-component-info.js.map +1 -1
- package/dist/tools/get-freemarker-info.d.ts +27 -0
- package/dist/tools/get-freemarker-info.d.ts.map +1 -0
- package/dist/tools/get-freemarker-info.js +161 -0
- package/dist/tools/get-freemarker-info.js.map +1 -0
- package/dist/tools/get-webcomponent-info.d.ts +52 -0
- package/dist/tools/get-webcomponent-info.d.ts.map +1 -0
- package/dist/tools/get-webcomponent-info.js +170 -0
- package/dist/tools/get-webcomponent-info.js.map +1 -0
- package/dist/tools/list-freemarker.d.ts +23 -0
- package/dist/tools/list-freemarker.d.ts.map +1 -0
- package/dist/tools/list-freemarker.js +97 -0
- package/dist/tools/list-freemarker.js.map +1 -0
- package/dist/tools/list-webcomponents.d.ts +32 -0
- package/dist/tools/list-webcomponents.d.ts.map +1 -0
- package/dist/tools/list-webcomponents.js +110 -0
- package/dist/tools/list-webcomponents.js.map +1 -0
- package/package.json +1 -1
- package/skills/mozaic-freemarker-builder/scripts/generate-component.sh +27 -0
- package/skills/mozaic-freemarker-builder/scripts/get-component.sh +28 -0
- package/skills/mozaic-freemarker-builder/scripts/list-components.sh +13 -0
- package/skills/mozaic-freemarker-builder/scripts/search-components.sh +14 -0
- package/skills/mozaic-freemarker-builder/skill.md +145 -0
- package/skills/mozaic-webcomponents-builder/scripts/generate-component.sh +67 -0
- package/skills/mozaic-webcomponents-builder/scripts/get-component.sh +105 -0
- package/skills/mozaic-webcomponents-builder/scripts/list-components.sh +42 -0
- package/skills/mozaic-webcomponents-builder/scripts/search-components.sh +34 -0
- package/skills/mozaic-webcomponents-builder/skill.md +292 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
import { readFileSync, existsSync, readdirSync, statSync } from "fs";
|
|
2
|
+
import { join, basename } from "path";
|
|
3
|
+
// Parse Custom Elements Manifest (CEM)
|
|
4
|
+
function parseCustomElementsManifest(basePath) {
|
|
5
|
+
const components = [];
|
|
6
|
+
const manifestPaths = [
|
|
7
|
+
join(basePath, "..", "..", "custom-elements.json"),
|
|
8
|
+
join(basePath, "..", "custom-elements.json"),
|
|
9
|
+
join(basePath, "custom-elements.json"),
|
|
10
|
+
join(basePath, "..", "..", "custom-elements-manifest.json"),
|
|
11
|
+
];
|
|
12
|
+
for (const manifestPath of manifestPaths) {
|
|
13
|
+
if (existsSync(manifestPath)) {
|
|
14
|
+
try {
|
|
15
|
+
const content = readFileSync(manifestPath, "utf-8");
|
|
16
|
+
const manifest = JSON.parse(content);
|
|
17
|
+
if (manifest.modules) {
|
|
18
|
+
for (const module of manifest.modules) {
|
|
19
|
+
if (module.declarations) {
|
|
20
|
+
for (const declaration of module.declarations) {
|
|
21
|
+
if (declaration.kind === "class" && declaration.tagName && declaration.name) {
|
|
22
|
+
const props = [];
|
|
23
|
+
const events = [];
|
|
24
|
+
const slots = [];
|
|
25
|
+
const cssProperties = [];
|
|
26
|
+
// Extract properties
|
|
27
|
+
if (declaration.members) {
|
|
28
|
+
for (const member of declaration.members) {
|
|
29
|
+
if (member.kind === "field" && member.attribute) {
|
|
30
|
+
props.push({
|
|
31
|
+
name: member.name || "",
|
|
32
|
+
type: member.type?.text,
|
|
33
|
+
defaultValue: member.default,
|
|
34
|
+
description: member.description,
|
|
35
|
+
required: !member.default,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Extract events
|
|
41
|
+
if (declaration.events) {
|
|
42
|
+
for (const event of declaration.events) {
|
|
43
|
+
if (event.name) {
|
|
44
|
+
events.push({
|
|
45
|
+
name: event.name,
|
|
46
|
+
payload: event.type?.text,
|
|
47
|
+
description: event.description,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Extract slots
|
|
53
|
+
if (declaration.slots) {
|
|
54
|
+
for (const slot of declaration.slots) {
|
|
55
|
+
slots.push({
|
|
56
|
+
name: slot.name || "default",
|
|
57
|
+
description: slot.description,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Extract CSS custom properties
|
|
62
|
+
if (declaration.cssProperties) {
|
|
63
|
+
for (const cssProp of declaration.cssProperties) {
|
|
64
|
+
if (cssProp.name) {
|
|
65
|
+
cssProperties.push(cssProp.name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
components.push({
|
|
70
|
+
name: declaration.name,
|
|
71
|
+
tagName: declaration.tagName,
|
|
72
|
+
description: declaration.description,
|
|
73
|
+
props,
|
|
74
|
+
slots,
|
|
75
|
+
events,
|
|
76
|
+
cssProperties,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
console.log(` ✓ Parsed custom elements manifest: ${components.length} components`);
|
|
84
|
+
return components;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.warn(`Warning: Could not parse manifest ${manifestPath}:`, error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return components;
|
|
92
|
+
}
|
|
93
|
+
// Extract properties from TypeScript/JavaScript source
|
|
94
|
+
function extractPropsFromSource(content) {
|
|
95
|
+
const props = [];
|
|
96
|
+
const seenProps = new Set();
|
|
97
|
+
// Pattern 1: @property() decorator (Lit)
|
|
98
|
+
const propertyRegex = /@property\s*\(\s*\{([^}]*)\}\s*\)\s*(?:\/\*\*[\s\S]*?\*\/\s*)?(\w+)(\??)\s*:\s*([^;=\n]+)/g;
|
|
99
|
+
let match;
|
|
100
|
+
while ((match = propertyRegex.exec(content)) !== null) {
|
|
101
|
+
const options = match[1];
|
|
102
|
+
const propName = match[2];
|
|
103
|
+
const isOptional = match[3] === "?";
|
|
104
|
+
const propType = match[4].trim();
|
|
105
|
+
if (!seenProps.has(propName)) {
|
|
106
|
+
seenProps.add(propName);
|
|
107
|
+
// Extract type from options
|
|
108
|
+
const typeMatch = options.match(/type\s*:\s*(\w+)/);
|
|
109
|
+
const attributeMatch = options.match(/attribute\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
110
|
+
// const reflectMatch = options.match(/reflect\s*:\s*(true|false)/);
|
|
111
|
+
// Extract JSDoc comment before decorator
|
|
112
|
+
const beforeDecorator = content.substring(0, match.index);
|
|
113
|
+
const jsdocMatch = beforeDecorator.match(/\/\*\*\s*([\s\S]*?)\s*\*\/\s*$/);
|
|
114
|
+
let description;
|
|
115
|
+
if (jsdocMatch) {
|
|
116
|
+
description = jsdocMatch[1]
|
|
117
|
+
.replace(/^\s*\*\s*/gm, "")
|
|
118
|
+
.replace(/\n/g, " ")
|
|
119
|
+
.trim();
|
|
120
|
+
}
|
|
121
|
+
props.push({
|
|
122
|
+
name: attributeMatch ? attributeMatch[1] : propName,
|
|
123
|
+
type: typeMatch ? typeMatch[1] : propType,
|
|
124
|
+
required: !isOptional,
|
|
125
|
+
description,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Pattern 2: static properties = { ... } (Lit)
|
|
130
|
+
const staticPropsMatch = content.match(/static\s+properties\s*=\s*\{([\s\S]*?)\};/);
|
|
131
|
+
if (staticPropsMatch) {
|
|
132
|
+
const propsContent = staticPropsMatch[1];
|
|
133
|
+
const propDefRegex = /(\w+)\s*:\s*\{([^}]*)\}/g;
|
|
134
|
+
while ((match = propDefRegex.exec(propsContent)) !== null) {
|
|
135
|
+
const propName = match[1];
|
|
136
|
+
const propDef = match[2];
|
|
137
|
+
if (!seenProps.has(propName)) {
|
|
138
|
+
seenProps.add(propName);
|
|
139
|
+
const typeMatch = propDef.match(/type\s*:\s*(\w+)/);
|
|
140
|
+
const attributeMatch = propDef.match(/attribute\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
141
|
+
props.push({
|
|
142
|
+
name: attributeMatch ? attributeMatch[1] : propName,
|
|
143
|
+
type: typeMatch ? typeMatch[1] : undefined,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Pattern 3: static get properties() { return { ... } }
|
|
149
|
+
const staticGetPropsMatch = content.match(/static\s+get\s+properties\s*\(\s*\)\s*\{[\s\S]*?return\s*\{([\s\S]*?)\}/);
|
|
150
|
+
if (staticGetPropsMatch) {
|
|
151
|
+
const propsContent = staticGetPropsMatch[1];
|
|
152
|
+
const propDefRegex = /(\w+)\s*:\s*\{([^}]*)\}/g;
|
|
153
|
+
while ((match = propDefRegex.exec(propsContent)) !== null) {
|
|
154
|
+
const propName = match[1];
|
|
155
|
+
const propDef = match[2];
|
|
156
|
+
if (!seenProps.has(propName)) {
|
|
157
|
+
seenProps.add(propName);
|
|
158
|
+
const typeMatch = propDef.match(/type\s*:\s*(\w+)/);
|
|
159
|
+
props.push({
|
|
160
|
+
name: propName,
|
|
161
|
+
type: typeMatch ? typeMatch[1] : undefined,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return props;
|
|
167
|
+
}
|
|
168
|
+
// Extract events from source
|
|
169
|
+
function extractEventsFromSource(content) {
|
|
170
|
+
const events = [];
|
|
171
|
+
const seenEvents = new Set();
|
|
172
|
+
// Pattern 1: dispatchEvent(new CustomEvent('event-name'))
|
|
173
|
+
const customEventRegex = /dispatchEvent\s*\(\s*new\s+CustomEvent\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
174
|
+
let match;
|
|
175
|
+
while ((match = customEventRegex.exec(content)) !== null) {
|
|
176
|
+
const eventName = match[1];
|
|
177
|
+
if (!seenEvents.has(eventName)) {
|
|
178
|
+
seenEvents.add(eventName);
|
|
179
|
+
events.push({ name: eventName });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Pattern 2: this.dispatchEvent(new Event('event-name'))
|
|
183
|
+
const eventRegex = /dispatchEvent\s*\(\s*new\s+Event\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
184
|
+
while ((match = eventRegex.exec(content)) !== null) {
|
|
185
|
+
const eventName = match[1];
|
|
186
|
+
if (!seenEvents.has(eventName)) {
|
|
187
|
+
seenEvents.add(eventName);
|
|
188
|
+
events.push({ name: eventName });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Pattern 3: @event JSDoc tags
|
|
192
|
+
const jsdocEventRegex = /@(?:fires?|event)\s+\{?([^}\s]+)\}?\s+(\w+)/g;
|
|
193
|
+
while ((match = jsdocEventRegex.exec(content)) !== null) {
|
|
194
|
+
const eventName = match[2];
|
|
195
|
+
if (!seenEvents.has(eventName)) {
|
|
196
|
+
seenEvents.add(eventName);
|
|
197
|
+
events.push({
|
|
198
|
+
name: eventName,
|
|
199
|
+
payload: match[1],
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return events;
|
|
204
|
+
}
|
|
205
|
+
// Extract slots from template/render
|
|
206
|
+
function extractSlotsFromSource(content) {
|
|
207
|
+
const slots = [];
|
|
208
|
+
const seenSlots = new Set();
|
|
209
|
+
// Match <slot> tags in template literals or html`` strings
|
|
210
|
+
const slotRegex = /<slot\s*(?:name=["']([^"']+)["'])?[^>]*>/g;
|
|
211
|
+
let match;
|
|
212
|
+
while ((match = slotRegex.exec(content)) !== null) {
|
|
213
|
+
const slotName = match[1] || "default";
|
|
214
|
+
if (!seenSlots.has(slotName)) {
|
|
215
|
+
seenSlots.add(slotName);
|
|
216
|
+
slots.push({ name: slotName });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return slots;
|
|
220
|
+
}
|
|
221
|
+
// Extract CSS custom properties
|
|
222
|
+
function extractCssProperties(content) {
|
|
223
|
+
const cssProps = [];
|
|
224
|
+
const seenProps = new Set();
|
|
225
|
+
// Match --property-name in CSS or static styles
|
|
226
|
+
const cssVarRegex = /(--[a-z0-9-]+)/g;
|
|
227
|
+
let match;
|
|
228
|
+
while ((match = cssVarRegex.exec(content)) !== null) {
|
|
229
|
+
const propName = match[1];
|
|
230
|
+
if (!seenProps.has(propName)) {
|
|
231
|
+
seenProps.add(propName);
|
|
232
|
+
cssProps.push(propName);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return cssProps;
|
|
236
|
+
}
|
|
237
|
+
// Parse TypeScript/JavaScript component file
|
|
238
|
+
function parseWebComponentFile(filePath) {
|
|
239
|
+
try {
|
|
240
|
+
const content = readFileSync(filePath, "utf-8");
|
|
241
|
+
const fileName = basename(filePath, ".ts").replace(/\.js$/, "");
|
|
242
|
+
// Extract component name from @customElement decorator or class name
|
|
243
|
+
let componentName = fileName;
|
|
244
|
+
let tagName = fileName.toLowerCase();
|
|
245
|
+
const customElementMatch = content.match(/@customElement\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/);
|
|
246
|
+
if (customElementMatch) {
|
|
247
|
+
tagName = customElementMatch[1];
|
|
248
|
+
// Convert tag-name to ClassName
|
|
249
|
+
componentName = tagName
|
|
250
|
+
.split("-")
|
|
251
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
252
|
+
.join("");
|
|
253
|
+
}
|
|
254
|
+
// Extract class name if available
|
|
255
|
+
const classMatch = content.match(/class\s+(\w+)\s+extends\s+(?:LitElement|HTMLElement)/);
|
|
256
|
+
if (classMatch) {
|
|
257
|
+
componentName = classMatch[1];
|
|
258
|
+
}
|
|
259
|
+
// Extract description from JSDoc
|
|
260
|
+
let description;
|
|
261
|
+
const jsdocMatch = content.match(/\/\*\*\s*([\s\S]*?)\s*\*\/\s*export\s+class/);
|
|
262
|
+
if (jsdocMatch) {
|
|
263
|
+
description = jsdocMatch[1]
|
|
264
|
+
.replace(/^\s*\*\s*/gm, "")
|
|
265
|
+
.replace(/@\w+.*$/gm, "")
|
|
266
|
+
.replace(/\n/g, " ")
|
|
267
|
+
.trim();
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
name: componentName,
|
|
271
|
+
tagName,
|
|
272
|
+
description,
|
|
273
|
+
props: extractPropsFromSource(content),
|
|
274
|
+
events: extractEventsFromSource(content),
|
|
275
|
+
slots: extractSlotsFromSource(content),
|
|
276
|
+
cssProperties: extractCssProperties(content),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
console.warn(`Warning: Could not parse ${filePath}:`, error);
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// Parse Storybook stories for web components
|
|
285
|
+
function parseWebComponentStories(filePath) {
|
|
286
|
+
const examples = [];
|
|
287
|
+
try {
|
|
288
|
+
const content = readFileSync(filePath, "utf-8");
|
|
289
|
+
// Match story exports with render functions
|
|
290
|
+
const storyRegex = /export\s+const\s+(\w+)[\s\S]*?render:\s*\(([^)]*)\)\s*=>\s*html`([^`]*)`/g;
|
|
291
|
+
let match;
|
|
292
|
+
while ((match = storyRegex.exec(content)) !== null) {
|
|
293
|
+
const storyName = match[1];
|
|
294
|
+
const template = match[3];
|
|
295
|
+
if (storyName !== "Default") {
|
|
296
|
+
examples.push({
|
|
297
|
+
title: storyName.replace(/([A-Z])/g, " $1").trim(),
|
|
298
|
+
code: template.trim(),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// Also match simple template assignments
|
|
303
|
+
const templateRegex = /template\s*:\s*html`([^`]+)`/g;
|
|
304
|
+
while ((match = templateRegex.exec(content)) !== null) {
|
|
305
|
+
examples.push({
|
|
306
|
+
title: "Example",
|
|
307
|
+
code: match[1].trim(),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
console.warn(`Warning: Could not parse stories ${filePath}:`, error);
|
|
313
|
+
}
|
|
314
|
+
return examples;
|
|
315
|
+
}
|
|
316
|
+
// Find component directories
|
|
317
|
+
function findComponentDirs(baseDir) {
|
|
318
|
+
const dirs = [];
|
|
319
|
+
if (!existsSync(baseDir)) {
|
|
320
|
+
return dirs;
|
|
321
|
+
}
|
|
322
|
+
const entries = readdirSync(baseDir);
|
|
323
|
+
for (const entry of entries) {
|
|
324
|
+
const fullPath = join(baseDir, entry);
|
|
325
|
+
const stat = statSync(fullPath);
|
|
326
|
+
if (stat.isDirectory() && /^[a-z]/.test(entry)) {
|
|
327
|
+
dirs.push(fullPath);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return dirs;
|
|
331
|
+
}
|
|
332
|
+
// Infer component category
|
|
333
|
+
function inferCategory(componentName, tagName) {
|
|
334
|
+
const name = (componentName + tagName).toLowerCase();
|
|
335
|
+
if (["button", "link"].some((n) => name.includes(n))) {
|
|
336
|
+
return "action";
|
|
337
|
+
}
|
|
338
|
+
if ([
|
|
339
|
+
"input",
|
|
340
|
+
"select",
|
|
341
|
+
"checkbox",
|
|
342
|
+
"radio",
|
|
343
|
+
"toggle",
|
|
344
|
+
"textarea",
|
|
345
|
+
"field",
|
|
346
|
+
"form",
|
|
347
|
+
"datepicker",
|
|
348
|
+
"dropdown",
|
|
349
|
+
].some((n) => name.includes(n))) {
|
|
350
|
+
return "form";
|
|
351
|
+
}
|
|
352
|
+
if (["accordion", "breadcrumb", "menu", "nav", "pagination", "tabs", "stepper"].some((n) => name.includes(n))) {
|
|
353
|
+
return "navigation";
|
|
354
|
+
}
|
|
355
|
+
if (["badge", "alert", "loader", "modal", "notification", "progress", "tooltip", "snackbar"].some((n) => name.includes(n))) {
|
|
356
|
+
return "feedback";
|
|
357
|
+
}
|
|
358
|
+
if (["card", "divider", "container", "grid", "stack"].some((n) => name.includes(n))) {
|
|
359
|
+
return "layout";
|
|
360
|
+
}
|
|
361
|
+
if (["table", "list", "heading", "text", "icon", "avatar", "chip", "tag"].some((n) => name.includes(n))) {
|
|
362
|
+
return "data-display";
|
|
363
|
+
}
|
|
364
|
+
return "other";
|
|
365
|
+
}
|
|
366
|
+
// Consolidate component data from multiple sources
|
|
367
|
+
function consolidateComponent(manifestData, sourceData, stories) {
|
|
368
|
+
// Use manifest as primary source, fall back to source parsing
|
|
369
|
+
const base = manifestData || sourceData;
|
|
370
|
+
if (!base)
|
|
371
|
+
return null;
|
|
372
|
+
const component = {
|
|
373
|
+
name: base.name + " (Web Component)", // Make name unique to avoid conflicts with Vue/React
|
|
374
|
+
slug: base.tagName,
|
|
375
|
+
category: inferCategory(base.name, base.tagName),
|
|
376
|
+
description: base.description,
|
|
377
|
+
frameworks: ["webcomponents"],
|
|
378
|
+
props: [],
|
|
379
|
+
slots: [],
|
|
380
|
+
events: [],
|
|
381
|
+
examples: [],
|
|
382
|
+
cssClasses: base.cssProperties || [],
|
|
383
|
+
};
|
|
384
|
+
// Consolidate props (deduplicate by name)
|
|
385
|
+
const propMap = new Map();
|
|
386
|
+
// Add manifest props first (higher priority)
|
|
387
|
+
if (manifestData) {
|
|
388
|
+
for (const prop of manifestData.props) {
|
|
389
|
+
propMap.set(prop.name, prop);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// Add source props if not already present
|
|
393
|
+
if (sourceData) {
|
|
394
|
+
for (const prop of sourceData.props) {
|
|
395
|
+
if (!propMap.has(prop.name)) {
|
|
396
|
+
propMap.set(prop.name, prop);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
component.props = Array.from(propMap.values());
|
|
401
|
+
// Consolidate events
|
|
402
|
+
const eventMap = new Map();
|
|
403
|
+
if (manifestData) {
|
|
404
|
+
for (const event of manifestData.events) {
|
|
405
|
+
eventMap.set(event.name, event);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (sourceData) {
|
|
409
|
+
for (const event of sourceData.events) {
|
|
410
|
+
if (!eventMap.has(event.name)) {
|
|
411
|
+
eventMap.set(event.name, event);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
component.events = Array.from(eventMap.values());
|
|
416
|
+
// Consolidate slots
|
|
417
|
+
const slotMap = new Map();
|
|
418
|
+
if (manifestData) {
|
|
419
|
+
for (const slot of manifestData.slots) {
|
|
420
|
+
slotMap.set(slot.name, slot);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
if (sourceData) {
|
|
424
|
+
for (const slot of sourceData.slots) {
|
|
425
|
+
if (!slotMap.has(slot.name)) {
|
|
426
|
+
slotMap.set(slot.name, slot);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
component.slots = Array.from(slotMap.values());
|
|
431
|
+
// Add examples from Storybook
|
|
432
|
+
component.examples = stories.map((story) => ({
|
|
433
|
+
framework: "webcomponents",
|
|
434
|
+
title: story.title,
|
|
435
|
+
code: story.code,
|
|
436
|
+
}));
|
|
437
|
+
return component;
|
|
438
|
+
}
|
|
439
|
+
export async function parseWebComponents(componentsPath) {
|
|
440
|
+
const components = [];
|
|
441
|
+
// Step 1: Parse Custom Elements Manifest
|
|
442
|
+
const manifestComponents = parseCustomElementsManifest(componentsPath);
|
|
443
|
+
const manifestMap = new Map();
|
|
444
|
+
for (const comp of manifestComponents) {
|
|
445
|
+
manifestMap.set(comp.tagName, comp);
|
|
446
|
+
}
|
|
447
|
+
// Step 2: Parse component source files
|
|
448
|
+
const componentDirs = findComponentDirs(componentsPath);
|
|
449
|
+
for (const dir of componentDirs) {
|
|
450
|
+
const dirName = basename(dir);
|
|
451
|
+
// Try to find component file
|
|
452
|
+
const possibleFiles = [
|
|
453
|
+
join(dir, `${dirName}.ts`),
|
|
454
|
+
join(dir, `${dirName}.js`),
|
|
455
|
+
join(dir, "index.ts"),
|
|
456
|
+
join(dir, "index.js"),
|
|
457
|
+
];
|
|
458
|
+
let componentFile = null;
|
|
459
|
+
for (const file of possibleFiles) {
|
|
460
|
+
if (existsSync(file)) {
|
|
461
|
+
componentFile = file;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const sourceData = componentFile ? parseWebComponentFile(componentFile) : null;
|
|
466
|
+
// Get manifest data if available (try by directory name as tag)
|
|
467
|
+
// Directory names like "accordionlist" match tags like "m-accordion-list" or "m-accordionlist"
|
|
468
|
+
const possibleTagNames = [
|
|
469
|
+
`m-${dirName}`, // e.g., "m-accordionlist"
|
|
470
|
+
`m-${dirName.replace(/([A-Z])/g, "-$1").toLowerCase()}`, // e.g., "m-accordion-list" for "accordionList"
|
|
471
|
+
`mozaic-${dirName}`,
|
|
472
|
+
dirName,
|
|
473
|
+
sourceData?.tagName || "",
|
|
474
|
+
];
|
|
475
|
+
let manifestData;
|
|
476
|
+
for (const tagName of possibleTagNames) {
|
|
477
|
+
if (manifestMap.has(tagName)) {
|
|
478
|
+
manifestData = manifestMap.get(tagName);
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
// Parse stories
|
|
483
|
+
let stories = [];
|
|
484
|
+
const storyPatterns = [
|
|
485
|
+
join(dir, `${dirName}.stories.ts`),
|
|
486
|
+
join(dir, `${dirName}.stories.js`),
|
|
487
|
+
join(dir, "stories", `${dirName}.stories.ts`),
|
|
488
|
+
];
|
|
489
|
+
for (const storyPath of storyPatterns) {
|
|
490
|
+
if (existsSync(storyPath)) {
|
|
491
|
+
stories = parseWebComponentStories(storyPath);
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
// Consolidate all data (manifest-only is ok if no source file found)
|
|
496
|
+
const component = consolidateComponent(manifestData, sourceData, stories);
|
|
497
|
+
if (component) {
|
|
498
|
+
components.push(component);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return components;
|
|
502
|
+
}
|
|
503
|
+
//# sourceMappingURL=web-components-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-components-parser.js","sourceRoot":"","sources":["../../src/parsers/web-components-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AA+CtC,uCAAuC;AACvC,SAAS,2BAA2B,CAAC,QAAgB;IACnD,MAAM,UAAU,GAAyB,EAAE,CAAC;IAE5C,MAAM,aAAa,GAAG;QACpB,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,sBAAsB,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,sBAAsB,CAAC;QAC5C,IAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC;QACtC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,+BAA+B,CAAC;KAC5D,CAAC;IAEF,KAAK,MAAM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CAAC,EAAE,CAAC;gBAC1B,OAAO,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;gBAC9C,MAAM;YACR,CAAC;QACH,CAAC;QAED,qEAAqE;QACrE,MAAM,SAAS,GAAG,oBAAoB,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAC1E,IAAI,SAAS,EAAE,CAAC;YACd,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Generate Freemarker macro usage code
|
|
5
|
+
*
|
|
6
|
+
* This tool generates ready-to-use Freemarker template code with:
|
|
7
|
+
* - Import statement for the macro
|
|
8
|
+
* - Macro invocation with configuration object
|
|
9
|
+
* - Example configuration based on component props
|
|
10
|
+
*/
|
|
11
|
+
declare const _GenerateFreemarkerInputSchema: z.ZodObject<{
|
|
12
|
+
component: z.ZodString;
|
|
13
|
+
config: z.ZodOptional<z.ZodString>;
|
|
14
|
+
content: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
component: string;
|
|
17
|
+
config?: string | undefined;
|
|
18
|
+
content?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
component: string;
|
|
21
|
+
config?: string | undefined;
|
|
22
|
+
content?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export type GenerateFreemarkerInput = z.infer<typeof _GenerateFreemarkerInputSchema>;
|
|
25
|
+
export declare function handleGenerateFreemarker(db: Database.Database, input: GenerateFreemarkerInput): {
|
|
26
|
+
content: Array<{
|
|
27
|
+
type: "text";
|
|
28
|
+
text: string;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=generate-freemarker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-freemarker.d.ts","sourceRoot":"","sources":["../../src/tools/generate-freemarker.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AAEH,QAAA,MAAM,8BAA8B;;;;;;;;;;;;EAOlC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAErF,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,KAAK,EAAE,uBAAuB,GAC7B;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAkJpD"}
|