@wireweave/core 1.2.0-beta.0 → 1.2.0-beta.2
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 +183 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -118,6 +118,189 @@ const { svg, width, height } = renderToSvg(doc, {
|
|
|
118
118
|
|
|
119
119
|
**Returns**: `{ svg: string, width: number, height: number }`
|
|
120
120
|
|
|
121
|
+
### Analysis
|
|
122
|
+
|
|
123
|
+
#### `analyze(doc: WireframeDocument, options?: AnalysisOptions): AnalysisResult`
|
|
124
|
+
|
|
125
|
+
Analyzes a wireframe document and returns comprehensive statistics.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { parse, analyze } from '@wireweave/core';
|
|
129
|
+
|
|
130
|
+
const doc = parse('page { card { text "Hello" button "Click" } }');
|
|
131
|
+
const result = analyze(doc);
|
|
132
|
+
|
|
133
|
+
console.log(result.summary);
|
|
134
|
+
// { totalComponents: 4, uniqueTypes: 4, mostUsedType: 'Page', ... }
|
|
135
|
+
|
|
136
|
+
console.log(result.tree);
|
|
137
|
+
// { totalNodes: 4, maxDepth: 3, avgDepth: 2, ... }
|
|
138
|
+
|
|
139
|
+
console.log(result.accessibility);
|
|
140
|
+
// { score: 100, imagesWithAlt: 0, inputsWithLabels: 0, ... }
|
|
141
|
+
|
|
142
|
+
console.log(result.complexity);
|
|
143
|
+
// { score: 2, level: 'simple', interactiveElements: 1, ... }
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Options**:
|
|
147
|
+
| Option | Type | Default | Description |
|
|
148
|
+
|--------|------|---------|-------------|
|
|
149
|
+
| `includeComponentBreakdown` | `boolean` | `true` | Include component statistics |
|
|
150
|
+
| `includeAccessibility` | `boolean` | `true` | Include accessibility metrics |
|
|
151
|
+
| `includeComplexity` | `boolean` | `true` | Include complexity analysis |
|
|
152
|
+
| `includeLayout` | `boolean` | `true` | Include layout analysis |
|
|
153
|
+
| `includeContent` | `boolean` | `true` | Include content analysis |
|
|
154
|
+
|
|
155
|
+
### Diff (Document Comparison)
|
|
156
|
+
|
|
157
|
+
#### `diff(oldDoc: WireframeDocument, newDoc: WireframeDocument, options?: DiffOptions): DiffResult`
|
|
158
|
+
|
|
159
|
+
Compares two wireframe documents and returns detailed differences.
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { parse, diff } from '@wireweave/core';
|
|
163
|
+
|
|
164
|
+
const oldDoc = parse('page { text "Hello" }');
|
|
165
|
+
const newDoc = parse('page { text "Hello" button "Click" }');
|
|
166
|
+
|
|
167
|
+
const result = diff(oldDoc, newDoc);
|
|
168
|
+
|
|
169
|
+
console.log(result.identical); // false
|
|
170
|
+
console.log(result.description); // "Added 1 component(s): Button."
|
|
171
|
+
console.log(result.summary);
|
|
172
|
+
// { addedCount: 1, removedCount: 0, changedCount: 0, ... }
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### `areIdentical(oldDoc: WireframeDocument, newDoc: WireframeDocument): boolean`
|
|
176
|
+
|
|
177
|
+
Quick check if two documents are identical.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import { parse, areIdentical } from '@wireweave/core';
|
|
181
|
+
|
|
182
|
+
const doc1 = parse('page { text "Hello" }');
|
|
183
|
+
const doc2 = parse('page { text "Hello" }');
|
|
184
|
+
|
|
185
|
+
console.log(areIdentical(doc1, doc2)); // true
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### `getChangeSummary(oldDoc: WireframeDocument, newDoc: WireframeDocument): string`
|
|
189
|
+
|
|
190
|
+
Returns a human-readable summary of changes.
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { parse, getChangeSummary } from '@wireweave/core';
|
|
194
|
+
|
|
195
|
+
const oldDoc = parse('page { text "A" }');
|
|
196
|
+
const newDoc = parse('page { text "B" }');
|
|
197
|
+
|
|
198
|
+
console.log(getChangeSummary(oldDoc, newDoc));
|
|
199
|
+
// "Modified 1 component(s)."
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Export
|
|
203
|
+
|
|
204
|
+
#### `exportToJson(doc: WireframeDocument, options?: ExportOptions): JsonExportResult`
|
|
205
|
+
|
|
206
|
+
Exports wireframe to JSON format.
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
import { parse, exportToJson } from '@wireweave/core';
|
|
210
|
+
|
|
211
|
+
const doc = parse('page { card { text "Hello" } }');
|
|
212
|
+
const result = exportToJson(doc);
|
|
213
|
+
|
|
214
|
+
console.log(result.version); // "1.0.0"
|
|
215
|
+
console.log(result.pages); // [{ type: 'page', children: [...] }]
|
|
216
|
+
console.log(result.metadata);
|
|
217
|
+
// { exportedAt: '...', nodeCount: 3, componentTypes: ['card', 'page', 'text'] }
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### `exportToJsonString(doc: WireframeDocument, options?: ExportOptions): string`
|
|
221
|
+
|
|
222
|
+
Exports wireframe to JSON string.
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import { parse, exportToJsonString } from '@wireweave/core';
|
|
226
|
+
|
|
227
|
+
const doc = parse('page { text "Hello" }');
|
|
228
|
+
const json = exportToJsonString(doc, { prettyPrint: true });
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### `exportToFigma(doc: WireframeDocument): FigmaExportResult`
|
|
232
|
+
|
|
233
|
+
Exports wireframe to Figma-compatible format.
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { parse, exportToFigma } from '@wireweave/core';
|
|
237
|
+
|
|
238
|
+
const doc = parse('page { card { text "Hello" } }');
|
|
239
|
+
const result = exportToFigma(doc);
|
|
240
|
+
|
|
241
|
+
console.log(result.document); // Figma-compatible node tree
|
|
242
|
+
console.log(result.componentMappings);
|
|
243
|
+
// { page: 'CANVAS', card: 'FRAME', text: 'TEXT' }
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### UX Validation
|
|
247
|
+
|
|
248
|
+
#### `validateUX(doc: WireframeDocument, options?: UXValidationOptions): UXValidationResult`
|
|
249
|
+
|
|
250
|
+
Validates wireframe against UX best practices.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
import { parse, validateUX } from '@wireweave/core';
|
|
254
|
+
|
|
255
|
+
const doc = parse(`
|
|
256
|
+
page {
|
|
257
|
+
button "Click" // No primary action indicator
|
|
258
|
+
button "Cancel"
|
|
259
|
+
}
|
|
260
|
+
`);
|
|
261
|
+
|
|
262
|
+
const result = validateUX(doc);
|
|
263
|
+
|
|
264
|
+
console.log(result.valid); // true/false
|
|
265
|
+
console.log(result.score); // 0-100
|
|
266
|
+
console.log(result.issues);
|
|
267
|
+
// [{ ruleId: 'button-needs-primary', severity: 'warning', message: '...' }]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
#### `isUXValid(doc: WireframeDocument): boolean`
|
|
271
|
+
|
|
272
|
+
Quick check if wireframe passes all UX rules.
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
import { parse, isUXValid } from '@wireweave/core';
|
|
276
|
+
|
|
277
|
+
const doc = parse('page { button "Submit" primary }');
|
|
278
|
+
console.log(isUXValid(doc)); // true
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### `getUXScore(doc: WireframeDocument): number`
|
|
282
|
+
|
|
283
|
+
Returns UX score from 0-100.
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
import { parse, getUXScore } from '@wireweave/core';
|
|
287
|
+
|
|
288
|
+
const doc = parse('page { form { input label="Name" button "Submit" primary } }');
|
|
289
|
+
console.log(getUXScore(doc)); // 95
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### `getUXIssues(doc: WireframeDocument): UXIssue[]`
|
|
293
|
+
|
|
294
|
+
Returns list of UX issues found.
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
import { parse, getUXIssues } from '@wireweave/core';
|
|
298
|
+
|
|
299
|
+
const doc = parse('page { image src="photo.jpg" }'); // Missing alt
|
|
300
|
+
const issues = getUXIssues(doc);
|
|
301
|
+
// [{ ruleId: 'image-needs-alt', severity: 'error', message: '...' }]
|
|
302
|
+
```
|
|
303
|
+
|
|
121
304
|
### AST Utilities
|
|
122
305
|
|
|
123
306
|
#### `walk(node: ASTNode, callback: WalkCallback): void`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wireweave/core",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.2",
|
|
4
4
|
"description": "Core parser and renderer for wireweave",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@release-it/conventional-changelog": "^10.0.4",
|
|
40
|
+
"@types/node": "^25.0.8",
|
|
40
41
|
"@vitest/coverage-v8": "^3.2.4",
|
|
41
42
|
"lucide": "^0.562.0",
|
|
42
43
|
"peggy": "^5.0.0",
|