@wire-dsl/engine 0.0.0-canary-20260221183600

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WireDSL Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # @wire-dsl/engine
2
+
3
+ Pure JavaScript/TypeScript engine for Wire-DSL. Provides the parser, IR generator, layout engine, and SVG renderer for transforming `.wire` files into interactive wireframes. **Browser-safe - no Node.js dependencies.**
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @wire-dsl/engine
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { parseWire, generateIR, computeLayout } from '@wire-dsl/engine';
15
+
16
+ // Parse .wire DSL file
17
+ const ast = parseWire(`
18
+ project "MyWireframe" {
19
+ style {
20
+ density: "normal"
21
+ spacing: "md"
22
+ radius: "md"
23
+ stroke: "normal"
24
+ font: "base"
25
+ }
26
+ screen Home {
27
+ layout stack(direction: vertical, gap: md, padding: lg) {
28
+ component Heading text: "Welcome"
29
+ component Button text: "Click me" variant: primary
30
+ }
31
+ }
32
+ }
33
+ `);
34
+
35
+ // Generate Intermediate Representation
36
+ const ir = generateIR(ast);
37
+
38
+ // Compute layout
39
+ const layout = computeLayout(ir);
40
+
41
+ console.log(layout);
42
+ ```
43
+
44
+ ## Core Modules
45
+
46
+ ### Parser
47
+ Transforms `.wire` DSL syntax into an Abstract Syntax Tree (AST) using Chevrotain.
48
+
49
+ ```typescript
50
+ import { parseWire } from '@wire-dsl/engine';
51
+ const ast = parseWire(wireCode);
52
+ ```
53
+
54
+ ### IR (Intermediate Representation)
55
+ Converts AST into a structured IR contract that describes components, properties, and relationships.
56
+
57
+ ```typescript
58
+ import { generateIR } from '@wire-dsl/engine';
59
+ const ir = generateIR(ast);
60
+ ```
61
+
62
+ ### Layout Engine
63
+ Computes positions and dimensions for all components based on container types and constraints.
64
+
65
+ ```typescript
66
+ import { computeLayout } from '@wire-dsl/engine';
67
+ const layout = computeLayout(ir);
68
+ ```
69
+
70
+ ### Validators
71
+ Schema-based validation using Zod to ensure IR correctness.
72
+
73
+ ```typescript
74
+ import { validateIR } from '@wire-dsl/engine';
75
+ validateIR(ir); // Throws if invalid
76
+ ```
77
+
78
+ ### Components
79
+ 30+ built-in UI components:
80
+
81
+ **Text**: Heading, Text, Label
82
+
83
+ **Input**: Input, Textarea, Select, Checkbox, Radio, Toggle
84
+
85
+ **Buttons**: Button, IconButton
86
+
87
+ **Navigation**: Topbar, SidebarMenu, Breadcrumbs, Tabs
88
+
89
+ **Data**: Table, List
90
+
91
+ **Media**: Image, Icon
92
+
93
+ **Display**: Divider, Badge, Link, Alert
94
+
95
+ **Info**: StatCard, Code, ChartPlaceholder
96
+
97
+ **Feedback**: Modal, Spinner
98
+
99
+ ## Features
100
+
101
+ - 🎯 **Type-safe** - Full TypeScript support
102
+ - ✅ **Validated** - Zod-based schema validation
103
+ - 📐 **Layout Engine** - Automatic responsive positioning
104
+ - 🔧 **Extensible** - Add custom components
105
+ - ⚡ **Performance** - Optimized parsing and computation
106
+ - 📦 **ESM + CJS** - Works in Node.js and browsers
107
+
108
+ ## Documentation
109
+
110
+ - [IR Contract Specification](https://github.com/Wire-DSL/wire-dsl/blob/main/specs/IR-CONTRACT.md)
111
+ - [Layout Engine Algorithm](https://github.com/Wire-DSL/wire-dsl/blob/main/specs/LAYOUT-ENGINE.md)
112
+ - [Validation Rules](https://github.com/Wire-DSL/wire-dsl/blob/main/specs/VALIDATION-RULES.md)
113
+
114
+ ## License
115
+
116
+ MIT