@clypra-studio/engine 1.10.0 → 1.10.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/{chunk-JP44RJUI.js → chunk-KUJR5V3B.js} +247 -1
- package/dist/chunk-KUJR5V3B.js.map +1 -0
- package/dist/{index-XWLBYyFQ.d.ts → index--k_VrUnv.d.ts} +132 -1
- package/dist/{index-FDQDo2pR.d.cts → index-n6E8NGM_.d.cts} +132 -1
- package/dist/index.cjs +254 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/rendering/index.cjs +254 -0
- package/dist/rendering/index.cjs.map +1 -1
- package/dist/rendering/index.d.cts +1 -1
- package/dist/rendering/index.d.ts +1 -1
- package/dist/rendering/index.js +17 -1
- package/package.json +12 -12
- package/dist/chunk-JP44RJUI.js.map +0 -1
|
@@ -522,6 +522,137 @@ 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
|
+
/**
|
|
526
|
+
* textBubbles.ts
|
|
527
|
+
*
|
|
528
|
+
* Canonical schema contract and layout resolver for Clypra's
|
|
529
|
+
* Text Bubble & Caption Preset System.
|
|
530
|
+
*
|
|
531
|
+
* Invariants:
|
|
532
|
+
* 1. Text Clip is the sole logical entity on the timeline.
|
|
533
|
+
* 2. Bubble is rendered behind the text as a composite drawable.
|
|
534
|
+
* 3. Text and Bubble share all transforms (x, y, scale, rotation, opacity, keyframes).
|
|
535
|
+
* 4. Content bounds define the safe text region inside the artwork so text never clips or overflows.
|
|
536
|
+
*/
|
|
537
|
+
type TextBubbleCategory = "all" | "speech" | "paper" | "labels" | "decorative" | "comic" | "cute" | "neon" | "banner";
|
|
538
|
+
type BubbleRenderMode = "svg" | "raster" | "nine-slice" | "procedural";
|
|
539
|
+
interface TextBubblePadding {
|
|
540
|
+
top: number;
|
|
541
|
+
right: number;
|
|
542
|
+
bottom: number;
|
|
543
|
+
left: number;
|
|
544
|
+
}
|
|
545
|
+
interface TextBubbleLayout {
|
|
546
|
+
/** Normalized safe content coordinates within the artwork [0..1] */
|
|
547
|
+
contentBounds: {
|
|
548
|
+
x: number;
|
|
549
|
+
y: number;
|
|
550
|
+
width: number;
|
|
551
|
+
height: number;
|
|
552
|
+
};
|
|
553
|
+
/** Minimum outer dimensions in logical editor units */
|
|
554
|
+
minWidth: number;
|
|
555
|
+
minHeight: number;
|
|
556
|
+
/** Whether the bubble artwork must preserve aspect ratio */
|
|
557
|
+
preserveAspectRatio: boolean;
|
|
558
|
+
/** Optional explicit padding around measured text */
|
|
559
|
+
padding?: TextBubblePadding;
|
|
560
|
+
/** Sizing mode: auto-fit grows with text; fixed wraps text into predefined box */
|
|
561
|
+
sizingMode?: "auto-fit" | "fixed";
|
|
562
|
+
}
|
|
563
|
+
interface TextBubblePreset {
|
|
564
|
+
schemaVersion: 1;
|
|
565
|
+
id: string;
|
|
566
|
+
version: number;
|
|
567
|
+
name: string;
|
|
568
|
+
category: TextBubbleCategory;
|
|
569
|
+
tags: string[];
|
|
570
|
+
isReset?: boolean;
|
|
571
|
+
asset?: {
|
|
572
|
+
url?: string;
|
|
573
|
+
format: "svg" | "png" | "webp" | "procedural";
|
|
574
|
+
width: number;
|
|
575
|
+
height: number;
|
|
576
|
+
sha256?: string;
|
|
577
|
+
renderMode: BubbleRenderMode;
|
|
578
|
+
};
|
|
579
|
+
layout: TextBubbleLayout;
|
|
580
|
+
defaultTextStyle?: {
|
|
581
|
+
fontFamily?: string;
|
|
582
|
+
fontSize?: number;
|
|
583
|
+
fontWeight?: string | number;
|
|
584
|
+
fontStyle?: "normal" | "italic";
|
|
585
|
+
textDecoration?: "none" | "underline" | "line-through";
|
|
586
|
+
color?: string;
|
|
587
|
+
};
|
|
588
|
+
thumbnailUrl?: string;
|
|
589
|
+
sampleText?: string;
|
|
590
|
+
renderPreview?: (active: boolean) => unknown;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Resolves the outer bubble bounds and text position given measured text bounds
|
|
594
|
+
* and preset layout rules:
|
|
595
|
+
*
|
|
596
|
+
* W_outer = max(W_text + P_left + P_right, minWidth)
|
|
597
|
+
* H_outer = max(H_text + P_top + P_bottom, minHeight)
|
|
598
|
+
*/
|
|
599
|
+
declare function resolveBubbleLayout(textWidth: number, textHeight: number, layout: TextBubbleLayout): {
|
|
600
|
+
outerWidth: number;
|
|
601
|
+
outerHeight: number;
|
|
602
|
+
textOffsetX: number;
|
|
603
|
+
textOffsetY: number;
|
|
604
|
+
contentWidth: number;
|
|
605
|
+
contentHeight: number;
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* bubbleRenderer.ts
|
|
610
|
+
*
|
|
611
|
+
* Dedicated Canvas2D Bubble Renderer for Clypra's Text Appearance System.
|
|
612
|
+
*
|
|
613
|
+
* Renders decorative background shapes (torn paper, speech bubbles,
|
|
614
|
+
* thought clouds, ribbons, comic bursts, receipts) behind live editable text.
|
|
615
|
+
*
|
|
616
|
+
* Invariants:
|
|
617
|
+
* - Deterministic output based on preset ID and dimensions.
|
|
618
|
+
* - Always restores canvas state (save/restore).
|
|
619
|
+
* - Operates in unscaled layout coordinates matching text composition.
|
|
620
|
+
*/
|
|
621
|
+
interface BubbleRenderOptions {
|
|
622
|
+
color?: string;
|
|
623
|
+
opacity?: number;
|
|
624
|
+
borderRadius?: number;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Procedural pseudo-random helper for deterministic edge irregularities
|
|
628
|
+
*/
|
|
629
|
+
declare function pseudoNoise(seed: number): number;
|
|
630
|
+
/**
|
|
631
|
+
* Draws a realistic torn paper strip with jagged top/bottom edges,
|
|
632
|
+
* paper texture, and drop shadow. (Matches CapCut reference)
|
|
633
|
+
*/
|
|
634
|
+
declare function drawTornPaper(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, shadow?: boolean): void;
|
|
635
|
+
/**
|
|
636
|
+
* Draws a smooth speech bubble balloon with a curved tail.
|
|
637
|
+
*/
|
|
638
|
+
declare function drawSpeechBubble(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number, radius?: number): void;
|
|
639
|
+
/**
|
|
640
|
+
* Draws a fluffy thought cloud bubble.
|
|
641
|
+
*/
|
|
642
|
+
declare function drawThoughtCloud(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
|
|
643
|
+
/**
|
|
644
|
+
* Draws an energetic comic starburst explosion.
|
|
645
|
+
*/
|
|
646
|
+
declare function drawComicBurst(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
|
|
647
|
+
/**
|
|
648
|
+
* Draws a folded ribbon / banner with chevron notch ends.
|
|
649
|
+
*/
|
|
650
|
+
declare function drawRibbonBanner(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
|
|
651
|
+
/**
|
|
652
|
+
* Main dispatcher: renders a bubble decoration based on its presetId.
|
|
653
|
+
*/
|
|
654
|
+
declare function renderBubbleBackground(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, presetId: string, x: number, y: number, width: number, height: number, options?: BubbleRenderOptions): boolean;
|
|
655
|
+
|
|
525
656
|
type CanonicalRenderInput = {
|
|
526
657
|
capability: "text-template";
|
|
527
658
|
artifact: unknown;
|
|
@@ -534,4 +665,4 @@ type CanonicalRenderInput = {
|
|
|
534
665
|
/** Extensible capability registry for all package-owned render semantics. */
|
|
535
666
|
declare function renderCanonicalToCanvas(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, input: CanonicalRenderInput): CanonicalRenderResult;
|
|
536
667
|
|
|
537
|
-
export { type
|
|
668
|
+
export { type TemplateTextNode as $, type TemplateControl as A, type BubbleRenderMode as B, type CompiledTextTemplate as C, type TemplateControlConstraints as D, type EvaluatedTemplateScene as E, type TemplateControlOption as F, type TemplateControlType as G, type TemplateDependencyManifest as H, type TemplateDurationPolicy as I, type TemplateFontRef as J, type TemplateImageNode as K, type TemplateLayerV2 as L, type TemplateMetadata as M, type TemplateNode as N, type TemplateNodeAnimation as O, type PublishedRevision as P, type TemplatePreviewArtifacts as Q, type RenderPlan as R, type SceneDocumentV2 as S, type TextTemplateArtifact as T, type TemplatePropertyKeyframes as U, type TemplateProtectedRegion as V, type TemplateRenderTarget as W, type TemplateRevision as X, type TemplateShapeNode as Y, type TemplateShapeNodeStyle as Z, type TemplateStyleRef as _, type ResolveTemplateControlValuesOptions as a, type TemplateTextNodeStyle as a0, type TemplateTimelineMarker as a1, type TemplateTiming as a2, type TextBubbleCategory as a3, type TextBubbleLayout as a4, type TextBubblePadding as a5, type TextBubblePreset as a6, type TextEffectRenderInput as a7, type TextTemplateCanvas as a8, type TextTemplateClip as a9, type TextTemplateDocument as aa, type TextTemplateDocumentV2 as ab, type TextTemplateFlexLayout as ac, type TextTemplateRenderInput as ad, canonicalContentHash as ae, canonicalizeSceneDocument as af, drawComicBurst as ag, drawRibbonBanner as ah, drawSpeechBubble as ai, drawThoughtCloud as aj, drawTornPaper as ak, evaluateTextEffect as al, evaluateTextTemplate as am, getRenderCapabilities as an, getTextTemplateControls as ao, normalizeTextEffect as ap, normalizeTextTemplate as aq, pseudoNoise as ar, renderBubbleBackground as as, renderCanonicalToCanvas as at, renderTextEffectToCanvas as au, renderTextTemplateToCanvas as av, resolveBubbleLayout as aw, resolveTemplateFontFamily as ax, resolveTextTemplateArtifact as ay, type TemplateCustomization as b, type TemplateRenderContext as c, type BubbleRenderOptions as d, CANONICAL_RENDERER_VERSION as e, CANONICAL_SCHEMA_VERSION as f, type CanonicalRenderContext as g, type CanonicalRenderInput as h, type CanonicalRenderResult as i, type CapabilityReport as j, type CapabilityStatus as k, type CompiledTemplateRenderLayer as l, type RenderCapability as m, type RenderDiagnostic as n, type RenderDiagnostics as o, type RenderEnvironment as p, type RenderIdentity as q, type RenderTarget as r, TEXT_TEMPLATE_KIND as s, TEXT_TEMPLATE_RENDERER_VERSION as t, TEXT_TEMPLATE_SCHEMA_VERSION as u, type TemplateAssetRef as v, type TemplateBackgroundPanel as w, type TemplateCapabilityReport as x, type TemplateContainerNode as y, type TemplateContainerNodeStyle as z };
|
|
@@ -522,6 +522,137 @@ 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
|
+
/**
|
|
526
|
+
* textBubbles.ts
|
|
527
|
+
*
|
|
528
|
+
* Canonical schema contract and layout resolver for Clypra's
|
|
529
|
+
* Text Bubble & Caption Preset System.
|
|
530
|
+
*
|
|
531
|
+
* Invariants:
|
|
532
|
+
* 1. Text Clip is the sole logical entity on the timeline.
|
|
533
|
+
* 2. Bubble is rendered behind the text as a composite drawable.
|
|
534
|
+
* 3. Text and Bubble share all transforms (x, y, scale, rotation, opacity, keyframes).
|
|
535
|
+
* 4. Content bounds define the safe text region inside the artwork so text never clips or overflows.
|
|
536
|
+
*/
|
|
537
|
+
type TextBubbleCategory = "all" | "speech" | "paper" | "labels" | "decorative" | "comic" | "cute" | "neon" | "banner";
|
|
538
|
+
type BubbleRenderMode = "svg" | "raster" | "nine-slice" | "procedural";
|
|
539
|
+
interface TextBubblePadding {
|
|
540
|
+
top: number;
|
|
541
|
+
right: number;
|
|
542
|
+
bottom: number;
|
|
543
|
+
left: number;
|
|
544
|
+
}
|
|
545
|
+
interface TextBubbleLayout {
|
|
546
|
+
/** Normalized safe content coordinates within the artwork [0..1] */
|
|
547
|
+
contentBounds: {
|
|
548
|
+
x: number;
|
|
549
|
+
y: number;
|
|
550
|
+
width: number;
|
|
551
|
+
height: number;
|
|
552
|
+
};
|
|
553
|
+
/** Minimum outer dimensions in logical editor units */
|
|
554
|
+
minWidth: number;
|
|
555
|
+
minHeight: number;
|
|
556
|
+
/** Whether the bubble artwork must preserve aspect ratio */
|
|
557
|
+
preserveAspectRatio: boolean;
|
|
558
|
+
/** Optional explicit padding around measured text */
|
|
559
|
+
padding?: TextBubblePadding;
|
|
560
|
+
/** Sizing mode: auto-fit grows with text; fixed wraps text into predefined box */
|
|
561
|
+
sizingMode?: "auto-fit" | "fixed";
|
|
562
|
+
}
|
|
563
|
+
interface TextBubblePreset {
|
|
564
|
+
schemaVersion: 1;
|
|
565
|
+
id: string;
|
|
566
|
+
version: number;
|
|
567
|
+
name: string;
|
|
568
|
+
category: TextBubbleCategory;
|
|
569
|
+
tags: string[];
|
|
570
|
+
isReset?: boolean;
|
|
571
|
+
asset?: {
|
|
572
|
+
url?: string;
|
|
573
|
+
format: "svg" | "png" | "webp" | "procedural";
|
|
574
|
+
width: number;
|
|
575
|
+
height: number;
|
|
576
|
+
sha256?: string;
|
|
577
|
+
renderMode: BubbleRenderMode;
|
|
578
|
+
};
|
|
579
|
+
layout: TextBubbleLayout;
|
|
580
|
+
defaultTextStyle?: {
|
|
581
|
+
fontFamily?: string;
|
|
582
|
+
fontSize?: number;
|
|
583
|
+
fontWeight?: string | number;
|
|
584
|
+
fontStyle?: "normal" | "italic";
|
|
585
|
+
textDecoration?: "none" | "underline" | "line-through";
|
|
586
|
+
color?: string;
|
|
587
|
+
};
|
|
588
|
+
thumbnailUrl?: string;
|
|
589
|
+
sampleText?: string;
|
|
590
|
+
renderPreview?: (active: boolean) => unknown;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Resolves the outer bubble bounds and text position given measured text bounds
|
|
594
|
+
* and preset layout rules:
|
|
595
|
+
*
|
|
596
|
+
* W_outer = max(W_text + P_left + P_right, minWidth)
|
|
597
|
+
* H_outer = max(H_text + P_top + P_bottom, minHeight)
|
|
598
|
+
*/
|
|
599
|
+
declare function resolveBubbleLayout(textWidth: number, textHeight: number, layout: TextBubbleLayout): {
|
|
600
|
+
outerWidth: number;
|
|
601
|
+
outerHeight: number;
|
|
602
|
+
textOffsetX: number;
|
|
603
|
+
textOffsetY: number;
|
|
604
|
+
contentWidth: number;
|
|
605
|
+
contentHeight: number;
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* bubbleRenderer.ts
|
|
610
|
+
*
|
|
611
|
+
* Dedicated Canvas2D Bubble Renderer for Clypra's Text Appearance System.
|
|
612
|
+
*
|
|
613
|
+
* Renders decorative background shapes (torn paper, speech bubbles,
|
|
614
|
+
* thought clouds, ribbons, comic bursts, receipts) behind live editable text.
|
|
615
|
+
*
|
|
616
|
+
* Invariants:
|
|
617
|
+
* - Deterministic output based on preset ID and dimensions.
|
|
618
|
+
* - Always restores canvas state (save/restore).
|
|
619
|
+
* - Operates in unscaled layout coordinates matching text composition.
|
|
620
|
+
*/
|
|
621
|
+
interface BubbleRenderOptions {
|
|
622
|
+
color?: string;
|
|
623
|
+
opacity?: number;
|
|
624
|
+
borderRadius?: number;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Procedural pseudo-random helper for deterministic edge irregularities
|
|
628
|
+
*/
|
|
629
|
+
declare function pseudoNoise(seed: number): number;
|
|
630
|
+
/**
|
|
631
|
+
* Draws a realistic torn paper strip with jagged top/bottom edges,
|
|
632
|
+
* paper texture, and drop shadow. (Matches CapCut reference)
|
|
633
|
+
*/
|
|
634
|
+
declare function drawTornPaper(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, shadow?: boolean): void;
|
|
635
|
+
/**
|
|
636
|
+
* Draws a smooth speech bubble balloon with a curved tail.
|
|
637
|
+
*/
|
|
638
|
+
declare function drawSpeechBubble(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number, radius?: number): void;
|
|
639
|
+
/**
|
|
640
|
+
* Draws a fluffy thought cloud bubble.
|
|
641
|
+
*/
|
|
642
|
+
declare function drawThoughtCloud(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
|
|
643
|
+
/**
|
|
644
|
+
* Draws an energetic comic starburst explosion.
|
|
645
|
+
*/
|
|
646
|
+
declare function drawComicBurst(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
|
|
647
|
+
/**
|
|
648
|
+
* Draws a folded ribbon / banner with chevron notch ends.
|
|
649
|
+
*/
|
|
650
|
+
declare function drawRibbonBanner(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number, fillColor?: string, strokeColor?: string, strokeWidth?: number): void;
|
|
651
|
+
/**
|
|
652
|
+
* Main dispatcher: renders a bubble decoration based on its presetId.
|
|
653
|
+
*/
|
|
654
|
+
declare function renderBubbleBackground(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, presetId: string, x: number, y: number, width: number, height: number, options?: BubbleRenderOptions): boolean;
|
|
655
|
+
|
|
525
656
|
type CanonicalRenderInput = {
|
|
526
657
|
capability: "text-template";
|
|
527
658
|
artifact: unknown;
|
|
@@ -534,4 +665,4 @@ type CanonicalRenderInput = {
|
|
|
534
665
|
/** Extensible capability registry for all package-owned render semantics. */
|
|
535
666
|
declare function renderCanonicalToCanvas(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, input: CanonicalRenderInput): CanonicalRenderResult;
|
|
536
667
|
|
|
537
|
-
export { type
|
|
668
|
+
export { type TemplateTextNode as $, type TemplateControl as A, type BubbleRenderMode as B, type CompiledTextTemplate as C, type TemplateControlConstraints as D, type EvaluatedTemplateScene as E, type TemplateControlOption as F, type TemplateControlType as G, type TemplateDependencyManifest as H, type TemplateDurationPolicy as I, type TemplateFontRef as J, type TemplateImageNode as K, type TemplateLayerV2 as L, type TemplateMetadata as M, type TemplateNode as N, type TemplateNodeAnimation as O, type PublishedRevision as P, type TemplatePreviewArtifacts as Q, type RenderPlan as R, type SceneDocumentV2 as S, type TextTemplateArtifact as T, type TemplatePropertyKeyframes as U, type TemplateProtectedRegion as V, type TemplateRenderTarget as W, type TemplateRevision as X, type TemplateShapeNode as Y, type TemplateShapeNodeStyle as Z, type TemplateStyleRef as _, type ResolveTemplateControlValuesOptions as a, type TemplateTextNodeStyle as a0, type TemplateTimelineMarker as a1, type TemplateTiming as a2, type TextBubbleCategory as a3, type TextBubbleLayout as a4, type TextBubblePadding as a5, type TextBubblePreset as a6, type TextEffectRenderInput as a7, type TextTemplateCanvas as a8, type TextTemplateClip as a9, type TextTemplateDocument as aa, type TextTemplateDocumentV2 as ab, type TextTemplateFlexLayout as ac, type TextTemplateRenderInput as ad, canonicalContentHash as ae, canonicalizeSceneDocument as af, drawComicBurst as ag, drawRibbonBanner as ah, drawSpeechBubble as ai, drawThoughtCloud as aj, drawTornPaper as ak, evaluateTextEffect as al, evaluateTextTemplate as am, getRenderCapabilities as an, getTextTemplateControls as ao, normalizeTextEffect as ap, normalizeTextTemplate as aq, pseudoNoise as ar, renderBubbleBackground as as, renderCanonicalToCanvas as at, renderTextEffectToCanvas as au, renderTextTemplateToCanvas as av, resolveBubbleLayout as aw, resolveTemplateFontFamily as ax, resolveTextTemplateArtifact as ay, type TemplateCustomization as b, type TemplateRenderContext as c, type BubbleRenderOptions as d, CANONICAL_RENDERER_VERSION as e, CANONICAL_SCHEMA_VERSION as f, type CanonicalRenderContext as g, type CanonicalRenderInput as h, type CanonicalRenderResult as i, type CapabilityReport as j, type CapabilityStatus as k, type CompiledTemplateRenderLayer as l, type RenderCapability as m, type RenderDiagnostic as n, type RenderDiagnostics as o, type RenderEnvironment as p, type RenderIdentity as q, type RenderTarget as r, TEXT_TEMPLATE_KIND as s, TEXT_TEMPLATE_RENDERER_VERSION as t, TEXT_TEMPLATE_SCHEMA_VERSION as u, type TemplateAssetRef as v, type TemplateBackgroundPanel as w, type TemplateCapabilityReport as x, type TemplateContainerNode as y, type TemplateContainerNodeStyle as z };
|
package/dist/index.cjs
CHANGED
|
@@ -228,8 +228,13 @@ __export(index_exports, {
|
|
|
228
228
|
downloadLottieMp4: () => downloadLottieMp4,
|
|
229
229
|
downloadPngSequenceZip: () => downloadPngSequenceZip,
|
|
230
230
|
downloadSceneWebM: () => downloadSceneWebM,
|
|
231
|
+
drawComicBurst: () => drawComicBurst,
|
|
231
232
|
drawPerCharText: () => drawPerCharText,
|
|
233
|
+
drawRibbonBanner: () => drawRibbonBanner,
|
|
232
234
|
drawRoundedRect: () => drawRoundedRect,
|
|
235
|
+
drawSpeechBubble: () => drawSpeechBubble,
|
|
236
|
+
drawThoughtCloud: () => drawThoughtCloud,
|
|
237
|
+
drawTornPaper: () => drawTornPaper,
|
|
233
238
|
duplicateTrackAtPlayhead: () => duplicateTrackAtPlayhead,
|
|
234
239
|
ease: () => ease,
|
|
235
240
|
editorCommandSystem: () => editorCommandSystem,
|
|
@@ -333,6 +338,7 @@ __export(index_exports, {
|
|
|
333
338
|
propertyInspectorEngine: () => propertyInspectorEngine,
|
|
334
339
|
propertyInterpolator: () => propertyInterpolator,
|
|
335
340
|
pruneTracksForLayer: () => pruneTracksForLayer,
|
|
341
|
+
pseudoNoise: () => pseudoNoise,
|
|
336
342
|
rainbowCharFillColors: () => rainbowCharFillColors,
|
|
337
343
|
readLayerScalar: () => readLayerScalar,
|
|
338
344
|
readStyleFromLottieLayer: () => readStyleFromLottieLayer,
|
|
@@ -341,6 +347,7 @@ __export(index_exports, {
|
|
|
341
347
|
removeKeyframe: () => removeKeyframe,
|
|
342
348
|
removeTemplateKeyframe: () => removeTemplateKeyframe,
|
|
343
349
|
removeTrack: () => removeTrack,
|
|
350
|
+
renderBubbleBackground: () => renderBubbleBackground,
|
|
344
351
|
renderCanonicalToCanvas: () => renderCanonicalToCanvas,
|
|
345
352
|
renderEvaluatedSceneToCanvas: () => renderEvaluatedSceneToCanvas,
|
|
346
353
|
renderPngSequence: () => renderPngSequence,
|
|
@@ -354,6 +361,7 @@ __export(index_exports, {
|
|
|
354
361
|
resolveAnchorPosition: () => resolveAnchorPosition,
|
|
355
362
|
resolveAnimatedScalar: () => resolveAnimatedScalar,
|
|
356
363
|
resolveBehaviorToAnimationSpec: () => resolveBehaviorToAnimationSpec,
|
|
364
|
+
resolveBubbleLayout: () => resolveBubbleLayout,
|
|
357
365
|
resolveConform: () => resolveConform,
|
|
358
366
|
resolveDocumentForBreakpoint: () => resolveDocumentForBreakpoint,
|
|
359
367
|
resolveExportCanvasDimensions: () => resolveExportCanvasDimensions,
|
|
@@ -13804,6 +13812,244 @@ function renderTextTemplateToCanvas(ctx, input) {
|
|
|
13804
13812
|
};
|
|
13805
13813
|
}
|
|
13806
13814
|
|
|
13815
|
+
// src/rendering/textBubbles.ts
|
|
13816
|
+
function resolveBubbleLayout(textWidth, textHeight, layout) {
|
|
13817
|
+
const p = layout.padding ?? {
|
|
13818
|
+
top: 14,
|
|
13819
|
+
right: 18,
|
|
13820
|
+
bottom: 14,
|
|
13821
|
+
left: 18
|
|
13822
|
+
};
|
|
13823
|
+
const rawOuterW = textWidth + p.left + p.right;
|
|
13824
|
+
const rawOuterH = textHeight + p.top + p.bottom;
|
|
13825
|
+
let outerWidth = Math.max(rawOuterW, layout.minWidth);
|
|
13826
|
+
let outerHeight = Math.max(rawOuterH, layout.minHeight);
|
|
13827
|
+
if (layout.preserveAspectRatio && layout.minWidth > 0 && layout.minHeight > 0) {
|
|
13828
|
+
const aspect = layout.minWidth / layout.minHeight;
|
|
13829
|
+
const currentAspect = outerWidth / outerHeight;
|
|
13830
|
+
if (currentAspect > aspect) {
|
|
13831
|
+
outerHeight = outerWidth / aspect;
|
|
13832
|
+
} else {
|
|
13833
|
+
outerWidth = outerHeight * aspect;
|
|
13834
|
+
}
|
|
13835
|
+
}
|
|
13836
|
+
const textOffsetX = (p.left - p.right) / 2;
|
|
13837
|
+
const textOffsetY = (p.top - p.bottom) / 2;
|
|
13838
|
+
return {
|
|
13839
|
+
outerWidth,
|
|
13840
|
+
outerHeight,
|
|
13841
|
+
textOffsetX,
|
|
13842
|
+
textOffsetY,
|
|
13843
|
+
contentWidth: outerWidth - p.left - p.right,
|
|
13844
|
+
contentHeight: outerHeight - p.top - p.bottom
|
|
13845
|
+
};
|
|
13846
|
+
}
|
|
13847
|
+
|
|
13848
|
+
// src/rendering/bubbleRenderer.ts
|
|
13849
|
+
function pseudoNoise(seed) {
|
|
13850
|
+
const x = Math.sin(seed * 12.9898 + 78.233) * 43758.5453;
|
|
13851
|
+
return x - Math.floor(x);
|
|
13852
|
+
}
|
|
13853
|
+
function drawTornPaper(ctx, x, y, width, height, fillColor = "#faf9f6", shadow = true) {
|
|
13854
|
+
ctx.save();
|
|
13855
|
+
if (shadow) {
|
|
13856
|
+
ctx.shadowColor = "rgba(0, 0, 0, 0.35)";
|
|
13857
|
+
ctx.shadowBlur = 12;
|
|
13858
|
+
ctx.shadowOffsetX = 0;
|
|
13859
|
+
ctx.shadowOffsetY = 4;
|
|
13860
|
+
}
|
|
13861
|
+
ctx.fillStyle = fillColor;
|
|
13862
|
+
ctx.beginPath();
|
|
13863
|
+
const steps = Math.max(16, Math.floor(width / 14));
|
|
13864
|
+
const stepW = width / steps;
|
|
13865
|
+
ctx.moveTo(x, y + 6);
|
|
13866
|
+
for (let i = 0; i <= steps; i++) {
|
|
13867
|
+
const curX = x + i * stepW;
|
|
13868
|
+
const n = pseudoNoise(i * 1.37 + 10);
|
|
13869
|
+
const wave2 = Math.sin(i / steps * Math.PI * 3) * 3;
|
|
13870
|
+
const curY = y + (n * 5 - 2.5) + wave2;
|
|
13871
|
+
if (i === 0) ctx.lineTo(curX, curY);
|
|
13872
|
+
else ctx.lineTo(curX, curY);
|
|
13873
|
+
}
|
|
13874
|
+
ctx.lineTo(x + width, y + height - 6);
|
|
13875
|
+
for (let i = steps; i >= 0; i--) {
|
|
13876
|
+
const curX = x + i * stepW;
|
|
13877
|
+
const n = pseudoNoise(i * 2.19 + 50);
|
|
13878
|
+
const wave2 = Math.sin(i / steps * Math.PI * 2) * 4;
|
|
13879
|
+
const curY = y + height + (n * 6 - 3) + wave2;
|
|
13880
|
+
ctx.lineTo(curX, curY);
|
|
13881
|
+
}
|
|
13882
|
+
ctx.lineTo(x, y + 6);
|
|
13883
|
+
ctx.closePath();
|
|
13884
|
+
ctx.fill();
|
|
13885
|
+
if (shadow) {
|
|
13886
|
+
ctx.shadowColor = "transparent";
|
|
13887
|
+
ctx.shadowBlur = 0;
|
|
13888
|
+
}
|
|
13889
|
+
const paperGrad = ctx.createLinearGradient(x, y, x, y + height);
|
|
13890
|
+
paperGrad.addColorStop(0, "rgba(255, 255, 255, 0.4)");
|
|
13891
|
+
paperGrad.addColorStop(0.5, "rgba(0, 0, 0, 0.02)");
|
|
13892
|
+
paperGrad.addColorStop(1, "rgba(0, 0, 0, 0.06)");
|
|
13893
|
+
ctx.fillStyle = paperGrad;
|
|
13894
|
+
ctx.fill();
|
|
13895
|
+
ctx.restore();
|
|
13896
|
+
}
|
|
13897
|
+
function drawSpeechBubble(ctx, x, y, width, height, fillColor = "#ffffff", strokeColor = "#000000", strokeWidth = 2, radius = 16) {
|
|
13898
|
+
ctx.save();
|
|
13899
|
+
const tailH = Math.min(16, height * 0.25);
|
|
13900
|
+
const bodyH = height - tailH;
|
|
13901
|
+
ctx.fillStyle = fillColor;
|
|
13902
|
+
ctx.strokeStyle = strokeColor;
|
|
13903
|
+
ctx.lineWidth = strokeWidth;
|
|
13904
|
+
ctx.beginPath();
|
|
13905
|
+
if (typeof ctx.roundRect === "function") {
|
|
13906
|
+
ctx.roundRect(x, y, width, bodyH, radius);
|
|
13907
|
+
} else {
|
|
13908
|
+
ctx.rect(x, y, width, bodyH);
|
|
13909
|
+
}
|
|
13910
|
+
ctx.fill();
|
|
13911
|
+
if (strokeWidth > 0) ctx.stroke();
|
|
13912
|
+
const tailBaseX = x + width * 0.25;
|
|
13913
|
+
const tailBaseW = Math.min(24, width * 0.2);
|
|
13914
|
+
const tailTipX = x + width * 0.15;
|
|
13915
|
+
const tailTipY = y + height;
|
|
13916
|
+
ctx.beginPath();
|
|
13917
|
+
ctx.moveTo(tailBaseX, y + bodyH - 2);
|
|
13918
|
+
ctx.quadraticCurveTo(tailBaseX + 2, y + bodyH + tailH * 0.6, tailTipX, tailTipY);
|
|
13919
|
+
ctx.quadraticCurveTo(tailBaseX + tailBaseW * 0.7, y + bodyH + tailH * 0.4, tailBaseX + tailBaseW, y + bodyH - 2);
|
|
13920
|
+
ctx.closePath();
|
|
13921
|
+
ctx.fill();
|
|
13922
|
+
if (strokeWidth > 0) ctx.stroke();
|
|
13923
|
+
ctx.beginPath();
|
|
13924
|
+
if (typeof ctx.roundRect === "function") {
|
|
13925
|
+
ctx.roundRect(x + 1, y + 1, width - 2, bodyH - 2, radius);
|
|
13926
|
+
} else {
|
|
13927
|
+
ctx.rect(x + 1, y + 1, width - 2, bodyH - 2);
|
|
13928
|
+
}
|
|
13929
|
+
ctx.fill();
|
|
13930
|
+
ctx.restore();
|
|
13931
|
+
}
|
|
13932
|
+
function drawThoughtCloud(ctx, x, y, width, height, fillColor = "#ffffff", strokeColor = "#000000", strokeWidth = 2) {
|
|
13933
|
+
ctx.save();
|
|
13934
|
+
ctx.fillStyle = fillColor;
|
|
13935
|
+
ctx.strokeStyle = strokeColor;
|
|
13936
|
+
ctx.lineWidth = strokeWidth;
|
|
13937
|
+
const cx = x + width / 2;
|
|
13938
|
+
const cy = y + height / 2;
|
|
13939
|
+
const rx = width * 0.44;
|
|
13940
|
+
const ry = height * 0.38;
|
|
13941
|
+
ctx.beginPath();
|
|
13942
|
+
const lobes = 8;
|
|
13943
|
+
for (let i = 0; i < lobes; i++) {
|
|
13944
|
+
const angle = i / lobes * Math.PI * 2;
|
|
13945
|
+
const lx = cx + Math.cos(angle) * rx;
|
|
13946
|
+
const ly = cy + Math.sin(angle) * ry;
|
|
13947
|
+
const lobeR = Math.min(width, height) * 0.28;
|
|
13948
|
+
ctx.moveTo(lx + lobeR, ly);
|
|
13949
|
+
ctx.arc(lx, ly, lobeR, 0, Math.PI * 2);
|
|
13950
|
+
}
|
|
13951
|
+
ctx.fill();
|
|
13952
|
+
if (strokeWidth > 0) ctx.stroke();
|
|
13953
|
+
ctx.restore();
|
|
13954
|
+
}
|
|
13955
|
+
function drawComicBurst(ctx, x, y, width, height, fillColor = "#ffffff", strokeColor = "#000000", strokeWidth = 3) {
|
|
13956
|
+
ctx.save();
|
|
13957
|
+
ctx.fillStyle = fillColor;
|
|
13958
|
+
ctx.strokeStyle = strokeColor;
|
|
13959
|
+
ctx.lineWidth = strokeWidth;
|
|
13960
|
+
const cx = x + width / 2;
|
|
13961
|
+
const cy = y + height / 2;
|
|
13962
|
+
const points = 16;
|
|
13963
|
+
const outerRx = width / 2;
|
|
13964
|
+
const outerRy = height / 2;
|
|
13965
|
+
const innerRx = width * 0.32;
|
|
13966
|
+
const innerRy = height * 0.32;
|
|
13967
|
+
ctx.beginPath();
|
|
13968
|
+
for (let i = 0; i < points * 2; i++) {
|
|
13969
|
+
const angle = i / (points * 2) * Math.PI * 2 - Math.PI / 2;
|
|
13970
|
+
const isOuter = i % 2 === 0;
|
|
13971
|
+
const rx = isOuter ? outerRx : innerRx;
|
|
13972
|
+
const ry = isOuter ? outerRy : innerRy;
|
|
13973
|
+
const px = cx + Math.cos(angle) * rx;
|
|
13974
|
+
const py = cy + Math.sin(angle) * ry;
|
|
13975
|
+
if (i === 0) ctx.moveTo(px, py);
|
|
13976
|
+
else ctx.lineTo(px, py);
|
|
13977
|
+
}
|
|
13978
|
+
ctx.closePath();
|
|
13979
|
+
ctx.fill();
|
|
13980
|
+
if (strokeWidth > 0) ctx.stroke();
|
|
13981
|
+
ctx.restore();
|
|
13982
|
+
}
|
|
13983
|
+
function drawRibbonBanner(ctx, x, y, width, height, fillColor = "#facc15", strokeColor = "#000000", strokeWidth = 2) {
|
|
13984
|
+
ctx.save();
|
|
13985
|
+
ctx.fillStyle = fillColor;
|
|
13986
|
+
ctx.strokeStyle = strokeColor;
|
|
13987
|
+
ctx.lineWidth = strokeWidth;
|
|
13988
|
+
const notch = Math.min(18, width * 0.08);
|
|
13989
|
+
ctx.beginPath();
|
|
13990
|
+
ctx.moveTo(x, y);
|
|
13991
|
+
ctx.lineTo(x + width - notch, y);
|
|
13992
|
+
ctx.lineTo(x + width, y + height / 2);
|
|
13993
|
+
ctx.lineTo(x + width - notch, y + height);
|
|
13994
|
+
ctx.lineTo(x, y + height);
|
|
13995
|
+
ctx.lineTo(x + notch, y + height / 2);
|
|
13996
|
+
ctx.closePath();
|
|
13997
|
+
ctx.fill();
|
|
13998
|
+
if (strokeWidth > 0) ctx.stroke();
|
|
13999
|
+
ctx.restore();
|
|
14000
|
+
}
|
|
14001
|
+
function renderBubbleBackground(ctx, presetId, x, y, width, height, options) {
|
|
14002
|
+
if (!presetId || presetId === "none") return false;
|
|
14003
|
+
const color = options?.color || "#ffffff";
|
|
14004
|
+
const opacity = options?.opacity ?? 1;
|
|
14005
|
+
ctx.save();
|
|
14006
|
+
if (opacity < 1) {
|
|
14007
|
+
ctx.globalAlpha *= opacity;
|
|
14008
|
+
}
|
|
14009
|
+
if (presetId === "bubble-paper-torn" || presetId === "bubble-paper-torn-beige" || presetId === "bubble-paper-kraft" || presetId === "bubble-paper-notebook") {
|
|
14010
|
+
const paperColor = presetId === "bubble-paper-kraft" ? "#d4a373" : presetId === "bubble-paper-torn-beige" ? "#f3eed9" : "#faf9f6";
|
|
14011
|
+
drawTornPaper(ctx, x, y, width, height, color || paperColor, true);
|
|
14012
|
+
ctx.restore();
|
|
14013
|
+
return true;
|
|
14014
|
+
}
|
|
14015
|
+
if (presetId === "bubble-speech-round" || presetId === "bubble-speech-oval" || presetId === "bubble-speech-tall") {
|
|
14016
|
+
drawSpeechBubble(ctx, x, y, width, height, color, "#000000", 2, 16);
|
|
14017
|
+
ctx.restore();
|
|
14018
|
+
return true;
|
|
14019
|
+
}
|
|
14020
|
+
if (presetId === "bubble-cloud-dotted" || presetId === "bubble-cloud-morning" || presetId === "bubble-cloud-yellow") {
|
|
14021
|
+
drawThoughtCloud(ctx, x, y, width, height, color, "#000000", 2);
|
|
14022
|
+
ctx.restore();
|
|
14023
|
+
return true;
|
|
14024
|
+
}
|
|
14025
|
+
if (presetId === "bubble-comic-bam" || presetId === "bubble-comic-dark-hero") {
|
|
14026
|
+
const burstColor = presetId === "bubble-comic-dark-hero" ? "#18181b" : color;
|
|
14027
|
+
const strokeColor = presetId === "bubble-comic-dark-hero" ? "#ef4444" : "#000000";
|
|
14028
|
+
drawComicBurst(ctx, x, y, width, height, burstColor, strokeColor, 3);
|
|
14029
|
+
ctx.restore();
|
|
14030
|
+
return true;
|
|
14031
|
+
}
|
|
14032
|
+
if (presetId === "bubble-ribbon-sunny" || presetId === "bubble-ribbon-yellow") {
|
|
14033
|
+
drawRibbonBanner(ctx, x, y, width, height, color || "#facc15", "#000000", 2);
|
|
14034
|
+
ctx.restore();
|
|
14035
|
+
return true;
|
|
14036
|
+
}
|
|
14037
|
+
const radius = options?.borderRadius ?? 8;
|
|
14038
|
+
ctx.shadowColor = "rgba(0, 0, 0, 0.2)";
|
|
14039
|
+
ctx.shadowBlur = 8;
|
|
14040
|
+
ctx.shadowOffsetY = 2;
|
|
14041
|
+
ctx.fillStyle = color;
|
|
14042
|
+
ctx.beginPath();
|
|
14043
|
+
if (typeof ctx.roundRect === "function") {
|
|
14044
|
+
ctx.roundRect(x, y, width, height, radius);
|
|
14045
|
+
} else {
|
|
14046
|
+
ctx.rect(x, y, width, height);
|
|
14047
|
+
}
|
|
14048
|
+
ctx.fill();
|
|
14049
|
+
ctx.restore();
|
|
14050
|
+
return true;
|
|
14051
|
+
}
|
|
14052
|
+
|
|
13807
14053
|
// src/rendering/index.ts
|
|
13808
14054
|
function renderCanonicalToCanvas(ctx, input) {
|
|
13809
14055
|
if (input.capability === "text-template") {
|
|
@@ -24856,8 +25102,13 @@ var VERSION = "1.4.0";
|
|
|
24856
25102
|
downloadLottieMp4,
|
|
24857
25103
|
downloadPngSequenceZip,
|
|
24858
25104
|
downloadSceneWebM,
|
|
25105
|
+
drawComicBurst,
|
|
24859
25106
|
drawPerCharText,
|
|
25107
|
+
drawRibbonBanner,
|
|
24860
25108
|
drawRoundedRect,
|
|
25109
|
+
drawSpeechBubble,
|
|
25110
|
+
drawThoughtCloud,
|
|
25111
|
+
drawTornPaper,
|
|
24861
25112
|
duplicateTrackAtPlayhead,
|
|
24862
25113
|
ease,
|
|
24863
25114
|
editorCommandSystem,
|
|
@@ -24961,6 +25212,7 @@ var VERSION = "1.4.0";
|
|
|
24961
25212
|
propertyInspectorEngine,
|
|
24962
25213
|
propertyInterpolator,
|
|
24963
25214
|
pruneTracksForLayer,
|
|
25215
|
+
pseudoNoise,
|
|
24964
25216
|
rainbowCharFillColors,
|
|
24965
25217
|
readLayerScalar,
|
|
24966
25218
|
readStyleFromLottieLayer,
|
|
@@ -24969,6 +25221,7 @@ var VERSION = "1.4.0";
|
|
|
24969
25221
|
removeKeyframe,
|
|
24970
25222
|
removeTemplateKeyframe,
|
|
24971
25223
|
removeTrack,
|
|
25224
|
+
renderBubbleBackground,
|
|
24972
25225
|
renderCanonicalToCanvas,
|
|
24973
25226
|
renderEvaluatedSceneToCanvas,
|
|
24974
25227
|
renderPngSequence,
|
|
@@ -24982,6 +25235,7 @@ var VERSION = "1.4.0";
|
|
|
24982
25235
|
resolveAnchorPosition,
|
|
24983
25236
|
resolveAnimatedScalar,
|
|
24984
25237
|
resolveBehaviorToAnimationSpec,
|
|
25238
|
+
resolveBubbleLayout,
|
|
24985
25239
|
resolveConform,
|
|
24986
25240
|
resolveDocumentForBreakpoint,
|
|
24987
25241
|
resolveExportCanvasDimensions,
|