@clypra/engine 1.1.0 → 1.1.2
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 +426 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -4
- package/dist/index.d.ts +168 -4
- package/dist/index.js +417 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -202,6 +202,96 @@ interface Preset {
|
|
|
202
202
|
category?: "3d" | "Neon" | "Metallic" | "Glitch" | "Retro" | "Gradient" | "Grunge" | "Outline" | "Shadow" | "Elements" | "Luxury" | "Classic" | "Experimental" | string;
|
|
203
203
|
createdAt?: number;
|
|
204
204
|
}
|
|
205
|
+
interface EffectIndexItem {
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
category: string;
|
|
209
|
+
description?: string;
|
|
210
|
+
tags?: string[];
|
|
211
|
+
isPremium?: boolean;
|
|
212
|
+
previewType?: 'static' | 'video' | 'lottie';
|
|
213
|
+
thumbnailUrl?: string;
|
|
214
|
+
thumbnail?: string;
|
|
215
|
+
previewUrl?: string;
|
|
216
|
+
durationMs?: number;
|
|
217
|
+
}
|
|
218
|
+
interface EffectFullDefinition extends EffectIndexItem {
|
|
219
|
+
version?: string;
|
|
220
|
+
description: string;
|
|
221
|
+
tags: string[];
|
|
222
|
+
font: {
|
|
223
|
+
family: string;
|
|
224
|
+
weight: number;
|
|
225
|
+
style: "normal" | "italic";
|
|
226
|
+
letterSpacing: number;
|
|
227
|
+
lineHeight: number;
|
|
228
|
+
};
|
|
229
|
+
fills: any[];
|
|
230
|
+
strokes: any[];
|
|
231
|
+
shadows: any[];
|
|
232
|
+
bevel?: any;
|
|
233
|
+
glow?: any;
|
|
234
|
+
glows?: any[];
|
|
235
|
+
panel?: any;
|
|
236
|
+
glitch?: any;
|
|
237
|
+
animation?: {
|
|
238
|
+
type: "none" | "typewriter" | "wave" | "fade" | "glitch";
|
|
239
|
+
speed?: number;
|
|
240
|
+
amplitude?: number;
|
|
241
|
+
frequency?: number;
|
|
242
|
+
};
|
|
243
|
+
background?: any;
|
|
244
|
+
stack?: any;
|
|
245
|
+
}
|
|
246
|
+
interface TextEffectDefinition extends EffectFullDefinition {
|
|
247
|
+
text?: string;
|
|
248
|
+
description: string;
|
|
249
|
+
tags: string[];
|
|
250
|
+
}
|
|
251
|
+
interface EvaluatedTextLayer {
|
|
252
|
+
readonly layerId: string;
|
|
253
|
+
readonly clipId: string;
|
|
254
|
+
readonly role: string;
|
|
255
|
+
readonly zIndex: number;
|
|
256
|
+
readonly layerType: "text";
|
|
257
|
+
readonly x: number;
|
|
258
|
+
readonly y: number;
|
|
259
|
+
readonly width: number;
|
|
260
|
+
readonly height: number;
|
|
261
|
+
readonly rotation: number;
|
|
262
|
+
readonly opacity: number;
|
|
263
|
+
readonly inTransition: boolean;
|
|
264
|
+
readonly blendMode: string;
|
|
265
|
+
readonly time?: number;
|
|
266
|
+
readonly clipStartTime?: number;
|
|
267
|
+
readonly clipDuration?: number;
|
|
268
|
+
readonly text: string;
|
|
269
|
+
readonly fontFamily: string;
|
|
270
|
+
readonly fontSize: number;
|
|
271
|
+
readonly color: string;
|
|
272
|
+
readonly fontWeight: "normal" | "bold" | number;
|
|
273
|
+
readonly fontStyle: "normal" | "italic";
|
|
274
|
+
readonly textAlign: "left" | "center" | "right";
|
|
275
|
+
readonly verticalAlign: "top" | "middle" | "bottom";
|
|
276
|
+
readonly lineHeight: number;
|
|
277
|
+
readonly letterSpacing: number;
|
|
278
|
+
readonly stroke?: {
|
|
279
|
+
color: string;
|
|
280
|
+
width: number;
|
|
281
|
+
};
|
|
282
|
+
readonly shadow?: {
|
|
283
|
+
color: string;
|
|
284
|
+
blur: number;
|
|
285
|
+
offsetX: number;
|
|
286
|
+
offsetY: number;
|
|
287
|
+
};
|
|
288
|
+
readonly background?: {
|
|
289
|
+
color: string;
|
|
290
|
+
padding: number;
|
|
291
|
+
borderRadius: number;
|
|
292
|
+
};
|
|
293
|
+
readonly styleId?: string;
|
|
294
|
+
}
|
|
205
295
|
|
|
206
296
|
declare function renderTextEffectCore(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig): void;
|
|
207
297
|
declare class TextEffectRenderer {
|
|
@@ -235,9 +325,48 @@ declare function injectFontVariantRules(): void;
|
|
|
235
325
|
*/
|
|
236
326
|
declare function initializeFontSystem(): Promise<void>;
|
|
237
327
|
/**
|
|
238
|
-
* Checks if a font variant is available for rendering
|
|
328
|
+
* Checks if a font variant is available for rendering.
|
|
329
|
+
* Uses document.fonts.check() which is the correct API for font availability —
|
|
330
|
+
* unlike measureText() which silently falls back to the system font and always
|
|
331
|
+
* returns a non-zero width regardless of whether the named font loaded.
|
|
239
332
|
*/
|
|
240
333
|
declare function checkFontVariant(variantName: string): boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Font descriptor for loading.
|
|
336
|
+
*/
|
|
337
|
+
interface FontDescriptor {
|
|
338
|
+
family: string;
|
|
339
|
+
weight?: string | number;
|
|
340
|
+
style?: "normal" | "italic";
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Font loading result.
|
|
344
|
+
*/
|
|
345
|
+
interface FontLoadResult {
|
|
346
|
+
font: FontDescriptor;
|
|
347
|
+
loaded: boolean;
|
|
348
|
+
error?: string;
|
|
349
|
+
loadTimeMs: number;
|
|
350
|
+
}
|
|
351
|
+
declare class FontLoader {
|
|
352
|
+
private state;
|
|
353
|
+
ensureFont(descriptor: FontDescriptor): Promise<FontLoadResult>;
|
|
354
|
+
ensureFonts(descriptors: FontDescriptor[]): Promise<FontLoadResult[]>;
|
|
355
|
+
waitForFontsReady(): Promise<void>;
|
|
356
|
+
isLoaded(descriptor: FontDescriptor): boolean;
|
|
357
|
+
getStats(): {
|
|
358
|
+
loaded: number;
|
|
359
|
+
loading: number;
|
|
360
|
+
failed: number;
|
|
361
|
+
};
|
|
362
|
+
clear(): void;
|
|
363
|
+
private loadFont;
|
|
364
|
+
private getFontKey;
|
|
365
|
+
private normalizeFontWeight;
|
|
366
|
+
}
|
|
367
|
+
declare function getFontLoader(): FontLoader;
|
|
368
|
+
declare function resetFontLoader(): void;
|
|
369
|
+
declare function ensureFontsLoaded(descriptors: FontDescriptor[]): Promise<FontLoadResult[]>;
|
|
241
370
|
|
|
242
371
|
declare function resolveCustomEngineId(cfg: TextEffectConfig): CustomEngineId | null;
|
|
243
372
|
/** Lossless migration from flat TextEffectConfig to SceneDocument */
|
|
@@ -252,6 +381,15 @@ interface CompositorFromScene {
|
|
|
252
381
|
}
|
|
253
382
|
/** Apply engine params from scene onto config without require() */
|
|
254
383
|
declare function mergeSceneIntoConfig(doc: SceneDocument, base: TextEffectConfig): TextEffectConfig;
|
|
384
|
+
declare function resolveFontFamilyName(fontFamily: string): string;
|
|
385
|
+
declare function _buildConfig(effect: TextEffectDefinition, text: string, fontSize: number, canvasWidth: number, canvasHeight: number, time?: number, clipStartTime?: number, clipDuration?: number): TextEffectConfig & {
|
|
386
|
+
width: number;
|
|
387
|
+
height: number;
|
|
388
|
+
};
|
|
389
|
+
declare function layerToTextEffectConfig(layer: EvaluatedTextLayer): TextEffectConfig & {
|
|
390
|
+
width: number;
|
|
391
|
+
height: number;
|
|
392
|
+
};
|
|
255
393
|
|
|
256
394
|
declare class WebGLCompositor {
|
|
257
395
|
private gl;
|
|
@@ -270,6 +408,11 @@ interface EvaluateOptions {
|
|
|
270
408
|
compositor?: WebGLCompositor | null;
|
|
271
409
|
skipPostFx?: boolean;
|
|
272
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Dispose the shared module-level compositor and release GPU resources.
|
|
413
|
+
* Call on hot-module-reload or application teardown to prevent WebGL context leaks.
|
|
414
|
+
*/
|
|
415
|
+
declare function disposeSharedCompositor(): void;
|
|
273
416
|
/**
|
|
274
417
|
* Single source of truth for rendering a scene at time t.
|
|
275
418
|
*/
|
|
@@ -958,14 +1101,35 @@ declare function createCanvas(width: number, height: number): HTMLCanvasElement
|
|
|
958
1101
|
* Release a DOM canvas created via createCanvas() when OffscreenCanvas
|
|
959
1102
|
* was unavailable. No-op for OffscreenCanvas instances.
|
|
960
1103
|
*
|
|
961
|
-
*
|
|
962
|
-
*
|
|
1104
|
+
* Sets width/height to 0 to release the backing store immediately rather
|
|
1105
|
+
* than waiting for GC. Call this after extracting ImageBitmap/ImageData.
|
|
963
1106
|
*/
|
|
964
1107
|
declare function releaseCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
965
1108
|
/**
|
|
966
1109
|
* Reset all cached capability flags (for testing only).
|
|
967
1110
|
*/
|
|
968
1111
|
declare function _resetPlatformCache(): void;
|
|
1112
|
+
/**
|
|
1113
|
+
* Unified resource allocator and manager for OffscreenCanvas and DOM Canvas pools.
|
|
1114
|
+
* Prevents GC thrashing and backing store leaks across WKWebView and standard browsers.
|
|
1115
|
+
*/
|
|
1116
|
+
declare class CanvasDevice {
|
|
1117
|
+
private static canvases;
|
|
1118
|
+
private static maxPoolSize;
|
|
1119
|
+
/**
|
|
1120
|
+
* Acquire a Canvas context from the pool or create a new one.
|
|
1121
|
+
* If a canvas is pulled from the pool, it is resized to the target dimensions.
|
|
1122
|
+
*/
|
|
1123
|
+
static acquire(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
|
|
1124
|
+
/**
|
|
1125
|
+
* Release a canvas back to the pool, or free its resources immediately if pool is full.
|
|
1126
|
+
*/
|
|
1127
|
+
static release(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
1128
|
+
/**
|
|
1129
|
+
* Disposes all pooled canvases to release GPU/memory backing stores.
|
|
1130
|
+
*/
|
|
1131
|
+
static clearPool(): void;
|
|
1132
|
+
}
|
|
969
1133
|
|
|
970
1134
|
/**
|
|
971
1135
|
* Canvas 2D utility helpers
|
|
@@ -1019,4 +1183,4 @@ declare class InkBrushEngine {
|
|
|
1019
1183
|
drawFrame(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1020
1184
|
}
|
|
1021
1185
|
|
|
1022
|
-
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_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_DURATION, DEFAULT_FONT_SIZE, DEFAULT_FPS, 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, InkBrushEngine, 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, _resetPlatformCache, addImageLayer, addKeyframeAtTime, addOrUpdateKeyframe, addShapeLayer, addSolidLayer, addTextLayer, addTrack, addVectorShape, advanceSceneTime, alignToLottieJ, applyFillColorToAll, applyLetterSpacing, 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, createCanvas, createDefaultRevealTrack, createEmptyScene, createPulseOpacityTrack, defaultConfig, deleteKeyframe, downloadDotLottie, downloadLottieJson, downloadPngSequenceZip, downloadSceneWebM, drawPerCharText, drawRoundedRect, 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, releaseCanvas, removeKeyframe, removeTrack, renderPngSequence, renderSceneWebM, renderTextEffectCore, resetSceneTime, resizeCharFillColors, resolveAnimatedScalar, resolveCustomEngineId, restoreLetterSpacing, scanLottieFonts, scanTextLayers, sceneToConfig, setCharFillColor, setSceneTime, setTracks, shouldUsePerCharFill, snapshotScene, sortKeyframes, supportsCtxFilter, supportsLetterSpacing, supportsOffscreenCanvas, supportsRoundRect, supportsWebGL2, syncCompositorFromScene, textEffectConfigToScene, trackId, updateKeyframe, updateStaticProperty, updateTimeline, updateTrack, updateTrackMatte, upsertKeyframe, waitForFontsReady, wrapTextToWidth };
|
|
1186
|
+
export { type AnimBuildOpts, type AnimKeyframe, type AnimTrack, type AnimTrackDef, type AnimatableParamDef, type AnimationCategory, type BatchInjection, COMPOSITION_PRESETS, CUSTOM_ENGINE_IDS, CanvasDevice, type CompositionPreset, type CompositorFromScene, type CompositorSettings, type CustomEngineId, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_DURATION, DEFAULT_FONT_SIZE, DEFAULT_FPS, DEFAULT_TEXT_STYLE, type DotLottieManifest, type DrawPerCharTextOptions, EMPHASIS_PRESETS, ENGINE_ID_TO_LEGACY, ENTRANCE_PRESETS, EXIT_PRESETS, type EasingControlPoint, type EffectFullDefinition, type EffectIndexItem, type EffectLayer, type EffectLayerType, type EvaluateOptions, type EvaluatedTextLayer, FONT_WEIGHT_OPTIONS, type FillType, type FontDescriptor, type FontLoadResult, FontLoader, type FontVariant, type GifExportOptions, type GifFrame, type GlowLayer, type GradientDir, type GradientStop, InkBrushEngine, 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, type TextEffectDefinition, TextEffectRenderer, type TextLayerConfig, type TextLayerStyle, type TextLayoutBounds, type TextLayoutResult, type TextStyleOverride, type Timeline, WEBM_EXPORT_MAX_FRAMES, WebGLCompositor, type WebMExportOptions, _buildConfig, _resetPlatformCache, addImageLayer, addKeyframeAtTime, addOrUpdateKeyframe, addShapeLayer, addSolidLayer, addTextLayer, addTrack, addVectorShape, advanceSceneTime, alignToLottieJ, applyFillColorToAll, applyLetterSpacing, 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, createCanvas, createDefaultRevealTrack, createEmptyScene, createPulseOpacityTrack, defaultConfig, deleteKeyframe, disposeSharedCompositor, downloadDotLottie, downloadLottieJson, downloadPngSequenceZip, downloadSceneWebM, drawPerCharText, drawRoundedRect, duplicateTrackAtPlayhead, ease, enableKeyframing, encodeGif, ensureDefaultTimeline, ensureFontInLottie, ensureFontsLoaded, evaluateConfig, evaluateScene, findTrackIndex, getAnimPreset, getAnimatableParamDef, getAnimatableParamsForLayer, getDefaultText, getFontLoader, getLayerById, getPresetScene, getSceneTime, getSupportedWebMMimeType, getTemplatePreset, getTemplatesByCategory, getWebMFrameCount, hexToLottieColor, hexToLottieRgb, initializeFontSystem, injectBatch, injectColor, injectFontVariantRules, injectGlobalTextStyle, injectSolidColor, injectText, injectTextStyle, isWebMExportSupported, layerToTextEffectConfig, loadLottieFonts, lottieColorToHex, lottieJToAlign, measureTextFits, mergeSceneIntoConfig, moveKeyframe, newLayerId, parseHistorySnapshot, parseLottieJson, preloadGoogleFont, presetToRecipe, pruneTracksForLayer, rainbowCharFillColors, readLayerScalar, readStyleFromLottieLayer, reindexLayers, releaseCanvas, removeKeyframe, removeTrack, renderPngSequence, renderSceneWebM, renderTextEffectCore, resetFontLoader, resetSceneTime, resizeCharFillColors, resolveAnimatedScalar, resolveCustomEngineId, resolveFontFamilyName, restoreLetterSpacing, scanLottieFonts, scanTextLayers, sceneToConfig, setCharFillColor, setSceneTime, setTracks, shouldUsePerCharFill, snapshotScene, sortKeyframes, supportsCtxFilter, supportsLetterSpacing, supportsOffscreenCanvas, supportsRoundRect, supportsWebGL2, syncCompositorFromScene, textEffectConfigToScene, trackId, updateKeyframe, updateStaticProperty, updateTimeline, updateTrack, updateTrackMatte, upsertKeyframe, waitForFontsReady, wrapTextToWidth };
|
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,96 @@ interface Preset {
|
|
|
202
202
|
category?: "3d" | "Neon" | "Metallic" | "Glitch" | "Retro" | "Gradient" | "Grunge" | "Outline" | "Shadow" | "Elements" | "Luxury" | "Classic" | "Experimental" | string;
|
|
203
203
|
createdAt?: number;
|
|
204
204
|
}
|
|
205
|
+
interface EffectIndexItem {
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
category: string;
|
|
209
|
+
description?: string;
|
|
210
|
+
tags?: string[];
|
|
211
|
+
isPremium?: boolean;
|
|
212
|
+
previewType?: 'static' | 'video' | 'lottie';
|
|
213
|
+
thumbnailUrl?: string;
|
|
214
|
+
thumbnail?: string;
|
|
215
|
+
previewUrl?: string;
|
|
216
|
+
durationMs?: number;
|
|
217
|
+
}
|
|
218
|
+
interface EffectFullDefinition extends EffectIndexItem {
|
|
219
|
+
version?: string;
|
|
220
|
+
description: string;
|
|
221
|
+
tags: string[];
|
|
222
|
+
font: {
|
|
223
|
+
family: string;
|
|
224
|
+
weight: number;
|
|
225
|
+
style: "normal" | "italic";
|
|
226
|
+
letterSpacing: number;
|
|
227
|
+
lineHeight: number;
|
|
228
|
+
};
|
|
229
|
+
fills: any[];
|
|
230
|
+
strokes: any[];
|
|
231
|
+
shadows: any[];
|
|
232
|
+
bevel?: any;
|
|
233
|
+
glow?: any;
|
|
234
|
+
glows?: any[];
|
|
235
|
+
panel?: any;
|
|
236
|
+
glitch?: any;
|
|
237
|
+
animation?: {
|
|
238
|
+
type: "none" | "typewriter" | "wave" | "fade" | "glitch";
|
|
239
|
+
speed?: number;
|
|
240
|
+
amplitude?: number;
|
|
241
|
+
frequency?: number;
|
|
242
|
+
};
|
|
243
|
+
background?: any;
|
|
244
|
+
stack?: any;
|
|
245
|
+
}
|
|
246
|
+
interface TextEffectDefinition extends EffectFullDefinition {
|
|
247
|
+
text?: string;
|
|
248
|
+
description: string;
|
|
249
|
+
tags: string[];
|
|
250
|
+
}
|
|
251
|
+
interface EvaluatedTextLayer {
|
|
252
|
+
readonly layerId: string;
|
|
253
|
+
readonly clipId: string;
|
|
254
|
+
readonly role: string;
|
|
255
|
+
readonly zIndex: number;
|
|
256
|
+
readonly layerType: "text";
|
|
257
|
+
readonly x: number;
|
|
258
|
+
readonly y: number;
|
|
259
|
+
readonly width: number;
|
|
260
|
+
readonly height: number;
|
|
261
|
+
readonly rotation: number;
|
|
262
|
+
readonly opacity: number;
|
|
263
|
+
readonly inTransition: boolean;
|
|
264
|
+
readonly blendMode: string;
|
|
265
|
+
readonly time?: number;
|
|
266
|
+
readonly clipStartTime?: number;
|
|
267
|
+
readonly clipDuration?: number;
|
|
268
|
+
readonly text: string;
|
|
269
|
+
readonly fontFamily: string;
|
|
270
|
+
readonly fontSize: number;
|
|
271
|
+
readonly color: string;
|
|
272
|
+
readonly fontWeight: "normal" | "bold" | number;
|
|
273
|
+
readonly fontStyle: "normal" | "italic";
|
|
274
|
+
readonly textAlign: "left" | "center" | "right";
|
|
275
|
+
readonly verticalAlign: "top" | "middle" | "bottom";
|
|
276
|
+
readonly lineHeight: number;
|
|
277
|
+
readonly letterSpacing: number;
|
|
278
|
+
readonly stroke?: {
|
|
279
|
+
color: string;
|
|
280
|
+
width: number;
|
|
281
|
+
};
|
|
282
|
+
readonly shadow?: {
|
|
283
|
+
color: string;
|
|
284
|
+
blur: number;
|
|
285
|
+
offsetX: number;
|
|
286
|
+
offsetY: number;
|
|
287
|
+
};
|
|
288
|
+
readonly background?: {
|
|
289
|
+
color: string;
|
|
290
|
+
padding: number;
|
|
291
|
+
borderRadius: number;
|
|
292
|
+
};
|
|
293
|
+
readonly styleId?: string;
|
|
294
|
+
}
|
|
205
295
|
|
|
206
296
|
declare function renderTextEffectCore(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig): void;
|
|
207
297
|
declare class TextEffectRenderer {
|
|
@@ -235,9 +325,48 @@ declare function injectFontVariantRules(): void;
|
|
|
235
325
|
*/
|
|
236
326
|
declare function initializeFontSystem(): Promise<void>;
|
|
237
327
|
/**
|
|
238
|
-
* Checks if a font variant is available for rendering
|
|
328
|
+
* Checks if a font variant is available for rendering.
|
|
329
|
+
* Uses document.fonts.check() which is the correct API for font availability —
|
|
330
|
+
* unlike measureText() which silently falls back to the system font and always
|
|
331
|
+
* returns a non-zero width regardless of whether the named font loaded.
|
|
239
332
|
*/
|
|
240
333
|
declare function checkFontVariant(variantName: string): boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Font descriptor for loading.
|
|
336
|
+
*/
|
|
337
|
+
interface FontDescriptor {
|
|
338
|
+
family: string;
|
|
339
|
+
weight?: string | number;
|
|
340
|
+
style?: "normal" | "italic";
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Font loading result.
|
|
344
|
+
*/
|
|
345
|
+
interface FontLoadResult {
|
|
346
|
+
font: FontDescriptor;
|
|
347
|
+
loaded: boolean;
|
|
348
|
+
error?: string;
|
|
349
|
+
loadTimeMs: number;
|
|
350
|
+
}
|
|
351
|
+
declare class FontLoader {
|
|
352
|
+
private state;
|
|
353
|
+
ensureFont(descriptor: FontDescriptor): Promise<FontLoadResult>;
|
|
354
|
+
ensureFonts(descriptors: FontDescriptor[]): Promise<FontLoadResult[]>;
|
|
355
|
+
waitForFontsReady(): Promise<void>;
|
|
356
|
+
isLoaded(descriptor: FontDescriptor): boolean;
|
|
357
|
+
getStats(): {
|
|
358
|
+
loaded: number;
|
|
359
|
+
loading: number;
|
|
360
|
+
failed: number;
|
|
361
|
+
};
|
|
362
|
+
clear(): void;
|
|
363
|
+
private loadFont;
|
|
364
|
+
private getFontKey;
|
|
365
|
+
private normalizeFontWeight;
|
|
366
|
+
}
|
|
367
|
+
declare function getFontLoader(): FontLoader;
|
|
368
|
+
declare function resetFontLoader(): void;
|
|
369
|
+
declare function ensureFontsLoaded(descriptors: FontDescriptor[]): Promise<FontLoadResult[]>;
|
|
241
370
|
|
|
242
371
|
declare function resolveCustomEngineId(cfg: TextEffectConfig): CustomEngineId | null;
|
|
243
372
|
/** Lossless migration from flat TextEffectConfig to SceneDocument */
|
|
@@ -252,6 +381,15 @@ interface CompositorFromScene {
|
|
|
252
381
|
}
|
|
253
382
|
/** Apply engine params from scene onto config without require() */
|
|
254
383
|
declare function mergeSceneIntoConfig(doc: SceneDocument, base: TextEffectConfig): TextEffectConfig;
|
|
384
|
+
declare function resolveFontFamilyName(fontFamily: string): string;
|
|
385
|
+
declare function _buildConfig(effect: TextEffectDefinition, text: string, fontSize: number, canvasWidth: number, canvasHeight: number, time?: number, clipStartTime?: number, clipDuration?: number): TextEffectConfig & {
|
|
386
|
+
width: number;
|
|
387
|
+
height: number;
|
|
388
|
+
};
|
|
389
|
+
declare function layerToTextEffectConfig(layer: EvaluatedTextLayer): TextEffectConfig & {
|
|
390
|
+
width: number;
|
|
391
|
+
height: number;
|
|
392
|
+
};
|
|
255
393
|
|
|
256
394
|
declare class WebGLCompositor {
|
|
257
395
|
private gl;
|
|
@@ -270,6 +408,11 @@ interface EvaluateOptions {
|
|
|
270
408
|
compositor?: WebGLCompositor | null;
|
|
271
409
|
skipPostFx?: boolean;
|
|
272
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Dispose the shared module-level compositor and release GPU resources.
|
|
413
|
+
* Call on hot-module-reload or application teardown to prevent WebGL context leaks.
|
|
414
|
+
*/
|
|
415
|
+
declare function disposeSharedCompositor(): void;
|
|
273
416
|
/**
|
|
274
417
|
* Single source of truth for rendering a scene at time t.
|
|
275
418
|
*/
|
|
@@ -958,14 +1101,35 @@ declare function createCanvas(width: number, height: number): HTMLCanvasElement
|
|
|
958
1101
|
* Release a DOM canvas created via createCanvas() when OffscreenCanvas
|
|
959
1102
|
* was unavailable. No-op for OffscreenCanvas instances.
|
|
960
1103
|
*
|
|
961
|
-
*
|
|
962
|
-
*
|
|
1104
|
+
* Sets width/height to 0 to release the backing store immediately rather
|
|
1105
|
+
* than waiting for GC. Call this after extracting ImageBitmap/ImageData.
|
|
963
1106
|
*/
|
|
964
1107
|
declare function releaseCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
965
1108
|
/**
|
|
966
1109
|
* Reset all cached capability flags (for testing only).
|
|
967
1110
|
*/
|
|
968
1111
|
declare function _resetPlatformCache(): void;
|
|
1112
|
+
/**
|
|
1113
|
+
* Unified resource allocator and manager for OffscreenCanvas and DOM Canvas pools.
|
|
1114
|
+
* Prevents GC thrashing and backing store leaks across WKWebView and standard browsers.
|
|
1115
|
+
*/
|
|
1116
|
+
declare class CanvasDevice {
|
|
1117
|
+
private static canvases;
|
|
1118
|
+
private static maxPoolSize;
|
|
1119
|
+
/**
|
|
1120
|
+
* Acquire a Canvas context from the pool or create a new one.
|
|
1121
|
+
* If a canvas is pulled from the pool, it is resized to the target dimensions.
|
|
1122
|
+
*/
|
|
1123
|
+
static acquire(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
|
|
1124
|
+
/**
|
|
1125
|
+
* Release a canvas back to the pool, or free its resources immediately if pool is full.
|
|
1126
|
+
*/
|
|
1127
|
+
static release(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
1128
|
+
/**
|
|
1129
|
+
* Disposes all pooled canvases to release GPU/memory backing stores.
|
|
1130
|
+
*/
|
|
1131
|
+
static clearPool(): void;
|
|
1132
|
+
}
|
|
969
1133
|
|
|
970
1134
|
/**
|
|
971
1135
|
* Canvas 2D utility helpers
|
|
@@ -1019,4 +1183,4 @@ declare class InkBrushEngine {
|
|
|
1019
1183
|
drawFrame(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1020
1184
|
}
|
|
1021
1185
|
|
|
1022
|
-
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_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_DURATION, DEFAULT_FONT_SIZE, DEFAULT_FPS, 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, InkBrushEngine, 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, _resetPlatformCache, addImageLayer, addKeyframeAtTime, addOrUpdateKeyframe, addShapeLayer, addSolidLayer, addTextLayer, addTrack, addVectorShape, advanceSceneTime, alignToLottieJ, applyFillColorToAll, applyLetterSpacing, 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, createCanvas, createDefaultRevealTrack, createEmptyScene, createPulseOpacityTrack, defaultConfig, deleteKeyframe, downloadDotLottie, downloadLottieJson, downloadPngSequenceZip, downloadSceneWebM, drawPerCharText, drawRoundedRect, 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, releaseCanvas, removeKeyframe, removeTrack, renderPngSequence, renderSceneWebM, renderTextEffectCore, resetSceneTime, resizeCharFillColors, resolveAnimatedScalar, resolveCustomEngineId, restoreLetterSpacing, scanLottieFonts, scanTextLayers, sceneToConfig, setCharFillColor, setSceneTime, setTracks, shouldUsePerCharFill, snapshotScene, sortKeyframes, supportsCtxFilter, supportsLetterSpacing, supportsOffscreenCanvas, supportsRoundRect, supportsWebGL2, syncCompositorFromScene, textEffectConfigToScene, trackId, updateKeyframe, updateStaticProperty, updateTimeline, updateTrack, updateTrackMatte, upsertKeyframe, waitForFontsReady, wrapTextToWidth };
|
|
1186
|
+
export { type AnimBuildOpts, type AnimKeyframe, type AnimTrack, type AnimTrackDef, type AnimatableParamDef, type AnimationCategory, type BatchInjection, COMPOSITION_PRESETS, CUSTOM_ENGINE_IDS, CanvasDevice, type CompositionPreset, type CompositorFromScene, type CompositorSettings, type CustomEngineId, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_DURATION, DEFAULT_FONT_SIZE, DEFAULT_FPS, DEFAULT_TEXT_STYLE, type DotLottieManifest, type DrawPerCharTextOptions, EMPHASIS_PRESETS, ENGINE_ID_TO_LEGACY, ENTRANCE_PRESETS, EXIT_PRESETS, type EasingControlPoint, type EffectFullDefinition, type EffectIndexItem, type EffectLayer, type EffectLayerType, type EvaluateOptions, type EvaluatedTextLayer, FONT_WEIGHT_OPTIONS, type FillType, type FontDescriptor, type FontLoadResult, FontLoader, type FontVariant, type GifExportOptions, type GifFrame, type GlowLayer, type GradientDir, type GradientStop, InkBrushEngine, 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, type TextEffectDefinition, TextEffectRenderer, type TextLayerConfig, type TextLayerStyle, type TextLayoutBounds, type TextLayoutResult, type TextStyleOverride, type Timeline, WEBM_EXPORT_MAX_FRAMES, WebGLCompositor, type WebMExportOptions, _buildConfig, _resetPlatformCache, addImageLayer, addKeyframeAtTime, addOrUpdateKeyframe, addShapeLayer, addSolidLayer, addTextLayer, addTrack, addVectorShape, advanceSceneTime, alignToLottieJ, applyFillColorToAll, applyLetterSpacing, 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, createCanvas, createDefaultRevealTrack, createEmptyScene, createPulseOpacityTrack, defaultConfig, deleteKeyframe, disposeSharedCompositor, downloadDotLottie, downloadLottieJson, downloadPngSequenceZip, downloadSceneWebM, drawPerCharText, drawRoundedRect, duplicateTrackAtPlayhead, ease, enableKeyframing, encodeGif, ensureDefaultTimeline, ensureFontInLottie, ensureFontsLoaded, evaluateConfig, evaluateScene, findTrackIndex, getAnimPreset, getAnimatableParamDef, getAnimatableParamsForLayer, getDefaultText, getFontLoader, getLayerById, getPresetScene, getSceneTime, getSupportedWebMMimeType, getTemplatePreset, getTemplatesByCategory, getWebMFrameCount, hexToLottieColor, hexToLottieRgb, initializeFontSystem, injectBatch, injectColor, injectFontVariantRules, injectGlobalTextStyle, injectSolidColor, injectText, injectTextStyle, isWebMExportSupported, layerToTextEffectConfig, loadLottieFonts, lottieColorToHex, lottieJToAlign, measureTextFits, mergeSceneIntoConfig, moveKeyframe, newLayerId, parseHistorySnapshot, parseLottieJson, preloadGoogleFont, presetToRecipe, pruneTracksForLayer, rainbowCharFillColors, readLayerScalar, readStyleFromLottieLayer, reindexLayers, releaseCanvas, removeKeyframe, removeTrack, renderPngSequence, renderSceneWebM, renderTextEffectCore, resetFontLoader, resetSceneTime, resizeCharFillColors, resolveAnimatedScalar, resolveCustomEngineId, resolveFontFamilyName, restoreLetterSpacing, scanLottieFonts, scanTextLayers, sceneToConfig, setCharFillColor, setSceneTime, setTracks, shouldUsePerCharFill, snapshotScene, sortKeyframes, supportsCtxFilter, supportsLetterSpacing, supportsOffscreenCanvas, supportsRoundRect, supportsWebGL2, syncCompositorFromScene, textEffectConfigToScene, trackId, updateKeyframe, updateStaticProperty, updateTimeline, updateTrack, updateTrackMatte, upsertKeyframe, waitForFontsReady, wrapTextToWidth };
|