@wire-dsl/language-support 0.0.2
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/INTEGRATION-GUIDE.md +218 -0
- package/LICENSE +36 -0
- package/README.md +55 -0
- package/dist/completions.d.ts +86 -0
- package/dist/completions.d.ts.map +1 -0
- package/dist/completions.js +416 -0
- package/dist/completions.js.map +1 -0
- package/dist/components.d.ts +39 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +271 -0
- package/dist/components.js.map +1 -0
- package/dist/context-detection.d.ts +56 -0
- package/dist/context-detection.d.ts.map +1 -0
- package/dist/context-detection.js +147 -0
- package/dist/context-detection.js.map +1 -0
- package/dist/document-parser.d.ts +63 -0
- package/dist/document-parser.d.ts.map +1 -0
- package/dist/document-parser.js +264 -0
- package/dist/document-parser.js.map +1 -0
- package/dist/documentation.d.ts +30 -0
- package/dist/documentation.d.ts.map +1 -0
- package/dist/documentation.js +121 -0
- package/dist/documentation.js.map +1 -0
- package/dist/generate-grammar.d.ts +28 -0
- package/dist/generate-grammar.d.ts.map +1 -0
- package/dist/generate-grammar.js +136 -0
- package/dist/generate-grammar.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Document Parser
|
|
3
|
+
* Extracts component definitions and references from Wire DSL documents
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Extract all component definitions from document text
|
|
7
|
+
* Syntax: define Component "ComponentName" { ... }
|
|
8
|
+
* Supports documentation via block comments before the definition
|
|
9
|
+
*/
|
|
10
|
+
export function extractComponentDefinitions(text) {
|
|
11
|
+
const definitions = [];
|
|
12
|
+
const lines = text.split('\n');
|
|
13
|
+
// Regex to match: define Component "ComponentName"
|
|
14
|
+
const regex = /define\s+Component\s+"([^"]+)"/gm;
|
|
15
|
+
let match;
|
|
16
|
+
while ((match = regex.exec(text)) !== null) {
|
|
17
|
+
const componentName = match[1];
|
|
18
|
+
const matchIndex = match.index;
|
|
19
|
+
// Calculate line and character position
|
|
20
|
+
const lineNumber = text.substring(0, matchIndex).split('\n').length - 1;
|
|
21
|
+
const lastLineBreak = text.lastIndexOf('\n', matchIndex);
|
|
22
|
+
const character = matchIndex - (lastLineBreak + 1);
|
|
23
|
+
// Find end line by locating the closing brace
|
|
24
|
+
const afterName = matchIndex + match[0].length;
|
|
25
|
+
let braceCount = 0;
|
|
26
|
+
let foundOpening = false;
|
|
27
|
+
let endLine = lineNumber;
|
|
28
|
+
for (let i = afterName; i < text.length; i++) {
|
|
29
|
+
const char = text[i];
|
|
30
|
+
if (char === '{') {
|
|
31
|
+
braceCount++;
|
|
32
|
+
foundOpening = true;
|
|
33
|
+
}
|
|
34
|
+
else if (char === '}') {
|
|
35
|
+
braceCount--;
|
|
36
|
+
if (foundOpening && braceCount === 0) {
|
|
37
|
+
// Found the closing brace
|
|
38
|
+
endLine = text.substring(0, i).split('\n').length - 1;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Extract documentation from block comments before the definition
|
|
44
|
+
let documentation;
|
|
45
|
+
if (lineNumber > 0) {
|
|
46
|
+
// Look backwards for /* ... */ block comment immediately before the definition
|
|
47
|
+
let currentLine = lineNumber - 1;
|
|
48
|
+
// Skip empty lines
|
|
49
|
+
while (currentLine >= 0 && lines[currentLine].trim() === '') {
|
|
50
|
+
currentLine--;
|
|
51
|
+
}
|
|
52
|
+
if (currentLine >= 0) {
|
|
53
|
+
const prevLine = lines[currentLine];
|
|
54
|
+
const prevTrimmed = prevLine.trim();
|
|
55
|
+
// Check if the previous line contains the end of a block comment
|
|
56
|
+
if (prevTrimmed.endsWith('*/')) {
|
|
57
|
+
// Find the start of the block comment
|
|
58
|
+
let blockStart = currentLine;
|
|
59
|
+
let foundStart = false;
|
|
60
|
+
// Look backwards for /*
|
|
61
|
+
for (let i = currentLine; i >= 0; i--) {
|
|
62
|
+
const lineText = lines[i];
|
|
63
|
+
if (lineText.includes('/*')) {
|
|
64
|
+
blockStart = i;
|
|
65
|
+
foundStart = true;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (foundStart) {
|
|
70
|
+
// Extract the block comment content
|
|
71
|
+
const commentLines = [];
|
|
72
|
+
for (let i = blockStart; i <= currentLine; i++) {
|
|
73
|
+
let lineText = lines[i].trim();
|
|
74
|
+
// Remove /* from the beginning and */ from the end
|
|
75
|
+
if (i === blockStart) {
|
|
76
|
+
lineText = lineText.replace(/^\/\*\s*/, '');
|
|
77
|
+
}
|
|
78
|
+
if (i === currentLine) {
|
|
79
|
+
lineText = lineText.replace(/\s*\*\/$/, '');
|
|
80
|
+
}
|
|
81
|
+
// Remove leading * from continuation lines
|
|
82
|
+
lineText = lineText.replace(/^\*\s*/, '');
|
|
83
|
+
if (lineText) {
|
|
84
|
+
commentLines.push(lineText);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (commentLines.length > 0) {
|
|
88
|
+
documentation = commentLines.join('\n');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
definitions.push({
|
|
95
|
+
name: componentName,
|
|
96
|
+
line: lineNumber,
|
|
97
|
+
character: character,
|
|
98
|
+
endLine: endLine,
|
|
99
|
+
documentation,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return definitions;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get the token at a specific position in the document
|
|
106
|
+
* Returns the word and its range
|
|
107
|
+
*/
|
|
108
|
+
export function getTokenAtPosition(text, line, character) {
|
|
109
|
+
const lines = text.split('\n');
|
|
110
|
+
if (line >= lines.length) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const lineText = lines[line];
|
|
114
|
+
// Skip if in comment
|
|
115
|
+
const commentIndex = lineText.indexOf('//');
|
|
116
|
+
if (commentIndex !== -1 && character > commentIndex) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
// Skip if in string literal (between quotes)
|
|
120
|
+
let inString = false;
|
|
121
|
+
let stringChar = '';
|
|
122
|
+
for (let i = 0; i < character; i++) {
|
|
123
|
+
if ((lineText[i] === '"' || lineText[i] === "'") && lineText[i - 1] !== '\\') {
|
|
124
|
+
if (!inString) {
|
|
125
|
+
inString = true;
|
|
126
|
+
stringChar = lineText[i];
|
|
127
|
+
}
|
|
128
|
+
else if (lineText[i] === stringChar) {
|
|
129
|
+
inString = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (inString) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
// Extract word boundaries
|
|
137
|
+
let start = character;
|
|
138
|
+
while (start > 0 && /[a-zA-Z0-9_]/.test(lineText[start - 1])) {
|
|
139
|
+
start--;
|
|
140
|
+
}
|
|
141
|
+
let end = character;
|
|
142
|
+
while (end < lineText.length && /[a-zA-Z0-9_]/.test(lineText[end])) {
|
|
143
|
+
end++;
|
|
144
|
+
}
|
|
145
|
+
if (start === end) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const token = lineText.substring(start, end);
|
|
149
|
+
return { token, startChar: start, endChar: end };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Check if a position is inside a component reference
|
|
153
|
+
* Pattern: component SomeComponent (with optional properties after)
|
|
154
|
+
*/
|
|
155
|
+
export function isComponentReference(text, line, character) {
|
|
156
|
+
const lines = text.split('\n');
|
|
157
|
+
if (line >= lines.length) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const lineText = lines[line];
|
|
161
|
+
// Skip if in comment
|
|
162
|
+
const commentIndex = lineText.indexOf('//');
|
|
163
|
+
if (commentIndex !== -1 && character > commentIndex) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
// Check if this line contains 'component' keyword
|
|
167
|
+
const componentIndex = lineText.indexOf('component');
|
|
168
|
+
if (componentIndex === -1) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
// Check if cursor is after the 'component' keyword
|
|
172
|
+
const componentKeywordEnd = componentIndex + 'component'.length;
|
|
173
|
+
if (character <= componentKeywordEnd) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
// Extract component name from after 'component' keyword
|
|
177
|
+
const afterComponent = lineText.substring(componentKeywordEnd).trimStart();
|
|
178
|
+
const componentNameMatch = afterComponent.match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
179
|
+
if (!componentNameMatch) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
// Calculate position of component name in original line
|
|
183
|
+
const nameStartInSubstring = lineText.substring(componentKeywordEnd).indexOf(componentNameMatch[1]);
|
|
184
|
+
const nameStart = componentKeywordEnd + nameStartInSubstring;
|
|
185
|
+
const nameEnd = nameStart + componentNameMatch[1].length;
|
|
186
|
+
// Check if cursor is within or just after the component name
|
|
187
|
+
return character >= nameStart && character <= nameEnd;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Extract all component references (usages) from the document
|
|
191
|
+
* Returns array of { name, line, character }
|
|
192
|
+
*/
|
|
193
|
+
export function extractComponentReferences(text) {
|
|
194
|
+
const references = [];
|
|
195
|
+
const lines = text.split('\n');
|
|
196
|
+
lines.forEach((lineText, lineNum) => {
|
|
197
|
+
// Match: component SomeName (not inside quotes)
|
|
198
|
+
const regex = /component\s+([a-zA-Z_][a-zA-Z0-9_]*)/g;
|
|
199
|
+
let match;
|
|
200
|
+
while ((match = regex.exec(lineText)) !== null) {
|
|
201
|
+
const componentName = match[1];
|
|
202
|
+
const character = match.index + 'component'.length + 1;
|
|
203
|
+
references.push({
|
|
204
|
+
name: componentName,
|
|
205
|
+
line: lineNum,
|
|
206
|
+
character: character,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return references;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Extract all screen definitions from document text
|
|
214
|
+
* Syntax: screen ScreenName { ... }
|
|
215
|
+
*/
|
|
216
|
+
export function extractScreenDefinitions(text) {
|
|
217
|
+
const definitions = [];
|
|
218
|
+
const regex = /screen\s+([a-zA-Z_][a-zA-Z0-9_]*)/gm;
|
|
219
|
+
let match;
|
|
220
|
+
while ((match = regex.exec(text)) !== null) {
|
|
221
|
+
const screenName = match[1];
|
|
222
|
+
const matchIndex = match.index;
|
|
223
|
+
const lineNumber = text.substring(0, matchIndex).split('\n').length - 1;
|
|
224
|
+
const lastLineBreak = text.lastIndexOf('\n', matchIndex);
|
|
225
|
+
const character = matchIndex - (lastLineBreak + 1);
|
|
226
|
+
definitions.push({
|
|
227
|
+
name: screenName,
|
|
228
|
+
line: lineNumber,
|
|
229
|
+
character: character,
|
|
230
|
+
endLine: lineNumber,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return definitions;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Find the definition position of a component, screen, or layout
|
|
237
|
+
*/
|
|
238
|
+
export function getPositionOfDefinition(text, name) {
|
|
239
|
+
// First check component definitions
|
|
240
|
+
const componentDefs = extractComponentDefinitions(text);
|
|
241
|
+
const componentDef = componentDefs.find((def) => def.name === name);
|
|
242
|
+
if (componentDef) {
|
|
243
|
+
return { line: componentDef.line, character: componentDef.character };
|
|
244
|
+
}
|
|
245
|
+
// Then check screen definitions
|
|
246
|
+
const screenDefs = extractScreenDefinitions(text);
|
|
247
|
+
const screenDef = screenDefs.find((def) => def.name === name);
|
|
248
|
+
if (screenDef) {
|
|
249
|
+
return { line: screenDef.line, character: screenDef.character };
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Find all references to a component or screen
|
|
255
|
+
*/
|
|
256
|
+
export function findComponentReferences(text, name) {
|
|
257
|
+
const references = extractComponentReferences(text);
|
|
258
|
+
const screenReferences = extractScreenDefinitions(text).filter((s) => s.name === name);
|
|
259
|
+
return [
|
|
260
|
+
...references.filter((ref) => ref.name === name).map((ref) => ({ line: ref.line, character: ref.character })),
|
|
261
|
+
...screenReferences.map((def) => ({ line: def.line, character: def.character })),
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
//# 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;AAaH;;;;GAIG;AACH,MAAM,UAAU,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,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACxE,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACzD,MAAM,SAAS,GAAG,UAAU,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;QAEnD,8CAA8C;QAC9C,MAAM,SAAS,GAAG,UAAU,GAAG,KAAK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G,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,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;KACjF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Documentation Data
|
|
3
|
+
* Provides detailed hover documentation for components, layouts, and properties
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate markdown documentation for a component
|
|
7
|
+
*/
|
|
8
|
+
export declare function getComponentDocumentation(componentName: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Generate markdown documentation for a layout
|
|
11
|
+
*/
|
|
12
|
+
export declare function getLayoutDocumentation(layoutName: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Get documentation for a specific property of a component
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPropertyDocumentation(componentName: string, propertyName: string): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Get documentation for a keyword
|
|
19
|
+
*/
|
|
20
|
+
export declare function getKeywordDocumentation(keyword: string): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* All documentation data indexed by type
|
|
23
|
+
*/
|
|
24
|
+
export declare const DOCUMENTATION: {
|
|
25
|
+
getComponentDocumentation: typeof getComponentDocumentation;
|
|
26
|
+
getLayoutDocumentation: typeof getLayoutDocumentation;
|
|
27
|
+
getPropertyDocumentation: typeof getPropertyDocumentation;
|
|
28
|
+
getKeywordDocumentation: typeof getKeywordDocumentation;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=documentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation.d.ts","sourceRoot":"","sources":["../src/documentation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqB9E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0BxE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiCnG;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBtE;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Documentation Data
|
|
3
|
+
* Provides detailed hover documentation for components, layouts, and properties
|
|
4
|
+
*/
|
|
5
|
+
import { COMPONENTS, LAYOUTS, PROPERTY_VALUES } from './components';
|
|
6
|
+
/**
|
|
7
|
+
* Generate markdown documentation for a component
|
|
8
|
+
*/
|
|
9
|
+
export function getComponentDocumentation(componentName) {
|
|
10
|
+
const component = COMPONENTS[componentName];
|
|
11
|
+
if (!component)
|
|
12
|
+
return null;
|
|
13
|
+
let doc = `## ${component.name}\n\n`;
|
|
14
|
+
doc += `${component.description}\n\n`;
|
|
15
|
+
if (component.properties.length > 0) {
|
|
16
|
+
doc += `**Properties:**\n`;
|
|
17
|
+
component.properties.forEach((prop) => {
|
|
18
|
+
const propDoc = getPropertyDocumentation(componentName, prop);
|
|
19
|
+
const typeInfo = propDoc ? ` - ${propDoc}` : '';
|
|
20
|
+
doc += `- \`${prop}\`${typeInfo}\n`;
|
|
21
|
+
});
|
|
22
|
+
doc += '\n';
|
|
23
|
+
}
|
|
24
|
+
doc += `**Example:**\n`;
|
|
25
|
+
doc += `\`\`\`wire\n${component.example}\n\`\`\``;
|
|
26
|
+
return doc;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate markdown documentation for a layout
|
|
30
|
+
*/
|
|
31
|
+
export function getLayoutDocumentation(layoutName) {
|
|
32
|
+
const layout = LAYOUTS[layoutName];
|
|
33
|
+
if (!layout)
|
|
34
|
+
return null;
|
|
35
|
+
let doc = `## ${layout.name.toUpperCase()} Layout\n\n`;
|
|
36
|
+
doc += `${layout.description}\n\n`;
|
|
37
|
+
if (layout.properties.length > 0) {
|
|
38
|
+
doc += `**Properties:**\n`;
|
|
39
|
+
layout.properties.forEach((prop) => {
|
|
40
|
+
const values = PROPERTY_VALUES[prop];
|
|
41
|
+
const valuesInfo = values ? ` - Values: \`${values.join(' | ')}\`` : '';
|
|
42
|
+
doc += `- \`${prop}\`${valuesInfo}\n`;
|
|
43
|
+
});
|
|
44
|
+
doc += '\n';
|
|
45
|
+
}
|
|
46
|
+
if (layout.requiredProperties && layout.requiredProperties.length > 0) {
|
|
47
|
+
doc += `**Required:**\n`;
|
|
48
|
+
doc += `${layout.requiredProperties.map((p) => `\`${p}\``).join(', ')}\n\n`;
|
|
49
|
+
}
|
|
50
|
+
doc += `**Example:**\n`;
|
|
51
|
+
doc += `\`\`\`wire\n${layout.example}\n\`\`\``;
|
|
52
|
+
return doc;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get documentation for a specific property of a component
|
|
56
|
+
*/
|
|
57
|
+
export function getPropertyDocumentation(componentName, propertyName) {
|
|
58
|
+
const component = COMPONENTS[componentName];
|
|
59
|
+
if (!component)
|
|
60
|
+
return null;
|
|
61
|
+
if (!component.properties.includes(propertyName))
|
|
62
|
+
return null;
|
|
63
|
+
// Check if property has enum values
|
|
64
|
+
if (component.propertyValues && component.propertyValues[propertyName]) {
|
|
65
|
+
const values = component.propertyValues[propertyName];
|
|
66
|
+
return `Values: \`${values.join(' | ')}\``;
|
|
67
|
+
}
|
|
68
|
+
// Return generic property documentation based on name
|
|
69
|
+
const propertyDocs = {
|
|
70
|
+
text: 'Text content (string)',
|
|
71
|
+
content: 'Text content (string)',
|
|
72
|
+
title: 'Title text (string)',
|
|
73
|
+
label: 'Label text (string)',
|
|
74
|
+
placeholder: 'Placeholder text (string)',
|
|
75
|
+
icon: 'Icon name (string)',
|
|
76
|
+
type: 'Icon type (string)',
|
|
77
|
+
variant: 'Visual variant style',
|
|
78
|
+
size: 'Component size',
|
|
79
|
+
height: 'Height in pixels (number)',
|
|
80
|
+
rows: 'Number of rows (number)',
|
|
81
|
+
items: 'List of items (array)',
|
|
82
|
+
columns: 'Number of columns (number)',
|
|
83
|
+
gap: 'Spacing between items',
|
|
84
|
+
padding: 'Internal padding',
|
|
85
|
+
value: 'Display value (string/number)',
|
|
86
|
+
};
|
|
87
|
+
return propertyDocs[propertyName] || null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get documentation for a keyword
|
|
91
|
+
*/
|
|
92
|
+
export function getKeywordDocumentation(keyword) {
|
|
93
|
+
const keywordDocs = {
|
|
94
|
+
project: 'Define a Wire DSL project with screens and design tokens',
|
|
95
|
+
screen: 'Define a screen/page in the project',
|
|
96
|
+
layout: 'Define a layout container (stack, grid, split, panel, card)',
|
|
97
|
+
component: 'Place a UI component instance',
|
|
98
|
+
cell: 'Define a cell within a grid layout',
|
|
99
|
+
define: 'Define a reusable custom component (define Component "Name" { ... })',
|
|
100
|
+
Component: 'Keyword for defining custom components',
|
|
101
|
+
theme: 'Configure design tokens (density, spacing, radius, stroke, font)',
|
|
102
|
+
colors: 'Define custom color values',
|
|
103
|
+
mocks: 'Define mock data for components',
|
|
104
|
+
stack: 'Stack layout - arrange items in row or column',
|
|
105
|
+
grid: 'Grid layout - 12-column flexible grid',
|
|
106
|
+
split: 'Split layout - sidebar + main content',
|
|
107
|
+
panel: 'Panel layout - container with border and padding',
|
|
108
|
+
card: 'Card layout - flexible vertical container',
|
|
109
|
+
};
|
|
110
|
+
return keywordDocs[keyword] || null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* All documentation data indexed by type
|
|
114
|
+
*/
|
|
115
|
+
export const DOCUMENTATION = {
|
|
116
|
+
getComponentDocumentation,
|
|
117
|
+
getLayoutDocumentation,
|
|
118
|
+
getPropertyDocumentation,
|
|
119
|
+
getKeywordDocumentation,
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=documentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation.js","sourceRoot":"","sources":["../src/documentation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,aAAqB;IAC7D,MAAM,SAAS,GAAG,UAAU,CAAC,aAAwC,CAAC,CAAC;IACvE,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,IAAI,GAAG,GAAG,MAAM,SAAS,CAAC,IAAI,MAAM,CAAC;IACrC,GAAG,IAAI,GAAG,SAAS,CAAC,WAAW,MAAM,CAAC;IAEtC,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,GAAG,IAAI,mBAAmB,CAAC;QAC3B,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACpC,MAAM,OAAO,GAAG,wBAAwB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,GAAG,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC;QACtC,CAAC,CAAC,CAAC;QACH,GAAG,IAA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,OAAO,EAAE,0DAA0D;QACnE,MAAM,EAAE,qCAAqC;QAC7C,MAAM,EAAE,6DAA6D;QACrE,SAAS,EAAE,+BAA+B;QAC1C,IAAI,EAAE,oCAAoC;QAC1C,MAAM,EAAE,sEAAsE;QAC9E,SAAS,EAAE,wCAAwC;QACnD,KAAK,EAAE,kEAAkE;QACzE,MAAM,EAAE,4BAA4B;QACpC,KAAK,EAAE,iCAAiC;QACxC,KAAK,EAAE,+CAA+C;QACtD,IAAI,EAAE,uCAAuC;QAC7C,KAAK,EAAE,uCAAuC;QAC9C,KAAK,EAAE,kDAAkD;QACzD,IAAI,EAAE,2CAA2C;KAClD,CAAC;IAEF,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,yBAAyB;IACzB,sBAAsB;IACtB,wBAAwB;IACxB,uBAAuB;CACxB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generador de gramática TextMate para Wire DSL
|
|
3
|
+
* Genera automáticamente wire.tmLanguage.json desde language-support
|
|
4
|
+
*/
|
|
5
|
+
interface TextMateGrammar {
|
|
6
|
+
$schema: string;
|
|
7
|
+
name: string;
|
|
8
|
+
patterns: Array<{
|
|
9
|
+
name?: string;
|
|
10
|
+
match?: string;
|
|
11
|
+
include?: string;
|
|
12
|
+
begin?: string;
|
|
13
|
+
end?: string;
|
|
14
|
+
patterns?: Array<any>;
|
|
15
|
+
}>;
|
|
16
|
+
repository: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
export declare function generateGrammar(): TextMateGrammar;
|
|
19
|
+
/**
|
|
20
|
+
* Escribe la gramática generada a un archivo
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeGrammar(outputPath: string): void;
|
|
23
|
+
declare const _default: {
|
|
24
|
+
generateGrammar: typeof generateGrammar;
|
|
25
|
+
writeGrammar: typeof writeGrammar;
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|
|
28
|
+
//# sourceMappingURL=generate-grammar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-grammar.d.ts","sourceRoot":"","sources":["../src/generate-grammar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;KACvB,CAAC,CAAC;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,wBAAgB,eAAe,IAAI,eAAe,CAkHjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAKrD;;;;;AAWD,wBAAiD"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generador de gramática TextMate para Wire DSL
|
|
3
|
+
* Genera automáticamente wire.tmLanguage.json desde language-support
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { COMPONENTS, PROPERTY_VALUES } from './components.js';
|
|
8
|
+
export function generateGrammar() {
|
|
9
|
+
// Agrupar keywords por tipo
|
|
10
|
+
const keywords = ['project', 'screen', 'component', 'if', 'for', 'let', 'const', 'state', 'render'];
|
|
11
|
+
const components = Object.keys(COMPONENTS);
|
|
12
|
+
const properties = Object.keys(PROPERTY_VALUES);
|
|
13
|
+
// Crear patrones regex
|
|
14
|
+
const keywordPattern = keywords.join('|');
|
|
15
|
+
const componentPattern = components.join('|');
|
|
16
|
+
const propertyPattern = properties.join('|');
|
|
17
|
+
return {
|
|
18
|
+
$schema: 'https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json',
|
|
19
|
+
name: 'Wire DSL',
|
|
20
|
+
patterns: [
|
|
21
|
+
{ include: '#comments' },
|
|
22
|
+
{ include: '#strings' },
|
|
23
|
+
{ include: '#numbers' },
|
|
24
|
+
{ include: '#keywords' },
|
|
25
|
+
{ include: '#components' },
|
|
26
|
+
{ include: '#properties' },
|
|
27
|
+
{ include: '#operators' },
|
|
28
|
+
{ include: '#punctuation' },
|
|
29
|
+
],
|
|
30
|
+
repository: {
|
|
31
|
+
comments: {
|
|
32
|
+
patterns: [
|
|
33
|
+
{
|
|
34
|
+
name: 'comment.line.double-slash.wire',
|
|
35
|
+
match: '//.*?$',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'comment.block.wire',
|
|
39
|
+
begin: '/\\*',
|
|
40
|
+
end: '\\*/',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
strings: {
|
|
45
|
+
patterns: [
|
|
46
|
+
{
|
|
47
|
+
name: 'string.quoted.double.wire',
|
|
48
|
+
begin: '"',
|
|
49
|
+
end: '"',
|
|
50
|
+
patterns: [
|
|
51
|
+
{
|
|
52
|
+
name: 'constant.character.escape.wire',
|
|
53
|
+
match: '\\\\.',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'string.quoted.single.wire',
|
|
59
|
+
begin: "'",
|
|
60
|
+
end: "'",
|
|
61
|
+
patterns: [
|
|
62
|
+
{
|
|
63
|
+
name: 'constant.character.escape.wire',
|
|
64
|
+
match: '\\\\.',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
numbers: {
|
|
71
|
+
patterns: [
|
|
72
|
+
{
|
|
73
|
+
name: 'constant.numeric.wire',
|
|
74
|
+
match: '\\b\\d+(\\.\\d+)?\\b',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
keywords: {
|
|
79
|
+
patterns: [
|
|
80
|
+
{
|
|
81
|
+
name: 'keyword.wire',
|
|
82
|
+
match: `\\b(${keywordPattern})\\b`,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
components: {
|
|
87
|
+
patterns: [
|
|
88
|
+
{
|
|
89
|
+
name: 'entity.name.class.wire',
|
|
90
|
+
match: `\\b(${componentPattern})\\b`,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
properties: {
|
|
95
|
+
patterns: [
|
|
96
|
+
{
|
|
97
|
+
name: 'variable.other.property.wire',
|
|
98
|
+
match: `\\b(${propertyPattern})(?=\\s*:)`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
operators: {
|
|
103
|
+
patterns: [
|
|
104
|
+
{
|
|
105
|
+
name: 'keyword.operator.wire',
|
|
106
|
+
match: '[=+\\-*/%&|^<>!]=?|[?:]',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
punctuation: {
|
|
111
|
+
patterns: [
|
|
112
|
+
{
|
|
113
|
+
name: 'punctuation.wire',
|
|
114
|
+
match: '[{}\\[\\]();,.]',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Escribe la gramática generada a un archivo
|
|
123
|
+
*/
|
|
124
|
+
export function writeGrammar(outputPath) {
|
|
125
|
+
const grammar = generateGrammar();
|
|
126
|
+
const content = JSON.stringify(grammar, null, 2);
|
|
127
|
+
fs.writeFileSync(outputPath, content);
|
|
128
|
+
console.log(`✅ Grammar generated: ${outputPath}`);
|
|
129
|
+
}
|
|
130
|
+
// Si se ejecuta directamente
|
|
131
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
132
|
+
const outputPath = path.join(path.dirname(import.meta.url.replace('file://', '')), '../wire.tmLanguage.json');
|
|
133
|
+
writeGrammar(outputPath);
|
|
134
|
+
}
|
|
135
|
+
export default { generateGrammar, writeGrammar };
|
|
136
|
+
//# sourceMappingURL=generate-grammar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-grammar.js","sourceRoot":"","sources":["../src/generate-grammar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAY,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgBxE,MAAM,UAAU,eAAe;IAC7B,4BAA4B;IAC5B,MAAM,QAAQ,GAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9G,MAAM,UAAU,GAAa,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrD,MAAM,UAAU,GAAa,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAE1D,uBAAuB;IACvB,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,gBAAgB,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE7C,OAAO;QACL,OAAO,EAAE,gFAAgF;QACzF,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,EAAE,OAAO,EAAE,WAAW,EAAE;YACxB,EAAE,OAAO,EAAE,UAAU,EAAE;YACvB,E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AAQ,EAAE;oBACR;wBACE,IAAI,EAAE,8BAA8B;wBACpC,KAAK,EAAE,OAAO,eAAe,YAAY;qBAC1C;iBACF;aACF;YACD,SAAS,EAAE;gBACT,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,uBAAuB;wBAC7B,KAAK,EAAE,yBAAyB;qBACjC;iBACF;aACF;YACD,WAAW,EAAE;gBACX,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,kBAAkB;wBACxB,KAAK,EAAE,iBAAiB;qBACzB;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,6BAA6B;AAC7B,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EACpD,yBAAyB,CAC1B,CAAC;IACF,YAAY,CAAC,UAAU,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Language Support
|
|
3
|
+
* Shared language definitions, syntax, and code intelligence for Monaco, VS Code, and other editors
|
|
4
|
+
*/
|
|
5
|
+
export { COMPONENTS, LAYOUTS, PROPERTY_VALUES, KEYWORDS, type ComponentMetadata, type LayoutMetadata, } from './components';
|
|
6
|
+
export { getComponentDocumentation, getLayoutDocumentation, getPropertyDocumentation, getKeywordDocumentation, } from './documentation';
|
|
7
|
+
export { extractComponentDefinitions, getTokenAtPosition, isComponentReference, extractComponentReferences, extractScreenDefinitions, getPositionOfDefinition, findComponentReferences, type ComponentDefinition, } from './document-parser';
|
|
8
|
+
export { determineScope, detectComponentContext, getComponentPropertiesForCompletion as getAvailableProperties, getAlreadyDeclaredProperties, type DocumentScope, type CompletionItem, } from './context-detection';
|
|
9
|
+
export { KEYWORD_COMPLETIONS, CONTAINER_COMPLETIONS, COMPONENT_COMPLETIONS, PROPERTY_COMPLETIONS, isPropertyContext, getComponentPropertiesForCompletion, getPropertyValueSuggestions, getScopeBasedCompletions, detectComponentKeyword, detectPropertyValueContext, getAvailableComponents, getComponentProperties, } from './completions';
|
|
10
|
+
export interface KeywordDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
type: 'keyword' | 'component' | 'property';
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CompletionSuggestion {
|
|
16
|
+
label: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
detail?: string;
|
|
19
|
+
documentation?: string;
|
|
20
|
+
sortText?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const ALL_KEYWORDS: KeywordDefinition[];
|
|
23
|
+
/**
|
|
24
|
+
* Get completions for a given prefix
|
|
25
|
+
* @param prefix Filter by prefix (e.g., 'but' → ['button', ...])
|
|
26
|
+
* @returns Array of completion suggestions
|
|
27
|
+
*/
|
|
28
|
+
export declare function getCompletions(prefix?: string): CompletionSuggestion[];
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH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