@polotno/schema 0.6.1 → 0.7.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.
- package/lib/asset-urls.d.ts +3 -0
- package/lib/asset-urls.js +28 -0
- package/lib/defaults.d.ts +2 -0
- package/lib/defaults.js +20 -0
- package/lib/design.schema.json +255 -31
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/schema.d.ts +146 -2
- package/lib/schema.js +57 -37
- package/lib/types.d.ts +7 -0
- package/package.json +7 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Asset fields belong to the design format. Keep this walk zod-free so Node
|
|
2
|
+
// renderers and fixture loaders can share it without importing validation.
|
|
3
|
+
// `custom` is arbitrary caller data; its strings must never be rewritten.
|
|
4
|
+
export const URL_FIELDS = ['src', 'clipSrc', 'maskSrc', 'background', 'url'];
|
|
5
|
+
const URL_FIELD_SET = new Set(URL_FIELDS);
|
|
6
|
+
/** Visit each asset string in place, including nested groups and font styles. */
|
|
7
|
+
export function forEveryUrlField(node, visit) {
|
|
8
|
+
if (!node || typeof node !== 'object')
|
|
9
|
+
return;
|
|
10
|
+
if (Array.isArray(node)) {
|
|
11
|
+
for (const item of node)
|
|
12
|
+
forEveryUrlField(item, visit);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const record = node;
|
|
16
|
+
for (const key of Object.keys(record)) {
|
|
17
|
+
if (key === 'custom')
|
|
18
|
+
continue;
|
|
19
|
+
const value = record[key];
|
|
20
|
+
if (typeof value === 'string') {
|
|
21
|
+
if (URL_FIELD_SET.has(key))
|
|
22
|
+
visit(record, key, value);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
forEveryUrlField(value, visit);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/lib/defaults.d.ts
CHANGED
|
@@ -79,3 +79,5 @@ export declare const MIN_FONT_SIZE = 1;
|
|
|
79
79
|
* the table", which is not a size to clamp.
|
|
80
80
|
*/
|
|
81
81
|
export declare const clampFontSize: <T extends number | undefined>(size: T) => T;
|
|
82
|
+
export declare const BLEND_MODES: readonly ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
|
|
83
|
+
export declare const GROUP_BLEND_MODES: readonly ["pass-through", "normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
|
package/lib/defaults.js
CHANGED
|
@@ -127,3 +127,23 @@ export const MIN_FONT_SIZE = 1;
|
|
|
127
127
|
* the table", which is not a size to clamp.
|
|
128
128
|
*/
|
|
129
129
|
export const clampFontSize = (size) => (size != null && size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size);
|
|
130
|
+
export const BLEND_MODES = [
|
|
131
|
+
'normal',
|
|
132
|
+
'multiply',
|
|
133
|
+
'screen',
|
|
134
|
+
'overlay',
|
|
135
|
+
'darken',
|
|
136
|
+
'lighten',
|
|
137
|
+
'color-dodge',
|
|
138
|
+
'color-burn',
|
|
139
|
+
'hard-light',
|
|
140
|
+
'soft-light',
|
|
141
|
+
'difference',
|
|
142
|
+
'exclusion',
|
|
143
|
+
'hue',
|
|
144
|
+
'saturation',
|
|
145
|
+
'color',
|
|
146
|
+
'luminosity',
|
|
147
|
+
];
|
|
148
|
+
// A group's default: its children blend through it. Any other mode isolates it.
|
|
149
|
+
export const GROUP_BLEND_MODES = ['pass-through', ...BLEND_MODES];
|
package/lib/design.schema.json
CHANGED
|
@@ -235,7 +235,8 @@
|
|
|
235
235
|
},
|
|
236
236
|
"type": {
|
|
237
237
|
"type": "string",
|
|
238
|
-
"const": "text"
|
|
238
|
+
"const": "text",
|
|
239
|
+
"description": "Element type identifier."
|
|
239
240
|
},
|
|
240
241
|
"name": {
|
|
241
242
|
"default": "",
|
|
@@ -275,6 +276,28 @@
|
|
|
275
276
|
"description": "Opacity level (0-1).",
|
|
276
277
|
"type": "number"
|
|
277
278
|
},
|
|
279
|
+
"blendMode": {
|
|
280
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
281
|
+
"type": "string",
|
|
282
|
+
"enum": [
|
|
283
|
+
"normal",
|
|
284
|
+
"multiply",
|
|
285
|
+
"screen",
|
|
286
|
+
"overlay",
|
|
287
|
+
"darken",
|
|
288
|
+
"lighten",
|
|
289
|
+
"color-dodge",
|
|
290
|
+
"color-burn",
|
|
291
|
+
"hard-light",
|
|
292
|
+
"soft-light",
|
|
293
|
+
"difference",
|
|
294
|
+
"exclusion",
|
|
295
|
+
"hue",
|
|
296
|
+
"saturation",
|
|
297
|
+
"color",
|
|
298
|
+
"luminosity"
|
|
299
|
+
]
|
|
300
|
+
},
|
|
278
301
|
"animations": {
|
|
279
302
|
"default": [],
|
|
280
303
|
"description": "Animation configurations.",
|
|
@@ -517,13 +540,9 @@
|
|
|
517
540
|
"lineHeight": {
|
|
518
541
|
"default": 1.2,
|
|
519
542
|
"description": "Line height multiplier or 'auto'.",
|
|
520
|
-
"
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
"type": "string"
|
|
526
|
-
}
|
|
543
|
+
"type": [
|
|
544
|
+
"number",
|
|
545
|
+
"string"
|
|
527
546
|
]
|
|
528
547
|
},
|
|
529
548
|
"letterSpacing": {
|
|
@@ -585,7 +604,8 @@
|
|
|
585
604
|
},
|
|
586
605
|
"type": {
|
|
587
606
|
"type": "string",
|
|
588
|
-
"const": "image"
|
|
607
|
+
"const": "image",
|
|
608
|
+
"description": "Element type identifier."
|
|
589
609
|
},
|
|
590
610
|
"name": {
|
|
591
611
|
"default": "",
|
|
@@ -625,6 +645,28 @@
|
|
|
625
645
|
"description": "Opacity level (0-1).",
|
|
626
646
|
"type": "number"
|
|
627
647
|
},
|
|
648
|
+
"blendMode": {
|
|
649
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
650
|
+
"type": "string",
|
|
651
|
+
"enum": [
|
|
652
|
+
"normal",
|
|
653
|
+
"multiply",
|
|
654
|
+
"screen",
|
|
655
|
+
"overlay",
|
|
656
|
+
"darken",
|
|
657
|
+
"lighten",
|
|
658
|
+
"color-dodge",
|
|
659
|
+
"color-burn",
|
|
660
|
+
"hard-light",
|
|
661
|
+
"soft-light",
|
|
662
|
+
"difference",
|
|
663
|
+
"exclusion",
|
|
664
|
+
"hue",
|
|
665
|
+
"saturation",
|
|
666
|
+
"color",
|
|
667
|
+
"luminosity"
|
|
668
|
+
]
|
|
669
|
+
},
|
|
628
670
|
"animations": {
|
|
629
671
|
"default": [],
|
|
630
672
|
"description": "Animation configurations.",
|
|
@@ -874,7 +916,8 @@
|
|
|
874
916
|
},
|
|
875
917
|
"type": {
|
|
876
918
|
"type": "string",
|
|
877
|
-
"const": "svg"
|
|
919
|
+
"const": "svg",
|
|
920
|
+
"description": "Element type identifier."
|
|
878
921
|
},
|
|
879
922
|
"name": {
|
|
880
923
|
"default": "",
|
|
@@ -896,10 +939,12 @@
|
|
|
896
939
|
},
|
|
897
940
|
"width": {
|
|
898
941
|
"default": 100,
|
|
942
|
+
"description": "Width in pixels.",
|
|
899
943
|
"type": "number"
|
|
900
944
|
},
|
|
901
945
|
"height": {
|
|
902
946
|
"default": 100,
|
|
947
|
+
"description": "Height in pixels.",
|
|
903
948
|
"type": "number"
|
|
904
949
|
},
|
|
905
950
|
"rotation": {
|
|
@@ -912,6 +957,28 @@
|
|
|
912
957
|
"description": "Opacity level (0-1).",
|
|
913
958
|
"type": "number"
|
|
914
959
|
},
|
|
960
|
+
"blendMode": {
|
|
961
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
962
|
+
"type": "string",
|
|
963
|
+
"enum": [
|
|
964
|
+
"normal",
|
|
965
|
+
"multiply",
|
|
966
|
+
"screen",
|
|
967
|
+
"overlay",
|
|
968
|
+
"darken",
|
|
969
|
+
"lighten",
|
|
970
|
+
"color-dodge",
|
|
971
|
+
"color-burn",
|
|
972
|
+
"hard-light",
|
|
973
|
+
"soft-light",
|
|
974
|
+
"difference",
|
|
975
|
+
"exclusion",
|
|
976
|
+
"hue",
|
|
977
|
+
"saturation",
|
|
978
|
+
"color",
|
|
979
|
+
"luminosity"
|
|
980
|
+
]
|
|
981
|
+
},
|
|
915
982
|
"animations": {
|
|
916
983
|
"default": [],
|
|
917
984
|
"description": "Animation configurations.",
|
|
@@ -1093,18 +1160,22 @@
|
|
|
1093
1160
|
},
|
|
1094
1161
|
"cropX": {
|
|
1095
1162
|
"default": 0,
|
|
1163
|
+
"description": "Crop X offset as a fraction (0-1).",
|
|
1096
1164
|
"type": "number"
|
|
1097
1165
|
},
|
|
1098
1166
|
"cropY": {
|
|
1099
1167
|
"default": 0,
|
|
1168
|
+
"description": "Crop Y offset as a fraction (0-1).",
|
|
1100
1169
|
"type": "number"
|
|
1101
1170
|
},
|
|
1102
1171
|
"cropWidth": {
|
|
1103
1172
|
"default": 1,
|
|
1173
|
+
"description": "Crop width as a fraction (0-1).",
|
|
1104
1174
|
"type": "number"
|
|
1105
1175
|
},
|
|
1106
1176
|
"cropHeight": {
|
|
1107
1177
|
"default": 1,
|
|
1178
|
+
"description": "Crop height as a fraction (0-1).",
|
|
1108
1179
|
"type": "number"
|
|
1109
1180
|
},
|
|
1110
1181
|
"keepRatio": {
|
|
@@ -1114,26 +1185,32 @@
|
|
|
1114
1185
|
},
|
|
1115
1186
|
"stretchEnabled": {
|
|
1116
1187
|
"default": true,
|
|
1188
|
+
"description": "Whether stretch mode is enabled.",
|
|
1117
1189
|
"type": "boolean"
|
|
1118
1190
|
},
|
|
1119
1191
|
"flipX": {
|
|
1120
1192
|
"default": false,
|
|
1193
|
+
"description": "Whether the image is flipped horizontally.",
|
|
1121
1194
|
"type": "boolean"
|
|
1122
1195
|
},
|
|
1123
1196
|
"flipY": {
|
|
1124
1197
|
"default": false,
|
|
1198
|
+
"description": "Whether the image is flipped vertically.",
|
|
1125
1199
|
"type": "boolean"
|
|
1126
1200
|
},
|
|
1127
1201
|
"borderColor": {
|
|
1128
1202
|
"default": "black",
|
|
1203
|
+
"description": "Border color.",
|
|
1129
1204
|
"type": "string"
|
|
1130
1205
|
},
|
|
1131
1206
|
"borderSize": {
|
|
1132
1207
|
"default": 0,
|
|
1208
|
+
"description": "Border width in pixels.",
|
|
1133
1209
|
"type": "number"
|
|
1134
1210
|
},
|
|
1135
1211
|
"cornerRadius": {
|
|
1136
1212
|
"default": 0,
|
|
1213
|
+
"description": "Corner radius in pixels.",
|
|
1137
1214
|
"type": "number"
|
|
1138
1215
|
},
|
|
1139
1216
|
"colorsReplace": {
|
|
@@ -1162,7 +1239,8 @@
|
|
|
1162
1239
|
},
|
|
1163
1240
|
"type": {
|
|
1164
1241
|
"type": "string",
|
|
1165
|
-
"const": "line"
|
|
1242
|
+
"const": "line",
|
|
1243
|
+
"description": "Element type identifier."
|
|
1166
1244
|
},
|
|
1167
1245
|
"name": {
|
|
1168
1246
|
"default": "",
|
|
@@ -1184,10 +1262,12 @@
|
|
|
1184
1262
|
},
|
|
1185
1263
|
"width": {
|
|
1186
1264
|
"default": 400,
|
|
1265
|
+
"description": "Width in pixels.",
|
|
1187
1266
|
"type": "number"
|
|
1188
1267
|
},
|
|
1189
1268
|
"height": {
|
|
1190
1269
|
"default": 10,
|
|
1270
|
+
"description": "Height in pixels.",
|
|
1191
1271
|
"type": "number"
|
|
1192
1272
|
},
|
|
1193
1273
|
"rotation": {
|
|
@@ -1200,6 +1280,28 @@
|
|
|
1200
1280
|
"description": "Opacity level (0-1).",
|
|
1201
1281
|
"type": "number"
|
|
1202
1282
|
},
|
|
1283
|
+
"blendMode": {
|
|
1284
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
1285
|
+
"type": "string",
|
|
1286
|
+
"enum": [
|
|
1287
|
+
"normal",
|
|
1288
|
+
"multiply",
|
|
1289
|
+
"screen",
|
|
1290
|
+
"overlay",
|
|
1291
|
+
"darken",
|
|
1292
|
+
"lighten",
|
|
1293
|
+
"color-dodge",
|
|
1294
|
+
"color-burn",
|
|
1295
|
+
"hard-light",
|
|
1296
|
+
"soft-light",
|
|
1297
|
+
"difference",
|
|
1298
|
+
"exclusion",
|
|
1299
|
+
"hue",
|
|
1300
|
+
"saturation",
|
|
1301
|
+
"color",
|
|
1302
|
+
"luminosity"
|
|
1303
|
+
]
|
|
1304
|
+
},
|
|
1203
1305
|
"animations": {
|
|
1204
1306
|
"default": [],
|
|
1205
1307
|
"description": "Animation configurations.",
|
|
@@ -1407,7 +1509,8 @@
|
|
|
1407
1509
|
},
|
|
1408
1510
|
"type": {
|
|
1409
1511
|
"type": "string",
|
|
1410
|
-
"const": "figure"
|
|
1512
|
+
"const": "figure",
|
|
1513
|
+
"description": "Element type identifier."
|
|
1411
1514
|
},
|
|
1412
1515
|
"name": {
|
|
1413
1516
|
"default": "",
|
|
@@ -1447,6 +1550,28 @@
|
|
|
1447
1550
|
"description": "Opacity level (0-1).",
|
|
1448
1551
|
"type": "number"
|
|
1449
1552
|
},
|
|
1553
|
+
"blendMode": {
|
|
1554
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
1555
|
+
"type": "string",
|
|
1556
|
+
"enum": [
|
|
1557
|
+
"normal",
|
|
1558
|
+
"multiply",
|
|
1559
|
+
"screen",
|
|
1560
|
+
"overlay",
|
|
1561
|
+
"darken",
|
|
1562
|
+
"lighten",
|
|
1563
|
+
"color-dodge",
|
|
1564
|
+
"color-burn",
|
|
1565
|
+
"hard-light",
|
|
1566
|
+
"soft-light",
|
|
1567
|
+
"difference",
|
|
1568
|
+
"exclusion",
|
|
1569
|
+
"hue",
|
|
1570
|
+
"saturation",
|
|
1571
|
+
"color",
|
|
1572
|
+
"luminosity"
|
|
1573
|
+
]
|
|
1574
|
+
},
|
|
1450
1575
|
"animations": {
|
|
1451
1576
|
"default": [],
|
|
1452
1577
|
"description": "Animation configurations.",
|
|
@@ -1636,14 +1761,17 @@
|
|
|
1636
1761
|
},
|
|
1637
1762
|
"strokeWidth": {
|
|
1638
1763
|
"default": 0,
|
|
1764
|
+
"description": "Stroke width in pixels.",
|
|
1639
1765
|
"type": "number"
|
|
1640
1766
|
},
|
|
1641
1767
|
"stroke": {
|
|
1642
1768
|
"default": "rgba(98, 197, 255, 1)",
|
|
1769
|
+
"description": "Stroke color.",
|
|
1643
1770
|
"type": "string"
|
|
1644
1771
|
},
|
|
1645
1772
|
"cornerRadius": {
|
|
1646
1773
|
"default": 0,
|
|
1774
|
+
"description": "Corner radius in pixels.",
|
|
1647
1775
|
"type": "number"
|
|
1648
1776
|
}
|
|
1649
1777
|
},
|
|
@@ -1661,7 +1789,8 @@
|
|
|
1661
1789
|
},
|
|
1662
1790
|
"type": {
|
|
1663
1791
|
"type": "string",
|
|
1664
|
-
"const": "gif"
|
|
1792
|
+
"const": "gif",
|
|
1793
|
+
"description": "Element type identifier."
|
|
1665
1794
|
},
|
|
1666
1795
|
"name": {
|
|
1667
1796
|
"default": "",
|
|
@@ -1701,6 +1830,28 @@
|
|
|
1701
1830
|
"description": "Opacity level (0-1).",
|
|
1702
1831
|
"type": "number"
|
|
1703
1832
|
},
|
|
1833
|
+
"blendMode": {
|
|
1834
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
1835
|
+
"type": "string",
|
|
1836
|
+
"enum": [
|
|
1837
|
+
"normal",
|
|
1838
|
+
"multiply",
|
|
1839
|
+
"screen",
|
|
1840
|
+
"overlay",
|
|
1841
|
+
"darken",
|
|
1842
|
+
"lighten",
|
|
1843
|
+
"color-dodge",
|
|
1844
|
+
"color-burn",
|
|
1845
|
+
"hard-light",
|
|
1846
|
+
"soft-light",
|
|
1847
|
+
"difference",
|
|
1848
|
+
"exclusion",
|
|
1849
|
+
"hue",
|
|
1850
|
+
"saturation",
|
|
1851
|
+
"color",
|
|
1852
|
+
"luminosity"
|
|
1853
|
+
]
|
|
1854
|
+
},
|
|
1704
1855
|
"animations": {
|
|
1705
1856
|
"default": [],
|
|
1706
1857
|
"description": "Animation configurations.",
|
|
@@ -1927,6 +2078,7 @@
|
|
|
1927
2078
|
},
|
|
1928
2079
|
"keepRatio": {
|
|
1929
2080
|
"default": true,
|
|
2081
|
+
"description": "Whether to maintain aspect ratio when resizing.",
|
|
1930
2082
|
"type": "boolean"
|
|
1931
2083
|
},
|
|
1932
2084
|
"stretchEnabled": {
|
|
@@ -1954,7 +2106,8 @@
|
|
|
1954
2106
|
},
|
|
1955
2107
|
"type": {
|
|
1956
2108
|
"type": "string",
|
|
1957
|
-
"const": "video"
|
|
2109
|
+
"const": "video",
|
|
2110
|
+
"description": "Element type identifier."
|
|
1958
2111
|
},
|
|
1959
2112
|
"name": {
|
|
1960
2113
|
"default": "",
|
|
@@ -1994,6 +2147,28 @@
|
|
|
1994
2147
|
"description": "Opacity level (0-1).",
|
|
1995
2148
|
"type": "number"
|
|
1996
2149
|
},
|
|
2150
|
+
"blendMode": {
|
|
2151
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
2152
|
+
"type": "string",
|
|
2153
|
+
"enum": [
|
|
2154
|
+
"normal",
|
|
2155
|
+
"multiply",
|
|
2156
|
+
"screen",
|
|
2157
|
+
"overlay",
|
|
2158
|
+
"darken",
|
|
2159
|
+
"lighten",
|
|
2160
|
+
"color-dodge",
|
|
2161
|
+
"color-burn",
|
|
2162
|
+
"hard-light",
|
|
2163
|
+
"soft-light",
|
|
2164
|
+
"difference",
|
|
2165
|
+
"exclusion",
|
|
2166
|
+
"hue",
|
|
2167
|
+
"saturation",
|
|
2168
|
+
"color",
|
|
2169
|
+
"luminosity"
|
|
2170
|
+
]
|
|
2171
|
+
},
|
|
1997
2172
|
"animations": {
|
|
1998
2173
|
"default": [],
|
|
1999
2174
|
"description": "Animation configurations.",
|
|
@@ -2309,6 +2484,28 @@
|
|
|
2309
2484
|
"description": "Opacity level (0-1).",
|
|
2310
2485
|
"type": "number"
|
|
2311
2486
|
},
|
|
2487
|
+
"blendMode": {
|
|
2488
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
2489
|
+
"type": "string",
|
|
2490
|
+
"enum": [
|
|
2491
|
+
"normal",
|
|
2492
|
+
"multiply",
|
|
2493
|
+
"screen",
|
|
2494
|
+
"overlay",
|
|
2495
|
+
"darken",
|
|
2496
|
+
"lighten",
|
|
2497
|
+
"color-dodge",
|
|
2498
|
+
"color-burn",
|
|
2499
|
+
"hard-light",
|
|
2500
|
+
"soft-light",
|
|
2501
|
+
"difference",
|
|
2502
|
+
"exclusion",
|
|
2503
|
+
"hue",
|
|
2504
|
+
"saturation",
|
|
2505
|
+
"color",
|
|
2506
|
+
"luminosity"
|
|
2507
|
+
]
|
|
2508
|
+
},
|
|
2312
2509
|
"animations": {
|
|
2313
2510
|
"default": [],
|
|
2314
2511
|
"description": "Animation configurations.",
|
|
@@ -2611,13 +2808,9 @@
|
|
|
2611
2808
|
},
|
|
2612
2809
|
"lineHeight": {
|
|
2613
2810
|
"description": "Line height multiplier or 'auto' (inherits from the table when omitted).",
|
|
2614
|
-
"
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
},
|
|
2618
|
-
{
|
|
2619
|
-
"type": "string"
|
|
2620
|
-
}
|
|
2811
|
+
"type": [
|
|
2812
|
+
"number",
|
|
2813
|
+
"string"
|
|
2621
2814
|
]
|
|
2622
2815
|
},
|
|
2623
2816
|
"letterSpacing": {
|
|
@@ -2715,13 +2908,9 @@
|
|
|
2715
2908
|
"lineHeight": {
|
|
2716
2909
|
"default": 1.2,
|
|
2717
2910
|
"description": "Default line height multiplier or 'auto'.",
|
|
2718
|
-
"
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
},
|
|
2722
|
-
{
|
|
2723
|
-
"type": "string"
|
|
2724
|
-
}
|
|
2911
|
+
"type": [
|
|
2912
|
+
"number",
|
|
2913
|
+
"string"
|
|
2725
2914
|
]
|
|
2726
2915
|
},
|
|
2727
2916
|
"letterSpacing": {
|
|
@@ -2759,43 +2948,78 @@
|
|
|
2759
2948
|
"type": "object",
|
|
2760
2949
|
"properties": {
|
|
2761
2950
|
"id": {
|
|
2762
|
-
"type": "string"
|
|
2951
|
+
"type": "string",
|
|
2952
|
+
"description": "Unique identifier for the element."
|
|
2763
2953
|
},
|
|
2764
2954
|
"type": {
|
|
2765
2955
|
"type": "string",
|
|
2766
|
-
"const": "group"
|
|
2956
|
+
"const": "group",
|
|
2957
|
+
"description": "Element type identifier."
|
|
2767
2958
|
},
|
|
2768
2959
|
"name": {
|
|
2769
2960
|
"default": "",
|
|
2961
|
+
"description": "Display name for the element.",
|
|
2770
2962
|
"type": "string"
|
|
2771
2963
|
},
|
|
2772
|
-
"custom": {
|
|
2964
|
+
"custom": {
|
|
2965
|
+
"description": "Custom data attached to the element."
|
|
2966
|
+
},
|
|
2773
2967
|
"opacity": {
|
|
2774
2968
|
"default": 1,
|
|
2969
|
+
"description": "Opacity level (0-1).",
|
|
2775
2970
|
"type": "number"
|
|
2776
2971
|
},
|
|
2972
|
+
"blendMode": {
|
|
2973
|
+
"description": "How the group composites with the content beneath it. Omitted means pass-through: children blend with that content directly. Any other mode composites the children together first.",
|
|
2974
|
+
"type": "string",
|
|
2975
|
+
"enum": [
|
|
2976
|
+
"pass-through",
|
|
2977
|
+
"normal",
|
|
2978
|
+
"multiply",
|
|
2979
|
+
"screen",
|
|
2980
|
+
"overlay",
|
|
2981
|
+
"darken",
|
|
2982
|
+
"lighten",
|
|
2983
|
+
"color-dodge",
|
|
2984
|
+
"color-burn",
|
|
2985
|
+
"hard-light",
|
|
2986
|
+
"soft-light",
|
|
2987
|
+
"difference",
|
|
2988
|
+
"exclusion",
|
|
2989
|
+
"hue",
|
|
2990
|
+
"saturation",
|
|
2991
|
+
"color",
|
|
2992
|
+
"luminosity"
|
|
2993
|
+
]
|
|
2994
|
+
},
|
|
2777
2995
|
"visible": {
|
|
2778
2996
|
"default": true,
|
|
2997
|
+
"description": "Whether the element is visible.",
|
|
2779
2998
|
"type": "boolean"
|
|
2780
2999
|
},
|
|
2781
3000
|
"selectable": {
|
|
2782
3001
|
"default": true,
|
|
3002
|
+
"description": "Whether the element can be selected.",
|
|
2783
3003
|
"type": "boolean"
|
|
2784
3004
|
},
|
|
2785
3005
|
"removable": {
|
|
2786
3006
|
"default": true,
|
|
3007
|
+
"description": "Whether the element can be removed.",
|
|
2787
3008
|
"type": "boolean"
|
|
2788
3009
|
},
|
|
2789
3010
|
"alwaysOnTop": {
|
|
2790
3011
|
"default": false,
|
|
3012
|
+
"description": "Whether the element stays on top of others.",
|
|
2791
3013
|
"type": "boolean"
|
|
2792
3014
|
},
|
|
2793
3015
|
"showInExport": {
|
|
2794
3016
|
"default": true,
|
|
3017
|
+
"description": "Whether the element appears in exports.",
|
|
2795
3018
|
"type": "boolean"
|
|
2796
3019
|
},
|
|
2797
3020
|
"animations": {
|
|
2798
3021
|
"default": [],
|
|
3022
|
+
"description": "Animation configurations.",
|
|
2799
3023
|
"type": "array",
|
|
2800
3024
|
"items": {
|
|
2801
3025
|
"type": "object",
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export type { PolotnoError, PolotnoErrorCode } from './errors.js';
|
|
2
|
+
export { URL_FIELDS, forEveryUrlField } from './asset-urls.js';
|
|
2
3
|
export { normalizeDesign, parseDesign } from './normalize.js';
|
|
3
4
|
export type { ParseOptions } from './normalize.js';
|
|
4
5
|
export { migrateDesign } from './migrate.js';
|
|
5
6
|
export type { MigrateOptions } from './migrate.js';
|
|
6
7
|
export { resolveBleed, ZERO_BLEED } from './bleed.js';
|
|
7
8
|
export type { ResolvedBleed } from './bleed.js';
|
|
8
|
-
export { TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
9
|
+
export { BLEND_MODES, GROUP_BLEND_MODES, TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
9
10
|
export { validateDesign, assertValidDesign, designSchemaLenient, designSchemaCanonical, CURRENT_SCHEMA_VERSION, } from './schema.js';
|
|
10
11
|
export type { DesignInput, ValidationError, ValidationResult, ValidateOptions, } from './schema.js';
|
|
11
12
|
export type * from './types.js';
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Single source: the zod schema (`./schema`) provides validation, defaults, and
|
|
3
3
|
// the generated JSON Schema; `./types` are the hand-written public TypeScript
|
|
4
4
|
// types. zod is a regular dependency (normalize parses with it).
|
|
5
|
+
export { URL_FIELDS, forEveryUrlField } from './asset-urls.js';
|
|
5
6
|
export { normalizeDesign, parseDesign } from './normalize.js';
|
|
6
7
|
export { migrateDesign } from './migrate.js';
|
|
7
8
|
export { resolveBleed, ZERO_BLEED } from './bleed.js';
|
|
8
9
|
// Also available zod-free via the `@polotno/schema/defaults` subpath.
|
|
9
|
-
export { TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
10
|
+
export { BLEND_MODES, GROUP_BLEND_MODES, TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
10
11
|
export { validateDesign, assertValidDesign, designSchemaLenient, designSchemaCanonical, CURRENT_SCHEMA_VERSION, } from './schema.js';
|
package/lib/schema.d.ts
CHANGED
|
@@ -152,6 +152,24 @@ export declare const leafSchemas: {
|
|
|
152
152
|
y: z.ZodDefault<z.ZodNumber>;
|
|
153
153
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
154
154
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
155
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
156
|
+
normal: "normal";
|
|
157
|
+
multiply: "multiply";
|
|
158
|
+
screen: "screen";
|
|
159
|
+
overlay: "overlay";
|
|
160
|
+
darken: "darken";
|
|
161
|
+
lighten: "lighten";
|
|
162
|
+
"color-dodge": "color-dodge";
|
|
163
|
+
"color-burn": "color-burn";
|
|
164
|
+
"hard-light": "hard-light";
|
|
165
|
+
"soft-light": "soft-light";
|
|
166
|
+
difference: "difference";
|
|
167
|
+
exclusion: "exclusion";
|
|
168
|
+
hue: "hue";
|
|
169
|
+
saturation: "saturation";
|
|
170
|
+
color: "color";
|
|
171
|
+
luminosity: "luminosity";
|
|
172
|
+
}>>;
|
|
155
173
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
156
174
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
157
175
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -213,6 +231,24 @@ export declare const leafSchemas: {
|
|
|
213
231
|
height: z.ZodDefault<z.ZodNumber>;
|
|
214
232
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
215
233
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
234
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
235
|
+
normal: "normal";
|
|
236
|
+
multiply: "multiply";
|
|
237
|
+
screen: "screen";
|
|
238
|
+
overlay: "overlay";
|
|
239
|
+
darken: "darken";
|
|
240
|
+
lighten: "lighten";
|
|
241
|
+
"color-dodge": "color-dodge";
|
|
242
|
+
"color-burn": "color-burn";
|
|
243
|
+
"hard-light": "hard-light";
|
|
244
|
+
"soft-light": "soft-light";
|
|
245
|
+
difference: "difference";
|
|
246
|
+
exclusion: "exclusion";
|
|
247
|
+
hue: "hue";
|
|
248
|
+
saturation: "saturation";
|
|
249
|
+
color: "color";
|
|
250
|
+
luminosity: "luminosity";
|
|
251
|
+
}>>;
|
|
216
252
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
217
253
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
218
254
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -262,8 +298,6 @@ export declare const leafSchemas: {
|
|
|
262
298
|
stretchEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
263
299
|
flipX: z.ZodDefault<z.ZodBoolean>;
|
|
264
300
|
flipY: z.ZodDefault<z.ZodBoolean>;
|
|
265
|
-
width: z.ZodDefault<z.ZodNumber>;
|
|
266
|
-
height: z.ZodDefault<z.ZodNumber>;
|
|
267
301
|
borderColor: z.ZodDefault<z.ZodString>;
|
|
268
302
|
borderSize: z.ZodDefault<z.ZodNumber>;
|
|
269
303
|
cornerRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -273,8 +307,28 @@ export declare const leafSchemas: {
|
|
|
273
307
|
custom: z.ZodOptional<z.ZodUnknown>;
|
|
274
308
|
x: z.ZodDefault<z.ZodNumber>;
|
|
275
309
|
y: z.ZodDefault<z.ZodNumber>;
|
|
310
|
+
width: z.ZodDefault<z.ZodNumber>;
|
|
311
|
+
height: z.ZodDefault<z.ZodNumber>;
|
|
276
312
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
277
313
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
314
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
315
|
+
normal: "normal";
|
|
316
|
+
multiply: "multiply";
|
|
317
|
+
screen: "screen";
|
|
318
|
+
overlay: "overlay";
|
|
319
|
+
darken: "darken";
|
|
320
|
+
lighten: "lighten";
|
|
321
|
+
"color-dodge": "color-dodge";
|
|
322
|
+
"color-burn": "color-burn";
|
|
323
|
+
"hard-light": "hard-light";
|
|
324
|
+
"soft-light": "soft-light";
|
|
325
|
+
difference: "difference";
|
|
326
|
+
exclusion: "exclusion";
|
|
327
|
+
hue: "hue";
|
|
328
|
+
saturation: "saturation";
|
|
329
|
+
color: "color";
|
|
330
|
+
luminosity: "luminosity";
|
|
331
|
+
}>>;
|
|
278
332
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
279
333
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
280
334
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -327,6 +381,24 @@ export declare const leafSchemas: {
|
|
|
327
381
|
y: z.ZodDefault<z.ZodNumber>;
|
|
328
382
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
329
383
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
384
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
385
|
+
normal: "normal";
|
|
386
|
+
multiply: "multiply";
|
|
387
|
+
screen: "screen";
|
|
388
|
+
overlay: "overlay";
|
|
389
|
+
darken: "darken";
|
|
390
|
+
lighten: "lighten";
|
|
391
|
+
"color-dodge": "color-dodge";
|
|
392
|
+
"color-burn": "color-burn";
|
|
393
|
+
"hard-light": "hard-light";
|
|
394
|
+
"soft-light": "soft-light";
|
|
395
|
+
difference: "difference";
|
|
396
|
+
exclusion: "exclusion";
|
|
397
|
+
hue: "hue";
|
|
398
|
+
saturation: "saturation";
|
|
399
|
+
color: "color";
|
|
400
|
+
luminosity: "luminosity";
|
|
401
|
+
}>>;
|
|
330
402
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
331
403
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
332
404
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -381,6 +453,24 @@ export declare const leafSchemas: {
|
|
|
381
453
|
height: z.ZodDefault<z.ZodNumber>;
|
|
382
454
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
383
455
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
456
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
457
|
+
normal: "normal";
|
|
458
|
+
multiply: "multiply";
|
|
459
|
+
screen: "screen";
|
|
460
|
+
overlay: "overlay";
|
|
461
|
+
darken: "darken";
|
|
462
|
+
lighten: "lighten";
|
|
463
|
+
"color-dodge": "color-dodge";
|
|
464
|
+
"color-burn": "color-burn";
|
|
465
|
+
"hard-light": "hard-light";
|
|
466
|
+
"soft-light": "soft-light";
|
|
467
|
+
difference: "difference";
|
|
468
|
+
exclusion: "exclusion";
|
|
469
|
+
hue: "hue";
|
|
470
|
+
saturation: "saturation";
|
|
471
|
+
color: "color";
|
|
472
|
+
luminosity: "luminosity";
|
|
473
|
+
}>>;
|
|
384
474
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
385
475
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
386
476
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -443,6 +533,24 @@ export declare const leafSchemas: {
|
|
|
443
533
|
height: z.ZodDefault<z.ZodNumber>;
|
|
444
534
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
445
535
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
536
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
537
|
+
normal: "normal";
|
|
538
|
+
multiply: "multiply";
|
|
539
|
+
screen: "screen";
|
|
540
|
+
overlay: "overlay";
|
|
541
|
+
darken: "darken";
|
|
542
|
+
lighten: "lighten";
|
|
543
|
+
"color-dodge": "color-dodge";
|
|
544
|
+
"color-burn": "color-burn";
|
|
545
|
+
"hard-light": "hard-light";
|
|
546
|
+
"soft-light": "soft-light";
|
|
547
|
+
difference: "difference";
|
|
548
|
+
exclusion: "exclusion";
|
|
549
|
+
hue: "hue";
|
|
550
|
+
saturation: "saturation";
|
|
551
|
+
color: "color";
|
|
552
|
+
luminosity: "luminosity";
|
|
553
|
+
}>>;
|
|
446
554
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
447
555
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
448
556
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -509,6 +617,24 @@ export declare const leafSchemas: {
|
|
|
509
617
|
height: z.ZodDefault<z.ZodNumber>;
|
|
510
618
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
511
619
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
620
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
621
|
+
normal: "normal";
|
|
622
|
+
multiply: "multiply";
|
|
623
|
+
screen: "screen";
|
|
624
|
+
overlay: "overlay";
|
|
625
|
+
darken: "darken";
|
|
626
|
+
lighten: "lighten";
|
|
627
|
+
"color-dodge": "color-dodge";
|
|
628
|
+
"color-burn": "color-burn";
|
|
629
|
+
"hard-light": "hard-light";
|
|
630
|
+
"soft-light": "soft-light";
|
|
631
|
+
difference: "difference";
|
|
632
|
+
exclusion: "exclusion";
|
|
633
|
+
hue: "hue";
|
|
634
|
+
saturation: "saturation";
|
|
635
|
+
color: "color";
|
|
636
|
+
luminosity: "luminosity";
|
|
637
|
+
}>>;
|
|
512
638
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
513
639
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
514
640
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -652,6 +778,24 @@ export declare const leafSchemas: {
|
|
|
652
778
|
y: z.ZodDefault<z.ZodNumber>;
|
|
653
779
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
654
780
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
781
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
782
|
+
normal: "normal";
|
|
783
|
+
multiply: "multiply";
|
|
784
|
+
screen: "screen";
|
|
785
|
+
overlay: "overlay";
|
|
786
|
+
darken: "darken";
|
|
787
|
+
lighten: "lighten";
|
|
788
|
+
"color-dodge": "color-dodge";
|
|
789
|
+
"color-burn": "color-burn";
|
|
790
|
+
"hard-light": "hard-light";
|
|
791
|
+
"soft-light": "soft-light";
|
|
792
|
+
difference: "difference";
|
|
793
|
+
exclusion: "exclusion";
|
|
794
|
+
hue: "hue";
|
|
795
|
+
saturation: "saturation";
|
|
796
|
+
color: "color";
|
|
797
|
+
luminosity: "luminosity";
|
|
798
|
+
}>>;
|
|
655
799
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
656
800
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
657
801
|
duration: z.ZodDefault<z.ZodNumber>;
|
package/lib/schema.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
// MIN_FONT_SIZE in ./defaults for what they each decided.
|
|
26
26
|
import { z } from 'zod';
|
|
27
27
|
import { polotnoError } from './errors.js';
|
|
28
|
-
import { MIN_FONT_SIZE, clampFontSize, TEXT_DEFAULTS } from './defaults.js';
|
|
28
|
+
import { BLEND_MODES, GROUP_BLEND_MODES, MIN_FONT_SIZE, clampFontSize, TEXT_DEFAULTS, } from './defaults.js';
|
|
29
29
|
export const CURRENT_SCHEMA_VERSION = 4;
|
|
30
30
|
// Every element type the design format knows. Kept in sync with the
|
|
31
31
|
// element discriminatedUnion in build() below.
|
|
@@ -70,6 +70,10 @@ function build(o) {
|
|
|
70
70
|
.describe('Filter intensity (-1 to 1).'),
|
|
71
71
|
}))
|
|
72
72
|
.describe('Applied image filters keyed by filter name.');
|
|
73
|
+
const blendMode = z
|
|
74
|
+
.enum(BLEND_MODES)
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('How the element composites with the content beneath it. Omitted means normal.');
|
|
73
77
|
// Fields shared by every Shape-derived element. Defaults inline.
|
|
74
78
|
const shapeBase = {
|
|
75
79
|
id: z.string().describe('Unique identifier for the element.'),
|
|
@@ -85,6 +89,7 @@ function build(o) {
|
|
|
85
89
|
height: z.number().default(100).describe('Height in pixels.'),
|
|
86
90
|
rotation: z.number().default(0).describe('Rotation angle in degrees.'),
|
|
87
91
|
opacity: z.number().default(1).describe('Opacity level (0-1).'),
|
|
92
|
+
blendMode,
|
|
88
93
|
animations: z
|
|
89
94
|
.array(animation)
|
|
90
95
|
.default([])
|
|
@@ -198,7 +203,7 @@ function build(o) {
|
|
|
198
203
|
};
|
|
199
204
|
const textShape = {
|
|
200
205
|
...shapeBase,
|
|
201
|
-
type: z.literal('text'),
|
|
206
|
+
type: z.literal('text').describe('Element type identifier.'),
|
|
202
207
|
text: z.string().default('').describe('Visible text shown on canvas.'),
|
|
203
208
|
placeholder: z
|
|
204
209
|
.string()
|
|
@@ -301,31 +306,36 @@ function build(o) {
|
|
|
301
306
|
.optional()
|
|
302
307
|
.describe('Internal compatibility flag stamped by the v2→v3 migration.'),
|
|
303
308
|
};
|
|
304
|
-
const imageShape = {
|
|
309
|
+
const imageShape = {
|
|
310
|
+
...shapeBase,
|
|
311
|
+
...imageProps,
|
|
312
|
+
type: z.literal('image').describe('Element type identifier.'),
|
|
313
|
+
};
|
|
305
314
|
const svgShape = {
|
|
306
315
|
...shapeBase,
|
|
307
|
-
type: z.literal('svg'),
|
|
316
|
+
type: z.literal('svg').describe('Element type identifier.'),
|
|
308
317
|
src: z.string().default('').describe('URL or data URI of the SVG.'),
|
|
309
318
|
maskSrc: z
|
|
310
319
|
.string()
|
|
311
320
|
.default('')
|
|
312
321
|
.describe('URL or data URI for an SVG mask.'),
|
|
313
|
-
cropX:
|
|
314
|
-
cropY:
|
|
315
|
-
cropWidth:
|
|
316
|
-
cropHeight:
|
|
322
|
+
cropX: imageProps.cropX,
|
|
323
|
+
cropY: imageProps.cropY,
|
|
324
|
+
cropWidth: imageProps.cropWidth,
|
|
325
|
+
cropHeight: imageProps.cropHeight,
|
|
317
326
|
keepRatio: z
|
|
318
327
|
.boolean()
|
|
319
328
|
.default(true)
|
|
320
329
|
.describe('Whether to maintain aspect ratio when resizing.'),
|
|
321
|
-
stretchEnabled: z
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
330
|
+
stretchEnabled: z
|
|
331
|
+
.boolean()
|
|
332
|
+
.default(true)
|
|
333
|
+
.describe('Whether stretch mode is enabled.'),
|
|
334
|
+
flipX: imageProps.flipX,
|
|
335
|
+
flipY: imageProps.flipY,
|
|
336
|
+
borderColor: imageProps.borderColor,
|
|
337
|
+
borderSize: imageProps.borderSize,
|
|
338
|
+
cornerRadius: imageProps.cornerRadius,
|
|
329
339
|
colorsReplace: z
|
|
330
340
|
.record(z.string(), z.string())
|
|
331
341
|
.default({})
|
|
@@ -333,9 +343,9 @@ function build(o) {
|
|
|
333
343
|
};
|
|
334
344
|
const lineShape = {
|
|
335
345
|
...shapeBase,
|
|
336
|
-
type: z.literal('line'),
|
|
337
|
-
width: z.number().default(400),
|
|
338
|
-
height: z.number().default(10),
|
|
346
|
+
type: z.literal('line').describe('Element type identifier.'),
|
|
347
|
+
width: z.number().default(400).describe('Width in pixels.'),
|
|
348
|
+
height: z.number().default(10).describe('Height in pixels.'),
|
|
339
349
|
color: z.string().default('black').describe('Line color.'),
|
|
340
350
|
dash: z.array(z.number()).default([]).describe('Dash pattern array.'),
|
|
341
351
|
startHead: z
|
|
@@ -349,28 +359,34 @@ function build(o) {
|
|
|
349
359
|
};
|
|
350
360
|
const figureShape = {
|
|
351
361
|
...shapeBase,
|
|
352
|
-
type: z.literal('figure'),
|
|
362
|
+
type: z.literal('figure').describe('Element type identifier.'),
|
|
353
363
|
subType: z
|
|
354
364
|
.string()
|
|
355
365
|
.default('rect')
|
|
356
366
|
.describe('Figure subtype: rect, ellipse, triangle, etc.'),
|
|
357
367
|
fill: z.string().default('rgb(0, 161, 255)').describe('Fill color.'),
|
|
358
368
|
dash: z.array(z.number()).default([]).describe('Dash pattern array.'),
|
|
359
|
-
strokeWidth: z.number().default(0),
|
|
360
|
-
stroke: z
|
|
361
|
-
|
|
369
|
+
strokeWidth: z.number().default(0).describe('Stroke width in pixels.'),
|
|
370
|
+
stroke: z
|
|
371
|
+
.string()
|
|
372
|
+
.default('rgba(98, 197, 255, 1)')
|
|
373
|
+
.describe('Stroke color.'),
|
|
374
|
+
cornerRadius: imageProps.cornerRadius,
|
|
362
375
|
};
|
|
363
376
|
const gifShape = {
|
|
364
377
|
...shapeBase,
|
|
365
378
|
...imageProps,
|
|
366
|
-
type: z.literal('gif'),
|
|
379
|
+
type: z.literal('gif').describe('Element type identifier.'),
|
|
367
380
|
duration: z.number().default(0).describe('GIF duration in milliseconds.'),
|
|
368
|
-
keepRatio: z
|
|
381
|
+
keepRatio: z
|
|
382
|
+
.boolean()
|
|
383
|
+
.default(true)
|
|
384
|
+
.describe('Whether to maintain aspect ratio when resizing.'),
|
|
369
385
|
};
|
|
370
386
|
const videoShape = {
|
|
371
387
|
...shapeBase,
|
|
372
388
|
...imageProps,
|
|
373
|
-
type: z.literal('video'),
|
|
389
|
+
type: z.literal('video').describe('Element type identifier.'),
|
|
374
390
|
duration: z.number().default(0).describe('Video duration in milliseconds.'),
|
|
375
391
|
startTime: z.number().default(0).describe('Start offset (0-1).'),
|
|
376
392
|
endTime: z.number().default(1).describe('End offset (0-1).'),
|
|
@@ -581,17 +597,21 @@ function build(o) {
|
|
|
581
597
|
.describe('Default cell padding in pixels.'),
|
|
582
598
|
};
|
|
583
599
|
const groupShape = (element) => ({
|
|
584
|
-
id:
|
|
585
|
-
type: z.literal('group'),
|
|
586
|
-
name:
|
|
587
|
-
custom:
|
|
588
|
-
opacity:
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
600
|
+
id: shapeBase.id,
|
|
601
|
+
type: z.literal('group').describe('Element type identifier.'),
|
|
602
|
+
name: shapeBase.name,
|
|
603
|
+
custom: shapeBase.custom,
|
|
604
|
+
opacity: shapeBase.opacity,
|
|
605
|
+
blendMode: z
|
|
606
|
+
.enum(GROUP_BLEND_MODES)
|
|
607
|
+
.optional()
|
|
608
|
+
.describe('How the group composites with the content beneath it. Omitted means pass-through: children blend with that content directly. Any other mode composites the children together first.'),
|
|
609
|
+
visible: shapeBase.visible,
|
|
610
|
+
selectable: shapeBase.selectable,
|
|
611
|
+
removable: shapeBase.removable,
|
|
612
|
+
alwaysOnTop: shapeBase.alwaysOnTop,
|
|
613
|
+
showInExport: shapeBase.showInExport,
|
|
614
|
+
animations: shapeBase.animations,
|
|
595
615
|
children: z
|
|
596
616
|
.array(element)
|
|
597
617
|
.default([])
|
package/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { BLEND_MODES, GROUP_BLEND_MODES } from './defaults.js';
|
|
2
|
+
export type BlendMode = (typeof BLEND_MODES)[number];
|
|
3
|
+
export type GroupBlendMode = (typeof GROUP_BLEND_MODES)[number];
|
|
1
4
|
export interface Design {
|
|
2
5
|
/** Schema version for compatibility / migration. */
|
|
3
6
|
schemaVersion: number;
|
|
@@ -120,6 +123,8 @@ export interface ShapeAttributes {
|
|
|
120
123
|
rotation: number;
|
|
121
124
|
/** Opacity (0-1). */
|
|
122
125
|
opacity: number;
|
|
126
|
+
/** How the element composites with the content beneath it. Omitted means normal. */
|
|
127
|
+
blendMode?: BlendMode;
|
|
123
128
|
/** Animation configurations. */
|
|
124
129
|
animations: Animation[];
|
|
125
130
|
blurEnabled: boolean;
|
|
@@ -155,6 +160,8 @@ export interface GroupElement {
|
|
|
155
160
|
name: string;
|
|
156
161
|
custom?: unknown;
|
|
157
162
|
opacity: number;
|
|
163
|
+
/** How the group composites with the content beneath it. Omitted means pass-through; any other mode composites the children together first. */
|
|
164
|
+
blendMode?: GroupBlendMode;
|
|
158
165
|
visible: boolean;
|
|
159
166
|
selectable: boolean;
|
|
160
167
|
removable: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polotno/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Canonical Polotno design format: types, normalize, validate, JSON Schema. Authored in zod, DOM-free.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"type": "module",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"import": "./lib/defaults.js",
|
|
17
17
|
"types": "./lib/defaults.d.ts"
|
|
18
18
|
},
|
|
19
|
+
"./asset-urls": {
|
|
20
|
+
"import": "./lib/asset-urls.js",
|
|
21
|
+
"types": "./lib/asset-urls.d.ts"
|
|
22
|
+
},
|
|
19
23
|
"./json": {
|
|
20
24
|
"import": "./lib/design.schema.json"
|
|
21
25
|
},
|
|
@@ -42,11 +46,11 @@
|
|
|
42
46
|
"LICENSE.md"
|
|
43
47
|
],
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"zod": "^4.
|
|
49
|
+
"zod": "^4.6.5"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
52
|
"typescript": "~6.0.3",
|
|
49
|
-
"vitest": "^
|
|
53
|
+
"vitest": "^5.0.1"
|
|
50
54
|
},
|
|
51
55
|
"scripts": {
|
|
52
56
|
"build": "rm -rf lib && tsc && node scripts/generate-schema.mjs && node ../../scripts/check-pack.mjs",
|