@clypra-studio/engine 1.10.0 → 1.10.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.
@@ -522,6 +522,252 @@ declare function getTextTemplateControls(input: unknown): TextTemplateArtifact["
522
522
  declare function resolveTemplateFontFamily(family?: string): string;
523
523
  declare function renderTextTemplateToCanvas(ctx: CanvasLike, input: TextTemplateRenderInput): CanonicalRenderResult;
524
524
 
525
+ /** Versioned, editable source of truth for authored text-bubble assets. */
526
+ type BubbleTailSide = "bottom" | "top" | "left" | "right";
527
+ interface ParametricBubbleDefinition {
528
+ schemaVersion: 1;
529
+ type: "clypra.textBubble";
530
+ coordinateSpace: "normalized";
531
+ geometry: {
532
+ kind: "parametric-path";
533
+ body: {
534
+ cornerRadius: number;
535
+ };
536
+ tail: {
537
+ enabled: boolean;
538
+ side: BubbleTailSide;
539
+ anchor: number;
540
+ width: number;
541
+ depth: number;
542
+ curvature: number;
543
+ };
544
+ };
545
+ layers: {
546
+ fill: {
547
+ color: string;
548
+ opacity: number;
549
+ };
550
+ outline: {
551
+ color: string;
552
+ width: number;
553
+ roughness: number;
554
+ seed: number;
555
+ };
556
+ accent?: {
557
+ color: string;
558
+ opacity: number;
559
+ texture: "none" | "hatch" | "chalk";
560
+ };
561
+ };
562
+ textLayout: {
563
+ padding: [number, number, number, number];
564
+ alignment: "left" | "center" | "right";
565
+ overflow: "grow" | "shrink-with-minimum" | "error";
566
+ };
567
+ }
568
+ type BubblePathCommand = {
569
+ kind: "move" | "line";
570
+ to: [number, number];
571
+ } | {
572
+ kind: "quadratic";
573
+ control: [number, number];
574
+ to: [number, number];
575
+ } | {
576
+ kind: "cubic";
577
+ control1: [number, number];
578
+ control2: [number, number];
579
+ to: [number, number];
580
+ } | {
581
+ kind: "close";
582
+ };
583
+ /** A portable authored silhouette; all coordinates stay normalized for export parity. */
584
+ interface FreeformBubbleDefinition {
585
+ schemaVersion: 1;
586
+ type: "clypra.textBubble";
587
+ coordinateSpace: "normalized";
588
+ geometry: {
589
+ kind: "freeform-path";
590
+ closed: true;
591
+ commands: BubblePathCommand[];
592
+ };
593
+ layers: ParametricBubbleDefinition["layers"];
594
+ textLayout: ParametricBubbleDefinition["textLayout"];
595
+ }
596
+ type BubbleAssetDefinition = ParametricBubbleDefinition | FreeformBubbleDefinition;
597
+ declare const createBubbleAssetDefinition: () => ParametricBubbleDefinition;
598
+ /** Creates an editable starting silhouette, not a flattened preview image. */
599
+ declare const createFreeformBubbleAssetDefinition: () => FreeformBubbleDefinition;
600
+ /** Compiles normalized parametric geometry to a stable SVG path. */
601
+ declare function compileBubblePath(definition: BubbleAssetDefinition): string;
602
+ /** Produces a portable SVG artifact from the canonical editable definition. */
603
+ declare function compileBubbleSvg(definition: BubbleAssetDefinition, width?: number, height?: number): string;
604
+ type BubbleCanvas = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
605
+ /** Renders the editable definition directly, avoiding a separate Studio-only drawing model. */
606
+ declare function renderBubbleAssetDefinition(ctx: BubbleCanvas, definition: BubbleAssetDefinition, x: number, y: number, width: number, height: number): void;
607
+ declare function validateBubbleAssetDefinition(definition: BubbleAssetDefinition): string[];
608
+
609
+ /**
610
+ * textBubbles.ts
611
+ *
612
+ * Canonical schema contract and layout resolver for Clypra's
613
+ * Text Bubble & Caption Preset System.
614
+ *
615
+ * Invariants:
616
+ * 1. Text Clip is the sole logical entity on the timeline.
617
+ * 2. Bubble is rendered behind the text as a composite drawable.
618
+ * 3. Text and Bubble share all transforms (x, y, scale, rotation, opacity, keyframes).
619
+ * 4. Content bounds define the safe text region inside the artwork so text never clips or overflows.
620
+ */
621
+ type TextBubbleCategory = "all" | "speech" | "paper" | "labels" | "decorative" | "comic" | "cute" | "neon" | "banner";
622
+ type BubbleRenderMode = "svg" | "raster" | "nine-slice" | "procedural";
623
+ /** Geometric families exposed by the Studio bubble designer. */
624
+ type BubbleShape = "rounded" | "speech" | "cloud" | "comic" | "paper" | "ribbon" | "chalk";
625
+ type BubbleTexture = "none" | "chalk" | "hatch" | "paper";
626
+ type BubbleTailPosition = "bottom-left" | "bottom-center" | "bottom-right";
627
+ /**
628
+ * Portable procedural art direction. This stays with a preset JSON file so
629
+ * a Studio-authored bubble can be rendered by any consumer of the engine.
630
+ */
631
+ interface BubbleAppearance {
632
+ shape: BubbleShape;
633
+ fillColor: string;
634
+ fillOpacity: number;
635
+ strokeColor: string;
636
+ strokeWidth: number;
637
+ cornerRadius: number;
638
+ tailPosition: BubbleTailPosition;
639
+ tailSize: number;
640
+ texture: BubbleTexture;
641
+ }
642
+ interface TextBubblePadding {
643
+ top: number;
644
+ right: number;
645
+ bottom: number;
646
+ left: number;
647
+ }
648
+ interface TextBubbleLayout {
649
+ /** Normalized safe content coordinates within the artwork [0..1] */
650
+ contentBounds: {
651
+ x: number;
652
+ y: number;
653
+ width: number;
654
+ height: number;
655
+ };
656
+ /** Minimum outer dimensions in logical editor units */
657
+ minWidth: number;
658
+ minHeight: number;
659
+ /** Whether the bubble artwork must preserve aspect ratio */
660
+ preserveAspectRatio: boolean;
661
+ /** Optional explicit padding around measured text */
662
+ padding?: TextBubblePadding;
663
+ /** Sizing mode: auto-fit grows with text; fixed wraps text into predefined box */
664
+ sizingMode?: "auto-fit" | "fixed";
665
+ }
666
+ interface TextBubblePreset {
667
+ schemaVersion: 1;
668
+ id: string;
669
+ version: number;
670
+ name: string;
671
+ category: TextBubbleCategory;
672
+ tags: string[];
673
+ isReset?: boolean;
674
+ asset?: {
675
+ url?: string;
676
+ format: "svg" | "png" | "webp" | "procedural";
677
+ width: number;
678
+ height: number;
679
+ sha256?: string;
680
+ renderMode: BubbleRenderMode;
681
+ };
682
+ /** Optional portable design controls for procedural custom bubbles. */
683
+ appearance?: BubbleAppearance;
684
+ /** Editable vector asset source; compiled previews are derived from this. */
685
+ definition?: BubbleAssetDefinition;
686
+ layout: TextBubbleLayout;
687
+ defaultTextStyle?: {
688
+ fontFamily?: string;
689
+ fontSize?: number;
690
+ fontWeight?: string | number;
691
+ fontStyle?: "normal" | "italic";
692
+ textDecoration?: "none" | "underline" | "line-through";
693
+ color?: string;
694
+ };
695
+ thumbnailUrl?: string;
696
+ sampleText?: string;
697
+ renderPreview?: (active: boolean) => unknown;
698
+ }
699
+ /**
700
+ * Resolves the outer bubble bounds and text position given measured text bounds
701
+ * and preset layout rules:
702
+ *
703
+ * W_outer = max(W_text + P_left + P_right, minWidth)
704
+ * H_outer = max(H_text + P_top + P_bottom, minHeight)
705
+ */
706
+ declare function resolveBubbleLayout(textWidth: number, textHeight: number, layout: TextBubbleLayout): {
707
+ outerWidth: number;
708
+ outerHeight: number;
709
+ textOffsetX: number;
710
+ textOffsetY: number;
711
+ contentWidth: number;
712
+ contentHeight: number;
713
+ };
714
+
715
+ /**
716
+ * bubbleRenderer.ts
717
+ *
718
+ * Dedicated Canvas2D Bubble Renderer for Clypra's Text Appearance System.
719
+ *
720
+ * Renders decorative background shapes (torn paper, speech bubbles,
721
+ * thought clouds, ribbons, comic bursts, receipts) behind live editable text.
722
+ *
723
+ * Invariants:
724
+ * - Deterministic output based on preset ID and dimensions.
725
+ * - Always restores canvas state (save/restore).
726
+ * - Operates in unscaled layout coordinates matching text composition.
727
+ */
728
+ interface BubbleRenderOptions {
729
+ color?: string;
730
+ opacity?: number;
731
+ borderRadius?: number;
732
+ }
733
+ /**
734
+ * Procedural pseudo-random helper for deterministic edge irregularities
735
+ */
736
+ declare function pseudoNoise(seed: number): number;
737
+ /**
738
+ * Draws a realistic torn paper strip with jagged top/bottom edges,
739
+ * paper texture, and drop shadow. (Matches CapCut reference)
740
+ */
741
+ declare function drawTornPaper(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, shadow?: boolean): void;
742
+ /**
743
+ * Draws a smooth speech bubble balloon with a curved tail.
744
+ */
745
+ declare function drawSpeechBubble(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number, radius?: number): void;
746
+ /** Renders a complete serialized preset, including Studio-authored appearance. */
747
+ declare function renderBubblePresetBackground(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, preset: Pick<TextBubblePreset, "id" | "appearance">, x: number, y: number, width: number, height: number): boolean;
748
+ /**
749
+ * Draws a hand-drawn chalk dialogue bubble: a translucent rose balloon with a
750
+ * rough white contour and a lime/yellow cross-hatched tail. The artwork is
751
+ * deterministic so it can be rendered identically in Studio and the editor.
752
+ */
753
+ declare function drawChalkSpeechBubble(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;
754
+ /**
755
+ * Draws a fluffy thought cloud bubble.
756
+ */
757
+ declare function drawThoughtCloud(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
758
+ /**
759
+ * Draws an energetic comic starburst explosion.
760
+ */
761
+ declare function drawComicBurst(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
762
+ /**
763
+ * Draws a folded ribbon / banner with chevron notch ends.
764
+ */
765
+ declare function drawRibbonBanner(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
766
+ /**
767
+ * Main dispatcher: renders a bubble decoration based on its presetId.
768
+ */
769
+ declare function renderBubbleBackground(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, presetId: string, x: number, y: number, width: number, height: number, options?: BubbleRenderOptions): boolean;
770
+
525
771
  type CanonicalRenderInput = {
526
772
  capability: "text-template";
527
773
  artifact: unknown;
@@ -534,4 +780,4 @@ type CanonicalRenderInput = {
534
780
  /** Extensible capability registry for all package-owned render semantics. */
535
781
  declare function renderCanonicalToCanvas(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, input: CanonicalRenderInput): CanonicalRenderResult;
536
782
 
537
- export { type TemplateTimelineMarker as $, type TemplateControlConstraints as A, type TemplateControlOption as B, type CompiledTextTemplate as C, type TemplateControlType as D, type EvaluatedTemplateScene as E, type TemplateDependencyManifest as F, type TemplateDurationPolicy as G, type TemplateFontRef as H, type TemplateImageNode as I, type TemplateLayerV2 as J, type TemplateMetadata as K, type TemplateNode as L, type TemplateNodeAnimation as M, type TemplatePreviewArtifacts as N, type TemplatePropertyKeyframes as O, type PublishedRevision as P, type TemplateProtectedRegion as Q, type RenderPlan as R, type SceneDocumentV2 as S, type TextTemplateArtifact as T, type TemplateRenderTarget as U, type TemplateRevision as V, type TemplateShapeNode as W, type TemplateShapeNodeStyle as X, type TemplateStyleRef as Y, type TemplateTextNode as Z, type TemplateTextNodeStyle as _, type ResolveTemplateControlValuesOptions as a, type TemplateTiming as a0, type TextEffectRenderInput as a1, type TextTemplateCanvas as a2, type TextTemplateClip as a3, type TextTemplateDocument as a4, type TextTemplateDocumentV2 as a5, type TextTemplateFlexLayout as a6, type TextTemplateRenderInput as a7, canonicalContentHash as a8, canonicalizeSceneDocument as a9, evaluateTextEffect as aa, evaluateTextTemplate as ab, getRenderCapabilities as ac, getTextTemplateControls as ad, normalizeTextEffect as ae, normalizeTextTemplate as af, renderCanonicalToCanvas as ag, renderTextEffectToCanvas as ah, renderTextTemplateToCanvas as ai, resolveTemplateFontFamily as aj, resolveTextTemplateArtifact as ak, type TemplateCustomization as b, type TemplateRenderContext as c, CANONICAL_RENDERER_VERSION as d, CANONICAL_SCHEMA_VERSION as e, type CanonicalRenderContext as f, type CanonicalRenderInput as g, type CanonicalRenderResult as h, type CapabilityReport as i, type CapabilityStatus as j, type CompiledTemplateRenderLayer as k, type RenderCapability as l, type RenderDiagnostic as m, type RenderDiagnostics as n, type RenderEnvironment as o, type RenderIdentity as p, type RenderTarget as q, TEXT_TEMPLATE_KIND as r, TEXT_TEMPLATE_RENDERER_VERSION as s, TEXT_TEMPLATE_SCHEMA_VERSION as t, type TemplateAssetRef as u, type TemplateBackgroundPanel as v, type TemplateCapabilityReport as w, type TemplateContainerNode as x, type TemplateContainerNodeStyle as y, type TemplateControl as z };
783
+ export { type TemplateNodeAnimation as $, TEXT_TEMPLATE_KIND as A, type BubbleAppearance as B, type CompiledTextTemplate as C, TEXT_TEMPLATE_RENDERER_VERSION as D, type EvaluatedTemplateScene as E, type FreeformBubbleDefinition as F, TEXT_TEMPLATE_SCHEMA_VERSION as G, type TemplateAssetRef as H, type TemplateBackgroundPanel as I, type TemplateCapabilityReport as J, type TemplateContainerNode as K, type TemplateContainerNodeStyle as L, type TemplateControl as M, type TemplateControlConstraints as N, type TemplateControlOption as O, type ParametricBubbleDefinition as P, type TemplateControlType as Q, type RenderPlan as R, type SceneDocumentV2 as S, type TextTemplateArtifact as T, type TemplateDependencyManifest as U, type TemplateDurationPolicy as V, type TemplateFontRef as W, type TemplateImageNode as X, type TemplateLayerV2 as Y, type TemplateMetadata as Z, type TemplateNode as _, type ResolveTemplateControlValuesOptions as a, type TemplatePreviewArtifacts as a0, type TemplatePropertyKeyframes as a1, type TemplateProtectedRegion as a2, type TemplateRenderTarget as a3, type TemplateRevision as a4, type TemplateShapeNode as a5, type TemplateShapeNodeStyle as a6, type TemplateStyleRef as a7, type TemplateTextNode as a8, type TemplateTextNodeStyle as a9, evaluateTextTemplate as aA, getRenderCapabilities as aB, getTextTemplateControls as aC, normalizeTextEffect as aD, normalizeTextTemplate as aE, pseudoNoise as aF, renderBubbleAssetDefinition as aG, renderBubbleBackground as aH, renderBubblePresetBackground as aI, renderCanonicalToCanvas as aJ, renderTextEffectToCanvas as aK, renderTextTemplateToCanvas as aL, resolveBubbleLayout as aM, resolveTemplateFontFamily as aN, resolveTextTemplateArtifact as aO, validateBubbleAssetDefinition as aP, type TemplateTimelineMarker as aa, type TemplateTiming as ab, type TextBubbleCategory as ac, type TextBubbleLayout as ad, type TextBubblePadding as ae, type TextBubblePreset as af, type TextEffectRenderInput as ag, type TextTemplateCanvas as ah, type TextTemplateClip as ai, type TextTemplateDocument as aj, type TextTemplateDocumentV2 as ak, type TextTemplateFlexLayout as al, type TextTemplateRenderInput as am, canonicalContentHash as an, canonicalizeSceneDocument as ao, compileBubblePath as ap, compileBubbleSvg as aq, createBubbleAssetDefinition as ar, createFreeformBubbleAssetDefinition as as, drawChalkSpeechBubble as at, drawComicBurst as au, drawRibbonBanner as av, drawSpeechBubble as aw, drawThoughtCloud as ax, drawTornPaper as ay, evaluateTextEffect as az, type TemplateCustomization as b, type TemplateRenderContext as c, type BubbleAssetDefinition as d, type BubblePathCommand as e, type BubbleRenderMode as f, type BubbleRenderOptions as g, type BubbleShape as h, type BubbleTailPosition as i, type BubbleTailSide as j, type BubbleTexture as k, CANONICAL_RENDERER_VERSION as l, CANONICAL_SCHEMA_VERSION as m, type CanonicalRenderContext as n, type CanonicalRenderInput as o, type CanonicalRenderResult as p, type CapabilityReport as q, type CapabilityStatus as r, type CompiledTemplateRenderLayer as s, type PublishedRevision as t, type RenderCapability as u, type RenderDiagnostic as v, type RenderDiagnostics as w, type RenderEnvironment as x, type RenderIdentity as y, type RenderTarget as z };
@@ -522,6 +522,252 @@ declare function getTextTemplateControls(input: unknown): TextTemplateArtifact["
522
522
  declare function resolveTemplateFontFamily(family?: string): string;
523
523
  declare function renderTextTemplateToCanvas(ctx: CanvasLike, input: TextTemplateRenderInput): CanonicalRenderResult;
524
524
 
525
+ /** Versioned, editable source of truth for authored text-bubble assets. */
526
+ type BubbleTailSide = "bottom" | "top" | "left" | "right";
527
+ interface ParametricBubbleDefinition {
528
+ schemaVersion: 1;
529
+ type: "clypra.textBubble";
530
+ coordinateSpace: "normalized";
531
+ geometry: {
532
+ kind: "parametric-path";
533
+ body: {
534
+ cornerRadius: number;
535
+ };
536
+ tail: {
537
+ enabled: boolean;
538
+ side: BubbleTailSide;
539
+ anchor: number;
540
+ width: number;
541
+ depth: number;
542
+ curvature: number;
543
+ };
544
+ };
545
+ layers: {
546
+ fill: {
547
+ color: string;
548
+ opacity: number;
549
+ };
550
+ outline: {
551
+ color: string;
552
+ width: number;
553
+ roughness: number;
554
+ seed: number;
555
+ };
556
+ accent?: {
557
+ color: string;
558
+ opacity: number;
559
+ texture: "none" | "hatch" | "chalk";
560
+ };
561
+ };
562
+ textLayout: {
563
+ padding: [number, number, number, number];
564
+ alignment: "left" | "center" | "right";
565
+ overflow: "grow" | "shrink-with-minimum" | "error";
566
+ };
567
+ }
568
+ type BubblePathCommand = {
569
+ kind: "move" | "line";
570
+ to: [number, number];
571
+ } | {
572
+ kind: "quadratic";
573
+ control: [number, number];
574
+ to: [number, number];
575
+ } | {
576
+ kind: "cubic";
577
+ control1: [number, number];
578
+ control2: [number, number];
579
+ to: [number, number];
580
+ } | {
581
+ kind: "close";
582
+ };
583
+ /** A portable authored silhouette; all coordinates stay normalized for export parity. */
584
+ interface FreeformBubbleDefinition {
585
+ schemaVersion: 1;
586
+ type: "clypra.textBubble";
587
+ coordinateSpace: "normalized";
588
+ geometry: {
589
+ kind: "freeform-path";
590
+ closed: true;
591
+ commands: BubblePathCommand[];
592
+ };
593
+ layers: ParametricBubbleDefinition["layers"];
594
+ textLayout: ParametricBubbleDefinition["textLayout"];
595
+ }
596
+ type BubbleAssetDefinition = ParametricBubbleDefinition | FreeformBubbleDefinition;
597
+ declare const createBubbleAssetDefinition: () => ParametricBubbleDefinition;
598
+ /** Creates an editable starting silhouette, not a flattened preview image. */
599
+ declare const createFreeformBubbleAssetDefinition: () => FreeformBubbleDefinition;
600
+ /** Compiles normalized parametric geometry to a stable SVG path. */
601
+ declare function compileBubblePath(definition: BubbleAssetDefinition): string;
602
+ /** Produces a portable SVG artifact from the canonical editable definition. */
603
+ declare function compileBubbleSvg(definition: BubbleAssetDefinition, width?: number, height?: number): string;
604
+ type BubbleCanvas = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
605
+ /** Renders the editable definition directly, avoiding a separate Studio-only drawing model. */
606
+ declare function renderBubbleAssetDefinition(ctx: BubbleCanvas, definition: BubbleAssetDefinition, x: number, y: number, width: number, height: number): void;
607
+ declare function validateBubbleAssetDefinition(definition: BubbleAssetDefinition): string[];
608
+
609
+ /**
610
+ * textBubbles.ts
611
+ *
612
+ * Canonical schema contract and layout resolver for Clypra's
613
+ * Text Bubble & Caption Preset System.
614
+ *
615
+ * Invariants:
616
+ * 1. Text Clip is the sole logical entity on the timeline.
617
+ * 2. Bubble is rendered behind the text as a composite drawable.
618
+ * 3. Text and Bubble share all transforms (x, y, scale, rotation, opacity, keyframes).
619
+ * 4. Content bounds define the safe text region inside the artwork so text never clips or overflows.
620
+ */
621
+ type TextBubbleCategory = "all" | "speech" | "paper" | "labels" | "decorative" | "comic" | "cute" | "neon" | "banner";
622
+ type BubbleRenderMode = "svg" | "raster" | "nine-slice" | "procedural";
623
+ /** Geometric families exposed by the Studio bubble designer. */
624
+ type BubbleShape = "rounded" | "speech" | "cloud" | "comic" | "paper" | "ribbon" | "chalk";
625
+ type BubbleTexture = "none" | "chalk" | "hatch" | "paper";
626
+ type BubbleTailPosition = "bottom-left" | "bottom-center" | "bottom-right";
627
+ /**
628
+ * Portable procedural art direction. This stays with a preset JSON file so
629
+ * a Studio-authored bubble can be rendered by any consumer of the engine.
630
+ */
631
+ interface BubbleAppearance {
632
+ shape: BubbleShape;
633
+ fillColor: string;
634
+ fillOpacity: number;
635
+ strokeColor: string;
636
+ strokeWidth: number;
637
+ cornerRadius: number;
638
+ tailPosition: BubbleTailPosition;
639
+ tailSize: number;
640
+ texture: BubbleTexture;
641
+ }
642
+ interface TextBubblePadding {
643
+ top: number;
644
+ right: number;
645
+ bottom: number;
646
+ left: number;
647
+ }
648
+ interface TextBubbleLayout {
649
+ /** Normalized safe content coordinates within the artwork [0..1] */
650
+ contentBounds: {
651
+ x: number;
652
+ y: number;
653
+ width: number;
654
+ height: number;
655
+ };
656
+ /** Minimum outer dimensions in logical editor units */
657
+ minWidth: number;
658
+ minHeight: number;
659
+ /** Whether the bubble artwork must preserve aspect ratio */
660
+ preserveAspectRatio: boolean;
661
+ /** Optional explicit padding around measured text */
662
+ padding?: TextBubblePadding;
663
+ /** Sizing mode: auto-fit grows with text; fixed wraps text into predefined box */
664
+ sizingMode?: "auto-fit" | "fixed";
665
+ }
666
+ interface TextBubblePreset {
667
+ schemaVersion: 1;
668
+ id: string;
669
+ version: number;
670
+ name: string;
671
+ category: TextBubbleCategory;
672
+ tags: string[];
673
+ isReset?: boolean;
674
+ asset?: {
675
+ url?: string;
676
+ format: "svg" | "png" | "webp" | "procedural";
677
+ width: number;
678
+ height: number;
679
+ sha256?: string;
680
+ renderMode: BubbleRenderMode;
681
+ };
682
+ /** Optional portable design controls for procedural custom bubbles. */
683
+ appearance?: BubbleAppearance;
684
+ /** Editable vector asset source; compiled previews are derived from this. */
685
+ definition?: BubbleAssetDefinition;
686
+ layout: TextBubbleLayout;
687
+ defaultTextStyle?: {
688
+ fontFamily?: string;
689
+ fontSize?: number;
690
+ fontWeight?: string | number;
691
+ fontStyle?: "normal" | "italic";
692
+ textDecoration?: "none" | "underline" | "line-through";
693
+ color?: string;
694
+ };
695
+ thumbnailUrl?: string;
696
+ sampleText?: string;
697
+ renderPreview?: (active: boolean) => unknown;
698
+ }
699
+ /**
700
+ * Resolves the outer bubble bounds and text position given measured text bounds
701
+ * and preset layout rules:
702
+ *
703
+ * W_outer = max(W_text + P_left + P_right, minWidth)
704
+ * H_outer = max(H_text + P_top + P_bottom, minHeight)
705
+ */
706
+ declare function resolveBubbleLayout(textWidth: number, textHeight: number, layout: TextBubbleLayout): {
707
+ outerWidth: number;
708
+ outerHeight: number;
709
+ textOffsetX: number;
710
+ textOffsetY: number;
711
+ contentWidth: number;
712
+ contentHeight: number;
713
+ };
714
+
715
+ /**
716
+ * bubbleRenderer.ts
717
+ *
718
+ * Dedicated Canvas2D Bubble Renderer for Clypra's Text Appearance System.
719
+ *
720
+ * Renders decorative background shapes (torn paper, speech bubbles,
721
+ * thought clouds, ribbons, comic bursts, receipts) behind live editable text.
722
+ *
723
+ * Invariants:
724
+ * - Deterministic output based on preset ID and dimensions.
725
+ * - Always restores canvas state (save/restore).
726
+ * - Operates in unscaled layout coordinates matching text composition.
727
+ */
728
+ interface BubbleRenderOptions {
729
+ color?: string;
730
+ opacity?: number;
731
+ borderRadius?: number;
732
+ }
733
+ /**
734
+ * Procedural pseudo-random helper for deterministic edge irregularities
735
+ */
736
+ declare function pseudoNoise(seed: number): number;
737
+ /**
738
+ * Draws a realistic torn paper strip with jagged top/bottom edges,
739
+ * paper texture, and drop shadow. (Matches CapCut reference)
740
+ */
741
+ declare function drawTornPaper(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, shadow?: boolean): void;
742
+ /**
743
+ * Draws a smooth speech bubble balloon with a curved tail.
744
+ */
745
+ declare function drawSpeechBubble(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number, radius?: number): void;
746
+ /** Renders a complete serialized preset, including Studio-authored appearance. */
747
+ declare function renderBubblePresetBackground(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, preset: Pick<TextBubblePreset, "id" | "appearance">, x: number, y: number, width: number, height: number): boolean;
748
+ /**
749
+ * Draws a hand-drawn chalk dialogue bubble: a translucent rose balloon with a
750
+ * rough white contour and a lime/yellow cross-hatched tail. The artwork is
751
+ * deterministic so it can be rendered identically in Studio and the editor.
752
+ */
753
+ declare function drawChalkSpeechBubble(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;
754
+ /**
755
+ * Draws a fluffy thought cloud bubble.
756
+ */
757
+ declare function drawThoughtCloud(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
758
+ /**
759
+ * Draws an energetic comic starburst explosion.
760
+ */
761
+ declare function drawComicBurst(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
762
+ /**
763
+ * Draws a folded ribbon / banner with chevron notch ends.
764
+ */
765
+ declare function drawRibbonBanner(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
766
+ /**
767
+ * Main dispatcher: renders a bubble decoration based on its presetId.
768
+ */
769
+ declare function renderBubbleBackground(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, presetId: string, x: number, y: number, width: number, height: number, options?: BubbleRenderOptions): boolean;
770
+
525
771
  type CanonicalRenderInput = {
526
772
  capability: "text-template";
527
773
  artifact: unknown;
@@ -534,4 +780,4 @@ type CanonicalRenderInput = {
534
780
  /** Extensible capability registry for all package-owned render semantics. */
535
781
  declare function renderCanonicalToCanvas(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, input: CanonicalRenderInput): CanonicalRenderResult;
536
782
 
537
- export { type TemplateTimelineMarker as $, type TemplateControlConstraints as A, type TemplateControlOption as B, type CompiledTextTemplate as C, type TemplateControlType as D, type EvaluatedTemplateScene as E, type TemplateDependencyManifest as F, type TemplateDurationPolicy as G, type TemplateFontRef as H, type TemplateImageNode as I, type TemplateLayerV2 as J, type TemplateMetadata as K, type TemplateNode as L, type TemplateNodeAnimation as M, type TemplatePreviewArtifacts as N, type TemplatePropertyKeyframes as O, type PublishedRevision as P, type TemplateProtectedRegion as Q, type RenderPlan as R, type SceneDocumentV2 as S, type TextTemplateArtifact as T, type TemplateRenderTarget as U, type TemplateRevision as V, type TemplateShapeNode as W, type TemplateShapeNodeStyle as X, type TemplateStyleRef as Y, type TemplateTextNode as Z, type TemplateTextNodeStyle as _, type ResolveTemplateControlValuesOptions as a, type TemplateTiming as a0, type TextEffectRenderInput as a1, type TextTemplateCanvas as a2, type TextTemplateClip as a3, type TextTemplateDocument as a4, type TextTemplateDocumentV2 as a5, type TextTemplateFlexLayout as a6, type TextTemplateRenderInput as a7, canonicalContentHash as a8, canonicalizeSceneDocument as a9, evaluateTextEffect as aa, evaluateTextTemplate as ab, getRenderCapabilities as ac, getTextTemplateControls as ad, normalizeTextEffect as ae, normalizeTextTemplate as af, renderCanonicalToCanvas as ag, renderTextEffectToCanvas as ah, renderTextTemplateToCanvas as ai, resolveTemplateFontFamily as aj, resolveTextTemplateArtifact as ak, type TemplateCustomization as b, type TemplateRenderContext as c, CANONICAL_RENDERER_VERSION as d, CANONICAL_SCHEMA_VERSION as e, type CanonicalRenderContext as f, type CanonicalRenderInput as g, type CanonicalRenderResult as h, type CapabilityReport as i, type CapabilityStatus as j, type CompiledTemplateRenderLayer as k, type RenderCapability as l, type RenderDiagnostic as m, type RenderDiagnostics as n, type RenderEnvironment as o, type RenderIdentity as p, type RenderTarget as q, TEXT_TEMPLATE_KIND as r, TEXT_TEMPLATE_RENDERER_VERSION as s, TEXT_TEMPLATE_SCHEMA_VERSION as t, type TemplateAssetRef as u, type TemplateBackgroundPanel as v, type TemplateCapabilityReport as w, type TemplateContainerNode as x, type TemplateContainerNodeStyle as y, type TemplateControl as z };
783
+ export { type TemplateNodeAnimation as $, TEXT_TEMPLATE_KIND as A, type BubbleAppearance as B, type CompiledTextTemplate as C, TEXT_TEMPLATE_RENDERER_VERSION as D, type EvaluatedTemplateScene as E, type FreeformBubbleDefinition as F, TEXT_TEMPLATE_SCHEMA_VERSION as G, type TemplateAssetRef as H, type TemplateBackgroundPanel as I, type TemplateCapabilityReport as J, type TemplateContainerNode as K, type TemplateContainerNodeStyle as L, type TemplateControl as M, type TemplateControlConstraints as N, type TemplateControlOption as O, type ParametricBubbleDefinition as P, type TemplateControlType as Q, type RenderPlan as R, type SceneDocumentV2 as S, type TextTemplateArtifact as T, type TemplateDependencyManifest as U, type TemplateDurationPolicy as V, type TemplateFontRef as W, type TemplateImageNode as X, type TemplateLayerV2 as Y, type TemplateMetadata as Z, type TemplateNode as _, type ResolveTemplateControlValuesOptions as a, type TemplatePreviewArtifacts as a0, type TemplatePropertyKeyframes as a1, type TemplateProtectedRegion as a2, type TemplateRenderTarget as a3, type TemplateRevision as a4, type TemplateShapeNode as a5, type TemplateShapeNodeStyle as a6, type TemplateStyleRef as a7, type TemplateTextNode as a8, type TemplateTextNodeStyle as a9, evaluateTextTemplate as aA, getRenderCapabilities as aB, getTextTemplateControls as aC, normalizeTextEffect as aD, normalizeTextTemplate as aE, pseudoNoise as aF, renderBubbleAssetDefinition as aG, renderBubbleBackground as aH, renderBubblePresetBackground as aI, renderCanonicalToCanvas as aJ, renderTextEffectToCanvas as aK, renderTextTemplateToCanvas as aL, resolveBubbleLayout as aM, resolveTemplateFontFamily as aN, resolveTextTemplateArtifact as aO, validateBubbleAssetDefinition as aP, type TemplateTimelineMarker as aa, type TemplateTiming as ab, type TextBubbleCategory as ac, type TextBubbleLayout as ad, type TextBubblePadding as ae, type TextBubblePreset as af, type TextEffectRenderInput as ag, type TextTemplateCanvas as ah, type TextTemplateClip as ai, type TextTemplateDocument as aj, type TextTemplateDocumentV2 as ak, type TextTemplateFlexLayout as al, type TextTemplateRenderInput as am, canonicalContentHash as an, canonicalizeSceneDocument as ao, compileBubblePath as ap, compileBubbleSvg as aq, createBubbleAssetDefinition as ar, createFreeformBubbleAssetDefinition as as, drawChalkSpeechBubble as at, drawComicBurst as au, drawRibbonBanner as av, drawSpeechBubble as aw, drawThoughtCloud as ax, drawTornPaper as ay, evaluateTextEffect as az, type TemplateCustomization as b, type TemplateRenderContext as c, type BubbleAssetDefinition as d, type BubblePathCommand as e, type BubbleRenderMode as f, type BubbleRenderOptions as g, type BubbleShape as h, type BubbleTailPosition as i, type BubbleTailSide as j, type BubbleTexture as k, CANONICAL_RENDERER_VERSION as l, CANONICAL_SCHEMA_VERSION as m, type CanonicalRenderContext as n, type CanonicalRenderInput as o, type CanonicalRenderResult as p, type CapabilityReport as q, type CapabilityStatus as r, type CompiledTemplateRenderLayer as s, type PublishedRevision as t, type RenderCapability as u, type RenderDiagnostic as v, type RenderDiagnostics as w, type RenderEnvironment as x, type RenderIdentity as y, type RenderTarget as z };