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.
@@ -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
- width: {
7
- type: "number",
8
- required: true,
9
- description: "Total width of the image canvas (in px).",
10
- },
11
- height: {
12
- type: "number",
13
- required: true,
14
- description: "Total height of the image canvas (in px).",
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
- src: {
28
- type: "string",
29
- required: true,
30
- description: "Source of the image (URL or asset ID).",
31
- },
32
- x: {
33
- type: "number",
34
- description: "X position in pixels.",
35
- },
36
- y: {
37
- type: "number",
38
- description: "Y position in pixels.",
39
- },
40
- width: {
41
- type: "number",
42
- description: "Display width in pixels.",
43
- },
44
- height: {
45
- type: "number",
46
- description: "Display height in pixels.",
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
- x: {
55
- type: "number",
56
- description: "X coordinate of the top-left of the ellipse box.",
57
- },
58
- y: {
59
- type: "number",
60
- description: "Y coordinate of the top-left of the ellipse box.",
61
- },
62
- width: {
63
- type: "number",
64
- description: "Box width.",
65
- },
66
- height: {
67
- type: "number",
68
- description: "Box height.",
69
- },
70
- stroke: {
71
- type: "string",
72
- format: "color",
73
- description: "Stroke color (CSS color string).",
74
- },
75
- strokeWidth: {
76
- type: "number",
77
- description: "Stroke width in pixels.",
78
- },
79
- fill: {
80
- type: "string",
81
- format: "color",
82
- description: "Fill color (inside the ellipse).",
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
- x1: {
91
- type: "number",
92
- description: "X coordinate of the start point.",
93
- },
94
- y1: {
95
- type: "number",
96
- description: "Y coordinate of the start point.",
97
- },
98
- x2: {
99
- type: "number",
100
- description: "X coordinate of the end point.",
101
- },
102
- y2: {
103
- type: "number",
104
- description: "Y coordinate of the end point.",
105
- },
106
- stroke: {
107
- type: "string",
108
- format: "color",
109
- description: "Stroke color of the line.",
110
- },
111
- strokeWidth: {
112
- type: "number",
113
- description: "Width of the stroke in px.",
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
- points: {
122
- type: "string",
123
- required: true,
124
- description: "List of points: 'x0,y0 x1,y1 x2,y2'.",
125
- },
126
- stroke: {
127
- type: "string",
128
- format: "color",
129
- description: "Stroke color.",
130
- },
131
- strokeWidth: {
132
- type: "number",
133
- description: "Stroke width in px.",
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
- points: {
142
- type: "string",
143
- required: true,
144
- description: "List of vertex points: 'x0,y0 x1,y1 ...'.",
145
- },
146
- stroke: {
147
- type: "string",
148
- format: "color",
149
- description: "Stroke color.",
150
- },
151
- strokeWidth: {
152
- type: "number",
153
- description: "Stroke width in px.",
154
- },
155
- fill: {
156
- type: "string",
157
- format: "color",
158
- description: "Fill color of the polygon.",
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
- x: {
167
- type: "number",
168
- description: "X position of the rectangle (top-left).",
169
- },
170
- y: {
171
- type: "number",
172
- description: "Y position of the rectangle (top-left).",
173
- },
174
- width: {
175
- type: "number",
176
- description: "Rectangle width in px.",
177
- },
178
- height: {
179
- type: "number",
180
- description: "Rectangle height in px.",
181
- },
182
- stroke: {
183
- type: "string",
184
- format: "color",
185
- description: "Stroke color.",
186
- },
187
- strokeWidth: {
188
- type: "number",
189
- description: "Stroke width in px.",
190
- },
191
- fill: {
192
- type: "string",
193
- format: "color",
194
- description: "Fill color of the rectangle.",
195
- },
196
- radius: {
197
- type: "number",
198
- description: "Corner radius in px (uniform).",
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
- x: {
207
- type: "number",
208
- description: "X position of the text anchor.",
209
- },
210
- y: {
211
- type: "number",
212
- description: "Y position of the text baseline.",
213
- },
214
- fontFamily: {
215
- type: "string",
216
- description: "Font family, e.g. 'Inter, system-ui'.",
217
- },
218
- fontSize: {
219
- type: "number",
220
- description: "Font size in pixels.",
221
- },
222
- fontWeight: {
223
- type: "string",
224
- description: "Font weight, e.g. 'bold', '700'.",
225
- },
226
- fill: {
227
- type: "string",
228
- format: "color",
229
- description: "Fill color (text color).",
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,GAAG;IACxB,QAAQ,EAAE;QACR,aAAa,EAAE;YACb,WAAW,EAAE,sEAAsE;YACnF,KAAK,EAAE;gBACL,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,QAAQ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AM,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 { PropertySchema } from "jsxpression";
2
- export declare function generateDataSchema(data: Record<string, unknown>): Record<string, PropertySchema>;
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,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAQhG"}
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
- const schema = {};
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 inferPropertySchema(value) {
9
- if (value === null || value === undefined) {
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
- const itemSchema = value.length > 0 ? inferPropertySchema(value[0]) : { type: "string" };
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
- const shape = {};
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
- return { type: "string" };
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":"AAEA,MAAM,UAAU,kBAAkB,CAAC,IAA6B;IAC9D,MAAM,MAAM,GAAmC,EAAE,CAAC;IAElD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO;YACL,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO;YACL,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO;YACL,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,K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C,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": "13.3.6",
4
- "gitHead": "9780e705c2bb2527a36560c0c0533a0de6c0cbed",
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.3.3"
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 PropertySchema, type Schema } from "jsxpression";
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?: Record<string, PropertySchema>,
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?: Record<string, PropertySchema>,
55
+ dataSchema?: Schema["data"],
56
56
  functionSchema?: Record<string, FunctionSchema>
57
57
  ): CompileDynamicImageResult {
58
58
  try {