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,211 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Utility for numbers that might be strings (e.g., "50%") or actual numbers
|
|
3
|
+
const numberOrStringPercentage = z.union([z.number(), z.string().regex(/^(\d+(\.\d+)?%?)$/)]);
|
|
4
|
+
const PropertyFromDataShape = z.object({
|
|
5
|
+
fromData: z.string(),
|
|
6
|
+
mode: z.enum(['cycle', 'useFallback', 'clamp']).optional().default('cycle'),
|
|
7
|
+
fallbackValue: z.any().optional() // Can be any type, as property values vary
|
|
8
|
+
});
|
|
9
|
+
const DynamicByIndexValueShape = z.object({
|
|
10
|
+
/**
|
|
11
|
+
* Specifies that the value should be determined dynamically, typically based on an element's index.
|
|
12
|
+
*/
|
|
13
|
+
type: z.literal('byIndex'),
|
|
14
|
+
/**
|
|
15
|
+
* A string representation of a JavaScript expression to be evaluated for each target element.
|
|
16
|
+
* This expression can use 'index' (the current element's index in the target list)
|
|
17
|
+
* and 'data' (the entire animation preset's resolved data context).
|
|
18
|
+
* Example: "index % 2 === 0 ? 100 : 50"
|
|
19
|
+
* Example: "data.baseValue + index * 10"
|
|
20
|
+
*/
|
|
21
|
+
expression: z.string(),
|
|
22
|
+
/**
|
|
23
|
+
* An optional fallback value to be used if the expression evaluation fails
|
|
24
|
+
* or if the expression itself is invalid.
|
|
25
|
+
*/
|
|
26
|
+
fallbackValue: z.any().optional()
|
|
27
|
+
});
|
|
28
|
+
const PropertyValueShape = z.union([
|
|
29
|
+
z.string(),
|
|
30
|
+
z.number(),
|
|
31
|
+
z.boolean(),
|
|
32
|
+
z.null(), // Direct primitive values
|
|
33
|
+
PropertyFromDataShape, // For { fromData: "key", mode?, fallbackValue? }
|
|
34
|
+
DynamicByIndexValueShape // For { type: "byIndex", expression: "..." }
|
|
35
|
+
]);
|
|
36
|
+
// === Stagger Definition ===
|
|
37
|
+
const StaggerObjectShape = z
|
|
38
|
+
.object({
|
|
39
|
+
type: z.literal('fromData').optional(), // Only "fromData" has a special type currently
|
|
40
|
+
dataKey: z.string().optional(), // Required if type is "fromData"
|
|
41
|
+
referencePoint: z.literal('tweenStart').optional(), // Mostly for "fromData"
|
|
42
|
+
each: z.number().optional(),
|
|
43
|
+
from: z.union([z.string(), z.number()]).optional(), // "start", "center", "end", "edges", "random", index
|
|
44
|
+
grid: z
|
|
45
|
+
.tuple([z.union([z.literal('auto'), z.number()]), z.union([z.literal('auto'), z.number()])])
|
|
46
|
+
.optional(),
|
|
47
|
+
axis: z.enum(['x', 'y']).optional(),
|
|
48
|
+
ease: z.string().optional(), // Easing function string
|
|
49
|
+
amount: z.number().optional()
|
|
50
|
+
})
|
|
51
|
+
.refine((data) => !(data.type === 'fromData' && !data.dataKey), {
|
|
52
|
+
message: "dataKey is required when stagger type is 'fromData'",
|
|
53
|
+
path: ['dataKey']
|
|
54
|
+
});
|
|
55
|
+
const StaggerShape = z.union([
|
|
56
|
+
z.number(), // Shorthand for { each: <number> }
|
|
57
|
+
StaggerObjectShape
|
|
58
|
+
]);
|
|
59
|
+
const BaseAnimatableProperties = z
|
|
60
|
+
.object({
|
|
61
|
+
opacity: PropertyValueShape.optional(),
|
|
62
|
+
x: PropertyValueShape.optional(),
|
|
63
|
+
y: PropertyValueShape.optional(),
|
|
64
|
+
scale: PropertyValueShape.optional(),
|
|
65
|
+
scaleX: PropertyValueShape.optional(),
|
|
66
|
+
scaleY: PropertyValueShape.optional(),
|
|
67
|
+
rotation: PropertyValueShape.optional(),
|
|
68
|
+
width: PropertyValueShape.optional(),
|
|
69
|
+
height: PropertyValueShape.optional(),
|
|
70
|
+
color: PropertyValueShape.optional()
|
|
71
|
+
// ... add more common animatable properties explicitly
|
|
72
|
+
})
|
|
73
|
+
.catchall(PropertyValueShape); // ANY other property added here must also be a PropertyValueShape
|
|
74
|
+
// TweenVarsShape defines the structure of the 'vars' object for a tween
|
|
75
|
+
const TweenVarsShape = z
|
|
76
|
+
.object({
|
|
77
|
+
// Explicitly define 'from' as an object whose values are animatable properties
|
|
78
|
+
from: BaseAnimatableProperties.optional(),
|
|
79
|
+
// Tween control properties (not animatable states themselves, but control the tween)
|
|
80
|
+
duration: PropertyValueShape.optional(), // Can be a number, or fromData for dynamic duration
|
|
81
|
+
ease: z.string().optional(),
|
|
82
|
+
delay: PropertyValueShape.optional(), // Can be a number, or fromData
|
|
83
|
+
stagger: StaggerShape.optional()
|
|
84
|
+
// Add other GSAP control params like repeat, yoyo, overwrite etc. explicitly if needed
|
|
85
|
+
// repeat: z.number().optional(),
|
|
86
|
+
// yoyo: z.boolean().optional(),
|
|
87
|
+
// For all other properties at this level (the "to" state or direct state for "set"/"from"),
|
|
88
|
+
// they should conform to BaseAnimatableProperties. We use .merge() or handle them with a catchall
|
|
89
|
+
// A simpler way is to use .catchall() here and ensure 'from', 'duration', etc. are NOT PropertyValueShape.
|
|
90
|
+
// Let's try with making the "to" state properties part of the catchall.
|
|
91
|
+
})
|
|
92
|
+
.catchall(z.any()); // This catchall is for the 'to' properties like opacity, x, y etc.
|
|
93
|
+
// Refinement to ensure the catchall doesn't incorrectly try to validate our specific control properties
|
|
94
|
+
// or 'from' as if they were simple PropertyValueShapes.
|
|
95
|
+
const FinalTweenVarsShape = TweenVarsShape.refine((vars) => {
|
|
96
|
+
const knownControlKeys = [
|
|
97
|
+
'from',
|
|
98
|
+
'duration',
|
|
99
|
+
'ease',
|
|
100
|
+
'delay',
|
|
101
|
+
'stagger' /* add other known controls like repeat, yoyo */
|
|
102
|
+
];
|
|
103
|
+
for (const key in vars) {
|
|
104
|
+
if (knownControlKeys.includes(key)) {
|
|
105
|
+
// Validation for these known keys is handled by their explicit Shape definitions
|
|
106
|
+
// (e.g., 'from' is BaseAnimatableProperties, 'stagger' is StaggerShape)
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// For any other key (which should be an animatable "to" property),
|
|
110
|
+
// it must conform to PropertyValueShape (which is handled by the .catchall).
|
|
111
|
+
// This refine is more about being explicit; the catchall *should* work,
|
|
112
|
+
// but the previous error indicates a conflict in how Zod resolves the index signature.
|
|
113
|
+
// The key is that 'from' itself is NOT a PropertyValueShape, its *contents* are.
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}).refine((vars) => {
|
|
117
|
+
// This is the original refine for 'from' being required with 'fromTo'
|
|
118
|
+
// This refine should be on TweenDefinitionShape, as it needs 'method'
|
|
119
|
+
return true;
|
|
120
|
+
});
|
|
121
|
+
// === Position Definition ===
|
|
122
|
+
const PositionObjectShape = z.object({
|
|
123
|
+
anchor: z.string(), // "componentStart", "componentEnd", "componentCenter", or a timeline item ID
|
|
124
|
+
anchorPoint: z.enum(['start', 'end']).optional(), // Only if anchor is another timeline item id
|
|
125
|
+
alignTween: z.enum(['start', 'end', 'center']).optional().default('start'),
|
|
126
|
+
offset: z
|
|
127
|
+
.string()
|
|
128
|
+
.regex(/^[+\-]?\d+(\.\d+)?s?$/)
|
|
129
|
+
.optional()
|
|
130
|
+
.default('0s') // e.g., "0s", "+=0.5s", "-1s"
|
|
131
|
+
});
|
|
132
|
+
const AnimationTimelinePositionShape = z.union([
|
|
133
|
+
z.string(), // Time value, label, relative position, "in", "out"
|
|
134
|
+
z.number(), // Time value, label, relative position, "in", "out"
|
|
135
|
+
PositionObjectShape
|
|
136
|
+
]);
|
|
137
|
+
const TweenDefinitionShape = z
|
|
138
|
+
.object({
|
|
139
|
+
method: z.enum(['to', 'from', 'fromTo', 'set']),
|
|
140
|
+
position: AnimationTimelinePositionShape.optional(),
|
|
141
|
+
vars: FinalTweenVarsShape // Use the refined Shape
|
|
142
|
+
})
|
|
143
|
+
.refine((data) => {
|
|
144
|
+
if (data.method === 'fromTo' && !data.vars.from) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (data.method !== 'fromTo' && data.vars.from !== undefined) {
|
|
148
|
+
// Optionally make this an error:
|
|
149
|
+
// console.warn(`'vars.from' is only applicable when method is 'fromTo'. Found with method '${data.method}'.`);
|
|
150
|
+
// return false;
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}, {
|
|
154
|
+
message: "'vars.from' is required when method is 'fromTo' (and only then).",
|
|
155
|
+
path: ['vars', 'from'] // More specific path
|
|
156
|
+
});
|
|
157
|
+
export const KeyframeAnimationShape = z.object({
|
|
158
|
+
/** Identifier for this keyframe-like animation definition */
|
|
159
|
+
id: z.string().optional(), // Optional if it's an inline anonymous definition
|
|
160
|
+
/** The single tween definition that constitutes this animation */
|
|
161
|
+
tween: TweenDefinitionShape, // Using your existing TweenDefinitionShape
|
|
162
|
+
/**
|
|
163
|
+
* Optional target for this single tween.
|
|
164
|
+
* Defaults to "container" if not specified.
|
|
165
|
+
*/
|
|
166
|
+
target: z.string().default('container').optional()
|
|
167
|
+
// revertAfterComplete: z.boolean().optional().default(false), // this probably does not make sense here
|
|
168
|
+
});
|
|
169
|
+
// === Timeline Item Definition ===
|
|
170
|
+
const AnimationSequenceItemShape = z.object({
|
|
171
|
+
id: z.string().optional(),
|
|
172
|
+
target: z.string().optional(), // "container", "words", "lines", "chars", or CSS selector
|
|
173
|
+
position: AnimationTimelinePositionShape.optional(),
|
|
174
|
+
tweens: z.array(TweenDefinitionShape).min(1)
|
|
175
|
+
});
|
|
176
|
+
// === Setup Step Definition ===
|
|
177
|
+
const SetupStylePropertiesShape = z.object({}).catchall(PropertyValueShape);
|
|
178
|
+
const SetupStepBaseShape = z.object({
|
|
179
|
+
type: z.string()
|
|
180
|
+
// target: z.string().optional(), // If you add specific targeting for setup steps
|
|
181
|
+
});
|
|
182
|
+
const SetupStyleStepShape = SetupStepBaseShape.extend({
|
|
183
|
+
type: z.literal('style'),
|
|
184
|
+
properties: SetupStylePropertiesShape
|
|
185
|
+
});
|
|
186
|
+
const SetupSplitTextStepShape = SetupStepBaseShape.extend({
|
|
187
|
+
type: z.literal('splitText'),
|
|
188
|
+
by: z.enum(['words', 'lines', 'chars'])
|
|
189
|
+
});
|
|
190
|
+
const SetupStepShape = z.discriminatedUnion('type', [
|
|
191
|
+
SetupStyleStepShape,
|
|
192
|
+
SetupSplitTextStepShape
|
|
193
|
+
// ... add other setup step types here
|
|
194
|
+
]);
|
|
195
|
+
// === Root Animation Preset Shape ===
|
|
196
|
+
export const AnimationPresetShape = z.object({
|
|
197
|
+
id: z.string(),
|
|
198
|
+
presetId: z.string().optional(),
|
|
199
|
+
version: z.string().optional(),
|
|
200
|
+
description: z.string().optional(),
|
|
201
|
+
duration: z.number().positive().optional(),
|
|
202
|
+
data: z.record(z.any()).default({}).optional(),
|
|
203
|
+
setup: z.array(SetupStepShape).default([]).optional(),
|
|
204
|
+
revertAfterComplete: z.boolean().default(false).optional(),
|
|
205
|
+
timeline: z.array(AnimationSequenceItemShape) // .min(1) - cancelled as we can have system presets that predefine the timeline so we can use this in component animations list as well
|
|
206
|
+
});
|
|
207
|
+
export const AnimationReferenceShape = z.union([
|
|
208
|
+
z.string(), // 1. Preset name (string ID)
|
|
209
|
+
AnimationPresetShape, // 2. Full AnimationPresetShape object
|
|
210
|
+
KeyframeAnimationShape // 3. Simplified KeyframeAnimationShape object
|
|
211
|
+
]);
|