@wireweave/language-data 1.5.3-beta.0 → 1.5.3

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.
@@ -1,14 +1,20 @@
1
+ import { StringStream } from '@codemirror/language';
2
+ import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
3
+ import { EditorView } from '@codemirror/view';
4
+ import { Diagnostic as Diagnostic$1 } from '@codemirror/lint';
5
+
1
6
  /**
2
7
  * CodeMirror Language Definition for Wireframe DSL
3
8
  *
4
9
  * Provides syntax highlighting using StreamLanguage
5
10
  */
11
+
6
12
  /**
7
13
  * StreamLanguage token function for CodeMirror
8
14
  * Use with StreamLanguage.define()
9
15
  */
10
16
  declare function createTokenizer(): {
11
- token(stream: any): string | null;
17
+ token(stream: StringStream): string | null;
12
18
  };
13
19
  /**
14
20
  * Get language configuration for CodeMirror
@@ -29,17 +35,7 @@ declare function getLanguageConfig(): {
29
35
  *
30
36
  * Provides auto-completion for components, attributes, and values
31
37
  */
32
- /**
33
- * Completion option type for CodeMirror
34
- */
35
- interface CompletionOption {
36
- label: string;
37
- type: string;
38
- detail?: string;
39
- info?: string;
40
- boost?: number;
41
- apply?: string;
42
- }
38
+
43
39
  /**
44
40
  * Create completion source for CodeMirror
45
41
  *
@@ -53,16 +49,14 @@ interface CompletionOption {
53
49
  * ];
54
50
  * ```
55
51
  */
56
- declare function createCompletionSource(): (context: any) => {
57
- from: number;
58
- options: CompletionOption[];
59
- };
52
+ declare function createCompletionSource(): (context: CompletionContext) => CompletionResult | null;
60
53
 
61
54
  /**
62
55
  * CodeMirror Hover Provider for Wireframe DSL
63
56
  *
64
57
  * Provides hover tooltips for components, attributes, and values
65
58
  */
59
+
66
60
  /**
67
61
  * Create hover tooltip extension for CodeMirror
68
62
  *
@@ -76,7 +70,7 @@ declare function createCompletionSource(): (context: any) => {
76
70
  * ];
77
71
  * ```
78
72
  */
79
- declare function createHoverTooltipSource(): (view: any, pos: number, _side: number) => {
73
+ declare function createHoverTooltipSource(): (view: EditorView, pos: number, _side: -1 | 1) => {
80
74
  pos: number;
81
75
  end: number;
82
76
  above: boolean;
@@ -90,6 +84,7 @@ declare function createHoverTooltipSource(): (view: any, pos: number, _side: num
90
84
  *
91
85
  * Provides diagnostics for syntax errors, unknown components, etc.
92
86
  */
87
+
93
88
  /**
94
89
  * Diagnostic severity levels
95
90
  */
@@ -120,11 +115,6 @@ declare function validateCode(text: string): Diagnostic[];
120
115
  * ];
121
116
  * ```
122
117
  */
123
- declare function createLinter(): (view: any) => {
124
- from: number;
125
- to: number;
126
- severity: DiagnosticSeverity;
127
- message: string;
128
- }[];
118
+ declare function createLinter(): (view: EditorView) => Diagnostic$1[];
129
119
 
130
120
  export { type Diagnostic, type DiagnosticSeverity, createCompletionSource, createHoverTooltipSource, createLinter, createTokenizer, getLanguageConfig, validateCode };
@@ -47,7 +47,12 @@ var ATTRIBUTES = [
47
47
  { name: "pb", type: "number", description: "Bottom padding", example: "pb=4" },
48
48
  { name: "pl", type: "number", description: "Left padding", example: "pl=4" },
49
49
  { name: "m", type: "number", description: "Margin (all sides)", example: "m=4" },
50
- { name: "mx", type: "string", description: 'Horizontal margin (number or "auto")', example: "mx=auto" },
50
+ {
51
+ name: "mx",
52
+ type: "string",
53
+ description: 'Horizontal margin (number or "auto")',
54
+ example: "mx=auto"
55
+ },
51
56
  { name: "my", type: "number", description: "Vertical margin", example: "my=4" },
52
57
  { name: "mt", type: "number", description: "Top margin", example: "mt=4" },
53
58
  { name: "mr", type: "number", description: "Right margin", example: "mr=4" },
@@ -57,10 +62,30 @@ var ATTRIBUTES = [
57
62
  // ============================================
58
63
  // Size Attributes
59
64
  // ============================================
60
- { name: "w", type: "string", description: 'Width (number, "full", "auto", "screen", "fit")', example: "w=full" },
61
- { name: "h", type: "string", description: 'Height (number, "full", "auto", "screen")', example: "h=full" },
62
- { name: "width", type: "number", description: "Width in pixels (page only)", example: "width=400" },
63
- { name: "height", type: "number", description: "Height in pixels (page only)", example: "height=300" },
65
+ {
66
+ name: "w",
67
+ type: "string",
68
+ description: 'Width (number, "full", "auto", "screen", "fit")',
69
+ example: "w=full"
70
+ },
71
+ {
72
+ name: "h",
73
+ type: "string",
74
+ description: 'Height (number, "full", "auto", "screen")',
75
+ example: "h=full"
76
+ },
77
+ {
78
+ name: "width",
79
+ type: "number",
80
+ description: "Width in pixels (page only)",
81
+ example: "width=400"
82
+ },
83
+ {
84
+ name: "height",
85
+ type: "number",
86
+ description: "Height in pixels (page only)",
87
+ example: "height=300"
88
+ },
64
89
  { name: "minW", type: "number", description: "Minimum width", example: "minW=200" },
65
90
  { name: "maxW", type: "number", description: "Maximum width", example: "maxW=600" },
66
91
  { name: "minH", type: "number", description: "Minimum height", example: "minH=100" },
@@ -69,9 +94,27 @@ var ATTRIBUTES = [
69
94
  // Flex/Grid Layout Attributes
70
95
  // ============================================
71
96
  { name: "flex", type: "boolean", description: "Enable flexbox", example: "flex" },
72
- { name: "direction", type: "enum", values: ["row", "column", "row-reverse", "column-reverse"], description: "Flex direction", example: "direction=column" },
73
- { name: "justify", type: "enum", values: ["start", "center", "end", "between", "around", "evenly"], description: "Main axis alignment", example: "justify=center" },
74
- { name: "align", type: "enum", values: ["start", "center", "end", "stretch", "baseline"], description: "Cross axis alignment", example: "align=center" },
97
+ {
98
+ name: "direction",
99
+ type: "enum",
100
+ values: ["row", "column", "row-reverse", "column-reverse"],
101
+ description: "Flex direction",
102
+ example: "direction=column"
103
+ },
104
+ {
105
+ name: "justify",
106
+ type: "enum",
107
+ values: ["start", "center", "end", "between", "around", "evenly"],
108
+ description: "Main axis alignment",
109
+ example: "justify=center"
110
+ },
111
+ {
112
+ name: "align",
113
+ type: "enum",
114
+ values: ["start", "center", "end", "stretch", "baseline"],
115
+ description: "Cross axis alignment",
116
+ example: "align=center"
117
+ },
75
118
  { name: "wrap", type: "boolean", description: "Enable flex wrap", example: "wrap" },
76
119
  { name: "span", type: "number", description: "Grid column span (1-12)", example: "span=6" },
77
120
  { name: "sm", type: "number", description: "Responsive span at 576px+", example: "sm=6" },
@@ -84,19 +127,60 @@ var ATTRIBUTES = [
84
127
  // ============================================
85
128
  { name: "x", type: "number", description: "Horizontal position", example: "x=100" },
86
129
  { name: "y", type: "number", description: "Vertical position", example: "y=50" },
87
- { name: "position", type: "enum", values: ["left", "right", "top", "bottom", "top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"], description: "Position preset", example: "position=left" },
130
+ {
131
+ name: "position",
132
+ type: "enum",
133
+ values: [
134
+ "left",
135
+ "right",
136
+ "top",
137
+ "bottom",
138
+ "top-left",
139
+ "top-center",
140
+ "top-right",
141
+ "bottom-left",
142
+ "bottom-center",
143
+ "bottom-right"
144
+ ],
145
+ description: "Position preset",
146
+ example: "position=left"
147
+ },
88
148
  // ============================================
89
149
  // Visual Attributes
90
150
  // ============================================
91
151
  { name: "border", type: "boolean", description: "Show border", example: "border" },
92
152
  { name: "rounded", type: "boolean", description: "Apply border radius", example: "rounded" },
93
- { name: "shadow", type: "enum", values: ["none", "sm", "md", "lg", "xl"], description: "Box shadow", example: "shadow=md" },
94
- { name: "bg", type: "enum", values: ["muted", "primary", "secondary"], description: "Background variant", example: "bg=muted" },
153
+ {
154
+ name: "shadow",
155
+ type: "enum",
156
+ values: ["none", "sm", "md", "lg", "xl"],
157
+ description: "Box shadow",
158
+ example: "shadow=md"
159
+ },
160
+ {
161
+ name: "bg",
162
+ type: "enum",
163
+ values: ["muted", "primary", "secondary"],
164
+ description: "Background variant",
165
+ example: "bg=muted"
166
+ },
95
167
  // ============================================
96
168
  // Text Attributes
97
169
  // ============================================
98
- { name: "size", type: "enum", values: ["xs", "sm", "base", "md", "lg", "xl", "2xl", "3xl"], description: "Size preset", example: "size=lg" },
99
- { name: "weight", type: "enum", values: ["normal", "medium", "semibold", "bold"], description: "Font weight", example: "weight=bold" },
170
+ {
171
+ name: "size",
172
+ type: "enum",
173
+ values: ["xs", "sm", "base", "md", "lg", "xl", "2xl", "3xl"],
174
+ description: "Size preset",
175
+ example: "size=lg"
176
+ },
177
+ {
178
+ name: "weight",
179
+ type: "enum",
180
+ values: ["normal", "medium", "semibold", "bold"],
181
+ description: "Font weight",
182
+ example: "weight=bold"
183
+ },
100
184
  { name: "level", type: "number", description: "Heading level (1-6)", example: "level=2" },
101
185
  { name: "muted", type: "boolean", description: "Muted/dimmed style", example: "muted" },
102
186
  { name: "bold", type: "boolean", description: "Bold text", example: "bold" },
@@ -111,12 +195,29 @@ var ATTRIBUTES = [
111
195
  // ============================================
112
196
  // Status Variant Attributes
113
197
  // ============================================
114
- { name: "variant", type: "enum", values: ["default", "primary", "secondary", "success", "warning", "danger", "info"], description: "Status variant", example: "variant=success" },
198
+ {
199
+ name: "variant",
200
+ type: "enum",
201
+ values: ["default", "primary", "secondary", "success", "warning", "danger", "info"],
202
+ description: "Status variant",
203
+ example: "variant=success"
204
+ },
115
205
  // ============================================
116
206
  // Form Attributes
117
207
  // ============================================
118
- { name: "inputType", type: "enum", values: ["text", "email", "password", "number", "tel", "url", "search", "date"], description: "Input field type", example: "inputType=email" },
119
- { name: "placeholder", type: "string", description: "Placeholder text", example: 'placeholder="Enter text"' },
208
+ {
209
+ name: "inputType",
210
+ type: "enum",
211
+ values: ["text", "email", "password", "number", "tel", "url", "search", "date"],
212
+ description: "Input field type",
213
+ example: "inputType=email"
214
+ },
215
+ {
216
+ name: "placeholder",
217
+ type: "string",
218
+ description: "Placeholder text",
219
+ example: 'placeholder="Enter text"'
220
+ },
120
221
  { name: "value", type: "string", description: "Default value", example: 'value="default"' },
121
222
  { name: "label", type: "string", description: "Field label", example: 'label="Name"' },
122
223
  { name: "name", type: "string", description: "Form field name", example: 'name="field"' },
@@ -150,7 +251,12 @@ var ATTRIBUTES = [
150
251
  // Feedback Attributes
151
252
  // ============================================
152
253
  { name: "dismissible", type: "boolean", description: "Can be dismissed", example: "dismissible" },
153
- { name: "indeterminate", type: "boolean", description: "Indeterminate state", example: "indeterminate" },
254
+ {
255
+ name: "indeterminate",
256
+ type: "boolean",
257
+ description: "Indeterminate state",
258
+ example: "indeterminate"
259
+ },
154
260
  { name: "pill", type: "boolean", description: "Pill/rounded style", example: "pill" },
155
261
  // ============================================
156
262
  // Data Attributes
@@ -163,20 +269,73 @@ var ATTRIBUTES = [
163
269
  // ============================================
164
270
  // Page/Viewport Attributes
165
271
  // ============================================
166
- { name: "viewport", type: "string", description: 'Viewport size (e.g., "1440x900")', example: 'viewport="1440x900"' },
272
+ {
273
+ name: "viewport",
274
+ type: "string",
275
+ description: 'Viewport size (e.g., "1440x900")',
276
+ example: 'viewport="1440x900"'
277
+ },
167
278
  { name: "device", type: "string", description: "Device preset", example: 'device="iphone14"' },
279
+ {
280
+ name: "at",
281
+ type: "function",
282
+ description: "Place page on the multi-page canvas at (x, y) \u2014 pages without at() auto-flow horizontally",
283
+ example: "at(0, 0)"
284
+ },
168
285
  // ============================================
169
286
  // Interactive Attributes
170
287
  // ============================================
171
- { name: "navigate", type: "string", description: "Navigation target URL or page", example: 'navigate="/dashboard"' },
172
- { name: "opens", type: "string", description: "Opens a modal, drawer, or popup", example: 'opens="settings-modal"' },
173
- { name: "toggles", type: "string", description: "Toggles visibility of an element", example: 'toggles="menu"' },
174
- { name: "action", type: "string", description: "Action identifier for event handling", example: 'action="submit-form"' },
288
+ {
289
+ name: "navigate",
290
+ type: "string",
291
+ description: "Navigation target URL or page",
292
+ example: 'navigate="/dashboard"'
293
+ },
294
+ {
295
+ name: "opens",
296
+ type: "string",
297
+ description: "Opens a modal, drawer, or popup",
298
+ example: 'opens="settings-modal"'
299
+ },
300
+ {
301
+ name: "toggles",
302
+ type: "string",
303
+ description: "Toggles visibility of an element",
304
+ example: 'toggles="menu"'
305
+ },
306
+ {
307
+ name: "action",
308
+ type: "string",
309
+ description: "Action identifier for event handling",
310
+ example: 'action="submit-form"'
311
+ },
175
312
  // ============================================
176
313
  // Annotation Attributes
177
314
  // ============================================
178
- { name: "anchor", type: "enum", values: ["top-left", "top-center", "top-right", "center-left", "center", "center-right", "bottom-left", "bottom-center", "bottom-right"], description: "Anchor position for marker in relative container", example: "anchor=top-right" },
179
- { name: "color", type: "enum", values: ["blue", "red", "green", "yellow", "purple", "orange"], description: "Marker color", example: "color=blue" }
315
+ {
316
+ name: "anchor",
317
+ type: "enum",
318
+ values: [
319
+ "top-left",
320
+ "top-center",
321
+ "top-right",
322
+ "center-left",
323
+ "center",
324
+ "center-right",
325
+ "bottom-left",
326
+ "bottom-center",
327
+ "bottom-right"
328
+ ],
329
+ description: "Anchor position for marker in relative container",
330
+ example: "anchor=top-right"
331
+ },
332
+ {
333
+ name: "color",
334
+ type: "enum",
335
+ values: ["blue", "red", "green", "yellow", "purple", "orange"],
336
+ description: "Marker color",
337
+ example: "color=blue"
338
+ }
180
339
  ];
181
340
  var ATTRIBUTE_MAP = new Map(
182
341
  ATTRIBUTES.map((attr) => [attr.name, attr])
@@ -194,10 +353,19 @@ var ALL_COMPONENTS = [
194
353
  name: "page",
195
354
  nodeType: "Page",
196
355
  category: "layout",
197
- attributes: [...COMMON_ATTRIBUTES, "title", "width", "height", "viewport", "device", "centered"],
356
+ attributes: [
357
+ ...COMMON_ATTRIBUTES,
358
+ "title",
359
+ "width",
360
+ "height",
361
+ "viewport",
362
+ "device",
363
+ "centered",
364
+ "at"
365
+ ],
198
366
  hasChildren: true,
199
- description: "Root container for a wireframe page",
200
- example: 'page "Dashboard" centered { ... }',
367
+ description: "Root container for a wireframe page. Multiple pages in one .wf file lay out side-by-side on a canvas; use at(x, y) for explicit placement, or omit for auto-flow.",
368
+ example: 'page "Login" at(0, 0) viewport="1280x800" { ... }',
201
369
  validChildren: ["header", "main", "footer", "sidebar", "section", "nav", "row", "col", "card"],
202
370
  validParents: []
203
371
  },
@@ -365,7 +533,19 @@ var ALL_COMPONENTS = [
365
533
  name: "input",
366
534
  nodeType: "Input",
367
535
  category: "input",
368
- attributes: [...COMMON_ATTRIBUTES, "label", "inputType", "placeholder", "value", "disabled", "required", "readonly", "icon", "size", "rounded"],
536
+ attributes: [
537
+ ...COMMON_ATTRIBUTES,
538
+ "label",
539
+ "inputType",
540
+ "placeholder",
541
+ "value",
542
+ "disabled",
543
+ "required",
544
+ "readonly",
545
+ "icon",
546
+ "size",
547
+ "rounded"
548
+ ],
369
549
  hasChildren: false,
370
550
  description: "Text input field",
371
551
  example: 'input "Email" inputType=email placeholder="user@example.com" required'
@@ -374,7 +554,15 @@ var ALL_COMPONENTS = [
374
554
  name: "textarea",
375
555
  nodeType: "Textarea",
376
556
  category: "input",
377
- attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "rows", "disabled", "required"],
557
+ attributes: [
558
+ ...COMMON_ATTRIBUTES,
559
+ "label",
560
+ "placeholder",
561
+ "value",
562
+ "rows",
563
+ "disabled",
564
+ "required"
565
+ ],
378
566
  hasChildren: false,
379
567
  description: "Multi-line text input",
380
568
  example: 'textarea "Description" rows=4 placeholder="Enter description..."'
@@ -428,7 +616,18 @@ var ALL_COMPONENTS = [
428
616
  name: "button",
429
617
  nodeType: "Button",
430
618
  category: "input",
431
- attributes: [...COMMON_ATTRIBUTES, "primary", "secondary", "outline", "ghost", "danger", "size", "icon", "disabled", "loading"],
619
+ attributes: [
620
+ ...COMMON_ATTRIBUTES,
621
+ "primary",
622
+ "secondary",
623
+ "outline",
624
+ "ghost",
625
+ "danger",
626
+ "size",
627
+ "icon",
628
+ "disabled",
629
+ "loading"
630
+ ],
432
631
  hasChildren: false,
433
632
  description: "Clickable button",
434
633
  example: 'button "Submit" primary icon=send'
@@ -927,6 +1126,7 @@ function createCompletionSource() {
927
1126
  });
928
1127
  });
929
1128
  } else if (attr?.type === "number") {
1129
+ ;
930
1130
  [1, 2, 3, 4, 5, 6, 8, 10, 12, 16].forEach((n) => {
931
1131
  options.push({
932
1132
  label: String(n),
@@ -971,6 +1171,8 @@ function createCompletionSource() {
971
1171
  apply = `${attr.name}=""`;
972
1172
  } else if (attr.type === "number" || attr.type === "enum") {
973
1173
  apply = `${attr.name}=`;
1174
+ } else if (attr.type === "function") {
1175
+ apply = `${attr.name}(`;
974
1176
  }
975
1177
  options.push({
976
1178
  label: attr.name,
@@ -987,6 +1189,8 @@ function createCompletionSource() {
987
1189
  apply = `${attr.name}=""`;
988
1190
  } else if (attr.type === "number" || attr.type === "enum") {
989
1191
  apply = `${attr.name}=`;
1192
+ } else if (attr.type === "function") {
1193
+ apply = `${attr.name}(`;
990
1194
  }
991
1195
  options.push({
992
1196
  label: attr.name,
@@ -1076,6 +1280,8 @@ function createHoverTooltipSource() {
1076
1280
  valueInfo = "Type: boolean";
1077
1281
  } else if (attribute.type === "enum" && attribute.values) {
1078
1282
  valueInfo = `Values: ${attribute.values.join(" | ")}`;
1283
+ } else if (attribute.type === "function") {
1284
+ valueInfo = `Functional shorthand. Example: ${attribute.example}`;
1079
1285
  }
1080
1286
  return {
1081
1287
  pos: from,
@@ -1100,9 +1306,7 @@ function createHoverTooltipSource() {
1100
1306
  };
1101
1307
  }
1102
1308
  if (VALUE_KEYWORDS.includes(word)) {
1103
- const relatedAttrs = ATTRIBUTES.filter(
1104
- (a) => a.type === "enum" && a.values?.includes(word)
1105
- );
1309
+ const relatedAttrs = ATTRIBUTES.filter((a) => a.type === "enum" && a.values?.includes(word));
1106
1310
  if (relatedAttrs.length > 0) {
1107
1311
  return {
1108
1312
  pos: from,
@@ -1135,7 +1339,7 @@ function createHoverTooltipSource() {
1135
1339
  function validateCode(text) {
1136
1340
  const diagnostics = [];
1137
1341
  const lines = text.split("\n");
1138
- let braceStack = [];
1342
+ const braceStack = [];
1139
1343
  let hasPage = false;
1140
1344
  let currentPos = 0;
1141
1345
  for (let lineNum = 0; lineNum < lines.length; lineNum++) {