@wireweave/language-data 1.0.0-beta.20260108022013
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 +106 -0
- package/dist/index.cjs +672 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +97 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +628 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# @wireweave/language-data
|
|
2
|
+
|
|
3
|
+
Shared language definitions for Wireweave DSL editors.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @wireweave/language-data
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @wireweave/language-data
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import {
|
|
17
|
+
ALL_COMPONENTS,
|
|
18
|
+
ATTRIBUTES,
|
|
19
|
+
getComponent,
|
|
20
|
+
getAttribute,
|
|
21
|
+
getValidChildren,
|
|
22
|
+
getComponentAttributes,
|
|
23
|
+
} from '@wireweave/language-data';
|
|
24
|
+
|
|
25
|
+
// Get component definition
|
|
26
|
+
const page = getComponent('page');
|
|
27
|
+
console.log(page?.description); // "Page root container..."
|
|
28
|
+
|
|
29
|
+
// Get attribute definition
|
|
30
|
+
const gap = getAttribute('gap');
|
|
31
|
+
console.log(gap?.values); // "number"
|
|
32
|
+
|
|
33
|
+
// Get valid children for a component
|
|
34
|
+
const children = getValidChildren('page');
|
|
35
|
+
console.log(children.map(c => c.name)); // ["header", "main", "footer", ...]
|
|
36
|
+
|
|
37
|
+
// Get attributes for a component
|
|
38
|
+
const attrs = getComponentAttributes('button');
|
|
39
|
+
console.log(attrs.map(a => a.name)); // ["primary", "secondary", ...]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Exports
|
|
43
|
+
|
|
44
|
+
### Data
|
|
45
|
+
|
|
46
|
+
| Export | Description |
|
|
47
|
+
|--------|-------------|
|
|
48
|
+
| `ALL_COMPONENTS` | Array of all 36 component definitions |
|
|
49
|
+
| `ATTRIBUTES` | Array of all attribute definitions |
|
|
50
|
+
| `VALUE_KEYWORDS` | Array of valid value keywords |
|
|
51
|
+
| `CATEGORY_LABELS` | Category name to label mapping |
|
|
52
|
+
| `COMMON_NUMBERS` | Common number values for suggestions |
|
|
53
|
+
| `SPACING_SCALE` | Spacing scale (4px base) |
|
|
54
|
+
|
|
55
|
+
### Types
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface ComponentDef {
|
|
59
|
+
name: string;
|
|
60
|
+
description: string;
|
|
61
|
+
category: ComponentCategory;
|
|
62
|
+
attributes: string[];
|
|
63
|
+
hasChildren: boolean;
|
|
64
|
+
validChildren?: string[];
|
|
65
|
+
validParents?: string[];
|
|
66
|
+
example?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface AttributeDef {
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
values?: string[] | 'number' | 'string' | 'boolean';
|
|
73
|
+
example?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type ComponentCategory =
|
|
77
|
+
| 'layout' | 'container' | 'grid' | 'text'
|
|
78
|
+
| 'input' | 'display' | 'data' | 'feedback'
|
|
79
|
+
| 'overlay' | 'navigation';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Utilities
|
|
83
|
+
|
|
84
|
+
| Function | Description |
|
|
85
|
+
|----------|-------------|
|
|
86
|
+
| `getComponent(name)` | Get component by name |
|
|
87
|
+
| `getAttribute(name)` | Get attribute by name |
|
|
88
|
+
| `getValidChildren(componentName)` | Get valid child components |
|
|
89
|
+
| `isValidChild(child, parent)` | Check if child is valid |
|
|
90
|
+
| `getComponentAttributes(componentName)` | Get attributes for component |
|
|
91
|
+
| `getComponentsByCategory(category)` | Get components by category |
|
|
92
|
+
| `getAttributeTypeLabel(attr)` | Get type label for display |
|
|
93
|
+
| `formatAttributeValues(attr)` | Format values for display |
|
|
94
|
+
| `isComponent(word)` | Check if word is a component |
|
|
95
|
+
| `isAttribute(word)` | Check if word is an attribute |
|
|
96
|
+
| `getComponentNames()` | Get all component names |
|
|
97
|
+
| `getAttributeNames()` | Get all attribute names |
|
|
98
|
+
|
|
99
|
+
## Used By
|
|
100
|
+
|
|
101
|
+
- [@wireweave/playground](https://www.npmjs.com/package/@wireweave/playground) - Monaco Editor integration
|
|
102
|
+
- [wireweave-vscode](https://marketplace.visualstudio.com/items?itemName=wireweave.wireweave-vscode) - VS Code Extension
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|