@clypra-studio/engine 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{chunk-E6O6LZME.js → chunk-7ORA5BPW.js} +14 -299
  2. package/dist/chunk-7ORA5BPW.js.map +1 -0
  3. package/dist/chunk-NG4F55V7.js +300 -0
  4. package/dist/chunk-NG4F55V7.js.map +1 -0
  5. package/dist/{chunk-3UEOLDJJ.js → chunk-SH7HOGVX.js} +1 -1
  6. package/dist/chunk-SH7HOGVX.js.map +1 -0
  7. package/dist/chunk-V5D5SJPO.js +1946 -0
  8. package/dist/chunk-V5D5SJPO.js.map +1 -0
  9. package/dist/index-DKJxLj6P.d.cts +122 -0
  10. package/dist/index-DbojK0dC.d.ts +491 -0
  11. package/dist/index-QSvA1MMy.d.ts +122 -0
  12. package/dist/index-l2Qgw6Dt.d.cts +491 -0
  13. package/dist/index.cjs +3669 -484
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +248 -150
  16. package/dist/index.d.ts +248 -150
  17. package/dist/index.js +2226 -930
  18. package/dist/index.js.map +1 -1
  19. package/dist/rendering/index.cjs +3743 -0
  20. package/dist/rendering/index.cjs.map +1 -0
  21. package/dist/rendering/index.d.cts +2 -0
  22. package/dist/rendering/index.d.ts +2 -0
  23. package/dist/rendering/index.js +23 -0
  24. package/dist/rendering/index.js.map +1 -0
  25. package/dist/textEffects/index.cjs +13 -5
  26. package/dist/textEffects/index.cjs.map +1 -1
  27. package/dist/textEffects/index.d.cts +2 -1
  28. package/dist/textEffects/index.d.ts +2 -1
  29. package/dist/textEffects/index.js +6 -4
  30. package/dist/{index-C18SQ-y6.d.cts → types-CoshNXmU.d.cts} +142 -129
  31. package/dist/{index-C18SQ-y6.d.ts → types-CoshNXmU.d.ts} +142 -129
  32. package/dist/videoEffects/index.cjs.map +1 -1
  33. package/dist/videoEffects/index.js +1 -1
  34. package/package.json +6 -1
  35. package/dist/chunk-3UEOLDJJ.js.map +0 -1
  36. package/dist/chunk-E6O6LZME.js.map +0 -1
@@ -445,13 +445,26 @@ interface EvaluatedTextLayer {
445
445
  };
446
446
  readonly styleId?: string;
447
447
  }
448
- type TemplateCategory = "lower-third" | "title-card" | "caption" | "callout" | "social" | "countdown";
449
- type AnimationPreset = "fade" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "scale-in" | "scale-out" | "blur-in" | "blur-out" | "typewriter" | "none";
450
- type TemplateEasingFunction = "linear" | "ease-in-out" | "ease-in" | "ease-out" | "ease";
448
+ type TemplateCategory = "lower-third" | "title-card" | "caption" | "callout" | "social" | "countdown" | "kinetic-type" | "cta" | "credits" | "quotes" | "sports" | "gaming" | "news" | "minimal";
449
+ type AnimationPreset = "fade" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "scale-in" | "scale-out" | "blur-in" | "blur-out" | "typewriter" | "3d-flip" | "scale-pop" | "track-in" | "wave" | "glitch" | "none";
450
+ type TemplateEasingFunction = "linear" | "ease-in-out" | "ease-in" | "ease-out" | "ease" | "cubic-bezier" | "spring" | "bounce";
451
+ interface BezierControlPoints {
452
+ x1: number;
453
+ y1: number;
454
+ x2: number;
455
+ y2: number;
456
+ }
457
+ interface SpringParams {
458
+ damping?: number;
459
+ stiffness?: number;
460
+ mass?: number;
461
+ }
451
462
  interface TemplateKeyframe<T> {
452
463
  time: number;
453
464
  value: T;
454
465
  easing?: TemplateEasingFunction;
466
+ bezier?: BezierControlPoints;
467
+ spring?: SpringParams;
455
468
  }
456
469
  type AnimatableValue<T> = T | {
457
470
  keyframes: TemplateKeyframe<T>[];
@@ -463,6 +476,79 @@ interface LayerAnimation {
463
476
  outDuration: number;
464
477
  hold: "full" | number;
465
478
  }
479
+ interface TextStyleSpan {
480
+ start: number;
481
+ end: number;
482
+ fontFamily?: string;
483
+ fontSize?: number;
484
+ fontWeight?: number;
485
+ fontStyle?: "normal" | "italic";
486
+ color?: string;
487
+ gradient?: {
488
+ angle: number;
489
+ stops: Array<{
490
+ color: string;
491
+ offset: number;
492
+ }>;
493
+ };
494
+ letterSpacing?: number;
495
+ baselineShift?: number;
496
+ opacity?: number;
497
+ }
498
+ type SplitMode = "character" | "word" | "line";
499
+ type StaggerDirection = "start-to-end" | "end-to-start" | "center-out" | "edges-in" | "random";
500
+ interface TextSplitTransform {
501
+ x?: number;
502
+ y?: number;
503
+ z?: number;
504
+ scale?: number;
505
+ scaleX?: number;
506
+ scaleY?: number;
507
+ rotation?: number;
508
+ rotateX?: number;
509
+ rotateY?: number;
510
+ opacity?: number;
511
+ blur?: number;
512
+ letterSpacingOffset?: number;
513
+ }
514
+ interface TextSplitAnimator {
515
+ splitBy: SplitMode;
516
+ direction: StaggerDirection;
517
+ delayPerUnit: number;
518
+ overlap: number;
519
+ randomSeed?: number;
520
+ initialTransform: TextSplitTransform;
521
+ easing?: TemplateEasingFunction;
522
+ bezier?: BezierControlPoints;
523
+ durationPerUnit?: number;
524
+ }
525
+ type SpatialAnchorPoint = "top-left" | "top-center" | "top-right" | "middle-left" | "center" | "middle-right" | "bottom-left" | "bottom-center" | "bottom-right";
526
+ interface ResponsiveAnchorConfig {
527
+ anchorPoint: SpatialAnchorPoint;
528
+ offsetPercentageX?: number;
529
+ offsetPercentageY?: number;
530
+ pixelOffsetX?: number;
531
+ pixelOffsetY?: number;
532
+ maxWidthPercentage?: number;
533
+ }
534
+ type TemplateVariableType = "string" | "number" | "color" | "boolean" | "timecode" | "counter" | "image" | "dataset-row";
535
+ interface TemplateVariableDefinition {
536
+ key: string;
537
+ label: string;
538
+ type: TemplateVariableType;
539
+ defaultValue: any;
540
+ description?: string;
541
+ category?: "content" | "style" | "timing";
542
+ constraints?: {
543
+ min?: number;
544
+ max?: number;
545
+ options?: Array<{
546
+ label: string;
547
+ value: any;
548
+ }>;
549
+ format?: string;
550
+ };
551
+ }
466
552
  interface TemplateTextLayer {
467
553
  kind: "text";
468
554
  id: string;
@@ -470,7 +556,10 @@ interface TemplateTextLayer {
470
556
  fontFamily: string;
471
557
  fontSize: AnimatableValue<number>;
472
558
  fontWeight: AnimatableValue<number>;
559
+ fontStyle?: "normal" | "italic";
473
560
  color: AnimatableValue<string>;
561
+ letterSpacing?: AnimatableValue<number>;
562
+ lineHeight?: AnimatableValue<number>;
474
563
  align: "left" | "center" | "right";
475
564
  x: AnimatableValue<number>;
476
565
  y: AnimatableValue<number>;
@@ -503,8 +592,20 @@ interface TemplateTextLayer {
503
592
  };
504
593
  overflow?: "wrap" | "shrink" | "expand-panel" | "clip";
505
594
  verticalAlign?: "top" | "middle" | "bottom";
595
+ /** Explicit layer visibility. Defaults to true. */
596
+ visible?: boolean;
506
597
  /** Studio-only UI state; ignored by render/export. */
507
598
  _paddingLinked?: boolean;
599
+ /** Per-character and span-level formatting */
600
+ spans?: TextStyleSpan[];
601
+ perCharFillEnabled?: boolean;
602
+ charFillColors?: string[];
603
+ /** Kinetic text splitting animator */
604
+ splitAnimator?: TextSplitAnimator;
605
+ /** Responsive layout anchor across aspect ratios */
606
+ anchor?: ResponsiveAnchorConfig;
607
+ /** Group / Parent identifier for inherited transforms */
608
+ parentId?: string;
508
609
  }
509
610
  interface TemplateShapeLayer {
510
611
  kind: "shape";
@@ -520,7 +621,11 @@ interface TemplateShapeLayer {
520
621
  width: AnimatableValue<number>;
521
622
  height: AnimatableValue<number>;
522
623
  opacity?: AnimatableValue<number>;
624
+ /** Explicit layer visibility. Defaults to true. */
625
+ visible?: boolean;
523
626
  animation: LayerAnimation;
627
+ anchor?: ResponsiveAnchorConfig;
628
+ parentId?: string;
524
629
  }
525
630
  interface TemplateImageLayer {
526
631
  kind: "image";
@@ -531,20 +636,45 @@ interface TemplateImageLayer {
531
636
  width: AnimatableValue<number>;
532
637
  height: AnimatableValue<number>;
533
638
  opacity?: AnimatableValue<number>;
639
+ /** Explicit layer visibility. Defaults to true. */
640
+ visible?: boolean;
534
641
  animation: LayerAnimation;
642
+ anchor?: ResponsiveAnchorConfig;
643
+ parentId?: string;
644
+ }
645
+ interface TemplateFlexLayout {
646
+ type: "flex" | "absolute";
647
+ direction: "row" | "column";
648
+ gap: AnimatableValue<number>;
649
+ alignItems: "start" | "center" | "end" | "stretch";
650
+ justifyContent: "start" | "center" | "end" | "space-between" | "space-around";
651
+ paddingTop?: AnimatableValue<number>;
652
+ paddingRight?: AnimatableValue<number>;
653
+ paddingBottom?: AnimatableValue<number>;
654
+ paddingLeft?: AnimatableValue<number>;
535
655
  }
536
- interface TemplateImageLayer {
537
- kind: "image";
656
+ interface TemplateContainerLayer {
657
+ kind: "container";
538
658
  id: string;
539
- url: string;
659
+ name?: string;
660
+ layout: TemplateFlexLayout;
540
661
  x: AnimatableValue<number>;
541
662
  y: AnimatableValue<number>;
542
- width: AnimatableValue<number>;
543
- height: AnimatableValue<number>;
663
+ width: AnimatableValue<number | "auto">;
664
+ height: AnimatableValue<number | "auto">;
665
+ backgroundColor?: AnimatableValue<string>;
666
+ backgroundOpacity?: AnimatableValue<number>;
667
+ backgroundRadius?: AnimatableValue<number>;
668
+ backgroundBorderColor?: AnimatableValue<string>;
669
+ backgroundBorderWidth?: AnimatableValue<number>;
544
670
  opacity?: AnimatableValue<number>;
671
+ /** Explicit layer visibility. Defaults to true. */
672
+ visible?: boolean;
545
673
  animation: LayerAnimation;
674
+ anchor?: ResponsiveAnchorConfig;
675
+ parentId?: string;
546
676
  }
547
- type TemplateLayer = TemplateTextLayer | TemplateShapeLayer | TemplateImageLayer;
677
+ type TemplateLayer = TemplateTextLayer | TemplateShapeLayer | TemplateImageLayer | TemplateContainerLayer;
548
678
  interface TextTemplate {
549
679
  id: string;
550
680
  schemaVersion?: number;
@@ -554,9 +684,11 @@ interface TextTemplate {
554
684
  fps?: number;
555
685
  canvasWidth: number;
556
686
  canvasHeight: number;
687
+ aspectRatio?: "16:9" | "9:16" | "1:1" | "4:5";
557
688
  thumbnail?: string;
558
689
  preview?: string;
559
690
  layers: TemplateLayer[];
691
+ variables?: Record<string, TemplateVariableDefinition>;
560
692
  dependencies?: Array<{
561
693
  effectId: string;
562
694
  revisionId: string;
@@ -664,123 +796,4 @@ interface ColorAdjustments {
664
796
  [key: string]: number | boolean | string | Record<string, unknown> | undefined;
665
797
  }
666
798
 
667
- declare function renderTextEffectCore(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig): void;
668
- declare class TextEffectRenderer {
669
- static draw(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, cfg: TextEffectConfig, _time?: number): void;
670
- }
671
-
672
- /** Style recipes (layer graphs): see `builtInRecipes` in src/engine/recipes.ts */
673
- declare const defaultConfig: TextEffectConfig;
674
- /**
675
- * Return a fresh, explicit blank authoring state.
676
- *
677
- * A blank state is intentionally different from a loosely spread object:
678
- * every optional visual contributor is disabled while its parameters remain
679
- * present for the controls and the canonical scene migration. This prevents
680
- * object presence (panel/glow/shadow/etc.) from being interpreted as active.
681
- */
682
- declare function createBlankTextEffectConfig(): TextEffectConfig;
683
- declare const builtInPresets: Preset[];
684
-
685
- /**
686
- * Font Loader for Lottie-web
687
- *
688
- * This module ensures that font variant names (like "Poppins-Italic") work correctly
689
- * with lottie-web by dynamically creating @font-face rules that map variant names
690
- * to the actual loaded fonts with proper styling.
691
- */
692
- interface FontVariant {
693
- variantName: string;
694
- baseFontFamily: string;
695
- weight: number;
696
- style: "normal" | "italic";
697
- }
698
- /**
699
- * Injects @font-face rules dynamically to create font variant aliases
700
- * This ensures lottie-web can find fonts by their variant names
701
- */
702
- declare function injectFontVariantRules(): void;
703
- /**
704
- * Waits for base fonts to load, then injects variant rules
705
- */
706
- declare function initializeFontSystem(): Promise<void>;
707
- /**
708
- * Checks if a font variant is available for rendering.
709
- * Uses document.fonts.check() which is the correct API for font availability —
710
- * unlike measureText() which silently falls back to the system font and always
711
- * returns a non-zero width regardless of whether the named font loaded.
712
- */
713
- declare function checkFontVariant(variantName: string): boolean;
714
- /**
715
- * Font descriptor for loading.
716
- */
717
- interface FontDescriptor {
718
- family: string;
719
- weight?: string | number;
720
- style?: "normal" | "italic";
721
- }
722
- /**
723
- * Font loading result.
724
- */
725
- interface FontLoadResult {
726
- font: FontDescriptor;
727
- loaded: boolean;
728
- error?: string;
729
- loadTimeMs: number;
730
- }
731
- declare class FontLoader {
732
- private state;
733
- ensureFont(descriptor: FontDescriptor): Promise<FontLoadResult>;
734
- ensureFonts(descriptors: FontDescriptor[]): Promise<FontLoadResult[]>;
735
- waitForFontsReady(): Promise<void>;
736
- isLoaded(descriptor: FontDescriptor): boolean;
737
- getStats(): {
738
- loaded: number;
739
- loading: number;
740
- failed: number;
741
- };
742
- clear(): void;
743
- private loadFont;
744
- private getFontKey;
745
- private normalizeFontWeight;
746
- }
747
- declare function getFontLoader(): FontLoader;
748
- declare function resetFontLoader(): void;
749
- declare function ensureFontsLoaded(descriptors: FontDescriptor[]): Promise<FontLoadResult[]>;
750
-
751
- /** Lossless migration from flat TextEffectConfig to SceneDocument */
752
- declare function textEffectConfigToScene(cfg: TextEffectConfig): SceneDocument;
753
- /** Flatten SceneDocument back to TextEffectConfig for legacy controls and renderer */
754
- declare function sceneToConfig(doc: SceneDocument): TextEffectConfig;
755
- declare function syncCompositorFromScene(doc: SceneDocument): CompositorFromScene;
756
- interface CompositorFromScene {
757
- blur: number;
758
- bloom: number;
759
- bloomThreshold: number;
760
- }
761
- /** Apply engine params from scene onto config without require() */
762
- declare function mergeSceneIntoConfig(doc: SceneDocument, base: TextEffectConfig): TextEffectConfig;
763
- declare function resolveFontFamilyName(fontFamily: string): string;
764
- declare function _buildConfig(effect: TextEffectDefinition, text: string, fontSize: number, canvasWidth: number, canvasHeight: number, time?: number, clipStartTime?: number, clipDuration?: number): TextEffectConfig & {
765
- width: number;
766
- height: number;
767
- };
768
- declare function layerToTextEffectConfig(layer: EvaluatedTextLayer): TextEffectConfig & {
769
- width: number;
770
- height: number;
771
- };
772
-
773
- interface EvaluateOptions {
774
- skipPostFx?: boolean;
775
- }
776
- /**
777
- * Single source of truth for rendering a scene at time t.
778
- */
779
- declare function evaluateScene(doc: SceneDocument, time: number, ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, options?: EvaluateOptions): void;
780
- declare function evaluateConfig(cfg: TextEffectConfig, time: number, ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, options?: EvaluateOptions): void;
781
- declare function advanceSceneTime(doc: SceneDocument, steps: number): number;
782
- declare function getSceneTime(doc: SceneDocument): number;
783
- declare function setSceneTime(doc: SceneDocument, time: number): void;
784
- declare function resetSceneTime(doc: SceneDocument): void;
785
-
786
- export { type Timeline as $, type AnimTrack as A, type EffectStroke as B, type CanvasBackgroundConfig as C, DEFAULT_CANVAS_HEIGHT as D, type EffectLayer as E, type EvaluateOptions as F, type GlowLayer as G, type EvaluatedTextLayer as H, type FontDescriptor as I, type FontLoadResult as J, type Keyframe as K, FontLoader as L, type FontVariant as M, type GradingParams as N, type LayerAnimation as O, type Preset as P, type LayerTarget as Q, SCENE_SCHEMA_VERSION as R, type SceneDocument as S, type TextEffectConfig as T, SCENE_VERSION as U, type SceneCanvas as V, type SceneText as W, type TemplateImageLayer as X, type TemplateShapeLayer as Y, type TemplateTextLayer as Z, TextEffectRenderer as _, type StyleRecipe as a, _buildConfig as a0, advanceSceneTime as a1, builtInPresets as a2, checkFontVariant as a3, createBlankTextEffectConfig as a4, createEmptyScene as a5, defaultConfig as a6, ensureFontsLoaded as a7, evaluateConfig as a8, evaluateScene as a9, getFontLoader as aa, getSceneTime as ab, initializeFontSystem as ac, injectFontVariantRules as ad, layerToTextEffectConfig as ae, mergeSceneIntoConfig as af, newLayerId as ag, renderTextEffectCore as ah, resetFontLoader as ai, resetSceneTime as aj, resolveFontFamilyName as ak, sceneToConfig as al, setSceneTime as am, syncCompositorFromScene as an, textEffectConfigToScene as ao, type TextEffectDefinition as b, type GradientStop as c, type TextTemplate as d, type TemplateLayer as e, type TemplateCategory as f, type AnimatableValue as g, type TemplateEasingFunction as h, type TemplateKeyframe as i, type AnimationPreset as j, type ColorAdjustments as k, type CompositorFromScene as l, type CompositorSettings as m, DEFAULT_CANVAS_WIDTH as n, DEFAULT_DURATION as o, DEFAULT_FONT_SIZE as p, DEFAULT_FPS as q, type EffectBevel as r, type EffectFill as s, type EffectFullDefinition as t, type EffectGlow as u, type EffectIndexItem as v, type EffectLayerType as w, type EffectPanel as x, type EffectShadow as y, type EffectStack as z };
799
+ export { type TemplateFlexLayout as $, type AnimTrack as A, type BezierControlPoints as B, type CanvasBackgroundConfig as C, DEFAULT_CANVAS_HEIGHT as D, type EffectLayer as E, type EffectLayerType as F, type GlowLayer as G, type EffectPanel as H, type EffectShadow as I, type EffectStack as J, type Keyframe as K, type LayerAnimation as L, type EffectStroke as M, type EvaluatedTextLayer as N, type GradingParams as O, type Preset as P, type LayerTarget as Q, type ResponsiveAnchorConfig as R, type SceneDocument as S, type TextTemplate as T, SCENE_SCHEMA_VERSION as U, SCENE_VERSION as V, type SceneCanvas as W, type SceneText as X, type SpatialAnchorPoint as Y, type StaggerDirection as Z, type TemplateContainerLayer as _, type TemplateLayer as a, type TemplateImageLayer as a0, type TemplateShapeLayer as a1, type TemplateTextLayer as a2, type TemplateVariableType as a3, type TextSplitTransform as a4, type Timeline as a5, createEmptyScene as a6, newLayerId as a7, type TemplateKeyframe as b, type TextStyleSpan as c, type TextSplitAnimator as d, type TemplateVariableDefinition as e, type TextEffectConfig as f, type StyleRecipe as g, type TextEffectDefinition as h, type GradientStop as i, type AnimatableValue as j, type TemplateEasingFunction as k, type SpringParams as l, type TemplateCategory as m, type SplitMode as n, type AnimationPreset as o, type ColorAdjustments as p, type CompositorSettings as q, DEFAULT_CANVAS_WIDTH as r, DEFAULT_DURATION as s, DEFAULT_FONT_SIZE as t, DEFAULT_FPS as u, type EffectBevel as v, type EffectFill as w, type EffectFullDefinition as x, type EffectGlow as y, type EffectIndexItem as z };