@wireweave/core 1.2.0-beta.1 → 1.2.0-beta.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 +125 -0
- package/dist/index.cjs +1 -1210
- package/dist/index.d.cts +1 -185
- package/dist/index.d.ts +1 -185
- package/dist/index.js +1 -1202
- package/dist/renderer.cjs +1 -1
- package/dist/renderer.d.cts +2 -0
- package/dist/renderer.d.ts +2 -0
- package/dist/renderer.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,6 +118,131 @@ 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
|
+
|
|
121
246
|
### AST Utilities
|
|
122
247
|
|
|
123
248
|
#### `walk(node: ASTNode, callback: WalkCallback): void`
|