@clypra/engine 1.0.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/dist/index.cjs +6254 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +892 -0
- package/dist/index.d.ts +892 -0
- package/dist/index.js +6089 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
declare const SCENE_VERSION: 1;
|
|
2
|
+
type EffectLayerType = "panel" | "glow" | "shadow" | "extrusion" | "duplicateStack" | "stroke" | "fill" | "mask" | "filter" | "customEngine";
|
|
3
|
+
type LayerTarget = "text" | "panel" | "scene" | "previous";
|
|
4
|
+
type CustomEngineId = "ink";
|
|
5
|
+
declare const CUSTOM_ENGINE_IDS: CustomEngineId[];
|
|
6
|
+
declare const LEGACY_RENDERER_MAP: Record<string, CustomEngineId>;
|
|
7
|
+
declare const ENGINE_ID_TO_LEGACY: Record<CustomEngineId, string>;
|
|
8
|
+
interface SceneCanvas {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
background: string;
|
|
12
|
+
}
|
|
13
|
+
interface SceneText {
|
|
14
|
+
content: string;
|
|
15
|
+
fontFamily: string;
|
|
16
|
+
fontWeight: number;
|
|
17
|
+
fontStyle: "normal" | "italic";
|
|
18
|
+
fontSize: number;
|
|
19
|
+
letterSpacing: number;
|
|
20
|
+
lineHeight: number;
|
|
21
|
+
textPosX: "left" | "center" | "right";
|
|
22
|
+
textPosY: "top" | "middle" | "bottom";
|
|
23
|
+
wrapText?: boolean;
|
|
24
|
+
autoFitText?: boolean;
|
|
25
|
+
perCharFillEnabled?: boolean;
|
|
26
|
+
charFillColors?: string[];
|
|
27
|
+
}
|
|
28
|
+
interface EffectLayer {
|
|
29
|
+
id: string;
|
|
30
|
+
type: EffectLayerType;
|
|
31
|
+
name: string;
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
opacity: number;
|
|
34
|
+
blendMode: GlobalCompositeOperation;
|
|
35
|
+
target: LayerTarget;
|
|
36
|
+
params: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
interface CompositorSettings {
|
|
39
|
+
blur: number;
|
|
40
|
+
bloom: number;
|
|
41
|
+
bloomThreshold?: number;
|
|
42
|
+
}
|
|
43
|
+
interface Keyframe {
|
|
44
|
+
time: number;
|
|
45
|
+
value: number;
|
|
46
|
+
easing?: "linear" | "easeIn" | "easeOut" | "easeInOut";
|
|
47
|
+
}
|
|
48
|
+
interface AnimTrack {
|
|
49
|
+
layerId: string;
|
|
50
|
+
paramPath: string;
|
|
51
|
+
keyframes: Keyframe[];
|
|
52
|
+
}
|
|
53
|
+
interface Timeline {
|
|
54
|
+
duration: number;
|
|
55
|
+
fps: number;
|
|
56
|
+
loop: boolean;
|
|
57
|
+
tracks: AnimTrack[];
|
|
58
|
+
}
|
|
59
|
+
interface SceneDocument {
|
|
60
|
+
version: typeof SCENE_VERSION;
|
|
61
|
+
effectName: string;
|
|
62
|
+
canvas: SceneCanvas;
|
|
63
|
+
text: SceneText;
|
|
64
|
+
effectLayers: EffectLayer[];
|
|
65
|
+
customEngineId: CustomEngineId | null;
|
|
66
|
+
engineParams?: Record<string, unknown>;
|
|
67
|
+
compositor: CompositorSettings;
|
|
68
|
+
timeline: Timeline;
|
|
69
|
+
/** Legacy flat config cache for gradual UI migration */
|
|
70
|
+
legacyConfig?: TextEffectConfig;
|
|
71
|
+
/** Deep Research extension snippet (not executed until sandboxed) */
|
|
72
|
+
extensionCode?: string | null;
|
|
73
|
+
}
|
|
74
|
+
interface StyleRecipe {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
category?: string;
|
|
78
|
+
layers: EffectLayer[];
|
|
79
|
+
exposed: string[];
|
|
80
|
+
tags: string[];
|
|
81
|
+
customEngineId?: CustomEngineId | null;
|
|
82
|
+
scene?: SceneDocument;
|
|
83
|
+
}
|
|
84
|
+
declare function createEmptyScene(overrides?: Partial<SceneDocument>): SceneDocument;
|
|
85
|
+
declare function newLayerId(): string;
|
|
86
|
+
|
|
87
|
+
interface GradientStop {
|
|
88
|
+
color: string;
|
|
89
|
+
offset: number;
|
|
90
|
+
}
|
|
91
|
+
interface GlowLayer {
|
|
92
|
+
enabled: boolean;
|
|
93
|
+
color: string;
|
|
94
|
+
blur: number;
|
|
95
|
+
opacity: number;
|
|
96
|
+
type: "outer" | "inner";
|
|
97
|
+
strength?: number;
|
|
98
|
+
spread?: number;
|
|
99
|
+
}
|
|
100
|
+
interface TextEffectConfig {
|
|
101
|
+
text: string;
|
|
102
|
+
effectName: string;
|
|
103
|
+
fontFamily: string;
|
|
104
|
+
fontWeight: number;
|
|
105
|
+
fontStyle: "normal" | "italic";
|
|
106
|
+
fontSize: number;
|
|
107
|
+
letterSpacing: number;
|
|
108
|
+
lineHeight: number;
|
|
109
|
+
fillType: "solid" | "linear" | "radial" | "pattern" | "none";
|
|
110
|
+
fillColor: string;
|
|
111
|
+
fillGradientAngle: number;
|
|
112
|
+
fillGradientStops: GradientStop[];
|
|
113
|
+
patternType?: "chalk" | "noise" | "grunge" | "carbon" | "stripes" | "film" | "brushed" | "marble" | "halftone" | "paper";
|
|
114
|
+
/** Pro: independent solid fill color per visible character (reading order) */
|
|
115
|
+
perCharFillEnabled?: boolean;
|
|
116
|
+
charFillColors?: string[];
|
|
117
|
+
strokeEnabled: boolean;
|
|
118
|
+
strokeColor: string;
|
|
119
|
+
strokeWidth: number;
|
|
120
|
+
strokePosition: "outside" | "center" | "inside";
|
|
121
|
+
strokeOpacity: number;
|
|
122
|
+
strokeLineJoin: "round" | "miter" | "bevel";
|
|
123
|
+
strokeBlur?: number;
|
|
124
|
+
strokeType?: "single" | "double" | "neon";
|
|
125
|
+
strokeColorSecondary?: string;
|
|
126
|
+
strokeWidthSecondary?: number;
|
|
127
|
+
strokeFadeRange?: number;
|
|
128
|
+
glowLayers: GlowLayer[];
|
|
129
|
+
shadowEnabled: boolean;
|
|
130
|
+
shadowColor: string;
|
|
131
|
+
shadowBlur: number;
|
|
132
|
+
shadowOffsetX: number;
|
|
133
|
+
shadowOffsetY: number;
|
|
134
|
+
shadowOpacity: number;
|
|
135
|
+
shadowType: "drop" | "inner";
|
|
136
|
+
bevelEnabled: boolean;
|
|
137
|
+
bevelDepth: number;
|
|
138
|
+
bevelHighlight: string;
|
|
139
|
+
bevelShadow: string;
|
|
140
|
+
bevelDirection: "bottom-right" | "bottom" | "right";
|
|
141
|
+
bevelCoreColor?: string;
|
|
142
|
+
bevelEdgeColor?: string;
|
|
143
|
+
bevelEdgeWidth?: number;
|
|
144
|
+
bevelBlur?: number;
|
|
145
|
+
bevelBlurColor?: string;
|
|
146
|
+
bevelPerspectiveEnabled?: boolean;
|
|
147
|
+
bevelVanishingPointX?: number;
|
|
148
|
+
bevelVanishingPointY?: number;
|
|
149
|
+
bevelFocalLength?: number;
|
|
150
|
+
stackEnabled?: boolean;
|
|
151
|
+
stackCount?: number;
|
|
152
|
+
stackOffsetX?: number;
|
|
153
|
+
stackOffsetY?: number;
|
|
154
|
+
stackOpacityDecay?: number;
|
|
155
|
+
stackColor1?: string;
|
|
156
|
+
stackColor2?: string;
|
|
157
|
+
stackColor3?: string;
|
|
158
|
+
stackColor4?: string;
|
|
159
|
+
panelEnabled: boolean;
|
|
160
|
+
panelColor: string;
|
|
161
|
+
panelOpacity: number;
|
|
162
|
+
panelRadius: number;
|
|
163
|
+
panelPaddingX: number;
|
|
164
|
+
panelPaddingY: number;
|
|
165
|
+
panelStrokeEnabled: boolean;
|
|
166
|
+
panelStrokeColor: string;
|
|
167
|
+
panelStrokeWidth: number;
|
|
168
|
+
canvasWidth: number;
|
|
169
|
+
canvasHeight: number;
|
|
170
|
+
textPosX: "left" | "center" | "right";
|
|
171
|
+
textPosY: "top" | "middle" | "bottom";
|
|
172
|
+
/** Scale type to fit safe area inside canvas */
|
|
173
|
+
autoFitText?: boolean;
|
|
174
|
+
/** Wrap long lines to composition safe width */
|
|
175
|
+
wrapText?: boolean;
|
|
176
|
+
inkColor?: string;
|
|
177
|
+
bristleDensity?: number;
|
|
178
|
+
bristleSkipRate?: number;
|
|
179
|
+
dripRate?: number;
|
|
180
|
+
dripMaxLength?: number;
|
|
181
|
+
grainDensity?: number;
|
|
182
|
+
skewX?: number;
|
|
183
|
+
customRenderer?: string;
|
|
184
|
+
}
|
|
185
|
+
interface Preset {
|
|
186
|
+
id: string;
|
|
187
|
+
name: string;
|
|
188
|
+
config: TextEffectConfig;
|
|
189
|
+
/** Cached scene graph (optional; built-ins use recipes cache) */
|
|
190
|
+
scene?: SceneDocument;
|
|
191
|
+
isCustom?: boolean;
|
|
192
|
+
category?: "3d" | "Neon" | "Metallic" | "Glitch" | "Retro" | "Gradient" | "Grunge" | "Outline" | "Shadow" | "Elements" | "Luxury" | "Classic" | "Experimental" | string;
|
|
193
|
+
createdAt?: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare function renderTextEffectCore(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig): void;
|
|
197
|
+
declare class TextEffectRenderer {
|
|
198
|
+
static draw(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig, _time?: number): void;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Style recipes (layer graphs): see `builtInRecipes` in src/engine/recipes.ts */
|
|
202
|
+
declare const defaultConfig: TextEffectConfig;
|
|
203
|
+
declare const builtInPresets: Preset[];
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Font Loader for Lottie-web
|
|
207
|
+
*
|
|
208
|
+
* This module ensures that font variant names (like "Poppins-Italic") work correctly
|
|
209
|
+
* with lottie-web by dynamically creating @font-face rules that map variant names
|
|
210
|
+
* to the actual loaded fonts with proper styling.
|
|
211
|
+
*/
|
|
212
|
+
interface FontVariant {
|
|
213
|
+
variantName: string;
|
|
214
|
+
baseFontFamily: string;
|
|
215
|
+
weight: number;
|
|
216
|
+
style: "normal" | "italic";
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Injects @font-face rules dynamically to create font variant aliases
|
|
220
|
+
* This ensures lottie-web can find fonts by their variant names
|
|
221
|
+
*/
|
|
222
|
+
declare function injectFontVariantRules(): void;
|
|
223
|
+
/**
|
|
224
|
+
* Waits for base fonts to load, then injects variant rules
|
|
225
|
+
*/
|
|
226
|
+
declare function initializeFontSystem(): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* Checks if a font variant is available for rendering
|
|
229
|
+
*/
|
|
230
|
+
declare function checkFontVariant(variantName: string): boolean;
|
|
231
|
+
|
|
232
|
+
declare function resolveCustomEngineId(cfg: TextEffectConfig): CustomEngineId | null;
|
|
233
|
+
/** Lossless migration from flat TextEffectConfig to SceneDocument */
|
|
234
|
+
declare function textEffectConfigToScene(cfg: TextEffectConfig): SceneDocument;
|
|
235
|
+
/** Flatten SceneDocument back to TextEffectConfig for legacy controls and renderer */
|
|
236
|
+
declare function sceneToConfig(doc: SceneDocument): TextEffectConfig;
|
|
237
|
+
declare function syncCompositorFromScene(doc: SceneDocument): CompositorFromScene;
|
|
238
|
+
interface CompositorFromScene {
|
|
239
|
+
blur: number;
|
|
240
|
+
bloom: number;
|
|
241
|
+
bloomThreshold: number;
|
|
242
|
+
}
|
|
243
|
+
/** Apply engine params from scene onto config without require() */
|
|
244
|
+
declare function mergeSceneIntoConfig(doc: SceneDocument, base: TextEffectConfig): TextEffectConfig;
|
|
245
|
+
|
|
246
|
+
declare class WebGLCompositor {
|
|
247
|
+
private gl;
|
|
248
|
+
private program;
|
|
249
|
+
private vao;
|
|
250
|
+
private texture;
|
|
251
|
+
readonly isSupported: boolean;
|
|
252
|
+
constructor();
|
|
253
|
+
private initProgram;
|
|
254
|
+
private compileShader;
|
|
255
|
+
renderToContext(targetCtx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, source: HTMLCanvasElement | OffscreenCanvas, settings: CompositorSettings): void;
|
|
256
|
+
dispose(): void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface EvaluateOptions {
|
|
260
|
+
compositor?: WebGLCompositor | null;
|
|
261
|
+
skipPostFx?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Single source of truth for rendering a scene at time t.
|
|
265
|
+
*/
|
|
266
|
+
declare function evaluateScene(doc: SceneDocument, time: number, ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, options?: EvaluateOptions): void;
|
|
267
|
+
declare function evaluateConfig(cfg: TextEffectConfig, time: number, ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, options?: EvaluateOptions): void;
|
|
268
|
+
declare function advanceSceneTime(doc: SceneDocument, steps: number): number;
|
|
269
|
+
declare function getSceneTime(doc: SceneDocument): number;
|
|
270
|
+
declare function setSceneTime(doc: SceneDocument, time: number): void;
|
|
271
|
+
declare function resetSceneTime(doc: SceneDocument): void;
|
|
272
|
+
|
|
273
|
+
declare function ease(t: number, kind?: Keyframe["easing"]): number;
|
|
274
|
+
/** Resolve animated scalar at time (seconds) */
|
|
275
|
+
declare function resolveAnimatedScalar(doc: SceneDocument, layerId: string, paramPath: string, baseValue: number, time: number): number;
|
|
276
|
+
/** Apply timeline to scene (returns shallow clone with updated layer params) */
|
|
277
|
+
declare function applyTimelineAtTime(doc: SceneDocument, time: number): SceneDocument;
|
|
278
|
+
declare function createDefaultRevealTrack(layerId: string): SceneDocument["timeline"]["tracks"][0];
|
|
279
|
+
declare function createPulseOpacityTrack(layerId: string): SceneDocument["timeline"]["tracks"][0];
|
|
280
|
+
|
|
281
|
+
interface TextLayoutBounds {
|
|
282
|
+
xMin: number;
|
|
283
|
+
yMin: number;
|
|
284
|
+
xMax: number;
|
|
285
|
+
yMax: number;
|
|
286
|
+
maxLineWidth: number;
|
|
287
|
+
textBlockHeight: number;
|
|
288
|
+
}
|
|
289
|
+
interface TextLayoutResult {
|
|
290
|
+
lines: string[];
|
|
291
|
+
fontSize: number;
|
|
292
|
+
startX: number;
|
|
293
|
+
startY: number;
|
|
294
|
+
align: CanvasTextAlign;
|
|
295
|
+
lineWidths: number[];
|
|
296
|
+
bounds: TextLayoutBounds;
|
|
297
|
+
safeRect: {
|
|
298
|
+
x: number;
|
|
299
|
+
y: number;
|
|
300
|
+
width: number;
|
|
301
|
+
height: number;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
interface CompositionPreset {
|
|
305
|
+
id: string;
|
|
306
|
+
label: string;
|
|
307
|
+
width: number;
|
|
308
|
+
height: number;
|
|
309
|
+
description?: string;
|
|
310
|
+
}
|
|
311
|
+
declare const COMPOSITION_PRESETS: CompositionPreset[];
|
|
312
|
+
/** Soft-wrap paragraphs to fit safe width */
|
|
313
|
+
declare function wrapTextToWidth(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, text: string, maxWidth: number, letterSpacing: number): string[];
|
|
314
|
+
declare function measureTextFits(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig, fontSize: number, lines: string[]): boolean;
|
|
315
|
+
declare function computeAutoFitFontSize(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig, wrappedLines: string[]): number;
|
|
316
|
+
/**
|
|
317
|
+
* Layout text for a composition: safe margins, optional wrap + auto-fit.
|
|
318
|
+
*/
|
|
319
|
+
declare function computeTextLayout(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig, options?: {
|
|
320
|
+
wrap?: boolean;
|
|
321
|
+
autoFit?: boolean;
|
|
322
|
+
}): TextLayoutResult;
|
|
323
|
+
/** Preview zoom: fit composition inside viewport */
|
|
324
|
+
declare function computeFitZoom(viewportWidth: number, viewportHeight: number, compositionWidth: number, compositionHeight: number, padding?: number): number;
|
|
325
|
+
|
|
326
|
+
declare function getPresetScene(preset: Preset): SceneDocument;
|
|
327
|
+
declare function presetToRecipe(preset: Preset): StyleRecipe;
|
|
328
|
+
declare const builtInRecipes: StyleRecipe[];
|
|
329
|
+
declare function applyRecipeToScene(base: SceneDocument, recipe: StyleRecipe): SceneDocument;
|
|
330
|
+
declare function clearRecipeCache(): void;
|
|
331
|
+
|
|
332
|
+
/** Visible glyph count (newlines excluded). */
|
|
333
|
+
declare function countTextGlyphs(text: string): number;
|
|
334
|
+
declare function resizeCharFillColors(text: string, colors: string[] | undefined, fallback: string): string[];
|
|
335
|
+
declare function setCharFillColor(colors: string[], glyphIndex: number, color: string): string[];
|
|
336
|
+
declare function applyFillColorToAll(colors: string[], color: string): string[];
|
|
337
|
+
/** Simple hue sweep for quick previews */
|
|
338
|
+
declare function rainbowCharFillColors(text: string): string[];
|
|
339
|
+
interface DrawPerCharTextOptions {
|
|
340
|
+
lines: string[];
|
|
341
|
+
startX: number;
|
|
342
|
+
startY: number;
|
|
343
|
+
lineAdvance: number;
|
|
344
|
+
align: CanvasTextAlign;
|
|
345
|
+
letterSpacing: number;
|
|
346
|
+
charFillColors: string[];
|
|
347
|
+
defaultColor: string;
|
|
348
|
+
mode: "fill" | "stroke";
|
|
349
|
+
offsetX?: number;
|
|
350
|
+
offsetY?: number;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Draw text one glyph at a time with per-index fill/stroke colors.
|
|
354
|
+
* Letter spacing is applied manually (canvas letterSpacing reset to 0).
|
|
355
|
+
*/
|
|
356
|
+
declare function drawPerCharText(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, opts: DrawPerCharTextOptions): void;
|
|
357
|
+
declare function shouldUsePerCharFill(cfg: TextEffectConfig): boolean;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Programmatic Lottie Animation Builder and Mutation Engine (Bodymovin Schema)
|
|
361
|
+
* Supports creating compositions from scratch, layer insertions, and visual keyframe timeline tracking.
|
|
362
|
+
*
|
|
363
|
+
* Font Handling:
|
|
364
|
+
* Lottie-web uses the 'fName' property to look up fonts in the browser's CSS.
|
|
365
|
+
* Each font variant (Regular, Bold, Italic, BoldItalic) is registered as a separate
|
|
366
|
+
* font-family name (e.g., "Poppins-Italic") that maps to the actual font with
|
|
367
|
+
* appropriate font-weight and font-style via @font-face rules in index.css.
|
|
368
|
+
*/
|
|
369
|
+
interface EasingControlPoint {
|
|
370
|
+
x: number[];
|
|
371
|
+
y: number[];
|
|
372
|
+
}
|
|
373
|
+
interface LottieKeyframe {
|
|
374
|
+
t: number;
|
|
375
|
+
s: number[] | number;
|
|
376
|
+
i?: EasingControlPoint;
|
|
377
|
+
o?: EasingControlPoint;
|
|
378
|
+
}
|
|
379
|
+
type LottiePropertyPath = "ks.a" | "ks.p" | "ks.s" | "ks.r" | "ks.o";
|
|
380
|
+
/**
|
|
381
|
+
* Creates a valid minimum blank slate Lottie composition
|
|
382
|
+
*/
|
|
383
|
+
declare function createBlankLottie(w: number, h: number, fps: number, durationFrames: number): any;
|
|
384
|
+
/**
|
|
385
|
+
* Re-indexes layer indices (ind) in a Lottie composition to ensure ordering integrity
|
|
386
|
+
*/
|
|
387
|
+
declare function reindexLayers(lottieData: any): void;
|
|
388
|
+
/**
|
|
389
|
+
* Adds a solid background layer (ty === 1) to the composition
|
|
390
|
+
*/
|
|
391
|
+
declare function addSolidLayer(lottieData: any, name: string, color: string, w: number, h: number): any;
|
|
392
|
+
/**
|
|
393
|
+
* Adds a standard vector text layer (ty === 5) to the composition
|
|
394
|
+
*/
|
|
395
|
+
declare function addTextLayer(lottieData: any, name: string, text: string): any;
|
|
396
|
+
/**
|
|
397
|
+
* Adds an empty shape layer (ty === 4) to the composition
|
|
398
|
+
*/
|
|
399
|
+
declare function addShapeLayer(lottieData: any, name: string): any;
|
|
400
|
+
/**
|
|
401
|
+
* Appends a basic vector shape (Rectangle or Ellipse) to a shape layer
|
|
402
|
+
*/
|
|
403
|
+
declare function addVectorShape(lottieData: any, layerIndex: number, shapeType: "rect" | "ellipse", colorHex: string): any;
|
|
404
|
+
/**
|
|
405
|
+
* Updates a static property on a Lottie layer
|
|
406
|
+
*/
|
|
407
|
+
declare function updateStaticProperty(lottieData: any, layerIndex: number, path: LottiePropertyPath, value: number | number[]): any;
|
|
408
|
+
/**
|
|
409
|
+
* Converts a static property to an animated keyframed track, inserting a default start keyframe
|
|
410
|
+
*/
|
|
411
|
+
declare function enableKeyframing(lottieData: any, layerIndex: number, path: LottiePropertyPath): any;
|
|
412
|
+
/**
|
|
413
|
+
* Inserts or updates a keyframe in an animated Lottie property track
|
|
414
|
+
*/
|
|
415
|
+
declare function addOrUpdateKeyframe(lottieData: any, layerIndex: number, path: LottiePropertyPath, frame: number, value: number | number[], easing?: "linear" | "easeIn" | "easeOut" | "easeInOut"): any;
|
|
416
|
+
/**
|
|
417
|
+
* Removes a keyframe from an animated Lottie property track
|
|
418
|
+
*/
|
|
419
|
+
declare function deleteKeyframe(lottieData: any, layerIndex: number, path: LottiePropertyPath, frame: number): any;
|
|
420
|
+
/**
|
|
421
|
+
* Adds an image asset and corresponding Image Layer (ty === 2) to the composition
|
|
422
|
+
*/
|
|
423
|
+
declare function addImageLayer(lottieData: any, name: string, base64Data: string, w: number, h: number): any;
|
|
424
|
+
/**
|
|
425
|
+
* Sets or clears the track matte mask setting of a layer
|
|
426
|
+
* matteType: 0 = None, 1 = Alpha Matte, 2 = Alpha Inverted Matte
|
|
427
|
+
*/
|
|
428
|
+
declare function updateTrackMatte(lottieData: any, layerIndex: number, matteType: number): any;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Lottie JSON Parser
|
|
432
|
+
* Auto-extracts dimensions, length, framerate, and all text layers.
|
|
433
|
+
*/
|
|
434
|
+
interface ParsedTextLayer {
|
|
435
|
+
layerName: string;
|
|
436
|
+
defaultText: string;
|
|
437
|
+
}
|
|
438
|
+
interface LottieFileInfo {
|
|
439
|
+
width: number;
|
|
440
|
+
height: number;
|
|
441
|
+
fps: number;
|
|
442
|
+
durationFrames: number;
|
|
443
|
+
textLayers: ParsedTextLayer[];
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Extracts the default text string from a Lottie layer.t.d.k structure
|
|
447
|
+
*/
|
|
448
|
+
declare function getDefaultText(layer: any): string;
|
|
449
|
+
/**
|
|
450
|
+
* Recursively scans layers (including nested precompositions) for text layers (ty === 5)
|
|
451
|
+
*/
|
|
452
|
+
declare function scanTextLayers(lottieData: any): ParsedTextLayer[];
|
|
453
|
+
/**
|
|
454
|
+
* Parse an uploaded Lottie JSON object to extract metadata and text layers
|
|
455
|
+
*/
|
|
456
|
+
declare function parseLottieJson(lottieData: any): LottieFileInfo;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Lottie Customization & Injections Engine
|
|
460
|
+
* Implements real-time text, color, and full per-layer style mutations.
|
|
461
|
+
*/
|
|
462
|
+
interface TextLayerConfig {
|
|
463
|
+
layerName: string;
|
|
464
|
+
defaultText: string;
|
|
465
|
+
maxCharacters: number;
|
|
466
|
+
role: "primary" | "secondary" | "accent";
|
|
467
|
+
}
|
|
468
|
+
type TextCustomization = {
|
|
469
|
+
primary: string;
|
|
470
|
+
secondary: string;
|
|
471
|
+
accent: string;
|
|
472
|
+
};
|
|
473
|
+
/** Full per-layer text style override — all fields optional */
|
|
474
|
+
interface TextStyleOverride {
|
|
475
|
+
text?: string;
|
|
476
|
+
fontName?: string;
|
|
477
|
+
fontSize?: number;
|
|
478
|
+
fillColor?: string;
|
|
479
|
+
strokeColor?: string;
|
|
480
|
+
strokeWidth?: number;
|
|
481
|
+
tracking?: number;
|
|
482
|
+
lineHeight?: number;
|
|
483
|
+
align?: 0 | 1 | 2 | 3;
|
|
484
|
+
opacity?: number;
|
|
485
|
+
scaleX?: number;
|
|
486
|
+
scaleY?: number;
|
|
487
|
+
posX?: number;
|
|
488
|
+
posY?: number;
|
|
489
|
+
rotation?: number;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Convert #RRGGBB to Lottie normalized [r, g, b] (0–1).
|
|
493
|
+
*/
|
|
494
|
+
declare function hexToLottieRgb(hex: string): [number, number, number];
|
|
495
|
+
/**
|
|
496
|
+
* Inject text content into mapped text layers by role.
|
|
497
|
+
*/
|
|
498
|
+
declare function injectText(lottieData: any, customization: TextCustomization, textLayers: TextLayerConfig[]): any;
|
|
499
|
+
/**
|
|
500
|
+
* Inject a full style override into a specific named text layer.
|
|
501
|
+
*/
|
|
502
|
+
declare function injectTextStyle(lottieData: any, layerName: string, override: TextStyleOverride): any;
|
|
503
|
+
/**
|
|
504
|
+
* Inject style overrides into ALL text layers at once.
|
|
505
|
+
* Useful for applying a global font/color change.
|
|
506
|
+
*/
|
|
507
|
+
declare function injectGlobalTextStyle(lottieData: any, override: Omit<TextStyleOverride, "text" | "posX" | "posY">): any;
|
|
508
|
+
/**
|
|
509
|
+
* Inject fill color into shape layers (ty === "fl") within a named layer.
|
|
510
|
+
*/
|
|
511
|
+
declare function injectColor(lottieData: any, layerName: string, hexColor: string): any;
|
|
512
|
+
/**
|
|
513
|
+
* Inject solid layer background color (ty === 1).
|
|
514
|
+
*/
|
|
515
|
+
declare function injectSolidColor(lottieData: any, layerName: string, hexColor: string): any;
|
|
516
|
+
/**
|
|
517
|
+
* Batch inject multiple overrides in one pass — most efficient for live preview.
|
|
518
|
+
*/
|
|
519
|
+
interface BatchInjection {
|
|
520
|
+
textCustomization?: {
|
|
521
|
+
customization: TextCustomization;
|
|
522
|
+
layers: TextLayerConfig[];
|
|
523
|
+
};
|
|
524
|
+
styleOverrides?: Array<{
|
|
525
|
+
layerName: string;
|
|
526
|
+
override: TextStyleOverride;
|
|
527
|
+
}>;
|
|
528
|
+
colorOverrides?: Array<{
|
|
529
|
+
layerName: string;
|
|
530
|
+
color: string;
|
|
531
|
+
}>;
|
|
532
|
+
solidOverrides?: Array<{
|
|
533
|
+
layerName: string;
|
|
534
|
+
color: string;
|
|
535
|
+
}>;
|
|
536
|
+
hiddenLayers?: Set<number>;
|
|
537
|
+
}
|
|
538
|
+
declare function injectBatch(lottieData: any, batch: BatchInjection): any;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Lottie Text Animation Presets — CapCut-grade entrance, exit, and loop animations.
|
|
542
|
+
* Each preset returns a set of Lottie keyframe tracks to bake into a text layer.
|
|
543
|
+
*/
|
|
544
|
+
type AnimationCategory = "entrance" | "exit" | "loop" | "emphasis";
|
|
545
|
+
interface LottieAnimPreset {
|
|
546
|
+
id: string;
|
|
547
|
+
name: string;
|
|
548
|
+
category: AnimationCategory;
|
|
549
|
+
icon: string;
|
|
550
|
+
description: string;
|
|
551
|
+
/** Duration in frames this animation occupies */
|
|
552
|
+
defaultDurationFrames: number;
|
|
553
|
+
/** Build keyframes for a given layer, start frame, total frames, and comp size */
|
|
554
|
+
buildTracks: (opts: AnimBuildOpts) => AnimTrackDef[];
|
|
555
|
+
}
|
|
556
|
+
interface AnimBuildOpts {
|
|
557
|
+
layerIndex: number;
|
|
558
|
+
startFrame: number;
|
|
559
|
+
endFrame: number;
|
|
560
|
+
totalFrames: number;
|
|
561
|
+
compW: number;
|
|
562
|
+
compH: number;
|
|
563
|
+
/** For exit animations, the frame at which exit begins */
|
|
564
|
+
exitStartFrame?: number;
|
|
565
|
+
}
|
|
566
|
+
interface AnimKeyframe {
|
|
567
|
+
t: number;
|
|
568
|
+
s: number[] | number;
|
|
569
|
+
i?: {
|
|
570
|
+
x: number[];
|
|
571
|
+
y: number[];
|
|
572
|
+
};
|
|
573
|
+
o?: {
|
|
574
|
+
x: number[];
|
|
575
|
+
y: number[];
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
interface AnimTrackDef {
|
|
579
|
+
/** Lottie property path e.g. "ks.p", "ks.s", "ks.o", "ks.r" */
|
|
580
|
+
path: string;
|
|
581
|
+
keyframes: AnimKeyframe[];
|
|
582
|
+
}
|
|
583
|
+
declare const LOTTIE_ANIM_PRESETS: LottieAnimPreset[];
|
|
584
|
+
declare const ENTRANCE_PRESETS: LottieAnimPreset[];
|
|
585
|
+
declare const EXIT_PRESETS: LottieAnimPreset[];
|
|
586
|
+
declare const LOOP_PRESETS: LottieAnimPreset[];
|
|
587
|
+
declare const EMPHASIS_PRESETS: LottieAnimPreset[];
|
|
588
|
+
declare function getAnimPreset(id: string): LottieAnimPreset | undefined;
|
|
589
|
+
/**
|
|
590
|
+
* Bake an animation preset into a Lottie layer's keyframe tracks.
|
|
591
|
+
* Merges with existing keyframes rather than replacing them.
|
|
592
|
+
*/
|
|
593
|
+
declare function bakeAnimationIntoLayer(lottieData: any, layerIndex: number, preset: LottieAnimPreset, opts: Omit<AnimBuildOpts, "layerIndex">): any;
|
|
594
|
+
/**
|
|
595
|
+
* Remove all animation keyframes from a layer property, reverting to static.
|
|
596
|
+
*/
|
|
597
|
+
declare function clearAnimationFromLayer(lottieData: any, layerIndex: number, paths?: string[]): any;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Lottie Per-Layer Text Style Engine
|
|
601
|
+
* Provides rich text styling (font, fill, gradient, stroke, shadow, glow, tracking)
|
|
602
|
+
* that maps directly to Lottie JSON text document properties.
|
|
603
|
+
*/
|
|
604
|
+
type TextAlign = "left" | "center" | "right" | "justify";
|
|
605
|
+
type FillType = "solid" | "gradient";
|
|
606
|
+
type GradientDir = "horizontal" | "vertical" | "diagonal" | "radial";
|
|
607
|
+
interface LottieGradientStop {
|
|
608
|
+
color: string;
|
|
609
|
+
position: number;
|
|
610
|
+
}
|
|
611
|
+
interface TextLayerStyle {
|
|
612
|
+
fontName: string;
|
|
613
|
+
fontFamily: string;
|
|
614
|
+
fontWeight: number;
|
|
615
|
+
fontStyle: "normal" | "italic";
|
|
616
|
+
fontSize: number;
|
|
617
|
+
tracking: number;
|
|
618
|
+
lineHeight: number;
|
|
619
|
+
align: TextAlign;
|
|
620
|
+
fillType: FillType;
|
|
621
|
+
fillColor: string;
|
|
622
|
+
gradientStops: LottieGradientStop[];
|
|
623
|
+
gradientDir: GradientDir;
|
|
624
|
+
strokeEnabled: boolean;
|
|
625
|
+
strokeColor: string;
|
|
626
|
+
strokeWidth: number;
|
|
627
|
+
strokeOpacity: number;
|
|
628
|
+
shadowEnabled: boolean;
|
|
629
|
+
shadowColor: string;
|
|
630
|
+
shadowBlur: number;
|
|
631
|
+
shadowOffsetX: number;
|
|
632
|
+
shadowOffsetY: number;
|
|
633
|
+
shadowOpacity: number;
|
|
634
|
+
glowEnabled: boolean;
|
|
635
|
+
glowColor: string;
|
|
636
|
+
glowBlur: number;
|
|
637
|
+
glowOpacity: number;
|
|
638
|
+
posX: number;
|
|
639
|
+
posY: number;
|
|
640
|
+
scaleX: number;
|
|
641
|
+
scaleY: number;
|
|
642
|
+
rotation: number;
|
|
643
|
+
opacity: number;
|
|
644
|
+
}
|
|
645
|
+
declare const DEFAULT_TEXT_STYLE: TextLayerStyle;
|
|
646
|
+
/** Convert #RRGGBB to Lottie normalized [r, g, b] (0–1) */
|
|
647
|
+
declare function hexToLottieColor(hex: string): [number, number, number];
|
|
648
|
+
/** Convert Lottie [r,g,b] (0–1) back to #RRGGBB */
|
|
649
|
+
declare function lottieColorToHex(rgb: number[]): string;
|
|
650
|
+
/** Map CSS font-weight + style to a Lottie fName */
|
|
651
|
+
declare function buildLottieFontName(family: string, weight: number, style: "normal" | "italic"): string;
|
|
652
|
+
/** Lottie text alignment: 0=left, 1=center, 2=right, 3=justify */
|
|
653
|
+
declare function alignToLottieJ(align: TextAlign): number;
|
|
654
|
+
declare function lottieJToAlign(j: number): TextAlign;
|
|
655
|
+
/**
|
|
656
|
+
* Extract a TextLayerStyle from an existing Lottie text layer (ty === 5).
|
|
657
|
+
* Falls back to defaults for any missing properties.
|
|
658
|
+
*/
|
|
659
|
+
declare function readStyleFromLottieLayer(layer: any): TextLayerStyle;
|
|
660
|
+
/**
|
|
661
|
+
* Apply a TextLayerStyle to a Lottie text layer (ty === 5).
|
|
662
|
+
* Returns a new deep-cloned layer with all style properties applied.
|
|
663
|
+
*/
|
|
664
|
+
declare function applyStyleToLottieLayer(layer: any, style: TextLayerStyle): any;
|
|
665
|
+
/**
|
|
666
|
+
* Apply a TextLayerStyle to a full Lottie composition at a given layer index.
|
|
667
|
+
*/
|
|
668
|
+
declare function applyStyleToLottie(lottieData: any, layerIndex: number, style: TextLayerStyle): any;
|
|
669
|
+
interface LottieFontEntry {
|
|
670
|
+
fName: string;
|
|
671
|
+
fFamily: string;
|
|
672
|
+
fWeight: string;
|
|
673
|
+
fStyle: string;
|
|
674
|
+
asName: string;
|
|
675
|
+
googleFont?: boolean;
|
|
676
|
+
}
|
|
677
|
+
/** Ensure a font is registered in the Lottie fonts list */
|
|
678
|
+
declare function ensureFontInLottie(lottieData: any, entry: LottieFontEntry): any;
|
|
679
|
+
/** Full set of supported fonts with all variants */
|
|
680
|
+
declare const SUPPORTED_FONT_FAMILIES: string[];
|
|
681
|
+
declare const FONT_WEIGHT_OPTIONS: {
|
|
682
|
+
label: string;
|
|
683
|
+
value: number;
|
|
684
|
+
}[];
|
|
685
|
+
/** Build all Lottie font entries for a given family */
|
|
686
|
+
declare function buildFontEntries(family: string): LottieFontEntry[];
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Built-in CapCut-style Lottie text template presets.
|
|
690
|
+
* Each preset is a complete Lottie JSON composition ready to use.
|
|
691
|
+
*/
|
|
692
|
+
type TemplatePresetCategory = "lower-third" | "title-card" | "callout" | "caption" | "kinetic" | "social" | "cinematic" | "sports" | "minimal" | "bold";
|
|
693
|
+
interface LottieTemplatePreset {
|
|
694
|
+
id: string;
|
|
695
|
+
name: string;
|
|
696
|
+
category: TemplatePresetCategory;
|
|
697
|
+
description: string;
|
|
698
|
+
tags: string[];
|
|
699
|
+
aspectRatio: "16:9" | "9:16" | "1:1" | "4:5";
|
|
700
|
+
/** Build and return the Lottie JSON for this preset */
|
|
701
|
+
build: () => any;
|
|
702
|
+
}
|
|
703
|
+
declare const LOTTIE_TEMPLATE_PRESETS: LottieTemplatePreset[];
|
|
704
|
+
declare function getTemplatePreset(id: string): LottieTemplatePreset | undefined;
|
|
705
|
+
declare function getTemplatesByCategory(category: TemplatePresetCategory): LottieTemplatePreset[];
|
|
706
|
+
declare const TEMPLATE_CATEGORIES: TemplatePresetCategory[];
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Lottie Export Engine
|
|
710
|
+
* Supports:
|
|
711
|
+
* - .lottie (dotLottie) — ZIP containing animation.json + manifest.json
|
|
712
|
+
* - .json — raw Lottie JSON
|
|
713
|
+
* - PNG sequence ZIP
|
|
714
|
+
* - Animated GIF (via canvas frame capture)
|
|
715
|
+
*/
|
|
716
|
+
interface DotLottieManifest {
|
|
717
|
+
version: string;
|
|
718
|
+
generator: string;
|
|
719
|
+
animations: Array<{
|
|
720
|
+
id: string;
|
|
721
|
+
speed?: number;
|
|
722
|
+
themeColor?: string;
|
|
723
|
+
loop?: boolean;
|
|
724
|
+
autoplay?: boolean;
|
|
725
|
+
direction?: 1 | -1;
|
|
726
|
+
}>;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Build a .lottie file (ZIP containing animation.json + manifest.json).
|
|
730
|
+
* The .lottie format is the standard used by LottieFiles and dotlottie-player.
|
|
731
|
+
*/
|
|
732
|
+
declare function buildDotLottie(lottieData: object, animationId: string, opts?: {
|
|
733
|
+
loop?: boolean;
|
|
734
|
+
autoplay?: boolean;
|
|
735
|
+
speed?: number;
|
|
736
|
+
}): Promise<Blob>;
|
|
737
|
+
/**
|
|
738
|
+
* Download a .lottie file.
|
|
739
|
+
*/
|
|
740
|
+
declare function downloadDotLottie(lottieData: object, filename: string, animationId?: string, opts?: {
|
|
741
|
+
loop?: boolean;
|
|
742
|
+
autoplay?: boolean;
|
|
743
|
+
speed?: number;
|
|
744
|
+
}): Promise<void>;
|
|
745
|
+
/**
|
|
746
|
+
* Download raw Lottie JSON.
|
|
747
|
+
*/
|
|
748
|
+
declare function downloadLottieJson(lottieData: object, filename: string): void;
|
|
749
|
+
interface GifExportOptions {
|
|
750
|
+
fps?: number;
|
|
751
|
+
duration?: number;
|
|
752
|
+
width?: number;
|
|
753
|
+
height?: number;
|
|
754
|
+
quality?: number;
|
|
755
|
+
loop?: boolean;
|
|
756
|
+
}
|
|
757
|
+
interface GifFrame {
|
|
758
|
+
imageData: ImageData;
|
|
759
|
+
delay: number;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Capture frames from a Lottie animation rendered via lottie-web into a canvas.
|
|
763
|
+
* Returns raw ImageData frames ready for GIF encoding.
|
|
764
|
+
*
|
|
765
|
+
* NOTE: Requires lottie-web to be loaded and the container to be in the DOM.
|
|
766
|
+
*/
|
|
767
|
+
declare function captureLottieFrames(lottieInstance: any, canvas: HTMLCanvasElement, opts?: GifExportOptions): Promise<GifFrame[]>;
|
|
768
|
+
/**
|
|
769
|
+
* Encode frames to an animated GIF using a pure-JS GIF encoder.
|
|
770
|
+
* Uses the omggif library approach (inline minimal encoder).
|
|
771
|
+
*/
|
|
772
|
+
declare function encodeGif(frames: GifFrame[], width: number, height: number, opts?: {
|
|
773
|
+
loop?: boolean;
|
|
774
|
+
quality?: number;
|
|
775
|
+
}): Uint8Array;
|
|
776
|
+
|
|
777
|
+
interface PngSequenceOptions {
|
|
778
|
+
fps?: number;
|
|
779
|
+
duration?: number;
|
|
780
|
+
width?: number;
|
|
781
|
+
height?: number;
|
|
782
|
+
}
|
|
783
|
+
interface PngSequenceFrame {
|
|
784
|
+
index: number;
|
|
785
|
+
time: number;
|
|
786
|
+
dataUrl: string;
|
|
787
|
+
}
|
|
788
|
+
/** Render all frames in-memory (browser) */
|
|
789
|
+
declare function renderPngSequence(doc: SceneDocument, options?: PngSequenceOptions): PngSequenceFrame[];
|
|
790
|
+
/** Build a minimal ZIP (store only, no compression) for PNG frames */
|
|
791
|
+
declare function buildPngSequenceZip(frames: PngSequenceFrame[]): Blob;
|
|
792
|
+
declare function downloadPngSequenceZip(doc: SceneDocument, filename: string, options?: PngSequenceOptions): void;
|
|
793
|
+
declare const WEBM_EXPORT_MAX_FRAMES = 900;
|
|
794
|
+
interface WebMExportOptions extends PngSequenceOptions {
|
|
795
|
+
videoBitsPerSecond?: number;
|
|
796
|
+
/** Pace frame capture so clip duration matches timeline (recommended) */
|
|
797
|
+
realtimePacing?: boolean;
|
|
798
|
+
}
|
|
799
|
+
declare function getSupportedWebMMimeType(): string | null;
|
|
800
|
+
declare function isWebMExportSupported(): boolean;
|
|
801
|
+
declare function getWebMFrameCount(doc: SceneDocument, options?: WebMExportOptions): number;
|
|
802
|
+
/**
|
|
803
|
+
* Encode timeline frames to WebM via MediaRecorder + canvas.captureStream(0).
|
|
804
|
+
* Browser-only; transparent backgrounds may flatten to black in the recording.
|
|
805
|
+
*/
|
|
806
|
+
declare function renderSceneWebM(doc: SceneDocument, options?: WebMExportOptions): Promise<Blob>;
|
|
807
|
+
declare function downloadSceneWebM(doc: SceneDocument, filename: string, options?: WebMExportOptions): Promise<void>;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Google Fonts loader for the Lottie Studio.
|
|
811
|
+
* Scans a Lottie composition for all font families used, then injects
|
|
812
|
+
* the appropriate Google Fonts stylesheet + @font-face rules so
|
|
813
|
+
* lottie-web can resolve them by fName.
|
|
814
|
+
*/
|
|
815
|
+
interface LottieFontUsage {
|
|
816
|
+
fName: string;
|
|
817
|
+
fFamily: string;
|
|
818
|
+
fWeight: number;
|
|
819
|
+
fStyle: "normal" | "italic";
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Scan a Lottie JSON object and return all unique font usages.
|
|
823
|
+
*/
|
|
824
|
+
declare function scanLottieFonts(lottieData: any): LottieFontUsage[];
|
|
825
|
+
/**
|
|
826
|
+
* Inject Google Fonts stylesheets for all non-system fonts found in a Lottie.
|
|
827
|
+
* Also injects @font-face rules that map Lottie fName → CSS font-family.
|
|
828
|
+
* Safe to call multiple times — deduplicates by family.
|
|
829
|
+
*/
|
|
830
|
+
declare function loadLottieFonts(lottieData: any): void;
|
|
831
|
+
/**
|
|
832
|
+
* Wait for all fonts currently in the document to be loaded.
|
|
833
|
+
* Useful before capturing thumbnails or exporting frames.
|
|
834
|
+
*/
|
|
835
|
+
declare function waitForFontsReady(): Promise<void>;
|
|
836
|
+
/**
|
|
837
|
+
* Preload a specific Google Font family with given weights.
|
|
838
|
+
* Useful for the Style Editor font picker.
|
|
839
|
+
*/
|
|
840
|
+
declare function preloadGoogleFont(family: string, weights?: number[]): void;
|
|
841
|
+
/**
|
|
842
|
+
* Clear the font loading cache (useful for testing).
|
|
843
|
+
*/
|
|
844
|
+
declare function clearFontCache(): void;
|
|
845
|
+
|
|
846
|
+
interface AnimatableParamDef {
|
|
847
|
+
path: string;
|
|
848
|
+
label: string;
|
|
849
|
+
min?: number;
|
|
850
|
+
max?: number;
|
|
851
|
+
step?: number;
|
|
852
|
+
unit?: string;
|
|
853
|
+
}
|
|
854
|
+
declare function getAnimatableParamsForLayer(layer: EffectLayer): AnimatableParamDef[];
|
|
855
|
+
declare function getAnimatableParamDef(layer: EffectLayer, paramPath: string): AnimatableParamDef | undefined;
|
|
856
|
+
declare function readLayerScalar(layer: EffectLayer, paramPath: string): number;
|
|
857
|
+
|
|
858
|
+
/** Blend two scenes by layer params (Lab preset blend) */
|
|
859
|
+
declare function blendScenes(sceneA: SceneDocument, sceneB: SceneDocument, ratio: number): SceneDocument;
|
|
860
|
+
declare function blendConfigs(cfgA: TextEffectConfig, cfgB: TextEffectConfig, ratio: number): TextEffectConfig;
|
|
861
|
+
|
|
862
|
+
declare function parseHistorySnapshot(raw: string): {
|
|
863
|
+
scene: SceneDocument;
|
|
864
|
+
config: TextEffectConfig;
|
|
865
|
+
};
|
|
866
|
+
declare function snapshotScene(scene: SceneDocument): string;
|
|
867
|
+
|
|
868
|
+
/** Apply rectangular wipe reveal (MVP mask) on composed canvas */
|
|
869
|
+
declare function applyMaskReveal(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, doc: SceneDocument, width: number, height: number): void;
|
|
870
|
+
|
|
871
|
+
/** Attach MVP demo animation tracks (shadow drift + optional mask reveal) */
|
|
872
|
+
declare function ensureDefaultTimeline(doc: SceneDocument): SceneDocument;
|
|
873
|
+
declare function cloneSceneWithNewIds(doc: SceneDocument): SceneDocument;
|
|
874
|
+
|
|
875
|
+
declare function trackId(track: AnimTrack): string;
|
|
876
|
+
declare function findTrackIndex(doc: SceneDocument, layerId: string, paramPath: string): number;
|
|
877
|
+
declare function getLayerById(doc: SceneDocument, layerId: string): EffectLayer;
|
|
878
|
+
declare function updateTimeline(doc: SceneDocument, patch: Partial<SceneDocument["timeline"]>): SceneDocument;
|
|
879
|
+
declare function setTracks(doc: SceneDocument, tracks: AnimTrack[]): SceneDocument;
|
|
880
|
+
declare function pruneTracksForLayer(doc: SceneDocument, layerId: string): SceneDocument;
|
|
881
|
+
declare function addTrack(doc: SceneDocument, layerId: string, paramPath: string, initialKeyframes?: Keyframe[]): SceneDocument;
|
|
882
|
+
declare function removeTrack(doc: SceneDocument, trackIndex: number): SceneDocument;
|
|
883
|
+
declare function updateTrack(doc: SceneDocument, trackIndex: number, updater: (track: AnimTrack) => AnimTrack): SceneDocument;
|
|
884
|
+
declare function sortKeyframes(keyframes: Keyframe[]): Keyframe[];
|
|
885
|
+
declare function upsertKeyframe(track: AnimTrack, time: number, value?: number, easing?: Keyframe["easing"]): AnimTrack;
|
|
886
|
+
declare function addKeyframeAtTime(doc: SceneDocument, trackIndex: number, time: number, value?: number): SceneDocument;
|
|
887
|
+
declare function moveKeyframe(doc: SceneDocument, trackIndex: number, keyframeIndex: number, time: number, duration: number): SceneDocument;
|
|
888
|
+
declare function updateKeyframe(doc: SceneDocument, trackIndex: number, keyframeIndex: number, patch: Partial<Keyframe>): SceneDocument;
|
|
889
|
+
declare function removeKeyframe(doc: SceneDocument, trackIndex: number, keyframeIndex: number): SceneDocument;
|
|
890
|
+
declare function duplicateTrackAtPlayhead(doc: SceneDocument, trackIndex: number, previewTime: number): SceneDocument;
|
|
891
|
+
|
|
892
|
+
export { type AnimBuildOpts, type AnimKeyframe, type AnimTrack, type AnimTrackDef, type AnimatableParamDef, type AnimationCategory, type BatchInjection, COMPOSITION_PRESETS, CUSTOM_ENGINE_IDS, type CompositionPreset, type CompositorFromScene, type CompositorSettings, type CustomEngineId, DEFAULT_TEXT_STYLE, type DotLottieManifest, type DrawPerCharTextOptions, EMPHASIS_PRESETS, ENGINE_ID_TO_LEGACY, ENTRANCE_PRESETS, EXIT_PRESETS, type EasingControlPoint, type EffectLayer, type EffectLayerType, type EvaluateOptions, FONT_WEIGHT_OPTIONS, type FillType, type FontVariant, type GifExportOptions, type GifFrame, type GlowLayer, type GradientDir, type GradientStop, type Keyframe, LEGACY_RENDERER_MAP, LOOP_PRESETS, LOTTIE_ANIM_PRESETS, LOTTIE_TEMPLATE_PRESETS, type LayerTarget, type LottieAnimPreset, type LottieFileInfo, type LottieFontEntry, type LottieFontUsage, type LottieGradientStop, type LottieKeyframe, type LottiePropertyPath, type LottieTemplatePreset, type ParsedTextLayer, type PngSequenceFrame, type PngSequenceOptions, type Preset, SCENE_VERSION, SUPPORTED_FONT_FAMILIES, type SceneCanvas, type SceneDocument, type SceneText, type StyleRecipe, TEMPLATE_CATEGORIES, type TemplatePresetCategory, type TextAlign, type TextCustomization, type TextEffectConfig, TextEffectRenderer, type TextLayerConfig, type TextLayerStyle, type TextLayoutBounds, type TextLayoutResult, type TextStyleOverride, type Timeline, WEBM_EXPORT_MAX_FRAMES, WebGLCompositor, type WebMExportOptions, addImageLayer, addKeyframeAtTime, addOrUpdateKeyframe, addShapeLayer, addSolidLayer, addTextLayer, addTrack, addVectorShape, advanceSceneTime, alignToLottieJ, applyFillColorToAll, applyMaskReveal, applyRecipeToScene, applyStyleToLottie, applyStyleToLottieLayer, applyTimelineAtTime, bakeAnimationIntoLayer, blendConfigs, blendScenes, buildDotLottie, buildFontEntries, buildLottieFontName, buildPngSequenceZip, builtInPresets, builtInRecipes, captureLottieFrames, checkFontVariant, clearAnimationFromLayer, clearFontCache, clearRecipeCache, cloneSceneWithNewIds, computeAutoFitFontSize, computeFitZoom, computeTextLayout, countTextGlyphs, createBlankLottie, createDefaultRevealTrack, createEmptyScene, createPulseOpacityTrack, defaultConfig, deleteKeyframe, downloadDotLottie, downloadLottieJson, downloadPngSequenceZip, downloadSceneWebM, drawPerCharText, duplicateTrackAtPlayhead, ease, enableKeyframing, encodeGif, ensureDefaultTimeline, ensureFontInLottie, evaluateConfig, evaluateScene, findTrackIndex, getAnimPreset, getAnimatableParamDef, getAnimatableParamsForLayer, getDefaultText, getLayerById, getPresetScene, getSceneTime, getSupportedWebMMimeType, getTemplatePreset, getTemplatesByCategory, getWebMFrameCount, hexToLottieColor, hexToLottieRgb, initializeFontSystem, injectBatch, injectColor, injectFontVariantRules, injectGlobalTextStyle, injectSolidColor, injectText, injectTextStyle, isWebMExportSupported, loadLottieFonts, lottieColorToHex, lottieJToAlign, measureTextFits, mergeSceneIntoConfig, moveKeyframe, newLayerId, parseHistorySnapshot, parseLottieJson, preloadGoogleFont, presetToRecipe, pruneTracksForLayer, rainbowCharFillColors, readLayerScalar, readStyleFromLottieLayer, reindexLayers, removeKeyframe, removeTrack, renderPngSequence, renderSceneWebM, renderTextEffectCore, resetSceneTime, resizeCharFillColors, resolveAnimatedScalar, resolveCustomEngineId, scanLottieFonts, scanTextLayers, sceneToConfig, setCharFillColor, setSceneTime, setTracks, shouldUsePerCharFill, snapshotScene, sortKeyframes, syncCompositorFromScene, textEffectConfigToScene, trackId, updateKeyframe, updateStaticProperty, updateTimeline, updateTrack, updateTrackMatte, upsertKeyframe, waitForFontsReady, wrapTextToWidth };
|