@polotno/schema 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE.md +10 -0
  2. package/README.md +81 -0
  3. package/lib/constants.d.ts +6 -0
  4. package/lib/constants.d.ts.map +1 -0
  5. package/lib/constants.js +61 -0
  6. package/lib/constants.js.map +1 -0
  7. package/lib/defaults.d.ts +445 -0
  8. package/lib/defaults.d.ts.map +1 -0
  9. package/lib/defaults.js +254 -0
  10. package/lib/defaults.js.map +1 -0
  11. package/lib/design.schema.json +2771 -0
  12. package/lib/index.d.ts +5 -0
  13. package/lib/index.d.ts.map +1 -0
  14. package/lib/index.js +7 -0
  15. package/lib/index.js.map +1 -0
  16. package/lib/migrate.d.ts +6 -0
  17. package/lib/migrate.d.ts.map +1 -0
  18. package/lib/migrate.js +58 -0
  19. package/lib/migrate.js.map +1 -0
  20. package/lib/normalize.d.ts +2 -0
  21. package/lib/normalize.d.ts.map +1 -0
  22. package/lib/normalize.js +36 -0
  23. package/lib/normalize.js.map +1 -0
  24. package/lib/processors.d.ts +13 -0
  25. package/lib/processors.d.ts.map +1 -0
  26. package/lib/processors.js +170 -0
  27. package/lib/processors.js.map +1 -0
  28. package/lib/schema.d.ts +693 -0
  29. package/lib/schema.d.ts.map +1 -0
  30. package/lib/schema.js +379 -0
  31. package/lib/schema.js.map +1 -0
  32. package/lib/traverse.d.ts +3 -0
  33. package/lib/traverse.d.ts.map +1 -0
  34. package/lib/traverse.js +32 -0
  35. package/lib/traverse.js.map +1 -0
  36. package/lib/types-parity.d.ts +2 -0
  37. package/lib/types-parity.d.ts.map +1 -0
  38. package/lib/types-parity.js +11 -0
  39. package/lib/types-parity.js.map +1 -0
  40. package/lib/types.d.ts +349 -0
  41. package/lib/types.d.ts.map +1 -0
  42. package/lib/types.js +22 -0
  43. package/lib/types.js.map +1 -0
  44. package/lib/validate.d.ts +19 -0
  45. package/lib/validate.d.ts.map +1 -0
  46. package/lib/validate.js +383 -0
  47. package/lib/validate.js.map +1 -0
  48. package/package.json +57 -0
package/lib/types.d.ts ADDED
@@ -0,0 +1,349 @@
1
+ export interface Design {
2
+ /** Schema version for compatibility / migration. */
3
+ schemaVersion: number;
4
+ /** Canvas width in pixels. */
5
+ width: number;
6
+ /** Canvas height in pixels. */
7
+ height: number;
8
+ /** Unit type for print measurements. */
9
+ unit: 'px' | 'pt' | 'mm' | 'cm' | 'in';
10
+ /** Dots per inch for print calculations. */
11
+ dpi: number;
12
+ /** Arbitrary client data attached to the design. */
13
+ custom?: unknown;
14
+ /** Fonts used in the design. */
15
+ fonts: Font[];
16
+ /** Pages in the design. */
17
+ pages: Page[];
18
+ /** Audio tracks in the design. */
19
+ audios: Audio[];
20
+ }
21
+ export interface FontStyleVariant {
22
+ /** Font source, typically in CSS `url(...)` form. */
23
+ src: string;
24
+ /** CSS font style: 'normal' or 'italic'. */
25
+ fontStyle?: string;
26
+ /** CSS font weight: 'normal', 'bold', or numeric string. */
27
+ fontWeight?: string;
28
+ }
29
+ export interface Font {
30
+ /** Font family name. */
31
+ fontFamily: string;
32
+ /** URL to load the font from (single-variant fonts). Defaults to ''. */
33
+ url: string;
34
+ /** Per-weight/style variants (multi-variant families). */
35
+ styles?: FontStyleVariant[];
36
+ }
37
+ export interface Audio {
38
+ /** Unique identifier. */
39
+ id: string;
40
+ /** URL or data URI of the audio file. */
41
+ src: string;
42
+ /** Duration in milliseconds. */
43
+ duration: number;
44
+ /** Start offset (0-1). */
45
+ startTime: number;
46
+ /** End offset (0-1). */
47
+ endTime: number;
48
+ /** Volume (0-1). */
49
+ volume: number;
50
+ /** Delay before playing, in milliseconds. */
51
+ delay: number;
52
+ /** Playback speed multiplier (1 = normal). */
53
+ speed: number;
54
+ /** Arbitrary client data. */
55
+ custom?: unknown;
56
+ }
57
+ export interface Page {
58
+ /** Unique identifier. */
59
+ id: string;
60
+ /** Page width in pixels or 'auto' (inherit from design). */
61
+ width: number | 'auto';
62
+ /** Page height in pixels or 'auto' (inherit from design). */
63
+ height: number | 'auto';
64
+ /** Background color or image. */
65
+ background: string;
66
+ /** Bleed area in pixels for print. */
67
+ bleed: number;
68
+ /** Arbitrary client data. */
69
+ custom?: unknown;
70
+ /** Page duration in milliseconds. */
71
+ duration: number;
72
+ /** Elements on this page. */
73
+ children: Element[];
74
+ }
75
+ export type Element = TextElement | ImageElement | SVGElement | LineElement | VideoElement | FigureElement | GifElement | GroupElement | TableElement;
76
+ export type ElementType = Element['type'];
77
+ export interface Animation {
78
+ /** Delay before the animation starts, in milliseconds. */
79
+ delay: number;
80
+ /** Animation duration in milliseconds. */
81
+ duration: number;
82
+ /** Whether the animation is enabled. */
83
+ enabled: boolean;
84
+ /** Animation phase. */
85
+ type: 'enter' | 'exit' | 'loop';
86
+ /** Animation name identifier. */
87
+ name: string;
88
+ /** Animation-specific data. */
89
+ data: unknown;
90
+ }
91
+ /** Properties shared by all non-group elements. */
92
+ export interface ShapeAttributes {
93
+ /** Unique identifier. */
94
+ id: string;
95
+ /** Element type identifier. */
96
+ type: string;
97
+ /** Display name (defaults to ''). */
98
+ name: string;
99
+ /** Arbitrary client data. */
100
+ custom?: unknown;
101
+ /** X position in pixels. */
102
+ x: number;
103
+ /** Y position in pixels. */
104
+ y: number;
105
+ /** Width in pixels. */
106
+ width: number;
107
+ /** Height in pixels. */
108
+ height: number;
109
+ /** Rotation in degrees. */
110
+ rotation: number;
111
+ /** Opacity (0-1). */
112
+ opacity: number;
113
+ /** Animation configurations. */
114
+ animations: Animation[];
115
+ blurEnabled: boolean;
116
+ blurRadius: number;
117
+ brightnessEnabled: boolean;
118
+ brightness: number;
119
+ sepiaEnabled: boolean;
120
+ grayscaleEnabled: boolean;
121
+ /** Applied image filters keyed by filter name. */
122
+ filters: Record<string, {
123
+ intensity: number;
124
+ }>;
125
+ shadowEnabled: boolean;
126
+ shadowBlur: number;
127
+ shadowOffsetX: number;
128
+ shadowOffsetY: number;
129
+ shadowColor: string;
130
+ shadowOpacity: number;
131
+ visible: boolean;
132
+ draggable: boolean;
133
+ resizable: boolean;
134
+ selectable: boolean;
135
+ removable: boolean;
136
+ contentEditable: boolean;
137
+ styleEditable: boolean;
138
+ alwaysOnTop: boolean;
139
+ showInExport: boolean;
140
+ }
141
+ export interface GroupElement {
142
+ id: string;
143
+ type: 'group';
144
+ /** Display name (defaults to ''). */
145
+ name: string;
146
+ custom?: unknown;
147
+ opacity: number;
148
+ visible: boolean;
149
+ selectable: boolean;
150
+ removable: boolean;
151
+ alwaysOnTop: boolean;
152
+ showInExport: boolean;
153
+ animations: Animation[];
154
+ /** Child elements in this group. */
155
+ children: Element[];
156
+ }
157
+ export interface TextElement extends ShapeAttributes {
158
+ type: 'text';
159
+ /** Visible text shown on canvas. */
160
+ text: string;
161
+ /** Placeholder text shown when empty. */
162
+ placeholder: string;
163
+ fontSize: number;
164
+ fontFamily: string;
165
+ /** 'normal' or 'italic'. */
166
+ fontStyle: string;
167
+ /** 'normal', 'bold', or numeric string. */
168
+ fontWeight: string;
169
+ textDecoration: string;
170
+ textTransform: string;
171
+ /** Text color. */
172
+ fill: string;
173
+ /** Horizontal alignment (commonly left | center | right | justify). */
174
+ align: string;
175
+ verticalAlign: string;
176
+ strokeWidth: number;
177
+ stroke: string;
178
+ /** Line height as a number multiplier or 'auto'. */
179
+ lineHeight: number | string;
180
+ /** Letter spacing as a fraction of font size. */
181
+ letterSpacing: number;
182
+ backgroundEnabled: boolean;
183
+ backgroundColor: string;
184
+ backgroundOpacity: number;
185
+ backgroundCornerRadius: number;
186
+ backgroundPadding: number;
187
+ curveEnabled: boolean;
188
+ curvePower: number;
189
+ /** Internal compatibility flag stamped by the v2→v3 migration. */
190
+ legacyBackground?: boolean;
191
+ }
192
+ /** Image-like crop/border properties shared by image, gif, and video. */
193
+ export interface BaseImageProps {
194
+ /** URL or data URI of the source. */
195
+ src: string;
196
+ /** Crop X offset (0-1). */
197
+ cropX: number;
198
+ /** Crop Y offset (0-1). */
199
+ cropY: number;
200
+ /** Crop width (0-1). */
201
+ cropWidth: number;
202
+ /** Crop height (0-1). */
203
+ cropHeight: number;
204
+ cornerRadius: number;
205
+ flipX: boolean;
206
+ flipY: boolean;
207
+ /** URL or data URI of a clipping mask. */
208
+ clipSrc: string;
209
+ borderColor: string;
210
+ borderSize: number;
211
+ keepRatio: boolean;
212
+ stretchEnabled: boolean;
213
+ }
214
+ export interface ImageElement extends ShapeAttributes, BaseImageProps {
215
+ type: 'image';
216
+ }
217
+ export interface SVGElement extends ShapeAttributes {
218
+ type: 'svg';
219
+ src: string;
220
+ maskSrc: string;
221
+ cropX: number;
222
+ cropY: number;
223
+ cropWidth: number;
224
+ cropHeight: number;
225
+ keepRatio: boolean;
226
+ stretchEnabled: boolean;
227
+ flipX: boolean;
228
+ flipY: boolean;
229
+ borderColor: string;
230
+ borderSize: number;
231
+ cornerRadius: number;
232
+ /** Color replacement mappings (original → replacement). */
233
+ colorsReplace: Record<string, string>;
234
+ }
235
+ export interface LineElement extends ShapeAttributes {
236
+ type: 'line';
237
+ color: string;
238
+ /** Dash pattern array. */
239
+ dash: number[];
240
+ /** Start arrow head: empty, arrow, circle, square, bar. */
241
+ startHead: string;
242
+ /** End arrow head: empty, arrow, circle, square, bar. */
243
+ endHead: string;
244
+ }
245
+ export interface FigureElement extends ShapeAttributes {
246
+ type: 'figure';
247
+ /** Figure subtype: rect, ellipse, triangle, etc. */
248
+ subType: string;
249
+ fill: string;
250
+ dash: number[];
251
+ strokeWidth: number;
252
+ stroke: string;
253
+ cornerRadius: number;
254
+ }
255
+ export interface GifElement extends ShapeAttributes, BaseImageProps {
256
+ type: 'gif';
257
+ /** Duration in milliseconds. */
258
+ duration: number;
259
+ }
260
+ export interface VideoElement extends ShapeAttributes, BaseImageProps {
261
+ type: 'video';
262
+ /** Duration in milliseconds. */
263
+ duration: number;
264
+ /** Start offset (0-1). */
265
+ startTime: number;
266
+ /** End offset (0-1). */
267
+ endTime: number;
268
+ /** Volume (0-1). */
269
+ volume: number;
270
+ /** Playback speed multiplier (1 = normal). */
271
+ speed: number;
272
+ }
273
+ export interface BorderSide {
274
+ /** Border color; inherits from the table when omitted. */
275
+ color?: string;
276
+ /** Border width in pixels; inherits from the table when omitted. */
277
+ width?: number;
278
+ /** Border style; inherits from the table when omitted. */
279
+ style?: 'solid' | 'dashed' | 'dotted' | 'none';
280
+ }
281
+ export interface CellBorders {
282
+ top?: BorderSide;
283
+ right?: BorderSide;
284
+ bottom?: BorderSide;
285
+ left?: BorderSide;
286
+ }
287
+ export interface TableCell {
288
+ id: string;
289
+ type: 'tablecell';
290
+ text: string;
291
+ opacity?: number;
292
+ rowSpan?: number;
293
+ colSpan?: number;
294
+ /** Id of the cell this one is merged into (hidden when set). */
295
+ mergedInto?: string;
296
+ name?: string;
297
+ custom?: unknown;
298
+ /** Per-side border overrides; absent sides inherit from the table. */
299
+ borders?: CellBorders;
300
+ fontSize?: number;
301
+ fontFamily?: string;
302
+ fontWeight?: string;
303
+ fontStyle?: string;
304
+ textDecoration?: string;
305
+ textTransform?: string;
306
+ fill?: string;
307
+ align?: string;
308
+ verticalAlign?: string;
309
+ lineHeight?: number | string;
310
+ letterSpacing?: number;
311
+ strokeWidth?: number;
312
+ stroke?: string;
313
+ cellBackground?: string;
314
+ cellPadding?: number;
315
+ }
316
+ /**
317
+ * Table element. Shadow / blur / brightness / sepia / grayscale / filter
318
+ * properties are stripped from the serialized table, so they're omitted here.
319
+ */
320
+ export interface TableElement extends Omit<ShapeAttributes, 'blurEnabled' | 'blurRadius' | 'brightnessEnabled' | 'brightness' | 'sepiaEnabled' | 'grayscaleEnabled' | 'filters' | 'shadowEnabled' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'shadowColor' | 'shadowOpacity'> {
321
+ type: 'table';
322
+ rows: number;
323
+ cols: number;
324
+ /** Column width fractions (sum to 1). */
325
+ colWidths: number[];
326
+ /** Row height fractions (sum to 1). */
327
+ rowHeights: number[];
328
+ /** Flat cell array in row-major order (length = rows * cols). */
329
+ cells: TableCell[];
330
+ borderColor: string;
331
+ borderWidth: number;
332
+ borderStyle: 'solid' | 'dashed' | 'dotted' | 'none';
333
+ fontSize: number;
334
+ fontFamily: string;
335
+ fontWeight: string;
336
+ fontStyle: string;
337
+ textDecoration: string;
338
+ textTransform: string;
339
+ fill: string;
340
+ align: string;
341
+ verticalAlign: string;
342
+ lineHeight: number | string;
343
+ letterSpacing: number;
344
+ strokeWidth: number;
345
+ stroke: string;
346
+ cellBackground: string;
347
+ cellPadding: number;
348
+ }
349
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,MAAM;IACrB,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACvC,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,2BAA2B;IAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,kCAAkC;IAClC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,IAAI;IACnB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,GAAG,EAAE,M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1,22 @@
1
+ // Public TypeScript types for the Polotno design format — the shape that
2
+ // `normalizeDesign()` returns and `validateDesign()` accepts.
3
+ //
4
+ // WHY HAND-WRITTEN (and not `z.infer` from `./schema`):
5
+ // The design is recursive — a `group` contains `Element`s, including more
6
+ // groups. zod v4 can infer self-referencing *objects*, but our element type is
7
+ // a `discriminatedUnion` whose `group` member references the union; inferring
8
+ // that hits TS2615 ("circularly references itself") and collapses `children` to
9
+ // `any`. So the recursive types here must be written by hand.
10
+ //
11
+ // DRIFT IS GUARDED, NOT TRUSTED: `./types-parity.ts` asserts (at compile time,
12
+ // via `tsc`) that every leaf element type plus `Font`/`Audio` equals `z.infer`
13
+ // of its zod leaf schema (`leafSchemas` in `./schema`). Shared field groups
14
+ // (`ShapeAttributes`, `BaseImageProps`, `Animation`, `BorderSide`, `TableCell`,
15
+ // …) are guarded transitively through those leaves. Only the three types that
16
+ // reference `Element` recursively — `GroupElement`, `Page`, `Design` — are
17
+ // unguarded (zod can't infer them); they change rarely and obviously.
18
+ //
19
+ // These reflect NORMALIZED output, so every field with a schema default is
20
+ // present (required) here, even when it's an empty string / zero.
21
+ export {};
22
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8DAA8D;AAC9D,EAAE;AACF,wDAAwD;AACxD,0EAA0E;AAC1E,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,8DAA8D;AAC9D,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,2EAA2E;AAC3E,sEAAsE;AACtE,EAAE;AACF,2EAA2E;AAC3E,kEAAkE"}
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod/v4';
2
+ type Mode = 'partial' | 'canonical';
3
+ export declare const designSchemaPartial: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
4
+ export declare const designSchemaCanonical: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
5
+ export interface ValidationError {
6
+ path: string;
7
+ message: string;
8
+ }
9
+ export interface ValidationResult {
10
+ valid: boolean;
11
+ errors: ValidationError[];
12
+ }
13
+ export interface ValidateOptions {
14
+ mode?: Mode;
15
+ }
16
+ export declare function validateDesign(input: unknown, opts?: ValidateOptions): ValidationResult;
17
+ export declare function assertValidDesign(input: unknown, opts?: ValidateOptions): void;
18
+ export {};
19
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAsQ3B,KAAK,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC;AA4HpC,eAAO,MAAM,mBAAmB,yEAAyB,CAAC;AAC1D,eAAO,MAAM,qBAAqB,yEAA2B,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AASD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,eAAoB,GACzB,gBAAgB,CAMlB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,eAAoB,GACzB,IAAI,CASN"}