@clypra-studio/engine 1.4.0 → 1.5.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-Q7XYDP4X.js +1898 -0
  6. package/dist/chunk-Q7XYDP4X.js.map +1 -0
  7. package/dist/{chunk-3UEOLDJJ.js → chunk-SH7HOGVX.js} +1 -1
  8. package/dist/chunk-SH7HOGVX.js.map +1 -0
  9. package/dist/index-B1lFl4p2.d.ts +122 -0
  10. package/dist/index-Cpps1DKP.d.ts +489 -0
  11. package/dist/index-DrzRbR7G.d.cts +122 -0
  12. package/dist/index-WsvrOpAy.d.cts +489 -0
  13. package/dist/index.cjs +3131 -482
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +185 -103
  16. package/dist/index.d.ts +185 -103
  17. package/dist/index.js +1599 -792
  18. package/dist/index.js.map +1 -1
  19. package/dist/rendering/index.cjs +3694 -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 +21 -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-IYwXGYkB.d.cts} +141 -129
  31. package/dist/{index-C18SQ-y6.d.ts → types-IYwXGYkB.d.ts} +141 -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";
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;
@@ -471,6 +557,8 @@ interface TemplateTextLayer {
471
557
  fontSize: AnimatableValue<number>;
472
558
  fontWeight: AnimatableValue<number>;
473
559
  color: AnimatableValue<string>;
560
+ letterSpacing?: AnimatableValue<number>;
561
+ lineHeight?: AnimatableValue<number>;
474
562
  align: "left" | "center" | "right";
475
563
  x: AnimatableValue<number>;
476
564
  y: AnimatableValue<number>;
@@ -503,8 +591,20 @@ interface TemplateTextLayer {
503
591
  };
504
592
  overflow?: "wrap" | "shrink" | "expand-panel" | "clip";
505
593
  verticalAlign?: "top" | "middle" | "bottom";
594
+ /** Explicit layer visibility. Defaults to true. */
595
+ visible?: boolean;
506
596
  /** Studio-only UI state; ignored by render/export. */
507
597
  _paddingLinked?: boolean;
598
+ /** Per-character and span-level formatting */
599
+ spans?: TextStyleSpan[];
600
+ perCharFillEnabled?: boolean;
601
+ charFillColors?: string[];
602
+ /** Kinetic text splitting animator */
603
+ splitAnimator?: TextSplitAnimator;
604
+ /** Responsive layout anchor across aspect ratios */
605
+ anchor?: ResponsiveAnchorConfig;
606
+ /** Group / Parent identifier for inherited transforms */
607
+ parentId?: string;
508
608
  }
509
609
  interface TemplateShapeLayer {
510
610
  kind: "shape";
@@ -520,7 +620,11 @@ interface TemplateShapeLayer {
520
620
  width: AnimatableValue<number>;
521
621
  height: AnimatableValue<number>;
522
622
  opacity?: AnimatableValue<number>;
623
+ /** Explicit layer visibility. Defaults to true. */
624
+ visible?: boolean;
523
625
  animation: LayerAnimation;
626
+ anchor?: ResponsiveAnchorConfig;
627
+ parentId?: string;
524
628
  }
525
629
  interface TemplateImageLayer {
526
630
  kind: "image";
@@ -531,20 +635,45 @@ interface TemplateImageLayer {
531
635
  width: AnimatableValue<number>;
532
636
  height: AnimatableValue<number>;
533
637
  opacity?: AnimatableValue<number>;
638
+ /** Explicit layer visibility. Defaults to true. */
639
+ visible?: boolean;
534
640
  animation: LayerAnimation;
641
+ anchor?: ResponsiveAnchorConfig;
642
+ parentId?: string;
643
+ }
644
+ interface TemplateFlexLayout {
645
+ type: "flex" | "absolute";
646
+ direction: "row" | "column";
647
+ gap: AnimatableValue<number>;
648
+ alignItems: "start" | "center" | "end" | "stretch";
649
+ justifyContent: "start" | "center" | "end" | "space-between" | "space-around";
650
+ paddingTop?: AnimatableValue<number>;
651
+ paddingRight?: AnimatableValue<number>;
652
+ paddingBottom?: AnimatableValue<number>;
653
+ paddingLeft?: AnimatableValue<number>;
535
654
  }
536
- interface TemplateImageLayer {
537
- kind: "image";
655
+ interface TemplateContainerLayer {
656
+ kind: "container";
538
657
  id: string;
539
- url: string;
658
+ name?: string;
659
+ layout: TemplateFlexLayout;
540
660
  x: AnimatableValue<number>;
541
661
  y: AnimatableValue<number>;
542
- width: AnimatableValue<number>;
543
- height: AnimatableValue<number>;
662
+ width: AnimatableValue<number | "auto">;
663
+ height: AnimatableValue<number | "auto">;
664
+ backgroundColor?: AnimatableValue<string>;
665
+ backgroundOpacity?: AnimatableValue<number>;
666
+ backgroundRadius?: AnimatableValue<number>;
667
+ backgroundBorderColor?: AnimatableValue<string>;
668
+ backgroundBorderWidth?: AnimatableValue<number>;
544
669
  opacity?: AnimatableValue<number>;
670
+ /** Explicit layer visibility. Defaults to true. */
671
+ visible?: boolean;
545
672
  animation: LayerAnimation;
673
+ anchor?: ResponsiveAnchorConfig;
674
+ parentId?: string;
546
675
  }
547
- type TemplateLayer = TemplateTextLayer | TemplateShapeLayer | TemplateImageLayer;
676
+ type TemplateLayer = TemplateTextLayer | TemplateShapeLayer | TemplateImageLayer | TemplateContainerLayer;
548
677
  interface TextTemplate {
549
678
  id: string;
550
679
  schemaVersion?: number;
@@ -554,9 +683,11 @@ interface TextTemplate {
554
683
  fps?: number;
555
684
  canvasWidth: number;
556
685
  canvasHeight: number;
686
+ aspectRatio?: "16:9" | "9:16" | "1:1" | "4:5";
557
687
  thumbnail?: string;
558
688
  preview?: string;
559
689
  layers: TemplateLayer[];
690
+ variables?: Record<string, TemplateVariableDefinition>;
560
691
  dependencies?: Array<{
561
692
  effectId: string;
562
693
  revisionId: string;
@@ -664,123 +795,4 @@ interface ColorAdjustments {
664
795
  [key: string]: number | boolean | string | Record<string, unknown> | undefined;
665
796
  }
666
797
 
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 };
798
+ 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 };