@polotno/schema 0.11.0 → 0.12.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/schema.js CHANGED
@@ -43,6 +43,7 @@ export const ELEMENT_TYPES = [
43
43
  'line',
44
44
  'figure',
45
45
  'gif',
46
+ 'lottie',
46
47
  'video',
47
48
  'table',
48
49
  'group',
@@ -80,7 +81,7 @@ function build(o) {
80
81
  "If the two together are longer than the element's time on the page, both play faster by the same factor to fit.",
81
82
  "On 'loop': the length of one cycle. Cycles repeat until the element disappears or the page ends.",
82
83
  "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
+ '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, lineWipe and linePeek, 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
85
  ].join(' ')),
85
86
  enabled: z
86
87
  .boolean()
@@ -94,7 +95,7 @@ function build(o) {
94
95
  .default('none')
95
96
  .describe([
96
97
  '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 'enter' and 'exit': 'none' | 'fade' | 'move' | 'zoom' | 'pop' | 'rise' | 'flip' | 'growTurn' | 'wipe' | 'blur' | 'count' | 'typewriter' | 'lineRise' | 'wordRise' | 'wordFade' | 'letterPop' | 'wordBlur' | 'lineWipe' | 'linePeek'.",
98
99
  "On 'loop': 'none' | 'rotate' | 'blink' | 'bounce' | 'pulse' | 'float' | 'shake' | 'glow' | 'kenBurns' | 'letterWave'.",
99
100
  "Use a name only on its own type: a fade on 'loop' plays once and leaves the element hidden.",
100
101
  'An unknown name passes validation, logs a console error and does not animate.',
@@ -102,9 +103,9 @@ function build(o) {
102
103
  '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
104
  'An exit plays the same preset backwards, except that move, rise, growTurn and wipe carry on the way they were going.',
104
105
  '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
+ "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, lineRise and lineWipe play rise and wipe on lines, and linePeek slides each line into place behind a wipe's edge, clipped to the line's own row. An exit runs from the last unit back to the first, and a linePeek line carries on the way it came.",
106
107
  '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
+ "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 and linePeek as wipe and letterWave as float.",
108
109
  "blur blurs only 'text', 'image', 'svg', 'video' and 'gif', and any other element only fades.",
109
110
  "glow plays nothing on 'table' and 'group'. kenBurns plays on the crop, so only on 'image', 'svg', 'video' and 'gif'.",
110
111
  'Every other preset plays on every element, groups included.',
@@ -121,6 +122,8 @@ function build(o) {
121
122
  'rise: `strength` 1 travels 5% of the shorter side of the page.',
122
123
  'growTurn: `strength` 1 turns 180 degrees.',
123
124
  "wipe: `direction` 'right' | 'left' | 'up' | 'down', default 'right', the way its edge travels.",
125
+ 'lineWipe: `direction` as wipe; without one, each line wipes in its own reading direction.',
126
+ "linePeek: `direction` 'right' | 'left' | 'up' | 'down', default 'up', the way each line travels.",
124
127
  'blur: `strength` 1 adds 20 to `blurRadius` at its most blurred.',
125
128
  "count: `from`, a number, default 0, where the count starts on 'enter' and ends on 'exit'.",
126
129
  'bounce: `strength` 1 shrinks to a third of the size, and 0.5 to half.',
@@ -495,6 +498,12 @@ function build(o) {
495
498
  .default(true)
496
499
  .describe('Whether to maintain aspect ratio when resizing.'),
497
500
  };
501
+ const lottieShape = {
502
+ ...shapeBase,
503
+ ...imageProps,
504
+ type: z.literal('lottie').describe('Element type identifier.'),
505
+ keepRatio: gifShape.keepRatio,
506
+ };
498
507
  const videoShape = {
499
508
  ...shapeBase,
500
509
  ...imageProps,
@@ -738,6 +747,7 @@ function build(o) {
738
747
  o(lineShape),
739
748
  o(figureShape),
740
749
  o(gifShape),
750
+ o(lottieShape),
741
751
  o(videoShape),
742
752
  o(tableShape),
743
753
  o(groupShape(element)),
@@ -865,6 +875,7 @@ function build(o) {
865
875
  line: lineShape,
866
876
  figure: figureShape,
867
877
  gif: gifShape,
878
+ lottie: lottieShape,
868
879
  video: videoShape,
869
880
  table: tableShape,
870
881
  font: fontShape,
@@ -893,6 +904,7 @@ export const leafSchemas = {
893
904
  line: z.object(lenient.shapes.line),
894
905
  figure: z.object(lenient.shapes.figure),
895
906
  gif: z.object(lenient.shapes.gif),
907
+ lottie: z.object(lenient.shapes.lottie),
896
908
  video: z.object(lenient.shapes.video),
897
909
  table: z.object(lenient.shapes.table),
898
910
  font: z.object(lenient.shapes.font),
package/lib/types.d.ts CHANGED
@@ -86,7 +86,7 @@ export interface Page {
86
86
  /** Elements on this page. */
87
87
  children: Element[];
88
88
  }
89
- export type Element = TextElement | ImageElement | SVGElement | LineElement | VideoElement | FigureElement | GifElement | GroupElement | TableElement;
89
+ export type Element = TextElement | ImageElement | SVGElement | LineElement | VideoElement | FigureElement | GifElement | LottieElement | GroupElement | TableElement;
90
90
  export type ElementType = Element['type'];
91
91
  /**
92
92
  * The JSON Schema's descriptions (`design.schema.json`) are the full reference:
@@ -302,6 +302,9 @@ export interface GifElement extends ShapeAttributes, BaseImageProps {
302
302
  /** Duration in milliseconds. */
303
303
  duration: number;
304
304
  }
305
+ export interface LottieElement extends ShapeAttributes, BaseImageProps {
306
+ type: 'lottie';
307
+ }
305
308
  export interface VideoElement extends ShapeAttributes, BaseImageProps {
306
309
  type: 'video';
307
310
  /** Duration in milliseconds. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polotno/schema",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",
@@ -49,13 +49,12 @@
49
49
  "zod": "^4.6.7"
50
50
  },
51
51
  "devDependencies": {
52
- "typescript": "~6.0.3",
53
- "vitest": "^5.0.5"
52
+ "typescript": "~7.0.2",
53
+ "vitest": "^5.1.0"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "rm -rf lib && tsc && node scripts/generate-schema.mjs && node ../../scripts/check-pack.mjs",
57
- "build:schema": "node scripts/generate-schema.mjs",
58
- "typecheck": "node ../../scripts/typecheck.mjs --noEmit",
57
+ "typecheck": "tsc --noEmit && tsc -p tests/tsconfig.json",
59
58
  "test": "vitest run"
60
59
  }
61
60
  }