@wireweave/language-data 1.5.2 → 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.
- package/README.md +52 -143
- package/dist/codemirror/index.cjs +238 -34
- package/dist/codemirror/index.cjs.map +1 -1
- package/dist/codemirror/index.d.cts +13 -23
- package/dist/codemirror/index.d.ts +13 -23
- package/dist/codemirror/index.js +238 -34
- package/dist/codemirror/index.js.map +1 -1
- package/dist/index.cjs +231 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +231 -30
- package/dist/index.js.map +1 -1
- package/dist/monaco/index.cjs +276 -49
- package/dist/monaco/index.cjs.map +1 -1
- package/dist/monaco/index.d.cts +13 -19
- package/dist/monaco/index.d.ts +13 -19
- package/dist/monaco/index.js +276 -49
- package/dist/monaco/index.js.map +1 -1
- package/package.json +88 -23
package/README.md
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="https://docs.wireweave.org/assets/wireweave-language-data.svg" width="128" height="128" alt="Wireweave Language Data">
|
|
3
|
-
</p>
|
|
1
|
+
# @wireweave/language-data
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
Component and attribute vocabulary for the Wireweave DSL, for editor autocomplete, validation, and tooling.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
## What it does
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
`@wireweave/language-data` is the single source of the Wireweave DSL vocabulary — every component, its allowed attributes, valid children, categories, and value keywords — exposed as plain data plus lookup helpers. It powers autocomplete, hover docs, and validation hints in editor integrations.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
npm install @wireweave/language-data
|
|
13
|
-
# or
|
|
14
|
-
pnpm add @wireweave/language-data
|
|
15
|
-
```
|
|
9
|
+
This package is **independent of `@wireweave/core`** — it ships only the language metadata, with no parser or renderer dependency.
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
Optional subpath entries provide ready-made editor integrations:
|
|
18
12
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
- **CodeMirror Integration** - Full IntelliSense for CodeMirror 6
|
|
22
|
-
- **Zero Dependencies** - Standalone package
|
|
13
|
+
- `@wireweave/language-data/monaco` — register the Wireweave language with Monaco Editor.
|
|
14
|
+
- `@wireweave/language-data/codemirror` — tokenizer, completion, hover, and linting sources for CodeMirror 6.
|
|
23
15
|
|
|
24
|
-
|
|
16
|
+
The editor adapters rely on optional peer dependencies (`monaco-editor`, `@codemirror/*`) — install only the ones for the integration you use.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
```bash
|
|
21
|
+
npm i @wireweave/language-data
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
27
25
|
|
|
28
26
|
```typescript
|
|
29
27
|
import {
|
|
@@ -33,150 +31,61 @@ import {
|
|
|
33
31
|
getAttribute,
|
|
34
32
|
getValidChildren,
|
|
35
33
|
getComponentAttributes,
|
|
36
|
-
|
|
34
|
+
isValidChild,
|
|
35
|
+
} from '@wireweave/language-data'
|
|
37
36
|
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
console.log(
|
|
37
|
+
// Component definition
|
|
38
|
+
const card = getComponent('card')
|
|
39
|
+
console.log(card?.description)
|
|
41
40
|
|
|
42
|
-
//
|
|
43
|
-
const
|
|
44
|
-
console.log(gap?.type); // "number"
|
|
41
|
+
// Attributes allowed on a component
|
|
42
|
+
const cardAttrs = getComponentAttributes('card')
|
|
45
43
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
// Validity checks for the editor
|
|
45
|
+
isValidChild('page', 'card') // true / false
|
|
46
|
+
getValidChildren('grid') // valid child component names
|
|
49
47
|
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
console.log(attrs.map(a => a.name));
|
|
48
|
+
// Full vocabulary
|
|
49
|
+
console.log(ALL_COMPONENTS.length, ATTRIBUTES.length)
|
|
53
50
|
```
|
|
54
51
|
|
|
55
|
-
### Monaco
|
|
52
|
+
### Monaco integration
|
|
56
53
|
|
|
57
54
|
```typescript
|
|
58
|
-
import * as monaco from 'monaco-editor'
|
|
59
|
-
import {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
getLanguageConfiguration,
|
|
63
|
-
createHoverProvider,
|
|
64
|
-
createCompletionProvider,
|
|
65
|
-
createDiagnosticsSetup,
|
|
66
|
-
} from '@wireweave/language-data/monaco';
|
|
67
|
-
|
|
68
|
-
// Register language
|
|
69
|
-
monaco.languages.register({ id: LANGUAGE_ID });
|
|
70
|
-
monaco.languages.setMonarchTokensProvider(LANGUAGE_ID, getMonarchTokensProvider());
|
|
71
|
-
monaco.languages.setLanguageConfiguration(LANGUAGE_ID, getLanguageConfiguration());
|
|
72
|
-
|
|
73
|
-
// Register IntelliSense
|
|
74
|
-
monaco.languages.registerHoverProvider(LANGUAGE_ID, createHoverProvider(monaco));
|
|
75
|
-
monaco.languages.registerCompletionItemProvider(LANGUAGE_ID, createCompletionProvider(monaco));
|
|
76
|
-
|
|
77
|
-
// Setup diagnostics
|
|
78
|
-
const editor = monaco.editor.create(container, { language: LANGUAGE_ID });
|
|
79
|
-
const setupDiagnostics = createDiagnosticsSetup(monaco);
|
|
80
|
-
setupDiagnostics(editor);
|
|
55
|
+
import * as monaco from 'monaco-editor'
|
|
56
|
+
import { registerWireframeLanguage } from '@wireweave/language-data/monaco'
|
|
57
|
+
|
|
58
|
+
registerWireframeLanguage(monaco)
|
|
81
59
|
```
|
|
82
60
|
|
|
83
|
-
### CodeMirror
|
|
61
|
+
### CodeMirror 6 integration
|
|
84
62
|
|
|
85
63
|
```typescript
|
|
86
|
-
import { StreamLanguage } from '@codemirror/language';
|
|
87
|
-
import { autocompletion } from '@codemirror/autocomplete';
|
|
88
|
-
import { hoverTooltip } from '@codemirror/view';
|
|
89
|
-
import { linter } from '@codemirror/lint';
|
|
90
64
|
import {
|
|
91
65
|
createTokenizer,
|
|
66
|
+
getLanguageConfig,
|
|
92
67
|
createCompletionSource,
|
|
93
68
|
createHoverTooltipSource,
|
|
94
69
|
createLinter,
|
|
95
|
-
} from '@wireweave/language-data/codemirror'
|
|
96
|
-
|
|
97
|
-
// Create language
|
|
98
|
-
const wireframeLanguage = StreamLanguage.define(createTokenizer());
|
|
99
|
-
|
|
100
|
-
// Setup extensions
|
|
101
|
-
const extensions = [
|
|
102
|
-
wireframeLanguage,
|
|
103
|
-
autocompletion({ override: [createCompletionSource()] }),
|
|
104
|
-
hoverTooltip(createHoverTooltipSource()),
|
|
105
|
-
linter(createLinter()),
|
|
106
|
-
];
|
|
70
|
+
} from '@wireweave/language-data/codemirror'
|
|
107
71
|
```
|
|
108
72
|
|
|
109
|
-
##
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
|
114
|
-
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
### Monaco (`@wireweave/language-data/monaco`)
|
|
127
|
-
|
|
128
|
-
| Export | Description |
|
|
129
|
-
|--------|-------------|
|
|
130
|
-
| `LANGUAGE_ID` | Language identifier (`"wireframe"`) |
|
|
131
|
-
| `getMonarchTokensProvider()` | Monarch tokenizer for syntax highlighting |
|
|
132
|
-
| `getLanguageConfiguration()` | Brackets, comments, auto-closing |
|
|
133
|
-
| `createHoverProvider(monaco)` | Hover tooltip provider |
|
|
134
|
-
| `createCompletionProvider(monaco)` | Auto-completion provider |
|
|
135
|
-
| `createDiagnosticsSetup(monaco)` | Diagnostics/linting setup |
|
|
136
|
-
|
|
137
|
-
### CodeMirror (`@wireweave/language-data/codemirror`)
|
|
138
|
-
|
|
139
|
-
| Export | Description |
|
|
140
|
-
|--------|-------------|
|
|
141
|
-
| `createTokenizer()` | StreamLanguage tokenizer |
|
|
142
|
-
| `createCompletionSource()` | Auto-completion source |
|
|
143
|
-
| `createHoverTooltipSource()` | Hover tooltip source |
|
|
144
|
-
| `createLinter()` | Linter for diagnostics |
|
|
145
|
-
|
|
146
|
-
## Types
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
interface ComponentDef {
|
|
150
|
-
name: string;
|
|
151
|
-
nodeType: string;
|
|
152
|
-
category: ComponentCategory;
|
|
153
|
-
attributes: string[];
|
|
154
|
-
hasChildren: boolean;
|
|
155
|
-
description: string;
|
|
156
|
-
example: string;
|
|
157
|
-
validChildren?: string[];
|
|
158
|
-
validParents?: string[];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
interface AttributeDef {
|
|
162
|
-
name: string;
|
|
163
|
-
type: 'string' | 'number' | 'boolean' | 'enum';
|
|
164
|
-
values?: string[];
|
|
165
|
-
description: string;
|
|
166
|
-
example: string;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
type ComponentCategory =
|
|
170
|
-
| 'layout' | 'container' | 'grid' | 'text'
|
|
171
|
-
| 'input' | 'display' | 'data' | 'feedback'
|
|
172
|
-
| 'overlay' | 'navigation';
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Used By
|
|
176
|
-
|
|
177
|
-
- **[@wireweave/playground](https://github.com/wireweave/playground)** - Monaco Editor integration
|
|
178
|
-
- **[wireweave-vscode](https://github.com/wireweave/vscode-extension)** - VS Code extension
|
|
179
|
-
- **[dashboard](https://wireweave.org)** - CodeMirror integration
|
|
73
|
+
## Main API
|
|
74
|
+
|
|
75
|
+
| Export | Description |
|
|
76
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
77
|
+
| `ALL_COMPONENTS`, `COMPONENT_MAP`, `NODE_TYPE_MAP`, `VALID_COMPONENT_NAMES` | Component definitions and lookup maps. |
|
|
78
|
+
| `ATTRIBUTES`, `ATTRIBUTE_MAP`, `COMMON_ATTRIBUTES`, `VALID_ATTRIBUTE_NAMES` | Attribute definitions and lookup maps. |
|
|
79
|
+
| `CATEGORY_LABELS`, `VALUE_KEYWORDS`, `COMMON_NUMBERS`, `SPACING_SCALE` | Categories, value keywords, and numeric scales for completion. |
|
|
80
|
+
| `getComponent`, `getComponentByNodeType`, `getComponentAttributes`, `getComponentsByCategory` | Component lookups. |
|
|
81
|
+
| `getAttribute`, `getAttributeTypeLabel`, `formatAttributeValues` | Attribute lookups and formatting. |
|
|
82
|
+
| `getValidChildren`, `isValidChild` | Containment rules for validation. |
|
|
83
|
+
| `isComponent`, `isAttribute`, `getComponentNames`, `getAttributeNames`, `getCategories` | Membership checks and name listings. |
|
|
84
|
+
| `ComponentDef`, `AttributeDef`, `ComponentCategory`, `AttributeValueType` | Type definitions. |
|
|
85
|
+
| `registerWireframeLanguage` (`/monaco`) | Register the language with Monaco Editor. |
|
|
86
|
+
| `createTokenizer`, `getLanguageConfig`, `createCompletionSource`, `createHoverTooltipSource`, `createLinter`, `validateCode` (`/codemirror`) | CodeMirror 6 language sources. |
|
|
87
|
+
|
|
88
|
+
Part of the [Wireweave monorepo](https://github.com/wireweave/wireweave).
|
|
180
89
|
|
|
181
90
|
## License
|
|
182
91
|
|
|
@@ -78,7 +78,12 @@ var ATTRIBUTES = [
|
|
|
78
78
|
{ name: "pb", type: "number", description: "Bottom padding", example: "pb=4" },
|
|
79
79
|
{ name: "pl", type: "number", description: "Left padding", example: "pl=4" },
|
|
80
80
|
{ name: "m", type: "number", description: "Margin (all sides)", example: "m=4" },
|
|
81
|
-
{
|
|
81
|
+
{
|
|
82
|
+
name: "mx",
|
|
83
|
+
type: "string",
|
|
84
|
+
description: 'Horizontal margin (number or "auto")',
|
|
85
|
+
example: "mx=auto"
|
|
86
|
+
},
|
|
82
87
|
{ name: "my", type: "number", description: "Vertical margin", example: "my=4" },
|
|
83
88
|
{ name: "mt", type: "number", description: "Top margin", example: "mt=4" },
|
|
84
89
|
{ name: "mr", type: "number", description: "Right margin", example: "mr=4" },
|
|
@@ -88,10 +93,30 @@ var ATTRIBUTES = [
|
|
|
88
93
|
// ============================================
|
|
89
94
|
// Size Attributes
|
|
90
95
|
// ============================================
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
{
|
|
97
|
+
name: "w",
|
|
98
|
+
type: "string",
|
|
99
|
+
description: 'Width (number, "full", "auto", "screen", "fit")',
|
|
100
|
+
example: "w=full"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "h",
|
|
104
|
+
type: "string",
|
|
105
|
+
description: 'Height (number, "full", "auto", "screen")',
|
|
106
|
+
example: "h=full"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "width",
|
|
110
|
+
type: "number",
|
|
111
|
+
description: "Width in pixels (page only)",
|
|
112
|
+
example: "width=400"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "height",
|
|
116
|
+
type: "number",
|
|
117
|
+
description: "Height in pixels (page only)",
|
|
118
|
+
example: "height=300"
|
|
119
|
+
},
|
|
95
120
|
{ name: "minW", type: "number", description: "Minimum width", example: "minW=200" },
|
|
96
121
|
{ name: "maxW", type: "number", description: "Maximum width", example: "maxW=600" },
|
|
97
122
|
{ name: "minH", type: "number", description: "Minimum height", example: "minH=100" },
|
|
@@ -100,9 +125,27 @@ var ATTRIBUTES = [
|
|
|
100
125
|
// Flex/Grid Layout Attributes
|
|
101
126
|
// ============================================
|
|
102
127
|
{ name: "flex", type: "boolean", description: "Enable flexbox", example: "flex" },
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
128
|
+
{
|
|
129
|
+
name: "direction",
|
|
130
|
+
type: "enum",
|
|
131
|
+
values: ["row", "column", "row-reverse", "column-reverse"],
|
|
132
|
+
description: "Flex direction",
|
|
133
|
+
example: "direction=column"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "justify",
|
|
137
|
+
type: "enum",
|
|
138
|
+
values: ["start", "center", "end", "between", "around", "evenly"],
|
|
139
|
+
description: "Main axis alignment",
|
|
140
|
+
example: "justify=center"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "align",
|
|
144
|
+
type: "enum",
|
|
145
|
+
values: ["start", "center", "end", "stretch", "baseline"],
|
|
146
|
+
description: "Cross axis alignment",
|
|
147
|
+
example: "align=center"
|
|
148
|
+
},
|
|
106
149
|
{ name: "wrap", type: "boolean", description: "Enable flex wrap", example: "wrap" },
|
|
107
150
|
{ name: "span", type: "number", description: "Grid column span (1-12)", example: "span=6" },
|
|
108
151
|
{ name: "sm", type: "number", description: "Responsive span at 576px+", example: "sm=6" },
|
|
@@ -115,19 +158,60 @@ var ATTRIBUTES = [
|
|
|
115
158
|
// ============================================
|
|
116
159
|
{ name: "x", type: "number", description: "Horizontal position", example: "x=100" },
|
|
117
160
|
{ name: "y", type: "number", description: "Vertical position", example: "y=50" },
|
|
118
|
-
{
|
|
161
|
+
{
|
|
162
|
+
name: "position",
|
|
163
|
+
type: "enum",
|
|
164
|
+
values: [
|
|
165
|
+
"left",
|
|
166
|
+
"right",
|
|
167
|
+
"top",
|
|
168
|
+
"bottom",
|
|
169
|
+
"top-left",
|
|
170
|
+
"top-center",
|
|
171
|
+
"top-right",
|
|
172
|
+
"bottom-left",
|
|
173
|
+
"bottom-center",
|
|
174
|
+
"bottom-right"
|
|
175
|
+
],
|
|
176
|
+
description: "Position preset",
|
|
177
|
+
example: "position=left"
|
|
178
|
+
},
|
|
119
179
|
// ============================================
|
|
120
180
|
// Visual Attributes
|
|
121
181
|
// ============================================
|
|
122
182
|
{ name: "border", type: "boolean", description: "Show border", example: "border" },
|
|
123
183
|
{ name: "rounded", type: "boolean", description: "Apply border radius", example: "rounded" },
|
|
124
|
-
{
|
|
125
|
-
|
|
184
|
+
{
|
|
185
|
+
name: "shadow",
|
|
186
|
+
type: "enum",
|
|
187
|
+
values: ["none", "sm", "md", "lg", "xl"],
|
|
188
|
+
description: "Box shadow",
|
|
189
|
+
example: "shadow=md"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "bg",
|
|
193
|
+
type: "enum",
|
|
194
|
+
values: ["muted", "primary", "secondary"],
|
|
195
|
+
description: "Background variant",
|
|
196
|
+
example: "bg=muted"
|
|
197
|
+
},
|
|
126
198
|
// ============================================
|
|
127
199
|
// Text Attributes
|
|
128
200
|
// ============================================
|
|
129
|
-
{
|
|
130
|
-
|
|
201
|
+
{
|
|
202
|
+
name: "size",
|
|
203
|
+
type: "enum",
|
|
204
|
+
values: ["xs", "sm", "base", "md", "lg", "xl", "2xl", "3xl"],
|
|
205
|
+
description: "Size preset",
|
|
206
|
+
example: "size=lg"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "weight",
|
|
210
|
+
type: "enum",
|
|
211
|
+
values: ["normal", "medium", "semibold", "bold"],
|
|
212
|
+
description: "Font weight",
|
|
213
|
+
example: "weight=bold"
|
|
214
|
+
},
|
|
131
215
|
{ name: "level", type: "number", description: "Heading level (1-6)", example: "level=2" },
|
|
132
216
|
{ name: "muted", type: "boolean", description: "Muted/dimmed style", example: "muted" },
|
|
133
217
|
{ name: "bold", type: "boolean", description: "Bold text", example: "bold" },
|
|
@@ -142,12 +226,29 @@ var ATTRIBUTES = [
|
|
|
142
226
|
// ============================================
|
|
143
227
|
// Status Variant Attributes
|
|
144
228
|
// ============================================
|
|
145
|
-
{
|
|
229
|
+
{
|
|
230
|
+
name: "variant",
|
|
231
|
+
type: "enum",
|
|
232
|
+
values: ["default", "primary", "secondary", "success", "warning", "danger", "info"],
|
|
233
|
+
description: "Status variant",
|
|
234
|
+
example: "variant=success"
|
|
235
|
+
},
|
|
146
236
|
// ============================================
|
|
147
237
|
// Form Attributes
|
|
148
238
|
// ============================================
|
|
149
|
-
{
|
|
150
|
-
|
|
239
|
+
{
|
|
240
|
+
name: "inputType",
|
|
241
|
+
type: "enum",
|
|
242
|
+
values: ["text", "email", "password", "number", "tel", "url", "search", "date"],
|
|
243
|
+
description: "Input field type",
|
|
244
|
+
example: "inputType=email"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "placeholder",
|
|
248
|
+
type: "string",
|
|
249
|
+
description: "Placeholder text",
|
|
250
|
+
example: 'placeholder="Enter text"'
|
|
251
|
+
},
|
|
151
252
|
{ name: "value", type: "string", description: "Default value", example: 'value="default"' },
|
|
152
253
|
{ name: "label", type: "string", description: "Field label", example: 'label="Name"' },
|
|
153
254
|
{ name: "name", type: "string", description: "Form field name", example: 'name="field"' },
|
|
@@ -181,7 +282,12 @@ var ATTRIBUTES = [
|
|
|
181
282
|
// Feedback Attributes
|
|
182
283
|
// ============================================
|
|
183
284
|
{ name: "dismissible", type: "boolean", description: "Can be dismissed", example: "dismissible" },
|
|
184
|
-
{
|
|
285
|
+
{
|
|
286
|
+
name: "indeterminate",
|
|
287
|
+
type: "boolean",
|
|
288
|
+
description: "Indeterminate state",
|
|
289
|
+
example: "indeterminate"
|
|
290
|
+
},
|
|
185
291
|
{ name: "pill", type: "boolean", description: "Pill/rounded style", example: "pill" },
|
|
186
292
|
// ============================================
|
|
187
293
|
// Data Attributes
|
|
@@ -194,20 +300,73 @@ var ATTRIBUTES = [
|
|
|
194
300
|
// ============================================
|
|
195
301
|
// Page/Viewport Attributes
|
|
196
302
|
// ============================================
|
|
197
|
-
{
|
|
303
|
+
{
|
|
304
|
+
name: "viewport",
|
|
305
|
+
type: "string",
|
|
306
|
+
description: 'Viewport size (e.g., "1440x900")',
|
|
307
|
+
example: 'viewport="1440x900"'
|
|
308
|
+
},
|
|
198
309
|
{ name: "device", type: "string", description: "Device preset", example: 'device="iphone14"' },
|
|
310
|
+
{
|
|
311
|
+
name: "at",
|
|
312
|
+
type: "function",
|
|
313
|
+
description: "Place page on the multi-page canvas at (x, y) \u2014 pages without at() auto-flow horizontally",
|
|
314
|
+
example: "at(0, 0)"
|
|
315
|
+
},
|
|
199
316
|
// ============================================
|
|
200
317
|
// Interactive Attributes
|
|
201
318
|
// ============================================
|
|
202
|
-
{
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
319
|
+
{
|
|
320
|
+
name: "navigate",
|
|
321
|
+
type: "string",
|
|
322
|
+
description: "Navigation target URL or page",
|
|
323
|
+
example: 'navigate="/dashboard"'
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: "opens",
|
|
327
|
+
type: "string",
|
|
328
|
+
description: "Opens a modal, drawer, or popup",
|
|
329
|
+
example: 'opens="settings-modal"'
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: "toggles",
|
|
333
|
+
type: "string",
|
|
334
|
+
description: "Toggles visibility of an element",
|
|
335
|
+
example: 'toggles="menu"'
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "action",
|
|
339
|
+
type: "string",
|
|
340
|
+
description: "Action identifier for event handling",
|
|
341
|
+
example: 'action="submit-form"'
|
|
342
|
+
},
|
|
206
343
|
// ============================================
|
|
207
344
|
// Annotation Attributes
|
|
208
345
|
// ============================================
|
|
209
|
-
{
|
|
210
|
-
|
|
346
|
+
{
|
|
347
|
+
name: "anchor",
|
|
348
|
+
type: "enum",
|
|
349
|
+
values: [
|
|
350
|
+
"top-left",
|
|
351
|
+
"top-center",
|
|
352
|
+
"top-right",
|
|
353
|
+
"center-left",
|
|
354
|
+
"center",
|
|
355
|
+
"center-right",
|
|
356
|
+
"bottom-left",
|
|
357
|
+
"bottom-center",
|
|
358
|
+
"bottom-right"
|
|
359
|
+
],
|
|
360
|
+
description: "Anchor position for marker in relative container",
|
|
361
|
+
example: "anchor=top-right"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "color",
|
|
365
|
+
type: "enum",
|
|
366
|
+
values: ["blue", "red", "green", "yellow", "purple", "orange"],
|
|
367
|
+
description: "Marker color",
|
|
368
|
+
example: "color=blue"
|
|
369
|
+
}
|
|
211
370
|
];
|
|
212
371
|
var ATTRIBUTE_MAP = new Map(
|
|
213
372
|
ATTRIBUTES.map((attr) => [attr.name, attr])
|
|
@@ -225,10 +384,19 @@ var ALL_COMPONENTS = [
|
|
|
225
384
|
name: "page",
|
|
226
385
|
nodeType: "Page",
|
|
227
386
|
category: "layout",
|
|
228
|
-
attributes: [
|
|
387
|
+
attributes: [
|
|
388
|
+
...COMMON_ATTRIBUTES,
|
|
389
|
+
"title",
|
|
390
|
+
"width",
|
|
391
|
+
"height",
|
|
392
|
+
"viewport",
|
|
393
|
+
"device",
|
|
394
|
+
"centered",
|
|
395
|
+
"at"
|
|
396
|
+
],
|
|
229
397
|
hasChildren: true,
|
|
230
|
-
description: "Root container for a wireframe page",
|
|
231
|
-
example: 'page "
|
|
398
|
+
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.",
|
|
399
|
+
example: 'page "Login" at(0, 0) viewport="1280x800" { ... }',
|
|
232
400
|
validChildren: ["header", "main", "footer", "sidebar", "section", "nav", "row", "col", "card"],
|
|
233
401
|
validParents: []
|
|
234
402
|
},
|
|
@@ -396,7 +564,19 @@ var ALL_COMPONENTS = [
|
|
|
396
564
|
name: "input",
|
|
397
565
|
nodeType: "Input",
|
|
398
566
|
category: "input",
|
|
399
|
-
attributes: [
|
|
567
|
+
attributes: [
|
|
568
|
+
...COMMON_ATTRIBUTES,
|
|
569
|
+
"label",
|
|
570
|
+
"inputType",
|
|
571
|
+
"placeholder",
|
|
572
|
+
"value",
|
|
573
|
+
"disabled",
|
|
574
|
+
"required",
|
|
575
|
+
"readonly",
|
|
576
|
+
"icon",
|
|
577
|
+
"size",
|
|
578
|
+
"rounded"
|
|
579
|
+
],
|
|
400
580
|
hasChildren: false,
|
|
401
581
|
description: "Text input field",
|
|
402
582
|
example: 'input "Email" inputType=email placeholder="user@example.com" required'
|
|
@@ -405,7 +585,15 @@ var ALL_COMPONENTS = [
|
|
|
405
585
|
name: "textarea",
|
|
406
586
|
nodeType: "Textarea",
|
|
407
587
|
category: "input",
|
|
408
|
-
attributes: [
|
|
588
|
+
attributes: [
|
|
589
|
+
...COMMON_ATTRIBUTES,
|
|
590
|
+
"label",
|
|
591
|
+
"placeholder",
|
|
592
|
+
"value",
|
|
593
|
+
"rows",
|
|
594
|
+
"disabled",
|
|
595
|
+
"required"
|
|
596
|
+
],
|
|
409
597
|
hasChildren: false,
|
|
410
598
|
description: "Multi-line text input",
|
|
411
599
|
example: 'textarea "Description" rows=4 placeholder="Enter description..."'
|
|
@@ -459,7 +647,18 @@ var ALL_COMPONENTS = [
|
|
|
459
647
|
name: "button",
|
|
460
648
|
nodeType: "Button",
|
|
461
649
|
category: "input",
|
|
462
|
-
attributes: [
|
|
650
|
+
attributes: [
|
|
651
|
+
...COMMON_ATTRIBUTES,
|
|
652
|
+
"primary",
|
|
653
|
+
"secondary",
|
|
654
|
+
"outline",
|
|
655
|
+
"ghost",
|
|
656
|
+
"danger",
|
|
657
|
+
"size",
|
|
658
|
+
"icon",
|
|
659
|
+
"disabled",
|
|
660
|
+
"loading"
|
|
661
|
+
],
|
|
463
662
|
hasChildren: false,
|
|
464
663
|
description: "Clickable button",
|
|
465
664
|
example: 'button "Submit" primary icon=send'
|
|
@@ -958,6 +1157,7 @@ function createCompletionSource() {
|
|
|
958
1157
|
});
|
|
959
1158
|
});
|
|
960
1159
|
} else if (attr?.type === "number") {
|
|
1160
|
+
;
|
|
961
1161
|
[1, 2, 3, 4, 5, 6, 8, 10, 12, 16].forEach((n) => {
|
|
962
1162
|
options.push({
|
|
963
1163
|
label: String(n),
|
|
@@ -1002,6 +1202,8 @@ function createCompletionSource() {
|
|
|
1002
1202
|
apply = `${attr.name}=""`;
|
|
1003
1203
|
} else if (attr.type === "number" || attr.type === "enum") {
|
|
1004
1204
|
apply = `${attr.name}=`;
|
|
1205
|
+
} else if (attr.type === "function") {
|
|
1206
|
+
apply = `${attr.name}(`;
|
|
1005
1207
|
}
|
|
1006
1208
|
options.push({
|
|
1007
1209
|
label: attr.name,
|
|
@@ -1018,6 +1220,8 @@ function createCompletionSource() {
|
|
|
1018
1220
|
apply = `${attr.name}=""`;
|
|
1019
1221
|
} else if (attr.type === "number" || attr.type === "enum") {
|
|
1020
1222
|
apply = `${attr.name}=`;
|
|
1223
|
+
} else if (attr.type === "function") {
|
|
1224
|
+
apply = `${attr.name}(`;
|
|
1021
1225
|
}
|
|
1022
1226
|
options.push({
|
|
1023
1227
|
label: attr.name,
|
|
@@ -1107,6 +1311,8 @@ function createHoverTooltipSource() {
|
|
|
1107
1311
|
valueInfo = "Type: boolean";
|
|
1108
1312
|
} else if (attribute.type === "enum" && attribute.values) {
|
|
1109
1313
|
valueInfo = `Values: ${attribute.values.join(" | ")}`;
|
|
1314
|
+
} else if (attribute.type === "function") {
|
|
1315
|
+
valueInfo = `Functional shorthand. Example: ${attribute.example}`;
|
|
1110
1316
|
}
|
|
1111
1317
|
return {
|
|
1112
1318
|
pos: from,
|
|
@@ -1131,9 +1337,7 @@ function createHoverTooltipSource() {
|
|
|
1131
1337
|
};
|
|
1132
1338
|
}
|
|
1133
1339
|
if (VALUE_KEYWORDS.includes(word)) {
|
|
1134
|
-
const relatedAttrs = ATTRIBUTES.filter(
|
|
1135
|
-
(a) => a.type === "enum" && a.values?.includes(word)
|
|
1136
|
-
);
|
|
1340
|
+
const relatedAttrs = ATTRIBUTES.filter((a) => a.type === "enum" && a.values?.includes(word));
|
|
1137
1341
|
if (relatedAttrs.length > 0) {
|
|
1138
1342
|
return {
|
|
1139
1343
|
pos: from,
|
|
@@ -1166,7 +1370,7 @@ function createHoverTooltipSource() {
|
|
|
1166
1370
|
function validateCode(text) {
|
|
1167
1371
|
const diagnostics = [];
|
|
1168
1372
|
const lines = text.split("\n");
|
|
1169
|
-
|
|
1373
|
+
const braceStack = [];
|
|
1170
1374
|
let hasPage = false;
|
|
1171
1375
|
let currentPos = 0;
|
|
1172
1376
|
for (let lineNum = 0; lineNum < lines.length; lineNum++) {
|