@wire-dsl/language-support 0.2.4 → 0.4.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.
Files changed (41) hide show
  1. package/INTEGRATION-GUIDE.md +50 -194
  2. package/README.md +39 -33
  3. package/dist/completions.d.ts.map +1 -1
  4. package/dist/completions.js +8 -1
  5. package/dist/completions.js.map +1 -1
  6. package/dist/components.d.ts +0 -6
  7. package/dist/components.d.ts.map +1 -1
  8. package/dist/components.js +94 -40
  9. package/dist/components.js.map +1 -1
  10. package/dist/context-detection.js +2 -2
  11. package/dist/context-detection.js.map +1 -1
  12. package/dist/document-parser.d.ts +12 -0
  13. package/dist/document-parser.d.ts.map +1 -1
  14. package/dist/document-parser.js +49 -0
  15. package/dist/document-parser.js.map +1 -1
  16. package/dist/documentation.js +1 -1
  17. package/dist/documentation.js.map +1 -1
  18. package/dist/icon-names.d.ts +8 -0
  19. package/dist/icon-names.d.ts.map +1 -0
  20. package/dist/icon-names.js +295 -0
  21. package/dist/icon-names.js.map +1 -0
  22. package/dist/index.d.ts +6 -5
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +7 -6
  25. package/dist/index.js.map +1 -1
  26. package/dist-cjs/completions.js +394 -0
  27. package/dist-cjs/completions.js.map +1 -0
  28. package/dist-cjs/components.js +504 -0
  29. package/dist-cjs/components.js.map +1 -0
  30. package/dist-cjs/context-detection.js +153 -0
  31. package/dist-cjs/context-detection.js.map +1 -0
  32. package/dist-cjs/document-parser.js +323 -0
  33. package/dist-cjs/document-parser.js.map +1 -0
  34. package/dist-cjs/documentation.js +133 -0
  35. package/dist-cjs/documentation.js.map +1 -0
  36. package/dist-cjs/icon-names.js +298 -0
  37. package/dist-cjs/icon-names.js.map +1 -0
  38. package/dist-cjs/index.js +114 -0
  39. package/dist-cjs/index.js.map +1 -0
  40. package/dist-cjs/package.json +1 -0
  41. package/package.json +14 -3
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ /**
3
+ * Wire DSL Context Detection
4
+ * Agnóstic logic for detecting document scope and completion context
5
+ * Used by Monaco, VS Code, and other editors
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.determineScope = determineScope;
9
+ exports.detectComponentContext = detectComponentContext;
10
+ exports.getCurrentWord = getCurrentWord;
11
+ exports.getComponentPropertiesForCompletion = getComponentPropertiesForCompletion;
12
+ exports.getAlreadyDeclaredProperties = getAlreadyDeclaredProperties;
13
+ const components_js_1 = require("./components.js");
14
+ /**
15
+ * Determine document scope by analyzing text structure
16
+ * Returns: empty-file | inside-project | inside-screen | inside-layout
17
+ *
18
+ * Hierarchy:
19
+ * project { ... } <- empty-file → inside-project
20
+ * screen Name { ... } <- inside-project → inside-screen
21
+ * layout stack(...) { <- inside-screen → inside-layout
22
+ * component Button <- inside-layout
23
+ */
24
+ function determineScope(textBeforeCursor) {
25
+ const cleanText = textBeforeCursor.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
26
+ if (cleanText.trim().length === 0) {
27
+ return 'empty-file';
28
+ }
29
+ // Track nesting depth by analyzing braces and keywords
30
+ let projectBraceCount = 0;
31
+ let screenBraceCount = 0;
32
+ let layoutBraceCount = 0;
33
+ let hasProject = false;
34
+ let hasScreen = false;
35
+ let hasLayout = false;
36
+ const lines = cleanText.split('\n');
37
+ for (const line of lines) {
38
+ // Track keywords
39
+ if (line.match(/\bproject\s+"?[^{]*{/)) {
40
+ hasProject = true;
41
+ }
42
+ if (line.match(/\bscreen\s+[A-Za-z_][A-Za-z0-9_]*\s*{/)) {
43
+ hasScreen = true;
44
+ }
45
+ if (line.match(/\blayout\s+[A-Za-z_][A-Za-z0-9_]*\s*\(/)) {
46
+ hasLayout = true;
47
+ }
48
+ // Count opening braces
49
+ if (line.includes('project') && line.includes('{'))
50
+ projectBraceCount++;
51
+ if (line.includes('screen') && line.includes('{'))
52
+ screenBraceCount++;
53
+ if (line.includes('layout') && line.includes('{'))
54
+ layoutBraceCount++;
55
+ // Count closing braces to track nesting level
56
+ projectBraceCount -= (line.match(/}/g) || []).length;
57
+ screenBraceCount -= (line.match(/}/g) || []).length;
58
+ layoutBraceCount -= (line.match(/}/g) || []).length;
59
+ }
60
+ // Determine scope based on nesting hierarchy
61
+ if (!hasProject) {
62
+ return 'empty-file';
63
+ }
64
+ // We're inside a layout (deepest level)
65
+ if (hasLayout && layoutBraceCount > 0) {
66
+ return 'inside-layout';
67
+ }
68
+ // We're inside a screen but not in a layout
69
+ if (hasScreen && screenBraceCount > 0) {
70
+ return 'inside-screen';
71
+ }
72
+ // We're inside project level
73
+ if (hasProject && projectBraceCount > 0) {
74
+ return 'inside-project';
75
+ }
76
+ return 'inside-project';
77
+ }
78
+ /**
79
+ * Detect if we're inside a component definition (after component keyword)
80
+ * and return the component name if found.
81
+ *
82
+ * Examples:
83
+ * - "component Button" → returns "Button"
84
+ * - "component Button text:" → returns "Button"
85
+ * - "component Button text: "Save"" → returns "Button"
86
+ * - "component B" → returns null (still typing component name)
87
+ */
88
+ function detectComponentContext(lineText) {
89
+ // Match "component ComponentName" where ComponentName starts with uppercase
90
+ // This ensures we have a complete, recognized component name
91
+ const match = lineText.match(/component\s+([A-Z]\w*)/);
92
+ if (!match) {
93
+ return null;
94
+ }
95
+ const componentName = match[1];
96
+ // Check if this is a valid component
97
+ if (!components_js_1.COMPONENTS[componentName]) {
98
+ return null;
99
+ }
100
+ // Get text after the component name
101
+ const afterComponent = lineText.substring(match.index + match[0].length);
102
+ // If there's nothing after, or only spaces, we're at the end - show properties
103
+ // Or if we have properties already (word followed by colon), show properties
104
+ if (afterComponent.match(/^\s*$/) || afterComponent.match(/^\s+[\w-]+:/)) {
105
+ return componentName;
106
+ }
107
+ return null;
108
+ }
109
+ /**
110
+ * Get the current word being typed at the end of a line
111
+ */
112
+ function getCurrentWord(lineText) {
113
+ const match = lineText.match(/[\w-]*$/);
114
+ return match ? match[0] : '';
115
+ }
116
+ function getComponentPropertiesForCompletion(componentName, alreadyDeclared = new Set()) {
117
+ const component = components_js_1.COMPONENTS[componentName];
118
+ if (!component)
119
+ return [];
120
+ const items = [];
121
+ const properties = Object.values(component.properties) || [];
122
+ for (const prop of properties) {
123
+ // Skip if this property is already declared
124
+ if (alreadyDeclared.has(prop.name)) {
125
+ continue;
126
+ }
127
+ const item = {
128
+ label: prop.name,
129
+ kind: 'Property',
130
+ detail: `Property of ${componentName}`,
131
+ insertText: `${prop.name}: `,
132
+ };
133
+ // Add property values if available
134
+ if (prop.type === 'enum' && prop.options && prop.options.length > 0) {
135
+ item.insertText = `${prop.name}: ${prop.options.length === 1 ? prop.options[0] : ''}`;
136
+ }
137
+ items.push(item);
138
+ }
139
+ return items;
140
+ }
141
+ /**
142
+ * Extract already-declared properties from a component line
143
+ * Patterns: propertyName: or propertyName: value
144
+ */
145
+ function getAlreadyDeclaredProperties(lineText) {
146
+ const declaredProps = new Set();
147
+ const matches = lineText.matchAll(/(\w+):\s*/g);
148
+ for (const match of Array.from(matches)) {
149
+ declaredProps.add(match[1]);
150
+ }
151
+ return declaredProps;
152
+ }
153
+ //# sourceMappingURL=context-detection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-detection.js","sourceRoot":"","sources":["../src/context-detection.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAuBH,wCA6DC;AAYD,wDAyBC;AAKD,wCAGC;AAcD,kFAgCC;AAMD,oEASC;AA5LD,mDAA6C;AAW7C;;;;;;;;;GASG;AACH,SAAgB,cAAc,CAAC,gBAAwB;IACrD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAE7F,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,uDAAuD;IACvD,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1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AAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,QAAgB;IAC3D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEhD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+ /**
3
+ * Wire DSL Document Parser
4
+ * Extracts component definitions and references from Wire DSL documents
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.extractComponentDefinitions = extractComponentDefinitions;
8
+ exports.extractLayoutDefinitions = extractLayoutDefinitions;
9
+ exports.getTokenAtPosition = getTokenAtPosition;
10
+ exports.isComponentReference = isComponentReference;
11
+ exports.extractComponentReferences = extractComponentReferences;
12
+ exports.extractScreenDefinitions = extractScreenDefinitions;
13
+ exports.getPositionOfDefinition = getPositionOfDefinition;
14
+ exports.findComponentReferences = findComponentReferences;
15
+ /**
16
+ * Extract all component definitions from document text
17
+ * Syntax: define Component "ComponentName" { ... }
18
+ * Supports documentation via block comments before the definition
19
+ */
20
+ function extractComponentDefinitions(text) {
21
+ const definitions = [];
22
+ const lines = text.split('\n');
23
+ // Regex to match: define Component "ComponentName"
24
+ const regex = /define\s+Component\s+"([^"]+)"/gm;
25
+ let match;
26
+ while ((match = regex.exec(text)) !== null) {
27
+ const componentName = match[1];
28
+ const matchIndex = match.index;
29
+ // Calculate line and character position
30
+ const lineNumber = text.substring(0, matchIndex).split('\n').length - 1;
31
+ const lastLineBreak = text.lastIndexOf('\n', matchIndex);
32
+ const character = matchIndex - (lastLineBreak + 1);
33
+ // Find end line by locating the closing brace
34
+ const afterName = matchIndex + match[0].length;
35
+ let braceCount = 0;
36
+ let foundOpening = false;
37
+ let endLine = lineNumber;
38
+ for (let i = afterName; i < text.length; i++) {
39
+ const char = text[i];
40
+ if (char === '{') {
41
+ braceCount++;
42
+ foundOpening = true;
43
+ }
44
+ else if (char === '}') {
45
+ braceCount--;
46
+ if (foundOpening && braceCount === 0) {
47
+ // Found the closing brace
48
+ endLine = text.substring(0, i).split('\n').length - 1;
49
+ break;
50
+ }
51
+ }
52
+ }
53
+ // Extract documentation from block comments before the definition
54
+ let documentation;
55
+ if (lineNumber > 0) {
56
+ // Look backwards for /* ... */ block comment immediately before the definition
57
+ let currentLine = lineNumber - 1;
58
+ // Skip empty lines
59
+ while (currentLine >= 0 && lines[currentLine].trim() === '') {
60
+ currentLine--;
61
+ }
62
+ if (currentLine >= 0) {
63
+ const prevLine = lines[currentLine];
64
+ const prevTrimmed = prevLine.trim();
65
+ // Check if the previous line contains the end of a block comment
66
+ if (prevTrimmed.endsWith('*/')) {
67
+ // Find the start of the block comment
68
+ let blockStart = currentLine;
69
+ let foundStart = false;
70
+ // Look backwards for /*
71
+ for (let i = currentLine; i >= 0; i--) {
72
+ const lineText = lines[i];
73
+ if (lineText.includes('/*')) {
74
+ blockStart = i;
75
+ foundStart = true;
76
+ break;
77
+ }
78
+ }
79
+ if (foundStart) {
80
+ // Extract the block comment content
81
+ const commentLines = [];
82
+ for (let i = blockStart; i <= currentLine; i++) {
83
+ let lineText = lines[i].trim();
84
+ // Remove /* from the beginning and */ from the end
85
+ if (i === blockStart) {
86
+ lineText = lineText.replace(/^\/\*\s*/, '');
87
+ }
88
+ if (i === currentLine) {
89
+ lineText = lineText.replace(/\s*\*\/$/, '');
90
+ }
91
+ // Remove leading * from continuation lines
92
+ lineText = lineText.replace(/^\*\s*/, '');
93
+ if (lineText) {
94
+ commentLines.push(lineText);
95
+ }
96
+ }
97
+ if (commentLines.length > 0) {
98
+ documentation = commentLines.join('\n');
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ definitions.push({
105
+ name: componentName,
106
+ line: lineNumber,
107
+ character: character,
108
+ endLine: endLine,
109
+ documentation,
110
+ });
111
+ }
112
+ return definitions;
113
+ }
114
+ /**
115
+ * Extract all layout definitions from document text
116
+ * Syntax: define Layout "layout_name" { ... }
117
+ */
118
+ function extractLayoutDefinitions(text) {
119
+ const definitions = [];
120
+ const regex = /define\s+Layout\s+"([^"]+)"/gm;
121
+ let match;
122
+ while ((match = regex.exec(text)) !== null) {
123
+ const layoutName = match[1];
124
+ const matchIndex = match.index;
125
+ const lineNumber = text.substring(0, matchIndex).split('\n').length - 1;
126
+ const lastLineBreak = text.lastIndexOf('\n', matchIndex);
127
+ const character = matchIndex - (lastLineBreak + 1);
128
+ const afterName = matchIndex + match[0].length;
129
+ let braceCount = 0;
130
+ let foundOpening = false;
131
+ let endLine = lineNumber;
132
+ for (let i = afterName; i < text.length; i++) {
133
+ const char = text[i];
134
+ if (char === '{') {
135
+ braceCount++;
136
+ foundOpening = true;
137
+ }
138
+ else if (char === '}') {
139
+ braceCount--;
140
+ if (foundOpening && braceCount === 0) {
141
+ endLine = text.substring(0, i).split('\n').length - 1;
142
+ break;
143
+ }
144
+ }
145
+ }
146
+ definitions.push({
147
+ name: layoutName,
148
+ line: lineNumber,
149
+ character,
150
+ endLine,
151
+ });
152
+ }
153
+ return definitions;
154
+ }
155
+ /**
156
+ * Get the token at a specific position in the document
157
+ * Returns the word and its range
158
+ */
159
+ function getTokenAtPosition(text, line, character) {
160
+ const lines = text.split('\n');
161
+ if (line >= lines.length) {
162
+ return null;
163
+ }
164
+ const lineText = lines[line];
165
+ // Skip if in comment
166
+ const commentIndex = lineText.indexOf('//');
167
+ if (commentIndex !== -1 && character > commentIndex) {
168
+ return null;
169
+ }
170
+ // Skip if in string literal (between quotes)
171
+ let inString = false;
172
+ let stringChar = '';
173
+ for (let i = 0; i < character; i++) {
174
+ if ((lineText[i] === '"' || lineText[i] === "'") && lineText[i - 1] !== '\\') {
175
+ if (!inString) {
176
+ inString = true;
177
+ stringChar = lineText[i];
178
+ }
179
+ else if (lineText[i] === stringChar) {
180
+ inString = false;
181
+ }
182
+ }
183
+ }
184
+ if (inString) {
185
+ return null;
186
+ }
187
+ // Extract word boundaries
188
+ let start = character;
189
+ while (start > 0 && /[a-zA-Z0-9_]/.test(lineText[start - 1])) {
190
+ start--;
191
+ }
192
+ let end = character;
193
+ while (end < lineText.length && /[a-zA-Z0-9_]/.test(lineText[end])) {
194
+ end++;
195
+ }
196
+ if (start === end) {
197
+ return null;
198
+ }
199
+ const token = lineText.substring(start, end);
200
+ return { token, startChar: start, endChar: end };
201
+ }
202
+ /**
203
+ * Check if a position is inside a component reference
204
+ * Pattern: component SomeComponent (with optional properties after)
205
+ */
206
+ function isComponentReference(text, line, character) {
207
+ const lines = text.split('\n');
208
+ if (line >= lines.length) {
209
+ return false;
210
+ }
211
+ const lineText = lines[line];
212
+ // Skip if in comment
213
+ const commentIndex = lineText.indexOf('//');
214
+ if (commentIndex !== -1 && character > commentIndex) {
215
+ return false;
216
+ }
217
+ // Check if this line contains 'component' keyword
218
+ const componentIndex = lineText.indexOf('component');
219
+ if (componentIndex === -1) {
220
+ return false;
221
+ }
222
+ // Check if cursor is after the 'component' keyword
223
+ const componentKeywordEnd = componentIndex + 'component'.length;
224
+ if (character <= componentKeywordEnd) {
225
+ return false;
226
+ }
227
+ // Extract component name from after 'component' keyword
228
+ const afterComponent = lineText.substring(componentKeywordEnd).trimStart();
229
+ const componentNameMatch = afterComponent.match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);
230
+ if (!componentNameMatch) {
231
+ return false;
232
+ }
233
+ // Calculate position of component name in original line
234
+ const nameStartInSubstring = lineText.substring(componentKeywordEnd).indexOf(componentNameMatch[1]);
235
+ const nameStart = componentKeywordEnd + nameStartInSubstring;
236
+ const nameEnd = nameStart + componentNameMatch[1].length;
237
+ // Check if cursor is within or just after the component name
238
+ return character >= nameStart && character <= nameEnd;
239
+ }
240
+ /**
241
+ * Extract all component references (usages) from the document
242
+ * Returns array of { name, line, character }
243
+ */
244
+ function extractComponentReferences(text) {
245
+ const references = [];
246
+ const lines = text.split('\n');
247
+ lines.forEach((lineText, lineNum) => {
248
+ // Match: component SomeName (not inside quotes)
249
+ const regex = /component\s+([a-zA-Z_][a-zA-Z0-9_]*)/g;
250
+ let match;
251
+ while ((match = regex.exec(lineText)) !== null) {
252
+ const componentName = match[1];
253
+ const character = match.index + 'component'.length + 1;
254
+ references.push({
255
+ name: componentName,
256
+ line: lineNum,
257
+ character: character,
258
+ });
259
+ }
260
+ });
261
+ return references;
262
+ }
263
+ /**
264
+ * Extract all screen definitions from document text
265
+ * Syntax: screen ScreenName { ... }
266
+ */
267
+ function extractScreenDefinitions(text) {
268
+ const definitions = [];
269
+ const regex = /screen\s+([a-zA-Z_][a-zA-Z0-9_]*)/gm;
270
+ let match;
271
+ while ((match = regex.exec(text)) !== null) {
272
+ const screenName = match[1];
273
+ const matchIndex = match.index;
274
+ const lineNumber = text.substring(0, matchIndex).split('\n').length - 1;
275
+ const lastLineBreak = text.lastIndexOf('\n', matchIndex);
276
+ const character = matchIndex - (lastLineBreak + 1);
277
+ definitions.push({
278
+ name: screenName,
279
+ line: lineNumber,
280
+ character: character,
281
+ endLine: lineNumber,
282
+ });
283
+ }
284
+ return definitions;
285
+ }
286
+ /**
287
+ * Find the definition position of a component, screen, or layout
288
+ */
289
+ function getPositionOfDefinition(text, name) {
290
+ // First check component definitions
291
+ const componentDefs = extractComponentDefinitions(text);
292
+ const componentDef = componentDefs.find((def) => def.name === name);
293
+ if (componentDef) {
294
+ return { line: componentDef.line, character: componentDef.character };
295
+ }
296
+ // Then check screen definitions
297
+ const screenDefs = extractScreenDefinitions(text);
298
+ const screenDef = screenDefs.find((def) => def.name === name);
299
+ if (screenDef) {
300
+ return { line: screenDef.line, character: screenDef.character };
301
+ }
302
+ // Then check layout definitions
303
+ const layoutDefs = extractLayoutDefinitions(text);
304
+ const layoutDef = layoutDefs.find((def) => def.name === name);
305
+ if (layoutDef) {
306
+ return { line: layoutDef.line, character: layoutDef.character };
307
+ }
308
+ return null;
309
+ }
310
+ /**
311
+ * Find all references to a component or screen
312
+ */
313
+ function findComponentReferences(text, name) {
314
+ const references = extractComponentReferences(text);
315
+ const screenReferences = extractScreenDefinitions(text).filter((s) => s.name === name);
316
+ const layoutDefinitions = extractLayoutDefinitions(text).filter((l) => l.name === name);
317
+ return [
318
+ ...references.filter((ref) => ref.name === name).map((ref) => ({ line: ref.line, character: ref.character })),
319
+ ...screenReferences.map((def) => ({ line: def.line, character: def.character })),
320
+ ...layoutDefinitions.map((def) => ({ line: def.line, character: def.character })),
321
+ ];
322
+ }
323
+ //# sourceMappingURL=document-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-parser.js","sourceRoot":"","sources":["../src/document-parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA0BH,kEA8GC;AAMD,4DAwCC;AAMD,gDAsDC;AAMD,oDA0CC;AAMD,gEAiCC;AAMD,4DAsBC;AAKD,0DAuBC;AAKD,0DAaC;AA9XD;;;;GAIG;AACH,SAAgB,2BAA2B,CAAC,IAAY;IACtD,MAAM,WAAW,GAA0B,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,mDAAmD;IACnD,MAAM,KAAK,GAAG,kCAAkC,CAAC;IACjD,IAAI,KAAK,CAAC;IAEV,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC3C,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAE/B,wCAAwC;QACxC,MAAM,UAAU,GAAG,IAAI,CAAC,SA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AAC,SAAS,EAAE,CAAC,CAAC;QAC7G,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;QAChF,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;KAClF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ /**
3
+ * Wire DSL Documentation Data
4
+ * Provides detailed hover documentation for components, layouts, and properties
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DOCUMENTATION = void 0;
8
+ exports.getComponentDocumentation = getComponentDocumentation;
9
+ exports.getLayoutDocumentation = getLayoutDocumentation;
10
+ exports.getPropertyDocumentation = getPropertyDocumentation;
11
+ exports.getKeywordDocumentation = getKeywordDocumentation;
12
+ const components_js_1 = require("./components.js");
13
+ /**
14
+ * Generate markdown documentation for a component
15
+ */
16
+ function getComponentDocumentation(componentName) {
17
+ const component = components_js_1.COMPONENTS[componentName];
18
+ if (!component)
19
+ return null;
20
+ let doc = `## ${component.name}\n\n`;
21
+ doc += `${component.description}\n\n`;
22
+ const properties = Object.values(component.properties);
23
+ if (properties.length > 0) {
24
+ doc += `**Properties:**\n`;
25
+ properties.forEach((prop) => {
26
+ const propDoc = getPropertyDocumentation(componentName, prop.name);
27
+ const typeInfo = propDoc ? ` - ${propDoc}` : `(${prop.type})`;
28
+ doc += `- \`${prop.name}\`${typeInfo}\n`;
29
+ });
30
+ doc += '\n';
31
+ }
32
+ doc += `**Example:**\n`;
33
+ doc += `\`\`\`wire\n${component.example}\n\`\`\``;
34
+ return doc;
35
+ }
36
+ /**
37
+ * Generate markdown documentation for a layout
38
+ */
39
+ function getLayoutDocumentation(layoutName) {
40
+ const layout = components_js_1.LAYOUTS[layoutName];
41
+ if (!layout)
42
+ return null;
43
+ let doc = `## ${layout.name.toUpperCase()} Layout\n\n`;
44
+ doc += `${layout.description}\n\n`;
45
+ const properties = Object.values(layout.properties);
46
+ if (properties.length > 0) {
47
+ doc += `**Properties:**\n`;
48
+ properties.forEach((prop) => {
49
+ const values = prop.options;
50
+ const valuesInfo = values ? ` - Values: \`${values.join(' | ')}\`` : `(${prop.type})`;
51
+ doc += `- \`${prop.name}\`${valuesInfo}\n`;
52
+ });
53
+ doc += '\n';
54
+ }
55
+ if (layout.requiredProperties && layout.requiredProperties.length > 0) {
56
+ doc += `**Required:**\n`;
57
+ doc += `${layout.requiredProperties.map((p) => `\`${p}\``).join(', ')}\n\n`;
58
+ }
59
+ doc += `**Example:**\n`;
60
+ doc += `\`\`\`wire\n${layout.example}\n\`\`\``;
61
+ return doc;
62
+ }
63
+ /**
64
+ * Get documentation for a specific property of a component
65
+ */
66
+ function getPropertyDocumentation(componentName, propertyName) {
67
+ const component = components_js_1.COMPONENTS[componentName];
68
+ if (!component)
69
+ return null;
70
+ const propDef = component.properties[propertyName];
71
+ if (!propDef)
72
+ return null;
73
+ // Check if property has enum values
74
+ if (propDef.type === 'enum' && propDef.options) {
75
+ return `Values: \`${propDef.options.join(' | ')}\``;
76
+ }
77
+ // Return generic property documentation based on name
78
+ const propertyDocs = {
79
+ text: 'Text content (string)',
80
+ content: 'Text content (string)',
81
+ title: 'Title text (string)',
82
+ label: 'Label text (string)',
83
+ placeholder: 'Placeholder text (string)',
84
+ icon: 'Icon name (string)',
85
+ avatar: 'Enable avatar display (`true`/`false`)',
86
+ visible: 'Show/hide component (`true`/`false`)',
87
+ type: 'Type identifier (string)',
88
+ variant: 'Visual variant style',
89
+ size: 'Component size',
90
+ height: 'Height in pixels (number)',
91
+ rows: 'Number of rows (number)',
92
+ items: 'Comma-separated items (string)',
93
+ columns: 'Table: CSV column names (string) / Grid: number of columns',
94
+ gap: 'Spacing between items',
95
+ padding: 'Internal padding',
96
+ spacing: 'Spacing token (`none|xs|sm|md|lg|xl`)',
97
+ value: 'Display value (string/number)',
98
+ };
99
+ return propertyDocs[propertyName] || null;
100
+ }
101
+ /**
102
+ * Get documentation for a keyword
103
+ */
104
+ function getKeywordDocumentation(keyword) {
105
+ const keywordDocs = {
106
+ project: 'Define a Wire DSL project with screens and design tokens',
107
+ screen: 'Define a screen/page in the project',
108
+ layout: 'Define a layout container (stack, grid, split, panel, card)',
109
+ component: 'Place a UI component instance',
110
+ cell: 'Define a cell within a grid layout',
111
+ define: 'Define a reusable custom component (define Component "Name" { ... })',
112
+ Component: 'Keyword for defining custom components',
113
+ style: 'Configure global style tokens (density, spacing, radius, stroke, font, background, theme, device)',
114
+ colors: 'Define project color tokens (e.g. variants `primary`, `danger` and semantic tokens `accent`, `control`, `chart`)',
115
+ mocks: 'Define mock data for components',
116
+ stack: 'Stack layout - arrange items in row or column',
117
+ grid: 'Grid layout - 12-column flexible grid',
118
+ split: 'Split layout - sidebar + main content',
119
+ panel: 'Panel layout - container with border and padding',
120
+ card: 'Card layout - flexible vertical container',
121
+ };
122
+ return keywordDocs[keyword] || null;
123
+ }
124
+ /**
125
+ * All documentation data indexed by type
126
+ */
127
+ exports.DOCUMENTATION = {
128
+ getComponentDocumentation,
129
+ getLayoutDocumentation,
130
+ getPropertyDocumentation,
131
+ getKeywordDocumentation,
132
+ };
133
+ //# sourceMappingURL=documentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentation.js","sourceRoot":"","sources":["../src/documentation.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,8DAsBC;AAKD,wDA2BC;AAKD,4DAoCC;AAKD,0DAqBC;AA9HD,mDAAsD;AAEtD;;GAEG;AACH,SAAgB,yBAAyB,CAAC,aAAqB;IAC7D,MAAM,SAAS,GAAG,0BAAU,CAAC,aAAwC,CAAC,CAAC;IACvE,IAAI,CAAC,SAAS;QA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