@wireweave/language-data 1.0.2 → 1.1.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.
- package/README.md +107 -34
- package/dist/codemirror/index.cjs +1223 -0
- package/dist/codemirror/index.cjs.map +1 -0
- package/dist/codemirror/index.d.cts +130 -0
- package/dist/codemirror/index.d.ts +130 -0
- package/dist/codemirror/index.js +1191 -0
- package/dist/codemirror/index.js.map +1 -0
- package/dist/index.cjs +390 -217
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -7
- package/dist/index.d.ts +82 -7
- package/dist/index.js +382 -217
- package/dist/index.js.map +1 -1
- package/dist/monaco/index.cjs +1270 -0
- package/dist/monaco/index.cjs.map +1 -0
- package/dist/monaco/index.d.cts +143 -0
- package/dist/monaco/index.d.ts +143 -0
- package/dist/monaco/index.js +1233 -0
- package/dist/monaco/index.js.map +1 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">@wireweave/language-data</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center">Shared language definitions for Wireweave DSL
|
|
7
|
+
<p align="center">Shared language definitions and editor integrations for Wireweave DSL</p>
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -14,8 +14,17 @@ npm install @wireweave/language-data
|
|
|
14
14
|
pnpm add @wireweave/language-data
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Language Data** - Component and attribute definitions
|
|
20
|
+
- **Monaco Integration** - Full IntelliSense for Monaco Editor
|
|
21
|
+
- **CodeMirror Integration** - Full IntelliSense for CodeMirror 6
|
|
22
|
+
- **Zero Dependencies** - Standalone package
|
|
23
|
+
|
|
17
24
|
## Usage
|
|
18
25
|
|
|
26
|
+
### Basic Data
|
|
27
|
+
|
|
19
28
|
```typescript
|
|
20
29
|
import {
|
|
21
30
|
ALL_COMPONENTS,
|
|
@@ -28,53 +37,133 @@ import {
|
|
|
28
37
|
|
|
29
38
|
// Get component definition
|
|
30
39
|
const page = getComponent('page');
|
|
31
|
-
console.log(page?.description);
|
|
40
|
+
console.log(page?.description);
|
|
32
41
|
|
|
33
42
|
// Get attribute definition
|
|
34
43
|
const gap = getAttribute('gap');
|
|
35
|
-
console.log(gap?.
|
|
44
|
+
console.log(gap?.type); // "number"
|
|
36
45
|
|
|
37
46
|
// Get valid children for a component
|
|
38
47
|
const children = getValidChildren('page');
|
|
39
|
-
console.log(children.map(c => c.name));
|
|
48
|
+
console.log(children.map(c => c.name));
|
|
40
49
|
|
|
41
50
|
// Get attributes for a component
|
|
42
51
|
const attrs = getComponentAttributes('button');
|
|
43
|
-
console.log(attrs.map(a => a.name));
|
|
52
|
+
console.log(attrs.map(a => a.name));
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Monaco Editor Integration
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import * as monaco from 'monaco-editor';
|
|
59
|
+
import {
|
|
60
|
+
LANGUAGE_ID,
|
|
61
|
+
getMonarchTokensProvider,
|
|
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);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### CodeMirror Integration
|
|
84
|
+
|
|
85
|
+
```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
|
+
import {
|
|
91
|
+
createTokenizer,
|
|
92
|
+
createCompletionSource,
|
|
93
|
+
createHoverTooltipSource,
|
|
94
|
+
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
|
+
];
|
|
44
107
|
```
|
|
45
108
|
|
|
46
109
|
## Exports
|
|
47
110
|
|
|
48
|
-
###
|
|
111
|
+
### Main (`@wireweave/language-data`)
|
|
49
112
|
|
|
50
113
|
| Export | Description |
|
|
51
114
|
|--------|-------------|
|
|
52
|
-
| `ALL_COMPONENTS` | Array of
|
|
53
|
-
| `ATTRIBUTES` | Array of
|
|
115
|
+
| `ALL_COMPONENTS` | Array of ~40 component definitions |
|
|
116
|
+
| `ATTRIBUTES` | Array of ~60 attribute definitions |
|
|
54
117
|
| `VALUE_KEYWORDS` | Array of valid value keywords |
|
|
55
118
|
| `CATEGORY_LABELS` | Category name to label mapping |
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
119
|
+
| `getComponent(name)` | Get component by name |
|
|
120
|
+
| `getAttribute(name)` | Get attribute by name |
|
|
121
|
+
| `getValidChildren(name)` | Get valid child components |
|
|
122
|
+
| `getComponentAttributes(name)` | Get attributes for component |
|
|
123
|
+
| `isComponent(word)` | Check if word is a component |
|
|
124
|
+
| `isAttribute(word)` | Check if word is an attribute |
|
|
58
125
|
|
|
59
|
-
###
|
|
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
|
|
60
147
|
|
|
61
148
|
```typescript
|
|
62
149
|
interface ComponentDef {
|
|
63
150
|
name: string;
|
|
64
|
-
|
|
151
|
+
nodeType: string;
|
|
65
152
|
category: ComponentCategory;
|
|
66
153
|
attributes: string[];
|
|
67
154
|
hasChildren: boolean;
|
|
155
|
+
description: string;
|
|
156
|
+
example: string;
|
|
68
157
|
validChildren?: string[];
|
|
69
158
|
validParents?: string[];
|
|
70
|
-
example?: string;
|
|
71
159
|
}
|
|
72
160
|
|
|
73
161
|
interface AttributeDef {
|
|
74
162
|
name: string;
|
|
163
|
+
type: 'string' | 'number' | 'boolean' | 'enum';
|
|
164
|
+
values?: string[];
|
|
75
165
|
description: string;
|
|
76
|
-
|
|
77
|
-
example?: string;
|
|
166
|
+
example: string;
|
|
78
167
|
}
|
|
79
168
|
|
|
80
169
|
type ComponentCategory =
|
|
@@ -83,27 +172,11 @@ type ComponentCategory =
|
|
|
83
172
|
| 'overlay' | 'navigation';
|
|
84
173
|
```
|
|
85
174
|
|
|
86
|
-
### Utilities
|
|
87
|
-
|
|
88
|
-
| Function | Description |
|
|
89
|
-
|----------|-------------|
|
|
90
|
-
| `getComponent(name)` | Get component by name |
|
|
91
|
-
| `getAttribute(name)` | Get attribute by name |
|
|
92
|
-
| `getValidChildren(componentName)` | Get valid child components |
|
|
93
|
-
| `isValidChild(child, parent)` | Check if child is valid |
|
|
94
|
-
| `getComponentAttributes(componentName)` | Get attributes for component |
|
|
95
|
-
| `getComponentsByCategory(category)` | Get components by category |
|
|
96
|
-
| `getAttributeTypeLabel(attr)` | Get type label for display |
|
|
97
|
-
| `formatAttributeValues(attr)` | Format values for display |
|
|
98
|
-
| `isComponent(word)` | Check if word is a component |
|
|
99
|
-
| `isAttribute(word)` | Check if word is an attribute |
|
|
100
|
-
| `getComponentNames()` | Get all component names |
|
|
101
|
-
| `getAttributeNames()` | Get all attribute names |
|
|
102
|
-
|
|
103
175
|
## Used By
|
|
104
176
|
|
|
105
|
-
- [@wireweave/playground](https://
|
|
106
|
-
- [wireweave-vscode](https://
|
|
177
|
+
- **[@wireweave/playground](https://github.com/wireweave/playground)** - Monaco Editor integration
|
|
178
|
+
- **[wireweave-vscode](https://github.com/wireweave/vscode-extension)** - VS Code extension
|
|
179
|
+
- **[mcp-dashboard](https://dashboard.wireweave.org)** - CodeMirror integration
|
|
107
180
|
|
|
108
181
|
## License
|
|
109
182
|
|