@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,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Component Metadata
|
|
3
|
+
* Used for autocompletion and hover documentation
|
|
4
|
+
*
|
|
5
|
+
* SYNC SOURCES:
|
|
6
|
+
* 1. Built-in components: Check packages/core/src/renderer/index.ts renderComponent() method
|
|
7
|
+
* for latest component implementations. Update this file when new components are added.
|
|
8
|
+
* 2. User-defined components: Syntax is `define Component "Name" { ... }`
|
|
9
|
+
* These are parsed and resolved before IR generation.
|
|
10
|
+
*
|
|
11
|
+
* Total components: 32 built-in + unlimited user-defined
|
|
12
|
+
* Last synced: February 2, 2026
|
|
13
|
+
*/
|
|
14
|
+
export const COMPONENTS = {
|
|
15
|
+
// Text Components
|
|
16
|
+
Heading: {
|
|
17
|
+
name: 'Heading',
|
|
18
|
+
description: 'Large heading/title text',
|
|
19
|
+
properties: ['text'],
|
|
20
|
+
example: 'component Heading text: "Users"',
|
|
21
|
+
},
|
|
22
|
+
Text: {
|
|
23
|
+
name: 'Text',
|
|
24
|
+
description: 'Regular paragraph text',
|
|
25
|
+
properties: ['content'],
|
|
26
|
+
example: 'component Text content: "Lorem ipsum dolor sit amet..."',
|
|
27
|
+
},
|
|
28
|
+
Label: {
|
|
29
|
+
name: 'Label',
|
|
30
|
+
description: 'Small label text',
|
|
31
|
+
properties: ['text'],
|
|
32
|
+
example: 'component Label text: "Field label"',
|
|
33
|
+
},
|
|
34
|
+
Code: {
|
|
35
|
+
name: 'Code',
|
|
36
|
+
description: 'Code or monospace text',
|
|
37
|
+
properties: ['content'],
|
|
38
|
+
example: 'component Code content: "const x = 42;"',
|
|
39
|
+
},
|
|
40
|
+
// Input Components
|
|
41
|
+
Input: {
|
|
42
|
+
name: 'Input',
|
|
43
|
+
description: 'Text input field',
|
|
44
|
+
properties: ['label', 'placeholder'],
|
|
45
|
+
example: 'component Input label: "Username" placeholder: "Enter name..."',
|
|
46
|
+
},
|
|
47
|
+
Textarea: {
|
|
48
|
+
name: 'Textarea',
|
|
49
|
+
description: 'Multi-line text input',
|
|
50
|
+
properties: ['label', 'placeholder', 'rows'],
|
|
51
|
+
example: 'component Textarea label: "Description" rows: 6',
|
|
52
|
+
},
|
|
53
|
+
Select: {
|
|
54
|
+
name: 'Select',
|
|
55
|
+
description: 'Dropdown selection list',
|
|
56
|
+
properties: ['label', 'options', 'placeholder'],
|
|
57
|
+
example: 'component Select label: "Role" options: ["Admin", "User", "Guest"]',
|
|
58
|
+
},
|
|
59
|
+
Checkbox: {
|
|
60
|
+
name: 'Checkbox',
|
|
61
|
+
description: 'Single checkbox input',
|
|
62
|
+
properties: ['label'],
|
|
63
|
+
example: 'component Checkbox label: "Remember me"',
|
|
64
|
+
},
|
|
65
|
+
Radio: {
|
|
66
|
+
name: 'Radio',
|
|
67
|
+
description: 'Single radio button',
|
|
68
|
+
properties: ['label'],
|
|
69
|
+
example: 'component Radio label: "Option"',
|
|
70
|
+
},
|
|
71
|
+
Toggle: {
|
|
72
|
+
name: 'Toggle',
|
|
73
|
+
description: 'Toggle switch input',
|
|
74
|
+
properties: ['label'],
|
|
75
|
+
example: 'component Toggle label: "Enable feature"',
|
|
76
|
+
},
|
|
77
|
+
// Button Components
|
|
78
|
+
Button: {
|
|
79
|
+
name: 'Button',
|
|
80
|
+
description: 'Clickable button element',
|
|
81
|
+
properties: ['text', 'variant'],
|
|
82
|
+
propertyValues: {
|
|
83
|
+
variant: ['primary', 'secondary', 'ghost'],
|
|
84
|
+
},
|
|
85
|
+
example: 'component Button text: "Save" variant: primary',
|
|
86
|
+
},
|
|
87
|
+
IconButton: {
|
|
88
|
+
name: 'IconButton',
|
|
89
|
+
description: 'Icon-only button element',
|
|
90
|
+
properties: ['icon', 'variant', 'size'],
|
|
91
|
+
propertyValues: {
|
|
92
|
+
variant: ['primary', 'secondary', 'ghost'],
|
|
93
|
+
size: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
94
|
+
},
|
|
95
|
+
example: 'component IconButton icon: "plus" variant: "primary" size: "md"',
|
|
96
|
+
},
|
|
97
|
+
// Navigation Components
|
|
98
|
+
SidebarMenu: {
|
|
99
|
+
name: 'SidebarMenu',
|
|
100
|
+
description: 'Vertical navigation menu',
|
|
101
|
+
properties: ['items'],
|
|
102
|
+
example: 'component SidebarMenu items: ["Users", "Roles", "Settings"]',
|
|
103
|
+
},
|
|
104
|
+
Topbar: {
|
|
105
|
+
name: 'Topbar',
|
|
106
|
+
description: 'Top navigation bar',
|
|
107
|
+
properties: ['title'],
|
|
108
|
+
example: 'component Topbar title: "Dashboard"',
|
|
109
|
+
},
|
|
110
|
+
Breadcrumbs: {
|
|
111
|
+
name: 'Breadcrumbs',
|
|
112
|
+
description: 'Breadcrumb navigation trail',
|
|
113
|
+
properties: ['items'],
|
|
114
|
+
example: 'component Breadcrumbs items: ["Home", "Users", "Detail"]',
|
|
115
|
+
},
|
|
116
|
+
Tabs: {
|
|
117
|
+
name: 'Tabs',
|
|
118
|
+
description: 'Tabbed content switcher',
|
|
119
|
+
properties: ['items', 'activeIndex'],
|
|
120
|
+
example: 'component Tabs items: ["Profile", "Settings", "Logs"]',
|
|
121
|
+
},
|
|
122
|
+
// Data Components
|
|
123
|
+
Table: {
|
|
124
|
+
name: 'Table',
|
|
125
|
+
description: 'Data table with rows and columns',
|
|
126
|
+
properties: ['columns', 'rowsMock', 'rowHeight'],
|
|
127
|
+
example: 'component Table columns: ["Name", "Email", "Status", "Role"] rowsMock: 8',
|
|
128
|
+
},
|
|
129
|
+
List: {
|
|
130
|
+
name: 'List',
|
|
131
|
+
description: 'Vertical list of items',
|
|
132
|
+
properties: ['items'],
|
|
133
|
+
example: 'component List items: ["Item 1", "Item 2", "Item 3"]',
|
|
134
|
+
},
|
|
135
|
+
// Container Components
|
|
136
|
+
Badge: {
|
|
137
|
+
name: 'Badge',
|
|
138
|
+
description: 'Small badge/tag element',
|
|
139
|
+
properties: ['text', 'variant'],
|
|
140
|
+
propertyValues: {
|
|
141
|
+
variant: ['primary', 'secondary', 'success', 'warning', 'error', 'info'],
|
|
142
|
+
},
|
|
143
|
+
example: 'component Badge text: "New" variant: primary',
|
|
144
|
+
},
|
|
145
|
+
Alert: {
|
|
146
|
+
name: 'Alert',
|
|
147
|
+
description: 'Alert message box',
|
|
148
|
+
properties: ['text', 'variant'],
|
|
149
|
+
propertyValues: {
|
|
150
|
+
variant: ['primary', 'secondary', 'success', 'warning', 'error', 'info'],
|
|
151
|
+
},
|
|
152
|
+
example: 'component Alert text: "Warning message" variant: warning',
|
|
153
|
+
},
|
|
154
|
+
// Visual Components
|
|
155
|
+
Icon: {
|
|
156
|
+
name: 'Icon',
|
|
157
|
+
description: 'Icon element (visual symbol)',
|
|
158
|
+
properties: ['type', 'size'],
|
|
159
|
+
propertyValues: {
|
|
160
|
+
size: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
161
|
+
},
|
|
162
|
+
example: 'component Icon type: "home" size: "md"',
|
|
163
|
+
},
|
|
164
|
+
Divider: {
|
|
165
|
+
name: 'Divider',
|
|
166
|
+
description: 'Horizontal divider line',
|
|
167
|
+
properties: [],
|
|
168
|
+
example: 'component Divider',
|
|
169
|
+
},
|
|
170
|
+
Image: {
|
|
171
|
+
name: 'Image',
|
|
172
|
+
description: 'Image placeholder or actual image',
|
|
173
|
+
properties: ['src', 'alt', 'height', 'placeholder'],
|
|
174
|
+
propertyValues: {
|
|
175
|
+
placeholder: ['square', 'landscape', 'avatar', 'icon'],
|
|
176
|
+
},
|
|
177
|
+
example: 'component Image placeholder: "landscape" height: 300',
|
|
178
|
+
},
|
|
179
|
+
ChartPlaceholder: {
|
|
180
|
+
name: 'ChartPlaceholder',
|
|
181
|
+
description: 'Chart visualization placeholder',
|
|
182
|
+
properties: ['type', 'height'],
|
|
183
|
+
propertyValues: {
|
|
184
|
+
type: ['bar', 'line', 'pie'],
|
|
185
|
+
},
|
|
186
|
+
example: 'component ChartPlaceholder type: "bar" height: 200',
|
|
187
|
+
},
|
|
188
|
+
Sidebar: {
|
|
189
|
+
name: 'Sidebar',
|
|
190
|
+
description: 'Sidebar navigation panel',
|
|
191
|
+
properties: ['title', 'items'],
|
|
192
|
+
example: 'component Sidebar title: "Navigation" items: ["Dashboard", "Users"]',
|
|
193
|
+
},
|
|
194
|
+
// Feedback Components
|
|
195
|
+
Modal: {
|
|
196
|
+
name: 'Modal',
|
|
197
|
+
description: 'Modal dialog window',
|
|
198
|
+
properties: ['title', 'content'],
|
|
199
|
+
example: 'component Modal title: "Confirm?" content: "Are you sure?"',
|
|
200
|
+
},
|
|
201
|
+
StatCard: {
|
|
202
|
+
name: 'StatCard',
|
|
203
|
+
description: 'Statistic card showing metric value',
|
|
204
|
+
properties: ['title', 'value'],
|
|
205
|
+
example: 'component StatCard title: "Total Users" value: "1,234"',
|
|
206
|
+
},
|
|
207
|
+
Spinner: {
|
|
208
|
+
name: 'Spinner',
|
|
209
|
+
description: 'Loading spinner/indicator',
|
|
210
|
+
properties: [],
|
|
211
|
+
example: 'component Spinner',
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
export const LAYOUTS = {
|
|
215
|
+
stack: {
|
|
216
|
+
name: 'stack',
|
|
217
|
+
description: 'Stack layout - arranges items in a row or column',
|
|
218
|
+
properties: ['direction', 'gap', 'padding', 'align', 'justify'],
|
|
219
|
+
example: 'layout stack(direction: vertical, gap: md, padding: lg) { ... }',
|
|
220
|
+
requiredProperties: [],
|
|
221
|
+
},
|
|
222
|
+
grid: {
|
|
223
|
+
name: 'grid',
|
|
224
|
+
description: 'Grid layout - 12-column grid system',
|
|
225
|
+
properties: ['columns', 'gap', 'align', 'padding'],
|
|
226
|
+
example: 'layout grid(columns: 12, gap: md) { cell span: 6 { ... } }',
|
|
227
|
+
requiredProperties: ['columns'],
|
|
228
|
+
},
|
|
229
|
+
split: {
|
|
230
|
+
name: 'split',
|
|
231
|
+
description: 'Split layout - sidebar + main content',
|
|
232
|
+
properties: ['sidebar', 'gap', 'padding'],
|
|
233
|
+
example: 'layout split(sidebar: 260, gap: md) { ... }',
|
|
234
|
+
requiredProperties: ['sidebar'],
|
|
235
|
+
},
|
|
236
|
+
panel: {
|
|
237
|
+
name: 'panel',
|
|
238
|
+
description: 'Panel layout - container with border and padding',
|
|
239
|
+
properties: ['padding', 'background', 'radius', 'border'],
|
|
240
|
+
example: 'layout panel(padding: md, background: white) { ... }',
|
|
241
|
+
requiredProperties: [],
|
|
242
|
+
},
|
|
243
|
+
card: {
|
|
244
|
+
name: 'card',
|
|
245
|
+
description: 'Card layout - flexible vertical container',
|
|
246
|
+
properties: ['padding', 'gap', 'radius', 'border', 'background'],
|
|
247
|
+
example: 'layout card(padding: md, gap: md, radius: md) { ... }',
|
|
248
|
+
requiredProperties: [],
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
// Property values for specific properties (layout-related)
|
|
252
|
+
export const PROPERTY_VALUES = {
|
|
253
|
+
direction: ['vertical', 'horizontal'],
|
|
254
|
+
gap: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
255
|
+
padding: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
256
|
+
align: ['start', 'center', 'end'],
|
|
257
|
+
justify: ['start', 'center', 'end', 'space-between', 'space-around'],
|
|
258
|
+
radius: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
259
|
+
density: ['compact', 'normal', 'comfortable'],
|
|
260
|
+
spacing: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
261
|
+
};
|
|
262
|
+
// Keywords
|
|
263
|
+
export const KEYWORDS = {
|
|
264
|
+
topLevel: ['project', 'theme', 'colors', 'mocks', 'define'],
|
|
265
|
+
screen: ['screen'],
|
|
266
|
+
layout: ['layout'],
|
|
267
|
+
component: ['component'],
|
|
268
|
+
cell: ['cell'],
|
|
269
|
+
special: ['span', 'sidebar', 'columns', 'gap', 'padding', 'direction', 'Component'],
|
|
270
|
+
};
|
|
271
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkBH,MAAM,CAAC,MAAM,UAAU,GAAsC;IAC3D,kBAAkB;IAClB,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,0BAA0B;QACvC,UAAU,EAAE,CAAC,MAAM,CAAC;QACpB,OAAO,EAAE,iCAAiC;KAC3C;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,wBAAwB;QACrC,UAAU,EAAE,CAAC,SAAS,CAAC;QACvB,OAAO,EAAE,yDAAyD;KACnE;IACD,KAAK,EAAE;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EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IACtC,OAAO,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,CAAC;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;CACxC,CAAC;AAEF,WAAW;AACX,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC;IAC3D,MAAM,EAAE,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,CAAC,QAAQ,CAAC;IAClB,SAAS,EAAE,CAAC,WAAW,CAAC;IACxB,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC;CACpF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Context Detection
|
|
3
|
+
* Agnóstic logic for detecting document scope and completion context
|
|
4
|
+
* Used by Monaco, VS Code, and other editors
|
|
5
|
+
*/
|
|
6
|
+
export type DocumentScope = 'empty-file' | 'inside-project' | 'inside-screen' | 'inside-layout';
|
|
7
|
+
export interface CompletionContext {
|
|
8
|
+
scope: DocumentScope;
|
|
9
|
+
componentName?: string;
|
|
10
|
+
lineText: string;
|
|
11
|
+
word?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Determine document scope by analyzing text structure
|
|
15
|
+
* Returns: empty-file | inside-project | inside-screen | inside-layout
|
|
16
|
+
*
|
|
17
|
+
* Hierarchy:
|
|
18
|
+
* project { ... } <- empty-file → inside-project
|
|
19
|
+
* screen Name { ... } <- inside-project → inside-screen
|
|
20
|
+
* layout stack(...) { <- inside-screen → inside-layout
|
|
21
|
+
* component Button <- inside-layout
|
|
22
|
+
*/
|
|
23
|
+
export declare function determineScope(textBeforeCursor: string): DocumentScope;
|
|
24
|
+
/**
|
|
25
|
+
* Detect if we're inside a component definition (after component keyword)
|
|
26
|
+
* and return the component name if found.
|
|
27
|
+
*
|
|
28
|
+
* Examples:
|
|
29
|
+
* - "component Button" → returns "Button"
|
|
30
|
+
* - "component Button text:" → returns "Button"
|
|
31
|
+
* - "component Button text: "Save"" → returns "Button"
|
|
32
|
+
* - "component B" → returns null (still typing component name)
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectComponentContext(lineText: string): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Get the current word being typed at the end of a line
|
|
37
|
+
*/
|
|
38
|
+
export declare function getCurrentWord(lineText: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get component properties available for completion
|
|
41
|
+
* Filters out properties that are already declared
|
|
42
|
+
*/
|
|
43
|
+
export interface CompletionItem {
|
|
44
|
+
label: string;
|
|
45
|
+
kind: 'Keyword' | 'Component' | 'Property' | 'Value' | 'Variable';
|
|
46
|
+
detail?: string;
|
|
47
|
+
documentation?: string;
|
|
48
|
+
insertText?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function getComponentPropertiesForCompletion(componentName: string, alreadyDeclared?: Set<string>): CompletionItem[];
|
|
51
|
+
/**
|
|
52
|
+
* Extract already-declared properties from a component line
|
|
53
|
+
* Patterns: propertyName: or propertyName: value
|
|
54
|
+
*/
|
|
55
|
+
export declare function getAlreadyDeclaredProperties(lineText: string): Set<string>;
|
|
56
|
+
//# sourceMappingURL=context-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-detection.d.ts","sourceRoot":"","sources":["../src/context-detection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,gBAAgB,GAAG,eAAe,GAAG,eAAe,CAAC;AAEhG,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,MAAM,GAAG,aAAa,CA6DtE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyBtE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,EACrB,eAAe,GAAE,GAAG,CAAC,MAAM,CAAa,GACvC,cAAc,EAAE,CA8BlB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAS1E"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Context Detection
|
|
3
|
+
* Agnóstic logic for detecting document scope and completion context
|
|
4
|
+
* Used by Monaco, VS Code, and other editors
|
|
5
|
+
*/
|
|
6
|
+
import { COMPONENTS } from './components';
|
|
7
|
+
/**
|
|
8
|
+
* Determine document scope by analyzing text structure
|
|
9
|
+
* Returns: empty-file | inside-project | inside-screen | inside-layout
|
|
10
|
+
*
|
|
11
|
+
* Hierarchy:
|
|
12
|
+
* project { ... } <- empty-file → inside-project
|
|
13
|
+
* screen Name { ... } <- inside-project → inside-screen
|
|
14
|
+
* layout stack(...) { <- inside-screen → inside-layout
|
|
15
|
+
* component Button <- inside-layout
|
|
16
|
+
*/
|
|
17
|
+
export function determineScope(textBeforeCursor) {
|
|
18
|
+
const cleanText = textBeforeCursor.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
19
|
+
if (cleanText.trim().length === 0) {
|
|
20
|
+
return 'empty-file';
|
|
21
|
+
}
|
|
22
|
+
// Track nesting depth by analyzing braces and keywords
|
|
23
|
+
let projectBraceCount = 0;
|
|
24
|
+
let screenBraceCount = 0;
|
|
25
|
+
let layoutBraceCount = 0;
|
|
26
|
+
let hasProject = false;
|
|
27
|
+
let hasScreen = false;
|
|
28
|
+
let hasLayout = false;
|
|
29
|
+
const lines = cleanText.split('\n');
|
|
30
|
+
for (const line of lines) {
|
|
31
|
+
// Track keywords
|
|
32
|
+
if (line.match(/\bproject\s+"?[^{]*{/)) {
|
|
33
|
+
hasProject = true;
|
|
34
|
+
}
|
|
35
|
+
if (line.match(/\bscreen\s+[A-Za-z_][A-Za-z0-9_]*\s*{/)) {
|
|
36
|
+
hasScreen = true;
|
|
37
|
+
}
|
|
38
|
+
if (line.match(/\blayout\s+(?:stack|grid|card|panel|split)\s*\(/)) {
|
|
39
|
+
hasLayout = true;
|
|
40
|
+
}
|
|
41
|
+
// Count opening braces
|
|
42
|
+
if (line.includes('project') && line.includes('{'))
|
|
43
|
+
projectBraceCount++;
|
|
44
|
+
if (line.includes('screen') && line.includes('{'))
|
|
45
|
+
screenBraceCount++;
|
|
46
|
+
if (line.includes('layout') && line.includes('{'))
|
|
47
|
+
layoutBraceCount++;
|
|
48
|
+
// Count closing braces to track nesting level
|
|
49
|
+
projectBraceCount -= (line.match(/}/g) || []).length;
|
|
50
|
+
screenBraceCount -= (line.match(/}/g) || []).length;
|
|
51
|
+
layoutBraceCount -= (line.match(/}/g) || []).length;
|
|
52
|
+
}
|
|
53
|
+
// Determine scope based on nesting hierarchy
|
|
54
|
+
if (!hasProject) {
|
|
55
|
+
return 'empty-file';
|
|
56
|
+
}
|
|
57
|
+
// We're inside a layout (deepest level)
|
|
58
|
+
if (hasLayout && layoutBraceCount > 0) {
|
|
59
|
+
return 'inside-layout';
|
|
60
|
+
}
|
|
61
|
+
// We're inside a screen but not in a layout
|
|
62
|
+
if (hasScreen && screenBraceCount > 0) {
|
|
63
|
+
return 'inside-screen';
|
|
64
|
+
}
|
|
65
|
+
// We're inside project level
|
|
66
|
+
if (hasProject && projectBraceCount > 0) {
|
|
67
|
+
return 'inside-project';
|
|
68
|
+
}
|
|
69
|
+
return 'inside-project';
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Detect if we're inside a component definition (after component keyword)
|
|
73
|
+
* and return the component name if found.
|
|
74
|
+
*
|
|
75
|
+
* Examples:
|
|
76
|
+
* - "component Button" → returns "Button"
|
|
77
|
+
* - "component Button text:" → returns "Button"
|
|
78
|
+
* - "component Button text: "Save"" → returns "Button"
|
|
79
|
+
* - "component B" → returns null (still typing component name)
|
|
80
|
+
*/
|
|
81
|
+
export function detectComponentContext(lineText) {
|
|
82
|
+
// Match "component ComponentName" where ComponentName starts with uppercase
|
|
83
|
+
// This ensures we have a complete, recognized component name
|
|
84
|
+
const match = lineText.match(/component\s+([A-Z]\w*)/);
|
|
85
|
+
if (!match) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const componentName = match[1];
|
|
89
|
+
// Check if this is a valid component
|
|
90
|
+
if (!COMPONENTS[componentName]) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
// Get text after the component name
|
|
94
|
+
const afterComponent = lineText.substring(match.index + match[0].length);
|
|
95
|
+
// If there's nothing after, or only spaces, we're at the end - show properties
|
|
96
|
+
// Or if we have properties already (word followed by colon), show properties
|
|
97
|
+
if (afterComponent.match(/^\s*$/) || afterComponent.match(/^\s+[\w-]+:/)) {
|
|
98
|
+
return componentName;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the current word being typed at the end of a line
|
|
104
|
+
*/
|
|
105
|
+
export function getCurrentWord(lineText) {
|
|
106
|
+
const match = lineText.match(/[\w-]*$/);
|
|
107
|
+
return match ? match[0] : '';
|
|
108
|
+
}
|
|
109
|
+
export function getComponentPropertiesForCompletion(componentName, alreadyDeclared = new Set()) {
|
|
110
|
+
const component = COMPONENTS[componentName];
|
|
111
|
+
if (!component)
|
|
112
|
+
return [];
|
|
113
|
+
const items = [];
|
|
114
|
+
const properties = component.properties || [];
|
|
115
|
+
for (const propName of properties) {
|
|
116
|
+
// Skip if this property is already declared
|
|
117
|
+
if (alreadyDeclared.has(propName)) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const item = {
|
|
121
|
+
label: propName,
|
|
122
|
+
kind: 'Property',
|
|
123
|
+
detail: `Property of ${componentName}`,
|
|
124
|
+
insertText: `${propName}: `,
|
|
125
|
+
};
|
|
126
|
+
// Add property values if available
|
|
127
|
+
if (component.propertyValues && component.propertyValues[propName]) {
|
|
128
|
+
const values = component.propertyValues[propName];
|
|
129
|
+
item.insertText = `${propName}: ${values.length === 1 ? values[0] : ''}`;
|
|
130
|
+
}
|
|
131
|
+
items.push(item);
|
|
132
|
+
}
|
|
133
|
+
return items;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Extract already-declared properties from a component line
|
|
137
|
+
* Patterns: propertyName: or propertyName: value
|
|
138
|
+
*/
|
|
139
|
+
export function getAlreadyDeclaredProperties(lineText) {
|
|
140
|
+
const declaredProps = new Set();
|
|
141
|
+
const matches = lineText.matchAll(/(\w+):\s*/g);
|
|
142
|
+
for (const match of matches) {
|
|
143
|
+
declaredProps.add(match[1]);
|
|
144
|
+
}
|
|
145
|
+
return declaredProps;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=context-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-det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,eAAe,aAAa,EAAE;YACtC,UAAU,EAAE,GAAG,QAAQ,IAAI;SAC5B,CAAC;QAEF,mCAAmC;QACnC,IAAI,SAAS,CAAC,cAAc,IAAI,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnE,MAAM,MAAM,GAAG,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YAClD,IAAI,CAAC,UAAU,GAAG,GAAG,QAAQ,KAAK,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC3E,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,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,OAAO,EAAE,CAAC;QAC5B,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire DSL Document Parser
|
|
3
|
+
* Extracts component definitions and references from Wire DSL documents
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Represents a component definition in the document
|
|
7
|
+
*/
|
|
8
|
+
export interface ComponentDefinition {
|
|
9
|
+
name: string;
|
|
10
|
+
line: number;
|
|
11
|
+
character: number;
|
|
12
|
+
endLine: number;
|
|
13
|
+
documentation?: string;
|
|
14
|
+
}
|
|
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
|
+
export declare function extractComponentDefinitions(text: string): ComponentDefinition[];
|
|
21
|
+
/**
|
|
22
|
+
* Get the token at a specific position in the document
|
|
23
|
+
* Returns the word and its range
|
|
24
|
+
*/
|
|
25
|
+
export declare function getTokenAtPosition(text: string, line: number, character: number): {
|
|
26
|
+
token: string;
|
|
27
|
+
startChar: number;
|
|
28
|
+
endChar: number;
|
|
29
|
+
} | null;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a position is inside a component reference
|
|
32
|
+
* Pattern: component SomeComponent (with optional properties after)
|
|
33
|
+
*/
|
|
34
|
+
export declare function isComponentReference(text: string, line: number, character: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Extract all component references (usages) from the document
|
|
37
|
+
* Returns array of { name, line, character }
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractComponentReferences(text: string): Array<{
|
|
40
|
+
name: string;
|
|
41
|
+
line: number;
|
|
42
|
+
character: number;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Extract all screen definitions from document text
|
|
46
|
+
* Syntax: screen ScreenName { ... }
|
|
47
|
+
*/
|
|
48
|
+
export declare function extractScreenDefinitions(text: string): ComponentDefinition[];
|
|
49
|
+
/**
|
|
50
|
+
* Find the definition position of a component, screen, or layout
|
|
51
|
+
*/
|
|
52
|
+
export declare function getPositionOfDefinition(text: string, name: string): {
|
|
53
|
+
line: number;
|
|
54
|
+
character: number;
|
|
55
|
+
} | null;
|
|
56
|
+
/**
|
|
57
|
+
* Find all references to a component or screen
|
|
58
|
+
*/
|
|
59
|
+
export declare function findComponentReferences(text: string, name: string): Array<{
|
|
60
|
+
line: number;
|
|
61
|
+
character: number;
|
|
62
|
+
}>;
|
|
63
|
+
//# sourceMappingURL=document-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-parser.d.ts","sourceRoot":"","sources":["../src/document-parser.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