desen-core 1.0.0-draft.29 → 1.0.0-draft.30

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > desen-core@1.0.0-draft.29 build /Users/selmanay/Desktop/desen/packages/core
3
+ > desen-core@1.0.0-draft.30 build /Users/selmanay/Desktop/desen/packages/core
4
4
  > tsc
5
5
 
package/LICENSE.md ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Selman Ay
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -4,6 +4,7 @@ exports.repeaterSpec = exports.compositionSpec = exports.nodeSpec = exports.layo
4
4
  const zod_1 = require("zod");
5
5
  const binding_1 = require("./binding");
6
6
  const telemetry_1 = require("./telemetry");
7
+ const style_1 = require("./style");
7
8
  // ─── Positioning ─────────────────────────────────────────────────
8
9
  // SPEC.md §3.5: relative, sticky, absolute
9
10
  exports.positioningSpec = zod_1.z.object({
@@ -109,13 +110,18 @@ const elementSpecInternal = zod_1.z.object({
109
110
  type: zod_1.z.string().min(1),
110
111
  id: zod_1.z.string().min(1),
111
112
  name: zod_1.z.string().optional(),
112
- props: zod_1.z.record(zod_1.z.any()),
113
+ props: zod_1.z.object({
114
+ style: style_1.styleSpec.optional(),
115
+ layout: exports.layoutSpec.optional(),
116
+ action: zod_1.z.any().optional(),
117
+ text: zod_1.z.string().optional(),
118
+ src: zod_1.z.string().optional(),
119
+ }).passthrough().optional(),
113
120
  constraints: constraintsSpec,
114
121
  modifiers: binding_1.modifiersSpec.optional(),
115
122
  telemetry: telemetry_1.telemetrySpec.optional(),
116
123
  }).passthrough()
117
- .refine((data) => !("children" in data), { message: "ElementSpec MUST NOT contain 'children'. Use CompositionSpec for containers." })
118
- .refine((data) => !("layout" in data), { message: "ElementSpec MUST NOT contain 'layout'. Use CompositionSpec for layout." });
124
+ .refine((data) => !("children" in data), { message: "ElementSpec MUST NOT contain 'children'. Use CompositionSpec for containers." });
119
125
  // ─── CompositionSpec ─────────────────────────────────────────────
120
126
  // SPEC.md §2.3: type (enum), id, layout, children, telemetry REQUIRED.
121
127
  exports.compositionSpec = zod_1.z.lazy(() => zod_1.z.object({
@@ -123,7 +129,7 @@ exports.compositionSpec = zod_1.z.lazy(() => zod_1.z.object({
123
129
  id: zod_1.z.string().min(1).regex(/^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/),
124
130
  name: zod_1.z.string().optional(),
125
131
  layout: exports.layoutSpec,
126
- style: zod_1.z.record(zod_1.z.any()).optional(),
132
+ style: style_1.styleSpec.optional(),
127
133
  children: zod_1.z.array(exports.nodeSpec).min(0),
128
134
  constraints: constraintsSpec,
129
135
  modifiers: binding_1.modifiersSpec.optional(),
@@ -14,6 +14,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
14
14
  font_weight_token: z.ZodOptional<z.ZodString>;
15
15
  line_height: z.ZodOptional<z.ZodNumber>;
16
16
  line_height_token: z.ZodOptional<z.ZodString>;
17
+ line_height_percent: z.ZodOptional<z.ZodNumber>;
18
+ letter_spacing: z.ZodOptional<z.ZodNumber>;
19
+ letter_spacing_token: z.ZodOptional<z.ZodString>;
20
+ letter_spacing_percent: z.ZodOptional<z.ZodNumber>;
21
+ text_align: z.ZodOptional<z.ZodString>;
22
+ text_decoration: z.ZodOptional<z.ZodString>;
23
+ text_transform: z.ZodOptional<z.ZodString>;
24
+ text_style: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
17
25
  padding: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodObject<{
18
26
  top: z.ZodOptional<z.ZodNumber>;
19
27
  right: z.ZodOptional<z.ZodNumber>;
@@ -48,10 +56,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
48
56
  left?: number | undefined;
49
57
  }>]>>;
50
58
  margin_token: z.ZodOptional<z.ZodString>;
51
- border_radius: z.ZodOptional<z.ZodNumber>;
59
+ border_radius: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
52
60
  border_radius_token: z.ZodOptional<z.ZodString>;
53
61
  border_width: z.ZodOptional<z.ZodNumber>;
54
62
  border_width_token: z.ZodOptional<z.ZodString>;
63
+ border_top_width: z.ZodOptional<z.ZodNumber>;
64
+ border_right_width: z.ZodOptional<z.ZodNumber>;
65
+ border_bottom_width: z.ZodOptional<z.ZodNumber>;
66
+ border_left_width: z.ZodOptional<z.ZodNumber>;
55
67
  min_height: z.ZodOptional<z.ZodNumber>;
56
68
  min_height_token: z.ZodOptional<z.ZodString>;
57
69
  min_width: z.ZodOptional<z.ZodNumber>;
@@ -62,6 +74,7 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
62
74
  height_token: z.ZodOptional<z.ZodString>;
63
75
  opacity: z.ZodOptional<z.ZodNumber>;
64
76
  opacity_token: z.ZodOptional<z.ZodString>;
77
+ box_shadow: z.ZodOptional<z.ZodString>;
65
78
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
66
79
  bg_color: z.ZodOptional<z.ZodString>;
67
80
  bg_color_token: z.ZodOptional<z.ZodString>;
@@ -77,6 +90,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
77
90
  font_weight_token: z.ZodOptional<z.ZodString>;
78
91
  line_height: z.ZodOptional<z.ZodNumber>;
79
92
  line_height_token: z.ZodOptional<z.ZodString>;
93
+ line_height_percent: z.ZodOptional<z.ZodNumber>;
94
+ letter_spacing: z.ZodOptional<z.ZodNumber>;
95
+ letter_spacing_token: z.ZodOptional<z.ZodString>;
96
+ letter_spacing_percent: z.ZodOptional<z.ZodNumber>;
97
+ text_align: z.ZodOptional<z.ZodString>;
98
+ text_decoration: z.ZodOptional<z.ZodString>;
99
+ text_transform: z.ZodOptional<z.ZodString>;
100
+ text_style: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
80
101
  padding: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodObject<{
81
102
  top: z.ZodOptional<z.ZodNumber>;
82
103
  right: z.ZodOptional<z.ZodNumber>;
@@ -111,10 +132,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
111
132
  left?: number | undefined;
112
133
  }>]>>;
113
134
  margin_token: z.ZodOptional<z.ZodString>;
114
- border_radius: z.ZodOptional<z.ZodNumber>;
135
+ border_radius: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
115
136
  border_radius_token: z.ZodOptional<z.ZodString>;
116
137
  border_width: z.ZodOptional<z.ZodNumber>;
117
138
  border_width_token: z.ZodOptional<z.ZodString>;
139
+ border_top_width: z.ZodOptional<z.ZodNumber>;
140
+ border_right_width: z.ZodOptional<z.ZodNumber>;
141
+ border_bottom_width: z.ZodOptional<z.ZodNumber>;
142
+ border_left_width: z.ZodOptional<z.ZodNumber>;
118
143
  min_height: z.ZodOptional<z.ZodNumber>;
119
144
  min_height_token: z.ZodOptional<z.ZodString>;
120
145
  min_width: z.ZodOptional<z.ZodNumber>;
@@ -125,6 +150,7 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
125
150
  height_token: z.ZodOptional<z.ZodString>;
126
151
  opacity: z.ZodOptional<z.ZodNumber>;
127
152
  opacity_token: z.ZodOptional<z.ZodString>;
153
+ box_shadow: z.ZodOptional<z.ZodString>;
128
154
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
129
155
  bg_color: z.ZodOptional<z.ZodString>;
130
156
  bg_color_token: z.ZodOptional<z.ZodString>;
@@ -140,6 +166,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
140
166
  font_weight_token: z.ZodOptional<z.ZodString>;
141
167
  line_height: z.ZodOptional<z.ZodNumber>;
142
168
  line_height_token: z.ZodOptional<z.ZodString>;
169
+ line_height_percent: z.ZodOptional<z.ZodNumber>;
170
+ letter_spacing: z.ZodOptional<z.ZodNumber>;
171
+ letter_spacing_token: z.ZodOptional<z.ZodString>;
172
+ letter_spacing_percent: z.ZodOptional<z.ZodNumber>;
173
+ text_align: z.ZodOptional<z.ZodString>;
174
+ text_decoration: z.ZodOptional<z.ZodString>;
175
+ text_transform: z.ZodOptional<z.ZodString>;
176
+ text_style: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
143
177
  padding: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodObject<{
144
178
  top: z.ZodOptional<z.ZodNumber>;
145
179
  right: z.ZodOptional<z.ZodNumber>;
@@ -174,10 +208,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
174
208
  left?: number | undefined;
175
209
  }>]>>;
176
210
  margin_token: z.ZodOptional<z.ZodString>;
177
- border_radius: z.ZodOptional<z.ZodNumber>;
211
+ border_radius: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
178
212
  border_radius_token: z.ZodOptional<z.ZodString>;
179
213
  border_width: z.ZodOptional<z.ZodNumber>;
180
214
  border_width_token: z.ZodOptional<z.ZodString>;
215
+ border_top_width: z.ZodOptional<z.ZodNumber>;
216
+ border_right_width: z.ZodOptional<z.ZodNumber>;
217
+ border_bottom_width: z.ZodOptional<z.ZodNumber>;
218
+ border_left_width: z.ZodOptional<z.ZodNumber>;
181
219
  min_height: z.ZodOptional<z.ZodNumber>;
182
220
  min_height_token: z.ZodOptional<z.ZodString>;
183
221
  min_width: z.ZodOptional<z.ZodNumber>;
@@ -188,6 +226,7 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
188
226
  height_token: z.ZodOptional<z.ZodString>;
189
227
  opacity: z.ZodOptional<z.ZodNumber>;
190
228
  opacity_token: z.ZodOptional<z.ZodString>;
229
+ box_shadow: z.ZodOptional<z.ZodString>;
191
230
  }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
192
231
  bg_color: z.ZodOptional<z.ZodString>;
193
232
  bg_color_token: z.ZodOptional<z.ZodString>;
@@ -203,6 +242,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
203
242
  font_weight_token: z.ZodOptional<z.ZodString>;
204
243
  line_height: z.ZodOptional<z.ZodNumber>;
205
244
  line_height_token: z.ZodOptional<z.ZodString>;
245
+ line_height_percent: z.ZodOptional<z.ZodNumber>;
246
+ letter_spacing: z.ZodOptional<z.ZodNumber>;
247
+ letter_spacing_token: z.ZodOptional<z.ZodString>;
248
+ letter_spacing_percent: z.ZodOptional<z.ZodNumber>;
249
+ text_align: z.ZodOptional<z.ZodString>;
250
+ text_decoration: z.ZodOptional<z.ZodString>;
251
+ text_transform: z.ZodOptional<z.ZodString>;
252
+ text_style: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
206
253
  padding: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodObject<{
207
254
  top: z.ZodOptional<z.ZodNumber>;
208
255
  right: z.ZodOptional<z.ZodNumber>;
@@ -237,10 +284,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
237
284
  left?: number | undefined;
238
285
  }>]>>;
239
286
  margin_token: z.ZodOptional<z.ZodString>;
240
- border_radius: z.ZodOptional<z.ZodNumber>;
287
+ border_radius: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
241
288
  border_radius_token: z.ZodOptional<z.ZodString>;
242
289
  border_width: z.ZodOptional<z.ZodNumber>;
243
290
  border_width_token: z.ZodOptional<z.ZodString>;
291
+ border_top_width: z.ZodOptional<z.ZodNumber>;
292
+ border_right_width: z.ZodOptional<z.ZodNumber>;
293
+ border_bottom_width: z.ZodOptional<z.ZodNumber>;
294
+ border_left_width: z.ZodOptional<z.ZodNumber>;
244
295
  min_height: z.ZodOptional<z.ZodNumber>;
245
296
  min_height_token: z.ZodOptional<z.ZodString>;
246
297
  min_width: z.ZodOptional<z.ZodNumber>;
@@ -251,6 +302,7 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
251
302
  height_token: z.ZodOptional<z.ZodString>;
252
303
  opacity: z.ZodOptional<z.ZodNumber>;
253
304
  opacity_token: z.ZodOptional<z.ZodString>;
305
+ box_shadow: z.ZodOptional<z.ZodString>;
254
306
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
255
307
  bg_color: z.ZodOptional<z.ZodString>;
256
308
  bg_color_token: z.ZodOptional<z.ZodString>;
@@ -266,6 +318,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
266
318
  font_weight_token: z.ZodOptional<z.ZodString>;
267
319
  line_height: z.ZodOptional<z.ZodNumber>;
268
320
  line_height_token: z.ZodOptional<z.ZodString>;
321
+ line_height_percent: z.ZodOptional<z.ZodNumber>;
322
+ letter_spacing: z.ZodOptional<z.ZodNumber>;
323
+ letter_spacing_token: z.ZodOptional<z.ZodString>;
324
+ letter_spacing_percent: z.ZodOptional<z.ZodNumber>;
325
+ text_align: z.ZodOptional<z.ZodString>;
326
+ text_decoration: z.ZodOptional<z.ZodString>;
327
+ text_transform: z.ZodOptional<z.ZodString>;
328
+ text_style: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
269
329
  padding: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodObject<{
270
330
  top: z.ZodOptional<z.ZodNumber>;
271
331
  right: z.ZodOptional<z.ZodNumber>;
@@ -300,10 +360,14 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
300
360
  left?: number | undefined;
301
361
  }>]>>;
302
362
  margin_token: z.ZodOptional<z.ZodString>;
303
- border_radius: z.ZodOptional<z.ZodNumber>;
363
+ border_radius: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodArray<z.ZodNumber, "many">]>>;
304
364
  border_radius_token: z.ZodOptional<z.ZodString>;
305
365
  border_width: z.ZodOptional<z.ZodNumber>;
306
366
  border_width_token: z.ZodOptional<z.ZodString>;
367
+ border_top_width: z.ZodOptional<z.ZodNumber>;
368
+ border_right_width: z.ZodOptional<z.ZodNumber>;
369
+ border_bottom_width: z.ZodOptional<z.ZodNumber>;
370
+ border_left_width: z.ZodOptional<z.ZodNumber>;
307
371
  min_height: z.ZodOptional<z.ZodNumber>;
308
372
  min_height_token: z.ZodOptional<z.ZodString>;
309
373
  min_width: z.ZodOptional<z.ZodNumber>;
@@ -314,5 +378,6 @@ export declare const styleSpec: z.ZodEffects<z.ZodObject<{
314
378
  height_token: z.ZodOptional<z.ZodString>;
315
379
  opacity: z.ZodOptional<z.ZodNumber>;
316
380
  opacity_token: z.ZodOptional<z.ZodString>;
381
+ box_shadow: z.ZodOptional<z.ZodString>;
317
382
  }, z.ZodTypeAny, "passthrough">>;
318
383
  export type StyleSpec = z.infer<typeof styleSpec>;
@@ -28,6 +28,15 @@ exports.styleSpec = zod_1.z.object({
28
28
  font_weight_token: dtcgTokenPath.optional(),
29
29
  line_height: zod_1.z.number().optional(),
30
30
  line_height_token: dtcgTokenPath.optional(),
31
+ line_height_percent: zod_1.z.number().optional(),
32
+ letter_spacing: zod_1.z.number().optional(),
33
+ letter_spacing_token: dtcgTokenPath.optional(),
34
+ letter_spacing_percent: zod_1.z.number().optional(),
35
+ text_align: zod_1.z.string().optional(),
36
+ text_decoration: zod_1.z.string().optional(),
37
+ text_transform: zod_1.z.string().optional(),
38
+ // ── Nested text_style (for composition children) ──
39
+ text_style: zod_1.z.record(zod_1.z.any()).optional(),
31
40
  // ── Spacing Properties ──
32
41
  padding: zod_1.z.union([
33
42
  zod_1.z.number(),
@@ -50,10 +59,14 @@ exports.styleSpec = zod_1.z.object({
50
59
  ]).optional(),
51
60
  margin_token: dtcgTokenPath.optional(),
52
61
  // ── Border Properties ──
53
- border_radius: zod_1.z.number().optional(),
62
+ border_radius: zod_1.z.union([zod_1.z.number(), zod_1.z.array(zod_1.z.number())]).optional(),
54
63
  border_radius_token: dtcgTokenPath.optional(),
55
64
  border_width: zod_1.z.number().optional(),
56
65
  border_width_token: dtcgTokenPath.optional(),
66
+ border_top_width: zod_1.z.number().optional(),
67
+ border_right_width: zod_1.z.number().optional(),
68
+ border_bottom_width: zod_1.z.number().optional(),
69
+ border_left_width: zod_1.z.number().optional(),
57
70
  // ── Dimension Properties ──
58
71
  min_height: zod_1.z.number().optional(),
59
72
  min_height_token: dtcgTokenPath.optional(),
@@ -63,9 +76,10 @@ exports.styleSpec = zod_1.z.object({
63
76
  width_token: dtcgTokenPath.optional(),
64
77
  height: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).optional(),
65
78
  height_token: dtcgTokenPath.optional(),
66
- // ── Opacity ──
79
+ // ── Visual ──
67
80
  opacity: zod_1.z.number().min(0).max(1).optional(),
68
81
  opacity_token: dtcgTokenPath.optional(),
82
+ box_shadow: zod_1.z.string().optional(),
69
83
  }).passthrough().superRefine((data, ctx) => {
70
84
  // Fail-Closed Governance: If a literal style value exists, its corresponding token MUST exist.
71
85
  const rules = [
@@ -76,6 +90,9 @@ exports.styleSpec = zod_1.z.object({
76
90
  { literal: 'font_size', token: 'font_size_token' },
77
91
  { literal: 'font_weight', token: 'font_weight_token' },
78
92
  { literal: 'line_height', token: 'line_height_token' },
93
+ { literal: 'line_height_percent', token: 'line_height_token' },
94
+ { literal: 'letter_spacing', token: 'letter_spacing_token' },
95
+ { literal: 'letter_spacing_percent', token: 'letter_spacing_token' },
79
96
  { literal: 'padding', token: 'padding_token' },
80
97
  { literal: 'margin', token: 'margin_token' },
81
98
  { literal: 'border_radius', token: 'border_radius_token' },
@@ -90,5 +107,28 @@ exports.styleSpec = zod_1.z.object({
90
107
  });
91
108
  }
92
109
  });
110
+ // Also validate nested text_style if present
111
+ if (data.text_style && typeof data.text_style === 'object') {
112
+ const ts = data.text_style;
113
+ const textRules = [
114
+ { literal: 'text_color', token: 'text_color_token' },
115
+ { literal: 'font_family', token: 'font_family_token' },
116
+ { literal: 'font_size', token: 'font_size_token' },
117
+ { literal: 'font_weight', token: 'font_weight_token' },
118
+ { literal: 'line_height', token: 'line_height_token' },
119
+ { literal: 'line_height_percent', token: 'line_height_token' },
120
+ { literal: 'letter_spacing', token: 'letter_spacing_token' },
121
+ { literal: 'letter_spacing_percent', token: 'letter_spacing_token' },
122
+ ];
123
+ textRules.forEach(({ literal, token }) => {
124
+ if (ts[literal] !== undefined && ts[token] === undefined) {
125
+ ctx.addIssue({
126
+ code: zod_1.z.ZodIssueCode.custom,
127
+ message: `Fail-Closed Governance: Unbound Literal Value. text_style declares [${literal}] but is missing [${token}]. Hardcoded visual styles are rejected.`,
128
+ path: ['text_style', literal],
129
+ });
130
+ }
131
+ });
132
+ }
93
133
  return true;
94
134
  }); // Allow vendor extensions (§2.9)
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "name": "desen-core",
3
- "version": "1.0.0-draft.29",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "scripts": {
7
- "build": "tsc",
8
- "dev": "tsc -w",
9
- "clean": "rm -rf dist"
10
- },
11
- "dependencies": {
12
- "zod": "^3.22.4"
13
- },
14
- "devDependencies": {
15
- "typescript": "^5.0.0"
16
- }
2
+ "name": "desen-core",
3
+ "version": "1.0.0-draft.30",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "dependencies": {
7
+ "zod": "^3.22.4"
8
+ },
9
+ "devDependencies": {
10
+ "typescript": "^5.0.0"
11
+ },
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "dev": "tsc -w",
15
+ "clean": "rm -rf dist"
16
+ }
17
17
  }
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { modifiersSpec, bindingSpec } from "./binding";
3
3
  import { telemetrySpec } from "./telemetry";
4
+ import { styleSpec } from "./style";
4
5
 
5
6
  // ─── Forward-declare recursive types ─────────────────────────────
6
7
  // TypeScript needs explicit type annotations for circular schemas.
@@ -128,7 +129,13 @@ const elementSpecInternal = z.object({
128
129
  type: z.string().min(1),
129
130
  id: z.string().min(1),
130
131
  name: z.string().optional(),
131
- props: z.record(z.any()),
132
+ props: z.object({
133
+ style: styleSpec.optional(),
134
+ layout: layoutSpec.optional(),
135
+ action: z.any().optional(),
136
+ text: z.string().optional(),
137
+ src: z.string().optional(),
138
+ }).passthrough().optional(),
132
139
  constraints: constraintsSpec,
133
140
  modifiers: modifiersSpec.optional(),
134
141
  telemetry: telemetrySpec.optional(),
@@ -136,10 +143,6 @@ const elementSpecInternal = z.object({
136
143
  .refine(
137
144
  (data) => !("children" in data),
138
145
  { message: "ElementSpec MUST NOT contain 'children'. Use CompositionSpec for containers." }
139
- )
140
- .refine(
141
- (data) => !("layout" in data),
142
- { message: "ElementSpec MUST NOT contain 'layout'. Use CompositionSpec for layout." }
143
146
  );
144
147
 
145
148
  // ─── CompositionSpec ─────────────────────────────────────────────
@@ -150,7 +153,7 @@ export const compositionSpec: z.ZodType<any> = z.lazy(() =>
150
153
  id: z.string().min(1).regex(/^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/),
151
154
  name: z.string().optional(),
152
155
  layout: layoutSpec,
153
- style: z.record(z.any()).optional(),
156
+ style: styleSpec.optional(),
154
157
  children: z.array(nodeSpec).min(0),
155
158
  constraints: constraintsSpec,
156
159
  modifiers: modifiersSpec.optional(),
@@ -29,6 +29,16 @@ export const styleSpec = z.object({
29
29
  font_weight_token: dtcgTokenPath.optional(),
30
30
  line_height: z.number().optional(),
31
31
  line_height_token: dtcgTokenPath.optional(),
32
+ line_height_percent: z.number().optional(),
33
+ letter_spacing: z.number().optional(),
34
+ letter_spacing_token: dtcgTokenPath.optional(),
35
+ letter_spacing_percent: z.number().optional(),
36
+ text_align: z.string().optional(),
37
+ text_decoration: z.string().optional(),
38
+ text_transform: z.string().optional(),
39
+
40
+ // ── Nested text_style (for composition children) ──
41
+ text_style: z.record(z.any()).optional(),
32
42
 
33
43
  // ── Spacing Properties ──
34
44
  padding: z.union([
@@ -53,10 +63,14 @@ export const styleSpec = z.object({
53
63
  margin_token: dtcgTokenPath.optional(),
54
64
 
55
65
  // ── Border Properties ──
56
- border_radius: z.number().optional(),
66
+ border_radius: z.union([z.number(), z.array(z.number())]).optional(),
57
67
  border_radius_token: dtcgTokenPath.optional(),
58
68
  border_width: z.number().optional(),
59
69
  border_width_token: dtcgTokenPath.optional(),
70
+ border_top_width: z.number().optional(),
71
+ border_right_width: z.number().optional(),
72
+ border_bottom_width: z.number().optional(),
73
+ border_left_width: z.number().optional(),
60
74
 
61
75
  // ── Dimension Properties ──
62
76
  min_height: z.number().optional(),
@@ -68,9 +82,10 @@ export const styleSpec = z.object({
68
82
  height: z.union([z.number(), z.string()]).optional(),
69
83
  height_token: dtcgTokenPath.optional(),
70
84
 
71
- // ── Opacity ──
85
+ // ── Visual ──
72
86
  opacity: z.number().min(0).max(1).optional(),
73
87
  opacity_token: dtcgTokenPath.optional(),
88
+ box_shadow: z.string().optional(),
74
89
  }).passthrough().superRefine((data, ctx) => {
75
90
  // Fail-Closed Governance: If a literal style value exists, its corresponding token MUST exist.
76
91
  const rules = [
@@ -81,6 +96,9 @@ export const styleSpec = z.object({
81
96
  { literal: 'font_size', token: 'font_size_token' },
82
97
  { literal: 'font_weight', token: 'font_weight_token' },
83
98
  { literal: 'line_height', token: 'line_height_token' },
99
+ { literal: 'line_height_percent', token: 'line_height_token' },
100
+ { literal: 'letter_spacing', token: 'letter_spacing_token' },
101
+ { literal: 'letter_spacing_percent', token: 'letter_spacing_token' },
84
102
  { literal: 'padding', token: 'padding_token' },
85
103
  { literal: 'margin', token: 'margin_token' },
86
104
  { literal: 'border_radius', token: 'border_radius_token' },
@@ -97,6 +115,30 @@ export const styleSpec = z.object({
97
115
  }
98
116
  });
99
117
 
118
+ // Also validate nested text_style if present
119
+ if (data.text_style && typeof data.text_style === 'object') {
120
+ const ts = data.text_style as Record<string, any>;
121
+ const textRules = [
122
+ { literal: 'text_color', token: 'text_color_token' },
123
+ { literal: 'font_family', token: 'font_family_token' },
124
+ { literal: 'font_size', token: 'font_size_token' },
125
+ { literal: 'font_weight', token: 'font_weight_token' },
126
+ { literal: 'line_height', token: 'line_height_token' },
127
+ { literal: 'line_height_percent', token: 'line_height_token' },
128
+ { literal: 'letter_spacing', token: 'letter_spacing_token' },
129
+ { literal: 'letter_spacing_percent', token: 'letter_spacing_token' },
130
+ ];
131
+ textRules.forEach(({ literal, token }) => {
132
+ if (ts[literal] !== undefined && ts[token] === undefined) {
133
+ ctx.addIssue({
134
+ code: z.ZodIssueCode.custom,
135
+ message: `Fail-Closed Governance: Unbound Literal Value. text_style declares [${literal}] but is missing [${token}]. Hardcoded visual styles are rejected.`,
136
+ path: ['text_style', literal],
137
+ });
138
+ }
139
+ });
140
+ }
141
+
100
142
  return true;
101
143
  }); // Allow vendor extensions (§2.9)
102
144