visualfries 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.
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/DIContainer.d.ts +4 -0
- package/dist/DIContainer.js +145 -0
- package/dist/SceneBuilder.svelte.d.ts +8574 -0
- package/dist/SceneBuilder.svelte.js +409 -0
- package/dist/adapters/subtitleHelpers.d.ts +2 -0
- package/dist/adapters/subtitleHelpers.js +187 -0
- package/dist/animations/AnimationContext.d.ts +17 -0
- package/dist/animations/AnimationContext.js +72 -0
- package/dist/animations/AnimationPresetsRegister.d.ts +362 -0
- package/dist/animations/AnimationPresetsRegister.js +20 -0
- package/dist/animations/AnimationSetup.d.ts +8 -0
- package/dist/animations/AnimationSetup.js +30 -0
- package/dist/animations/SplitTextCache.d.ts +28 -0
- package/dist/animations/SplitTextCache.js +68 -0
- package/dist/animations/animationBuilder.d.ts +31 -0
- package/dist/animations/animationBuilder.js +255 -0
- package/dist/animations/animationPreset.d.ts +7 -0
- package/dist/animations/animationPreset.js +31 -0
- package/dist/animations/builders/AnimationPresetFactory.d.ts +43 -0
- package/dist/animations/builders/AnimationPresetFactory.js +139 -0
- package/dist/animations/builders/LineHighlighterAnimationBuilder.d.ts +16 -0
- package/dist/animations/builders/LineHighlighterAnimationBuilder.js +183 -0
- package/dist/animations/builders/WordHighlighterAnimationBuilder.d.ts +15 -0
- package/dist/animations/builders/WordHighlighterAnimationBuilder.js +180 -0
- package/dist/animations/engines/AnimationEngineAdaptor.d.ts +107 -0
- package/dist/animations/engines/AnimationEngineAdaptor.js +1 -0
- package/dist/animations/engines/GSAPEngineAdaptor.d.ts +21 -0
- package/dist/animations/engines/GSAPEngineAdaptor.js +145 -0
- package/dist/animations/presets/index.d.ts +2 -0
- package/dist/animations/presets/index.js +3 -0
- package/dist/animations/presets/lines.d.ts +52 -0
- package/dist/animations/presets/lines.js +547 -0
- package/dist/animations/presets/words.d.ts +31 -0
- package/dist/animations/presets/words.js +268 -0
- package/dist/animations/transformers/AnimationReferenceTransformer.d.ts +9 -0
- package/dist/animations/transformers/AnimationReferenceTransformer.js +114 -0
- package/dist/builders/PixiComponentBuilder.d.ts +63 -0
- package/dist/builders/PixiComponentBuilder.js +112 -0
- package/dist/builders/_ComponentState.svelte.d.ts +795 -0
- package/dist/builders/_ComponentState.svelte.js +203 -0
- package/dist/builders/html/HtmlBuilder.d.ts +66 -0
- package/dist/builders/html/HtmlBuilder.js +171 -0
- package/dist/builders/html/HtmlBuilderFactory.d.ts +27 -0
- package/dist/builders/html/HtmlBuilderFactory.js +30 -0
- package/dist/builders/html/StyleBuilder.d.ts +13 -0
- package/dist/builders/html/StyleBuilder.js +133 -0
- package/dist/builders/html/StyleProcessor.d.ts +9 -0
- package/dist/builders/html/StyleProcessor.js +1 -0
- package/dist/builders/html/TextComponentHtmlBuilder.d.ts +16 -0
- package/dist/builders/html/TextComponentHtmlBuilder.js +93 -0
- package/dist/builders/html/TextShadowBuilder.d.ts +60 -0
- package/dist/builders/html/TextShadowBuilder.js +227 -0
- package/dist/builders/html/processors/AppearanceStyleProcessor.d.ts +5 -0
- package/dist/builders/html/processors/AppearanceStyleProcessor.js +57 -0
- package/dist/builders/html/processors/TextAppearanceStyleProcessor.d.ts +5 -0
- package/dist/builders/html/processors/TextAppearanceStyleProcessor.js +37 -0
- package/dist/builders/html/processors/TextEffectsStyleProcessor.d.ts +6 -0
- package/dist/builders/html/processors/TextEffectsStyleProcessor.js +68 -0
- package/dist/commands/Command.d.ts +6 -0
- package/dist/commands/Command.js +1 -0
- package/dist/commands/CommandRunner.d.ts +28 -0
- package/dist/commands/CommandRunner.js +81 -0
- package/dist/commands/CommandTypes.d.ts +11 -0
- package/dist/commands/CommandTypes.js +13 -0
- package/dist/commands/PauseCommand.d.ts +4 -0
- package/dist/commands/PauseCommand.js +5 -0
- package/dist/commands/PlayCommand.d.ts +4 -0
- package/dist/commands/PlayCommand.js +6 -0
- package/dist/commands/RenderCommand.d.ts +15 -0
- package/dist/commands/RenderCommand.js +18 -0
- package/dist/commands/RenderFrameCommand.d.ts +17 -0
- package/dist/commands/RenderFrameCommand.js +93 -0
- package/dist/commands/ReplaceSourceOnTimeCommand.d.ts +4 -0
- package/dist/commands/ReplaceSourceOnTimeCommand.js +22 -0
- package/dist/commands/SeekCommand.d.ts +15 -0
- package/dist/commands/SeekCommand.js +39 -0
- package/dist/commands/UpdateComponentCommand.d.ts +4 -0
- package/dist/commands/UpdateComponentCommand.js +17 -0
- package/dist/components/AnimatedGIF.d.ts +201 -0
- package/dist/components/AnimatedGIF.js +391 -0
- package/dist/components/Component.svelte.d.ts +33 -0
- package/dist/components/Component.svelte.js +152 -0
- package/dist/components/ComponentContext.svelte.d.ts +33 -0
- package/dist/components/ComponentContext.svelte.js +105 -0
- package/dist/components/hooks/AnimationHook.d.ts +25 -0
- package/dist/components/hooks/AnimationHook.js +180 -0
- package/dist/components/hooks/CanvasShapeHook.d.ts +12 -0
- package/dist/components/hooks/CanvasShapeHook.js +229 -0
- package/dist/components/hooks/HtmlAnimationHook.d.ts +8 -0
- package/dist/components/hooks/HtmlAnimationHook.js +70 -0
- package/dist/components/hooks/HtmlTextHook.d.ts +16 -0
- package/dist/components/hooks/HtmlTextHook.js +102 -0
- package/dist/components/hooks/HtmlToCanvasHook.d.ts +16 -0
- package/dist/components/hooks/HtmlToCanvasHook.js +148 -0
- package/dist/components/hooks/ImageHook.d.ts +10 -0
- package/dist/components/hooks/ImageHook.js +45 -0
- package/dist/components/hooks/MediaHook.d.ts +15 -0
- package/dist/components/hooks/MediaHook.js +252 -0
- package/dist/components/hooks/MediaSeekingHook.d.ts +12 -0
- package/dist/components/hooks/MediaSeekingHook.js +204 -0
- package/dist/components/hooks/PixiDisplayObjectHook.d.ts +15 -0
- package/dist/components/hooks/PixiDisplayObjectHook.js +77 -0
- package/dist/components/hooks/PixiGifHook.d.ts +15 -0
- package/dist/components/hooks/PixiGifHook.js +97 -0
- package/dist/components/hooks/PixiProgressShapeHook.d.ts +12 -0
- package/dist/components/hooks/PixiProgressShapeHook.js +128 -0
- package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.d.ts +21 -0
- package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.js +210 -0
- package/dist/components/hooks/PixiTextureHook.d.ts +7 -0
- package/dist/components/hooks/PixiTextureHook.js +29 -0
- package/dist/components/hooks/PixiVideoTextureHook.d.ts +10 -0
- package/dist/components/hooks/PixiVideoTextureHook.js +35 -0
- package/dist/components/hooks/SubtitlesHook.d.ts +88 -0
- package/dist/components/hooks/SubtitlesHook.js +199 -0
- package/dist/components/hooks/VerifyGifHook.d.ts +7 -0
- package/dist/components/hooks/VerifyGifHook.js +27 -0
- package/dist/components/hooks/VerifyImageHook.d.ts +7 -0
- package/dist/components/hooks/VerifyImageHook.js +27 -0
- package/dist/components/hooks/VerifyMediaHook.d.ts +7 -0
- package/dist/components/hooks/VerifyMediaHook.js +21 -0
- package/dist/components/hooks/shapes/progress/CustomProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/CustomProgressRenderer.js +53 -0
- package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.js +69 -0
- package/dist/components/hooks/shapes/progress/LinearProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/LinearProgressRenderer.js +60 -0
- package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.d.ts +9 -0
- package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.js +213 -0
- package/dist/components/hooks/shapes/progress/ProgressRenderer.d.ts +17 -0
- package/dist/components/hooks/shapes/progress/ProgressRenderer.js +75 -0
- package/dist/components/hooks/shapes/progress/RadialProgressRenderer.d.ts +8 -0
- package/dist/components/hooks/shapes/progress/RadialProgressRenderer.js +50 -0
- package/dist/components/hooks/shapes/progress/index.d.ts +6 -0
- package/dist/components/hooks/shapes/progress/index.js +6 -0
- package/dist/composers/componentComposer.d.ts +55 -0
- package/dist/composers/componentComposer.js +118 -0
- package/dist/composers/layerComposer.d.ts +46 -0
- package/dist/composers/layerComposer.js +79 -0
- package/dist/composers/sceneComposer.d.ts +48 -0
- package/dist/composers/sceneComposer.js +92 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +14 -0
- package/dist/directors/ComponentDirector.d.ts +20 -0
- package/dist/directors/ComponentDirector.js +86 -0
- package/dist/factories/SceneBuilderFactory.d.ts +15 -0
- package/dist/factories/SceneBuilderFactory.js +51 -0
- package/dist/fonts/GoogleFontsProvider.d.ts +12 -0
- package/dist/fonts/GoogleFontsProvider.js +125 -0
- package/dist/fonts/fontLoader.d.ts +15 -0
- package/dist/fonts/fontLoader.js +41 -0
- package/dist/fonts/types.d.ts +1 -0
- package/dist/fonts/types.js +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +14 -0
- package/dist/layers/Layer.svelte.d.ts +8492 -0
- package/dist/layers/Layer.svelte.js +125 -0
- package/dist/managers/AppManager.svelte.d.ts +23 -0
- package/dist/managers/AppManager.svelte.js +89 -0
- package/dist/managers/ComponentsManager.svelte.d.ts +49 -0
- package/dist/managers/ComponentsManager.svelte.js +247 -0
- package/dist/managers/DomManager.d.ts +18 -0
- package/dist/managers/DomManager.js +73 -0
- package/dist/managers/EventManager.d.ts +7 -0
- package/dist/managers/EventManager.js +22 -0
- package/dist/managers/LayersManager.svelte.d.ts +8499 -0
- package/dist/managers/LayersManager.svelte.js +176 -0
- package/dist/managers/MediaManager.d.ts +32 -0
- package/dist/managers/MediaManager.js +243 -0
- package/dist/managers/RenderManager.d.ts +23 -0
- package/dist/managers/RenderManager.js +59 -0
- package/dist/managers/StateManager.svelte.d.ts +8746 -0
- package/dist/managers/StateManager.svelte.js +272 -0
- package/dist/managers/SubtitlesManager.svelte.d.ts +261 -0
- package/dist/managers/SubtitlesManager.svelte.js +1385 -0
- package/dist/managers/TimeManager.svelte.d.ts +6 -0
- package/dist/managers/TimeManager.svelte.js +18 -0
- package/dist/managers/TimelineManager.svelte.d.ts +25 -0
- package/dist/managers/TimelineManager.svelte.js +152 -0
- package/dist/registers.d.ts +12 -0
- package/dist/registers.js +29 -0
- package/dist/schemas/runtime/index.d.ts +3 -0
- package/dist/schemas/runtime/index.js +4 -0
- package/dist/schemas/runtime/types.d.ts +323 -0
- package/dist/schemas/runtime/types.js +12 -0
- package/dist/schemas/scene/animations.d.ts +89738 -0
- package/dist/schemas/scene/animations.js +211 -0
- package/dist/schemas/scene/components.js +515 -0
- package/dist/schemas/scene/core.js +160 -0
- package/dist/schemas/scene/index.d.ts +22 -0
- package/dist/schemas/scene/index.js +10 -0
- package/dist/schemas/scene/properties.d.ts +914 -0
- package/dist/schemas/scene/properties.js +398 -0
- package/dist/schemas/scene/subtitles.d.ts +1141 -0
- package/dist/schemas/scene/subtitles.js +111 -0
- package/dist/schemas/scene/utils.d.ts +1 -0
- package/dist/schemas/scene/utils.js +5 -0
- package/dist/seeds/SeedFactory.d.ts +59 -0
- package/dist/seeds/SeedFactory.js +99 -0
- package/dist/seeds/index.d.ts +8 -0
- package/dist/seeds/index.js +8 -0
- package/dist/transformers/ColorTransformer.d.ts +5 -0
- package/dist/transformers/ColorTransformer.js +67 -0
- package/dist/transformers/PixiColorTransformer.d.ts +22 -0
- package/dist/transformers/PixiColorTransformer.js +104 -0
- package/dist/utils/canvas.d.ts +6 -0
- package/dist/utils/canvas.js +18 -0
- package/dist/utils/document.d.ts +2 -0
- package/dist/utils/document.js +36 -0
- package/dist/utils/emoji.d.ts +10 -0
- package/dist/utils/emoji.js +51 -0
- package/dist/utils/html.d.ts +4 -0
- package/dist/utils/html.js +45 -0
- package/dist/utils/svgGenerator.d.ts +20 -0
- package/dist/utils/svgGenerator.js +103 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +125 -0
- package/package.json +96 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { isValidColor } from './utils.js';
|
|
3
|
+
// Utility functions
|
|
4
|
+
const toFixed3 = (val) => parseFloat(val.toFixed(3));
|
|
5
|
+
const toFixed3Optional = (val) => {
|
|
6
|
+
if (val === undefined || val === null)
|
|
7
|
+
return val;
|
|
8
|
+
return parseFloat(val.toFixed(3));
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Gradient definition schema
|
|
12
|
+
* Defines properties for both linear and radial gradients
|
|
13
|
+
*/
|
|
14
|
+
export const GradientDefinitionShape = z.object({
|
|
15
|
+
/** Gradient type */
|
|
16
|
+
type: z.enum(['linear', 'radial']),
|
|
17
|
+
/** Array of color strings */
|
|
18
|
+
colors: z.array(z.string().refine(isValidColor, { message: 'Invalid gradient color' })).min(2),
|
|
19
|
+
/** Optional array of stop positions (0-1) matching colors */
|
|
20
|
+
stops: z.array(z.number().min(0).max(100)).optional(),
|
|
21
|
+
/** Angle in degrees (for linear gradients) */
|
|
22
|
+
angle: z.number().min(-360).max(360).optional(),
|
|
23
|
+
/** Position description (for radial gradients) */
|
|
24
|
+
position: z.string().optional(),
|
|
25
|
+
/** Shape type (for radial gradients) */
|
|
26
|
+
shape: z.enum(['ellipse', 'circle']).optional()
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Color type that can be either a string or a gradient object
|
|
30
|
+
*/
|
|
31
|
+
export const ColorTypeShape = z.union([
|
|
32
|
+
z.string().refine(isValidColor, { message: 'Invalid color format' }),
|
|
33
|
+
GradientDefinitionShape
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* Position property schema
|
|
37
|
+
* Defines the position of a component within the scene
|
|
38
|
+
*/
|
|
39
|
+
export const PositionShape = z.object({
|
|
40
|
+
/** X-coordinate position (from left) */
|
|
41
|
+
x: z.number(),
|
|
42
|
+
/** Y-coordinate position (from top) */
|
|
43
|
+
y: z.number(),
|
|
44
|
+
/** Rotation in degrees */
|
|
45
|
+
rotation: z.number().default(0),
|
|
46
|
+
/** Anchor point for transformations (0,0 is top-left, 1,1 is bottom-right) */
|
|
47
|
+
anchor: z
|
|
48
|
+
.object({
|
|
49
|
+
x: z.number().min(0).max(1).default(0.5),
|
|
50
|
+
y: z.number().min(0).max(1).default(0.5)
|
|
51
|
+
})
|
|
52
|
+
.default({ x: 0.5, y: 0.5 })
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Size property schema
|
|
56
|
+
* Defines the dimensions of a component
|
|
57
|
+
*/
|
|
58
|
+
export const SizeShape = z.object({
|
|
59
|
+
/** Width in pixels */
|
|
60
|
+
width: z.number().positive(),
|
|
61
|
+
/** Height in pixels */
|
|
62
|
+
height: z.number().positive(),
|
|
63
|
+
/** Uniform scale factor */
|
|
64
|
+
scale: z.number().positive().default(1),
|
|
65
|
+
/** Whether to maintain aspect ratio when resizing */
|
|
66
|
+
maintainAspectRatio: z.boolean().default(true),
|
|
67
|
+
/** Original dimensions before any transformations */
|
|
68
|
+
original: z
|
|
69
|
+
.object({
|
|
70
|
+
width: z.number().positive().optional(),
|
|
71
|
+
height: z.number().positive().optional()
|
|
72
|
+
})
|
|
73
|
+
.optional()
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Transform property schema
|
|
77
|
+
* Defines additional transformations beyond basic position and size
|
|
78
|
+
*/
|
|
79
|
+
export const TransformShape = z.object({
|
|
80
|
+
/** Horizontal scale factor (1 = 100%) */
|
|
81
|
+
scaleX: z.number().default(1),
|
|
82
|
+
/** Vertical scale factor (1 = 100%) */
|
|
83
|
+
scaleY: z.number().default(1),
|
|
84
|
+
/** Horizontal skew in degrees */
|
|
85
|
+
skewX: z.number().default(0),
|
|
86
|
+
/** Vertical skew in degrees */
|
|
87
|
+
skewY: z.number().default(0),
|
|
88
|
+
/** Origin point for transformations */
|
|
89
|
+
transformOrigin: z
|
|
90
|
+
.object({
|
|
91
|
+
x: z.number().min(0).max(1).default(0.5),
|
|
92
|
+
y: z.number().min(0).max(1).default(0.5)
|
|
93
|
+
})
|
|
94
|
+
.optional()
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Shadow effect schema
|
|
98
|
+
*/
|
|
99
|
+
export const ShadowShape = z.object({
|
|
100
|
+
enabled: z.boolean().default(true).optional(),
|
|
101
|
+
/** Optional preset name */
|
|
102
|
+
preset: z.string().optional(),
|
|
103
|
+
/** Shadow color */
|
|
104
|
+
color: z.string().refine(isValidColor, { message: 'Invalid shadow color format' }).optional(),
|
|
105
|
+
/** Shadow blur radius in pixels */
|
|
106
|
+
blur: z.number().min(0).optional(),
|
|
107
|
+
/** Shadow size in pixels */
|
|
108
|
+
size: z.number().optional(),
|
|
109
|
+
/** Horizontal offset in pixels */
|
|
110
|
+
offsetX: z.number().optional(),
|
|
111
|
+
/** Vertical offset in pixels */
|
|
112
|
+
offsetY: z.number().optional(),
|
|
113
|
+
/** Shadow opacity (0-1) */
|
|
114
|
+
opacity: z.number().min(0).max(1).optional() // Keep opacity, useful even with presets
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Outline/Stroke effect schema
|
|
118
|
+
*/
|
|
119
|
+
export const OutlineShape = z.object({
|
|
120
|
+
enabled: z.boolean().default(true).optional(),
|
|
121
|
+
/** Optional preset name */
|
|
122
|
+
preset: z.string().optional(),
|
|
123
|
+
/** Outline color */
|
|
124
|
+
color: z.string().refine(isValidColor, { message: 'Invalid outline color format' }),
|
|
125
|
+
/** Outline width in pixels */
|
|
126
|
+
size: z.number().min(0).optional(),
|
|
127
|
+
/** Outline opacity (0-1) */
|
|
128
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
129
|
+
/** Outline style (Note: style/dashArray not in schema-llm.md, maybe remove?) */
|
|
130
|
+
style: z.enum(['solid', 'dashed', 'dotted']).default('solid').optional(),
|
|
131
|
+
/** Custom dash pattern (only for 'dashed' style) */
|
|
132
|
+
dashArray: z.array(z.number()).optional()
|
|
133
|
+
});
|
|
134
|
+
/**
|
|
135
|
+
* Font size with unit schema
|
|
136
|
+
*/
|
|
137
|
+
export const FontSizeShape = z.object({
|
|
138
|
+
/** Font size value */
|
|
139
|
+
value: z.number().positive(),
|
|
140
|
+
/** Font size unit */
|
|
141
|
+
unit: z.enum(['px', 'em', 'rem', '%']).default('px')
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* Line height with unit schema
|
|
145
|
+
*/
|
|
146
|
+
export const LineHeightShape = z.object({
|
|
147
|
+
/** Line height value */
|
|
148
|
+
value: z.number().positive(),
|
|
149
|
+
/** Line height unit */
|
|
150
|
+
unit: z.enum(['normal', 'px', 'em', '%']).default('normal')
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Color with opacity schema
|
|
154
|
+
*/
|
|
155
|
+
export const ColorWithOpacityShape = z.object({
|
|
156
|
+
/** Color value (hex, rgb, rgba, etc.) */
|
|
157
|
+
color: z.string().refine(isValidColor, { message: 'Invalid color format' }),
|
|
158
|
+
/** Opacity (0-1) */
|
|
159
|
+
opacity: z.number().min(0).max(1).default(1)
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* Gradient stop schema
|
|
163
|
+
*/
|
|
164
|
+
export const GradientStopShape = z.object({
|
|
165
|
+
/** Color value */
|
|
166
|
+
color: z.string().refine(isValidColor, { message: 'Invalid gradient color format' }),
|
|
167
|
+
/** Position in the gradient (0-1) */
|
|
168
|
+
position: z.number().min(0).max(1),
|
|
169
|
+
/** Opacity (0-1) */
|
|
170
|
+
opacity: z.number().min(0).max(1).default(1)
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Gradient background schema
|
|
174
|
+
*/
|
|
175
|
+
export const GradientShape = z.object({
|
|
176
|
+
/** Gradient type */
|
|
177
|
+
type: z.enum(['linear', 'radial']),
|
|
178
|
+
/** Gradient stops */
|
|
179
|
+
stops: z.array(GradientStopShape).min(2),
|
|
180
|
+
/** Angle in degrees (for linear gradients) */
|
|
181
|
+
angle: z.number().min(0).max(360).default(0).optional(),
|
|
182
|
+
/** Center position (for radial gradients) */
|
|
183
|
+
center: z
|
|
184
|
+
.object({
|
|
185
|
+
x: z.number().min(0).max(1).default(0.5),
|
|
186
|
+
y: z.number().min(0).max(1).default(0.5)
|
|
187
|
+
})
|
|
188
|
+
.optional()
|
|
189
|
+
});
|
|
190
|
+
/**
|
|
191
|
+
* Animation timing schema
|
|
192
|
+
* Defines timing properties for animations
|
|
193
|
+
*/
|
|
194
|
+
export const AnimationTimingShape = z.object({
|
|
195
|
+
/** Delay before animation starts (in seconds) */
|
|
196
|
+
delay: z.number().min(0).default(0),
|
|
197
|
+
/** Animation duration (in seconds) */
|
|
198
|
+
duration: z.number().min(0).default(1).transform(toFixed3),
|
|
199
|
+
/** Number of times the animation repeats (-1 for infinite) */
|
|
200
|
+
repeat: z.number().int().default(0),
|
|
201
|
+
/** Delay between animation repetitions (in seconds) */
|
|
202
|
+
repeatDelay: z.number().min(0).default(0),
|
|
203
|
+
/** Time between successive animations in seconds (for staggered animations) */
|
|
204
|
+
stagger: z.number().min(0).default(0),
|
|
205
|
+
/** Whether to reverse the animation on alternate repeats */
|
|
206
|
+
yoyo: z.boolean().default(false)
|
|
207
|
+
});
|
|
208
|
+
/**
|
|
209
|
+
* Animation easing schema
|
|
210
|
+
* Defines how animations accelerate and decelerate
|
|
211
|
+
*/
|
|
212
|
+
export const AnimationEasingShape = z.union([
|
|
213
|
+
// Predefined easing functions
|
|
214
|
+
z.enum([
|
|
215
|
+
'linear',
|
|
216
|
+
'power1.in',
|
|
217
|
+
'power1.out',
|
|
218
|
+
'power1.inOut',
|
|
219
|
+
'power2.in',
|
|
220
|
+
'power2.out',
|
|
221
|
+
'power2.inOut',
|
|
222
|
+
'power3.in',
|
|
223
|
+
'power3.out',
|
|
224
|
+
'power3.inOut',
|
|
225
|
+
'power4.in',
|
|
226
|
+
'power4.out',
|
|
227
|
+
'power4.inOut',
|
|
228
|
+
'back.in',
|
|
229
|
+
'back.out',
|
|
230
|
+
'back.inOut',
|
|
231
|
+
'elastic.in',
|
|
232
|
+
'elastic.out',
|
|
233
|
+
'elastic.inOut',
|
|
234
|
+
'bounce.in',
|
|
235
|
+
'bounce.out',
|
|
236
|
+
'bounce.inOut',
|
|
237
|
+
'circ.in',
|
|
238
|
+
'circ.out',
|
|
239
|
+
'circ.inOut',
|
|
240
|
+
'expo.in',
|
|
241
|
+
'expo.out',
|
|
242
|
+
'expo.inOut',
|
|
243
|
+
'sine.in',
|
|
244
|
+
'sine.out',
|
|
245
|
+
'sine.inOut'
|
|
246
|
+
]),
|
|
247
|
+
// Custom cubic-bezier
|
|
248
|
+
z.object({
|
|
249
|
+
type: z.literal('cubicBezier'),
|
|
250
|
+
x1: z.number().min(0).max(1),
|
|
251
|
+
y1: z.number(),
|
|
252
|
+
x2: z.number().min(0).max(1),
|
|
253
|
+
y2: z.number()
|
|
254
|
+
})
|
|
255
|
+
]);
|
|
256
|
+
/**
|
|
257
|
+
* Keyframe schema
|
|
258
|
+
* Defines a single keyframe in an animation
|
|
259
|
+
*/
|
|
260
|
+
export const KeyframeShape = z.object({
|
|
261
|
+
/** Time position in seconds relative to animation start */
|
|
262
|
+
time: z.number().min(0).transform(toFixed3),
|
|
263
|
+
/** Target property values at this keyframe */
|
|
264
|
+
value: z.record(z.union([z.string(), z.number(), z.boolean()])),
|
|
265
|
+
/** Easing to use when transitioning to this keyframe */
|
|
266
|
+
easing: AnimationEasingShape.optional()
|
|
267
|
+
});
|
|
268
|
+
/**
|
|
269
|
+
* Animation target schema
|
|
270
|
+
* Defines what elements an animation affects
|
|
271
|
+
*/
|
|
272
|
+
export const AnimationTargetShape = z.enum([
|
|
273
|
+
'element', // The entire element
|
|
274
|
+
'words', // Individual words (for text)
|
|
275
|
+
'lines', // Lines of text
|
|
276
|
+
'chars', // Individual characters (for text)
|
|
277
|
+
'transform', // Just transform properties
|
|
278
|
+
'opacity', // Just opacity
|
|
279
|
+
'position', // Just position
|
|
280
|
+
'size' // Just size
|
|
281
|
+
]);
|
|
282
|
+
/**
|
|
283
|
+
* Enhanced animation schema
|
|
284
|
+
* Comprehensive definition of an animation
|
|
285
|
+
*/
|
|
286
|
+
export const EnhancedAnimationShape = z.object({
|
|
287
|
+
/** Unique identifier */
|
|
288
|
+
id: z.string().max(255),
|
|
289
|
+
/** Animation name */
|
|
290
|
+
name: z.string().max(255),
|
|
291
|
+
/** Animation type */
|
|
292
|
+
type: z.enum(['preset', 'custom', 'keyframe']),
|
|
293
|
+
/** Preset identifier (for preset animations) */
|
|
294
|
+
presetId: z.string().max(255).optional(),
|
|
295
|
+
/** What the animation targets */
|
|
296
|
+
target: AnimationTargetShape.default('element'),
|
|
297
|
+
/** Animation timing properties */
|
|
298
|
+
timing: AnimationTimingShape.default({}),
|
|
299
|
+
/** Animation easing */
|
|
300
|
+
easing: AnimationEasingShape.default('power2.out'),
|
|
301
|
+
/** For keyframe animations: the keyframes */
|
|
302
|
+
keyframes: z.array(KeyframeShape).optional(),
|
|
303
|
+
/** Whether animation plays automatically */
|
|
304
|
+
autoplay: z.boolean().default(true),
|
|
305
|
+
/** Whether to preserve transform styles that aren't explicitly animated */
|
|
306
|
+
preserveTransform: z.boolean().default(true),
|
|
307
|
+
/** Additional animation parameters */
|
|
308
|
+
parameters: z.record(z.unknown()).optional()
|
|
309
|
+
});
|
|
310
|
+
/**
|
|
311
|
+
* Transition schema
|
|
312
|
+
* Defines a transition between two components or states
|
|
313
|
+
*/
|
|
314
|
+
export const TransitionShape = z.object({
|
|
315
|
+
/** Unique identifier */
|
|
316
|
+
id: z.string().max(255),
|
|
317
|
+
/** Transition name */
|
|
318
|
+
name: z.string().max(255).optional(),
|
|
319
|
+
/** Source component ID */
|
|
320
|
+
fromComponentId: z.string().max(255),
|
|
321
|
+
/** Target component ID */
|
|
322
|
+
toComponentId: z.string().max(255),
|
|
323
|
+
/** Transition type */
|
|
324
|
+
type: z.enum(['fade', 'slide', 'zoom', 'wipe', 'custom', 'preset']),
|
|
325
|
+
/** Preset identifier (for preset transitions) */
|
|
326
|
+
presetId: z.string().optional(),
|
|
327
|
+
/** Transition duration in seconds */
|
|
328
|
+
duration: z.number().min(0).max(72000).transform(toFixed3),
|
|
329
|
+
/** Transition direction (for directional transitions) */
|
|
330
|
+
direction: z.enum(['left', 'right', 'up', 'down', 'in', 'out']).optional(),
|
|
331
|
+
/** Transition easing */
|
|
332
|
+
easing: AnimationEasingShape.default('power2.inOut'),
|
|
333
|
+
/** Additional transition parameters */
|
|
334
|
+
parameters: z.record(z.unknown()).optional()
|
|
335
|
+
});
|
|
336
|
+
/**
|
|
337
|
+
* Effect schema base
|
|
338
|
+
* Base schema for all effects
|
|
339
|
+
*/
|
|
340
|
+
export const EffectBaseShape = z.object({
|
|
341
|
+
/** Effect type */
|
|
342
|
+
type: z.string(),
|
|
343
|
+
/** Whether the effect is enabled */
|
|
344
|
+
enabled: z.boolean().default(true).optional(),
|
|
345
|
+
/** Effect intensity (0-1) */
|
|
346
|
+
intensity: z.number().min(0).max(1).default(1),
|
|
347
|
+
/** Effect mix blend mode */
|
|
348
|
+
blendMode: z
|
|
349
|
+
.enum([
|
|
350
|
+
'normal',
|
|
351
|
+
'multiply',
|
|
352
|
+
'screen',
|
|
353
|
+
'overlay',
|
|
354
|
+
'darken',
|
|
355
|
+
'lighten',
|
|
356
|
+
'color-dodge',
|
|
357
|
+
'color-burn',
|
|
358
|
+
'hard-light',
|
|
359
|
+
'soft-light',
|
|
360
|
+
'difference',
|
|
361
|
+
'exclusion',
|
|
362
|
+
'hue',
|
|
363
|
+
'saturation',
|
|
364
|
+
'color',
|
|
365
|
+
'luminosity'
|
|
366
|
+
])
|
|
367
|
+
.default('normal')
|
|
368
|
+
});
|
|
369
|
+
/**
|
|
370
|
+
* Blur effect schema
|
|
371
|
+
*/
|
|
372
|
+
export const BlurEffectShape = EffectBaseShape.extend({
|
|
373
|
+
type: z.literal('blur'),
|
|
374
|
+
/** Blur radius in pixels */
|
|
375
|
+
radius: z.number().min(0).default(5)
|
|
376
|
+
});
|
|
377
|
+
/**
|
|
378
|
+
* Color adjustment effect schema
|
|
379
|
+
*/
|
|
380
|
+
export const ColorAdjustmentEffectShape = EffectBaseShape.extend({
|
|
381
|
+
type: z.literal('colorAdjustment'),
|
|
382
|
+
/** Brightness adjustment (-1 to 1) */
|
|
383
|
+
brightness: z.number().min(-1).max(1).default(0),
|
|
384
|
+
/** Contrast adjustment (-1 to 1) */
|
|
385
|
+
contrast: z.number().min(-1).max(1).default(0),
|
|
386
|
+
/** Saturation adjustment (-1 to 1) */
|
|
387
|
+
saturation: z.number().min(-1).max(1).default(0),
|
|
388
|
+
/** Hue rotation in degrees (0-360) */
|
|
389
|
+
hue: z.number().min(0).max(360).default(0)
|
|
390
|
+
});
|
|
391
|
+
/**
|
|
392
|
+
* Union of all effect types
|
|
393
|
+
*/
|
|
394
|
+
export const EffectShape = z.discriminatedUnion('type', [
|
|
395
|
+
BlurEffectShape,
|
|
396
|
+
ColorAdjustmentEffectShape
|
|
397
|
+
// Additional effect schemas can be added here
|
|
398
|
+
]);
|