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.
Files changed (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +213 -0
  3. package/dist/DIContainer.d.ts +4 -0
  4. package/dist/DIContainer.js +145 -0
  5. package/dist/SceneBuilder.svelte.d.ts +8574 -0
  6. package/dist/SceneBuilder.svelte.js +409 -0
  7. package/dist/adapters/subtitleHelpers.d.ts +2 -0
  8. package/dist/adapters/subtitleHelpers.js +187 -0
  9. package/dist/animations/AnimationContext.d.ts +17 -0
  10. package/dist/animations/AnimationContext.js +72 -0
  11. package/dist/animations/AnimationPresetsRegister.d.ts +362 -0
  12. package/dist/animations/AnimationPresetsRegister.js +20 -0
  13. package/dist/animations/AnimationSetup.d.ts +8 -0
  14. package/dist/animations/AnimationSetup.js +30 -0
  15. package/dist/animations/SplitTextCache.d.ts +28 -0
  16. package/dist/animations/SplitTextCache.js +68 -0
  17. package/dist/animations/animationBuilder.d.ts +31 -0
  18. package/dist/animations/animationBuilder.js +255 -0
  19. package/dist/animations/animationPreset.d.ts +7 -0
  20. package/dist/animations/animationPreset.js +31 -0
  21. package/dist/animations/builders/AnimationPresetFactory.d.ts +43 -0
  22. package/dist/animations/builders/AnimationPresetFactory.js +139 -0
  23. package/dist/animations/builders/LineHighlighterAnimationBuilder.d.ts +16 -0
  24. package/dist/animations/builders/LineHighlighterAnimationBuilder.js +183 -0
  25. package/dist/animations/builders/WordHighlighterAnimationBuilder.d.ts +15 -0
  26. package/dist/animations/builders/WordHighlighterAnimationBuilder.js +180 -0
  27. package/dist/animations/engines/AnimationEngineAdaptor.d.ts +107 -0
  28. package/dist/animations/engines/AnimationEngineAdaptor.js +1 -0
  29. package/dist/animations/engines/GSAPEngineAdaptor.d.ts +21 -0
  30. package/dist/animations/engines/GSAPEngineAdaptor.js +145 -0
  31. package/dist/animations/presets/index.d.ts +2 -0
  32. package/dist/animations/presets/index.js +3 -0
  33. package/dist/animations/presets/lines.d.ts +52 -0
  34. package/dist/animations/presets/lines.js +547 -0
  35. package/dist/animations/presets/words.d.ts +31 -0
  36. package/dist/animations/presets/words.js +268 -0
  37. package/dist/animations/transformers/AnimationReferenceTransformer.d.ts +9 -0
  38. package/dist/animations/transformers/AnimationReferenceTransformer.js +114 -0
  39. package/dist/builders/PixiComponentBuilder.d.ts +63 -0
  40. package/dist/builders/PixiComponentBuilder.js +112 -0
  41. package/dist/builders/_ComponentState.svelte.d.ts +795 -0
  42. package/dist/builders/_ComponentState.svelte.js +203 -0
  43. package/dist/builders/html/HtmlBuilder.d.ts +66 -0
  44. package/dist/builders/html/HtmlBuilder.js +171 -0
  45. package/dist/builders/html/HtmlBuilderFactory.d.ts +27 -0
  46. package/dist/builders/html/HtmlBuilderFactory.js +30 -0
  47. package/dist/builders/html/StyleBuilder.d.ts +13 -0
  48. package/dist/builders/html/StyleBuilder.js +133 -0
  49. package/dist/builders/html/StyleProcessor.d.ts +9 -0
  50. package/dist/builders/html/StyleProcessor.js +1 -0
  51. package/dist/builders/html/TextComponentHtmlBuilder.d.ts +16 -0
  52. package/dist/builders/html/TextComponentHtmlBuilder.js +93 -0
  53. package/dist/builders/html/TextShadowBuilder.d.ts +60 -0
  54. package/dist/builders/html/TextShadowBuilder.js +227 -0
  55. package/dist/builders/html/processors/AppearanceStyleProcessor.d.ts +5 -0
  56. package/dist/builders/html/processors/AppearanceStyleProcessor.js +57 -0
  57. package/dist/builders/html/processors/TextAppearanceStyleProcessor.d.ts +5 -0
  58. package/dist/builders/html/processors/TextAppearanceStyleProcessor.js +37 -0
  59. package/dist/builders/html/processors/TextEffectsStyleProcessor.d.ts +6 -0
  60. package/dist/builders/html/processors/TextEffectsStyleProcessor.js +68 -0
  61. package/dist/commands/Command.d.ts +6 -0
  62. package/dist/commands/Command.js +1 -0
  63. package/dist/commands/CommandRunner.d.ts +28 -0
  64. package/dist/commands/CommandRunner.js +81 -0
  65. package/dist/commands/CommandTypes.d.ts +11 -0
  66. package/dist/commands/CommandTypes.js +13 -0
  67. package/dist/commands/PauseCommand.d.ts +4 -0
  68. package/dist/commands/PauseCommand.js +5 -0
  69. package/dist/commands/PlayCommand.d.ts +4 -0
  70. package/dist/commands/PlayCommand.js +6 -0
  71. package/dist/commands/RenderCommand.d.ts +15 -0
  72. package/dist/commands/RenderCommand.js +18 -0
  73. package/dist/commands/RenderFrameCommand.d.ts +17 -0
  74. package/dist/commands/RenderFrameCommand.js +93 -0
  75. package/dist/commands/ReplaceSourceOnTimeCommand.d.ts +4 -0
  76. package/dist/commands/ReplaceSourceOnTimeCommand.js +22 -0
  77. package/dist/commands/SeekCommand.d.ts +15 -0
  78. package/dist/commands/SeekCommand.js +39 -0
  79. package/dist/commands/UpdateComponentCommand.d.ts +4 -0
  80. package/dist/commands/UpdateComponentCommand.js +17 -0
  81. package/dist/components/AnimatedGIF.d.ts +201 -0
  82. package/dist/components/AnimatedGIF.js +391 -0
  83. package/dist/components/Component.svelte.d.ts +33 -0
  84. package/dist/components/Component.svelte.js +152 -0
  85. package/dist/components/ComponentContext.svelte.d.ts +33 -0
  86. package/dist/components/ComponentContext.svelte.js +105 -0
  87. package/dist/components/hooks/AnimationHook.d.ts +25 -0
  88. package/dist/components/hooks/AnimationHook.js +180 -0
  89. package/dist/components/hooks/CanvasShapeHook.d.ts +12 -0
  90. package/dist/components/hooks/CanvasShapeHook.js +229 -0
  91. package/dist/components/hooks/HtmlAnimationHook.d.ts +8 -0
  92. package/dist/components/hooks/HtmlAnimationHook.js +70 -0
  93. package/dist/components/hooks/HtmlTextHook.d.ts +16 -0
  94. package/dist/components/hooks/HtmlTextHook.js +102 -0
  95. package/dist/components/hooks/HtmlToCanvasHook.d.ts +16 -0
  96. package/dist/components/hooks/HtmlToCanvasHook.js +148 -0
  97. package/dist/components/hooks/ImageHook.d.ts +10 -0
  98. package/dist/components/hooks/ImageHook.js +45 -0
  99. package/dist/components/hooks/MediaHook.d.ts +15 -0
  100. package/dist/components/hooks/MediaHook.js +252 -0
  101. package/dist/components/hooks/MediaSeekingHook.d.ts +12 -0
  102. package/dist/components/hooks/MediaSeekingHook.js +204 -0
  103. package/dist/components/hooks/PixiDisplayObjectHook.d.ts +15 -0
  104. package/dist/components/hooks/PixiDisplayObjectHook.js +77 -0
  105. package/dist/components/hooks/PixiGifHook.d.ts +15 -0
  106. package/dist/components/hooks/PixiGifHook.js +97 -0
  107. package/dist/components/hooks/PixiProgressShapeHook.d.ts +12 -0
  108. package/dist/components/hooks/PixiProgressShapeHook.js +128 -0
  109. package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.d.ts +21 -0
  110. package/dist/components/hooks/PixiSplitScreenDisplayObjectHook.js +210 -0
  111. package/dist/components/hooks/PixiTextureHook.d.ts +7 -0
  112. package/dist/components/hooks/PixiTextureHook.js +29 -0
  113. package/dist/components/hooks/PixiVideoTextureHook.d.ts +10 -0
  114. package/dist/components/hooks/PixiVideoTextureHook.js +35 -0
  115. package/dist/components/hooks/SubtitlesHook.d.ts +88 -0
  116. package/dist/components/hooks/SubtitlesHook.js +199 -0
  117. package/dist/components/hooks/VerifyGifHook.d.ts +7 -0
  118. package/dist/components/hooks/VerifyGifHook.js +27 -0
  119. package/dist/components/hooks/VerifyImageHook.d.ts +7 -0
  120. package/dist/components/hooks/VerifyImageHook.js +27 -0
  121. package/dist/components/hooks/VerifyMediaHook.d.ts +7 -0
  122. package/dist/components/hooks/VerifyMediaHook.js +21 -0
  123. package/dist/components/hooks/shapes/progress/CustomProgressRenderer.d.ts +8 -0
  124. package/dist/components/hooks/shapes/progress/CustomProgressRenderer.js +53 -0
  125. package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.d.ts +8 -0
  126. package/dist/components/hooks/shapes/progress/DoubleProgressRenderer.js +69 -0
  127. package/dist/components/hooks/shapes/progress/LinearProgressRenderer.d.ts +8 -0
  128. package/dist/components/hooks/shapes/progress/LinearProgressRenderer.js +60 -0
  129. package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.d.ts +9 -0
  130. package/dist/components/hooks/shapes/progress/PerimeterProgressRenderer.js +213 -0
  131. package/dist/components/hooks/shapes/progress/ProgressRenderer.d.ts +17 -0
  132. package/dist/components/hooks/shapes/progress/ProgressRenderer.js +75 -0
  133. package/dist/components/hooks/shapes/progress/RadialProgressRenderer.d.ts +8 -0
  134. package/dist/components/hooks/shapes/progress/RadialProgressRenderer.js +50 -0
  135. package/dist/components/hooks/shapes/progress/index.d.ts +6 -0
  136. package/dist/components/hooks/shapes/progress/index.js +6 -0
  137. package/dist/composers/componentComposer.d.ts +55 -0
  138. package/dist/composers/componentComposer.js +118 -0
  139. package/dist/composers/layerComposer.d.ts +46 -0
  140. package/dist/composers/layerComposer.js +79 -0
  141. package/dist/composers/sceneComposer.d.ts +48 -0
  142. package/dist/composers/sceneComposer.js +92 -0
  143. package/dist/constants.d.ts +12 -0
  144. package/dist/constants.js +14 -0
  145. package/dist/directors/ComponentDirector.d.ts +20 -0
  146. package/dist/directors/ComponentDirector.js +86 -0
  147. package/dist/factories/SceneBuilderFactory.d.ts +15 -0
  148. package/dist/factories/SceneBuilderFactory.js +51 -0
  149. package/dist/fonts/GoogleFontsProvider.d.ts +12 -0
  150. package/dist/fonts/GoogleFontsProvider.js +125 -0
  151. package/dist/fonts/fontLoader.d.ts +15 -0
  152. package/dist/fonts/fontLoader.js +41 -0
  153. package/dist/fonts/types.d.ts +1 -0
  154. package/dist/fonts/types.js +1 -0
  155. package/dist/index.d.ts +11 -0
  156. package/dist/index.js +14 -0
  157. package/dist/layers/Layer.svelte.d.ts +8492 -0
  158. package/dist/layers/Layer.svelte.js +125 -0
  159. package/dist/managers/AppManager.svelte.d.ts +23 -0
  160. package/dist/managers/AppManager.svelte.js +89 -0
  161. package/dist/managers/ComponentsManager.svelte.d.ts +49 -0
  162. package/dist/managers/ComponentsManager.svelte.js +247 -0
  163. package/dist/managers/DomManager.d.ts +18 -0
  164. package/dist/managers/DomManager.js +73 -0
  165. package/dist/managers/EventManager.d.ts +7 -0
  166. package/dist/managers/EventManager.js +22 -0
  167. package/dist/managers/LayersManager.svelte.d.ts +8499 -0
  168. package/dist/managers/LayersManager.svelte.js +176 -0
  169. package/dist/managers/MediaManager.d.ts +32 -0
  170. package/dist/managers/MediaManager.js +243 -0
  171. package/dist/managers/RenderManager.d.ts +23 -0
  172. package/dist/managers/RenderManager.js +59 -0
  173. package/dist/managers/StateManager.svelte.d.ts +8746 -0
  174. package/dist/managers/StateManager.svelte.js +272 -0
  175. package/dist/managers/SubtitlesManager.svelte.d.ts +261 -0
  176. package/dist/managers/SubtitlesManager.svelte.js +1385 -0
  177. package/dist/managers/TimeManager.svelte.d.ts +6 -0
  178. package/dist/managers/TimeManager.svelte.js +18 -0
  179. package/dist/managers/TimelineManager.svelte.d.ts +25 -0
  180. package/dist/managers/TimelineManager.svelte.js +152 -0
  181. package/dist/registers.d.ts +12 -0
  182. package/dist/registers.js +29 -0
  183. package/dist/schemas/runtime/index.d.ts +3 -0
  184. package/dist/schemas/runtime/index.js +4 -0
  185. package/dist/schemas/runtime/types.d.ts +323 -0
  186. package/dist/schemas/runtime/types.js +12 -0
  187. package/dist/schemas/scene/animations.d.ts +89738 -0
  188. package/dist/schemas/scene/animations.js +211 -0
  189. package/dist/schemas/scene/components.js +515 -0
  190. package/dist/schemas/scene/core.js +160 -0
  191. package/dist/schemas/scene/index.d.ts +22 -0
  192. package/dist/schemas/scene/index.js +10 -0
  193. package/dist/schemas/scene/properties.d.ts +914 -0
  194. package/dist/schemas/scene/properties.js +398 -0
  195. package/dist/schemas/scene/subtitles.d.ts +1141 -0
  196. package/dist/schemas/scene/subtitles.js +111 -0
  197. package/dist/schemas/scene/utils.d.ts +1 -0
  198. package/dist/schemas/scene/utils.js +5 -0
  199. package/dist/seeds/SeedFactory.d.ts +59 -0
  200. package/dist/seeds/SeedFactory.js +99 -0
  201. package/dist/seeds/index.d.ts +8 -0
  202. package/dist/seeds/index.js +8 -0
  203. package/dist/transformers/ColorTransformer.d.ts +5 -0
  204. package/dist/transformers/ColorTransformer.js +67 -0
  205. package/dist/transformers/PixiColorTransformer.d.ts +22 -0
  206. package/dist/transformers/PixiColorTransformer.js +104 -0
  207. package/dist/utils/canvas.d.ts +6 -0
  208. package/dist/utils/canvas.js +18 -0
  209. package/dist/utils/document.d.ts +2 -0
  210. package/dist/utils/document.js +36 -0
  211. package/dist/utils/emoji.d.ts +10 -0
  212. package/dist/utils/emoji.js +51 -0
  213. package/dist/utils/html.d.ts +4 -0
  214. package/dist/utils/html.js +45 -0
  215. package/dist/utils/svgGenerator.d.ts +20 -0
  216. package/dist/utils/svgGenerator.js +103 -0
  217. package/dist/utils/utils.d.ts +5 -0
  218. package/dist/utils/utils.js +125 -0
  219. package/package.json +96 -0
@@ -0,0 +1,15 @@
1
+ import type { Animation } from '../..';
2
+ import type { ComponentData } from '../..';
3
+ import type { SplitTextCache } from '../SplitTextCache.js';
4
+ export declare class WordHighlighterAnimationBuilder {
5
+ static build(data: ComponentData, target: HTMLElement, animationData: Record<string, any>, splitTextCache: SplitTextCache): Animation[];
6
+ private static createWordHighlightAnimations;
7
+ private static prepareHighlightStyles;
8
+ private static createHighlightAnimation;
9
+ private static createUnhighlightAnimation;
10
+ private static createBackgroundHighlightAnimation;
11
+ private static createBackgroundElement;
12
+ private static getBackgroundConfig;
13
+ private static initializeBackgroundElement;
14
+ private static buildBackgroundAnimation;
15
+ }
@@ -0,0 +1,180 @@
1
+ import { get } from 'lodash-es';
2
+ import { wordsHighlighter } from '../presets/words.js';
3
+ import { AnimationPresetFactory } from './AnimationPresetFactory.js';
4
+ import { ColorTransformer } from '../../transformers/ColorTransformer.js';
5
+ export class WordHighlighterAnimationBuilder {
6
+ static build(data, target, animationData, splitTextCache) {
7
+ if (data.type !== 'TEXT') {
8
+ return [];
9
+ }
10
+ const activeWord = get(data, 'appearance.text.activeWord', null);
11
+ if (!activeWord?.enabled) {
12
+ return [];
13
+ }
14
+ const config = {
15
+ activeWord,
16
+ data,
17
+ animationData,
18
+ target,
19
+ splitTextCache
20
+ };
21
+ return this.createWordHighlightAnimations(config);
22
+ }
23
+ static createWordHighlightAnimations(config) {
24
+ const animations = [];
25
+ const styles = this.prepareHighlightStyles(config);
26
+ // Create main highlight animation
27
+ const highlightAnimation = this.createHighlightAnimation(config.data.id, styles.highlight, config.animationData);
28
+ animations.push(highlightAnimation);
29
+ // Create unhighlight animation if needed
30
+ const unhighlightAnimation = this.createUnhighlightAnimation(config.data.id, styles.original, config.animationData);
31
+ if (unhighlightAnimation) {
32
+ animations.push(unhighlightAnimation);
33
+ }
34
+ // Create background highlight animation if needed
35
+ const backgroundAnimation = this.createBackgroundHighlightAnimation(config);
36
+ if (backgroundAnimation) {
37
+ animations.push(backgroundAnimation);
38
+ }
39
+ return animations;
40
+ }
41
+ static prepareHighlightStyles(config) {
42
+ const { activeWord, data } = config;
43
+ const highlightStyles = ColorTransformer.transform(activeWord.color, 'text');
44
+ const originalStyles = ColorTransformer.transform(data.appearance.text?.color, 'text');
45
+ // Handle font weight if specified
46
+ if (get(activeWord, 'fontWeight', undefined)) {
47
+ highlightStyles.fontWeight = activeWord.fontWeight;
48
+ originalStyles.fontWeight = data.appearance.text?.fontWeight ?? 'normal';
49
+ }
50
+ return {
51
+ highlight: highlightStyles,
52
+ original: originalStyles
53
+ };
54
+ }
55
+ static createHighlightAnimation(componentId, styles, animationData) {
56
+ const animation = AnimationPresetFactory.from(wordsHighlighter)
57
+ .resetTimeline()
58
+ .timeline()
59
+ .target('words')
60
+ .to({
61
+ ...styles,
62
+ stagger: { type: 'fromData', dataKey: 'wordStartTimes' }
63
+ })
64
+ .build();
65
+ return {
66
+ id: `words-highlight-${componentId}`,
67
+ name: 'Words Highlight',
68
+ animation,
69
+ startAt: 0
70
+ };
71
+ }
72
+ static createUnhighlightAnimation(componentId, originalStyles, animationData) {
73
+ if (!animationData.wordUnhighlightTimes) {
74
+ return null;
75
+ }
76
+ const animation = AnimationPresetFactory.from(wordsHighlighter)
77
+ .resetTimeline()
78
+ .timeline()
79
+ .target('words')
80
+ .to({
81
+ ...originalStyles,
82
+ stagger: { type: 'fromData', dataKey: 'wordUnhighlightTimes' }
83
+ })
84
+ .build();
85
+ return {
86
+ id: `words-highlight-${componentId}-unhighlight`,
87
+ name: 'Words Unhighlight',
88
+ animation
89
+ };
90
+ }
91
+ static createBackgroundHighlightAnimation(config) {
92
+ const { activeWord, target, splitTextCache, data, animationData } = config;
93
+ if (!activeWord.backgroundColor) {
94
+ return null;
95
+ }
96
+ const words = splitTextCache.getSplitText(target, 'words');
97
+ if (!words?.length) {
98
+ return null;
99
+ }
100
+ const bgHighlighter = this.createBackgroundElement(target);
101
+ const backgroundConfig = this.getBackgroundConfig(activeWord);
102
+ const bgStyles = ColorTransformer.transform(activeWord.backgroundColor, 'background');
103
+ this.initializeBackgroundElement(bgHighlighter, words[0], backgroundConfig, bgStyles);
104
+ const animation = this.buildBackgroundAnimation(data.id, words, animationData, backgroundConfig, bgStyles);
105
+ return {
106
+ id: `words-background-highlight-${data.id}`,
107
+ name: 'Words Background Highlight',
108
+ animation,
109
+ startAt: 0
110
+ };
111
+ }
112
+ static createBackgroundElement(target) {
113
+ const bgHighlighter = document.createElement('div');
114
+ bgHighlighter.id = 'highlighter-bg';
115
+ bgHighlighter.style.position = 'absolute';
116
+ bgHighlighter.style.pointerEvents = 'none';
117
+ target.prepend(bgHighlighter);
118
+ return bgHighlighter;
119
+ }
120
+ static getBackgroundConfig(activeWord) {
121
+ return {
122
+ paddingX: get(activeWord, 'backgroundPaddingX', 25),
123
+ paddingY: get(activeWord, 'backgroundPaddingY', 10),
124
+ borderRadius: get(activeWord, 'backgroundBorderRadius', 10)
125
+ };
126
+ }
127
+ static initializeBackgroundElement(bgHighlighter, firstWord, config, bgStyles) {
128
+ const { paddingX, paddingY, borderRadius } = config;
129
+ bgHighlighter.style.left = `${firstWord.offsetLeft - paddingX}px`;
130
+ bgHighlighter.style.top = `${firstWord.offsetTop - paddingY}px`;
131
+ bgHighlighter.style.width = `${firstWord.clientWidth + 2 * paddingX}px`;
132
+ bgHighlighter.style.height = `${firstWord.clientHeight + 2 * paddingY}px`;
133
+ bgHighlighter.style.borderRadius = `${borderRadius}px`;
134
+ bgHighlighter.style.opacity = '1';
135
+ if (bgStyles) {
136
+ Object.entries(bgStyles).forEach(([key, value]) => {
137
+ // Check if key is a valid writable style property
138
+ if (key in bgHighlighter.style) {
139
+ bgHighlighter.style[key] = String(value);
140
+ }
141
+ else {
142
+ // For custom properties or CSS variables, use setProperty
143
+ bgHighlighter.style.setProperty(key, String(value));
144
+ }
145
+ });
146
+ }
147
+ }
148
+ static buildBackgroundAnimation(componentId, words, animationData, backgroundConfig, bgStyles) {
149
+ const presetComposer = AnimationPresetFactory.create(`words-bg-highlight-anim-${componentId}`);
150
+ const timelineComposer = presetComposer.timeline();
151
+ const targetComposer = timelineComposer.target('#highlighter-bg');
152
+ const wordStartTimes = animationData.wordStartTimes ?? [];
153
+ if (wordStartTimes.length <= 1) {
154
+ return timelineComposer.build();
155
+ }
156
+ const { paddingX, paddingY, borderRadius } = backgroundConfig;
157
+ for (let i = 0; i < wordStartTimes.length; i++) {
158
+ const currentWord = words[i];
159
+ if (!currentWord) {
160
+ console.warn(`WordHighlighter: Word element at index ${i} is missing.`);
161
+ continue;
162
+ }
163
+ const startTime = parseFloat(wordStartTimes[i].toFixed(3));
164
+ targetComposer
165
+ .to({
166
+ borderRadius: `${borderRadius}px`,
167
+ left: currentWord.offsetLeft - paddingX,
168
+ top: currentWord.offsetTop - paddingY,
169
+ width: currentWord.clientWidth + 2 * paddingX,
170
+ height: currentWord.clientHeight + 2 * paddingY,
171
+ duration: 0.15,
172
+ ease: 'power1.out',
173
+ // delay: startTime,
174
+ ...bgStyles
175
+ }, startTime)
176
+ .position(0);
177
+ }
178
+ return timelineComposer.build();
179
+ }
180
+ }
@@ -0,0 +1,107 @@
1
+ import type { AnimationContext } from '../AnimationContext.js';
2
+ export type EngineTarget = any;
3
+ export type EngineTimeline = any;
4
+ export type EngineStaggerOptions = any;
5
+ export interface AnimationEngineAdaptor {
6
+ /**
7
+ * Creates a new timeline instance from the animation engine.
8
+ * @param options - Engine-specific timeline options.
9
+ * @returns An instance of the engine's timeline.
10
+ */
11
+ createTimeline(options?: Record<string, any>): EngineTimeline;
12
+ /**
13
+ * Adds a tween to the given timeline.
14
+ * @param timeline - The engine timeline instance to add the tween to.
15
+ * @param targets - The target(s) for the animation.
16
+ * @param method - The animation method ('to', 'from', 'fromTo', 'set').
17
+ * @param vars - An object containing properties to animate and animation parameters (duration, ease, etc.).
18
+ * This should include resolved values (e.g., data references already looked up).
19
+ * For 'fromTo', 'vars.from' will contain the from-properties.
20
+ * @param position - The position in the timeline where the tween should be inserted (e.g., absolute time, label, relative offset).
21
+ */
22
+ addTween(timeline: EngineTimeline, targets: EngineTarget | EngineTarget[], method: 'to' | 'from' | 'fromTo' | 'set', vars: Record<string, any>, position?: string | number): number;
23
+ /**
24
+ * Resolves stagger options, especially 'fromData' type, into engine-specific stagger configuration.
25
+ * @param staggerDefinition - The stagger object from the JSON preset.
26
+ * @param context - The animation context, for accessing data like `wordTimestamps`.
27
+ * @param tweenDuration - The duration of the individual tween that stagger is applied to (can be undefined).
28
+ * @returns Engine-specific stagger options or a value that the engine understands for staggering.
29
+ */
30
+ resolveStagger(staggerDefinition: Record<string, any> | number, context: AnimationContext, tweenDuration?: number): EngineStaggerOptions;
31
+ /**
32
+ * Plays the given timeline.
33
+ * @param timeline - The engine timeline instance to play.
34
+ * @param position - (Optional) Time or label from which to start playing.
35
+ */
36
+ play(timeline: EngineTimeline, position?: string | number): void;
37
+ /**
38
+ * Pauses the given timeline.
39
+ * @param timeline - The engine timeline instance to pause.
40
+ */
41
+ pause(timeline: EngineTimeline): void;
42
+ /**
43
+ * Resumes the given timeline.
44
+ * @param timeline - The engine timeline instance to resume.
45
+ * @param position - (Optional) Time or label from which to resume playing.
46
+ */
47
+ resume(timeline: EngineTimeline, position?: string | number): void;
48
+ /**
49
+ * Seeks to a specific time or label in the timeline.
50
+ * @param timeline - The engine timeline instance.
51
+ * @param position - Time (seconds) or label to seek to.
52
+ * @param suppressEvents - (Optional) If true, suppress events during the seek (engine dependent).
53
+ */
54
+ seek(timeline: EngineTimeline, position: string | number, suppressEvents?: boolean): void;
55
+ /**
56
+ * Gets the total duration of a timeline.
57
+ * @param timeline - The engine timeline instance.
58
+ * @returns The duration in seconds.
59
+ */
60
+ totalDuration(timeline: EngineTimeline): number;
61
+ /**
62
+ * Kills/destroys the timeline and its animations, removing them from the engine.
63
+ * @param timeline - The engine timeline instance to kill.
64
+ */
65
+ kill(timeline: EngineTimeline): void;
66
+ /**
67
+ * (Optional) Utility to convert a generic property value (which might be a data reference)
68
+ * into its actual value. This might be handled by the AnimationBuilder before calling addTween,
69
+ * or the adaptor can provide a utility if the engine has specific ways to handle dynamic values.
70
+ * For now, let's assume AnimationBuilder resolves data references.
71
+ */
72
+ /**
73
+ * (Optional) Helper to create a "pause" or empty tween in the timeline.
74
+ * @param timeline The engine timeline to add the pause to.
75
+ * @param duration The duration of the pause.
76
+ * @param position The position in the timeline.
77
+ */
78
+ addPause(timeline: EngineTimeline, duration: number, position?: string | number): void;
79
+ /**
80
+ * (Optional) Adds a label to the timeline at the current end or a specific time.
81
+ * @param timeline The engine timeline.
82
+ * @param label The name of the label.
83
+ * @param position The position for the label.
84
+ */
85
+ addLabel(timeline: EngineTimeline, label: string, position?: string | number): void;
86
+ /**
87
+ * (Optional) Adds a callback to the timeline.
88
+ * @param timeline The engine timeline.
89
+ * @param callback The function to call.
90
+ * @param position The position for the callback.
91
+ */
92
+ addCallback(timeline: EngineTimeline, callback: () => void, position?: string | number): void;
93
+ /**
94
+ * (Optional) Adds a callback to the timeline.
95
+ * @param timeline The engine timeline.
96
+ * @param callback The function to call.
97
+ */
98
+ onComplete(timeline: EngineTimeline, callback: () => void): void;
99
+ /**
100
+ * Repositions a label by removing it and adding it again at a new position.
101
+ * This should cause any animations positioned at that label to move to the new position.
102
+ * @param timeline The engine timeline.
103
+ * @param labelName The name of the label to reposition.
104
+ * @param newPosition The new position for the label.
105
+ */
106
+ repositionLabel(timeline: EngineTimeline, labelName: string, newPosition: string | number): void;
107
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { AnimationEngineAdaptor, EngineTarget, EngineStaggerOptions } from './AnimationEngineAdaptor.ts';
2
+ import type { AnimationContext } from '../AnimationContext.ts';
3
+ type GsapEngineTimeline = gsap.core.Timeline;
4
+ export declare class GsapEngineAdaptor implements AnimationEngineAdaptor {
5
+ createTimeline(options?: gsap.TimelineVars): GsapEngineTimeline;
6
+ addTween(timeline: GsapEngineTimeline, targets: EngineTarget | EngineTarget[], method: 'to' | 'from' | 'fromTo' | 'set', vars: gsap.TweenVars, // GSAP's TweenVars is very flexible
7
+ position?: string | number): number;
8
+ resolveStagger(staggerDefinition: Record<string, any> | number, context: AnimationContext, _tweenDuration?: number): EngineStaggerOptions;
9
+ play(timeline: GsapEngineTimeline, position?: string | number): void;
10
+ pause(timeline: GsapEngineTimeline): void;
11
+ resume(timeline: GsapEngineTimeline, position?: string | number): void;
12
+ seek(timeline: GsapEngineTimeline, position: string | number, suppressEvents?: boolean): void;
13
+ totalDuration(timeline: GsapEngineTimeline): number;
14
+ kill(timeline: GsapEngineTimeline): void;
15
+ addPause(timeline: GsapEngineTimeline, duration: number, position?: string | number): void;
16
+ addLabel(timeline: GsapEngineTimeline, label: string, position?: string | number): void;
17
+ addCallback(timeline: GsapEngineTimeline, callback: () => void, position?: string | number): void;
18
+ onComplete(timeline: GsapEngineTimeline, callback: () => void): void;
19
+ repositionLabel(timeline: GsapEngineTimeline, labelName: string, newPosition: string | number): void;
20
+ }
21
+ export {};
@@ -0,0 +1,145 @@
1
+ import { gsap } from 'gsap';
2
+ import { get } from 'lodash-es';
3
+ export class GsapEngineAdaptor {
4
+ createTimeline(options) {
5
+ if (!options) {
6
+ options = {};
7
+ }
8
+ const revertAfterComplete = get(options, 'revertAfterComplete', false);
9
+ // options.smoothChildTiming = true;
10
+ if (revertAfterComplete) {
11
+ options.onComplete = function () {
12
+ this.seek(0);
13
+ };
14
+ }
15
+ const tl = gsap.timeline(options); // options
16
+ tl.callbackScope = tl;
17
+ return tl;
18
+ }
19
+ addTween(timeline, targets, method, vars, // GSAP's TweenVars is very flexible
20
+ position) {
21
+ if (!targets || (Array.isArray(targets) && targets.length === 0)) {
22
+ console.warn('GSAP addTween: No targets provided.');
23
+ return 0;
24
+ }
25
+ let populatedVars = { ...vars }; // Clone vars to avoid mutating original from preset
26
+ // GSAP's .fromTo() expects 'from' vars as the second argument,
27
+ // and 'to' vars as the third.
28
+ // Our 'vars' for 'fromTo' contains 'vars.from' and the 'to' vars directly in 'vars'.
29
+ if (method === 'fromTo') {
30
+ const fromVars = populatedVars.from || {};
31
+ delete populatedVars.from; // Remove it from the 'to' vars object
32
+ timeline.set(targets, fromVars, position);
33
+ const tween = timeline.to(targets, populatedVars, position);
34
+ return tween.duration();
35
+ }
36
+ const tween = timeline[method](targets, populatedVars, position);
37
+ return tween.duration();
38
+ }
39
+ resolveStagger(staggerDefinition, context, _tweenDuration // GSAP often handles duration within stagger context if 'amount' is used
40
+ ) {
41
+ // Returns GSAPStaggerVars
42
+ if (typeof staggerDefinition === 'number') {
43
+ return staggerDefinition; // GSAP shorthand for { each: number }
44
+ }
45
+ const { type, dataKey, ...restOfStagger } = staggerDefinition;
46
+ if (type === 'fromData' && dataKey) {
47
+ const timingsArray = context.getData(dataKey);
48
+ if (!Array.isArray(timingsArray)) {
49
+ console.warn(`Stagger 'fromData': dataKey "${dataKey}" did not resolve to an array.`);
50
+ return restOfStagger; // Fallback to other stagger props if any
51
+ }
52
+ // GSAP functional stagger:
53
+ // The function receives (index, target, targetsArray)
54
+ // We want the Nth word to start at timingsArray[N] relative to this stagger block's start.
55
+ return (index, _target, _targets) => {
56
+ // Ensure the specific timing applies to the start of the individual tween.
57
+ // If the stagger block itself has an overall duration ('amount'), GSAP handles distribution.
58
+ // If 'each' is explicitly needed for individual tween starts based on data,
59
+ // this functional value for 'each' is very powerful.
60
+ // However, GSAP's 'amount' along with a from/distribution model often handles this.
61
+ // For precise start times from an array, a function directly controlling delay is more robust.
62
+ //
63
+ // Simpler approach if timingsArray are ABSOLUTE start times for items within this stagger block:
64
+ // We return a value that GSAP interprets as the delay for *that specific element*.
65
+ // GSAP's stagger `each` can accept a function.
66
+ // But for explicit timings, it's usually better to create individual tweens
67
+ // or use a function that returns the DELAY.
68
+ //
69
+ // Let's assume timingsArray contains offsets for each element for this stagger.
70
+ // This is a bit tricky as GSAP's `each` or `amount` with a function is nuanced.
71
+ // A common GSAP pattern for fully custom time placement within a stagger:
72
+ // The function for 'each' might determine *how much longer* than the PREVIOUS one,
73
+ // or 'amount' is used to distribute over a total time.
74
+ //
75
+ // If `timingsArray` are desired *absolute start times* within the current tween:
76
+ // The most robust way in GSAP, if not using `amount`, is for the function
77
+ // passed to `stagger` to directly return the *delay from the start of the stagger sequence*.
78
+ // This is often what a functional value for `each` or if `stagger` itself is a function would achieve.
79
+ // For now, let's assume `timingsArray[index]` is the desired start offset for `targets[index]`.
80
+ // This might need refinement based on how GSAP's `stagger` function is structured.
81
+ // A direct mapping to individual delays is typically done by passing a function to stagger itself:
82
+ // stagger: (index, target, list) => timingsArray[index] // This is the delay for that element
83
+ if (timingsArray && index < timingsArray.length) {
84
+ return timingsArray[index];
85
+ }
86
+ return 0; // Default delay if no timing found
87
+ };
88
+ }
89
+ return staggerDefinition; // Standard GSAP stagger object or number
90
+ }
91
+ play(timeline, position) {
92
+ timeline.play(position);
93
+ }
94
+ pause(timeline) {
95
+ timeline.pause();
96
+ }
97
+ resume(timeline, position) {
98
+ // GSAP's play() handles resuming correctly. If a position is given, it seeks and plays.
99
+ timeline.play(position);
100
+ }
101
+ seek(timeline, position, suppressEvents = true) {
102
+ timeline.seek(position, suppressEvents);
103
+ }
104
+ totalDuration(timeline) {
105
+ return timeline.totalDuration();
106
+ }
107
+ kill(timeline) {
108
+ timeline.kill();
109
+ }
110
+ addPause(timeline, duration, position) {
111
+ // GSAP timeline.addPause(position, callback, params)
112
+ // To add a pause of a certain duration, we can add an empty tween or a specific delay.
113
+ // A common way is to add a label then another label offset by duration,
114
+ // or simply an empty tween if that's how you want to signify it.
115
+ // Or more directly:
116
+ if (position !== undefined) {
117
+ timeline.addLabel('pauseStart', position);
118
+ timeline.addLabel('pauseEnd', `+= ${duration}`);
119
+ }
120
+ else {
121
+ timeline.addPause(`+=${duration}`); // Adds a pause at the current end for 'duration' seconds.
122
+ // Actually, GSAP's addPause creates a hard stop.
123
+ // To create a gap of 'duration':
124
+ timeline.to({}, { duration }, position); // Empty tween to create a gap
125
+ }
126
+ }
127
+ addLabel(timeline, label, position) {
128
+ timeline.addLabel(label, position);
129
+ }
130
+ addCallback(timeline, callback, position) {
131
+ timeline.call(callback, undefined, position); // GSAP's call method
132
+ }
133
+ onComplete(timeline, callback) {
134
+ timeline.onComplete(callback);
135
+ }
136
+ repositionLabel(timeline, labelName, newPosition) {
137
+ if (!get(timeline, 'labels.' + labelName)) {
138
+ console.warn(`Label "${labelName}" not found in timeline`);
139
+ }
140
+ else {
141
+ timeline.removeLabel(labelName);
142
+ }
143
+ timeline.addLabel(labelName, newPosition);
144
+ }
145
+ }
@@ -0,0 +1,2 @@
1
+ export * from './words.js';
2
+ export * from './lines.js';
@@ -0,0 +1,3 @@
1
+ export * from './words.js';
2
+ // Line-based animations
3
+ export * from './lines.js';
@@ -0,0 +1,52 @@
1
+ import type { AnimationPreset } from '../..';
2
+ export declare const linesHighlighter: AnimationPreset;
3
+ /**
4
+ * Lines reveal and fade preset
5
+ * Reveals lines one by one with a scale effect
6
+ */
7
+ export declare const linesRevealAndFade: AnimationPreset;
8
+ /**
9
+ * Lines elastic preset
10
+ * Reveals lines with an elastic bounce effect
11
+ */
12
+ export declare const linesElastic: AnimationPreset;
13
+ /**
14
+ * Lines swipe left preset
15
+ * Lines slide in from right and out to left
16
+ */
17
+ export declare const linesSwipeLeft: AnimationPreset;
18
+ /**
19
+ * Lines exchange preset
20
+ * Lines scale in and out with a smooth transition
21
+ */
22
+ export declare const linesExchange: AnimationPreset;
23
+ /**
24
+ * Lines rolling preset
25
+ * Lines roll in with 3D rotation effect
26
+ */
27
+ export declare const linesRolling: AnimationPreset;
28
+ /**
29
+ * Lines spiral preset
30
+ * Lines spiral in with 3D rotation effect
31
+ */
32
+ export declare const linesDna: AnimationPreset;
33
+ /**
34
+ * Lines bounce preset
35
+ * Lines bounce in from the top
36
+ */
37
+ export declare const linesBounce: AnimationPreset;
38
+ /**
39
+ * Lines glitch preset
40
+ * Lines appear with glitchy rough animation
41
+ */
42
+ export declare const linesJiggle: AnimationPreset;
43
+ /**
44
+ * Lines rotate preset
45
+ * Lines rotate in with scale effect
46
+ */
47
+ export declare const rotatingWarpText: AnimationPreset;
48
+ /**
49
+ * Lines lift up preset
50
+ * Lines lift up with alternating rotation
51
+ */
52
+ export declare const coolLinesAnimation: AnimationPreset;