@wireweave/language-data 1.5.3-beta.0 → 1.6.0-beta.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.
@@ -1,651 +1,117 @@
1
- // src/attributes.ts
2
- var COMMON_ATTRIBUTES = [
3
- // Spacing
4
- "p",
5
- "px",
6
- "py",
7
- "pt",
8
- "pr",
9
- "pb",
10
- "pl",
11
- "m",
12
- "mx",
13
- "my",
14
- "mt",
15
- "mr",
16
- "mb",
17
- "ml",
18
- "gap",
19
- // Size
20
- "w",
21
- "h",
22
- "minW",
23
- "maxW",
24
- "minH",
25
- "maxH",
26
- // Flex
27
- "flex",
28
- "direction",
29
- "justify",
30
- "align",
31
- "wrap",
32
- // Grid
33
- "span",
34
- // Position
35
- "x",
36
- "y"
37
- ];
38
- var ATTRIBUTES = [
39
- // ============================================
40
- // Spacing Attributes
41
- // ============================================
42
- { name: "p", type: "number", description: "Padding (all sides)", example: "p=4" },
43
- { name: "px", type: "number", description: "Horizontal padding", example: "px=4" },
44
- { name: "py", type: "number", description: "Vertical padding", example: "py=4" },
45
- { name: "pt", type: "number", description: "Top padding", example: "pt=4" },
46
- { name: "pr", type: "number", description: "Right padding", example: "pr=4" },
47
- { name: "pb", type: "number", description: "Bottom padding", example: "pb=4" },
48
- { name: "pl", type: "number", description: "Left padding", example: "pl=4" },
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" },
51
- { name: "my", type: "number", description: "Vertical margin", example: "my=4" },
52
- { name: "mt", type: "number", description: "Top margin", example: "mt=4" },
53
- { name: "mr", type: "number", description: "Right margin", example: "mr=4" },
54
- { name: "mb", type: "number", description: "Bottom margin", example: "mb=4" },
55
- { name: "ml", type: "number", description: "Left margin", example: "ml=4" },
56
- { name: "gap", type: "number", description: "Gap between children", example: "gap=4" },
57
- // ============================================
58
- // Size Attributes
59
- // ============================================
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" },
64
- { name: "minW", type: "number", description: "Minimum width", example: "minW=200" },
65
- { name: "maxW", type: "number", description: "Maximum width", example: "maxW=600" },
66
- { name: "minH", type: "number", description: "Minimum height", example: "minH=100" },
67
- { name: "maxH", type: "number", description: "Maximum height", example: "maxH=400" },
68
- // ============================================
69
- // Flex/Grid Layout Attributes
70
- // ============================================
71
- { 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" },
75
- { name: "wrap", type: "boolean", description: "Enable flex wrap", example: "wrap" },
76
- { name: "span", type: "number", description: "Grid column span (1-12)", example: "span=6" },
77
- { name: "sm", type: "number", description: "Responsive span at 576px+", example: "sm=6" },
78
- { name: "md", type: "number", description: "Responsive span at 768px+", example: "md=4" },
79
- { name: "lg", type: "number", description: "Responsive span at 992px+", example: "lg=3" },
80
- { name: "xl", type: "number", description: "Responsive span at 1200px+", example: "xl=2" },
81
- { name: "order", type: "number", description: "Flex order", example: "order=1" },
82
- // ============================================
83
- // Position Attributes
84
- // ============================================
85
- { name: "x", type: "number", description: "Horizontal position", example: "x=100" },
86
- { 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" },
88
- // ============================================
89
- // Visual Attributes
90
- // ============================================
91
- { name: "border", type: "boolean", description: "Show border", example: "border" },
92
- { 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" },
95
- // ============================================
96
- // Text Attributes
97
- // ============================================
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" },
100
- { name: "level", type: "number", description: "Heading level (1-6)", example: "level=2" },
101
- { name: "muted", type: "boolean", description: "Muted/dimmed style", example: "muted" },
102
- { name: "bold", type: "boolean", description: "Bold text", example: "bold" },
103
- // ============================================
104
- // Button Variant Attributes
105
- // ============================================
106
- { name: "primary", type: "boolean", description: "Primary style", example: "primary" },
107
- { name: "secondary", type: "boolean", description: "Secondary style", example: "secondary" },
108
- { name: "outline", type: "boolean", description: "Outline style", example: "outline" },
109
- { name: "ghost", type: "boolean", description: "Ghost/transparent style", example: "ghost" },
110
- { name: "danger", type: "boolean", description: "Danger/destructive style", example: "danger" },
111
- // ============================================
112
- // Status Variant Attributes
113
- // ============================================
114
- { name: "variant", type: "enum", values: ["default", "primary", "secondary", "success", "warning", "danger", "info"], description: "Status variant", example: "variant=success" },
115
- // ============================================
116
- // Form Attributes
117
- // ============================================
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"' },
120
- { name: "value", type: "string", description: "Default value", example: 'value="default"' },
121
- { name: "label", type: "string", description: "Field label", example: 'label="Name"' },
122
- { name: "name", type: "string", description: "Form field name", example: 'name="field"' },
123
- { name: "required", type: "boolean", description: "Required field", example: "required" },
124
- { name: "disabled", type: "boolean", description: "Disabled state", example: "disabled" },
125
- { name: "readonly", type: "boolean", description: "Read-only state", example: "readonly" },
126
- { name: "checked", type: "boolean", description: "Checked state", example: "checked" },
127
- { name: "loading", type: "boolean", description: "Loading state", example: "loading" },
128
- { name: "rows", type: "number", description: "Textarea rows", example: "rows=4" },
129
- { name: "min", type: "number", description: "Minimum value", example: "min=0" },
130
- { name: "max", type: "number", description: "Maximum value", example: "max=100" },
131
- { name: "step", type: "number", description: "Step increment", example: "step=1" },
132
- // ============================================
133
- // Content Attributes
134
- // ============================================
135
- { name: "title", type: "string", description: "Title text", example: 'title="Title"' },
136
- { name: "src", type: "string", description: "Source URL", example: 'src="/image.png"' },
137
- { name: "alt", type: "string", description: "Alt text", example: 'alt="Image"' },
138
- { name: "href", type: "string", description: "Link URL", example: 'href="/path"' },
139
- { name: "icon", type: "string", description: "Icon name", example: 'icon="home"' },
140
- { name: "external", type: "boolean", description: "External link", example: "external" },
141
- // ============================================
142
- // State Attributes
143
- // ============================================
144
- { name: "active", type: "number", description: "Active index", example: "active=0" },
145
- { name: "expanded", type: "boolean", description: "Expanded state", example: "expanded" },
146
- { name: "centered", type: "boolean", description: "Center content", example: "centered" },
147
- { name: "vertical", type: "boolean", description: "Vertical orientation", example: "vertical" },
148
- { name: "scroll", type: "boolean", description: "Enable scrolling", example: "scroll" },
149
- // ============================================
150
- // Feedback Attributes
151
- // ============================================
152
- { name: "dismissible", type: "boolean", description: "Can be dismissed", example: "dismissible" },
153
- { name: "indeterminate", type: "boolean", description: "Indeterminate state", example: "indeterminate" },
154
- { name: "pill", type: "boolean", description: "Pill/rounded style", example: "pill" },
155
- // ============================================
156
- // Data Attributes
157
- // ============================================
158
- { name: "striped", type: "boolean", description: "Striped rows", example: "striped" },
159
- { name: "bordered", type: "boolean", description: "Full borders", example: "bordered" },
160
- { name: "hover", type: "boolean", description: "Hover effect", example: "hover" },
161
- { name: "ordered", type: "boolean", description: "Ordered list", example: "ordered" },
162
- { name: "none", type: "boolean", description: "No list markers", example: "none" },
163
- // ============================================
164
- // Page/Viewport Attributes
165
- // ============================================
166
- { name: "viewport", type: "string", description: 'Viewport size (e.g., "1440x900")', example: 'viewport="1440x900"' },
167
- { name: "device", type: "string", description: "Device preset", example: 'device="iphone14"' },
168
- // ============================================
169
- // Interactive Attributes
170
- // ============================================
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"' },
175
- // ============================================
176
- // Annotation Attributes
177
- // ============================================
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" }
180
- ];
181
- var ATTRIBUTE_MAP = new Map(
182
- ATTRIBUTES.map((attr) => [attr.name, attr])
183
- );
184
- var VALID_ATTRIBUTE_NAMES = new Set(
185
- ATTRIBUTES.map((attr) => attr.name)
186
- );
187
-
188
1
  // src/components.ts
189
- var ALL_COMPONENTS = [
190
- // ============================================
191
- // Layout Components
192
- // ============================================
193
- {
194
- name: "page",
195
- nodeType: "Page",
196
- category: "layout",
197
- attributes: [...COMMON_ATTRIBUTES, "title", "width", "height", "viewport", "device", "centered"],
198
- hasChildren: true,
199
- description: "Root container for a wireframe page",
200
- example: 'page "Dashboard" centered { ... }',
2
+ import {
3
+ COMPONENT_SPEC_BY_NAME,
4
+ COMPONENT_NAMES
5
+ } from "@wireweave/core/spec";
6
+ var EDITOR_METADATA = {
7
+ // Layout
8
+ page: {
9
+ example: 'page "Login" at(0, 0) viewport="1280x800" { ... }',
201
10
  validChildren: ["header", "main", "footer", "sidebar", "section", "nav", "row", "col", "card"],
11
+ validParents: [],
12
+ extraAttributes: ["at"]
13
+ },
14
+ header: { example: "header h=56 border { ... }", validParents: ["page"] },
15
+ main: { example: "main p=6 scroll { ... }", validParents: ["page"] },
16
+ footer: { example: "footer h=48 border { ... }", validParents: ["page"] },
17
+ sidebar: { example: "sidebar w=240 border { ... }", validParents: ["page"] },
18
+ section: { example: 'section "Settings" expanded { ... }' },
19
+ // Structure (reuse definitions — top level only)
20
+ layout: {
21
+ example: "layout app { header { ... } slot footer { ... } }",
202
22
  validParents: []
203
23
  },
204
- {
205
- name: "header",
206
- nodeType: "Header",
207
- category: "layout",
208
- attributes: [...COMMON_ATTRIBUTES, "border"],
209
- hasChildren: true,
210
- description: "Page header section",
211
- example: "header h=56 border { ... }",
212
- validParents: ["page"]
213
- },
214
- {
215
- name: "main",
216
- nodeType: "Main",
217
- category: "layout",
218
- attributes: [...COMMON_ATTRIBUTES, "scroll"],
219
- hasChildren: true,
220
- description: "Main content section",
221
- example: "main p=6 scroll { ... }",
222
- validParents: ["page"]
223
- },
224
- {
225
- name: "footer",
226
- nodeType: "Footer",
227
- category: "layout",
228
- attributes: [...COMMON_ATTRIBUTES, "border"],
229
- hasChildren: true,
230
- description: "Page footer section",
231
- example: "footer h=48 border { ... }",
232
- validParents: ["page"]
233
- },
234
- {
235
- name: "sidebar",
236
- nodeType: "Sidebar",
237
- category: "layout",
238
- attributes: [...COMMON_ATTRIBUTES, "position", "border", "bg"],
239
- hasChildren: true,
240
- description: "Side navigation or content area",
241
- example: "sidebar w=240 border { ... }",
242
- validParents: ["page"]
243
- },
244
- {
245
- name: "section",
246
- nodeType: "Section",
247
- category: "layout",
248
- attributes: [...COMMON_ATTRIBUTES, "title", "expanded"],
249
- hasChildren: true,
250
- description: "Grouped content section",
251
- example: 'section "Settings" expanded { ... }'
252
- },
253
- // ============================================
254
- // Grid Components
255
- // ============================================
256
- {
257
- name: "row",
258
- nodeType: "Row",
259
- category: "grid",
260
- attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
261
- hasChildren: true,
262
- description: "Horizontal flex container",
263
- example: "row flex gap=4 justify=between { ... }"
264
- },
265
- {
266
- name: "col",
267
- nodeType: "Col",
268
- category: "grid",
269
- attributes: [...COMMON_ATTRIBUTES, "sm", "md", "lg", "xl", "order", "border", "bg", "scroll"],
270
- hasChildren: true,
271
- description: "Vertical flex container or grid column",
272
- example: "col span=6 md=4 { ... }"
273
- },
274
- {
275
- name: "stack",
276
- nodeType: "Stack",
277
- category: "grid",
278
- attributes: [...COMMON_ATTRIBUTES, "border", "bg"],
279
- hasChildren: true,
280
- description: "Vertical stack that only takes content height (unlike col which fills)",
281
- example: "stack gap=4 align=center { ... }"
282
- },
283
- {
284
- name: "relative",
285
- nodeType: "Relative",
286
- category: "grid",
287
- attributes: [...COMMON_ATTRIBUTES],
288
- hasChildren: true,
289
- description: "Container for overlaying elements with absolute positioning",
290
- example: 'relative { button "Submit" marker 1 anchor=top-right }'
291
- },
292
- // ============================================
293
- // Container Components
294
- // ============================================
295
- {
296
- name: "card",
297
- nodeType: "Card",
298
- category: "container",
299
- attributes: [...COMMON_ATTRIBUTES, "title", "shadow", "border", "rounded"],
300
- hasChildren: true,
301
- description: "Card container with optional title",
302
- example: 'card "Settings" p=4 shadow=md { ... }'
303
- },
304
- {
305
- name: "modal",
306
- nodeType: "Modal",
307
- category: "container",
308
- attributes: [...COMMON_ATTRIBUTES, "title"],
309
- hasChildren: true,
310
- description: "Modal dialog overlay",
311
- example: 'modal "Confirm" w=400 { ... }'
312
- },
313
- {
314
- name: "drawer",
315
- nodeType: "Drawer",
316
- category: "container",
317
- attributes: [...COMMON_ATTRIBUTES, "title", "position"],
318
- hasChildren: true,
319
- description: "Slide-in drawer panel",
320
- example: 'drawer "Menu" position=left { ... }'
321
- },
322
- {
323
- name: "accordion",
324
- nodeType: "Accordion",
325
- category: "container",
326
- attributes: [...COMMON_ATTRIBUTES, "title"],
327
- hasChildren: true,
328
- description: "Collapsible sections container",
329
- example: 'accordion { section "FAQ 1" { ... } }'
330
- },
331
- // ============================================
332
- // Text Components
333
- // ============================================
334
- {
335
- name: "text",
336
- nodeType: "Text",
337
- category: "text",
338
- attributes: [...COMMON_ATTRIBUTES, "size", "weight", "muted", "bold"],
339
- hasChildren: false,
340
- description: "Text content",
341
- example: 'text "Hello World" size=lg weight=bold'
342
- },
343
- {
344
- name: "title",
345
- nodeType: "Title",
346
- category: "text",
347
- attributes: [...COMMON_ATTRIBUTES, "level", "size"],
348
- hasChildren: false,
349
- description: "Heading element (h1-h6)",
350
- example: 'title "Welcome" level=2'
351
- },
352
- {
353
- name: "link",
354
- nodeType: "Link",
355
- category: "text",
356
- attributes: [...COMMON_ATTRIBUTES, "href", "external"],
357
- hasChildren: false,
358
- description: "Hyperlink text",
359
- example: 'link "Learn more" href="/docs" external'
360
- },
361
- // ============================================
362
- // Input Components
363
- // ============================================
364
- {
365
- name: "input",
366
- nodeType: "Input",
367
- category: "input",
368
- attributes: [...COMMON_ATTRIBUTES, "label", "inputType", "placeholder", "value", "disabled", "required", "readonly", "icon", "size", "rounded"],
369
- hasChildren: false,
370
- description: "Text input field",
371
- example: 'input "Email" inputType=email placeholder="user@example.com" required'
372
- },
373
- {
374
- name: "textarea",
375
- nodeType: "Textarea",
376
- category: "input",
377
- attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "rows", "disabled", "required"],
378
- hasChildren: false,
379
- description: "Multi-line text input",
380
- example: 'textarea "Description" rows=4 placeholder="Enter description..."'
381
- },
382
- {
383
- name: "select",
384
- nodeType: "Select",
385
- category: "input",
386
- attributes: [...COMMON_ATTRIBUTES, "label", "placeholder", "value", "disabled", "required"],
387
- hasChildren: false,
388
- description: "Dropdown select",
389
- example: 'select "Country" ["USA", "Canada", "UK"] placeholder="Select..."'
390
- },
391
- {
392
- name: "checkbox",
393
- nodeType: "Checkbox",
394
- category: "input",
395
- attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
396
- hasChildren: false,
397
- description: "Checkbox input",
398
- example: 'checkbox "I agree to terms" checked'
399
- },
400
- {
401
- name: "radio",
402
- nodeType: "Radio",
403
- category: "input",
404
- attributes: [...COMMON_ATTRIBUTES, "label", "name", "checked", "disabled"],
405
- hasChildren: false,
406
- description: "Radio button input",
407
- example: 'radio "Option A" name="choice" checked'
408
- },
409
- {
410
- name: "switch",
411
- nodeType: "Switch",
412
- category: "input",
413
- attributes: [...COMMON_ATTRIBUTES, "label", "checked", "disabled"],
414
- hasChildren: false,
415
- description: "Toggle switch",
416
- example: 'switch "Dark mode" checked'
417
- },
418
- {
419
- name: "slider",
420
- nodeType: "Slider",
421
- category: "input",
422
- attributes: [...COMMON_ATTRIBUTES, "label", "min", "max", "value", "step", "disabled"],
423
- hasChildren: false,
424
- description: "Range slider",
425
- example: 'slider "Volume" min=0 max=100 value=50'
426
- },
427
- {
428
- name: "button",
429
- nodeType: "Button",
430
- category: "input",
431
- attributes: [...COMMON_ATTRIBUTES, "primary", "secondary", "outline", "ghost", "danger", "size", "icon", "disabled", "loading"],
432
- hasChildren: false,
433
- description: "Clickable button",
434
- example: 'button "Submit" primary icon=send'
435
- },
436
- // ============================================
437
- // Display Components
438
- // ============================================
439
- {
440
- name: "image",
441
- nodeType: "Image",
442
- category: "display",
443
- attributes: [...COMMON_ATTRIBUTES, "src", "alt"],
444
- hasChildren: false,
445
- description: "Image placeholder",
446
- example: "image w=200 h=150"
447
- },
448
- {
449
- name: "placeholder",
450
- nodeType: "Placeholder",
451
- category: "display",
452
- attributes: [...COMMON_ATTRIBUTES, "label"],
453
- hasChildren: true,
454
- description: "Generic placeholder",
455
- example: 'placeholder "Banner Image" w=full h=200 { ... }'
456
- },
457
- {
458
- name: "avatar",
459
- nodeType: "Avatar",
460
- category: "display",
461
- attributes: [...COMMON_ATTRIBUTES, "name", "src", "size"],
462
- hasChildren: false,
463
- description: "User avatar",
464
- example: 'avatar "John Doe" size=lg'
24
+ component: {
25
+ example: 'component userbadge { avatar "SW" text "Seungwoo" }',
26
+ validParents: []
465
27
  },
466
- {
467
- name: "badge",
468
- nodeType: "Badge",
469
- category: "display",
470
- attributes: [...COMMON_ATTRIBUTES, "variant", "pill", "icon", "size"],
471
- hasChildren: false,
472
- description: "Status badge",
473
- example: 'badge "New" variant=success pill'
28
+ slot: {
29
+ example: "slot",
30
+ validParents: ["layout"]
474
31
  },
475
- {
476
- name: "icon",
477
- nodeType: "Icon",
478
- category: "display",
479
- attributes: [...COMMON_ATTRIBUTES, "size", "muted"],
480
- hasChildren: false,
481
- description: "Lucide icon",
482
- example: 'icon "settings" size=lg'
32
+ use: {
33
+ example: 'use userbadge(name="Ada") { ... }'
483
34
  },
484
- // ============================================
485
- // Data Components
486
- // ============================================
487
- {
488
- name: "table",
489
- nodeType: "Table",
490
- category: "data",
491
- attributes: [...COMMON_ATTRIBUTES, "striped", "bordered", "hover"],
492
- hasChildren: false,
493
- description: "Data table",
35
+ // Grid
36
+ row: { example: "row flex gap=4 justify=between { ... }" },
37
+ col: { example: "col span=6 md=4 { ... }" },
38
+ stack: { example: "stack gap=4 align=center { ... }" },
39
+ relative: { example: 'relative { button "Submit" marker 1 anchor=top-right }' },
40
+ // Container
41
+ card: { example: 'card "Settings" p=4 shadow=md { ... }' },
42
+ modal: { example: 'modal "Confirm" w=400 { ... }' },
43
+ drawer: { example: 'drawer "Menu" position=left { ... }' },
44
+ accordion: { example: 'accordion { section "FAQ 1" { ... } }' },
45
+ // Text
46
+ text: { example: 'text "Hello World" size=lg weight=bold' },
47
+ title: { example: 'title "Welcome" level=2' },
48
+ link: { example: 'link "Learn more" href="/docs" external' },
49
+ // Input
50
+ input: { example: 'input "Email" inputType=email placeholder="user@example.com" required' },
51
+ textarea: { example: 'textarea "Description" rows=4 placeholder="Enter description..."' },
52
+ select: { example: 'select "Country" ["USA", "Canada", "UK"] placeholder="Select..."' },
53
+ checkbox: { example: 'checkbox "I agree to terms" checked' },
54
+ radio: { example: 'radio "Option A" name="choice" checked' },
55
+ switch: { example: 'switch "Dark mode" checked' },
56
+ slider: { example: 'slider "Volume" min=0 max=100 value=50' },
57
+ button: { example: 'button "Submit" primary icon=send' },
58
+ // Display
59
+ image: { example: "image w=200 h=150" },
60
+ placeholder: { example: 'placeholder "Banner Image" w=full h=200 { ... }' },
61
+ avatar: { example: 'avatar "John Doe" size=lg' },
62
+ badge: { example: 'badge "New" variant=success pill' },
63
+ icon: { example: 'icon "settings" size=lg' },
64
+ // Data
65
+ table: {
494
66
  example: 'table striped bordered { columns ["Name", "Email"] row ["John", "john@example.com"] }'
495
67
  },
496
- {
497
- name: "list",
498
- nodeType: "List",
499
- category: "data",
500
- attributes: [...COMMON_ATTRIBUTES, "ordered", "none"],
501
- hasChildren: false,
502
- description: "List of items",
503
- example: 'list ordered ["First", "Second", "Third"]'
504
- },
505
- // ============================================
506
- // Feedback Components
507
- // ============================================
508
- {
509
- name: "alert",
510
- nodeType: "Alert",
511
- category: "feedback",
512
- attributes: [...COMMON_ATTRIBUTES, "variant", "dismissible", "icon"],
513
- hasChildren: false,
514
- description: "Alert message",
515
- example: 'alert "Changes saved!" variant=success'
516
- },
517
- {
518
- name: "toast",
519
- nodeType: "Toast",
520
- category: "feedback",
521
- attributes: [...COMMON_ATTRIBUTES, "position", "variant"],
522
- hasChildren: false,
523
- description: "Toast notification",
524
- example: 'toast "Item deleted" position=bottom-right variant=danger'
525
- },
526
- {
527
- name: "progress",
528
- nodeType: "Progress",
529
- category: "feedback",
530
- attributes: [...COMMON_ATTRIBUTES, "value", "max", "label", "indeterminate"],
531
- hasChildren: false,
532
- description: "Progress bar",
533
- example: 'progress value=75 label="Uploading..."'
534
- },
535
- {
536
- name: "spinner",
537
- nodeType: "Spinner",
538
- category: "feedback",
539
- attributes: [...COMMON_ATTRIBUTES, "label", "size"],
540
- hasChildren: false,
541
- description: "Loading spinner",
542
- example: "spinner size=lg"
543
- },
544
- // ============================================
545
- // Overlay Components
546
- // ============================================
547
- {
548
- name: "tooltip",
549
- nodeType: "Tooltip",
550
- category: "overlay",
551
- attributes: [...COMMON_ATTRIBUTES, "position"],
552
- hasChildren: false,
553
- description: "Tooltip on hover",
554
- example: 'tooltip "More info" position=top { icon "help-circle" }'
555
- },
556
- {
557
- name: "popover",
558
- nodeType: "Popover",
559
- category: "overlay",
560
- attributes: [...COMMON_ATTRIBUTES, "title"],
561
- hasChildren: true,
562
- description: "Popover panel",
563
- example: 'popover "Details" { ... }'
564
- },
565
- {
566
- name: "dropdown",
567
- nodeType: "Dropdown",
568
- category: "overlay",
569
- attributes: [...COMMON_ATTRIBUTES],
570
- hasChildren: false,
571
- description: "Dropdown menu",
572
- example: 'dropdown { item "Edit" icon=edit item "Delete" icon=trash danger }'
573
- },
574
- // ============================================
575
- // Navigation Components
576
- // ============================================
577
- {
578
- name: "nav",
579
- nodeType: "Nav",
580
- category: "navigation",
581
- attributes: [...COMMON_ATTRIBUTES, "vertical"],
582
- hasChildren: false,
583
- description: "Navigation menu",
584
- example: 'nav [{ label="Home" icon=home active }, { label="Settings" icon=settings }] vertical'
585
- },
586
- {
587
- name: "tabs",
588
- nodeType: "Tabs",
589
- category: "navigation",
590
- attributes: [...COMMON_ATTRIBUTES, "active"],
591
- hasChildren: true,
592
- description: "Tab navigation",
593
- example: 'tabs { tab "General" active { ... } tab "Advanced" { ... } }'
594
- },
595
- {
596
- name: "breadcrumb",
597
- nodeType: "Breadcrumb",
598
- category: "navigation",
599
- attributes: [...COMMON_ATTRIBUTES],
600
- hasChildren: false,
601
- description: "Breadcrumb navigation",
68
+ list: { example: 'list ordered ["First", "Second", "Third"]' },
69
+ // Feedback
70
+ alert: { example: 'alert "Changes saved!" variant=success' },
71
+ toast: { example: 'toast "Item deleted" position=bottom-right variant=danger' },
72
+ progress: { example: 'progress value=75 label="Uploading..."' },
73
+ spinner: { example: "spinner size=lg" },
74
+ // Overlay
75
+ tooltip: { example: 'tooltip "More info" position=top { icon "circle-question-mark" }' },
76
+ popover: { example: 'popover "Details" { ... }' },
77
+ dropdown: { example: 'dropdown { item "Edit" icon=pencil item "Delete" icon=trash danger }' },
78
+ // Navigation
79
+ nav: {
80
+ example: 'nav [{ label="Home" icon=house active }, { label="Settings" icon=settings }] vertical'
81
+ },
82
+ tabs: { example: 'tabs { tab "General" active { ... } tab "Advanced" { ... } }' },
83
+ breadcrumb: {
602
84
  example: 'breadcrumb [{ label="Home" href="/" }, { label="Products" }, { label="Details" }]'
603
85
  },
604
- // ============================================
605
- // Divider Component
606
- // ============================================
607
- {
608
- name: "divider",
609
- nodeType: "Divider",
610
- category: "layout",
611
- attributes: [...COMMON_ATTRIBUTES, "vertical"],
612
- hasChildren: false,
613
- description: "Horizontal separator",
614
- example: "divider my=4"
615
- },
616
- // ============================================
617
- // Annotation Components
618
- // ============================================
619
- {
620
- name: "marker",
621
- nodeType: "Marker",
622
- category: "annotation",
623
- attributes: [...COMMON_ATTRIBUTES, "color", "anchor"],
624
- hasChildren: false,
625
- description: "Number marker for referencing in annotations",
626
- example: "marker 1 anchor=top-right color=blue"
627
- },
628
- {
629
- name: "annotations",
630
- nodeType: "Annotations",
631
- category: "annotation",
632
- attributes: [...COMMON_ATTRIBUTES, "title"],
633
- hasChildren: true,
634
- description: "Documentation panel for screen specifications",
86
+ // Divider
87
+ divider: { example: "divider my=4" },
88
+ // Annotation
89
+ marker: { example: "marker 1 anchor=top-right color=blue" },
90
+ annotations: {
635
91
  example: 'annotations title="\uD654\uBA74 \uC124\uBA85" { item 1 "\uC81C\uBAA9" { text "\uC124\uBA85" } }',
636
92
  validChildren: ["item"]
637
93
  },
638
- {
639
- name: "item",
640
- nodeType: "AnnotationItem",
641
- category: "annotation",
642
- attributes: [],
643
- hasChildren: true,
644
- description: "Individual annotation entry with marker number and title",
94
+ item: {
645
95
  example: 'item 1 "\uB85C\uADF8\uC778 \uBC84\uD2BC" { text "OAuth \uC5F0\uB3D9 \uC608\uC815" }',
646
96
  validParents: ["annotations"]
647
97
  }
648
- ];
98
+ };
99
+ function toComponentDef(name) {
100
+ const spec = COMPONENT_SPEC_BY_NAME[name];
101
+ const { example, validChildren, validParents, extraAttributes } = EDITOR_METADATA[name];
102
+ return {
103
+ name: spec.name,
104
+ nodeType: spec.nodeType,
105
+ category: spec.category,
106
+ attributes: [...spec.attributes, ...extraAttributes ?? []],
107
+ hasChildren: spec.hasChildren,
108
+ description: spec.description,
109
+ example,
110
+ ...validChildren ? { validChildren } : {},
111
+ ...validParents ? { validParents } : {}
112
+ };
113
+ }
114
+ var ALL_COMPONENTS = COMPONENT_NAMES.map(toComponentDef);
649
115
  var COMPONENT_MAP = new Map(
650
116
  ALL_COMPONENTS.map((comp) => [comp.name, comp])
651
117
  );
@@ -656,8 +122,205 @@ var VALID_COMPONENT_NAMES = new Set(
656
122
  ALL_COMPONENTS.map((comp) => comp.name)
657
123
  );
658
124
 
125
+ // src/attributes.ts
126
+ import {
127
+ ATTRIBUTE_SPECS as ATTRIBUTE_SPECS2,
128
+ BOX_ATTRIBUTES as SPEC_BOX_ATTRIBUTES,
129
+ CONTAINER_ATTRIBUTES as SPEC_CONTAINER_ATTRIBUTES
130
+ } from "@wireweave/core/spec";
131
+
132
+ // src/core-spec-gaps.ts
133
+ import { ATTRIBUTE_SPECS } from "@wireweave/core/spec";
134
+ function coreValuesOf(name) {
135
+ const values = ATTRIBUTE_SPECS.find((spec) => spec.name === name)?.values;
136
+ return values ? [...values] : void 0;
137
+ }
138
+ var EDITOR_ONLY_ATTRIBUTES = [
139
+ {
140
+ name: "at",
141
+ type: "function",
142
+ description: "Place page on the multi-page canvas at (x, y) \u2014 pages without at() auto-flow horizontally",
143
+ example: "at(0, 0)"
144
+ },
145
+ {
146
+ // Desugared, not missing. `wireframe.peggy` (Input rule) reads the authored
147
+ // `type`, deletes it, and re-emits it as `inputType`; the renderer then reads
148
+ // `node.inputType` for the HTML type attribute. The rename is forced, not
149
+ // incidental: `type` is every AST node's kind discriminant, which is why
150
+ // `validation/index.ts` lists it among the structural keys it skips. Adding
151
+ // `type` to `ATTRIBUTE_SPECS` would put the same name in `validate()`'s
152
+ // known-attribute set and its structural-skip set at once, so core is right
153
+ // to declare only `inputType` and this is the source spelling's only home.
154
+ name: "type",
155
+ type: "string",
156
+ // One attribute, two spellings — so one value space. Copying core's list
157
+ // would let `inputType` gain a value that `type=` never completes.
158
+ values: coreValuesOf("inputType"),
159
+ description: "Input type \u2014 written as `type` and stored on the node as `inputType`",
160
+ example: "type=email"
161
+ }
162
+ ];
163
+ var PENDING_CORE_ATTRIBUTES = [];
164
+
165
+ // src/attributes.ts
166
+ var ATTRIBUTE_EXAMPLES = {
167
+ // Spacing
168
+ p: "p=4",
169
+ px: "px=4",
170
+ py: "py=4",
171
+ pt: "pt=4",
172
+ pr: "pr=4",
173
+ pb: "pb=4",
174
+ pl: "pl=4",
175
+ m: "m=4",
176
+ mx: "mx=auto",
177
+ my: "my=4",
178
+ mt: "mt=4",
179
+ mr: "mr=4",
180
+ mb: "mb=4",
181
+ ml: "ml=4",
182
+ gap: "gap=4",
183
+ // Size
184
+ w: "w=full",
185
+ h: "h=full",
186
+ width: "width=400",
187
+ height: "height=300",
188
+ minW: "minW=200",
189
+ maxW: "maxW=600",
190
+ minH: "minH=100",
191
+ maxH: "maxH=400",
192
+ // Flex / Grid
193
+ flex: "flex",
194
+ direction: "direction=column",
195
+ justify: "justify=center",
196
+ align: "align=center",
197
+ wrap: "wrap",
198
+ span: "span=6",
199
+ sm: "sm=6",
200
+ md: "md=4",
201
+ lg: "lg=3",
202
+ xl: "xl=2",
203
+ order: "order=1",
204
+ // Position
205
+ x: "x=100",
206
+ y: "y=50",
207
+ position: "position=left",
208
+ // Visual
209
+ border: "border",
210
+ rounded: "rounded",
211
+ shadow: "shadow=md",
212
+ bg: "bg=muted",
213
+ // Text
214
+ size: "size=lg",
215
+ weight: "weight=bold",
216
+ level: "level=2",
217
+ muted: "muted",
218
+ bold: "bold",
219
+ // Button variants
220
+ primary: "primary",
221
+ secondary: "secondary",
222
+ outline: "outline",
223
+ ghost: "ghost",
224
+ danger: "danger",
225
+ // Status variant
226
+ variant: "variant=success",
227
+ // Form
228
+ inputType: "inputType=email",
229
+ placeholder: 'placeholder="Enter text"',
230
+ value: 'value="default"',
231
+ label: 'label="Name"',
232
+ name: 'name="field"',
233
+ required: "required",
234
+ disabled: "disabled",
235
+ readonly: "readonly",
236
+ checked: "checked",
237
+ loading: "loading",
238
+ rows: "rows=4",
239
+ min: "min=0",
240
+ max: "max=100",
241
+ step: "step=1",
242
+ // Content
243
+ title: 'title="Title"',
244
+ src: 'src="/image.png"',
245
+ alt: 'alt="Image"',
246
+ href: 'href="/path"',
247
+ icon: 'icon="home"',
248
+ external: "external",
249
+ // Accessibility
250
+ aria: 'aria="Close dialog"',
251
+ "aria-label": 'aria-label="Close dialog"',
252
+ // State
253
+ active: "active=0",
254
+ expanded: "expanded",
255
+ centered: "centered",
256
+ vertical: "vertical",
257
+ scroll: "scroll",
258
+ // Feedback
259
+ dismissible: "dismissible",
260
+ indeterminate: "indeterminate",
261
+ pill: "pill",
262
+ // Data
263
+ striped: "striped",
264
+ bordered: "bordered",
265
+ hover: "hover",
266
+ ordered: "ordered",
267
+ none: "none",
268
+ // Page / viewport
269
+ id: 'id="dashboard"',
270
+ viewport: 'viewport="1440x900"',
271
+ device: 'device="iphone14"',
272
+ // Reuse
273
+ uses: 'uses="app-shell"',
274
+ // Interaction
275
+ navigate: 'navigate="Dashboard"',
276
+ opens: 'opens="settings-modal"',
277
+ toggles: 'toggles="filter-drawer"',
278
+ action: "action=back",
279
+ // Typed state and events
280
+ states: "states=[{ name=allowed, valueType=boolean, initial=false }]",
281
+ on: "on={ event=click, effects=[{ kind=toggle, state=allowed }] }",
282
+ visibleWhen: "visibleWhen={ state=allowed, equals=true }",
283
+ enabledWhen: "enabledWhen={ state=allowed, equals=true }",
284
+ // Annotation
285
+ anchor: "anchor=top-right",
286
+ color: "color=blue"
287
+ };
288
+ function toAttributeDef(spec) {
289
+ const example = ATTRIBUTE_EXAMPLES[spec.name];
290
+ if (example === void 0) {
291
+ throw new Error(
292
+ `[@wireweave/language-data] No editor example for attribute "${spec.name}". Add one to ATTRIBUTE_EXAMPLES in src/attributes.ts.`
293
+ );
294
+ }
295
+ if (spec.description === void 0) {
296
+ throw new Error(
297
+ `[@wireweave/language-data] Attribute "${spec.name}" has no description in the core spec.`
298
+ );
299
+ }
300
+ return {
301
+ name: spec.name,
302
+ type: spec.type,
303
+ ...spec.values ? { values: [...spec.values] } : {},
304
+ description: spec.description,
305
+ example
306
+ };
307
+ }
308
+ var ATTRIBUTES = [
309
+ ...ATTRIBUTE_SPECS2.map(toAttributeDef),
310
+ ...EDITOR_ONLY_ATTRIBUTES,
311
+ ...PENDING_CORE_ATTRIBUTES
312
+ ];
313
+ var ATTRIBUTE_MAP = new Map(
314
+ ATTRIBUTES.map((attr) => [attr.name, attr])
315
+ );
316
+ var VALID_ATTRIBUTE_NAMES = new Set(
317
+ ATTRIBUTES.map((attr) => attr.name)
318
+ );
319
+
659
320
  // src/keywords.ts
321
+ import { ATTRIBUTE_SPECS as ATTRIBUTE_SPECS3 } from "@wireweave/core/spec";
660
322
  var CATEGORY_LABELS = {
323
+ structure: "Structure",
661
324
  layout: "Layout",
662
325
  container: "Container",
663
326
  grid: "Grid",
@@ -670,86 +333,13 @@ var CATEGORY_LABELS = {
670
333
  navigation: "Navigation",
671
334
  annotation: "Annotation"
672
335
  };
336
+ var BOOLEAN_LITERALS = ["true", "false"];
673
337
  var VALUE_KEYWORDS = [
674
- // Booleans
675
- "true",
676
- "false",
677
- // Button variants
678
- "primary",
679
- "secondary",
680
- "outline",
681
- "ghost",
682
- // Status variants
683
- "success",
684
- "danger",
685
- "warning",
686
- "info",
687
- "default",
688
- // Sizes
689
- "xs",
690
- "sm",
691
- "md",
692
- "lg",
693
- "xl",
694
- "base",
695
- "2xl",
696
- "3xl",
697
- // Flex alignment
698
- "start",
699
- "center",
700
- "end",
701
- "between",
702
- "around",
703
- "evenly",
704
- "stretch",
705
- "baseline",
706
- // Positions
707
- "left",
708
- "right",
709
- "top",
710
- "bottom",
711
- "top-left",
712
- "top-center",
713
- "top-right",
714
- "bottom-left",
715
- "bottom-center",
716
- "bottom-right",
717
- "center-left",
718
- "center-right",
719
- // Marker colors
720
- "blue",
721
- "red",
722
- "green",
723
- "yellow",
724
- "purple",
725
- "orange",
726
- // Sizing
727
- "full",
728
- "auto",
729
- "screen",
730
- "fit",
731
- // Font weights
732
- "normal",
733
- "medium",
734
- "semibold",
735
- "bold",
736
- // Input types
737
- "text",
738
- "email",
739
- "password",
740
- "number",
741
- "tel",
742
- "url",
743
- "search",
744
- "date",
745
- // Flex direction
746
- "row",
747
- "column",
748
- "row-reverse",
749
- "column-reverse",
750
- // List
751
- "none",
752
- "nowrap"
338
+ .../* @__PURE__ */ new Set([
339
+ ...BOOLEAN_LITERALS,
340
+ ...ATTRIBUTE_SPECS3.flatMap((attr) => attr.values ?? []),
341
+ ...PENDING_CORE_ATTRIBUTES.flatMap((attr) => attr.values ?? [])
342
+ ])
753
343
  ];
754
344
 
755
345
  // src/utils.ts
@@ -774,69 +364,8 @@ function getComponentAttributes(componentName) {
774
364
  }
775
365
 
776
366
  // src/codemirror/language.ts
777
- var COMPONENT_NAMES = ALL_COMPONENTS.map((c) => c.name);
367
+ var COMPONENT_NAMES2 = ALL_COMPONENTS.map((c) => c.name);
778
368
  var ATTRIBUTE_NAMES = ATTRIBUTES.map((a) => a.name);
779
- var VALUE_KEYWORDS2 = [
780
- // Sizes
781
- "xs",
782
- "sm",
783
- "md",
784
- "lg",
785
- "xl",
786
- "2xl",
787
- "3xl",
788
- // Weights
789
- "thin",
790
- "light",
791
- "normal",
792
- "medium",
793
- "semibold",
794
- "bold",
795
- "extrabold",
796
- // Alignments
797
- "left",
798
- "center",
799
- "right",
800
- "start",
801
- "end",
802
- "top",
803
- "middle",
804
- "bottom",
805
- "between",
806
- "around",
807
- "evenly",
808
- "stretch",
809
- // Directions
810
- "horizontal",
811
- "vertical",
812
- // Variants
813
- "primary",
814
- "secondary",
815
- "outline",
816
- "ghost",
817
- "link",
818
- "danger",
819
- "info",
820
- "success",
821
- "warning",
822
- "error",
823
- // Boolean
824
- "true",
825
- "false",
826
- // Devices
827
- "mobile",
828
- "tablet",
829
- "desktop",
830
- // Input types
831
- "text",
832
- "email",
833
- "password",
834
- "number",
835
- "tel",
836
- "url",
837
- "search",
838
- "date"
839
- ];
840
369
  function createTokenizer() {
841
370
  return {
842
371
  token(stream) {
@@ -851,7 +380,7 @@ function createTokenizer() {
851
380
  if (stream.match(/\d+/)) {
852
381
  return "number";
853
382
  }
854
- for (const kw of COMPONENT_NAMES) {
383
+ for (const kw of COMPONENT_NAMES2) {
855
384
  if (stream.match(new RegExp(`^${kw}\\b`))) {
856
385
  return "keyword";
857
386
  }
@@ -861,7 +390,7 @@ function createTokenizer() {
861
390
  return "propertyName";
862
391
  }
863
392
  }
864
- for (const val of VALUE_KEYWORDS2) {
393
+ for (const val of VALUE_KEYWORDS) {
865
394
  if (stream.match(new RegExp(`^${val}\\b`))) {
866
395
  return "atom";
867
396
  }
@@ -927,6 +456,7 @@ function createCompletionSource() {
927
456
  });
928
457
  });
929
458
  } else if (attr?.type === "number") {
459
+ ;
930
460
  [1, 2, 3, 4, 5, 6, 8, 10, 12, 16].forEach((n) => {
931
461
  options.push({
932
462
  label: String(n),
@@ -971,6 +501,8 @@ function createCompletionSource() {
971
501
  apply = `${attr.name}=""`;
972
502
  } else if (attr.type === "number" || attr.type === "enum") {
973
503
  apply = `${attr.name}=`;
504
+ } else if (attr.type === "function") {
505
+ apply = `${attr.name}(`;
974
506
  }
975
507
  options.push({
976
508
  label: attr.name,
@@ -987,6 +519,8 @@ function createCompletionSource() {
987
519
  apply = `${attr.name}=""`;
988
520
  } else if (attr.type === "number" || attr.type === "enum") {
989
521
  apply = `${attr.name}=`;
522
+ } else if (attr.type === "function") {
523
+ apply = `${attr.name}(`;
990
524
  }
991
525
  options.push({
992
526
  label: attr.name,
@@ -1076,6 +610,8 @@ function createHoverTooltipSource() {
1076
610
  valueInfo = "Type: boolean";
1077
611
  } else if (attribute.type === "enum" && attribute.values) {
1078
612
  valueInfo = `Values: ${attribute.values.join(" | ")}`;
613
+ } else if (attribute.type === "function") {
614
+ valueInfo = `Functional shorthand. Example: ${attribute.example}`;
1079
615
  }
1080
616
  return {
1081
617
  pos: from,
@@ -1100,9 +636,7 @@ function createHoverTooltipSource() {
1100
636
  };
1101
637
  }
1102
638
  if (VALUE_KEYWORDS.includes(word)) {
1103
- const relatedAttrs = ATTRIBUTES.filter(
1104
- (a) => a.type === "enum" && a.values?.includes(word)
1105
- );
639
+ const relatedAttrs = ATTRIBUTES.filter((a) => a.type === "enum" && a.values?.includes(word));
1106
640
  if (relatedAttrs.length > 0) {
1107
641
  return {
1108
642
  pos: from,
@@ -1135,7 +669,7 @@ function createHoverTooltipSource() {
1135
669
  function validateCode(text) {
1136
670
  const diagnostics = [];
1137
671
  const lines = text.split("\n");
1138
- let braceStack = [];
672
+ const braceStack = [];
1139
673
  let hasPage = false;
1140
674
  let currentPos = 0;
1141
675
  for (let lineNum = 0; lineNum < lines.length; lineNum++) {