abstract-image 13.3.6 → 14.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.
- package/CHANGELOG.md +4 -0
- package/lib/dynamic-image/dynamic-image.d.ts +3 -3
- package/lib/dynamic-image/dynamic-image.d.ts.map +1 -1
- package/lib/dynamic-image/dynamic-image.js.map +1 -1
- package/lib/dynamic-image/schema.d.ts +2 -234
- package/lib/dynamic-image/schema.d.ts.map +1 -1
- package/lib/dynamic-image/schema.js +198 -175
- package/lib/dynamic-image/schema.js.map +1 -1
- package/lib/dynamic-image/utils.d.ts +5 -2
- package/lib/dynamic-image/utils.d.ts.map +1 -1
- package/lib/dynamic-image/utils.js +10 -45
- package/lib/dynamic-image/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/dynamic-image/dynamic-image.ts +3 -3
- package/src/dynamic-image/schema.ts +200 -177
- package/src/dynamic-image/utils.ts +13 -55
|
@@ -3,83 +3,91 @@ export const baseSchema = {
|
|
|
3
3
|
AbstractImage: {
|
|
4
4
|
description: "Root container — defines the image canvas and its coordinate system.",
|
|
5
5
|
props: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
width: {
|
|
9
|
+
type: "number",
|
|
10
|
+
description: "Total width of the image canvas (in px).",
|
|
11
|
+
},
|
|
12
|
+
height: {
|
|
13
|
+
type: "number",
|
|
14
|
+
description: "Total height of the image canvas (in px).",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ["width", "height"],
|
|
16
18
|
},
|
|
17
19
|
allowedChildren: ["Image", "Text", "Rectangle", "Ellipse", "Line", "Polyline", "Polygon", "Group"],
|
|
18
20
|
},
|
|
19
21
|
Group: {
|
|
20
22
|
description: "Groups elements together.",
|
|
21
|
-
props: {},
|
|
23
|
+
props: { type: "object", properties: {} },
|
|
22
24
|
allowedChildren: ["Image", "Text", "Rectangle", "Ellipse", "Line", "Polyline", "Polygon", "Group"],
|
|
23
25
|
},
|
|
24
26
|
Image: {
|
|
25
27
|
description: "Displays a raster image.",
|
|
26
28
|
props: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
type: "object",
|
|
30
|
+
properties: {
|
|
31
|
+
src: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "Source of the image (URL or asset ID).",
|
|
34
|
+
},
|
|
35
|
+
x: {
|
|
36
|
+
type: "number",
|
|
37
|
+
description: "X position in pixels.",
|
|
38
|
+
},
|
|
39
|
+
y: {
|
|
40
|
+
type: "number",
|
|
41
|
+
description: "Y position in pixels.",
|
|
42
|
+
},
|
|
43
|
+
width: {
|
|
44
|
+
type: "number",
|
|
45
|
+
description: "Display width in pixels.",
|
|
46
|
+
},
|
|
47
|
+
height: {
|
|
48
|
+
type: "number",
|
|
49
|
+
description: "Display height in pixels.",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ["src"],
|
|
48
53
|
},
|
|
49
54
|
allowedChildren: [],
|
|
50
55
|
},
|
|
51
56
|
Ellipse: {
|
|
52
57
|
description: "Draws an ellipse using x, y, width, and height.",
|
|
53
58
|
props: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
x: {
|
|
62
|
+
type: "number",
|
|
63
|
+
description: "X coordinate of the top-left of the ellipse box.",
|
|
64
|
+
},
|
|
65
|
+
y: {
|
|
66
|
+
type: "number",
|
|
67
|
+
description: "Y coordinate of the top-left of the ellipse box.",
|
|
68
|
+
},
|
|
69
|
+
width: {
|
|
70
|
+
type: "number",
|
|
71
|
+
description: "Box width.",
|
|
72
|
+
},
|
|
73
|
+
height: {
|
|
74
|
+
type: "number",
|
|
75
|
+
description: "Box height.",
|
|
76
|
+
},
|
|
77
|
+
stroke: {
|
|
78
|
+
type: "string",
|
|
79
|
+
format: "color",
|
|
80
|
+
description: "Stroke color (CSS color string).",
|
|
81
|
+
},
|
|
82
|
+
strokeWidth: {
|
|
83
|
+
type: "number",
|
|
84
|
+
description: "Stroke width in pixels.",
|
|
85
|
+
},
|
|
86
|
+
fill: {
|
|
87
|
+
type: "string",
|
|
88
|
+
format: "color",
|
|
89
|
+
description: "Fill color (inside the ellipse).",
|
|
90
|
+
},
|
|
83
91
|
},
|
|
84
92
|
},
|
|
85
93
|
allowedChildren: [],
|
|
@@ -87,30 +95,33 @@ export const baseSchema = {
|
|
|
87
95
|
Line: {
|
|
88
96
|
description: "Draws a straight line between two points.",
|
|
89
97
|
props: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
98
|
+
type: "object",
|
|
99
|
+
properties: {
|
|
100
|
+
x1: {
|
|
101
|
+
type: "number",
|
|
102
|
+
description: "X coordinate of the start point.",
|
|
103
|
+
},
|
|
104
|
+
y1: {
|
|
105
|
+
type: "number",
|
|
106
|
+
description: "Y coordinate of the start point.",
|
|
107
|
+
},
|
|
108
|
+
x2: {
|
|
109
|
+
type: "number",
|
|
110
|
+
description: "X coordinate of the end point.",
|
|
111
|
+
},
|
|
112
|
+
y2: {
|
|
113
|
+
type: "number",
|
|
114
|
+
description: "Y coordinate of the end point.",
|
|
115
|
+
},
|
|
116
|
+
stroke: {
|
|
117
|
+
type: "string",
|
|
118
|
+
format: "color",
|
|
119
|
+
description: "Stroke color of the line.",
|
|
120
|
+
},
|
|
121
|
+
strokeWidth: {
|
|
122
|
+
type: "number",
|
|
123
|
+
description: "Width of the stroke in px.",
|
|
124
|
+
},
|
|
114
125
|
},
|
|
115
126
|
},
|
|
116
127
|
allowedChildren: [],
|
|
@@ -118,84 +129,93 @@ export const baseSchema = {
|
|
|
118
129
|
Polyline: {
|
|
119
130
|
description: "A connected set of line segments (open shape).",
|
|
120
131
|
props: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
type: "object",
|
|
133
|
+
properties: {
|
|
134
|
+
points: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "List of points: 'x0,y0 x1,y1 x2,y2'.",
|
|
137
|
+
},
|
|
138
|
+
stroke: {
|
|
139
|
+
type: "string",
|
|
140
|
+
format: "color",
|
|
141
|
+
description: "Stroke color.",
|
|
142
|
+
},
|
|
143
|
+
strokeWidth: {
|
|
144
|
+
type: "number",
|
|
145
|
+
description: "Stroke width in px.",
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
required: ["points"],
|
|
135
149
|
},
|
|
136
150
|
allowedChildren: [],
|
|
137
151
|
},
|
|
138
152
|
Polygon: {
|
|
139
153
|
description: "A closed polygon shape.",
|
|
140
154
|
props: {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
type: "object",
|
|
156
|
+
properties: {
|
|
157
|
+
points: {
|
|
158
|
+
type: "string",
|
|
159
|
+
description: "List of vertex points: 'x0,y0 x1,y1 ...'.",
|
|
160
|
+
},
|
|
161
|
+
stroke: {
|
|
162
|
+
type: "string",
|
|
163
|
+
format: "color",
|
|
164
|
+
description: "Stroke color.",
|
|
165
|
+
},
|
|
166
|
+
strokeWidth: {
|
|
167
|
+
type: "number",
|
|
168
|
+
description: "Stroke width in px.",
|
|
169
|
+
},
|
|
170
|
+
fill: {
|
|
171
|
+
type: "string",
|
|
172
|
+
format: "color",
|
|
173
|
+
description: "Fill color of the polygon.",
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
required: ["points"],
|
|
160
177
|
},
|
|
161
178
|
allowedChildren: [],
|
|
162
179
|
},
|
|
163
180
|
Rectangle: {
|
|
164
181
|
description: "Draws a rectangle, optionally with rounded corners.",
|
|
165
182
|
props: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
183
|
+
type: "object",
|
|
184
|
+
properties: {
|
|
185
|
+
x: {
|
|
186
|
+
type: "number",
|
|
187
|
+
description: "X position of the rectangle (top-left).",
|
|
188
|
+
},
|
|
189
|
+
y: {
|
|
190
|
+
type: "number",
|
|
191
|
+
description: "Y position of the rectangle (top-left).",
|
|
192
|
+
},
|
|
193
|
+
width: {
|
|
194
|
+
type: "number",
|
|
195
|
+
description: "Rectangle width in px.",
|
|
196
|
+
},
|
|
197
|
+
height: {
|
|
198
|
+
type: "number",
|
|
199
|
+
description: "Rectangle height in px.",
|
|
200
|
+
},
|
|
201
|
+
stroke: {
|
|
202
|
+
type: "string",
|
|
203
|
+
format: "color",
|
|
204
|
+
description: "Stroke color.",
|
|
205
|
+
},
|
|
206
|
+
strokeWidth: {
|
|
207
|
+
type: "number",
|
|
208
|
+
description: "Stroke width in px.",
|
|
209
|
+
},
|
|
210
|
+
fill: {
|
|
211
|
+
type: "string",
|
|
212
|
+
format: "color",
|
|
213
|
+
description: "Fill color of the rectangle.",
|
|
214
|
+
},
|
|
215
|
+
radius: {
|
|
216
|
+
type: "number",
|
|
217
|
+
description: "Corner radius in px (uniform).",
|
|
218
|
+
},
|
|
199
219
|
},
|
|
200
220
|
},
|
|
201
221
|
allowedChildren: [],
|
|
@@ -203,30 +223,33 @@ export const baseSchema = {
|
|
|
203
223
|
Text: {
|
|
204
224
|
description: "Renders a text element.",
|
|
205
225
|
props: {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
type: "object",
|
|
227
|
+
properties: {
|
|
228
|
+
x: {
|
|
229
|
+
type: "number",
|
|
230
|
+
description: "X position of the text anchor.",
|
|
231
|
+
},
|
|
232
|
+
y: {
|
|
233
|
+
type: "number",
|
|
234
|
+
description: "Y position of the text baseline.",
|
|
235
|
+
},
|
|
236
|
+
fontFamily: {
|
|
237
|
+
type: "string",
|
|
238
|
+
description: "Font family, e.g. 'Inter, system-ui'.",
|
|
239
|
+
},
|
|
240
|
+
fontSize: {
|
|
241
|
+
type: "number",
|
|
242
|
+
description: "Font size in pixels.",
|
|
243
|
+
},
|
|
244
|
+
fontWeight: {
|
|
245
|
+
type: "string",
|
|
246
|
+
description: "Font weight, e.g. 'bold', '700'.",
|
|
247
|
+
},
|
|
248
|
+
fill: {
|
|
249
|
+
type: "string",
|
|
250
|
+
format: "color",
|
|
251
|
+
description: "Fill color (text color).",
|
|
252
|
+
},
|
|
230
253
|
},
|
|
231
254
|
},
|
|
232
255
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/dynamic-image/schema.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/dynamic-image/schema.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAW;IAChC,QAAQ,EAAE;QACR,aAAa,EAAE;YACb,WAAW,EAAE,sEAAsE;YACnF,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,0CAA0C;qBACxD;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,2CAA2C;qBACzD;iBACF;gBAC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EAAE,QAAQ;wBACd,WAAW,EAAE,yBAAyB;qBACvC;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,MAAM,EAAE,OAAO;wBACf,WAAW,EAAE,eAAe;qBAC7B;oBACD,WAAW,EAAE;wBACX,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,qBAAqB;qBACnC;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,MAAM,EAAE,OAAO;wBACf,WAAW,EAAE,8BAA8B;qBAC5C;oBACD,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,gCAAgC;qBAC9C;iBACF;aACF;YACD,eAAe,EAAE,EAAE;SACpB;QAED,IAAI,EAAE;YACJ,WAAW,EAAE,yBAAyB;YACtC,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,CAAC,EAAE;wBACD,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,gCAAgC;qBAC9C;oBACD,CAAC,EAAE;wBACD,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,kCAAkC;qBAChD;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,uCAAuC;qBACrD;oBACD,QAAQ,EAAE;wBACR,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,sBAAsB;qBACpC;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,kCAAkC;qBAChD;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,MAAM,EAAE,OAAO;wBACf,WAAW,EAAE,0BAA0B;qBACxC;iBACF;aACF;SACF;KACF;CACF,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Schema } from "jsxpression";
|
|
2
|
+
type DataSchema = NonNullable<Schema["data"]>;
|
|
3
|
+
/** The JSON schema of data like the given, each value's schema inferred from it, an array's from its first item */
|
|
4
|
+
export declare function generateDataSchema(data: Record<string, unknown>): DataSchema;
|
|
5
|
+
export {};
|
|
3
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/dynamic-image/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/dynamic-image/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,KAAK,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAE9C,mHAAmH;AACnH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAE5E"}
|
|
@@ -1,53 +1,18 @@
|
|
|
1
|
+
/** The JSON schema of data like the given, each value's schema inferred from it, an array's from its first item */
|
|
1
2
|
export function generateDataSchema(data) {
|
|
2
|
-
|
|
3
|
-
for (const [key, value] of Object.entries(data)) {
|
|
4
|
-
schema[key] = inferPropertySchema(value);
|
|
5
|
-
}
|
|
6
|
-
return schema;
|
|
3
|
+
return { type: "object", properties: Object.fromEntries(Object.entries(data).map(([key, value]) => [key, inferSchema(value)])) };
|
|
7
4
|
}
|
|
8
|
-
function
|
|
9
|
-
if (value ===
|
|
10
|
-
return {
|
|
11
|
-
type: "string",
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
if (typeof value === "string") {
|
|
15
|
-
return {
|
|
16
|
-
type: "string",
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
if (typeof value === "number") {
|
|
20
|
-
return {
|
|
21
|
-
type: "number",
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if (typeof value === "boolean") {
|
|
25
|
-
return {
|
|
26
|
-
type: "boolean",
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (typeof value === "function") {
|
|
30
|
-
return {
|
|
31
|
-
type: "function",
|
|
32
|
-
};
|
|
5
|
+
function inferSchema(value) {
|
|
6
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
7
|
+
return { type: typeof value };
|
|
33
8
|
}
|
|
34
9
|
if (Array.isArray(value)) {
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
type: "array",
|
|
38
|
-
shape: itemSchema,
|
|
39
|
-
};
|
|
10
|
+
return { type: "array", items: value.length > 0 ? inferSchema(value[0]) : {} };
|
|
40
11
|
}
|
|
41
|
-
if (typeof value === "object") {
|
|
42
|
-
|
|
43
|
-
for (const [k, v] of Object.entries(value)) {
|
|
44
|
-
shape[k] = inferPropertySchema(v);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
type: "object",
|
|
48
|
-
shape,
|
|
49
|
-
};
|
|
12
|
+
if (typeof value === "object" && value !== null) {
|
|
13
|
+
return { type: "object", properties: Object.fromEntries(Object.entries(value).map(([k, v]) => [k, inferSchema(v)])) };
|
|
50
14
|
}
|
|
51
|
-
|
|
15
|
+
// null, undefined and functions, which JSON schemas don't describe
|
|
16
|
+
return {};
|
|
52
17
|
}
|
|
53
18
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/dynamic-image/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/dynamic-image/utils.ts"],"names":[],"mappings":"AAIA,mHAAmH;AACnH,MAAM,UAAU,kBAAkB,CAAC,IAA6B;IAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnI,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACzF,OAAO,EAAE,IAAI,EAAE,OAAO,KAAwC,EAAE,CAAC;IACnE,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACjF,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxH,CAAC;IACD,mEAAmE;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abstract-image",
|
|
3
|
-
"version": "
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
|
+
"gitHead": "e390532e0c62215f15e6aec1796e4d5a2e30dff1",
|
|
5
5
|
"description": "Dynamically create images using code or JSX and render to any format",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-image",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"fast-xml-parser": "^4.5.0",
|
|
28
28
|
"handlebars": "4.7.8",
|
|
29
29
|
"handlebars-xml": "^0.6.1",
|
|
30
|
-
"jsxpression": "^0.
|
|
30
|
+
"jsxpression": "^0.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/base64-js": "^1.3.2",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalysisError, evaluate, compile, render, type FunctionSchema, type
|
|
1
|
+
import { AnalysisError, evaluate, compile, render, type FunctionSchema, type Schema } from "jsxpression";
|
|
2
2
|
import type { AbstractImage } from "../model/abstract-image.js";
|
|
3
3
|
import { createComponents } from "./components.js";
|
|
4
4
|
import { baseSchema } from "./schema.js";
|
|
@@ -21,7 +21,7 @@ export type DynamicImageError = {
|
|
|
21
21
|
export function dynamicImage(
|
|
22
22
|
source: string,
|
|
23
23
|
data: Record<string, unknown>,
|
|
24
|
-
dataSchema?:
|
|
24
|
+
dataSchema?: Schema["data"],
|
|
25
25
|
functions?: Record<string, Function>,
|
|
26
26
|
funcSchema?: Record<string, FunctionSchema>
|
|
27
27
|
): DynamicImageResult {
|
|
@@ -52,7 +52,7 @@ export type CompileDynamicImageResult = { readonly type: "Ok"; value: string } |
|
|
|
52
52
|
|
|
53
53
|
export function compileDynamicImage(
|
|
54
54
|
source: string,
|
|
55
|
-
dataSchema?:
|
|
55
|
+
dataSchema?: Schema["data"],
|
|
56
56
|
functionSchema?: Record<string, FunctionSchema>
|
|
57
57
|
): CompileDynamicImageResult {
|
|
58
58
|
try {
|