@polotno/schema 0.9.1 → 0.11.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/README.md +1 -0
- package/lib/defaults.d.ts +3 -0
- package/lib/defaults.js +15 -0
- package/lib/design.schema.json +1 -3111
- package/lib/migrate.js +31 -1
- package/lib/schema.d.ts +9 -1
- package/lib/schema.js +98 -14
- package/lib/types.d.ts +20 -7
- package/package.json +1 -1
package/lib/migrate.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
// decision into the design (`legacyBackground`), so the second pass through any
|
|
34
34
|
// entry point is a no-op and every renderer reads the same resolved intent.
|
|
35
35
|
import { CURRENT_SCHEMA_VERSION } from './schema.js';
|
|
36
|
-
import { TEXT_DEFAULTS } from './defaults.js';
|
|
36
|
+
import { DESIGN_SIZE, TEXT_DEFAULTS } from './defaults.js';
|
|
37
37
|
/** Named effects that never used the -100..100 intensity range. */
|
|
38
38
|
const UNSCALED_FILTERS = ['warm', 'cold', 'natural'];
|
|
39
39
|
/** The tags Quill actually emitted. Anything else is not evidence. */
|
|
@@ -191,6 +191,36 @@ export function migrateDesign(json, options = {}) {
|
|
|
191
191
|
}
|
|
192
192
|
// v3→4 is a marker only: v4 is the video time-anchor render change. Nothing
|
|
193
193
|
// to transform, but the bump lets a future migration target pre-v4 designs.
|
|
194
|
+
if (from < 5) {
|
|
195
|
+
// A move travelled a fixed 200px. From v5 it travels a share of its page's
|
|
196
|
+
// shorter side (core's `TRAVEL.move`), so scale each saved strength to keep
|
|
197
|
+
// the 200px. Both numbers stay frozen here.
|
|
198
|
+
const MOVE_PX = 200;
|
|
199
|
+
const MOVE_SHARE = 0.2;
|
|
200
|
+
const side = (page, design) => typeof page === 'number' ? page : (design ?? DESIGN_SIZE);
|
|
201
|
+
for (const page of Array.isArray(data.pages) ? data.pages : []) {
|
|
202
|
+
if (!page || typeof page !== 'object')
|
|
203
|
+
continue;
|
|
204
|
+
const unit = Math.min(side(page.width, data.width), side(page.height, data.height));
|
|
205
|
+
if (!(unit > 0))
|
|
206
|
+
continue;
|
|
207
|
+
forEveryElement([page], (element) => {
|
|
208
|
+
if (!Array.isArray(element.animations))
|
|
209
|
+
return;
|
|
210
|
+
for (const animation of element.animations) {
|
|
211
|
+
if (animation?.name !== 'move')
|
|
212
|
+
continue;
|
|
213
|
+
const strength = Number.isFinite(animation.data?.strength)
|
|
214
|
+
? animation.data.strength
|
|
215
|
+
: 1;
|
|
216
|
+
animation.data = {
|
|
217
|
+
...animation.data,
|
|
218
|
+
strength: (strength * MOVE_PX) / (MOVE_SHARE * unit),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
194
224
|
data.schemaVersion = CURRENT_SCHEMA_VERSION;
|
|
195
225
|
return data;
|
|
196
226
|
}
|
package/lib/schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const CURRENT_SCHEMA_VERSION =
|
|
2
|
+
export declare const CURRENT_SCHEMA_VERSION = 5;
|
|
3
3
|
export declare const ELEMENT_TYPES: readonly ["text", "image", "svg", "line", "figure", "gif", "video", "table", "group"];
|
|
4
4
|
/** Non-strict: strips unknown keys, fills defaults. `normalizeDesign` uses this. */
|
|
5
5
|
export declare const designSchemaLenient: z.ZodObject<{
|
|
@@ -187,6 +187,7 @@ export declare const leafSchemas: {
|
|
|
187
187
|
}>;
|
|
188
188
|
name: z.ZodDefault<z.ZodString>;
|
|
189
189
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
190
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
190
191
|
}, z.core.$strip>>>;
|
|
191
192
|
blurEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
192
193
|
blurRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -266,6 +267,7 @@ export declare const leafSchemas: {
|
|
|
266
267
|
}>;
|
|
267
268
|
name: z.ZodDefault<z.ZodString>;
|
|
268
269
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
270
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
269
271
|
}, z.core.$strip>>>;
|
|
270
272
|
blurEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
271
273
|
blurRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -346,6 +348,7 @@ export declare const leafSchemas: {
|
|
|
346
348
|
}>;
|
|
347
349
|
name: z.ZodDefault<z.ZodString>;
|
|
348
350
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
351
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
349
352
|
}, z.core.$strip>>>;
|
|
350
353
|
blurEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
351
354
|
blurRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -416,6 +419,7 @@ export declare const leafSchemas: {
|
|
|
416
419
|
}>;
|
|
417
420
|
name: z.ZodDefault<z.ZodString>;
|
|
418
421
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
422
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
419
423
|
}, z.core.$strip>>>;
|
|
420
424
|
blurEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
421
425
|
blurRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -488,6 +492,7 @@ export declare const leafSchemas: {
|
|
|
488
492
|
}>;
|
|
489
493
|
name: z.ZodDefault<z.ZodString>;
|
|
490
494
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
495
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
491
496
|
}, z.core.$strip>>>;
|
|
492
497
|
blurEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
493
498
|
blurRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -568,6 +573,7 @@ export declare const leafSchemas: {
|
|
|
568
573
|
}>;
|
|
569
574
|
name: z.ZodDefault<z.ZodString>;
|
|
570
575
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
576
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
571
577
|
}, z.core.$strip>>>;
|
|
572
578
|
blurEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
573
579
|
blurRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -652,6 +658,7 @@ export declare const leafSchemas: {
|
|
|
652
658
|
}>;
|
|
653
659
|
name: z.ZodDefault<z.ZodString>;
|
|
654
660
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
661
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
655
662
|
}, z.core.$strip>>>;
|
|
656
663
|
blurEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
657
664
|
blurRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -813,6 +820,7 @@ export declare const leafSchemas: {
|
|
|
813
820
|
}>;
|
|
814
821
|
name: z.ZodDefault<z.ZodString>;
|
|
815
822
|
data: z.ZodDefault<z.ZodUnknown>;
|
|
823
|
+
easing: z.ZodOptional<z.ZodString>;
|
|
816
824
|
}, z.core.$strip>>>;
|
|
817
825
|
visible: z.ZodDefault<z.ZodBoolean>;
|
|
818
826
|
draggable: z.ZodDefault<z.ZodBoolean>;
|
package/lib/schema.js
CHANGED
|
@@ -23,10 +23,17 @@
|
|
|
23
23
|
// format rather than a behavior of one entry point. Leaving it out did not keep
|
|
24
24
|
// the schema neutral, it just moved the decision into each renderer — see
|
|
25
25
|
// MIN_FONT_SIZE in ./defaults for what they each decided.
|
|
26
|
+
//
|
|
27
|
+
// A type used in more than one place takes `.meta({ id })`, so the generated
|
|
28
|
+
// JSON Schema defines it once under `$defs` and `$ref`s it, rather than copying
|
|
29
|
+
// it into every element (Animation alone was ~6 KB of descriptions, nine
|
|
30
|
+
// times). It changes the JSON only: zod drops `id` from the output, and the two
|
|
31
|
+
// `build()` variants are never converted together. Keep the id on the type and
|
|
32
|
+
// the `.describe()` on each use, so every property still has a description.
|
|
26
33
|
import { z } from 'zod';
|
|
27
34
|
import { polotnoError } from './errors.js';
|
|
28
|
-
import { BLEND_MODES, GROUP_BLEND_MODES, MIN_FONT_SIZE, clampFontSize, TEXT_DEFAULTS, } from './defaults.js';
|
|
29
|
-
export const CURRENT_SCHEMA_VERSION =
|
|
35
|
+
import { ANIMATION_EASINGS, BLEND_MODES, GROUP_BLEND_MODES, MIN_FONT_SIZE, clampFontSize, DESIGN_SIZE, TEXT_DEFAULTS, } from './defaults.js';
|
|
36
|
+
export const CURRENT_SCHEMA_VERSION = 5;
|
|
30
37
|
// Every element type the design format knows. Kept in sync with the
|
|
31
38
|
// element discriminatedUnion in build() below.
|
|
32
39
|
export const ELEMENT_TYPES = [
|
|
@@ -45,23 +52,95 @@ export const ELEMENT_TYPES = [
|
|
|
45
52
|
// — a `strict ? z.strictObject : z.object` ternary would widen to a union and
|
|
46
53
|
// break `z.infer` of the leaf schemas (and thus the type-drift guard).
|
|
47
54
|
function build(o) {
|
|
55
|
+
// These descriptions are the public reference for writing an animation by
|
|
56
|
+
// hand: polotno.com/docs/schema/animation prints each one in a table cell of
|
|
57
|
+
// an MDX page. So a description stays on one line, with no raw `{` or `<`,
|
|
58
|
+
// and the object itself takes none (it would land in unquoted YAML
|
|
59
|
+
// frontmatter). They mirror what the canvas plays (polotno
|
|
60
|
+
// `utils/animations.ts`) and what the Animate panel offers per element type.
|
|
61
|
+
// `cameraZoom` stays out: it is going away (`docs/next-major.md`).
|
|
48
62
|
const animation = o({
|
|
49
63
|
delay: z
|
|
50
64
|
.number()
|
|
51
65
|
.default(0)
|
|
52
|
-
.describe(
|
|
66
|
+
.describe([
|
|
67
|
+
"Time in milliseconds, measured on the element's page, not on the whole design.",
|
|
68
|
+
"On 'enter': how long after the page starts the element appears. It is hidden until then.",
|
|
69
|
+
"On 'exit': how long before the page ends the element disappears. The exit finishes at that moment, and the element stays hidden after it.",
|
|
70
|
+
"On 'loop': how long after the page starts the first cycle begins. It does not wait for the entrance, so a loop can be mid-cycle when the element appears. Until then the element is at rest.",
|
|
71
|
+
'kenBurns ignores it, and letterWave also waits for an entrance that is a text preset to finish.',
|
|
72
|
+
].join(' ')),
|
|
53
73
|
duration: z
|
|
54
74
|
.number()
|
|
55
75
|
.default(500)
|
|
56
|
-
.describe(
|
|
76
|
+
.describe([
|
|
77
|
+
'Time in milliseconds.',
|
|
78
|
+
"On 'enter': how long the entrance plays, from its `delay`.",
|
|
79
|
+
"On 'exit': how long the exit plays, up to the moment the element disappears.",
|
|
80
|
+
"If the two together are longer than the element's time on the page, both play faster by the same factor to fit.",
|
|
81
|
+
"On 'loop': the length of one cycle. Cycles repeat until the element disappears or the page ends.",
|
|
82
|
+
"kenBurns ignores it and plays once across the element's whole time on the page.",
|
|
83
|
+
'The default suits a transition of the whole element. Picking a preset in the editor sets a longer one: 1000 for lineRise, wordRise, wordFade, letterPop, wordBlur and lineWipe, 50 per letter from 1000 to 4000 for typewriter, 4000 for rotate, 2500 for float, 2000 for letterWave and glow, 1500 for blink and pulse, and 1000 for shake.',
|
|
84
|
+
].join(' ')),
|
|
57
85
|
enabled: z
|
|
58
86
|
.boolean()
|
|
59
87
|
.default(true)
|
|
60
|
-
.describe(
|
|
61
|
-
type: z
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
.describe("Whether the animation plays. A disabled 'enter' or 'exit' also loses its `delay`, so the element is on the page from its start or to its end. To time an element with no transition, keep it enabled with the name 'none'."),
|
|
89
|
+
type: z
|
|
90
|
+
.enum(['enter', 'exit', 'loop'])
|
|
91
|
+
.describe("Animation phase: 'enter' brings the element onto the page, 'exit' takes it off, and 'loop' repeats while it is there, also during the entrance and the exit."),
|
|
92
|
+
name: z
|
|
93
|
+
.string()
|
|
94
|
+
.default('none')
|
|
95
|
+
.describe([
|
|
96
|
+
'Preset to play. Which names are valid depends on `type`.',
|
|
97
|
+
"On 'enter' and 'exit': 'none' | 'fade' | 'move' | 'zoom' | 'pop' | 'rise' | 'flip' | 'growTurn' | 'wipe' | 'blur' | 'count' | 'typewriter' | 'lineRise' | 'wordRise' | 'wordFade' | 'letterPop' | 'wordBlur' | 'lineWipe'.",
|
|
98
|
+
"On 'loop': 'none' | 'rotate' | 'blink' | 'bounce' | 'pulse' | 'float' | 'shake' | 'glow' | 'kenBurns' | 'letterWave'.",
|
|
99
|
+
"Use a name only on its own type: a fade on 'loop' plays once and leaves the element hidden.",
|
|
100
|
+
'An unknown name passes validation, logs a console error and does not animate.',
|
|
101
|
+
'none is a hard cut: the element still appears or disappears at its `delay`, with no transition, and `duration` is ignored.',
|
|
102
|
+
'As entrances: fade fades in, move slides in along a straight line, zoom scales into place, pop grows into place and fades in over its first third, rise moves up into place while fading in, flip turns half round about its vertical center line from its mirrored back, growTurn turns into place from half size while fading in, wipe shows the element behind a travelling edge, blur comes into focus while fading in, and count counts the first number in the text up to its value, keeping the style of the text and the format of the number, such as its thousands separator.',
|
|
103
|
+
'An exit plays the same preset backwards, except that move, rise, growTurn and wipe carry on the way they were going.',
|
|
104
|
+
'Presets that scale keep the center of the element in place.',
|
|
105
|
+
'The text presets play on each unit of the text in turn, and `duration` covers them all: typewriter shows letters, letterPop pops letters, wordRise, wordFade and wordBlur play rise, fade and blur on words, and lineRise and lineWipe play rise and wipe on lines. An exit runs from the last unit back to the first.',
|
|
106
|
+
'As loops: rotate turns clockwise once per cycle, blink fades out and back, pulse grows a little and back, float lifts and settles, shake swings side to side and dies out within the cycle, glow swells and fades a halo around the element, letterWave bobs each letter in turn, and kenBurns zooms, and can pan, inside the frame of the element. bounce shrinks and grows back: the editor no longer offers it, so prefer pulse.',
|
|
107
|
+
"Element limits: count, the text presets and letterWave are for 'text' elements. count plays nothing without a number in the text. Curved text or any other element plays a text preset whole, as its base preset: typewriter and wordFade as fade, lineRise and wordRise as rise, letterPop as pop, wordBlur as blur, lineWipe as wipe and letterWave as float.",
|
|
108
|
+
"blur blurs only 'text', 'image', 'svg', 'video' and 'gif', and any other element only fades.",
|
|
109
|
+
"glow plays nothing on 'table' and 'group'. kenBurns plays on the crop, so only on 'image', 'svg', 'video' and 'gif'.",
|
|
110
|
+
'Every other preset plays on every element, groups included.',
|
|
111
|
+
].join(' ')),
|
|
112
|
+
data: z
|
|
113
|
+
.unknown()
|
|
114
|
+
.default({})
|
|
115
|
+
.describe([
|
|
116
|
+
'Object of options for the preset in `name`. Every option is optional, and a preset not listed here takes none.',
|
|
117
|
+
'`strength` is always a multiplier, default 1, and the editor offers 0.1 to 3.',
|
|
118
|
+
"move: `direction` 'right' | 'left' | 'up' | 'down' | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left', default 'right', the way the element travels on both 'enter' and 'exit'. `strength` 1 travels 20% of the shorter side of the page: it covers that distance, not the way to the edge of the page.",
|
|
119
|
+
"zoom: `direction` 'in' | 'out', default 'in'. 'in' starts smaller and grows into place, 'out' starts larger and shrinks into place, and any other value plays as 'out'. `strength` 1 starts 25% away from full size.",
|
|
120
|
+
'pop: `strength` 1 starts from nothing, and 0.5 from half size.',
|
|
121
|
+
'rise: `strength` 1 travels 5% of the shorter side of the page.',
|
|
122
|
+
'growTurn: `strength` 1 turns 180 degrees.',
|
|
123
|
+
"wipe: `direction` 'right' | 'left' | 'up' | 'down', default 'right', the way its edge travels.",
|
|
124
|
+
'blur: `strength` 1 adds 20 to `blurRadius` at its most blurred.',
|
|
125
|
+
"count: `from`, a number, default 0, where the count starts on 'enter' and ends on 'exit'.",
|
|
126
|
+
'bounce: `strength` 1 shrinks to a third of the size, and 0.5 to half.',
|
|
127
|
+
'pulse: `strength` 1 grows 8%.',
|
|
128
|
+
'float: `strength` 1 lifts 2% of the shorter side of the page.',
|
|
129
|
+
'shake: `strength` 1 swings 1.5% of the shorter side of the page.',
|
|
130
|
+
'letterWave: `strength` 1 lifts each letter 0.3 of its font size.',
|
|
131
|
+
"glow: `strength` 1 spreads 2% of the shorter side of the page. It has no color option: it uses the element's `shadowColor` when `shadowEnabled` is true or `shadowColor` is not 'black', else its `fill` (`color` on a line), else black. So a `shadowColor` with `shadowEnabled` false glows in that color and shows no shadow at rest.",
|
|
132
|
+
"kenBurns: `zoom` 'in' | 'out', default 'in'. 'in' narrows the saved crop, and 'out' widens to it. `direction` 'none' | 'right' | 'left' | 'up' | 'down', default 'none', the way the view pans. `strength` 1 narrows the crop by 15%.",
|
|
133
|
+
'A design below `schemaVersion` 5, or with none, has its move `strength` rescaled on load to keep the fixed 200px those versions travelled.',
|
|
134
|
+
].join(' ')),
|
|
135
|
+
// Optional with NO default, so normalizeDesign output stays unchanged for
|
|
136
|
+
// a design that never sets it. A plain string, not an enum, for the reason
|
|
137
|
+
// `textOverflow` gives below: an older SDK must read a curve added later as
|
|
138
|
+
// missing instead of crashing on load.
|
|
139
|
+
easing: z
|
|
140
|
+
.string()
|
|
141
|
+
.optional()
|
|
142
|
+
.describe(`Timing curve: ${ANIMATION_EASINGS.map((e) => `'${e}'`).join(' | ')}. Missing (or unknown) plays linear. Setting a preset in the editor writes its recommended curve: fade, move, zoom, blur, count, rise, flip, growTurn and wipe ease out on enter and ease in on exit, pop overshoots (backOut on enter, backIn on exit), blink and bounce ease in and out on each sweep, kenBurns eases in and out across the element's time, a text preset eases each of its letters, words or lines as the preset it plays, and every other animation is linear.`),
|
|
143
|
+
}).meta({ id: 'Animation' });
|
|
65
144
|
const filters = z
|
|
66
145
|
.record(z.string(), o({
|
|
67
146
|
intensity: z
|
|
@@ -69,9 +148,11 @@ function build(o) {
|
|
|
69
148
|
.default(1)
|
|
70
149
|
.describe('Filter intensity (-1 to 1).'),
|
|
71
150
|
}))
|
|
151
|
+
.meta({ id: 'Filters' })
|
|
72
152
|
.describe('Applied image filters keyed by filter name.');
|
|
73
153
|
const blendMode = z
|
|
74
154
|
.enum(BLEND_MODES)
|
|
155
|
+
.meta({ id: 'BlendMode' })
|
|
75
156
|
.optional()
|
|
76
157
|
.describe('How the element composites with the content beneath it. Omitted means normal.');
|
|
77
158
|
// Fields shared by every Shape-derived element. Defaults inline.
|
|
@@ -93,7 +174,7 @@ function build(o) {
|
|
|
93
174
|
animations: z
|
|
94
175
|
.array(animation)
|
|
95
176
|
.default([])
|
|
96
|
-
.describe('
|
|
177
|
+
.describe("The element's animations, at most one of each `type`, so an 'enter', an 'exit' and a 'loop' can play together. A group's animations play on top of its children's."),
|
|
97
178
|
blurEnabled: z
|
|
98
179
|
.boolean()
|
|
99
180
|
.default(false)
|
|
@@ -437,7 +518,7 @@ function build(o) {
|
|
|
437
518
|
.enum(['solid', 'dashed', 'dotted', 'none'])
|
|
438
519
|
.optional()
|
|
439
520
|
.describe('Border style for this side.'),
|
|
440
|
-
});
|
|
521
|
+
}).meta({ id: 'BorderSide' });
|
|
441
522
|
// Cell styling fields are optional (inherit from the table when omitted).
|
|
442
523
|
const tableCell = o({
|
|
443
524
|
id: z.string().describe('Unique identifier for the cell.'),
|
|
@@ -746,9 +827,12 @@ function build(o) {
|
|
|
746
827
|
schemaVersion: z
|
|
747
828
|
.number()
|
|
748
829
|
.default(CURRENT_SCHEMA_VERSION)
|
|
749
|
-
.describe('Schema version for compatibility / migration.'),
|
|
750
|
-
width: z.number().default(
|
|
751
|
-
height: z
|
|
830
|
+
.describe('Schema version for compatibility / migration. A design without it counts as version 0, the oldest format, and is migrated on load, so write the current version in new JSON.'),
|
|
831
|
+
width: z.number().default(DESIGN_SIZE).describe('Canvas width in pixels.'),
|
|
832
|
+
height: z
|
|
833
|
+
.number()
|
|
834
|
+
.default(DESIGN_SIZE)
|
|
835
|
+
.describe('Canvas height in pixels.'),
|
|
752
836
|
unit: z
|
|
753
837
|
.enum(['px', 'pt', 'mm', 'cm', 'in'])
|
|
754
838
|
.default('px')
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { BLEND_MODES, GROUP_BLEND_MODES } from './defaults.js';
|
|
1
|
+
import type { ANIMATION_EASINGS, BLEND_MODES, GROUP_BLEND_MODES } from './defaults.js';
|
|
2
2
|
export type BlendMode = (typeof BLEND_MODES)[number];
|
|
3
3
|
export type GroupBlendMode = (typeof GROUP_BLEND_MODES)[number];
|
|
4
|
+
export type AnimationEasing = (typeof ANIMATION_EASINGS)[number];
|
|
4
5
|
export interface Design {
|
|
5
6
|
/** Schema version for compatibility / migration. */
|
|
6
7
|
schemaVersion: number;
|
|
@@ -87,19 +88,31 @@ export interface Page {
|
|
|
87
88
|
}
|
|
88
89
|
export type Element = TextElement | ImageElement | SVGElement | LineElement | VideoElement | FigureElement | GifElement | GroupElement | TableElement;
|
|
89
90
|
export type ElementType = Element['type'];
|
|
91
|
+
/**
|
|
92
|
+
* The JSON Schema's descriptions (`design.schema.json`) are the full reference:
|
|
93
|
+
* the preset names for each `type`, their options and element limits.
|
|
94
|
+
*/
|
|
90
95
|
export interface Animation {
|
|
91
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Milliseconds on the element's page: after its start on `enter` and `loop`,
|
|
98
|
+
* before its end on `exit`.
|
|
99
|
+
*/
|
|
92
100
|
delay: number;
|
|
93
|
-
/**
|
|
101
|
+
/** Length in milliseconds: of the transition, or of one `loop` cycle. */
|
|
94
102
|
duration: number;
|
|
95
|
-
/** Whether
|
|
103
|
+
/** Whether it plays. A disabled `enter` or `exit` also loses its `delay`. */
|
|
96
104
|
enabled: boolean;
|
|
97
105
|
/** Animation phase. */
|
|
98
106
|
type: 'enter' | 'exit' | 'loop';
|
|
99
|
-
/**
|
|
107
|
+
/** Preset to play. Which names are valid depends on `type`. */
|
|
100
108
|
name: string;
|
|
101
|
-
/**
|
|
109
|
+
/** Options for the preset in `name`. */
|
|
102
110
|
data: unknown;
|
|
111
|
+
/**
|
|
112
|
+
* Timing curve, one of {@link AnimationEasing}. Missing (or unknown) plays
|
|
113
|
+
* linear.
|
|
114
|
+
*/
|
|
115
|
+
easing?: string;
|
|
103
116
|
}
|
|
104
117
|
/** Properties shared by all non-group elements. */
|
|
105
118
|
export interface ShapeAttributes {
|
|
@@ -125,7 +138,7 @@ export interface ShapeAttributes {
|
|
|
125
138
|
opacity: number;
|
|
126
139
|
/** How the element composites with the content beneath it. Omitted means normal. */
|
|
127
140
|
blendMode?: BlendMode;
|
|
128
|
-
/**
|
|
141
|
+
/** The element's animations, at most one of each `type`. */
|
|
129
142
|
animations: Animation[];
|
|
130
143
|
blurEnabled: boolean;
|
|
131
144
|
blurRadius: number;
|
package/package.json
CHANGED