@clypra/engine 1.0.2 → 1.1.1
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 +237 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -2
- package/dist/index.d.ts +129 -2
- package/dist/index.js +220 -115
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
declare const SCENE_VERSION: 1;
|
|
2
|
+
/** Default canvas width in pixels. */
|
|
3
|
+
declare const DEFAULT_CANVAS_WIDTH: 800;
|
|
4
|
+
/** Default canvas height in pixels. */
|
|
5
|
+
declare const DEFAULT_CANVAS_HEIGHT: 200;
|
|
6
|
+
/** Default font size in pixels. */
|
|
7
|
+
declare const DEFAULT_FONT_SIZE: 80;
|
|
8
|
+
/** Default frames per second for new timelines. */
|
|
9
|
+
declare const DEFAULT_FPS: 30;
|
|
10
|
+
/** Default timeline duration in seconds for new scenes. */
|
|
11
|
+
declare const DEFAULT_DURATION: 2;
|
|
2
12
|
type EffectLayerType = "panel" | "glow" | "shadow" | "extrusion" | "duplicateStack" | "stroke" | "fill" | "mask" | "filter" | "customEngine";
|
|
3
13
|
type LayerTarget = "text" | "panel" | "scene" | "previous";
|
|
4
14
|
type CustomEngineId = "ink";
|
|
@@ -225,7 +235,10 @@ declare function injectFontVariantRules(): void;
|
|
|
225
235
|
*/
|
|
226
236
|
declare function initializeFontSystem(): Promise<void>;
|
|
227
237
|
/**
|
|
228
|
-
* Checks if a font variant is available for rendering
|
|
238
|
+
* Checks if a font variant is available for rendering.
|
|
239
|
+
* Uses document.fonts.check() which is the correct API for font availability —
|
|
240
|
+
* unlike measureText() which silently falls back to the system font and always
|
|
241
|
+
* returns a non-zero width regardless of whether the named font loaded.
|
|
229
242
|
*/
|
|
230
243
|
declare function checkFontVariant(variantName: string): boolean;
|
|
231
244
|
|
|
@@ -260,6 +273,11 @@ interface EvaluateOptions {
|
|
|
260
273
|
compositor?: WebGLCompositor | null;
|
|
261
274
|
skipPostFx?: boolean;
|
|
262
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Dispose the shared module-level compositor and release GPU resources.
|
|
278
|
+
* Call on hot-module-reload or application teardown to prevent WebGL context leaks.
|
|
279
|
+
*/
|
|
280
|
+
declare function disposeSharedCompositor(): void;
|
|
263
281
|
/**
|
|
264
282
|
* Single source of truth for rendering a scene at time t.
|
|
265
283
|
*/
|
|
@@ -889,6 +907,115 @@ declare function updateKeyframe(doc: SceneDocument, trackIndex: number, keyframe
|
|
|
889
907
|
declare function removeKeyframe(doc: SceneDocument, trackIndex: number, keyframeIndex: number): SceneDocument;
|
|
890
908
|
declare function duplicateTrackAtPlayhead(doc: SceneDocument, trackIndex: number, previewTime: number): SceneDocument;
|
|
891
909
|
|
|
910
|
+
/**
|
|
911
|
+
* Platform Capability Detection
|
|
912
|
+
*
|
|
913
|
+
* Single source of truth for Canvas 2D / WebGL feature detection
|
|
914
|
+
* across WKWebView (macOS Tauri), WebView2 (Windows Tauri), and
|
|
915
|
+
* standard browser environments.
|
|
916
|
+
*
|
|
917
|
+
* All results are cached after the first call. Never call DOM APIs
|
|
918
|
+
* on every frame — detect once, branch always.
|
|
919
|
+
*
|
|
920
|
+
* Covers:
|
|
921
|
+
* - ctx.filter (absent on WKWebView < Safari 18 / macOS Sequoia)
|
|
922
|
+
* - ctx.roundRect (absent on older WebView2 and Safari < 15.4)
|
|
923
|
+
* - ctx.letterSpacing (absent on older WebView2 and Safari < 16.1)
|
|
924
|
+
* - OffscreenCanvas (absent on WKWebView < Safari 16.4)
|
|
925
|
+
* - WebGL2 (absent on very old WebView2 builds)
|
|
926
|
+
*/
|
|
927
|
+
/**
|
|
928
|
+
* Returns true when CanvasRenderingContext2D.filter is supported and
|
|
929
|
+
* actually applies (some WebViews accept the assignment silently but ignore it).
|
|
930
|
+
*
|
|
931
|
+
* Used to decide whether stroke-blur and glow effects should go through
|
|
932
|
+
* the WebGLCompositor fallback path.
|
|
933
|
+
*/
|
|
934
|
+
declare function supportsCtxFilter(): boolean;
|
|
935
|
+
/**
|
|
936
|
+
* Returns true when CanvasRenderingContext2D.roundRect() exists.
|
|
937
|
+
*
|
|
938
|
+
* Used to decide whether to fall back to the manual quadraticCurveTo
|
|
939
|
+
* rounded-rect implementation in panel rendering.
|
|
940
|
+
*/
|
|
941
|
+
declare function supportsRoundRect(): boolean;
|
|
942
|
+
/**
|
|
943
|
+
* Returns true when CanvasRenderingContext2D.letterSpacing is supported
|
|
944
|
+
* as an assignable CSS property.
|
|
945
|
+
*
|
|
946
|
+
* When false, letter-spacing must be emulated by drawing characters
|
|
947
|
+
* individually (or accepted as absent for fallback quality).
|
|
948
|
+
*/
|
|
949
|
+
declare function supportsLetterSpacing(): boolean;
|
|
950
|
+
/**
|
|
951
|
+
* Returns true when OffscreenCanvas is available in this environment.
|
|
952
|
+
*
|
|
953
|
+
* When false, fall back to document.createElement('canvas') for
|
|
954
|
+
* intermediate rendering and ensure cleanup of DOM nodes.
|
|
955
|
+
*/
|
|
956
|
+
declare function supportsOffscreenCanvas(): boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Returns true when WebGL2 is available.
|
|
959
|
+
*
|
|
960
|
+
* When false, WebGLCompositor.isSupported will also be false.
|
|
961
|
+
* Bloom/blur post-FX will be silently skipped.
|
|
962
|
+
*/
|
|
963
|
+
declare function supportsWebGL2(): boolean;
|
|
964
|
+
declare function createCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
|
|
965
|
+
/**
|
|
966
|
+
* Release a DOM canvas created via createCanvas() when OffscreenCanvas
|
|
967
|
+
* was unavailable. No-op for OffscreenCanvas instances.
|
|
968
|
+
*
|
|
969
|
+
* Sets width/height to 0 to release the backing store immediately rather
|
|
970
|
+
* than waiting for GC. Call this after extracting ImageBitmap/ImageData.
|
|
971
|
+
*/
|
|
972
|
+
declare function releaseCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
973
|
+
/**
|
|
974
|
+
* Reset all cached capability flags (for testing only).
|
|
975
|
+
*/
|
|
976
|
+
declare function _resetPlatformCache(): void;
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Canvas 2D utility helpers
|
|
980
|
+
*
|
|
981
|
+
* Cross-platform polyfills and small drawing helpers shared by the
|
|
982
|
+
* renderer, rasterizer, and any other Canvas 2D consumers.
|
|
983
|
+
*/
|
|
984
|
+
type Ctx2D = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
985
|
+
/**
|
|
986
|
+
* Draw a rounded rectangle path, compatible with all WebView targets.
|
|
987
|
+
*
|
|
988
|
+
* Uses the native ctx.roundRect() when available (Chrome 99+, Safari 15.4+,
|
|
989
|
+
* WebView2 1.0.1108+). Falls back to manual quadraticCurveTo() on older
|
|
990
|
+
* WKWebView / WebView2 builds.
|
|
991
|
+
*
|
|
992
|
+
* Callers must still call ctx.fill() / ctx.stroke() after this.
|
|
993
|
+
*
|
|
994
|
+
* @param ctx - 2D rendering context
|
|
995
|
+
* @param x - top-left x
|
|
996
|
+
* @param y - top-left y
|
|
997
|
+
* @param w - width
|
|
998
|
+
* @param h - height
|
|
999
|
+
* @param r - corner radius (uniform, clamped to half the shorter side)
|
|
1000
|
+
*/
|
|
1001
|
+
declare function drawRoundedRect(ctx: Ctx2D, x: number, y: number, w: number, h: number, r: number): void;
|
|
1002
|
+
/**
|
|
1003
|
+
* Apply letterSpacing to a canvas context when the CSS property is
|
|
1004
|
+
* supported. Returns the previous value so callers can restore it.
|
|
1005
|
+
*
|
|
1006
|
+
* When letterSpacing is NOT supported by the current WebView, returns
|
|
1007
|
+
* the current value unchanged and applies no mutation.
|
|
1008
|
+
*
|
|
1009
|
+
* @param ctx - 2D rendering context
|
|
1010
|
+
* @param value - spacing in pixels (pass 0 to reset)
|
|
1011
|
+
* @returns previous letterSpacing string ("0px" if unknown)
|
|
1012
|
+
*/
|
|
1013
|
+
declare function applyLetterSpacing(ctx: Ctx2D, value: number): string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Restore letterSpacing to a previously saved value.
|
|
1016
|
+
*/
|
|
1017
|
+
declare function restoreLetterSpacing(ctx: Ctx2D, saved: string): void;
|
|
1018
|
+
|
|
892
1019
|
declare class InkBrushEngine {
|
|
893
1020
|
private cfg;
|
|
894
1021
|
private bristleLines;
|
|
@@ -900,4 +1027,4 @@ declare class InkBrushEngine {
|
|
|
900
1027
|
drawFrame(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
901
1028
|
}
|
|
902
1029
|
|
|
903
|
-
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, 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, 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 };
|
|
1030
|
+
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, disposeSharedCompositor, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
declare const SCENE_VERSION: 1;
|
|
2
|
+
/** Default canvas width in pixels. */
|
|
3
|
+
declare const DEFAULT_CANVAS_WIDTH: 800;
|
|
4
|
+
/** Default canvas height in pixels. */
|
|
5
|
+
declare const DEFAULT_CANVAS_HEIGHT: 200;
|
|
6
|
+
/** Default font size in pixels. */
|
|
7
|
+
declare const DEFAULT_FONT_SIZE: 80;
|
|
8
|
+
/** Default frames per second for new timelines. */
|
|
9
|
+
declare const DEFAULT_FPS: 30;
|
|
10
|
+
/** Default timeline duration in seconds for new scenes. */
|
|
11
|
+
declare const DEFAULT_DURATION: 2;
|
|
2
12
|
type EffectLayerType = "panel" | "glow" | "shadow" | "extrusion" | "duplicateStack" | "stroke" | "fill" | "mask" | "filter" | "customEngine";
|
|
3
13
|
type LayerTarget = "text" | "panel" | "scene" | "previous";
|
|
4
14
|
type CustomEngineId = "ink";
|
|
@@ -225,7 +235,10 @@ declare function injectFontVariantRules(): void;
|
|
|
225
235
|
*/
|
|
226
236
|
declare function initializeFontSystem(): Promise<void>;
|
|
227
237
|
/**
|
|
228
|
-
* Checks if a font variant is available for rendering
|
|
238
|
+
* Checks if a font variant is available for rendering.
|
|
239
|
+
* Uses document.fonts.check() which is the correct API for font availability —
|
|
240
|
+
* unlike measureText() which silently falls back to the system font and always
|
|
241
|
+
* returns a non-zero width regardless of whether the named font loaded.
|
|
229
242
|
*/
|
|
230
243
|
declare function checkFontVariant(variantName: string): boolean;
|
|
231
244
|
|
|
@@ -260,6 +273,11 @@ interface EvaluateOptions {
|
|
|
260
273
|
compositor?: WebGLCompositor | null;
|
|
261
274
|
skipPostFx?: boolean;
|
|
262
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Dispose the shared module-level compositor and release GPU resources.
|
|
278
|
+
* Call on hot-module-reload or application teardown to prevent WebGL context leaks.
|
|
279
|
+
*/
|
|
280
|
+
declare function disposeSharedCompositor(): void;
|
|
263
281
|
/**
|
|
264
282
|
* Single source of truth for rendering a scene at time t.
|
|
265
283
|
*/
|
|
@@ -889,6 +907,115 @@ declare function updateKeyframe(doc: SceneDocument, trackIndex: number, keyframe
|
|
|
889
907
|
declare function removeKeyframe(doc: SceneDocument, trackIndex: number, keyframeIndex: number): SceneDocument;
|
|
890
908
|
declare function duplicateTrackAtPlayhead(doc: SceneDocument, trackIndex: number, previewTime: number): SceneDocument;
|
|
891
909
|
|
|
910
|
+
/**
|
|
911
|
+
* Platform Capability Detection
|
|
912
|
+
*
|
|
913
|
+
* Single source of truth for Canvas 2D / WebGL feature detection
|
|
914
|
+
* across WKWebView (macOS Tauri), WebView2 (Windows Tauri), and
|
|
915
|
+
* standard browser environments.
|
|
916
|
+
*
|
|
917
|
+
* All results are cached after the first call. Never call DOM APIs
|
|
918
|
+
* on every frame — detect once, branch always.
|
|
919
|
+
*
|
|
920
|
+
* Covers:
|
|
921
|
+
* - ctx.filter (absent on WKWebView < Safari 18 / macOS Sequoia)
|
|
922
|
+
* - ctx.roundRect (absent on older WebView2 and Safari < 15.4)
|
|
923
|
+
* - ctx.letterSpacing (absent on older WebView2 and Safari < 16.1)
|
|
924
|
+
* - OffscreenCanvas (absent on WKWebView < Safari 16.4)
|
|
925
|
+
* - WebGL2 (absent on very old WebView2 builds)
|
|
926
|
+
*/
|
|
927
|
+
/**
|
|
928
|
+
* Returns true when CanvasRenderingContext2D.filter is supported and
|
|
929
|
+
* actually applies (some WebViews accept the assignment silently but ignore it).
|
|
930
|
+
*
|
|
931
|
+
* Used to decide whether stroke-blur and glow effects should go through
|
|
932
|
+
* the WebGLCompositor fallback path.
|
|
933
|
+
*/
|
|
934
|
+
declare function supportsCtxFilter(): boolean;
|
|
935
|
+
/**
|
|
936
|
+
* Returns true when CanvasRenderingContext2D.roundRect() exists.
|
|
937
|
+
*
|
|
938
|
+
* Used to decide whether to fall back to the manual quadraticCurveTo
|
|
939
|
+
* rounded-rect implementation in panel rendering.
|
|
940
|
+
*/
|
|
941
|
+
declare function supportsRoundRect(): boolean;
|
|
942
|
+
/**
|
|
943
|
+
* Returns true when CanvasRenderingContext2D.letterSpacing is supported
|
|
944
|
+
* as an assignable CSS property.
|
|
945
|
+
*
|
|
946
|
+
* When false, letter-spacing must be emulated by drawing characters
|
|
947
|
+
* individually (or accepted as absent for fallback quality).
|
|
948
|
+
*/
|
|
949
|
+
declare function supportsLetterSpacing(): boolean;
|
|
950
|
+
/**
|
|
951
|
+
* Returns true when OffscreenCanvas is available in this environment.
|
|
952
|
+
*
|
|
953
|
+
* When false, fall back to document.createElement('canvas') for
|
|
954
|
+
* intermediate rendering and ensure cleanup of DOM nodes.
|
|
955
|
+
*/
|
|
956
|
+
declare function supportsOffscreenCanvas(): boolean;
|
|
957
|
+
/**
|
|
958
|
+
* Returns true when WebGL2 is available.
|
|
959
|
+
*
|
|
960
|
+
* When false, WebGLCompositor.isSupported will also be false.
|
|
961
|
+
* Bloom/blur post-FX will be silently skipped.
|
|
962
|
+
*/
|
|
963
|
+
declare function supportsWebGL2(): boolean;
|
|
964
|
+
declare function createCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
|
|
965
|
+
/**
|
|
966
|
+
* Release a DOM canvas created via createCanvas() when OffscreenCanvas
|
|
967
|
+
* was unavailable. No-op for OffscreenCanvas instances.
|
|
968
|
+
*
|
|
969
|
+
* Sets width/height to 0 to release the backing store immediately rather
|
|
970
|
+
* than waiting for GC. Call this after extracting ImageBitmap/ImageData.
|
|
971
|
+
*/
|
|
972
|
+
declare function releaseCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
973
|
+
/**
|
|
974
|
+
* Reset all cached capability flags (for testing only).
|
|
975
|
+
*/
|
|
976
|
+
declare function _resetPlatformCache(): void;
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Canvas 2D utility helpers
|
|
980
|
+
*
|
|
981
|
+
* Cross-platform polyfills and small drawing helpers shared by the
|
|
982
|
+
* renderer, rasterizer, and any other Canvas 2D consumers.
|
|
983
|
+
*/
|
|
984
|
+
type Ctx2D = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
985
|
+
/**
|
|
986
|
+
* Draw a rounded rectangle path, compatible with all WebView targets.
|
|
987
|
+
*
|
|
988
|
+
* Uses the native ctx.roundRect() when available (Chrome 99+, Safari 15.4+,
|
|
989
|
+
* WebView2 1.0.1108+). Falls back to manual quadraticCurveTo() on older
|
|
990
|
+
* WKWebView / WebView2 builds.
|
|
991
|
+
*
|
|
992
|
+
* Callers must still call ctx.fill() / ctx.stroke() after this.
|
|
993
|
+
*
|
|
994
|
+
* @param ctx - 2D rendering context
|
|
995
|
+
* @param x - top-left x
|
|
996
|
+
* @param y - top-left y
|
|
997
|
+
* @param w - width
|
|
998
|
+
* @param h - height
|
|
999
|
+
* @param r - corner radius (uniform, clamped to half the shorter side)
|
|
1000
|
+
*/
|
|
1001
|
+
declare function drawRoundedRect(ctx: Ctx2D, x: number, y: number, w: number, h: number, r: number): void;
|
|
1002
|
+
/**
|
|
1003
|
+
* Apply letterSpacing to a canvas context when the CSS property is
|
|
1004
|
+
* supported. Returns the previous value so callers can restore it.
|
|
1005
|
+
*
|
|
1006
|
+
* When letterSpacing is NOT supported by the current WebView, returns
|
|
1007
|
+
* the current value unchanged and applies no mutation.
|
|
1008
|
+
*
|
|
1009
|
+
* @param ctx - 2D rendering context
|
|
1010
|
+
* @param value - spacing in pixels (pass 0 to reset)
|
|
1011
|
+
* @returns previous letterSpacing string ("0px" if unknown)
|
|
1012
|
+
*/
|
|
1013
|
+
declare function applyLetterSpacing(ctx: Ctx2D, value: number): string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Restore letterSpacing to a previously saved value.
|
|
1016
|
+
*/
|
|
1017
|
+
declare function restoreLetterSpacing(ctx: Ctx2D, saved: string): void;
|
|
1018
|
+
|
|
892
1019
|
declare class InkBrushEngine {
|
|
893
1020
|
private cfg;
|
|
894
1021
|
private bristleLines;
|
|
@@ -900,4 +1027,4 @@ declare class InkBrushEngine {
|
|
|
900
1027
|
drawFrame(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
901
1028
|
}
|
|
902
1029
|
|
|
903
|
-
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, 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, 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 };
|
|
1030
|
+
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, disposeSharedCompositor, 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 };
|