planscript 1.4.0 → 2.0.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.
Files changed (42) hide show
  1. package/LANGUAGE_REFERENCE.md +472 -4
  2. package/dist/ast/types.d.ts +84 -4
  3. package/dist/ast/types.d.ts.map +1 -1
  4. package/dist/cli.js +28 -6
  5. package/dist/cli.js.map +1 -1
  6. package/dist/exporters/svg.d.ts +3 -0
  7. package/dist/exporters/svg.d.ts.map +1 -1
  8. package/dist/exporters/svg.js +48 -2
  9. package/dist/exporters/svg.js.map +1 -1
  10. package/dist/geometry/index.d.ts.map +1 -1
  11. package/dist/geometry/index.js +7 -0
  12. package/dist/geometry/index.js.map +1 -1
  13. package/dist/geometry/types.d.ts +7 -0
  14. package/dist/geometry/types.d.ts.map +1 -1
  15. package/dist/lowering/index.d.ts +23 -1
  16. package/dist/lowering/index.d.ts.map +1 -1
  17. package/dist/lowering/index.js +374 -28
  18. package/dist/lowering/index.js.map +1 -1
  19. package/dist/parser/grammar.d.ts +52 -5
  20. package/dist/parser/grammar.d.ts.map +1 -1
  21. package/dist/parser/grammar.js +4927 -2026
  22. package/dist/parser/grammar.js.map +1 -1
  23. package/dist/validation/index.d.ts +5 -0
  24. package/dist/validation/index.d.ts.map +1 -1
  25. package/dist/validation/index.js +215 -0
  26. package/dist/validation/index.js.map +1 -1
  27. package/examples/advanced_positioning.psc +225 -0
  28. package/examples/advanced_positioning.svg +76 -0
  29. package/examples/courtyard_house.psc +141 -0
  30. package/examples/courtyard_house.svg +93 -0
  31. package/examples/orientation.psc +141 -0
  32. package/examples/orientation.svg +88 -0
  33. package/examples/zones.psc +275 -0
  34. package/examples/zones.svg +89 -0
  35. package/package.json +1 -1
  36. package/examples/casa_moderna.psc +0 -375
  37. package/examples/casa_moderna_v2.psc +0 -406
  38. package/examples/casa_moderna_v3.psc +0 -375
  39. package/examples/casa_moderna_v5.psc +0 -397
  40. package/examples/house2.psc +0 -156
  41. package/examples/house2.svg +0 -103
  42. package/examples/house3.svg +0 -139
@@ -0,0 +1,275 @@
1
+ # Zones Example
2
+ #
3
+ # This example demonstrates the zone feature in PlanScript.
4
+ # Zones allow you to group rooms logically and position them as a unit.
5
+ #
6
+ # This is a typical house layout with three zones:
7
+ # - Access zone: entry, garage
8
+ # - Social zone: living, dining, kitchen
9
+ # - Private zone: master suite, secondary bedrooms
10
+ #
11
+ # Layout (conceptual):
12
+ #
13
+ # +------------------+------------------+
14
+ # | PRIVATE ZONE |
15
+ # | +-------+-------+-------+-------+ |
16
+ # | |Master | Bath | Bed 2 | Bed 3 | |
17
+ # | +-------+-------+-------+-------+ |
18
+ # +------------------+------------------+
19
+ # | SOCIAL ZONE |
20
+ # | +--------+--------+--------+ |
21
+ # | | Living | Dining | Kitchen| |
22
+ # | +--------+--------+--------+ |
23
+ # +------------------+------------------+
24
+ # | ACCESS ZONE |
25
+ # | +--------+----------+ |
26
+ # | | Entry | Garage | |
27
+ # | +--------+----------+ |
28
+ # +-------------------------------------+
29
+ #
30
+
31
+ units m
32
+
33
+ defaults {
34
+ door_width 0.9
35
+ window_width 1.5
36
+ }
37
+
38
+ plan "House with Zones" {
39
+ footprint rect (0, 0) (20, 22)
40
+
41
+ # ============================================
42
+ # ACCESS ZONE - Entry and garage at ground level
43
+ # ============================================
44
+
45
+ zone access {
46
+ label "Access Zone"
47
+
48
+ room entry {
49
+ rect (0, 0) (5, 4)
50
+ label "Entry"
51
+ }
52
+
53
+ room garage {
54
+ rect size (7, 4)
55
+ attach east_of entry
56
+ align bottom
57
+ gap 0
58
+ label "Garage"
59
+ }
60
+ }
61
+
62
+ # ============================================
63
+ # SOCIAL ZONE - Living spaces
64
+ # ============================================
65
+
66
+ zone social {
67
+ label "Social Zone"
68
+ attach north_of access
69
+ align left
70
+ gap 0
71
+
72
+ room living {
73
+ rect (0, 0) (7, 6)
74
+ label "Living Room"
75
+ }
76
+
77
+ room dining {
78
+ rect size (5, 6)
79
+ attach east_of living
80
+ align top
81
+ gap 0
82
+ label "Dining Room"
83
+ }
84
+
85
+ room kitchen {
86
+ rect size (5, 6)
87
+ attach east_of dining
88
+ align top
89
+ gap 0
90
+ label "Kitchen"
91
+ }
92
+ }
93
+
94
+ # ============================================
95
+ # PRIVATE ZONE - Bedrooms
96
+ # ============================================
97
+
98
+ zone private {
99
+ label "Private Zone"
100
+ attach north_of social
101
+ align left
102
+ gap 0
103
+
104
+ room master {
105
+ rect (0, 0) (6, 5)
106
+ label "Master Bedroom"
107
+ }
108
+
109
+ room master_bath {
110
+ rect size (3, 5)
111
+ attach east_of master
112
+ align top
113
+ gap 0
114
+ label "Master Bath"
115
+ }
116
+
117
+ room bedroom2 {
118
+ rect size (4, 5)
119
+ attach east_of master_bath
120
+ align top
121
+ gap 0
122
+ label "Bedroom 2"
123
+ }
124
+
125
+ room bedroom3 {
126
+ rect size (4, 5)
127
+ attach east_of bedroom2
128
+ align top
129
+ gap 0
130
+ label "Bedroom 3"
131
+ }
132
+ }
133
+
134
+ # ============================================
135
+ # DOORS
136
+ # ============================================
137
+
138
+ # Access zone doors
139
+ opening door d_front {
140
+ on entry.edge south
141
+ at 50%
142
+ width 1.0
143
+ }
144
+
145
+ opening door d_garage {
146
+ on garage.edge south
147
+ at 50%
148
+ width 5.0
149
+ }
150
+
151
+ opening door d_entry_garage {
152
+ between entry and garage
153
+ on shared_edge
154
+ at 50%
155
+ }
156
+
157
+ # Access to social
158
+ opening door d_entry_living {
159
+ between entry and living
160
+ on shared_edge
161
+ at 50%
162
+ width 1.2
163
+ }
164
+
165
+ # Social zone doors
166
+ opening door d_living_dining {
167
+ between living and dining
168
+ on shared_edge
169
+ at 50%
170
+ width 2.0
171
+ }
172
+
173
+ opening door d_dining_kitchen {
174
+ between dining and kitchen
175
+ on shared_edge
176
+ at 50%
177
+ width 1.5
178
+ }
179
+
180
+ # Social to private
181
+ opening door d_living_master {
182
+ between living and master
183
+ on shared_edge
184
+ at 50%
185
+ }
186
+
187
+ # Private zone doors
188
+ opening door d_master_bath {
189
+ between master and master_bath
190
+ on shared_edge
191
+ at 50%
192
+ width 0.8
193
+ }
194
+
195
+ opening door d_bath_bed2 {
196
+ between master_bath and bedroom2
197
+ on shared_edge
198
+ at 50%
199
+ }
200
+
201
+ opening door d_bed2_bed3 {
202
+ between bedroom2 and bedroom3
203
+ on shared_edge
204
+ at 50%
205
+ }
206
+
207
+ # ============================================
208
+ # WINDOWS
209
+ # ============================================
210
+
211
+ # Living room
212
+ opening window w_living_w {
213
+ on living.edge west
214
+ at 3.0
215
+ width 2.5
216
+ }
217
+
218
+ # Dining room
219
+ opening window w_dining_n {
220
+ on dining.edge north
221
+ at 2.5
222
+ width 2.0
223
+ }
224
+
225
+ # Kitchen
226
+ opening window w_kitchen_e {
227
+ on kitchen.edge east
228
+ at 3.0
229
+ width 2.0
230
+ }
231
+
232
+ # Master bedroom
233
+ opening window w_master_n {
234
+ on master.edge north
235
+ at 3.0
236
+ width 2.5
237
+ }
238
+
239
+ opening window w_master_w {
240
+ on master.edge west
241
+ at 2.5
242
+ width 2.0
243
+ }
244
+
245
+ # Bedroom 2
246
+ opening window w_bed2_n {
247
+ on bedroom2.edge north
248
+ at 2.0
249
+ width 1.5
250
+ }
251
+
252
+ # Bedroom 3
253
+ opening window w_bed3_n {
254
+ on bedroom3.edge north
255
+ at 2.0
256
+ width 1.5
257
+ }
258
+
259
+ opening window w_bed3_e {
260
+ on bedroom3.edge east
261
+ at 2.5
262
+ width 1.5
263
+ }
264
+
265
+ # ============================================
266
+ # VALIDATION
267
+ # ============================================
268
+
269
+ assert no_overlap rooms
270
+ assert inside footprint all_rooms
271
+ assert min_room_area living >= 35
272
+ assert min_room_area master >= 25
273
+ assert min_room_area bedroom2 >= 15
274
+ assert min_room_area bedroom3 >= 15
275
+ }
@@ -0,0 +1,89 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="1000" height="800" viewBox="0 0 1000 800">
3
+ <defs>
4
+ <style>
5
+ .room-label { font-family: Arial, sans-serif; font-weight: 500; }
6
+ </style>
7
+ </defs>
8
+
9
+ <!-- Background -->
10
+ <rect width="1000" height="800" fill="#ffffff" />
11
+
12
+ <!-- Footprint (boundary) -->
13
+ <path d="M 190.91 740.00 L 809.09 740.00 L 809.09 60.00 L 190.91 60.00 Z" fill="none" stroke="#7f8c8d" stroke-width="2" stroke-dasharray="8,4" />
14
+
15
+ <!-- Rooms -->
16
+ <path d="M 190.91 740.00 L 345.45 740.00 L 345.45 616.36 L 190.91 616.36 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
17
+ <path d="M 345.45 740.00 L 561.82 740.00 L 561.82 616.36 L 345.45 616.36 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
18
+ <path d="M 190.91 616.36 L 407.27 616.36 L 407.27 430.91 L 190.91 430.91 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
19
+ <path d="M 407.27 616.36 L 561.82 616.36 L 561.82 430.91 L 407.27 430.91 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
20
+ <path d="M 561.82 616.36 L 716.36 616.36 L 716.36 430.91 L 561.82 430.91 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
21
+ <path d="M 190.91 430.91 L 376.36 430.91 L 376.36 276.36 L 190.91 276.36 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
22
+ <path d="M 376.36 430.91 L 469.09 430.91 L 469.09 276.36 L 376.36 276.36 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
23
+ <path d="M 469.09 430.91 L 592.73 430.91 L 592.73 276.36 L 469.09 276.36 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
24
+ <path d="M 592.73 430.91 L 716.36 430.91 L 716.36 276.36 L 592.73 276.36 Z" fill="#ecf0f1" stroke="#bdc3c7" stroke-width="1" />
25
+
26
+ <!-- Walls -->
27
+ <line x1="345.45" y1="740.00" x2="345.45" y2="616.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
28
+ <line x1="190.91" y1="616.36" x2="345.45" y2="616.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
29
+ <line x1="345.45" y1="616.36" x2="407.27" y2="616.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
30
+ <line x1="407.27" y1="616.36" x2="561.82" y2="616.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
31
+ <line x1="407.27" y1="616.36" x2="407.27" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
32
+ <line x1="190.91" y1="430.91" x2="376.36" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
33
+ <line x1="376.36" y1="430.91" x2="407.27" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
34
+ <line x1="561.82" y1="616.36" x2="561.82" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
35
+ <line x1="407.27" y1="430.91" x2="469.09" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
36
+ <line x1="469.09" y1="430.91" x2="561.82" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
37
+ <line x1="561.82" y1="430.91" x2="592.73" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
38
+ <line x1="592.73" y1="430.91" x2="716.36" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
39
+ <line x1="376.36" y1="430.91" x2="376.36" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
40
+ <line x1="469.09" y1="430.91" x2="469.09" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
41
+ <line x1="592.73" y1="430.91" x2="592.73" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
42
+ <line x1="190.91" y1="740.00" x2="345.45" y2="740.00" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
43
+ <line x1="190.91" y1="740.00" x2="190.91" y2="616.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
44
+ <line x1="345.45" y1="740.00" x2="561.82" y2="740.00" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
45
+ <line x1="561.82" y1="740.00" x2="561.82" y2="616.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
46
+ <line x1="190.91" y1="616.36" x2="190.91" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
47
+ <line x1="561.82" y1="616.36" x2="716.36" y2="616.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
48
+ <line x1="716.36" y1="616.36" x2="716.36" y2="430.91" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
49
+ <line x1="190.91" y1="276.36" x2="376.36" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
50
+ <line x1="190.91" y1="430.91" x2="190.91" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
51
+ <line x1="376.36" y1="276.36" x2="469.09" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
52
+ <line x1="469.09" y1="276.36" x2="592.73" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
53
+ <line x1="716.36" y1="430.91" x2="716.36" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
54
+ <line x1="592.73" y1="276.36" x2="716.36" y2="276.36" stroke="#2c3e50" stroke-width="3" stroke-linecap="round" />
55
+
56
+ <!-- Openings (doors/windows) -->
57
+ <line x1="252.73" y1="740.00" x2="283.64" y2="740.00" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
58
+ <line x1="376.36" y1="740.00" x2="530.91" y2="740.00" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
59
+ <line x1="345.45" y1="692.09" x2="345.45" y2="664.27" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
60
+ <line x1="249.64" y1="616.36" x2="286.73" y2="616.36" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
61
+ <line x1="407.27" y1="554.55" x2="407.27" y2="492.73" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
62
+ <line x1="561.82" y1="546.82" x2="561.82" y2="500.45" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
63
+ <line x1="269.73" y1="430.91" x2="297.55" y2="430.91" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
64
+ <line x1="376.36" y1="366.00" x2="376.36" y2="341.27" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
65
+ <line x1="469.09" y1="367.55" x2="469.09" y2="339.73" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
66
+ <line x1="592.73" y1="367.55" x2="592.73" y2="339.73" stroke="#e74c3c" stroke-width="4" stroke-linecap="round" />
67
+ <line x1="190.91" y1="562.27" x2="190.91" y2="485.00" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
68
+ <line x1="453.64" y1="430.91" x2="515.45" y2="430.91" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
69
+ <line x1="716.36" y1="554.55" x2="716.36" y2="492.73" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
70
+ <line x1="245.00" y1="276.36" x2="322.27" y2="276.36" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
71
+ <line x1="190.91" y1="384.55" x2="190.91" y2="322.73" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
72
+ <line x1="507.73" y1="276.36" x2="554.09" y2="276.36" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
73
+ <line x1="631.36" y1="276.36" x2="677.73" y2="276.36" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
74
+ <line x1="716.36" y1="376.82" x2="716.36" y2="330.45" stroke="#3498db" stroke-width="3" stroke-linecap="round" />
75
+
76
+ <!-- Labels -->
77
+ <text x="268.18" y="678.18" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Entry</text>
78
+ <text x="453.64" y="678.18" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Garage</text>
79
+ <text x="299.09" y="523.64" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Living Room</text>
80
+ <text x="484.55" y="523.64" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Dining Room</text>
81
+ <text x="639.09" y="523.64" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Kitchen</text>
82
+ <text x="283.64" y="353.64" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Master Bedroom</text>
83
+ <text x="422.73" y="353.64" font-size="11" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Master Bath</text>
84
+ <text x="530.91" y="353.64" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Bedroom 2</text>
85
+ <text x="654.55" y="353.64" font-size="14" fill="#2c3e50" text-anchor="middle" dominant-baseline="middle" font-family="Arial, sans-serif">Bedroom 3</text>
86
+
87
+ <!-- Dimensions -->
88
+
89
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "planscript",
3
- "version": "1.4.0",
3
+ "version": "2.0.0",
4
4
  "description": "PlanScript - A DSL for defining floor plans",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",