@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
package/dist/index.js CHANGED
@@ -1,3 +1,50 @@
1
+ import {
2
+ CANONICAL_RENDERER_VERSION,
3
+ CANONICAL_SCHEMA_VERSION,
4
+ TEXT_TEMPLATE_KIND,
5
+ TEXT_TEMPLATE_RENDERER_VERSION,
6
+ TEXT_TEMPLATE_SCHEMA_VERSION,
7
+ addKeyframe,
8
+ applyEasing,
9
+ assertValidTextTemplateArtifact,
10
+ canonicalContentHash,
11
+ canonicalTemplateHash,
12
+ canonicalizeSceneDocument,
13
+ compileTextTemplate,
14
+ createKeyframed,
15
+ cubicBezier,
16
+ evaluateAnimatable,
17
+ evaluateSplitTextTransforms,
18
+ evaluateTextEffect,
19
+ evaluateTextTemplate,
20
+ getRenderCapabilities,
21
+ getSpanForCharIndex,
22
+ getTextTemplateControls,
23
+ interpolateColorString,
24
+ interpolateValue,
25
+ isKeyframed,
26
+ normalizeTextEffect,
27
+ normalizeTextTemplate,
28
+ normalizeTextTemplateArtifact,
29
+ removeTemplateKeyframe,
30
+ renderCanonicalToCanvas,
31
+ renderTextEffectToCanvas,
32
+ renderTextTemplateToCanvas,
33
+ resolveTemplateFontFamily,
34
+ resolveTextTemplateArtifact,
35
+ solveSpring,
36
+ splitTextContent,
37
+ validateTextTemplateArtifact
38
+ } from "./chunk-V5D5SJPO.js";
39
+ import {
40
+ FontLoader,
41
+ checkFontVariant,
42
+ ensureFontsLoaded,
43
+ getFontLoader,
44
+ initializeFontSystem,
45
+ injectFontVariantRules,
46
+ resetFontLoader
47
+ } from "./chunk-NG4F55V7.js";
1
48
  import {
2
49
  COMPOSITION_PRESETS,
3
50
  CanvasDevice,
@@ -6,7 +53,6 @@ import {
6
53
  DEFAULT_DURATION,
7
54
  DEFAULT_FONT_SIZE,
8
55
  DEFAULT_FPS,
9
- FontLoader,
10
56
  SCENE_SCHEMA_VERSION,
11
57
  SCENE_VERSION,
12
58
  TextEffectRenderer,
@@ -18,7 +64,6 @@ import {
18
64
  applyMaskReveal,
19
65
  applyTimelineAtTime,
20
66
  builtInPresets,
21
- checkFontVariant,
22
67
  cloneSceneWithNewIds,
23
68
  computeAutoFitFontSize,
24
69
  computeFitZoom,
@@ -34,13 +79,9 @@ import {
34
79
  drawRoundedRect,
35
80
  ease,
36
81
  ensureDefaultTimeline,
37
- ensureFontsLoaded,
38
82
  evaluateConfig,
39
83
  evaluateScene,
40
- getFontLoader,
41
84
  getSceneTime,
42
- initializeFontSystem,
43
- injectFontVariantRules,
44
85
  layerToTextEffectConfig,
45
86
  measureTextFits,
46
87
  mergeSceneIntoConfig,
@@ -48,7 +89,6 @@ import {
48
89
  rainbowCharFillColors,
49
90
  releaseCanvas,
50
91
  renderTextEffectCore,
51
- resetFontLoader,
52
92
  resetSceneTime,
53
93
  resizeCharFillColors,
54
94
  resolveAnimatedScalar,
@@ -65,23 +105,7 @@ import {
65
105
  syncCompositorFromScene,
66
106
  textEffectConfigToScene,
67
107
  wrapTextToWidth
68
- } from "./chunk-E6O6LZME.js";
69
- import {
70
- ALL_TRANSITIONS,
71
- TRANSITION_CATEGORIES,
72
- TRANSITION_PRESETS,
73
- TransitionRenderer,
74
- getAllTransitionTags,
75
- getAllTransitions,
76
- getRecommendedDuration,
77
- getTransitionById,
78
- getTransitionByRenderer,
79
- getTransitionCategories,
80
- getTransitionCountByCategory,
81
- getTransitionsByCategory,
82
- getTransitionsByTags,
83
- searchTransitions
84
- } from "./chunk-PU3Q4QI7.js";
108
+ } from "./chunk-7ORA5BPW.js";
85
109
  import {
86
110
  EFFECTS_REGISTRY,
87
111
  EffectEngine,
@@ -107,7 +131,23 @@ import {
107
131
  searchEffects,
108
132
  searchEffectsForApi,
109
133
  withContext
110
- } from "./chunk-3UEOLDJJ.js";
134
+ } from "./chunk-SH7HOGVX.js";
135
+ import {
136
+ ALL_TRANSITIONS,
137
+ TRANSITION_CATEGORIES,
138
+ TRANSITION_PRESETS,
139
+ TransitionRenderer,
140
+ getAllTransitionTags,
141
+ getAllTransitions,
142
+ getRecommendedDuration,
143
+ getTransitionById,
144
+ getTransitionByRenderer,
145
+ getTransitionCategories,
146
+ getTransitionCountByCategory,
147
+ getTransitionsByCategory,
148
+ getTransitionsByTags,
149
+ searchTransitions
150
+ } from "./chunk-PU3Q4QI7.js";
111
151
  import "./chunk-PZ5AY32C.js";
112
152
 
113
153
  // src/validation.ts
@@ -299,7 +339,15 @@ var TemplateCategorySchema = z.enum([
299
339
  "caption",
300
340
  "callout",
301
341
  "social",
302
- "countdown"
342
+ "countdown",
343
+ "kinetic-type",
344
+ "cta",
345
+ "credits",
346
+ "quotes",
347
+ "sports",
348
+ "gaming",
349
+ "news",
350
+ "minimal"
303
351
  ]);
304
352
  var AnimationPresetSchema = z.enum([
305
353
  "fade",
@@ -594,16 +642,16 @@ function reindexLayers(lottieData) {
594
642
  });
595
643
  }
596
644
  function addSolidLayer(lottieData, name, color, w, h) {
597
- const clone2 = JSON.parse(JSON.stringify(lottieData));
598
- if (!Array.isArray(clone2.layers)) clone2.layers = [];
645
+ const clone = JSON.parse(JSON.stringify(lottieData));
646
+ if (!Array.isArray(clone.layers)) clone.layers = [];
599
647
  const newLayer = {
600
648
  ty: 1,
601
649
  nm: name,
602
650
  sr: 1,
603
651
  st: 0,
604
652
  ip: 0,
605
- op: clone2.op,
606
- ind: clone2.layers.length + 1,
653
+ op: clone.op,
654
+ ind: clone.layers.length + 1,
607
655
  sw: w,
608
656
  sh: h,
609
657
  sc: color,
@@ -616,23 +664,23 @@ function addSolidLayer(lottieData, name, color, w, h) {
616
664
  o: { a: 0, k: 100 }
617
665
  }
618
666
  };
619
- clone2.layers.push(newLayer);
620
- reindexLayers(clone2);
621
- return clone2;
667
+ clone.layers.push(newLayer);
668
+ reindexLayers(clone);
669
+ return clone;
622
670
  }
623
671
  function addTextLayer(lottieData, name, text) {
624
- const clone2 = JSON.parse(JSON.stringify(lottieData));
625
- if (!Array.isArray(clone2.layers)) clone2.layers = [];
626
- const w = clone2.w || 1920;
627
- const h = clone2.h || 1080;
672
+ const clone = JSON.parse(JSON.stringify(lottieData));
673
+ if (!Array.isArray(clone.layers)) clone.layers = [];
674
+ const w = clone.w || 1920;
675
+ const h = clone.h || 1080;
628
676
  const newLayer = {
629
677
  ty: 5,
630
678
  nm: name,
631
679
  sr: 1,
632
680
  st: 0,
633
681
  ip: 0,
634
- op: clone2.op,
635
- ind: clone2.layers.length + 1,
682
+ op: clone.op,
683
+ ind: clone.layers.length + 1,
636
684
  ks: {
637
685
  a: { a: 0, k: [0, 0, 0] },
638
686
  p: { a: 0, k: [w / 2, h / 2, 0] },
@@ -674,23 +722,23 @@ function addTextLayer(lottieData, name, text) {
674
722
  }
675
723
  }
676
724
  };
677
- clone2.layers.unshift(newLayer);
678
- reindexLayers(clone2);
679
- return clone2;
725
+ clone.layers.unshift(newLayer);
726
+ reindexLayers(clone);
727
+ return clone;
680
728
  }
681
729
  function addShapeLayer(lottieData, name) {
682
- const clone2 = JSON.parse(JSON.stringify(lottieData));
683
- if (!Array.isArray(clone2.layers)) clone2.layers = [];
684
- const w = clone2.w || 1920;
685
- const h = clone2.h || 1080;
730
+ const clone = JSON.parse(JSON.stringify(lottieData));
731
+ if (!Array.isArray(clone.layers)) clone.layers = [];
732
+ const w = clone.w || 1920;
733
+ const h = clone.h || 1080;
686
734
  const newLayer = {
687
735
  ty: 4,
688
736
  nm: name,
689
737
  sr: 1,
690
738
  st: 0,
691
739
  ip: 0,
692
- op: clone2.op,
693
- ind: clone2.layers.length + 1,
740
+ op: clone.op,
741
+ ind: clone.layers.length + 1,
694
742
  ks: {
695
743
  a: { a: 0, k: [0, 0, 0] },
696
744
  p: { a: 0, k: [w / 2, h / 2, 0] },
@@ -700,14 +748,14 @@ function addShapeLayer(lottieData, name) {
700
748
  },
701
749
  shapes: []
702
750
  };
703
- clone2.layers.unshift(newLayer);
704
- reindexLayers(clone2);
705
- return clone2;
751
+ clone.layers.unshift(newLayer);
752
+ reindexLayers(clone);
753
+ return clone;
706
754
  }
707
755
  function addVectorShape(lottieData, layerIndex, shapeType, colorHex) {
708
- const clone2 = JSON.parse(JSON.stringify(lottieData));
709
- const layer = clone2.layers[layerIndex];
710
- if (!layer || layer.ty !== 4) return clone2;
756
+ const clone = JSON.parse(JSON.stringify(lottieData));
757
+ const layer = clone.layers[layerIndex];
758
+ if (!layer || layer.ty !== 4) return clone;
711
759
  if (!Array.isArray(layer.shapes)) layer.shapes = [];
712
760
  const cleanHex = colorHex.startsWith("#") ? colorHex.slice(1) : colorHex;
713
761
  const r = parseInt(cleanHex.slice(0, 2), 16) / 255 || 0.5;
@@ -781,7 +829,7 @@ function addVectorShape(lottieData, layerIndex, shapeType, colorHex) {
781
829
  };
782
830
  }
783
831
  layer.shapes.push(shapeContent);
784
- return clone2;
832
+ return clone;
785
833
  }
786
834
  function getProperty(layer, path) {
787
835
  if (!layer) return null;
@@ -794,9 +842,9 @@ function getProperty(layer, path) {
794
842
  return current;
795
843
  }
796
844
  function updateStaticProperty(lottieData, layerIndex, path, value) {
797
- const clone2 = JSON.parse(JSON.stringify(lottieData));
798
- const layer = clone2.layers[layerIndex];
799
- if (!layer) return clone2;
845
+ const clone = JSON.parse(JSON.stringify(lottieData));
846
+ const layer = clone.layers[layerIndex];
847
+ if (!layer) return clone;
800
848
  const propObj = getProperty(layer, path);
801
849
  if (propObj) {
802
850
  propObj.a = 0;
@@ -806,7 +854,7 @@ function updateStaticProperty(lottieData, layerIndex, path, value) {
806
854
  propObj.k = value;
807
855
  }
808
856
  }
809
- return clone2;
857
+ return clone;
810
858
  }
811
859
  var EASING_CURVES = {
812
860
  linear: {
@@ -827,9 +875,9 @@ var EASING_CURVES = {
827
875
  }
828
876
  };
829
877
  function enableKeyframing(lottieData, layerIndex, path) {
830
- const clone2 = JSON.parse(JSON.stringify(lottieData));
831
- const layer = clone2.layers[layerIndex];
832
- if (!layer) return clone2;
878
+ const clone = JSON.parse(JSON.stringify(lottieData));
879
+ const layer = clone.layers[layerIndex];
880
+ if (!layer) return clone;
833
881
  const propObj = getProperty(layer, path);
834
882
  if (propObj && propObj.a === 0) {
835
883
  const staticValue = propObj.k;
@@ -843,14 +891,14 @@ function enableKeyframing(lottieData, layerIndex, path) {
843
891
  }
844
892
  ];
845
893
  }
846
- return clone2;
894
+ return clone;
847
895
  }
848
896
  function addOrUpdateKeyframe(lottieData, layerIndex, path, frame, value, easing = "easeInOut") {
849
- const clone2 = JSON.parse(JSON.stringify(lottieData));
850
- const layer = clone2.layers[layerIndex];
851
- if (!layer) return clone2;
897
+ const clone = JSON.parse(JSON.stringify(lottieData));
898
+ const layer = clone.layers[layerIndex];
899
+ if (!layer) return clone;
852
900
  const propObj = getProperty(layer, path);
853
- if (!propObj) return clone2;
901
+ if (!propObj) return clone;
854
902
  if (propObj.a === 0) {
855
903
  propObj.a = 1;
856
904
  propObj.k = [
@@ -891,14 +939,14 @@ function addOrUpdateKeyframe(lottieData, layerIndex, path, frame, value, easing
891
939
  kf2.o = kf2.o || curves.o;
892
940
  }
893
941
  });
894
- return clone2;
942
+ return clone;
895
943
  }
896
944
  function deleteKeyframe(lottieData, layerIndex, path, frame) {
897
- const clone2 = JSON.parse(JSON.stringify(lottieData));
898
- const layer = clone2.layers[layerIndex];
899
- if (!layer) return clone2;
945
+ const clone = JSON.parse(JSON.stringify(lottieData));
946
+ const layer = clone.layers[layerIndex];
947
+ if (!layer) return clone;
900
948
  const propObj = getProperty(layer, path);
901
- if (!propObj || propObj.a === 0) return clone2;
949
+ if (!propObj || propObj.a === 0) return clone;
902
950
  let keyframes = propObj.k;
903
951
  keyframes = keyframes.filter((kf2) => kf2.t !== frame);
904
952
  if (keyframes.length === 0) {
@@ -913,14 +961,14 @@ function deleteKeyframe(lottieData, layerIndex, path, frame) {
913
961
  }
914
962
  });
915
963
  }
916
- return clone2;
964
+ return clone;
917
965
  }
918
966
  function addImageLayer(lottieData, name, base64Data, w, h) {
919
- const clone2 = JSON.parse(JSON.stringify(lottieData));
920
- if (!Array.isArray(clone2.assets)) clone2.assets = [];
921
- if (!Array.isArray(clone2.layers)) clone2.layers = [];
967
+ const clone = JSON.parse(JSON.stringify(lottieData));
968
+ if (!Array.isArray(clone.assets)) clone.assets = [];
969
+ if (!Array.isArray(clone.layers)) clone.layers = [];
922
970
  const assetId = `img_${Date.now()}`;
923
- clone2.assets.push({
971
+ clone.assets.push({
924
972
  id: assetId,
925
973
  w,
926
974
  h,
@@ -929,8 +977,8 @@ function addImageLayer(lottieData, name, base64Data, w, h) {
929
977
  // data:image/png;base64,...
930
978
  e: 1
931
979
  });
932
- const compW = clone2.w || 1920;
933
- const compH = clone2.h || 1080;
980
+ const compW = clone.w || 1920;
981
+ const compH = clone.h || 1080;
934
982
  const newLayer = {
935
983
  ty: 2,
936
984
  nm: name,
@@ -938,8 +986,8 @@ function addImageLayer(lottieData, name, base64Data, w, h) {
938
986
  sr: 1,
939
987
  st: 0,
940
988
  ip: 0,
941
- op: clone2.op,
942
- ind: clone2.layers.length + 1,
989
+ op: clone.op,
990
+ ind: clone.layers.length + 1,
943
991
  ks: {
944
992
  a: { a: 0, k: [w / 2, h / 2, 0] },
945
993
  p: { a: 0, k: [compW / 2, compH / 2, 0] },
@@ -948,20 +996,20 @@ function addImageLayer(lottieData, name, base64Data, w, h) {
948
996
  o: { a: 0, k: 100 }
949
997
  }
950
998
  };
951
- clone2.layers.unshift(newLayer);
952
- reindexLayers(clone2);
953
- return clone2;
999
+ clone.layers.unshift(newLayer);
1000
+ reindexLayers(clone);
1001
+ return clone;
954
1002
  }
955
1003
  function updateTrackMatte(lottieData, layerIndex, matteType) {
956
- const clone2 = JSON.parse(JSON.stringify(lottieData));
957
- const layer = clone2.layers[layerIndex];
958
- if (!layer) return clone2;
1004
+ const clone = JSON.parse(JSON.stringify(lottieData));
1005
+ const layer = clone.layers[layerIndex];
1006
+ if (!layer) return clone;
959
1007
  if (matteType === 0) {
960
1008
  delete layer.tt;
961
1009
  } else {
962
1010
  layer.tt = matteType;
963
1011
  }
964
- return clone2;
1012
+ return clone;
965
1013
  }
966
1014
 
967
1015
  // src/engine/lottieParser.ts
@@ -1088,9 +1136,9 @@ function traverseAllLayers(lottieData, fn) {
1088
1136
  }
1089
1137
  function injectText(lottieData, customization, textLayers) {
1090
1138
  if (!lottieData) return lottieData;
1091
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1139
+ const clone = JSON.parse(JSON.stringify(lottieData));
1092
1140
  const configMap = new Map(textLayers.map((l) => [l.layerName, l]));
1093
- traverseAllLayers(clone2, (layer) => {
1141
+ traverseAllLayers(clone, (layer) => {
1094
1142
  if (layer.ty !== 5) return;
1095
1143
  const config = configMap.get(layer.nm);
1096
1144
  if (!config) return;
@@ -1098,29 +1146,29 @@ function injectText(lottieData, customization, textLayers) {
1098
1146
  const text = raw.slice(0, config.maxCharacters);
1099
1147
  mutateTextLayer(layer, { text });
1100
1148
  });
1101
- return clone2;
1149
+ return clone;
1102
1150
  }
1103
1151
  function injectTextStyle(lottieData, layerName, override) {
1104
1152
  if (!lottieData) return lottieData;
1105
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1106
- traverseAllLayers(clone2, (layer) => {
1153
+ const clone = JSON.parse(JSON.stringify(lottieData));
1154
+ traverseAllLayers(clone, (layer) => {
1107
1155
  if (layer.ty !== 5 || layer.nm !== layerName) return;
1108
1156
  mutateTextLayer(layer, override);
1109
1157
  });
1110
- return clone2;
1158
+ return clone;
1111
1159
  }
1112
1160
  function injectGlobalTextStyle(lottieData, override) {
1113
1161
  if (!lottieData) return lottieData;
1114
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1115
- traverseAllLayers(clone2, (layer) => {
1162
+ const clone = JSON.parse(JSON.stringify(lottieData));
1163
+ traverseAllLayers(clone, (layer) => {
1116
1164
  if (layer.ty !== 5) return;
1117
1165
  mutateTextLayer(layer, override);
1118
1166
  });
1119
- return clone2;
1167
+ return clone;
1120
1168
  }
1121
1169
  function injectColor(lottieData, layerName, hexColor) {
1122
1170
  if (!lottieData || !layerName) return lottieData;
1123
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1171
+ const clone = JSON.parse(JSON.stringify(lottieData));
1124
1172
  const targetRgb = hexToLottieRgb(hexColor);
1125
1173
  function traverseShapes(obj) {
1126
1174
  if (!obj || typeof obj !== "object") return;
@@ -1140,33 +1188,33 @@ function injectColor(lottieData, layerName, hexColor) {
1140
1188
  else if (val && typeof val === "object") traverseShapes(val);
1141
1189
  }
1142
1190
  }
1143
- traverseAllLayers(clone2, (layer) => {
1191
+ traverseAllLayers(clone, (layer) => {
1144
1192
  if (layer.nm === layerName) traverseShapes(layer);
1145
1193
  });
1146
- return clone2;
1194
+ return clone;
1147
1195
  }
1148
1196
  function injectSolidColor(lottieData, layerName, hexColor) {
1149
1197
  if (!lottieData) return lottieData;
1150
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1151
- traverseAllLayers(clone2, (layer) => {
1198
+ const clone = JSON.parse(JSON.stringify(lottieData));
1199
+ traverseAllLayers(clone, (layer) => {
1152
1200
  if (layer.ty === 1 && layer.nm === layerName) {
1153
1201
  layer.sc = hexColor;
1154
1202
  }
1155
1203
  });
1156
- return clone2;
1204
+ return clone;
1157
1205
  }
1158
1206
  function injectBatch(lottieData, batch) {
1159
1207
  if (!lottieData) return lottieData;
1160
- let clone2 = JSON.parse(JSON.stringify(lottieData));
1161
- if (batch.hiddenLayers && Array.isArray(clone2.layers)) {
1162
- clone2.layers.forEach((layer, idx) => {
1208
+ let clone = JSON.parse(JSON.stringify(lottieData));
1209
+ if (batch.hiddenLayers && Array.isArray(clone.layers)) {
1210
+ clone.layers.forEach((layer, idx) => {
1163
1211
  layer.hd = batch.hiddenLayers.has(idx);
1164
1212
  });
1165
1213
  }
1166
1214
  if (batch.textCustomization) {
1167
1215
  const { customization, layers } = batch.textCustomization;
1168
1216
  const configMap = new Map(layers.map((l) => [l.layerName, l]));
1169
- traverseAllLayers(clone2, (layer) => {
1217
+ traverseAllLayers(clone, (layer) => {
1170
1218
  if (layer.ty !== 5) return;
1171
1219
  const config = configMap.get(layer.nm);
1172
1220
  if (!config) return;
@@ -1176,7 +1224,7 @@ function injectBatch(lottieData, batch) {
1176
1224
  }
1177
1225
  if (batch.styleOverrides) {
1178
1226
  const styleMap = new Map(batch.styleOverrides.map((s) => [s.layerName, s.override]));
1179
- traverseAllLayers(clone2, (layer) => {
1227
+ traverseAllLayers(clone, (layer) => {
1180
1228
  if (layer.ty !== 5) return;
1181
1229
  const override = styleMap.get(layer.nm);
1182
1230
  if (override) mutateTextLayer(layer, override);
@@ -1184,15 +1232,15 @@ function injectBatch(lottieData, batch) {
1184
1232
  }
1185
1233
  if (batch.colorOverrides) {
1186
1234
  for (const { layerName, color } of batch.colorOverrides) {
1187
- clone2 = injectColor(clone2, layerName, color);
1235
+ clone = injectColor(clone, layerName, color);
1188
1236
  }
1189
1237
  }
1190
1238
  if (batch.solidOverrides) {
1191
1239
  for (const { layerName, color } of batch.solidOverrides) {
1192
- clone2 = injectSolidColor(clone2, layerName, color);
1240
+ clone = injectSolidColor(clone, layerName, color);
1193
1241
  }
1194
1242
  }
1195
- return clone2;
1243
+ return clone;
1196
1244
  }
1197
1245
 
1198
1246
  // src/engine/lottieTextAnimations.ts
@@ -1692,9 +1740,9 @@ function getAnimPreset(id) {
1692
1740
  return LOTTIE_ANIM_PRESETS.find((p) => p.id === id);
1693
1741
  }
1694
1742
  function bakeAnimationIntoLayer(lottieData, layerIndex, preset, opts) {
1695
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1696
- const layer = clone2.layers?.[layerIndex];
1697
- if (!layer) return clone2;
1743
+ const clone = JSON.parse(JSON.stringify(lottieData));
1744
+ const layer = clone.layers?.[layerIndex];
1745
+ if (!layer) return clone;
1698
1746
  const tracks = preset.buildTracks({ ...opts, layerIndex });
1699
1747
  for (const track of tracks) {
1700
1748
  const keys = track.path.split(".");
@@ -1726,12 +1774,12 @@ function bakeAnimationIntoLayer(lottieData, layerIndex, preset, opts) {
1726
1774
  });
1727
1775
  prop.k = existing;
1728
1776
  }
1729
- return clone2;
1777
+ return clone;
1730
1778
  }
1731
1779
  function clearAnimationFromLayer(lottieData, layerIndex, paths = ["ks.p", "ks.s", "ks.r", "ks.o"]) {
1732
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1733
- const layer = clone2.layers?.[layerIndex];
1734
- if (!layer) return clone2;
1780
+ const clone = JSON.parse(JSON.stringify(lottieData));
1781
+ const layer = clone.layers?.[layerIndex];
1782
+ if (!layer) return clone;
1735
1783
  for (const path of paths) {
1736
1784
  const keys = path.split(".");
1737
1785
  let prop = layer;
@@ -1747,7 +1795,7 @@ function clearAnimationFromLayer(lottieData, layerIndex, paths = ["ks.p", "ks.s"
1747
1795
  }
1748
1796
  }
1749
1797
  }
1750
- return clone2;
1798
+ return clone;
1751
1799
  }
1752
1800
 
1753
1801
  // src/engine/lottieTextStyle.ts
@@ -1883,9 +1931,9 @@ function readStyleFromLottieLayer(layer) {
1883
1931
  return style;
1884
1932
  }
1885
1933
  function applyStyleToLottieLayer(layer, style) {
1886
- const clone2 = JSON.parse(JSON.stringify(layer));
1887
- if (!clone2 || clone2.ty !== 5) return clone2;
1888
- const ks = clone2.ks || {};
1934
+ const clone = JSON.parse(JSON.stringify(layer));
1935
+ if (!clone || clone.ty !== 5) return clone;
1936
+ const ks = clone.ks || {};
1889
1937
  if (ks.p) {
1890
1938
  if (ks.p.a === 0) {
1891
1939
  const base = Array.isArray(ks.p.k) ? ks.p.k : [0, 0, 0];
@@ -1903,9 +1951,9 @@ function applyStyleToLottieLayer(layer, style) {
1903
1951
  if (ks.o) {
1904
1952
  if (ks.o.a === 0) ks.o.k = style.opacity;
1905
1953
  }
1906
- clone2.ks = ks;
1907
- const td = clone2.t?.d;
1908
- if (!td) return clone2;
1954
+ clone.ks = ks;
1955
+ const td = clone.t?.d;
1956
+ if (!td) return clone;
1909
1957
  const applyToDoc = (doc) => {
1910
1958
  if (!doc) return;
1911
1959
  doc.s = style.fontSize;
@@ -1929,21 +1977,21 @@ function applyStyleToLottieLayer(layer, style) {
1929
1977
  } else if (td.k?.s) {
1930
1978
  applyToDoc(td.k.s);
1931
1979
  }
1932
- return clone2;
1980
+ return clone;
1933
1981
  }
1934
1982
  function applyStyleToLottie(lottieData, layerIndex, style) {
1935
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1936
- if (!clone2.layers?.[layerIndex]) return clone2;
1937
- clone2.layers[layerIndex] = applyStyleToLottieLayer(clone2.layers[layerIndex], style);
1938
- return clone2;
1983
+ const clone = JSON.parse(JSON.stringify(lottieData));
1984
+ if (!clone.layers?.[layerIndex]) return clone;
1985
+ clone.layers[layerIndex] = applyStyleToLottieLayer(clone.layers[layerIndex], style);
1986
+ return clone;
1939
1987
  }
1940
1988
  function ensureFontInLottie(lottieData, entry) {
1941
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1942
- if (!clone2.fonts) clone2.fonts = { list: [] };
1943
- if (!Array.isArray(clone2.fonts.list)) clone2.fonts.list = [];
1944
- const exists = clone2.fonts.list.some((f) => f.fName === entry.fName);
1945
- if (!exists) clone2.fonts.list.push(entry);
1946
- return clone2;
1989
+ const clone = JSON.parse(JSON.stringify(lottieData));
1990
+ if (!clone.fonts) clone.fonts = { list: [] };
1991
+ if (!Array.isArray(clone.fonts.list)) clone.fonts.list = [];
1992
+ const exists = clone.fonts.list.some((f) => f.fName === entry.fName);
1993
+ if (!exists) clone.fonts.list.push(entry);
1994
+ return clone;
1947
1995
  }
1948
1996
  var SUPPORTED_FONT_FAMILIES = ["Poppins", "Montserrat", "Inter", "Roboto", "Open Sans", "Lato", "Raleway", "Oswald", "Bebas Neue", "Anton", "Playfair Display", "Merriweather", "Nunito", "Ubuntu", "Source Sans Pro", "PT Sans", "Noto Sans", "Exo 2", "Barlow", "Kanit", "Righteous", "Pacifico", "Lobster", "Dancing Script", "Satisfy", "Permanent Marker", "Arial", "Georgia", "Times New Roman", "Courier New"];
1949
1997
  var FONT_WEIGHT_OPTIONS = [
@@ -1981,7 +2029,7 @@ function hex2lottie(hex) {
1981
2029
  return [parseInt(c.slice(0, 2), 16) / 255, parseInt(c.slice(2, 4), 16) / 255, parseInt(c.slice(4, 6), 16) / 255];
1982
2030
  }
1983
2031
  function applyTextDoc(layer, opts) {
1984
- const clone2 = JSON.parse(JSON.stringify(layer));
2032
+ const clone = JSON.parse(JSON.stringify(layer));
1985
2033
  const applyDoc = (doc) => {
1986
2034
  doc.t = opts.text;
1987
2035
  doc.f = opts.font;
@@ -1995,22 +2043,22 @@ function applyTextDoc(layer, opts) {
1995
2043
  doc.sw = opts.strokeWidth;
1996
2044
  }
1997
2045
  };
1998
- const td = clone2.t?.d;
1999
- if (!td) return clone2;
2046
+ const td = clone.t?.d;
2047
+ if (!td) return clone;
2000
2048
  if (Array.isArray(td.k))
2001
2049
  td.k.forEach((kf2) => {
2002
2050
  if (kf2?.s) applyDoc(kf2.s);
2003
2051
  });
2004
2052
  else if (td.k?.s) applyDoc(td.k.s);
2005
- return clone2;
2053
+ return clone;
2006
2054
  }
2007
2055
  function setLayerPos(layer, x, y) {
2008
- const clone2 = JSON.parse(JSON.stringify(layer));
2009
- if (clone2.ks?.p?.a === 0) clone2.ks.p.k = [x, y, 0];
2010
- return clone2;
2056
+ const clone = JSON.parse(JSON.stringify(layer));
2057
+ if (clone.ks?.p?.a === 0) clone.ks.p.k = [x, y, 0];
2058
+ return clone;
2011
2059
  }
2012
2060
  function addRoundedRect(lottie, name, cx, cy, w, h, r, color) {
2013
- let clone2 = JSON.parse(JSON.stringify(lottie));
2061
+ let clone = JSON.parse(JSON.stringify(lottie));
2014
2062
  const [cr, cg, cb] = hex2lottie(color);
2015
2063
  const shapeLayer = {
2016
2064
  ty: 4,
@@ -2018,7 +2066,7 @@ function addRoundedRect(lottie, name, cx, cy, w, h, r, color) {
2018
2066
  sr: 1,
2019
2067
  st: 0,
2020
2068
  ip: 0,
2021
- op: clone2.op,
2069
+ op: clone.op,
2022
2070
  ind: 1,
2023
2071
  ks: {
2024
2072
  a: { a: 0, k: [0, 0, 0] },
@@ -2039,9 +2087,9 @@ function addRoundedRect(lottie, name, cx, cy, w, h, r, color) {
2039
2087
  }
2040
2088
  ]
2041
2089
  };
2042
- clone2.layers.push(shapeLayer);
2043
- reindexLayers(clone2);
2044
- return clone2;
2090
+ clone.layers.push(shapeLayer);
2091
+ reindexLayers(clone);
2092
+ return clone;
2045
2093
  }
2046
2094
  function buildCleanLowerThird() {
2047
2095
  let l = createBlankLottie(1920, 1080, 30, 120);
@@ -2649,8 +2697,8 @@ function quantizeTopalette(pixels, maxColors) {
2649
2697
  function mapPixelsToPalette(pixels, palette, transparentIndex) {
2650
2698
  const indices = new Uint8Array(pixels.length / 4);
2651
2699
  for (let i = 0; i < pixels.length; i += 4) {
2652
- const alpha = pixels[i + 3];
2653
- if (alpha < 128) {
2700
+ const alpha2 = pixels[i + 3];
2701
+ if (alpha2 < 128) {
2654
2702
  indices[i / 4] = transparentIndex;
2655
2703
  continue;
2656
2704
  }
@@ -4258,448 +4306,73 @@ var TextEffectBuilder = class _TextEffectBuilder {
4258
4306
  }
4259
4307
  };
4260
4308
 
4261
- // src/templates/keyframes.ts
4262
- function isKeyframed(value) {
4263
- return typeof value === "object" && value !== null && "keyframes" in value && Array.isArray(value.keyframes);
4264
- }
4265
- function evaluateAnimatable(value, time, templateDuration) {
4266
- if (!isKeyframed(value)) {
4267
- return value;
4268
- }
4269
- const { keyframes } = value;
4270
- if (keyframes.length === 0) {
4271
- throw new Error("Keyframes array cannot be empty");
4272
- }
4273
- if (keyframes.length === 1) {
4274
- return keyframes[0].value;
4275
- }
4276
- const sorted = [...keyframes].sort((a, b) => a.time - b.time);
4277
- if (time <= sorted[0].time) {
4278
- return sorted[0].value;
4279
- }
4280
- if (time >= sorted[sorted.length - 1].time) {
4281
- return sorted[sorted.length - 1].value;
4282
- }
4283
- let leftIdx = 0;
4284
- for (let i = 0; i < sorted.length - 1; i++) {
4285
- if (time >= sorted[i].time && time <= sorted[i + 1].time) {
4286
- leftIdx = i;
4309
+ // src/templates/responsiveLayout.ts
4310
+ function resolveAnchorPosition(anchor, currentBounds, canvasWidth, canvasHeight) {
4311
+ if (!anchor) {
4312
+ return currentBounds;
4313
+ }
4314
+ let { width, height } = currentBounds;
4315
+ if (anchor.maxWidthPercentage && anchor.maxWidthPercentage > 0) {
4316
+ const maxW = canvasWidth * anchor.maxWidthPercentage / 100;
4317
+ if (width > maxW) {
4318
+ width = maxW;
4319
+ }
4320
+ }
4321
+ const point = anchor.anchorPoint || "center";
4322
+ const pctX = (anchor.offsetPercentageX ?? 0) / 100;
4323
+ const pctY = (anchor.offsetPercentageY ?? 0) / 100;
4324
+ const pxX = anchor.pixelOffsetX ?? 0;
4325
+ const pxY = anchor.pixelOffsetY ?? 0;
4326
+ let x = currentBounds.x;
4327
+ let y = currentBounds.y;
4328
+ switch (point) {
4329
+ case "top-left":
4330
+ x = canvasWidth * pctX + pxX;
4331
+ y = canvasHeight * pctY + pxY;
4332
+ break;
4333
+ case "top-center":
4334
+ x = canvasWidth / 2 - width / 2 + canvasWidth * pctX + pxX;
4335
+ y = canvasHeight * pctY + pxY;
4336
+ break;
4337
+ case "top-right":
4338
+ x = canvasWidth - width - canvasWidth * pctX + pxX;
4339
+ y = canvasHeight * pctY + pxY;
4340
+ break;
4341
+ case "middle-left":
4342
+ x = canvasWidth * pctX + pxX;
4343
+ y = canvasHeight / 2 - height / 2 + canvasHeight * pctY + pxY;
4344
+ break;
4345
+ case "center":
4346
+ x = canvasWidth / 2 - width / 2 + canvasWidth * pctX + pxX;
4347
+ y = canvasHeight / 2 - height / 2 + canvasHeight * pctY + pxY;
4348
+ break;
4349
+ case "middle-right":
4350
+ x = canvasWidth - width - canvasWidth * pctX + pxX;
4351
+ y = canvasHeight / 2 - height / 2 + canvasHeight * pctY + pxY;
4352
+ break;
4353
+ case "bottom-left":
4354
+ x = canvasWidth * pctX + pxX;
4355
+ y = canvasHeight - height - canvasHeight * pctY + pxY;
4356
+ break;
4357
+ case "bottom-center":
4358
+ x = canvasWidth / 2 - width / 2 + canvasWidth * pctX + pxX;
4359
+ y = canvasHeight - height - canvasHeight * pctY + pxY;
4360
+ break;
4361
+ case "bottom-right":
4362
+ x = canvasWidth - width - canvasWidth * pctX + pxX;
4363
+ y = canvasHeight - height - canvasHeight * pctY + pxY;
4287
4364
  break;
4288
- }
4289
- }
4290
- const left = sorted[leftIdx];
4291
- const right = sorted[leftIdx + 1];
4292
- const range = right.time - left.time;
4293
- const t = range === 0 ? 0 : (time - left.time) / range;
4294
- const easedT = applyEasing(t, right.easing || "linear");
4295
- return interpolateValue(left.value, right.value, easedT);
4296
- }
4297
- function applyEasing(t, easing) {
4298
- switch (easing) {
4299
- case "linear":
4300
- return t;
4301
- case "ease-in":
4302
- return t * t;
4303
- case "ease-out":
4304
- return t * (2 - t);
4305
- case "ease-in-out":
4306
- return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
4307
- case "ease":
4308
- return t * t * (3 - 2 * t);
4309
- default:
4310
- return t;
4311
- }
4312
- }
4313
- function interpolateValue(from, to, t) {
4314
- if (typeof from === "number" && typeof to === "number") {
4315
- return from + (to - from) * t;
4316
- }
4317
- if (typeof from === "string" && typeof to === "string" && from.startsWith("#") && to.startsWith("#")) {
4318
- return interpolateColor(from, to, t);
4319
- }
4320
- return t < 0.5 ? from : to;
4321
- }
4322
- function interpolateColor(from, to, t) {
4323
- const fromRgb = hexToRgb(from);
4324
- const toRgb = hexToRgb(to);
4325
- if (!fromRgb || !toRgb) {
4326
- return t < 0.5 ? from : to;
4327
- }
4328
- const r = Math.round(fromRgb.r + (toRgb.r - fromRgb.r) * t);
4329
- const g = Math.round(fromRgb.g + (toRgb.g - fromRgb.g) * t);
4330
- const b = Math.round(fromRgb.b + (toRgb.b - fromRgb.b) * t);
4331
- return rgbToHex(r, g, b);
4332
- }
4333
- function hexToRgb(hex) {
4334
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
4335
- return result ? {
4336
- r: parseInt(result[1], 16),
4337
- g: parseInt(result[2], 16),
4338
- b: parseInt(result[3], 16)
4339
- } : null;
4340
- }
4341
- function rgbToHex(r, g, b) {
4342
- return "#" + [r, g, b].map((x) => {
4343
- const hex = x.toString(16);
4344
- return hex.length === 1 ? "0" + hex : hex;
4345
- }).join("");
4346
- }
4347
- function createKeyframed(keyframes) {
4348
- return { keyframes };
4349
- }
4350
- function addKeyframe(value, time, newValue, easing = "ease-in-out") {
4351
- const existing = isKeyframed(value) ? value.keyframes : [{ time: 0, value, easing: "linear" }];
4352
- const existingIndex = existing.findIndex((kf2) => Math.abs(kf2.time - time) < 0.01);
4353
- if (existingIndex >= 0) {
4354
- const updated = [...existing];
4355
- updated[existingIndex] = { time, value: newValue, easing };
4356
- return { keyframes: updated.sort((a, b) => a.time - b.time) };
4357
- }
4358
- return {
4359
- keyframes: [...existing, { time, value: newValue, easing }].sort((a, b) => a.time - b.time)
4360
- };
4361
- }
4362
- function removeTemplateKeyframe(value, time) {
4363
- if (!isKeyframed(value)) {
4364
- return value;
4365
- }
4366
- const filtered = value.keyframes.filter((kf2) => Math.abs(kf2.time - time) >= 0.01);
4367
- if (filtered.length === 0) {
4368
- throw new Error("Cannot remove all keyframes");
4369
- }
4370
- if (filtered.length === 1) {
4371
- return filtered[0].value;
4372
- }
4373
- return { keyframes: filtered };
4374
- }
4375
-
4376
- // src/contracts.ts
4377
- var CANONICAL_SCHEMA_VERSION = 2;
4378
- var CANONICAL_RENDERER_VERSION = "1.3.0";
4379
- function clone(value) {
4380
- return JSON.parse(JSON.stringify(value));
4381
- }
4382
- function stableStringify(value) {
4383
- if (value === null || typeof value !== "object") return JSON.stringify(value);
4384
- if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
4385
- const record = value;
4386
- return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`).join(",")}}`;
4387
- }
4388
- function canonicalContentHash(value) {
4389
- const input = stableStringify(value);
4390
- let hash = 2166136261;
4391
- for (let i = 0; i < input.length; i += 1) {
4392
- hash ^= input.charCodeAt(i);
4393
- hash = Math.imul(hash, 16777619);
4394
- }
4395
- return `fnv1a-${(hash >>> 0).toString(16).padStart(8, "0")}`;
4396
- }
4397
- function stableLayerId(layer, index, counts) {
4398
- if (layer.id && !/^layer-[a-z0-9-]+$/i.test(layer.id)) return layer.id;
4399
- const count = (counts.get(layer.type) ?? 0) + 1;
4400
- counts.set(layer.type, count);
4401
- return count === 1 ? layer.type : `${layer.type}-${count}`;
4402
- }
4403
- function canonicalizeSceneDocument(input) {
4404
- const doc = clone(input);
4405
- const legacyDoc = doc;
4406
- delete legacyDoc.customEngineId;
4407
- delete legacyDoc.engineParams;
4408
- if (doc.legacyConfig) {
4409
- const legacyConfig = doc.legacyConfig;
4410
- for (const key of [
4411
- "customRenderer",
4412
- "inkColor",
4413
- "bristleDensity",
4414
- "bristleSkipRate",
4415
- "dripRate",
4416
- "dripMaxLength",
4417
- "grainDensity",
4418
- "skewX"
4419
- ]) delete legacyConfig[key];
4420
- }
4421
- const idMap = /* @__PURE__ */ new Map();
4422
- const counts = /* @__PURE__ */ new Map();
4423
- const usedIds = /* @__PURE__ */ new Set();
4424
- const effectLayers = doc.effectLayers.filter((layer) => layer.type !== "customEngine").map((layer) => {
4425
- let id = stableLayerId(layer, 0, counts);
4426
- let suffix = 2;
4427
- while (usedIds.has(id)) id = `${id}-${suffix++}`;
4428
- usedIds.add(id);
4429
- const effectiveEnabled = layer.enabled !== false && layer.params.enabled !== false;
4430
- idMap.set(layer.id, id);
4431
- return {
4432
- ...layer,
4433
- id,
4434
- enabled: effectiveEnabled,
4435
- opacity: Number.isFinite(layer.opacity) ? layer.opacity : 1,
4436
- params: { ...layer.params, enabled: effectiveEnabled }
4437
- };
4438
- });
4439
- const timeline = {
4440
- ...doc.timeline,
4441
- tracks: doc.timeline.tracks.map((track) => ({
4442
- ...track,
4443
- layerId: idMap.get(track.layerId) ?? track.layerId
4444
- }))
4445
- };
4446
- return {
4447
- ...doc,
4448
- schemaVersion: SCENE_SCHEMA_VERSION,
4449
- effectLayers,
4450
- timeline
4451
- };
4452
- }
4453
- function effectDefinitionToConfig(input) {
4454
- const raw = input;
4455
- const fontSize = Number(raw.fontSize ?? 100);
4456
- return {
4457
- ..._buildConfig(
4458
- input,
4459
- raw.text ?? "CLYPRA",
4460
- fontSize,
4461
- Number(raw.canvasWidth ?? 800),
4462
- Number(raw.canvasHeight ?? 200)
4463
- ),
4464
- effectName: input.name,
4465
- textPosX: "center",
4466
- textPosY: "middle"
4467
- };
4468
- }
4469
- function normalizeTextEffect(input, metadata) {
4470
- if (!input || typeof input !== "object") throw new Error("Invalid text effect document");
4471
- const raw = input;
4472
- const scene = Array.isArray(raw.effectLayers) ? canonicalizeSceneDocument(raw) : canonicalizeSceneDocument(
4473
- textEffectConfigToScene(
4474
- raw.font && Array.isArray(raw.fills) ? effectDefinitionToConfig(raw) : raw
4475
- )
4476
- );
4477
- const content = { ...scene, revision: void 0 };
4478
- if (metadata?.assetId) {
4479
- scene.revision = {
4480
- assetId: metadata.assetId,
4481
- revisionId: metadata.revisionId ?? "draft",
4482
- schemaVersion: CANONICAL_SCHEMA_VERSION,
4483
- contentHash: metadata.contentHash ?? canonicalContentHash(content),
4484
- rendererVersion: metadata.rendererVersion ?? CANONICAL_RENDERER_VERSION,
4485
- createdAt: metadata.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
4486
- };
4487
- }
4488
- return scene;
4489
- }
4490
- function normalizeTemplateLayer(layer, index) {
4491
- const normalized = clone(layer);
4492
- normalized.id = normalized.id || `${normalized.kind}-${index + 1}`;
4493
- if (normalized.kind === "text") {
4494
- const text = normalized;
4495
- if (!text.styleRef && text.styleDefinition) {
4496
- const snapshot = normalizeTextEffect(text.styleDefinition, { assetId: text.styleId ?? "legacy-effect" });
4497
- text.styleRef = {
4498
- effectId: text.styleId ?? snapshot.effectName,
4499
- revisionId: String(text.styleVersion ?? "legacy"),
4500
- contentHash: canonicalContentHash({ ...snapshot, revision: void 0 }),
4501
- snapshot
4502
- };
4503
- }
4504
- }
4505
- return normalized;
4506
- }
4507
- function normalizeTemplateElement(element, index) {
4508
- const animation = element.animation ?? {
4509
- in: "none",
4510
- out: "none",
4511
- inDuration: 0,
4512
- outDuration: 0,
4513
- hold: "full"
4514
- };
4515
- const base = {
4516
- id: element.id || `${element.kind}-${index + 1}`,
4517
- x: element.x ?? element.relativePosition?.x ?? 0,
4518
- y: element.y ?? element.relativePosition?.y ?? 0,
4519
- width: element.width ?? "auto",
4520
- height: element.height ?? "auto",
4521
- animation
4522
- };
4523
- if (element.kind === "text") {
4524
- const props2 = element.textProperties ?? element;
4525
- return {
4526
- kind: "text",
4527
- ...base,
4528
- content: props2.text ?? props2.content ?? "Text",
4529
- fontFamily: props2.fontFamily ?? "Inter Variable",
4530
- fontSize: props2.fontSize ?? 48,
4531
- fontWeight: props2.fontWeight ?? 400,
4532
- color: props2.color ?? "#FFFFFF",
4533
- align: props2.align ?? "center",
4534
- role: props2.role ?? "none",
4535
- verticalAlign: props2.verticalAlign ?? "middle",
4536
- styleRef: props2.styleRef
4537
- };
4538
- }
4539
- if (element.kind === "solid" || element.kind === "shape") {
4540
- const props2 = element.solidProperties ?? element;
4541
- return {
4542
- kind: "shape",
4543
- ...base,
4544
- shape: props2.shape ?? "rect",
4545
- fill: props2.color ?? props2.fill ?? "#000000",
4546
- opacity: props2.opacity ?? 1
4547
- };
4548
- }
4549
- const props = element.imageProperties ?? element;
4550
- return {
4551
- kind: "image",
4552
- ...base,
4553
- url: props.url ?? "",
4554
- opacity: props.opacity ?? 1
4555
- };
4556
- }
4557
- function normalizeTextTemplate(input, metadata) {
4558
- if (!input || typeof input !== "object") throw new Error("Invalid text template document");
4559
- const raw = input;
4560
- const sourceLayers = Array.isArray(raw.layers) ? raw.layers : Array.isArray(raw.elements) ? raw.elements.map(normalizeTemplateElement) : [];
4561
- const layers = sourceLayers.map(normalizeTemplateLayer);
4562
- const dependencies = layers.map((layer) => layer.kind === "text" ? layer.styleRef : void 0).filter((ref) => !!ref).filter((ref, index, all) => all.findIndex((other) => other.effectId === ref.effectId && other.revisionId === ref.revisionId) === index);
4563
- const document2 = {
4564
- schemaVersion: CANONICAL_SCHEMA_VERSION,
4565
- id: String(raw.id),
4566
- label: String(raw.label ?? raw.name ?? raw.displayName ?? raw.id),
4567
- category: raw.category ?? "title-card",
4568
- description: String(raw.description ?? ""),
4569
- tags: Array.isArray(raw.tags) ? raw.tags.map(String) : [],
4570
- duration: Number(raw.duration ?? raw.defaultDuration ?? 4),
4571
- fps: Number(raw.fps ?? 30),
4572
- canvasWidth: Number(raw.canvasWidth ?? raw.width ?? 1920),
4573
- canvasHeight: Number(raw.canvasHeight ?? raw.height ?? 1080),
4574
- layers,
4575
- dependencies,
4576
- thumbnail: raw.thumbnail ?? raw.thumbnailUrl,
4577
- preview: raw.preview ?? raw.previewVideoUrl,
4578
- published: raw.published,
4579
- creatorName: raw.creatorName,
4580
- creatorLink: raw.creatorLink
4581
- };
4582
- if (!document2.id || !Number.isFinite(document2.duration) || document2.duration <= 0) {
4583
- throw new Error("Text template must have a valid id and positive duration");
4584
- }
4585
- if (metadata?.assetId) {
4586
- document2.revision = {
4587
- assetId: metadata.assetId,
4588
- revisionId: metadata.revisionId ?? "draft",
4589
- schemaVersion: CANONICAL_SCHEMA_VERSION,
4590
- contentHash: metadata.contentHash ?? canonicalContentHash({ ...document2, revision: void 0 }),
4591
- rendererVersion: metadata.rendererVersion ?? CANONICAL_RENDERER_VERSION,
4592
- createdAt: metadata.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
4593
- };
4594
4365
  }
4595
- return document2;
4596
- }
4597
- function activeEffectDiagnostics(scene) {
4598
- const config = sceneToConfig(scene);
4599
- const glowLayers = scene.effectLayers.filter((layer) => layer.type === "glow");
4600
- return scene.effectLayers.map((layer) => {
4601
- const glowIndex = glowLayers.indexOf(layer);
4602
- const semanticEnabled = (() => {
4603
- switch (layer.type) {
4604
- case "panel":
4605
- return config.panelEnabled;
4606
- case "glow":
4607
- return config.glowLayers[glowIndex]?.enabled === true;
4608
- case "shadow":
4609
- return config.shadowEnabled;
4610
- case "extrusion":
4611
- return config.bevelEnabled;
4612
- case "duplicateStack":
4613
- return config.stackEnabled;
4614
- case "stroke":
4615
- return config.strokeEnabled;
4616
- case "fill":
4617
- return config.fillType !== "none";
4618
- default:
4619
- return true;
4620
- }
4621
- })();
4622
- const contributes = layer.enabled === true && layer.opacity > 0 && layer.params.enabled !== false && semanticEnabled === true;
4623
- return {
4624
- layerId: layer.id,
4625
- layerType: layer.type,
4626
- enabled: contributes,
4627
- contribution: contributes ? "active" : "disabled",
4628
- reason: contributes ? `${layer.name} is enabled` : `${layer.name} is explicitly disabled`
4629
- };
4630
- });
4631
- }
4632
- function capabilities(target, unsupportedFeatures = []) {
4633
- const status = unsupportedFeatures.length > 0 ? target === "native" ? "rasterized" : "unsupported" : "exact";
4634
- return { target, status, unsupportedFeatures, approximations: [] };
4635
- }
4636
- function evaluateTextEffect(document2, time = 0, _overrides = {}) {
4637
- const scene = normalizeTextEffect(document2);
4638
- const evaluated = canonicalizeSceneDocument(applyTimelineAtTime(scene, time));
4639
- const diagnostics = activeEffectDiagnostics(evaluated);
4640
- const unsupported = [];
4641
- return {
4642
- kind: "text-effect",
4643
- width: evaluated.canvas.width,
4644
- height: evaluated.canvas.height,
4645
- duration: evaluated.timeline.duration,
4646
- time,
4647
- effect: evaluated,
4648
- diagnostics,
4649
- capabilities: {
4650
- canvas2d: capabilities("canvas2d"),
4651
- native: capabilities("native", unsupported),
4652
- export: capabilities("export", unsupported)
4653
- }
4654
- };
4655
- }
4656
- function evaluateTextTemplate(document2, time = 0, overrides = {}) {
4657
- const template = normalizeTextTemplate(document2);
4658
- const diagnostics = template.layers.map((layer) => {
4659
- const enabled = evaluateAnimatable(layer.opacity ?? 1, time, template.duration) > 0;
4660
- return {
4661
- layerId: layer.id,
4662
- layerType: layer.kind,
4663
- enabled,
4664
- contribution: enabled ? "active" : "disabled",
4665
- reason: enabled ? `${layer.kind} layer contributes at ${time.toFixed(3)}s` : "Layer opacity is zero"
4666
- };
4667
- });
4668
- void overrides;
4669
- return {
4670
- kind: "text-template",
4671
- width: template.canvasWidth,
4672
- height: template.canvasHeight,
4673
- duration: template.duration,
4674
- time,
4675
- template,
4676
- diagnostics,
4677
- capabilities: {
4678
- canvas2d: capabilities("canvas2d"),
4679
- native: capabilities("native"),
4680
- export: capabilities("export")
4681
- }
4682
- };
4683
- }
4684
- function getRenderCapabilities(plan, target) {
4685
- return plan.capabilities[target];
4366
+ return { x, y, width, height };
4686
4367
  }
4368
+ var ASPECT_RATIO_PRESETS = {
4369
+ "16:9": { width: 1920, height: 1080, label: "16:9 Widescreen (1920x1080)" },
4370
+ "9:16": { width: 1080, height: 1920, label: "9:16 Vertical (1080x1920)" },
4371
+ "1:1": { width: 1080, height: 1080, label: "1:1 Square (1080x1080)" },
4372
+ "4:5": { width: 1080, height: 1350, label: "4:5 Social (1080x1350)" }
4373
+ };
4687
4374
 
4688
4375
  // src/templates/TemplateRenderer.ts
4689
- function cubicBezier(x1, y1, x2, y2) {
4690
- return function(t) {
4691
- if (t <= 0) return 0;
4692
- if (t >= 1) return 1;
4693
- let tApprox = t;
4694
- for (let i = 0; i < 8; i++) {
4695
- const x = 3 * (1 - tApprox) * (1 - tApprox) * tApprox * x1 + 3 * (1 - tApprox) * tApprox * tApprox * x2 + tApprox * tApprox * tApprox;
4696
- const slope = 3 * (1 - tApprox) * (1 - tApprox) * x1 + 6 * (1 - tApprox) * tApprox * (x2 - x1) + 3 * tApprox * tApprox * (1 - x2);
4697
- if (Math.abs(slope) < 1e-6) break;
4698
- tApprox -= (x - t) / slope;
4699
- }
4700
- return 3 * (1 - tApprox) * (1 - tApprox) * tApprox * y1 + 3 * (1 - tApprox) * tApprox * tApprox * y2 + tApprox * tApprox * tApprox;
4701
- };
4702
- }
4703
4376
  var TemplateRenderer = class {
4704
4377
  template;
4705
4378
  editedValues;
@@ -4708,6 +4381,7 @@ var TemplateRenderer = class {
4708
4381
  currentTime = 0;
4709
4382
  // Track current time for keyframe evaluation
4710
4383
  lastLayerLayouts = /* @__PURE__ */ new Map();
4384
+ computedFlexLayouts = /* @__PURE__ */ new Map();
4711
4385
  constructor(template) {
4712
4386
  this.template = normalizeTextTemplate(template);
4713
4387
  this.editedValues = /* @__PURE__ */ new Map();
@@ -4718,7 +4392,10 @@ var TemplateRenderer = class {
4718
4392
  }
4719
4393
  updateLayer(layerId, changes) {
4720
4394
  const existing = this.editedValues.get(layerId) ?? {};
4721
- this.editedValues.set(layerId, { ...existing, ...changes });
4395
+ this.editedValues.set(layerId, {
4396
+ ...existing,
4397
+ ...changes
4398
+ });
4722
4399
  }
4723
4400
  getLayerLayout(layerId) {
4724
4401
  return this.lastLayerLayouts.get(layerId) ?? null;
@@ -4737,7 +4414,11 @@ var TemplateRenderer = class {
4737
4414
  evaluateTextDimension(layer, prop) {
4738
4415
  const value = layer[prop];
4739
4416
  if (value === "auto") return "auto";
4740
- return evaluateAnimatable(value, this.currentTime, this.template.duration);
4417
+ return evaluateAnimatable(
4418
+ value,
4419
+ this.currentTime,
4420
+ this.template.duration
4421
+ );
4741
4422
  }
4742
4423
  // Compute animation parameters (transforms, opacity, scale, typewriter, etc.)
4743
4424
  computeTransform(layer, time) {
@@ -4801,12 +4482,47 @@ var TemplateRenderer = class {
4801
4482
  case "typewriter":
4802
4483
  typewriterProgress = p;
4803
4484
  break;
4485
+ case "3d-flip":
4486
+ opacity = p;
4487
+ scale = 0.6 + p * 0.4;
4488
+ y = (1 - p) * 25;
4489
+ break;
4490
+ case "scale-pop":
4491
+ opacity = p;
4492
+ scale = p < 0.7 ? p / 0.7 * 1.15 : 1.15 - (p - 0.7) / 0.3 * 0.15;
4493
+ break;
4494
+ case "track-in":
4495
+ opacity = p;
4496
+ blur = (1 - p) * 8;
4497
+ break;
4498
+ case "wave":
4499
+ opacity = p;
4500
+ y = Math.sin(p * Math.PI) * -15;
4501
+ break;
4502
+ case "glitch":
4503
+ opacity = p > 0.05 ? 1 : 0;
4504
+ x = Math.sin(p * 25) * 6 * (1 - p);
4505
+ break;
4804
4506
  case "none":
4805
4507
  default:
4806
4508
  break;
4807
4509
  }
4808
4510
  return { opacity, x, y, scale, blur, typewriterProgress };
4809
4511
  }
4512
+ /** Resolve dynamic {{variable}} tokens in string content */
4513
+ resolveDynamicContent(rawContent) {
4514
+ if (!rawContent || !rawContent.includes("{{")) return rawContent;
4515
+ const vars = this.template.variables || {};
4516
+ return rawContent.replace(/\{\{([^}]+)\}\}/g, (_, key) => {
4517
+ const trimmed = key.trim();
4518
+ const override = this.template.variableValues?.[trimmed];
4519
+ if (override !== void 0) return String(override);
4520
+ const def = vars[trimmed];
4521
+ if (def && def.defaultValue !== void 0)
4522
+ return String(def.defaultValue);
4523
+ return `{{${trimmed}}}`;
4524
+ });
4525
+ }
4810
4526
  drawFrame(ctx, time, fitToContentOrOpts = false) {
4811
4527
  const fitToContent = typeof fitToContentOrOpts === "boolean" ? fitToContentOrOpts : !!fitToContentOrOpts?.fitToContent;
4812
4528
  const skipClear = typeof fitToContentOrOpts === "object" ? !!fitToContentOrOpts?.skipClear : false;
@@ -4819,15 +4535,26 @@ var TemplateRenderer = class {
4819
4535
  const bounds = this.getContentBounds();
4820
4536
  if (bounds && bounds.width > 0 && bounds.height > 0) {
4821
4537
  if (!skipClear) {
4822
- ctx.clearRect(0, 0, this.template.canvasWidth, this.template.canvasHeight);
4538
+ ctx.clearRect(
4539
+ 0,
4540
+ 0,
4541
+ this.template.canvasWidth,
4542
+ this.template.canvasHeight
4543
+ );
4823
4544
  }
4824
4545
  ctx.save();
4825
4546
  const padding = 0.85;
4826
- const scale = Math.min(this.template.canvasWidth / bounds.width, this.template.canvasHeight / bounds.height) * padding;
4547
+ const scale = Math.min(
4548
+ this.template.canvasWidth / bounds.width,
4549
+ this.template.canvasHeight / bounds.height
4550
+ ) * padding;
4827
4551
  const finalScale = Math.min(3, scale);
4828
4552
  const cx = bounds.x + bounds.width / 2;
4829
4553
  const cy = bounds.y + bounds.height / 2;
4830
- ctx.translate(this.template.canvasWidth / 2, this.template.canvasHeight / 2);
4554
+ ctx.translate(
4555
+ this.template.canvasWidth / 2,
4556
+ this.template.canvasHeight / 2
4557
+ );
4831
4558
  ctx.scale(finalScale, finalScale);
4832
4559
  ctx.translate(-cx, -cy);
4833
4560
  this.drawLayers(ctx, time);
@@ -4836,7 +4563,12 @@ var TemplateRenderer = class {
4836
4563
  }
4837
4564
  }
4838
4565
  if (!skipClear) {
4839
- ctx.clearRect(0, 0, this.template.canvasWidth, this.template.canvasHeight);
4566
+ ctx.clearRect(
4567
+ 0,
4568
+ 0,
4569
+ this.template.canvasWidth,
4570
+ this.template.canvasHeight
4571
+ );
4840
4572
  }
4841
4573
  this.drawLayers(ctx, time);
4842
4574
  }
@@ -4849,6 +4581,7 @@ var TemplateRenderer = class {
4849
4581
  let hasTextLayers = false;
4850
4582
  for (const [layerId, layout] of this.lastLayerLayouts.entries()) {
4851
4583
  const layer = this.template?.layers?.find((l) => l.id === layerId);
4584
+ if (layer && layer.visible === false) continue;
4852
4585
  if (layer && layer.kind === "text") {
4853
4586
  hasTextLayers = true;
4854
4587
  minX = Math.min(minX, layout.x);
@@ -4873,28 +4606,449 @@ var TemplateRenderer = class {
4873
4606
  height: maxY - minY
4874
4607
  };
4875
4608
  }
4609
+ computeFlexLayouts(time) {
4610
+ this.computedFlexLayouts.clear();
4611
+ if (!this.template || !Array.isArray(this.template.layers)) return;
4612
+ const layers = this.template.layers.map((l) => this.resolveLayer(l));
4613
+ const containers = layers.filter(
4614
+ (l) => l.kind === "container"
4615
+ );
4616
+ if (containers.length === 0) return;
4617
+ const measuredBounds = /* @__PURE__ */ new Map();
4618
+ for (const layer of layers) {
4619
+ if (layer.kind === "text") {
4620
+ const textLayer = layer;
4621
+ const rawW = this.evaluateTextDimension(textLayer, "width");
4622
+ const rawH = this.evaluateTextDimension(textLayer, "height");
4623
+ const fontSize = Number(
4624
+ evaluateAnimatable(
4625
+ textLayer.fontSize,
4626
+ this.currentTime,
4627
+ this.template.duration
4628
+ )
4629
+ ) || 48;
4630
+ const fontWeight = evaluateAnimatable(
4631
+ textLayer.fontWeight,
4632
+ this.currentTime,
4633
+ this.template.duration
4634
+ ) || 400;
4635
+ const rawFontFamily = textLayer.fontFamily || "Space Grotesk";
4636
+ const fontFamily = resolveFontFamilyName(rawFontFamily);
4637
+ const legacyPad = Number(
4638
+ evaluateAnimatable(
4639
+ textLayer.padding ?? 0,
4640
+ this.currentTime,
4641
+ this.template.duration
4642
+ )
4643
+ ) || 0;
4644
+ const padL = Number(
4645
+ evaluateAnimatable(
4646
+ textLayer.paddingLeft ?? legacyPad,
4647
+ this.currentTime,
4648
+ this.template.duration
4649
+ )
4650
+ ) || 0;
4651
+ const padR = Number(
4652
+ evaluateAnimatable(
4653
+ textLayer.paddingRight ?? legacyPad,
4654
+ this.currentTime,
4655
+ this.template.duration
4656
+ )
4657
+ ) || 0;
4658
+ const padT = Number(
4659
+ evaluateAnimatable(
4660
+ textLayer.paddingTop ?? legacyPad,
4661
+ this.currentTime,
4662
+ this.template.duration
4663
+ )
4664
+ ) || 0;
4665
+ const padB = Number(
4666
+ evaluateAnimatable(
4667
+ textLayer.paddingBottom ?? legacyPad,
4668
+ this.currentTime,
4669
+ this.template.duration
4670
+ )
4671
+ ) || 0;
4672
+ const text = this.resolveDynamicContent(textLayer.content || "");
4673
+ const lines = text.split("\n");
4674
+ let textW = 0;
4675
+ if (typeof document !== "undefined") {
4676
+ const mCanvas = document.createElement("canvas");
4677
+ const mCtx = mCanvas.getContext("2d");
4678
+ if (mCtx) {
4679
+ mCtx.font = `${fontWeight} ${fontSize}px "${fontFamily}", "${rawFontFamily}", sans-serif`;
4680
+ textW = Math.max(
4681
+ ...lines.map((l) => mCtx.measureText(l || "Ag").width),
4682
+ 20
4683
+ );
4684
+ }
4685
+ }
4686
+ if (!textW) {
4687
+ const charFactor = Number(fontWeight) >= 600 ? 0.72 : 0.65;
4688
+ textW = Math.max(
4689
+ ...lines.map((l) => l.length * fontSize * charFactor),
4690
+ 20
4691
+ );
4692
+ }
4693
+ const lineHeightMultiplier = Number(
4694
+ evaluateAnimatable(
4695
+ textLayer.lineHeight,
4696
+ this.currentTime,
4697
+ this.template.duration
4698
+ )
4699
+ ) || 1.25;
4700
+ const lineAdvance = fontSize * lineHeightMultiplier;
4701
+ const textH = lines.length === 1 ? fontSize * 1.2 : fontSize * 1 + (lines.length - 1) * lineAdvance;
4702
+ const isAutoOrBox = rawW === "auto" || textLayer.overflow === "expand-panel" || textLayer.backgroundColor !== void 0 && textLayer.backgroundColor !== null;
4703
+ const w = isAutoOrBox ? textW + padL + padR : Number(rawW);
4704
+ const h = rawH === "auto" ? textH + padT + padB : Number(rawH);
4705
+ measuredBounds.set(layer.id, { width: w, height: h });
4706
+ } else if (layer.kind === "shape" || layer.kind === "image") {
4707
+ const w = Number(
4708
+ evaluateAnimatable(
4709
+ layer.width,
4710
+ this.currentTime,
4711
+ this.template.duration
4712
+ )
4713
+ ) || 100;
4714
+ const h = Number(
4715
+ evaluateAnimatable(
4716
+ layer.height,
4717
+ this.currentTime,
4718
+ this.template.duration
4719
+ )
4720
+ ) || 100;
4721
+ measuredBounds.set(layer.id, { width: w, height: h });
4722
+ }
4723
+ }
4724
+ for (const container of containers) {
4725
+ const children = layers.filter(
4726
+ (l) => l.parentId === container.id && l.visible !== false
4727
+ );
4728
+ const layout = container.layout || {
4729
+ type: "flex",
4730
+ direction: "column",
4731
+ gap: 0,
4732
+ alignItems: "start",
4733
+ justifyContent: "start"
4734
+ };
4735
+ const direction = layout.direction || "column";
4736
+ const gap = Number(
4737
+ evaluateAnimatable(
4738
+ layout.gap,
4739
+ this.currentTime,
4740
+ this.template.duration
4741
+ )
4742
+ ) || 0;
4743
+ const padTop = Number(
4744
+ evaluateAnimatable(
4745
+ layout.paddingTop,
4746
+ this.currentTime,
4747
+ this.template.duration
4748
+ )
4749
+ ) || 0;
4750
+ const padRight = Number(
4751
+ evaluateAnimatable(
4752
+ layout.paddingRight,
4753
+ this.currentTime,
4754
+ this.template.duration
4755
+ )
4756
+ ) || 0;
4757
+ const padBottom = Number(
4758
+ evaluateAnimatable(
4759
+ layout.paddingBottom,
4760
+ this.currentTime,
4761
+ this.template.duration
4762
+ )
4763
+ ) || 0;
4764
+ const padLeft = Number(
4765
+ evaluateAnimatable(
4766
+ layout.paddingLeft,
4767
+ this.currentTime,
4768
+ this.template.duration
4769
+ )
4770
+ ) || 0;
4771
+ const alignItems = layout.alignItems || "center";
4772
+ const containerX = Number(
4773
+ evaluateAnimatable(
4774
+ container.x,
4775
+ this.currentTime,
4776
+ this.template.duration
4777
+ )
4778
+ ) || 0;
4779
+ const containerY = Number(
4780
+ evaluateAnimatable(
4781
+ container.y,
4782
+ this.currentTime,
4783
+ this.template.duration
4784
+ )
4785
+ ) || 0;
4786
+ if (direction === "column") {
4787
+ let totalChildHeight = 0;
4788
+ let maxChildWidth = 0;
4789
+ const childSizes = [];
4790
+ for (const child of children) {
4791
+ const sz = measuredBounds.get(child.id) || { width: 100, height: 50 };
4792
+ childSizes.push({ id: child.id, width: sz.width, height: sz.height });
4793
+ totalChildHeight += sz.height;
4794
+ maxChildWidth = Math.max(maxChildWidth, sz.width);
4795
+ }
4796
+ if (children.length > 1) {
4797
+ totalChildHeight += (children.length - 1) * gap;
4798
+ }
4799
+ const rawContainerW = container.width;
4800
+ const rawContainerH = container.height;
4801
+ const declaredW = rawContainerW === "auto" || !rawContainerW ? 0 : Number(
4802
+ evaluateAnimatable(
4803
+ rawContainerW,
4804
+ this.currentTime,
4805
+ this.template.duration
4806
+ )
4807
+ ) || 0;
4808
+ const declaredH = rawContainerH === "auto" || !rawContainerH ? 0 : Number(
4809
+ evaluateAnimatable(
4810
+ rawContainerH,
4811
+ this.currentTime,
4812
+ this.template.duration
4813
+ )
4814
+ ) || 0;
4815
+ const containerW = Math.max(
4816
+ declaredW,
4817
+ maxChildWidth + padLeft + padRight
4818
+ );
4819
+ const containerH = Math.max(
4820
+ declaredH,
4821
+ totalChildHeight + padTop + padBottom
4822
+ );
4823
+ this.computedFlexLayouts.set(container.id, {
4824
+ x: containerX,
4825
+ y: containerY,
4826
+ width: containerW,
4827
+ height: containerH
4828
+ });
4829
+ let currentY = containerY + padTop;
4830
+ const innerW = Math.max(0, containerW - padLeft - padRight);
4831
+ for (const child of childSizes) {
4832
+ let childW = child.width;
4833
+ let childX = containerX + padLeft;
4834
+ if (alignItems === "center") {
4835
+ childX = containerX + padLeft + (innerW - childW) / 2;
4836
+ } else if (alignItems === "end") {
4837
+ childX = containerX + padLeft + (innerW - childW);
4838
+ } else if (alignItems === "stretch") {
4839
+ childW = innerW;
4840
+ }
4841
+ this.computedFlexLayouts.set(child.id, {
4842
+ x: childX,
4843
+ y: currentY,
4844
+ width: childW,
4845
+ height: child.height
4846
+ });
4847
+ currentY += child.height + gap;
4848
+ }
4849
+ } else {
4850
+ let totalChildWidth = 0;
4851
+ let maxChildHeight = 0;
4852
+ const childSizes = [];
4853
+ for (const child of children) {
4854
+ const sz = measuredBounds.get(child.id) || { width: 100, height: 50 };
4855
+ childSizes.push({ id: child.id, width: sz.width, height: sz.height });
4856
+ totalChildWidth += sz.width;
4857
+ maxChildHeight = Math.max(maxChildHeight, sz.height);
4858
+ }
4859
+ if (children.length > 1) {
4860
+ totalChildWidth += (children.length - 1) * gap;
4861
+ }
4862
+ const rawContainerW = container.width;
4863
+ const rawContainerH = container.height;
4864
+ const declaredW = rawContainerW === "auto" || !rawContainerW ? 0 : Number(
4865
+ evaluateAnimatable(
4866
+ rawContainerW,
4867
+ this.currentTime,
4868
+ this.template.duration
4869
+ )
4870
+ ) || 0;
4871
+ const declaredH = rawContainerH === "auto" || !rawContainerH ? 0 : Number(
4872
+ evaluateAnimatable(
4873
+ rawContainerH,
4874
+ this.currentTime,
4875
+ this.template.duration
4876
+ )
4877
+ ) || 0;
4878
+ const containerW = Math.max(
4879
+ declaredW,
4880
+ totalChildWidth + padLeft + padRight
4881
+ );
4882
+ const containerH = Math.max(
4883
+ declaredH,
4884
+ maxChildHeight + padTop + padBottom
4885
+ );
4886
+ this.computedFlexLayouts.set(container.id, {
4887
+ x: containerX,
4888
+ y: containerY,
4889
+ width: containerW,
4890
+ height: containerH
4891
+ });
4892
+ let currentX = containerX + padLeft;
4893
+ const innerH = Math.max(0, containerH - padTop - padBottom);
4894
+ for (const child of childSizes) {
4895
+ let childH = child.height;
4896
+ let childY = containerY + padTop;
4897
+ if (alignItems === "center") {
4898
+ childY = containerY + padTop + (innerH - childH) / 2;
4899
+ } else if (alignItems === "end") {
4900
+ childY = containerY + padTop + (innerH - childH);
4901
+ } else if (alignItems === "stretch") {
4902
+ childH = innerH;
4903
+ }
4904
+ this.computedFlexLayouts.set(child.id, {
4905
+ x: currentX,
4906
+ y: childY,
4907
+ width: child.width,
4908
+ height: childH
4909
+ });
4910
+ currentX += child.width + gap;
4911
+ }
4912
+ }
4913
+ }
4914
+ }
4915
+ drawContainerLayer(ctx, layer) {
4916
+ const resolved = layer;
4917
+ const layout = this.computedFlexLayouts.get(resolved.id);
4918
+ const x = layout?.x ?? (Number(
4919
+ evaluateAnimatable(
4920
+ resolved.x,
4921
+ this.currentTime,
4922
+ this.template.duration
4923
+ )
4924
+ ) || 0);
4925
+ const y = layout?.y ?? (Number(
4926
+ evaluateAnimatable(
4927
+ resolved.y,
4928
+ this.currentTime,
4929
+ this.template.duration
4930
+ )
4931
+ ) || 0);
4932
+ const width = layout?.width ?? (resolved.width === "auto" ? 400 : Number(
4933
+ evaluateAnimatable(
4934
+ resolved.width,
4935
+ this.currentTime,
4936
+ this.template.duration
4937
+ )
4938
+ ) || 400);
4939
+ const height = layout?.height ?? (resolved.height === "auto" ? 200 : Number(
4940
+ evaluateAnimatable(
4941
+ resolved.height,
4942
+ this.currentTime,
4943
+ this.template.duration
4944
+ )
4945
+ ) || 200);
4946
+ this.lastLayerLayouts.set(resolved.id, { x, y, width, height });
4947
+ const bgColor = resolved.backgroundColor ? evaluateAnimatable(
4948
+ resolved.backgroundColor,
4949
+ this.currentTime,
4950
+ this.template.duration
4951
+ ) : null;
4952
+ const bgOpacity = resolved.backgroundOpacity !== void 0 ? Number(
4953
+ evaluateAnimatable(
4954
+ resolved.backgroundOpacity,
4955
+ this.currentTime,
4956
+ this.template.duration
4957
+ )
4958
+ ) : 1;
4959
+ const bgRadius = resolved.backgroundRadius !== void 0 ? Number(
4960
+ evaluateAnimatable(
4961
+ resolved.backgroundRadius,
4962
+ this.currentTime,
4963
+ this.template.duration
4964
+ )
4965
+ ) : 0;
4966
+ const borderColor = resolved.backgroundBorderColor ? evaluateAnimatable(
4967
+ resolved.backgroundBorderColor,
4968
+ this.currentTime,
4969
+ this.template.duration
4970
+ ) : null;
4971
+ const borderWidth = resolved.backgroundBorderWidth !== void 0 ? Number(
4972
+ evaluateAnimatable(
4973
+ resolved.backgroundBorderWidth,
4974
+ this.currentTime,
4975
+ this.template.duration
4976
+ )
4977
+ ) : 0;
4978
+ if (bgColor || borderColor && borderWidth > 0) {
4979
+ const currentAlpha = ctx.globalAlpha;
4980
+ ctx.save();
4981
+ ctx.globalAlpha = currentAlpha * bgOpacity;
4982
+ ctx.beginPath();
4983
+ if (bgRadius > 0) {
4984
+ ctx.moveTo(x + bgRadius, y);
4985
+ ctx.lineTo(x + width - bgRadius, y);
4986
+ ctx.quadraticCurveTo(x + width, y, x + width, y + bgRadius);
4987
+ ctx.lineTo(x + width, y + height - bgRadius);
4988
+ ctx.quadraticCurveTo(
4989
+ x + width,
4990
+ y + height,
4991
+ x + width - bgRadius,
4992
+ y + height
4993
+ );
4994
+ ctx.lineTo(x + bgRadius, y + height);
4995
+ ctx.quadraticCurveTo(x, y + height, x, y + height - bgRadius);
4996
+ ctx.lineTo(x, y + bgRadius);
4997
+ ctx.quadraticCurveTo(x, y, x + bgRadius, y);
4998
+ } else {
4999
+ ctx.rect(x, y, width, height);
5000
+ }
5001
+ ctx.closePath();
5002
+ if (bgColor) {
5003
+ ctx.fillStyle = bgColor;
5004
+ ctx.fill();
5005
+ }
5006
+ if (borderColor && borderWidth > 0) {
5007
+ ctx.strokeStyle = borderColor;
5008
+ ctx.lineWidth = borderWidth;
5009
+ ctx.globalAlpha = currentAlpha;
5010
+ ctx.stroke();
5011
+ }
5012
+ ctx.restore();
5013
+ }
5014
+ }
4876
5015
  drawLayers(ctx, time) {
4877
5016
  if (!this.template || !Array.isArray(this.template.layers)) return;
4878
5017
  this.lastLayerLayouts.clear();
5018
+ this.computeFlexLayouts(time);
4879
5019
  for (const layer of this.template.layers) {
4880
5020
  const resolved = this.resolveLayer(layer);
5021
+ if (resolved.visible === false) continue;
4881
5022
  const transform = this.computeTransform(resolved, time);
4882
- const layerOpacity = resolved.opacity !== void 0 ? evaluateAnimatable(resolved.opacity, this.currentTime, this.template.duration) : 1;
5023
+ const layerOpacity = resolved.opacity !== void 0 ? evaluateAnimatable(
5024
+ resolved.opacity,
5025
+ this.currentTime,
5026
+ this.template.duration
5027
+ ) : 1;
4883
5028
  ctx.save();
4884
5029
  ctx.globalAlpha = transform.opacity * layerOpacity;
4885
- const x = this.evaluateLayerProperty(resolved, "x");
4886
- const y = this.evaluateLayerProperty(resolved, "y");
5030
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5031
+ const x = flexLayout?.x ?? this.evaluateLayerProperty(resolved, "x");
5032
+ const y = flexLayout?.y ?? this.evaluateLayerProperty(resolved, "y");
4887
5033
  let cx;
4888
5034
  let cy;
4889
5035
  if (resolved.kind === "text") {
4890
5036
  const textLayer = resolved;
4891
- const rawW = this.evaluateTextDimension(textLayer, "width");
4892
- const rawH = this.evaluateTextDimension(textLayer, "height");
5037
+ const rawW = flexLayout?.width ?? this.evaluateTextDimension(textLayer, "width");
5038
+ const rawH = flexLayout?.height ?? this.evaluateTextDimension(textLayer, "height");
4893
5039
  cx = rawW === "auto" ? x : x + rawW / 2;
4894
5040
  cy = rawH === "auto" ? y : y + rawH / 2;
4895
5041
  } else {
4896
- const width = evaluateAnimatable(resolved.width, this.currentTime, this.template.duration);
4897
- const height = evaluateAnimatable(resolved.height, this.currentTime, this.template.duration);
5042
+ const width = flexLayout?.width ?? evaluateAnimatable(
5043
+ resolved.width,
5044
+ this.currentTime,
5045
+ this.template.duration
5046
+ );
5047
+ const height = flexLayout?.height ?? evaluateAnimatable(
5048
+ resolved.height,
5049
+ this.currentTime,
5050
+ this.template.duration
5051
+ );
4898
5052
  cx = x + width / 2;
4899
5053
  cy = y + height / 2;
4900
5054
  }
@@ -4905,59 +5059,142 @@ var TemplateRenderer = class {
4905
5059
  ctx.filter = `blur(${transform.blur}px)`;
4906
5060
  }
4907
5061
  if (resolved.kind === "text") {
4908
- this.drawTextLayer(ctx, resolved, transform);
5062
+ this.drawTextLayer(
5063
+ ctx,
5064
+ resolved,
5065
+ transform
5066
+ );
4909
5067
  } else if (resolved.kind === "shape") {
4910
- this.drawShapeLayer(ctx, resolved);
5068
+ this.drawShapeLayer(
5069
+ ctx,
5070
+ resolved
5071
+ );
4911
5072
  } else if (resolved.kind === "image") {
4912
- this.drawImageLayer(ctx, resolved);
5073
+ this.drawImageLayer(
5074
+ ctx,
5075
+ resolved
5076
+ );
5077
+ } else if (resolved.kind === "container") {
5078
+ this.drawContainerLayer(
5079
+ ctx,
5080
+ resolved
5081
+ );
4913
5082
  }
4914
5083
  ctx.restore();
4915
5084
  }
4916
5085
  }
4917
5086
  drawTextLayer(ctx, layer, transform) {
4918
5087
  const resolved = layer;
4919
- const content = resolved.content;
5088
+ const rawContent = resolved.content;
5089
+ const content = this.resolveDynamicContent(rawContent);
4920
5090
  const rawFontFamily = resolved.fontFamily;
4921
5091
  const fontFamily = resolveFontFamilyName(rawFontFamily);
4922
- const fontSize = evaluateAnimatable(resolved.fontSize, this.currentTime, this.template.duration);
4923
- const fontWeight = evaluateAnimatable(resolved.fontWeight, this.currentTime, this.template.duration);
4924
- const color = evaluateAnimatable(resolved.color, this.currentTime, this.template.duration);
5092
+ const fontSize = evaluateAnimatable(
5093
+ resolved.fontSize,
5094
+ this.currentTime,
5095
+ this.template.duration
5096
+ );
5097
+ const fontWeight = evaluateAnimatable(
5098
+ resolved.fontWeight,
5099
+ this.currentTime,
5100
+ this.template.duration
5101
+ );
5102
+ const color = evaluateAnimatable(
5103
+ resolved.color,
5104
+ this.currentTime,
5105
+ this.template.duration
5106
+ );
4925
5107
  const align = resolved.align;
4926
- const x = evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
4927
- const y = evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
4928
- const rawWidth = this.evaluateTextDimension(resolved, "width");
4929
- const rawHeight = this.evaluateTextDimension(resolved, "height");
4930
- const backgroundColor = resolved.backgroundColor ? evaluateAnimatable(resolved.backgroundColor, this.currentTime, this.template.duration) : null;
4931
- const backgroundOpacity = resolved.backgroundOpacity !== void 0 ? evaluateAnimatable(resolved.backgroundOpacity, this.currentTime, this.template.duration) : 1;
4932
- const backgroundRadius = resolved.backgroundRadius !== void 0 ? evaluateAnimatable(resolved.backgroundRadius, this.currentTime, this.template.duration) : 0;
4933
- const backgroundBorderColor = resolved.backgroundBorderColor ? evaluateAnimatable(resolved.backgroundBorderColor, this.currentTime, this.template.duration) : null;
4934
- const backgroundBorderWidth = resolved.backgroundBorderWidth !== void 0 ? evaluateAnimatable(resolved.backgroundBorderWidth, this.currentTime, this.template.duration) : 0;
4935
- const legacyPadding = resolved.padding !== void 0 ? evaluateAnimatable(resolved.padding, this.currentTime, this.template.duration) : 0;
4936
- const pt = resolved.paddingTop !== void 0 ? evaluateAnimatable(resolved.paddingTop, this.currentTime, this.template.duration) : legacyPadding;
4937
- const pr = resolved.paddingRight !== void 0 ? evaluateAnimatable(resolved.paddingRight, this.currentTime, this.template.duration) : legacyPadding;
4938
- const pb = resolved.paddingBottom !== void 0 ? evaluateAnimatable(resolved.paddingBottom, this.currentTime, this.template.duration) : legacyPadding;
4939
- const pl = resolved.paddingLeft !== void 0 ? evaluateAnimatable(resolved.paddingLeft, this.currentTime, this.template.duration) : legacyPadding;
5108
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5109
+ const x = flexLayout?.x ?? evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5110
+ const y = flexLayout?.y ?? evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5111
+ const rawWidth = flexLayout?.width ?? this.evaluateTextDimension(resolved, "width");
5112
+ const rawHeight = flexLayout?.height ?? this.evaluateTextDimension(resolved, "height");
5113
+ const backgroundColor = resolved.backgroundColor ? evaluateAnimatable(
5114
+ resolved.backgroundColor,
5115
+ this.currentTime,
5116
+ this.template.duration
5117
+ ) : null;
5118
+ const backgroundOpacity = resolved.backgroundOpacity !== void 0 ? evaluateAnimatable(
5119
+ resolved.backgroundOpacity,
5120
+ this.currentTime,
5121
+ this.template.duration
5122
+ ) : 1;
5123
+ const backgroundRadius = resolved.backgroundRadius !== void 0 ? evaluateAnimatable(
5124
+ resolved.backgroundRadius,
5125
+ this.currentTime,
5126
+ this.template.duration
5127
+ ) : 0;
5128
+ const backgroundBorderColor = resolved.backgroundBorderColor ? evaluateAnimatable(
5129
+ resolved.backgroundBorderColor,
5130
+ this.currentTime,
5131
+ this.template.duration
5132
+ ) : null;
5133
+ const backgroundBorderWidth = resolved.backgroundBorderWidth !== void 0 ? evaluateAnimatable(
5134
+ resolved.backgroundBorderWidth,
5135
+ this.currentTime,
5136
+ this.template.duration
5137
+ ) : 0;
5138
+ const legacyPadding = resolved.padding !== void 0 ? evaluateAnimatable(
5139
+ resolved.padding,
5140
+ this.currentTime,
5141
+ this.template.duration
5142
+ ) : 0;
5143
+ const pt = resolved.paddingTop !== void 0 ? evaluateAnimatable(
5144
+ resolved.paddingTop,
5145
+ this.currentTime,
5146
+ this.template.duration
5147
+ ) : legacyPadding;
5148
+ const pr = resolved.paddingRight !== void 0 ? evaluateAnimatable(
5149
+ resolved.paddingRight,
5150
+ this.currentTime,
5151
+ this.template.duration
5152
+ ) : legacyPadding;
5153
+ const pb = resolved.paddingBottom !== void 0 ? evaluateAnimatable(
5154
+ resolved.paddingBottom,
5155
+ this.currentTime,
5156
+ this.template.duration
5157
+ ) : legacyPadding;
5158
+ const pl = resolved.paddingLeft !== void 0 ? evaluateAnimatable(
5159
+ resolved.paddingLeft,
5160
+ this.currentTime,
5161
+ this.template.duration
5162
+ ) : legacyPadding;
4940
5163
  const overflow = resolved.overflow;
4941
5164
  const verticalAlign = resolved.verticalAlign || "middle";
4942
- const visibleCharsCount = Math.floor(transform.typewriterProgress * content.length);
5165
+ const visibleCharsCount = Math.floor(
5166
+ transform.typewriterProgress * content.length
5167
+ );
4943
5168
  const textToDraw = content.slice(0, visibleCharsCount);
4944
5169
  ctx.save();
4945
5170
  ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", "${rawFontFamily}", sans-serif`;
4946
5171
  ctx.textBaseline = "alphabetic";
4947
5172
  ctx.textAlign = align;
4948
5173
  let adjustedFontSize = fontSize;
4949
- let lines = [textToDraw];
5174
+ const lineHeightMultiplier = Number(
5175
+ evaluateAnimatable(
5176
+ resolved.lineHeight,
5177
+ this.currentTime,
5178
+ this.template.duration
5179
+ )
5180
+ ) || 1.25;
5181
+ const rawLines = textToDraw.split("\n");
5182
+ let lines = rawLines;
5183
+ const maxLineTextWidth = Math.max(
5184
+ ...rawLines.map((l) => ctx.measureText(l || "Ag").width),
5185
+ 20
5186
+ );
4950
5187
  let resolvedWidth;
4951
- if (rawWidth === "auto") {
4952
- const measured = ctx.measureText(textToDraw || "Ag").width;
4953
- resolvedWidth = measured + pl + pr;
5188
+ if (rawWidth === "auto" || overflow === "expand-panel" || backgroundColor && !rawWidth) {
5189
+ resolvedWidth = maxLineTextWidth + pl + pr;
5190
+ } else if (flexLayout) {
5191
+ resolvedWidth = overflow === "shrink" || overflow === "wrap" ? flexLayout.width : Math.max(flexLayout.width, maxLineTextWidth + pl + pr);
4954
5192
  } else {
4955
5193
  resolvedWidth = rawWidth;
4956
5194
  }
4957
5195
  const contentW = Math.max(0, resolvedWidth - pl - pr);
4958
5196
  if (overflow === "shrink") {
4959
- const measuredWidth = ctx.measureText(textToDraw).width;
4960
- let scale = measuredWidth > contentW && contentW > 0 ? contentW / measuredWidth : 1;
5197
+ let scale = maxLineTextWidth > contentW && contentW > 0 ? contentW / maxLineTextWidth : 1;
4961
5198
  if (rawHeight !== "auto") {
4962
5199
  const declaredContentH = Math.max(0, rawHeight - pt - pb);
4963
5200
  const singleLineH = fontSize * 1;
@@ -4969,20 +5206,22 @@ var TemplateRenderer = class {
4969
5206
  adjustedFontSize = fontSize * scale;
4970
5207
  ctx.font = `${fontWeight} ${adjustedFontSize}px "${fontFamily}", "${rawFontFamily}", sans-serif`;
4971
5208
  }
4972
- } else if (overflow === "wrap") {
4973
- lines = wrapTextToWidth(ctx, textToDraw, contentW, 0);
5209
+ } else if (overflow === "wrap" && contentW > 0) {
5210
+ lines = [];
5211
+ for (const rLine of rawLines) {
5212
+ lines.push(...wrapTextToWidth(ctx, rLine, contentW, 0));
5213
+ }
4974
5214
  } else if (overflow === "expand-panel") {
4975
- const measuredWidth = ctx.measureText(textToDraw).width;
4976
- resolvedWidth = measuredWidth + pl + pr;
5215
+ resolvedWidth = maxLineTextWidth + pl + pr;
4977
5216
  }
5217
+ const lineAdvance = adjustedFontSize * lineHeightMultiplier;
5218
+ const sampleMetrics = ctx.measureText(lines[0] || "Ag");
5219
+ const ascent = sampleMetrics.actualBoundingBoxAscent ?? adjustedFontSize * 0.8;
5220
+ const descent = sampleMetrics.actualBoundingBoxDescent ?? adjustedFontSize * 0.2;
5221
+ const inkLineH = ascent + descent;
5222
+ const totalInkH = lines.length === 1 ? inkLineH : inkLineH + (lines.length - 1) * lineAdvance;
4978
5223
  let resolvedHeight;
4979
5224
  if (rawHeight === "auto") {
4980
- const sampleMetrics2 = ctx.measureText(lines[0] || "Ag");
4981
- const ascent2 = sampleMetrics2.actualBoundingBoxAscent ?? adjustedFontSize * 0.8;
4982
- const descent2 = sampleMetrics2.actualBoundingBoxDescent ?? adjustedFontSize * 0.2;
4983
- const inkLineH2 = ascent2 + descent2;
4984
- const lineAdvance = adjustedFontSize * 1.2;
4985
- const totalInkH = lines.length === 1 ? inkLineH2 : inkLineH2 + (lines.length - 1) * lineAdvance;
4986
5225
  resolvedHeight = totalInkH + pt + pb;
4987
5226
  } else {
4988
5227
  resolvedHeight = rawHeight;
@@ -5000,10 +5239,30 @@ var TemplateRenderer = class {
5000
5239
  bgX = x;
5001
5240
  }
5002
5241
  }
5003
- this.lastLayerLayouts.set(resolved.id, { x: bgX, y: bgY, width: bgWidth, height: bgHeight });
5242
+ if (resolved.anchor) {
5243
+ const anchored = resolveAnchorPosition(
5244
+ resolved.anchor,
5245
+ { x: bgX, y: bgY, width: bgWidth, height: bgHeight },
5246
+ this.template.canvasWidth,
5247
+ this.template.canvasHeight
5248
+ );
5249
+ bgX = anchored.x;
5250
+ bgY = anchored.y;
5251
+ bgWidth = anchored.width;
5252
+ bgHeight = anchored.height;
5253
+ }
5254
+ this.lastLayerLayouts.set(resolved.id, {
5255
+ x: bgX,
5256
+ y: bgY,
5257
+ width: bgWidth,
5258
+ height: bgHeight
5259
+ });
5004
5260
  const styleRef = resolved.styleRef;
5005
5261
  if (styleRef?.snapshot?.effectLayers) {
5006
- const effectCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(Math.max(1, Math.ceil(bgWidth)), Math.max(1, Math.ceil(bgHeight))) : typeof document !== "undefined" ? Object.assign(document.createElement("canvas"), {
5262
+ const effectCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(
5263
+ Math.max(1, Math.ceil(bgWidth)),
5264
+ Math.max(1, Math.ceil(bgHeight))
5265
+ ) : typeof document !== "undefined" ? Object.assign(document.createElement("canvas"), {
5007
5266
  width: Math.max(1, Math.ceil(bgWidth)),
5008
5267
  height: Math.max(1, Math.ceil(bgHeight))
5009
5268
  }) : null;
@@ -5019,7 +5278,13 @@ var TemplateRenderer = class {
5019
5278
  effectScene.text.textPosX = "center";
5020
5279
  effectScene.text.textPosY = "middle";
5021
5280
  evaluateScene(effectScene, this.currentTime, effectCtx);
5022
- ctx.drawImage(effectCanvas, bgX, bgY, bgWidth, bgHeight);
5281
+ ctx.drawImage(
5282
+ effectCanvas,
5283
+ bgX,
5284
+ bgY,
5285
+ bgWidth,
5286
+ bgHeight
5287
+ );
5023
5288
  ctx.restore();
5024
5289
  return;
5025
5290
  }
@@ -5028,22 +5293,39 @@ var TemplateRenderer = class {
5028
5293
  let contentY = bgY + pt;
5029
5294
  let contentH = Math.max(0, bgHeight - pt - pb);
5030
5295
  ctx.save();
5031
- ctx.beginPath();
5032
- if (backgroundRadius > 0) {
5033
- ctx.moveTo(bgX + backgroundRadius, bgY);
5034
- ctx.lineTo(bgX + bgWidth - backgroundRadius, bgY);
5035
- ctx.quadraticCurveTo(bgX + bgWidth, bgY, bgX + bgWidth, bgY + backgroundRadius);
5036
- ctx.lineTo(bgX + bgWidth, bgY + bgHeight - backgroundRadius);
5037
- ctx.quadraticCurveTo(bgX + bgWidth, bgY + bgHeight, bgX + bgWidth - backgroundRadius, bgY + bgHeight);
5038
- ctx.lineTo(bgX + backgroundRadius, bgY + bgHeight);
5039
- ctx.quadraticCurveTo(bgX, bgY + bgHeight, bgX, bgY + bgHeight - backgroundRadius);
5040
- ctx.lineTo(bgX, bgY + backgroundRadius);
5041
- ctx.quadraticCurveTo(bgX, bgY, bgX + backgroundRadius, bgY);
5042
- } else {
5043
- ctx.rect(bgX, bgY, bgWidth, bgHeight);
5296
+ if (overflow === "clip") {
5297
+ ctx.beginPath();
5298
+ if (backgroundRadius > 0) {
5299
+ ctx.moveTo(bgX + backgroundRadius, bgY);
5300
+ ctx.lineTo(bgX + bgWidth - backgroundRadius, bgY);
5301
+ ctx.quadraticCurveTo(
5302
+ bgX + bgWidth,
5303
+ bgY,
5304
+ bgX + bgWidth,
5305
+ bgY + backgroundRadius
5306
+ );
5307
+ ctx.lineTo(bgX + bgWidth, bgY + bgHeight - backgroundRadius);
5308
+ ctx.quadraticCurveTo(
5309
+ bgX + bgWidth,
5310
+ bgY + bgHeight,
5311
+ bgX + bgWidth - backgroundRadius,
5312
+ bgY + bgHeight
5313
+ );
5314
+ ctx.lineTo(bgX + backgroundRadius, bgY + bgHeight);
5315
+ ctx.quadraticCurveTo(
5316
+ bgX,
5317
+ bgY + bgHeight,
5318
+ bgX,
5319
+ bgY + bgHeight - backgroundRadius
5320
+ );
5321
+ ctx.lineTo(bgX, bgY + backgroundRadius);
5322
+ ctx.quadraticCurveTo(bgX, bgY, bgX + backgroundRadius, bgY);
5323
+ } else {
5324
+ ctx.rect(bgX, bgY, bgWidth, bgHeight);
5325
+ }
5326
+ ctx.closePath();
5327
+ ctx.clip();
5044
5328
  }
5045
- ctx.closePath();
5046
- ctx.clip();
5047
5329
  if (backgroundColor) {
5048
5330
  const currentAlpha = ctx.globalAlpha;
5049
5331
  ctx.save();
@@ -5053,11 +5335,26 @@ var TemplateRenderer = class {
5053
5335
  ctx.beginPath();
5054
5336
  ctx.moveTo(bgX + backgroundRadius, bgY);
5055
5337
  ctx.lineTo(bgX + bgWidth - backgroundRadius, bgY);
5056
- ctx.quadraticCurveTo(bgX + bgWidth, bgY, bgX + bgWidth, bgY + backgroundRadius);
5338
+ ctx.quadraticCurveTo(
5339
+ bgX + bgWidth,
5340
+ bgY,
5341
+ bgX + bgWidth,
5342
+ bgY + backgroundRadius
5343
+ );
5057
5344
  ctx.lineTo(bgX + bgWidth, bgY + bgHeight - backgroundRadius);
5058
- ctx.quadraticCurveTo(bgX + bgWidth, bgY + bgHeight, bgX + bgWidth - backgroundRadius, bgY + bgHeight);
5345
+ ctx.quadraticCurveTo(
5346
+ bgX + bgWidth,
5347
+ bgY + bgHeight,
5348
+ bgX + bgWidth - backgroundRadius,
5349
+ bgY + bgHeight
5350
+ );
5059
5351
  ctx.lineTo(bgX + backgroundRadius, bgY + bgHeight);
5060
- ctx.quadraticCurveTo(bgX, bgY + bgHeight, bgX, bgY + bgHeight - backgroundRadius);
5352
+ ctx.quadraticCurveTo(
5353
+ bgX,
5354
+ bgY + bgHeight,
5355
+ bgX,
5356
+ bgY + bgHeight - backgroundRadius
5357
+ );
5061
5358
  ctx.lineTo(bgX, bgY + backgroundRadius);
5062
5359
  ctx.quadraticCurveTo(bgX, bgY, bgX + backgroundRadius, bgY);
5063
5360
  ctx.closePath();
@@ -5089,13 +5386,93 @@ var TemplateRenderer = class {
5089
5386
  } else {
5090
5387
  drawX = contentX;
5091
5388
  }
5092
- const sampleMetrics = ctx.measureText(lines[0] || "Ag");
5093
- const ascent = sampleMetrics.actualBoundingBoxAscent ?? adjustedFontSize * 0.8;
5094
- const descent = sampleMetrics.actualBoundingBoxDescent ?? adjustedFontSize * 0.2;
5095
- const inkLineH = ascent + descent;
5096
- const lineHeight = adjustedFontSize * 1.2;
5097
- if (overflow === "wrap") {
5098
- const totalInkHeight = inkLineH + (lines.length - 1) * lineHeight;
5389
+ if (resolved.splitAnimator) {
5390
+ const inEnd = resolved.animation.inDuration;
5391
+ const animProgress = inEnd > 0 ? Math.min(1, Math.max(0, this.currentTime / inEnd)) : 1;
5392
+ const splitUnits = splitTextContent(
5393
+ textToDraw,
5394
+ resolved.splitAnimator.splitBy
5395
+ );
5396
+ const computedUnits = evaluateSplitTextTransforms(
5397
+ splitUnits,
5398
+ resolved.splitAnimator,
5399
+ animProgress,
5400
+ "in"
5401
+ );
5402
+ let currentX = drawX;
5403
+ if (align === "center") {
5404
+ const fullW = ctx.measureText(textToDraw).width;
5405
+ currentX = contentX + (contentW - fullW) / 2;
5406
+ } else if (align === "right") {
5407
+ const fullW = ctx.measureText(textToDraw).width;
5408
+ currentX = contentX + contentW - fullW;
5409
+ }
5410
+ const drawY = verticalAlign === "top" ? contentY + ascent : verticalAlign === "bottom" ? contentY + contentH - descent : contentY + (contentH - inkLineH) / 2 + ascent;
5411
+ computedUnits.forEach((item, unitIdx) => {
5412
+ const span = getSpanForCharIndex(
5413
+ resolved.spans,
5414
+ item.unit.charStartIndex
5415
+ );
5416
+ const charColor = resolved.perCharFillEnabled && resolved.charFillColors?.[unitIdx] ? resolved.charFillColors[unitIdx] : span?.color || color;
5417
+ ctx.save();
5418
+ ctx.globalAlpha = ctx.globalAlpha * item.opacity;
5419
+ ctx.fillStyle = charColor;
5420
+ const uW = ctx.measureText(item.unit.text).width;
5421
+ const uCX = currentX + uW / 2 + item.x;
5422
+ const uCY = drawY - ascent / 2 + item.y;
5423
+ ctx.translate(uCX, uCY);
5424
+ ctx.scale(item.scale * item.scaleX, item.scale * item.scaleY);
5425
+ if (item.rotation !== 0) ctx.rotate(item.rotation * Math.PI / 180);
5426
+ ctx.translate(-uCX, -uCY);
5427
+ if (item.blur > 0 && "filter" in ctx) {
5428
+ ctx.filter = `blur(${item.blur}px)`;
5429
+ }
5430
+ ctx.fillText(
5431
+ item.unit.text,
5432
+ currentX + item.x,
5433
+ drawY + item.y + (span?.baselineShift || 0)
5434
+ );
5435
+ ctx.restore();
5436
+ currentX += uW + (item.letterSpacingOffset || 0);
5437
+ });
5438
+ } else if (resolved.spans && resolved.spans.length > 0) {
5439
+ const totalInkHeight = lines.length === 1 ? inkLineH : inkLineH + (lines.length - 1) * lineAdvance;
5440
+ let firstBaselineY = verticalAlign === "top" ? contentY + ascent : verticalAlign === "bottom" ? contentY + contentH - totalInkHeight + ascent : contentY + (contentH - totalInkHeight) / 2 + ascent;
5441
+ let globalCharIndex = 0;
5442
+ ctx.textAlign = "left";
5443
+ lines.forEach((line, lineIndex) => {
5444
+ let curX = contentX;
5445
+ if (align === "center") {
5446
+ const lW = ctx.measureText(line).width;
5447
+ curX = contentX + (contentW - lW) / 2;
5448
+ } else if (align === "right") {
5449
+ const lW = ctx.measureText(line).width;
5450
+ curX = contentX + contentW - lW;
5451
+ }
5452
+ const chars = Array.from(line);
5453
+ chars.forEach((ch) => {
5454
+ const span = getSpanForCharIndex(resolved.spans, globalCharIndex);
5455
+ const chColor = resolved.perCharFillEnabled && resolved.charFillColors?.[globalCharIndex] ? resolved.charFillColors[globalCharIndex] : span?.color || color;
5456
+ ctx.save();
5457
+ if (span?.fontFamily || span?.fontWeight || span?.fontSize) {
5458
+ ctx.font = `${span.fontWeight || fontWeight} ${span.fontSize || adjustedFontSize}px "${resolveFontFamilyName(
5459
+ span.fontFamily || rawFontFamily
5460
+ )}", sans-serif`;
5461
+ }
5462
+ ctx.fillStyle = chColor;
5463
+ ctx.fillText(
5464
+ ch,
5465
+ curX,
5466
+ firstBaselineY + lineIndex * lineAdvance + (span?.baselineShift || 0)
5467
+ );
5468
+ ctx.restore();
5469
+ curX += ctx.measureText(ch).width + (span?.letterSpacing || 0);
5470
+ globalCharIndex += ch.length;
5471
+ });
5472
+ globalCharIndex += 1;
5473
+ });
5474
+ } else {
5475
+ const totalInkHeight = lines.length === 1 ? inkLineH : inkLineH + (lines.length - 1) * lineAdvance;
5099
5476
  let firstBaselineY;
5100
5477
  if (verticalAlign === "top") {
5101
5478
  firstBaselineY = contentY + ascent;
@@ -5104,19 +5481,10 @@ var TemplateRenderer = class {
5104
5481
  } else {
5105
5482
  firstBaselineY = contentY + (contentH - totalInkHeight) / 2 + ascent;
5106
5483
  }
5484
+ ctx.textAlign = align;
5107
5485
  lines.forEach((line, index) => {
5108
- ctx.fillText(line, drawX, firstBaselineY + index * lineHeight);
5486
+ ctx.fillText(line, drawX, firstBaselineY + index * lineAdvance);
5109
5487
  });
5110
- } else {
5111
- let drawY;
5112
- if (verticalAlign === "top") {
5113
- drawY = contentY + ascent;
5114
- } else if (verticalAlign === "bottom") {
5115
- drawY = contentY + contentH - descent;
5116
- } else {
5117
- drawY = contentY + (contentH - inkLineH) / 2 + ascent;
5118
- }
5119
- ctx.fillText(lines[0], drawX, drawY);
5120
5488
  }
5121
5489
  ctx.restore();
5122
5490
  ctx.restore();
@@ -5124,11 +5492,24 @@ var TemplateRenderer = class {
5124
5492
  drawShapeLayer(ctx, layer) {
5125
5493
  const resolved = layer;
5126
5494
  const shape = resolved.shape;
5127
- const fill = evaluateAnimatable(resolved.fill, this.currentTime, this.template.duration);
5128
- const x = evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5129
- const y = evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5130
- const width = evaluateAnimatable(resolved.width, this.currentTime, this.template.duration);
5131
- const height = evaluateAnimatable(resolved.height, this.currentTime, this.template.duration);
5495
+ const fill = evaluateAnimatable(
5496
+ resolved.fill,
5497
+ this.currentTime,
5498
+ this.template.duration
5499
+ );
5500
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5501
+ const x = flexLayout?.x ?? evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5502
+ const y = flexLayout?.y ?? evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5503
+ const width = flexLayout?.width ?? evaluateAnimatable(
5504
+ resolved.width,
5505
+ this.currentTime,
5506
+ this.template.duration
5507
+ );
5508
+ const height = flexLayout?.height ?? evaluateAnimatable(
5509
+ resolved.height,
5510
+ this.currentTime,
5511
+ this.template.duration
5512
+ );
5132
5513
  const stroke = resolved.stroke;
5133
5514
  this.lastLayerLayouts.set(resolved.id, { x, y, width, height });
5134
5515
  ctx.fillStyle = fill;
@@ -5145,8 +5526,16 @@ var TemplateRenderer = class {
5145
5526
  }
5146
5527
  ctx.fill();
5147
5528
  if (stroke && stroke.width) {
5148
- const strokeWidth = evaluateAnimatable(stroke.width, this.currentTime, this.template.duration);
5149
- const strokeColor = evaluateAnimatable(stroke.color, this.currentTime, this.template.duration);
5529
+ const strokeWidth = evaluateAnimatable(
5530
+ stroke.width,
5531
+ this.currentTime,
5532
+ this.template.duration
5533
+ );
5534
+ const strokeColor = evaluateAnimatable(
5535
+ stroke.color,
5536
+ this.currentTime,
5537
+ this.template.duration
5538
+ );
5150
5539
  if (strokeWidth > 0) {
5151
5540
  ctx.strokeStyle = strokeColor;
5152
5541
  ctx.lineWidth = strokeWidth;
@@ -5157,10 +5546,19 @@ var TemplateRenderer = class {
5157
5546
  drawImageLayer(ctx, layer) {
5158
5547
  const resolved = layer;
5159
5548
  const url = resolved.url;
5160
- const x = evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5161
- const y = evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5162
- const width = evaluateAnimatable(resolved.width, this.currentTime, this.template.duration);
5163
- const height = evaluateAnimatable(resolved.height, this.currentTime, this.template.duration);
5549
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5550
+ const x = flexLayout?.x ?? evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5551
+ const y = flexLayout?.y ?? evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5552
+ const width = flexLayout?.width ?? evaluateAnimatable(
5553
+ resolved.width,
5554
+ this.currentTime,
5555
+ this.template.duration
5556
+ );
5557
+ const height = flexLayout?.height ?? evaluateAnimatable(
5558
+ resolved.height,
5559
+ this.currentTime,
5560
+ this.template.duration
5561
+ );
5164
5562
  this.lastLayerLayouts.set(resolved.id, { x, y, width, height });
5165
5563
  if (!url) return;
5166
5564
  let img = this.imageCache.get(url);
@@ -5173,6 +5571,33 @@ var TemplateRenderer = class {
5173
5571
  ctx.drawImage(img, x, y, width, height);
5174
5572
  }
5175
5573
  }
5574
+ /**
5575
+ * Renders multi-frame ghost/onion-skin frames onto the canvas for precision motion tuning.
5576
+ */
5577
+ drawOnionSkin(ctx, time, options = {}) {
5578
+ const frameCount = options.frameCount ?? 2;
5579
+ const delta = options.frameDelta ?? 0.066;
5580
+ const duration = this.template.duration || 3;
5581
+ for (let i = frameCount; i >= 1; i--) {
5582
+ const ghostTime = Math.max(0, time - i * delta);
5583
+ if (ghostTime !== time) {
5584
+ ctx.save();
5585
+ ctx.globalAlpha = 0.25 / i;
5586
+ this.drawLayers(ctx, ghostTime);
5587
+ ctx.restore();
5588
+ }
5589
+ }
5590
+ for (let i = frameCount; i >= 1; i--) {
5591
+ const ghostTime = Math.min(duration, time + i * delta);
5592
+ if (ghostTime !== time) {
5593
+ ctx.save();
5594
+ ctx.globalAlpha = 0.25 / i;
5595
+ this.drawLayers(ctx, ghostTime);
5596
+ ctx.restore();
5597
+ }
5598
+ }
5599
+ this.drawFrame(ctx, time, { skipClear: true });
5600
+ }
5176
5601
  };
5177
5602
 
5178
5603
  // src/templates/presets.ts
@@ -5271,53 +5696,659 @@ var BUILTIN_CANVAS_TEMPLATES = [
5271
5696
  width: 1e3,
5272
5697
  height: 280,
5273
5698
  animation: {
5274
- in: "scale-in",
5699
+ in: "scale-in",
5700
+ out: "fade",
5701
+ inDuration: 0.5,
5702
+ outDuration: 0.4,
5703
+ hold: "full"
5704
+ }
5705
+ },
5706
+ {
5707
+ kind: "text",
5708
+ id: "title-text",
5709
+ content: "EXPLORE MORE",
5710
+ fontFamily: "Poppins",
5711
+ fontSize: 84,
5712
+ fontWeight: 700,
5713
+ color: "#ffffff",
5714
+ align: "center",
5715
+ x: 460,
5716
+ y: 440,
5717
+ width: 1e3,
5718
+ height: 100,
5719
+ role: "primary",
5720
+ animation: {
5721
+ in: "slide-down",
5722
+ out: "fade",
5723
+ inDuration: 0.6,
5724
+ outDuration: 0.3,
5725
+ hold: "full"
5726
+ }
5727
+ },
5728
+ {
5729
+ kind: "text",
5730
+ id: "subtitle-text",
5731
+ content: "A Cinematic Experience",
5732
+ fontFamily: "Poppins",
5733
+ fontSize: 32,
5734
+ fontWeight: 400,
5735
+ color: "#a49bff",
5736
+ align: "center",
5737
+ x: 460,
5738
+ y: 560,
5739
+ width: 1e3,
5740
+ height: 50,
5741
+ role: "secondary",
5742
+ animation: {
5743
+ in: "fade",
5744
+ out: "fade",
5745
+ inDuration: 0.8,
5746
+ outDuration: 0.3,
5747
+ hold: "full"
5748
+ }
5749
+ }
5750
+ ]
5751
+ },
5752
+ {
5753
+ id: "clean-caption",
5754
+ label: "Clean Caption Bar",
5755
+ category: "caption",
5756
+ duration: 3,
5757
+ canvasWidth: 1920,
5758
+ canvasHeight: 1080,
5759
+ layers: [
5760
+ {
5761
+ kind: "shape",
5762
+ id: "caption-bg",
5763
+ shape: "rect",
5764
+ fill: "rgba(0, 0, 0, 0.7)",
5765
+ x: 460,
5766
+ // Centered: (1920 - 1000) / 2
5767
+ y: 490,
5768
+ // Centered vertically
5769
+ width: 1e3,
5770
+ height: 100,
5771
+ animation: {
5772
+ in: "fade",
5773
+ out: "fade",
5774
+ inDuration: 0.3,
5775
+ outDuration: 0.2,
5776
+ hold: "full"
5777
+ }
5778
+ },
5779
+ {
5780
+ kind: "text",
5781
+ id: "caption-content",
5782
+ content: "Enter your subtitles or captions here",
5783
+ fontFamily: "Arial",
5784
+ fontSize: 32,
5785
+ fontWeight: 600,
5786
+ color: "#ffd43b",
5787
+ align: "center",
5788
+ x: 460,
5789
+ y: 515,
5790
+ width: 1e3,
5791
+ height: 50,
5792
+ role: "primary",
5793
+ animation: {
5794
+ in: "typewriter",
5795
+ out: "fade",
5796
+ inDuration: 1,
5797
+ outDuration: 0.2,
5798
+ hold: "full"
5799
+ }
5800
+ }
5801
+ ]
5802
+ },
5803
+ {
5804
+ id: "pill-callout",
5805
+ label: "Clean Pill Callout",
5806
+ category: "callout",
5807
+ duration: 3,
5808
+ canvasWidth: 1920,
5809
+ canvasHeight: 1080,
5810
+ layers: [
5811
+ {
5812
+ kind: "shape",
5813
+ id: "pill-bg",
5814
+ shape: "circle",
5815
+ fill: "#ffd43b",
5816
+ x: 800,
5817
+ // Centered: (1920 - 320) / 2
5818
+ y: 500,
5819
+ // Centered vertically
5820
+ width: 320,
5821
+ height: 80,
5822
+ animation: {
5823
+ in: "scale-in",
5824
+ out: "scale-out",
5825
+ inDuration: 0.4,
5826
+ outDuration: 0.3,
5827
+ hold: "full"
5828
+ }
5829
+ },
5830
+ {
5831
+ kind: "text",
5832
+ id: "callout-text",
5833
+ content: "LOOK HERE!",
5834
+ fontFamily: "Poppins",
5835
+ fontSize: 32,
5836
+ fontWeight: 700,
5837
+ color: "#000000",
5838
+ align: "center",
5839
+ x: 800,
5840
+ y: 515,
5841
+ width: 320,
5842
+ height: 50,
5843
+ role: "primary",
5844
+ animation: {
5845
+ in: "fade",
5846
+ out: "fade",
5847
+ inDuration: 0.5,
5848
+ outDuration: 0.3,
5849
+ hold: "full"
5850
+ }
5851
+ }
5852
+ ]
5853
+ },
5854
+ {
5855
+ id: "social-subscribe",
5856
+ label: "Youtube Subscribe Pill",
5857
+ category: "social",
5858
+ duration: 4,
5859
+ canvasWidth: 1920,
5860
+ canvasHeight: 1080,
5861
+ layers: [
5862
+ {
5863
+ kind: "shape",
5864
+ id: "btn-bg",
5865
+ shape: "rect",
5866
+ fill: "#ff0000",
5867
+ x: 810,
5868
+ // Centered: (1920 - 300) / 2
5869
+ y: 505,
5870
+ // Centered vertically
5871
+ width: 300,
5872
+ height: 70,
5873
+ animation: {
5874
+ in: "slide-up",
5875
+ out: "slide-down",
5876
+ inDuration: 0.4,
5877
+ outDuration: 0.3,
5878
+ hold: "full"
5879
+ }
5880
+ },
5881
+ {
5882
+ kind: "text",
5883
+ id: "sub-label",
5884
+ content: "SUBSCRIBE",
5885
+ fontFamily: "Poppins",
5886
+ fontSize: 28,
5887
+ fontWeight: 700,
5888
+ color: "#ffffff",
5889
+ align: "center",
5890
+ x: 810,
5891
+ y: 515,
5892
+ width: 300,
5893
+ height: 50,
5894
+ role: "primary",
5895
+ animation: {
5896
+ in: "fade",
5897
+ out: "fade",
5898
+ inDuration: 0.6,
5899
+ outDuration: 0.2,
5900
+ hold: "full"
5901
+ }
5902
+ }
5903
+ ]
5904
+ },
5905
+ {
5906
+ id: "countdown-timer",
5907
+ label: "Futuristic Countdown",
5908
+ category: "countdown",
5909
+ duration: 5,
5910
+ canvasWidth: 1920,
5911
+ canvasHeight: 1080,
5912
+ layers: [
5913
+ {
5914
+ kind: "shape",
5915
+ id: "outer-ring",
5916
+ shape: "circle",
5917
+ fill: "rgba(124, 111, 255, 0.1)",
5918
+ stroke: { color: "#7c6fff", width: 4 },
5919
+ x: 810,
5920
+ // Centered: (1920 - 300) / 2
5921
+ y: 390,
5922
+ // Centered vertically
5923
+ width: 300,
5924
+ height: 300,
5925
+ animation: {
5926
+ in: "scale-in",
5927
+ out: "fade",
5928
+ inDuration: 0.6,
5929
+ outDuration: 0.4,
5930
+ hold: "full"
5931
+ }
5932
+ },
5933
+ {
5934
+ kind: "text",
5935
+ id: "timer-digits",
5936
+ content: "5",
5937
+ fontFamily: "Poppins",
5938
+ fontSize: 120,
5939
+ fontWeight: 700,
5940
+ color: "#ffffff",
5941
+ align: "center",
5942
+ x: 810,
5943
+ y: 440,
5944
+ width: 300,
5945
+ height: 200,
5946
+ role: "primary",
5947
+ animation: {
5948
+ in: "fade",
5949
+ out: "fade",
5950
+ inDuration: 0.3,
5951
+ outDuration: 0.3,
5952
+ hold: "full"
5953
+ }
5954
+ }
5955
+ ]
5956
+ },
5957
+ {
5958
+ id: "kinetic-split-title",
5959
+ label: "Kinetic Stagger Opener",
5960
+ category: "kinetic-type",
5961
+ duration: 4,
5962
+ canvasWidth: 1920,
5963
+ canvasHeight: 1080,
5964
+ variables: {
5965
+ title: {
5966
+ key: "title",
5967
+ label: "Title Text",
5968
+ type: "string",
5969
+ defaultValue: "FUTURE MOTION"
5970
+ },
5971
+ subtitle: {
5972
+ key: "subtitle",
5973
+ label: "Subtitle Text",
5974
+ type: "string",
5975
+ defaultValue: "ADVANCED TYPOGRAPHY STUDIO"
5976
+ }
5977
+ },
5978
+ layers: [
5979
+ {
5980
+ kind: "text",
5981
+ id: "main-title",
5982
+ content: "{{title}}",
5983
+ fontFamily: "Poppins",
5984
+ fontSize: 72,
5985
+ fontWeight: 900,
5986
+ color: "#ffffff",
5987
+ align: "center",
5988
+ x: 460,
5989
+ y: 440,
5990
+ width: 1e3,
5991
+ height: 100,
5992
+ role: "primary",
5993
+ animation: {
5994
+ in: "scale-pop",
5995
+ out: "fade",
5996
+ inDuration: 0.8,
5997
+ outDuration: 0.4,
5998
+ hold: "full"
5999
+ },
6000
+ splitAnimator: {
6001
+ splitBy: "character",
6002
+ direction: "start-to-end",
6003
+ delayPerUnit: 0.03,
6004
+ overlap: 0.6,
6005
+ initialTransform: {
6006
+ y: 40,
6007
+ opacity: 0,
6008
+ scale: 0.7,
6009
+ rotateX: 45,
6010
+ blur: 8
6011
+ },
6012
+ easing: "cubic-bezier",
6013
+ bezier: { x1: 0.2, y1: 0.8, x2: 0.2, y2: 1 }
6014
+ },
6015
+ anchor: {
6016
+ anchorPoint: "center",
6017
+ maxWidthPercentage: 90
6018
+ }
6019
+ },
6020
+ {
6021
+ kind: "text",
6022
+ id: "sub-title",
6023
+ content: "{{subtitle}}",
6024
+ fontFamily: "Inter Variable",
6025
+ fontSize: 22,
6026
+ fontWeight: 600,
6027
+ color: "#7c6fff",
6028
+ letterSpacing: 6,
6029
+ align: "center",
6030
+ x: 460,
6031
+ y: 550,
6032
+ width: 1e3,
6033
+ height: 40,
6034
+ role: "secondary",
6035
+ animation: {
6036
+ in: "track-in",
6037
+ out: "fade",
6038
+ inDuration: 0.9,
6039
+ outDuration: 0.4,
6040
+ hold: "full"
6041
+ },
6042
+ anchor: {
6043
+ anchorPoint: "center",
6044
+ maxWidthPercentage: 85
6045
+ }
6046
+ }
6047
+ ]
6048
+ },
6049
+ {
6050
+ id: "responsive-speaker-lower-third",
6051
+ label: "Responsive Speaker Badge",
6052
+ category: "lower-third",
6053
+ duration: 5,
6054
+ canvasWidth: 1920,
6055
+ canvasHeight: 1080,
6056
+ variables: {
6057
+ speakerName: {
6058
+ key: "speakerName",
6059
+ label: "Speaker Name",
6060
+ type: "string",
6061
+ defaultValue: "Sarah Chen"
6062
+ },
6063
+ speakerRole: {
6064
+ key: "speakerRole",
6065
+ label: "Role / Organization",
6066
+ type: "string",
6067
+ defaultValue: "VP of Product @ Clypra"
6068
+ }
6069
+ },
6070
+ layers: [
6071
+ {
6072
+ kind: "text",
6073
+ id: "badge-name",
6074
+ content: "{{speakerName}}",
6075
+ fontFamily: "Poppins",
6076
+ fontSize: 32,
6077
+ fontWeight: 700,
6078
+ color: "#ffffff",
6079
+ backgroundColor: "#1E1E28",
6080
+ backgroundOpacity: 0.95,
6081
+ backgroundRadius: 8,
6082
+ backgroundBorderColor: "#7c6fff",
6083
+ backgroundBorderWidth: 2,
6084
+ paddingTop: 12,
6085
+ paddingBottom: 12,
6086
+ paddingLeft: 20,
6087
+ paddingRight: 20,
6088
+ align: "left",
6089
+ x: 100,
6090
+ y: 860,
6091
+ width: "auto",
6092
+ height: "auto",
6093
+ overflow: "expand-panel",
6094
+ role: "primary",
6095
+ animation: {
6096
+ in: "slide-right",
6097
+ out: "fade",
6098
+ inDuration: 0.5,
6099
+ outDuration: 0.3,
6100
+ hold: "full"
6101
+ },
6102
+ anchor: {
6103
+ anchorPoint: "bottom-left",
6104
+ offsetPercentageX: 5,
6105
+ offsetPercentageY: 10
6106
+ }
6107
+ },
6108
+ {
6109
+ kind: "text",
6110
+ id: "badge-role",
6111
+ content: "{{speakerRole}}",
6112
+ fontFamily: "Inter Variable",
6113
+ fontSize: 18,
6114
+ fontWeight: 500,
6115
+ color: "#9A9AAA",
6116
+ backgroundColor: "#121218",
6117
+ backgroundOpacity: 0.85,
6118
+ backgroundRadius: 6,
6119
+ paddingTop: 8,
6120
+ paddingBottom: 8,
6121
+ paddingLeft: 16,
6122
+ paddingRight: 16,
6123
+ align: "left",
6124
+ x: 100,
6125
+ y: 930,
6126
+ width: "auto",
6127
+ height: "auto",
6128
+ overflow: "expand-panel",
6129
+ role: "secondary",
6130
+ animation: {
6131
+ in: "slide-right",
6132
+ out: "fade",
6133
+ inDuration: 0.6,
6134
+ outDuration: 0.3,
6135
+ hold: "full"
6136
+ },
6137
+ anchor: {
6138
+ anchorPoint: "bottom-left",
6139
+ offsetPercentageX: 5,
6140
+ offsetPercentageY: 4
6141
+ }
6142
+ }
6143
+ ]
6144
+ },
6145
+ {
6146
+ id: "action-cta-card",
6147
+ label: "Modern Action CTA",
6148
+ category: "cta",
6149
+ duration: 4,
6150
+ canvasWidth: 1920,
6151
+ canvasHeight: 1080,
6152
+ layers: [
6153
+ {
6154
+ kind: "shape",
6155
+ id: "cta-bg",
6156
+ shape: "rect",
6157
+ fill: "rgba(18, 18, 28, 0.95)",
6158
+ stroke: { color: "#6366f1", width: 2 },
6159
+ x: 460,
6160
+ y: 380,
6161
+ width: 1e3,
6162
+ height: 320,
6163
+ animation: {
6164
+ in: "scale-in",
6165
+ out: "fade",
6166
+ inDuration: 0.5,
6167
+ outDuration: 0.3,
6168
+ hold: "full"
6169
+ }
6170
+ },
6171
+ {
6172
+ kind: "text",
6173
+ id: "cta-heading",
6174
+ content: "READY TO LEVEL UP?",
6175
+ fontFamily: "Poppins",
6176
+ fontSize: 64,
6177
+ fontWeight: 800,
6178
+ color: "#ffffff",
6179
+ align: "center",
6180
+ x: 460,
6181
+ y: 420,
6182
+ width: 1e3,
6183
+ height: 80,
6184
+ role: "primary",
6185
+ animation: {
6186
+ in: "slide-down",
6187
+ out: "fade",
6188
+ inDuration: 0.6,
6189
+ outDuration: 0.3,
6190
+ hold: "full"
6191
+ }
6192
+ },
6193
+ {
6194
+ kind: "text",
6195
+ id: "cta-sub",
6196
+ content: "Download Clypra Studio and start creating today.",
6197
+ fontFamily: "Inter Variable",
6198
+ fontSize: 26,
6199
+ fontWeight: 400,
6200
+ color: "#94a3b8",
6201
+ align: "center",
6202
+ x: 460,
6203
+ y: 510,
6204
+ width: 1e3,
6205
+ height: 40,
6206
+ role: "secondary",
6207
+ animation: {
6208
+ in: "fade",
6209
+ out: "fade",
6210
+ inDuration: 0.7,
6211
+ outDuration: 0.3,
6212
+ hold: "full"
6213
+ }
6214
+ },
6215
+ {
6216
+ kind: "text",
6217
+ id: "cta-btn-text",
6218
+ content: "GET STARTED FREE",
6219
+ fontFamily: "Poppins",
6220
+ fontSize: 24,
6221
+ fontWeight: 700,
6222
+ color: "#ffffff",
6223
+ backgroundColor: "#6366f1",
6224
+ backgroundOpacity: 0.95,
6225
+ paddingTop: 10,
6226
+ paddingBottom: 10,
6227
+ paddingLeft: 28,
6228
+ paddingRight: 28,
6229
+ backgroundRadius: 8,
6230
+ align: "center",
6231
+ x: 810,
6232
+ y: 580,
6233
+ width: 300,
6234
+ height: 50,
6235
+ role: "accent",
6236
+ animation: {
6237
+ in: "scale-pop",
6238
+ out: "fade",
6239
+ inDuration: 0.8,
6240
+ outDuration: 0.3,
6241
+ hold: "full"
6242
+ }
6243
+ }
6244
+ ]
6245
+ },
6246
+ {
6247
+ id: "cinematic-credits-card",
6248
+ label: "Cinematic Cast Card",
6249
+ category: "credits",
6250
+ duration: 5,
6251
+ canvasWidth: 1920,
6252
+ canvasHeight: 1080,
6253
+ layers: [
6254
+ {
6255
+ kind: "text",
6256
+ id: "credit-role",
6257
+ content: "DIRECTED BY",
6258
+ fontFamily: "Inter Variable",
6259
+ fontSize: 24,
6260
+ fontWeight: 600,
6261
+ color: "#7c6fff",
6262
+ letterSpacing: 6,
6263
+ align: "center",
6264
+ x: 460,
6265
+ y: 450,
6266
+ width: 1e3,
6267
+ height: 40,
6268
+ role: "secondary",
6269
+ animation: {
6270
+ in: "fade",
6271
+ out: "fade",
6272
+ inDuration: 0.8,
6273
+ outDuration: 0.4,
6274
+ hold: "full"
6275
+ }
6276
+ },
6277
+ {
6278
+ kind: "text",
6279
+ id: "credit-name",
6280
+ content: "MARCUS VANCE",
6281
+ fontFamily: "Poppins",
6282
+ fontSize: 56,
6283
+ fontWeight: 800,
6284
+ color: "#ffffff",
6285
+ letterSpacing: 2,
6286
+ align: "center",
6287
+ x: 460,
6288
+ y: 510,
6289
+ width: 1e3,
6290
+ height: 70,
6291
+ role: "primary",
6292
+ animation: {
6293
+ in: "slide-up",
5275
6294
  out: "fade",
5276
- inDuration: 0.5,
6295
+ inDuration: 0.8,
5277
6296
  outDuration: 0.4,
5278
6297
  hold: "full"
5279
6298
  }
5280
- },
6299
+ }
6300
+ ]
6301
+ },
6302
+ {
6303
+ id: "editorial-pull-quote",
6304
+ label: "Editorial Pull Quote",
6305
+ category: "quotes",
6306
+ duration: 5,
6307
+ canvasWidth: 1920,
6308
+ canvasHeight: 1080,
6309
+ layers: [
5281
6310
  {
5282
6311
  kind: "text",
5283
- id: "title-text",
5284
- content: "EXPLORE MORE",
6312
+ id: "quote-body",
6313
+ content: "\u201CCreativity is intelligence having fun.\u201D",
5285
6314
  fontFamily: "Poppins",
5286
- fontSize: 84,
5287
- fontWeight: 700,
6315
+ fontSize: 48,
6316
+ fontWeight: 400,
6317
+ fontStyle: "italic",
5288
6318
  color: "#ffffff",
5289
6319
  align: "center",
5290
- x: 460,
6320
+ x: 360,
5291
6321
  y: 440,
5292
- width: 1e3,
5293
- height: 100,
6322
+ width: 1200,
6323
+ height: 80,
5294
6324
  role: "primary",
5295
6325
  animation: {
5296
- in: "slide-down",
6326
+ in: "fade",
5297
6327
  out: "fade",
5298
- inDuration: 0.6,
6328
+ inDuration: 0.8,
5299
6329
  outDuration: 0.3,
5300
6330
  hold: "full"
5301
6331
  }
5302
6332
  },
5303
6333
  {
5304
6334
  kind: "text",
5305
- id: "subtitle-text",
5306
- content: "A Cinematic Experience",
5307
- fontFamily: "Poppins",
5308
- fontSize: 32,
5309
- fontWeight: 400,
5310
- color: "#a49bff",
6335
+ id: "quote-author",
6336
+ content: "\u2014 ALBERT EINSTEIN",
6337
+ fontFamily: "Inter Variable",
6338
+ fontSize: 24,
6339
+ fontWeight: 600,
6340
+ color: "#38bdf8",
6341
+ letterSpacing: 3,
5311
6342
  align: "center",
5312
6343
  x: 460,
5313
- y: 560,
6344
+ y: 540,
5314
6345
  width: 1e3,
5315
- height: 50,
6346
+ height: 40,
5316
6347
  role: "secondary",
5317
6348
  animation: {
5318
- in: "fade",
6349
+ in: "slide-up",
5319
6350
  out: "fade",
5320
- inDuration: 0.8,
6351
+ inDuration: 0.9,
5321
6352
  outDuration: 0.3,
5322
6353
  hold: "full"
5323
6354
  }
@@ -5325,99 +6356,130 @@ var BUILTIN_CANVAS_TEMPLATES = [
5325
6356
  ]
5326
6357
  },
5327
6358
  {
5328
- id: "clean-caption",
5329
- label: "Clean Caption Bar",
5330
- category: "caption",
5331
- duration: 3,
6359
+ id: "sports-match-score",
6360
+ label: "Sports Match Scoreboard",
6361
+ category: "sports",
6362
+ duration: 4,
5332
6363
  canvasWidth: 1920,
5333
6364
  canvasHeight: 1080,
5334
6365
  layers: [
5335
6366
  {
5336
6367
  kind: "shape",
5337
- id: "caption-bg",
6368
+ id: "score-bg",
5338
6369
  shape: "rect",
5339
- fill: "rgba(0, 0, 0, 0.7)",
5340
- x: 460,
5341
- // Centered: (1920 - 1000) / 2
5342
- y: 490,
5343
- // Centered vertically
5344
- width: 1e3,
5345
- height: 100,
6370
+ fill: "rgba(15, 23, 42, 0.95)",
6371
+ stroke: { color: "#38bdf8", width: 2 },
6372
+ x: 660,
6373
+ y: 440,
6374
+ width: 600,
6375
+ height: 180,
6376
+ animation: {
6377
+ in: "scale-in",
6378
+ out: "fade",
6379
+ inDuration: 0.4,
6380
+ outDuration: 0.3,
6381
+ hold: "full"
6382
+ }
6383
+ },
6384
+ {
6385
+ kind: "text",
6386
+ id: "team-names",
6387
+ content: "WARRIORS vs CHAMPIONS",
6388
+ fontFamily: "Inter Variable",
6389
+ fontSize: 26,
6390
+ fontWeight: 700,
6391
+ color: "#94a3b8",
6392
+ align: "center",
6393
+ x: 660,
6394
+ y: 460,
6395
+ width: 600,
6396
+ height: 40,
6397
+ role: "secondary",
5346
6398
  animation: {
5347
6399
  in: "fade",
5348
6400
  out: "fade",
5349
- inDuration: 0.3,
5350
- outDuration: 0.2,
6401
+ inDuration: 0.5,
6402
+ outDuration: 0.3,
5351
6403
  hold: "full"
5352
6404
  }
5353
6405
  },
5354
6406
  {
5355
6407
  kind: "text",
5356
- id: "caption-content",
5357
- content: "Enter your subtitles or captions here",
5358
- fontFamily: "Arial",
5359
- fontSize: 32,
5360
- fontWeight: 600,
5361
- color: "#ffd43b",
6408
+ id: "score-digits",
6409
+ content: "3 - 2",
6410
+ fontFamily: "Poppins",
6411
+ fontSize: 72,
6412
+ fontWeight: 900,
6413
+ color: "#ffffff",
5362
6414
  align: "center",
5363
- x: 460,
5364
- y: 515,
5365
- width: 1e3,
5366
- height: 50,
6415
+ x: 660,
6416
+ y: 505,
6417
+ width: 600,
6418
+ height: 90,
5367
6419
  role: "primary",
5368
6420
  animation: {
5369
- in: "typewriter",
6421
+ in: "scale-pop",
5370
6422
  out: "fade",
5371
- inDuration: 1,
5372
- outDuration: 0.2,
6423
+ inDuration: 0.6,
6424
+ outDuration: 0.3,
5373
6425
  hold: "full"
5374
6426
  }
5375
6427
  }
5376
6428
  ]
5377
6429
  },
5378
6430
  {
5379
- id: "pill-callout",
5380
- label: "Clean Pill Callout",
5381
- category: "callout",
5382
- duration: 3,
6431
+ id: "gamer-hud-tag",
6432
+ label: "Cyberpunk Gamer HUD",
6433
+ category: "gaming",
6434
+ duration: 4,
5383
6435
  canvasWidth: 1920,
5384
6436
  canvasHeight: 1080,
5385
6437
  layers: [
5386
6438
  {
5387
- kind: "shape",
5388
- id: "pill-bg",
5389
- shape: "circle",
5390
- fill: "#ffd43b",
5391
- x: 800,
5392
- // Centered: (1920 - 320) / 2
5393
- y: 500,
5394
- // Centered vertically
5395
- width: 320,
5396
- height: 80,
6439
+ kind: "text",
6440
+ id: "gamer-lvl",
6441
+ content: "LVL 99 \xB7 PRO",
6442
+ fontFamily: "Inter Variable",
6443
+ fontSize: 22,
6444
+ fontWeight: 800,
6445
+ color: "#a855f7",
6446
+ backgroundColor: "#2e1065",
6447
+ backgroundOpacity: 0.9,
6448
+ paddingTop: 6,
6449
+ paddingBottom: 6,
6450
+ paddingLeft: 16,
6451
+ paddingRight: 16,
6452
+ backgroundRadius: 4,
6453
+ align: "center",
6454
+ x: 810,
6455
+ y: 450,
6456
+ width: 300,
6457
+ height: 40,
6458
+ role: "secondary",
5397
6459
  animation: {
5398
- in: "scale-in",
5399
- out: "scale-out",
5400
- inDuration: 0.4,
5401
- outDuration: 0.3,
6460
+ in: "scale-pop",
6461
+ out: "fade",
6462
+ inDuration: 0.3,
6463
+ outDuration: 0.2,
5402
6464
  hold: "full"
5403
6465
  }
5404
6466
  },
5405
6467
  {
5406
6468
  kind: "text",
5407
- id: "callout-text",
5408
- content: "LOOK HERE!",
6469
+ id: "gamer-handle",
6470
+ content: "NIGHT_RAVEN",
5409
6471
  fontFamily: "Poppins",
5410
- fontSize: 32,
5411
- fontWeight: 700,
5412
- color: "#000000",
6472
+ fontSize: 60,
6473
+ fontWeight: 900,
6474
+ color: "#ffffff",
5413
6475
  align: "center",
5414
- x: 800,
5415
- y: 515,
5416
- width: 320,
5417
- height: 50,
6476
+ x: 660,
6477
+ y: 500,
6478
+ width: 600,
6479
+ height: 80,
5418
6480
  role: "primary",
5419
6481
  animation: {
5420
- in: "fade",
6482
+ in: "slide-up",
5421
6483
  out: "fade",
5422
6484
  inDuration: 0.5,
5423
6485
  outDuration: 0.3,
@@ -5427,103 +6489,126 @@ var BUILTIN_CANVAS_TEMPLATES = [
5427
6489
  ]
5428
6490
  },
5429
6491
  {
5430
- id: "social-subscribe",
5431
- label: "Youtube Subscribe Pill",
5432
- category: "social",
5433
- duration: 4,
6492
+ id: "breaking-news-live",
6493
+ label: "Live Breaking News Strap",
6494
+ category: "news",
6495
+ duration: 5,
5434
6496
  canvasWidth: 1920,
5435
6497
  canvasHeight: 1080,
5436
6498
  layers: [
5437
6499
  {
5438
- kind: "shape",
5439
- id: "btn-bg",
5440
- shape: "rect",
5441
- fill: "#ff0000",
5442
- x: 810,
5443
- // Centered: (1920 - 300) / 2
5444
- y: 505,
5445
- // Centered vertically
5446
- width: 300,
5447
- height: 70,
6500
+ kind: "text",
6501
+ id: "news-badge",
6502
+ content: "BREAKING NEWS",
6503
+ fontFamily: "Inter Variable",
6504
+ fontSize: 24,
6505
+ fontWeight: 800,
6506
+ color: "#ffffff",
6507
+ backgroundColor: "#dc2626",
6508
+ backgroundOpacity: 0.95,
6509
+ paddingTop: 8,
6510
+ paddingBottom: 8,
6511
+ paddingLeft: 20,
6512
+ paddingRight: 20,
6513
+ backgroundRadius: 4,
6514
+ align: "left",
6515
+ x: 100,
6516
+ y: 840,
6517
+ width: "auto",
6518
+ height: "auto",
6519
+ role: "accent",
5448
6520
  animation: {
5449
- in: "slide-up",
5450
- out: "slide-down",
5451
- inDuration: 0.4,
5452
- outDuration: 0.3,
6521
+ in: "scale-pop",
6522
+ out: "fade",
6523
+ inDuration: 0.3,
6524
+ outDuration: 0.2,
5453
6525
  hold: "full"
5454
6526
  }
5455
6527
  },
5456
6528
  {
5457
6529
  kind: "text",
5458
- id: "sub-label",
5459
- content: "SUBSCRIBE",
6530
+ id: "news-headline",
6531
+ content: "MAJOR DISCOVERY ANNOUNCED LIVE TODAY",
5460
6532
  fontFamily: "Poppins",
5461
- fontSize: 28,
5462
- fontWeight: 700,
6533
+ fontSize: 48,
6534
+ fontWeight: 800,
5463
6535
  color: "#ffffff",
5464
- align: "center",
5465
- x: 810,
5466
- y: 515,
5467
- width: 300,
5468
- height: 50,
6536
+ backgroundColor: "rgba(15, 23, 42, 0.95)",
6537
+ backgroundOpacity: 0.95,
6538
+ paddingTop: 12,
6539
+ paddingBottom: 12,
6540
+ paddingLeft: 28,
6541
+ paddingRight: 28,
6542
+ backgroundRadius: 4,
6543
+ backgroundBorderColor: "#dc2626",
6544
+ backgroundBorderWidth: 2,
6545
+ align: "left",
6546
+ x: 100,
6547
+ y: 890,
6548
+ width: "auto",
6549
+ height: "auto",
5469
6550
  role: "primary",
5470
6551
  animation: {
5471
- in: "fade",
6552
+ in: "slide-right",
5472
6553
  out: "fade",
5473
- inDuration: 0.6,
5474
- outDuration: 0.2,
6554
+ inDuration: 0.5,
6555
+ outDuration: 0.3,
5475
6556
  hold: "full"
5476
6557
  }
5477
6558
  }
5478
6559
  ]
5479
6560
  },
5480
6561
  {
5481
- id: "countdown-timer",
5482
- label: "Futuristic Countdown",
5483
- category: "countdown",
5484
- duration: 5,
6562
+ id: "minimal-editorial-title",
6563
+ label: "Minimalist Editorial Layout",
6564
+ category: "minimal",
6565
+ duration: 4,
5485
6566
  canvasWidth: 1920,
5486
6567
  canvasHeight: 1080,
5487
6568
  layers: [
5488
6569
  {
5489
- kind: "shape",
5490
- id: "outer-ring",
5491
- shape: "circle",
5492
- fill: "rgba(124, 111, 255, 0.1)",
5493
- stroke: { color: "#7c6fff", width: 4 },
5494
- x: 810,
5495
- // Centered: (1920 - 300) / 2
5496
- y: 390,
5497
- // Centered vertically
5498
- width: 300,
5499
- height: 300,
6570
+ kind: "text",
6571
+ id: "min-title",
6572
+ content: "ESSENTIAL PERSPECTIVES",
6573
+ fontFamily: "Inter Variable",
6574
+ fontSize: 64,
6575
+ fontWeight: 300,
6576
+ letterSpacing: 8,
6577
+ color: "#ffffff",
6578
+ align: "center",
6579
+ x: 360,
6580
+ y: 470,
6581
+ width: 1200,
6582
+ height: 80,
6583
+ role: "primary",
5500
6584
  animation: {
5501
- in: "scale-in",
6585
+ in: "fade",
5502
6586
  out: "fade",
5503
- inDuration: 0.6,
6587
+ inDuration: 1,
5504
6588
  outDuration: 0.4,
5505
6589
  hold: "full"
5506
6590
  }
5507
6591
  },
5508
6592
  {
5509
6593
  kind: "text",
5510
- id: "timer-digits",
5511
- content: "5",
5512
- fontFamily: "Poppins",
5513
- fontSize: 120,
5514
- fontWeight: 700,
5515
- color: "#ffffff",
6594
+ id: "min-sub",
6595
+ content: "Volume 01 \u2014 Issue 2026",
6596
+ fontFamily: "Inter Variable",
6597
+ fontSize: 22,
6598
+ fontWeight: 500,
6599
+ letterSpacing: 4,
6600
+ color: "#94a3b8",
5516
6601
  align: "center",
5517
- x: 810,
5518
- y: 440,
5519
- width: 300,
5520
- height: 200,
5521
- role: "primary",
6602
+ x: 460,
6603
+ y: 560,
6604
+ width: 1e3,
6605
+ height: 40,
6606
+ role: "secondary",
5522
6607
  animation: {
5523
6608
  in: "fade",
5524
6609
  out: "fade",
5525
- inDuration: 0.3,
5526
- outDuration: 0.3,
6610
+ inDuration: 1.2,
6611
+ outDuration: 0.4,
5527
6612
  hold: "full"
5528
6613
  }
5529
6614
  }
@@ -6253,7 +7338,7 @@ var ProjectCompiler = class {
6253
7338
  if (!definition) {
6254
7339
  throw new Error(`Unknown effect type: ${effect.type}. Ensure it is registered in NodeRegistry.`);
6255
7340
  }
6256
- const { capabilities: capabilities2, requirements } = definition;
7341
+ const { capabilities, requirements } = definition;
6257
7342
  const effectNode = {
6258
7343
  id: effectNodeId,
6259
7344
  type: effect.type,
@@ -6265,7 +7350,7 @@ var ProjectCompiler = class {
6265
7350
  outputs: {
6266
7351
  output: { id: "output", name: "Color Output", type: "Texture" }
6267
7352
  },
6268
- capabilities: capabilities2,
7353
+ capabilities,
6269
7354
  requirements,
6270
7355
  lifecycle: "Created"
6271
7356
  };
@@ -7032,6 +8117,13 @@ function resolveConform(conform, canvasWidth, canvasHeight) {
7032
8117
  if (!sw || !sh) {
7033
8118
  return { x: 0, y: 0, width: canvasWidth, height: canvasHeight };
7034
8119
  }
8120
+ if (mode === "stretch") {
8121
+ const width2 = canvasWidth * userScale;
8122
+ const height2 = canvasHeight * userScale;
8123
+ const x2 = (canvasWidth - width2) / 2 + userOffsetX;
8124
+ const y2 = (canvasHeight - height2) / 2 + userOffsetY;
8125
+ return { x: x2, y: y2, width: width2, height: height2 };
8126
+ }
7035
8127
  let baseScale;
7036
8128
  switch (mode) {
7037
8129
  case "fit":
@@ -9023,11 +10115,13 @@ var DataBindingEngine = class {
9023
10115
  }
9024
10116
  }
9025
10117
  if (direction === "horizontal") {
9026
- clonedNode.x = repeater.x + idx * (clonedNode.width + gap);
10118
+ const nodeW = typeof clonedNode.width === "number" ? clonedNode.width : 0;
10119
+ clonedNode.x = repeater.x + idx * (nodeW + gap);
9027
10120
  clonedNode.y = repeater.y;
9028
10121
  } else {
10122
+ const nodeH = typeof clonedNode.height === "number" ? clonedNode.height : 0;
9029
10123
  clonedNode.x = repeater.x;
9030
- clonedNode.y = repeater.y + idx * (clonedNode.height + gap);
10124
+ clonedNode.y = repeater.y + idx * (nodeH + gap);
9031
10125
  }
9032
10126
  if (clonedNode.animation?.entrance) {
9033
10127
  clonedNode.animation.entrance = {
@@ -10016,8 +11110,8 @@ var CommandExecutor = class {
10016
11110
  for (const n of targetNodes) {
10017
11111
  if (n.x < minX) minX = n.x;
10018
11112
  if (n.y < minY) minY = n.y;
10019
- if (n.x + n.width > maxX) maxX = n.x + n.width;
10020
- if (n.y + n.height > maxY) maxY = n.y + n.height;
11113
+ if (typeof n.width === "number" && n.x + n.width > maxX) maxX = n.x + n.width;
11114
+ if (typeof n.height === "number" && n.y + n.height > maxY) maxY = n.y + n.height;
10021
11115
  }
10022
11116
  const frameId = `frame-${Date.now().toString(36)}`;
10023
11117
  const frameNode = {
@@ -10473,17 +11567,19 @@ var DocumentValidator = class {
10473
11567
  });
10474
11568
  }
10475
11569
  }
10476
- const absX = node.x < 100 ? node.x / 100 * doc.canvas.width : node.x;
10477
- const absY = node.y < 100 ? node.y / 100 * doc.canvas.height : node.y;
10478
- const absW = node.width <= 100 ? node.width / 100 * doc.canvas.width : node.width;
10479
- const absH = node.height <= 100 ? node.height / 100 * doc.canvas.height : node.height;
10480
- if (absX + absW > doc.canvas.width || absY + absH > doc.canvas.height) {
10481
- diagnostics.push({
10482
- severity: "warning",
10483
- code: "WARN_OUT_OF_BOUNDS",
10484
- message: `Node "${node.name || node.id}" extends outside canvas bounds.`,
10485
- nodeId: node.id
10486
- });
11570
+ if (typeof node.width === "number" && typeof node.height === "number") {
11571
+ const absX = node.x < 100 ? node.x / 100 * doc.canvas.width : node.x;
11572
+ const absY = node.y < 100 ? node.y / 100 * doc.canvas.height : node.y;
11573
+ const absW = node.width <= 100 ? node.width / 100 * doc.canvas.width : node.width;
11574
+ const absH = node.height <= 100 ? node.height / 100 * doc.canvas.height : node.height;
11575
+ if (absX + absW > doc.canvas.width || absY + absH > doc.canvas.height) {
11576
+ diagnostics.push({
11577
+ severity: "warning",
11578
+ code: "WARN_OUT_OF_BOUNDS",
11579
+ message: `Node "${node.name || node.id}" extends outside canvas bounds.`,
11580
+ nodeId: node.id
11581
+ });
11582
+ }
10487
11583
  }
10488
11584
  if ("children" in node && Array.isArray(node.children)) {
10489
11585
  for (const child of node.children) {
@@ -10805,43 +11901,45 @@ var SnapEngine = class {
10805
11901
  let snappedX = movingNode.x;
10806
11902
  let snappedY = movingNode.y;
10807
11903
  const guides = [];
11904
+ const movingW = typeof movingNode.width === "number" ? movingNode.width : 0;
11905
+ const movingH = typeof movingNode.height === "number" ? movingNode.height : 0;
10808
11906
  const nodeLeft = movingNode.x;
10809
- const nodeCenter = movingNode.x + movingNode.width / 2;
10810
- const nodeRight = movingNode.x + movingNode.width;
11907
+ const nodeCenter = movingNode.x + movingW / 2;
11908
+ const nodeRight = movingNode.x + movingW;
10811
11909
  const nodeTop = movingNode.y;
10812
- const nodeMiddle = movingNode.y + movingNode.height / 2;
10813
- const nodeBottom = movingNode.y + movingNode.height;
11910
+ const nodeMiddle = movingNode.y + movingH / 2;
11911
+ const nodeBottom = movingNode.y + movingH;
10814
11912
  const safeMarginX = Math.round(canvasWidth * 0.05);
10815
11913
  const safeMarginY = Math.round(canvasHeight * 0.05);
10816
11914
  const canvasCenterX = canvasWidth / 2;
10817
11915
  const canvasCenterY = canvasHeight / 2;
10818
11916
  if (Math.abs(nodeCenter - canvasCenterX) < threshold) {
10819
- snappedX = canvasCenterX - movingNode.width / 2;
11917
+ snappedX = canvasCenterX - movingW / 2;
10820
11918
  guides.push({ type: "vertical", position: canvasCenterX });
10821
11919
  }
10822
11920
  if (Math.abs(nodeMiddle - canvasCenterY) < threshold) {
10823
- snappedY = canvasCenterY - movingNode.height / 2;
11921
+ snappedY = canvasCenterY - movingH / 2;
10824
11922
  guides.push({ type: "horizontal", position: canvasCenterY });
10825
11923
  }
10826
11924
  if (Math.abs(nodeLeft - safeMarginX) < threshold) {
10827
11925
  snappedX = safeMarginX;
10828
11926
  guides.push({ type: "vertical", position: safeMarginX });
10829
11927
  } else if (Math.abs(nodeRight - (canvasWidth - safeMarginX)) < threshold) {
10830
- snappedX = canvasWidth - safeMarginX - movingNode.width;
11928
+ snappedX = canvasWidth - safeMarginX - movingW;
10831
11929
  guides.push({ type: "vertical", position: canvasWidth - safeMarginX });
10832
11930
  }
10833
11931
  if (Math.abs(nodeTop - safeMarginY) < threshold) {
10834
11932
  snappedY = safeMarginY;
10835
11933
  guides.push({ type: "horizontal", position: safeMarginY });
10836
11934
  } else if (Math.abs(nodeBottom - (canvasHeight - safeMarginY)) < threshold) {
10837
- snappedY = canvasHeight - safeMarginY - movingNode.height;
11935
+ snappedY = canvasHeight - safeMarginY - movingH;
10838
11936
  guides.push({ type: "horizontal", position: canvasHeight - safeMarginY });
10839
11937
  }
10840
11938
  for (const other of otherNodes) {
10841
11939
  const otherX = other.x;
10842
11940
  const otherY = other.y;
10843
- const otherW = other.width;
10844
- const otherH = other.height;
11941
+ const otherW = typeof other.width === "number" ? other.width : 0;
11942
+ const otherH = typeof other.height === "number" ? other.height : 0;
10845
11943
  const otherCenter = otherX + otherW / 2;
10846
11944
  const otherMiddle = otherY + otherH / 2;
10847
11945
  const minXDist = Math.min(
@@ -10861,29 +11959,31 @@ var SnapEngine = class {
10861
11959
  snappedX = otherX;
10862
11960
  guides.push({ type: "vertical", position: otherX });
10863
11961
  } else if (Math.abs(nodeCenter - otherCenter) < threshold) {
10864
- snappedX = otherCenter - movingNode.width / 2;
11962
+ snappedX = otherCenter - movingW / 2;
10865
11963
  guides.push({ type: "vertical", position: otherCenter });
10866
11964
  } else if (Math.abs(nodeRight - (otherX + otherW)) < threshold) {
10867
- snappedX = otherX + otherW - movingNode.width;
11965
+ snappedX = otherX + otherW - movingW;
10868
11966
  guides.push({ type: "vertical", position: otherX + otherW });
10869
11967
  }
10870
11968
  if (Math.abs(nodeTop - otherY) < threshold) {
10871
11969
  snappedY = otherY;
10872
11970
  guides.push({ type: "horizontal", position: otherY });
10873
11971
  } else if (Math.abs(nodeMiddle - otherMiddle) < threshold) {
10874
- snappedY = otherMiddle - movingNode.height / 2;
11972
+ snappedY = otherMiddle - movingH / 2;
10875
11973
  guides.push({ type: "horizontal", position: otherMiddle });
10876
11974
  } else if (Math.abs(nodeBottom - (otherY + otherH)) < threshold) {
10877
- snappedY = otherY + otherH - movingNode.height;
11975
+ snappedY = otherY + otherH - movingH;
10878
11976
  guides.push({ type: "horizontal", position: otherY + otherH });
10879
11977
  }
10880
11978
  }
10881
11979
  if (otherNodes.length >= 2) {
10882
11980
  const sortedX = [...otherNodes].sort((a, b) => a.x - b.x);
10883
11981
  for (let i = 0; i < sortedX.length - 1; i++) {
10884
- const gap = sortedX[i + 1].x - (sortedX[i].x + sortedX[i].width);
11982
+ const itemW = typeof sortedX[i].width === "number" ? sortedX[i].width : 0;
11983
+ const nextItemW = typeof sortedX[i + 1].width === "number" ? sortedX[i + 1].width : 0;
11984
+ const gap = sortedX[i + 1].x - (sortedX[i].x + itemW);
10885
11985
  if (gap > 0) {
10886
- const targetNextX = sortedX[i + 1].x + sortedX[i + 1].width + gap;
11986
+ const targetNextX = sortedX[i + 1].x + nextItemW + gap;
10887
11987
  if (Math.abs(nodeLeft - targetNextX) < threshold) {
10888
11988
  snappedX = targetNextX;
10889
11989
  guides.push({ type: "vertical", position: targetNextX });
@@ -11281,7 +12381,12 @@ var LayoutEngine = class {
11281
12381
  const anchor = node.anchor;
11282
12382
  if (anchor && anchor.targetId && result[anchor.targetId]) {
11283
12383
  const targetBounds = result[anchor.targetId];
11284
- const currentBounds = result[node.id] || { x: node.x, y: node.y, width: node.width, height: node.height };
12384
+ const currentBounds = result[node.id] || {
12385
+ x: node.x,
12386
+ y: node.y,
12387
+ width: typeof node.width === "number" ? node.width : 400,
12388
+ height: typeof node.height === "number" ? node.height : 120
12389
+ };
11285
12390
  let targetPointX = targetBounds.x + targetBounds.width / 2;
11286
12391
  let targetPointY = targetBounds.y + targetBounds.height / 2;
11287
12392
  const targetSide = anchor.targetSide || "right";
@@ -11320,10 +12425,12 @@ var LayoutEngine = class {
11320
12425
  const startTarget = lineNode.startNodeId ? result[lineNode.startNodeId] : void 0;
11321
12426
  const endTarget = lineNode.endNodeId ? result[lineNode.endNodeId] : void 0;
11322
12427
  if (startTarget || endTarget || lineNode.startX !== void 0 || lineNode.endX !== void 0) {
12428
+ const fallbackEndW = typeof node.width === "number" ? node.width : 0;
12429
+ const fallbackEndH = typeof node.height === "number" ? node.height : 0;
11323
12430
  const startX = startTarget ? startTarget.x + startTarget.width / 2 : lineNode.startX ?? node.x;
11324
12431
  const startY = startTarget ? startTarget.y + startTarget.height / 2 : lineNode.startY ?? node.y;
11325
- const endX = endTarget ? endTarget.x + endTarget.width / 2 : lineNode.endX ?? node.x + node.width;
11326
- const endY = endTarget ? endTarget.y + endTarget.height / 2 : lineNode.endY ?? node.y + node.height;
12432
+ const endX = endTarget ? endTarget.x + endTarget.width / 2 : lineNode.endX ?? node.x + fallbackEndW;
12433
+ const endY = endTarget ? endTarget.y + endTarget.height / 2 : lineNode.endY ?? node.y + fallbackEndH;
11327
12434
  const minX = Math.min(startX, endX);
11328
12435
  const minY = Math.min(startY, endY);
11329
12436
  const lineW = Math.max(1, Math.abs(endX - startX));
@@ -11343,7 +12450,9 @@ var LayoutEngine = class {
11343
12450
  const fromTarget = conn.fromNodeId ? result[conn.fromNodeId] : void 0;
11344
12451
  const toTarget = conn.toNodeId ? result[conn.toNodeId] : void 0;
11345
12452
  const fromPt = fromTarget ? this.resolveAnchorPoint(fromTarget, conn.fromAnchor || conn.fromElement) : { x: node.x, y: node.y };
11346
- const toPt = toTarget ? this.resolveAnchorPoint(toTarget, conn.toAnchor || conn.toElement) : { x: node.x + (node.width || 100), y: node.y + (node.height || 100) };
12453
+ const fallbackConnW = typeof node.width === "number" ? node.width : 100;
12454
+ const fallbackConnH = typeof node.height === "number" ? node.height : 100;
12455
+ const toPt = toTarget ? this.resolveAnchorPoint(toTarget, conn.toAnchor || conn.toElement) : { x: node.x + fallbackConnW, y: node.y + fallbackConnH };
11347
12456
  const minX = Math.min(fromPt.x, toPt.x);
11348
12457
  const minY = Math.min(fromPt.y, toPt.y);
11349
12458
  const connW = Math.max(1, Math.abs(toPt.x - fromPt.x));
@@ -11396,8 +12505,22 @@ var LayoutEngine = class {
11396
12505
  computeNodeGeometry(node, doc, context, result, parentX = 0, parentY = 0, isAbsoluteSlot = false) {
11397
12506
  let absX = isAbsoluteSlot ? parentX : parentX + node.x;
11398
12507
  let absY = isAbsoluteSlot ? parentY : parentY + node.y;
11399
- let width = node.width;
11400
- let height = node.height;
12508
+ let width;
12509
+ let height;
12510
+ if (node.type === "text") {
12511
+ const fontSize = node.style?.fontSize ?? 48;
12512
+ const fontWeight = node.style?.fontWeight ?? "normal";
12513
+ const fontFamily = node.style?.fontFamily ?? "Inter, sans-serif";
12514
+ const textContent = node.text ?? "Text";
12515
+ const measuredW = measureTextWidth(textContent, fontSize, fontWeight, fontFamily);
12516
+ width = typeof node.width === "number" && node.width > 0 ? node.width : measuredW;
12517
+ const lineHeight = node.style?.lineHeight ?? 1.2;
12518
+ const measuredH = Math.ceil(fontSize * lineHeight);
12519
+ height = typeof node.height === "number" && node.height > 0 ? node.height : measuredH;
12520
+ } else {
12521
+ width = typeof node.width === "number" ? node.width : 400;
12522
+ height = typeof node.height === "number" ? node.height : 120;
12523
+ }
11401
12524
  if (node.type === "line" || node.shapeKind === "line") {
11402
12525
  const strokeW = node.style?.strokeWidth ?? node.strokeWidth;
11403
12526
  if (typeof strokeW === "number" && strokeW > 0) {
@@ -11430,7 +12553,8 @@ var LayoutEngine = class {
11430
12553
  const scaleX = containerW / (doc.canvas.width || 1280);
11431
12554
  absX = Math.round(parentX + node.x * scaleX);
11432
12555
  if (node.layout?.constraints?.widthMode !== "fixed") {
11433
- width = Math.round(node.width * scaleX);
12556
+ const baseW = typeof node.width === "number" ? node.width : width;
12557
+ width = Math.round(baseW * scaleX);
11434
12558
  }
11435
12559
  }
11436
12560
  if (verticalPin === "center") {
@@ -11441,7 +12565,8 @@ var LayoutEngine = class {
11441
12565
  const scaleY = containerH / (doc.canvas.height || 720);
11442
12566
  absY = Math.round(parentY + node.y * scaleY);
11443
12567
  if (node.layout?.constraints?.heightMode !== "fixed") {
11444
- height = Math.round(node.height * scaleY);
12568
+ const baseH = typeof node.height === "number" ? node.height : height;
12569
+ height = Math.round(baseH * scaleY);
11445
12570
  }
11446
12571
  }
11447
12572
  }
@@ -11614,7 +12739,7 @@ var LayoutEngine = class {
11614
12739
  }
11615
12740
  }
11616
12741
  if (effectiveHeightMode === "hug") {
11617
- height = activeChildren.length > 0 ? hugHeight : node.height || 240;
12742
+ height = activeChildren.length > 0 ? hugHeight : typeof node.height === "number" ? node.height : 240;
11618
12743
  } else if (effectiveHeightMode !== "fill") {
11619
12744
  if (activeChildren.length > 0 && hugHeight > height) {
11620
12745
  height = hugHeight;
@@ -11711,14 +12836,14 @@ var LayoutEngine = class {
11711
12836
  const hugWidth = maxChildW + normPadding.left + normPadding.right;
11712
12837
  const hugHeight = totalContentH + normPadding.top + normPadding.bottom;
11713
12838
  if (effectiveWidthMode === "hug") {
11714
- width = activeColChildren.length > 0 ? hugWidth : node.width || 320;
12839
+ width = activeColChildren.length > 0 ? hugWidth : typeof node.width === "number" ? node.width : 320;
11715
12840
  } else if (effectiveWidthMode !== "fill") {
11716
12841
  if (activeColChildren.length > 0 && hugWidth > width) {
11717
12842
  width = hugWidth;
11718
12843
  }
11719
12844
  }
11720
12845
  if (effectiveHeightMode === "hug") {
11721
- height = activeColChildren.length > 0 ? hugHeight : node.height || 240;
12846
+ height = activeColChildren.length > 0 ? hugHeight : typeof node.height === "number" ? node.height : 240;
11722
12847
  } else if (effectiveHeightMode !== "fill") {
11723
12848
  if (activeColChildren.length > 0 && hugHeight > height) {
11724
12849
  height = hugHeight;
@@ -12043,7 +13168,9 @@ var SelectionEngine = class {
12043
13168
  for (let i = container.children.length - 1; i >= 0; i--) {
12044
13169
  const child = container.children[i];
12045
13170
  if (child.locked) continue;
12046
- if (clickPoint.x >= child.x && clickPoint.x <= child.x + child.width && clickPoint.y >= child.y && clickPoint.y <= child.y + child.height) {
13171
+ const childW = typeof child.width === "number" ? child.width : 0;
13172
+ const childH = typeof child.height === "number" ? child.height : 0;
13173
+ if (clickPoint.x >= child.x && clickPoint.x <= child.x + childW && clickPoint.y >= child.y && clickPoint.y <= child.y + childH) {
12047
13174
  this.select(child.id, doc);
12048
13175
  return true;
12049
13176
  }
@@ -12175,56 +13302,58 @@ var TransformEngine = class {
12175
13302
  */
12176
13303
  static resizeNode(node, handle, dx, dy, options = {}) {
12177
13304
  const { lockAspectRatio = false, minWidth = 10, minHeight = 10 } = options;
13305
+ const initialW = typeof node.width === "number" ? node.width : 200;
13306
+ const initialH = typeof node.height === "number" ? node.height : 50;
12178
13307
  let newX = node.x;
12179
13308
  let newY = node.y;
12180
- let newWidth = node.width;
12181
- let newHeight = node.height;
12182
- const initialAspect = node.width > 0 && node.height > 0 ? node.width / node.height : 1;
13309
+ let newWidth = initialW;
13310
+ let newHeight = initialH;
13311
+ const initialAspect = initialW > 0 && initialH > 0 ? initialW / initialH : 1;
12183
13312
  switch (handle) {
12184
13313
  case "e":
12185
- newWidth = Math.max(minWidth, node.width + dx);
13314
+ newWidth = Math.max(minWidth, initialW + dx);
12186
13315
  if (lockAspectRatio) newHeight = Math.max(minHeight, newWidth / initialAspect);
12187
13316
  break;
12188
13317
  case "w": {
12189
- const potentialW = node.width - dx;
13318
+ const potentialW = initialW - dx;
12190
13319
  if (potentialW >= minWidth) {
12191
13320
  newWidth = potentialW;
12192
13321
  newX = node.x + dx;
12193
13322
  } else {
12194
13323
  newWidth = minWidth;
12195
- newX = node.x + (node.width - minWidth);
13324
+ newX = node.x + (initialW - minWidth);
12196
13325
  }
12197
13326
  if (lockAspectRatio) newHeight = Math.max(minHeight, newWidth / initialAspect);
12198
13327
  break;
12199
13328
  }
12200
13329
  case "s":
12201
- newHeight = Math.max(minHeight, node.height + dy);
13330
+ newHeight = Math.max(minHeight, initialH + dy);
12202
13331
  if (lockAspectRatio) newWidth = Math.max(minWidth, newHeight * initialAspect);
12203
13332
  break;
12204
13333
  case "n": {
12205
- const potentialH = node.height - dy;
13334
+ const potentialH = initialH - dy;
12206
13335
  if (potentialH >= minHeight) {
12207
13336
  newHeight = potentialH;
12208
13337
  newY = node.y + dy;
12209
13338
  } else {
12210
13339
  newHeight = minHeight;
12211
- newY = node.y + (node.height - minHeight);
13340
+ newY = node.y + (initialH - minHeight);
12212
13341
  }
12213
13342
  if (lockAspectRatio) newWidth = Math.max(minWidth, newHeight * initialAspect);
12214
13343
  break;
12215
13344
  }
12216
13345
  case "se":
12217
- newWidth = Math.max(minWidth, node.width + dx);
12218
- newHeight = Math.max(minHeight, node.height + dy);
13346
+ newWidth = Math.max(minWidth, initialW + dx);
13347
+ newHeight = Math.max(minHeight, initialH + dy);
12219
13348
  if (lockAspectRatio) {
12220
- const scale = Math.max(newWidth / node.width, newHeight / node.height);
12221
- newWidth = Math.max(minWidth, node.width * scale);
12222
- newHeight = Math.max(minHeight, node.height * scale);
13349
+ const scale = Math.max(newWidth / initialW, newHeight / initialH);
13350
+ newWidth = Math.max(minWidth, initialW * scale);
13351
+ newHeight = Math.max(minHeight, initialH * scale);
12223
13352
  }
12224
13353
  break;
12225
13354
  case "nw": {
12226
- const potW = node.width - dx;
12227
- const potH = node.height - dy;
13355
+ const potW = initialW - dx;
13356
+ const potH = initialH - dy;
12228
13357
  if (potW >= minWidth) {
12229
13358
  newWidth = potW;
12230
13359
  newX = node.x + dx;
@@ -12234,15 +13363,15 @@ var TransformEngine = class {
12234
13363
  newY = node.y + dy;
12235
13364
  }
12236
13365
  if (lockAspectRatio) {
12237
- const scale = Math.max(newWidth / node.width, newHeight / node.height);
12238
- newWidth = Math.max(minWidth, node.width * scale);
12239
- newHeight = Math.max(minHeight, node.height * scale);
13366
+ const scale = Math.max(newWidth / initialW, newHeight / initialH);
13367
+ newWidth = Math.max(minWidth, initialW * scale);
13368
+ newHeight = Math.max(minHeight, initialH * scale);
12240
13369
  }
12241
13370
  break;
12242
13371
  }
12243
13372
  case "ne": {
12244
- newWidth = Math.max(minWidth, node.width + dx);
12245
- const potH = node.height - dy;
13373
+ newWidth = Math.max(minWidth, initialW + dx);
13374
+ const potH = initialH - dy;
12246
13375
  if (potH >= minHeight) {
12247
13376
  newHeight = potH;
12248
13377
  newY = node.y + dy;
@@ -12253,12 +13382,12 @@ var TransformEngine = class {
12253
13382
  break;
12254
13383
  }
12255
13384
  case "sw": {
12256
- const potW = node.width - dx;
13385
+ const potW = initialW - dx;
12257
13386
  if (potW >= minWidth) {
12258
13387
  newWidth = potW;
12259
13388
  newX = node.x + dx;
12260
13389
  }
12261
- newHeight = Math.max(minHeight, node.height + dy);
13390
+ newHeight = Math.max(minHeight, initialH + dy);
12262
13391
  if (lockAspectRatio) {
12263
13392
  newWidth = Math.max(minWidth, newHeight * initialAspect);
12264
13393
  }
@@ -12302,9 +13431,9 @@ var TransformEngine = class {
12302
13431
  }
12303
13432
  } else {
12304
13433
  const minX = Math.min(...nodes.map((n) => n.x));
12305
- const maxX = Math.max(...nodes.map((n) => n.x + n.width));
13434
+ const maxX = Math.max(...nodes.map((n) => n.x + (typeof n.width === "number" ? n.width : 0)));
12306
13435
  const minY = Math.min(...nodes.map((n) => n.y));
12307
- const maxY = Math.max(...nodes.map((n) => n.y + n.height));
13436
+ const maxY = Math.max(...nodes.map((n) => n.y + (typeof n.height === "number" ? n.height : 0)));
12308
13437
  switch (alignment) {
12309
13438
  case "left":
12310
13439
  targetCoord = minX;
@@ -12329,24 +13458,26 @@ var TransformEngine = class {
12329
13458
  return nodes.map((node) => {
12330
13459
  let updatedX = node.x;
12331
13460
  let updatedY = node.y;
13461
+ const nW = typeof node.width === "number" ? node.width : 0;
13462
+ const nH = typeof node.height === "number" ? node.height : 0;
12332
13463
  switch (alignment) {
12333
13464
  case "left":
12334
13465
  updatedX = targetCoord;
12335
13466
  break;
12336
13467
  case "center":
12337
- updatedX = Math.round(targetCoord - node.width / 2);
13468
+ updatedX = Math.round(targetCoord - nW / 2);
12338
13469
  break;
12339
13470
  case "right":
12340
- updatedX = Math.round(targetCoord - node.width);
13471
+ updatedX = Math.round(targetCoord - nW);
12341
13472
  break;
12342
13473
  case "top":
12343
13474
  updatedY = targetCoord;
12344
13475
  break;
12345
13476
  case "middle":
12346
- updatedY = Math.round(targetCoord - node.height / 2);
13477
+ updatedY = Math.round(targetCoord - nH / 2);
12347
13478
  break;
12348
13479
  case "bottom":
12349
- updatedY = Math.round(targetCoord - node.height);
13480
+ updatedY = Math.round(targetCoord - nH);
12350
13481
  break;
12351
13482
  }
12352
13483
  return { ...node, x: updatedX, y: updatedY };
@@ -12361,33 +13492,37 @@ var TransformEngine = class {
12361
13492
  const first = sorted[0];
12362
13493
  const last = sorted[sorted.length - 1];
12363
13494
  if (axis === "horizontal") {
12364
- const totalSpan = last.x + last.width - first.x;
12365
- const totalNodeWidths = sorted.reduce((sum, n) => sum + n.width, 0);
13495
+ const lastW = typeof last.width === "number" ? last.width : 0;
13496
+ const totalSpan = last.x + lastW - first.x;
13497
+ const totalNodeWidths = sorted.reduce((sum, n) => sum + (typeof n.width === "number" ? n.width : 0), 0);
12366
13498
  const totalGapSpace = totalSpan - totalNodeWidths;
12367
13499
  const gap = totalGapSpace / (sorted.length - 1);
12368
13500
  let currentX = first.x;
12369
13501
  return sorted.map((node, i) => {
13502
+ const nW = typeof node.width === "number" ? node.width : 0;
12370
13503
  if (i === 0) {
12371
- currentX += node.width + gap;
13504
+ currentX += nW + gap;
12372
13505
  return node;
12373
13506
  }
12374
13507
  const updated = { ...node, x: Math.round(currentX) };
12375
- currentX += node.width + gap;
13508
+ currentX += nW + gap;
12376
13509
  return updated;
12377
13510
  });
12378
13511
  } else {
12379
- const totalSpan = last.y + last.height - first.y;
12380
- const totalNodeHeights = sorted.reduce((sum, n) => sum + n.height, 0);
13512
+ const lastH = typeof last.height === "number" ? last.height : 0;
13513
+ const totalSpan = last.y + lastH - first.y;
13514
+ const totalNodeHeights = sorted.reduce((sum, n) => sum + (typeof n.height === "number" ? n.height : 0), 0);
12381
13515
  const totalGapSpace = totalSpan - totalNodeHeights;
12382
13516
  const gap = totalGapSpace / (sorted.length - 1);
12383
13517
  let currentY = first.y;
12384
13518
  return sorted.map((node, i) => {
13519
+ const nH = typeof node.height === "number" ? node.height : 0;
12385
13520
  if (i === 0) {
12386
- currentY += node.height + gap;
13521
+ currentY += nH + gap;
12387
13522
  return node;
12388
13523
  }
12389
13524
  const updated = { ...node, y: Math.round(currentY) };
12390
- currentY += node.height + gap;
13525
+ currentY += nH + gap;
12391
13526
  return updated;
12392
13527
  });
12393
13528
  }
@@ -12868,21 +14003,23 @@ var SmartGuideEngine = class {
12868
14003
  let snappedX = false;
12869
14004
  let snappedY = false;
12870
14005
  const guides = [];
14006
+ const movingW = typeof moving.width === "number" ? moving.width : 0;
14007
+ const movingH = typeof moving.height === "number" ? moving.height : 0;
12871
14008
  const left = moving.x;
12872
- const centerX = moving.x + moving.width / 2;
12873
- const right = moving.x + moving.width;
14009
+ const centerX = moving.x + movingW / 2;
14010
+ const right = moving.x + movingW;
12874
14011
  const top = moving.y;
12875
- const centerY = moving.y + moving.height / 2;
12876
- const bottom = moving.y + moving.height;
14012
+ const centerY = moving.y + movingH / 2;
14013
+ const bottom = moving.y + movingH;
12877
14014
  const canvasCenterX = canvasWidth / 2;
12878
14015
  const canvasCenterY = canvasHeight / 2;
12879
14016
  if (Math.abs(centerX - canvasCenterX) <= threshold) {
12880
- finalX = Math.round(canvasCenterX - moving.width / 2);
14017
+ finalX = Math.round(canvasCenterX - movingW / 2);
12881
14018
  snappedX = true;
12882
14019
  guides.push({ type: "vertical", position: canvasCenterX, label: "Canvas Center X" });
12883
14020
  }
12884
14021
  if (Math.abs(centerY - canvasCenterY) <= threshold) {
12885
- finalY = Math.round(canvasCenterY - moving.height / 2);
14022
+ finalY = Math.round(canvasCenterY - movingH / 2);
12886
14023
  snappedY = true;
12887
14024
  guides.push({ type: "horizontal", position: canvasCenterY, label: "Canvas Center Y" });
12888
14025
  }
@@ -12894,7 +14031,7 @@ var SmartGuideEngine = class {
12894
14031
  snappedX = true;
12895
14032
  guides.push({ type: "vertical", position: safeMarginX, label: "Safe Margin Left" });
12896
14033
  } else if (Math.abs(right - (canvasWidth - safeMarginX)) <= threshold) {
12897
- finalX = canvasWidth - safeMarginX - moving.width;
14034
+ finalX = canvasWidth - safeMarginX - movingW;
12898
14035
  snappedX = true;
12899
14036
  guides.push({ type: "vertical", position: canvasWidth - safeMarginX, label: "Safe Margin Right" });
12900
14037
  }
@@ -12905,29 +14042,31 @@ var SmartGuideEngine = class {
12905
14042
  snappedY = true;
12906
14043
  guides.push({ type: "horizontal", position: safeMarginY, label: "Safe Margin Top" });
12907
14044
  } else if (Math.abs(bottom - (canvasHeight - safeMarginY)) <= threshold) {
12908
- finalY = canvasHeight - safeMarginY - moving.height;
14045
+ finalY = canvasHeight - safeMarginY - movingH;
12909
14046
  snappedY = true;
12910
14047
  guides.push({ type: "horizontal", position: canvasHeight - safeMarginY, label: "Safe Margin Bottom" });
12911
14048
  }
12912
14049
  }
12913
14050
  for (const other of otherNodes) {
14051
+ const otherW = typeof other.width === "number" ? other.width : 0;
14052
+ const otherH = typeof other.height === "number" ? other.height : 0;
12914
14053
  const oLeft = other.x;
12915
- const oCenterX = other.x + other.width / 2;
12916
- const oRight = other.x + other.width;
14054
+ const oCenterX = other.x + otherW / 2;
14055
+ const oRight = other.x + otherW;
12917
14056
  const oTop = other.y;
12918
- const oCenterY = other.y + other.height / 2;
12919
- const oBottom = other.y + other.height;
14057
+ const oCenterY = other.y + otherH / 2;
14058
+ const oBottom = other.y + otherH;
12920
14059
  if (!snappedX) {
12921
14060
  if (Math.abs(left - oLeft) <= threshold) {
12922
14061
  finalX = oLeft;
12923
14062
  snappedX = true;
12924
14063
  guides.push({ type: "vertical", position: oLeft, label: "Align Left" });
12925
14064
  } else if (Math.abs(centerX - oCenterX) <= threshold) {
12926
- finalX = Math.round(oCenterX - moving.width / 2);
14065
+ finalX = Math.round(oCenterX - movingW / 2);
12927
14066
  snappedX = true;
12928
14067
  guides.push({ type: "vertical", position: oCenterX, label: "Align Center X" });
12929
14068
  } else if (Math.abs(right - oRight) <= threshold) {
12930
- finalX = Math.round(oRight - moving.width);
14069
+ finalX = Math.round(oRight - movingW);
12931
14070
  snappedX = true;
12932
14071
  guides.push({ type: "vertical", position: oRight, label: "Align Right" });
12933
14072
  } else if (Math.abs(left - oRight) <= threshold) {
@@ -12935,7 +14074,7 @@ var SmartGuideEngine = class {
12935
14074
  snappedX = true;
12936
14075
  guides.push({ type: "vertical", position: oRight, label: "Edge Flush Right" });
12937
14076
  } else if (Math.abs(right - oLeft) <= threshold) {
12938
- finalX = Math.round(oLeft - moving.width);
14077
+ finalX = Math.round(oLeft - movingW);
12939
14078
  snappedX = true;
12940
14079
  guides.push({ type: "vertical", position: oLeft, label: "Edge Flush Left" });
12941
14080
  }
@@ -12946,11 +14085,11 @@ var SmartGuideEngine = class {
12946
14085
  snappedY = true;
12947
14086
  guides.push({ type: "horizontal", position: oTop, label: "Align Top" });
12948
14087
  } else if (Math.abs(centerY - oCenterY) <= threshold) {
12949
- finalY = Math.round(oCenterY - moving.height / 2);
14088
+ finalY = Math.round(oCenterY - movingH / 2);
12950
14089
  snappedY = true;
12951
14090
  guides.push({ type: "horizontal", position: oCenterY, label: "Align Center Y" });
12952
14091
  } else if (Math.abs(bottom - oBottom) <= threshold) {
12953
- finalY = Math.round(oBottom - moving.height);
14092
+ finalY = Math.round(oBottom - movingH);
12954
14093
  snappedY = true;
12955
14094
  guides.push({ type: "horizontal", position: oBottom, label: "Align Bottom" });
12956
14095
  } else if (Math.abs(top - oBottom) <= threshold) {
@@ -12958,7 +14097,7 @@ var SmartGuideEngine = class {
12958
14097
  snappedY = true;
12959
14098
  guides.push({ type: "horizontal", position: oBottom, label: "Edge Flush Bottom" });
12960
14099
  } else if (Math.abs(bottom - oTop) <= threshold) {
12961
- finalY = Math.round(oTop - moving.height);
14100
+ finalY = Math.round(oTop - movingH);
12962
14101
  snappedY = true;
12963
14102
  guides.push({ type: "horizontal", position: oTop, label: "Edge Flush Top" });
12964
14103
  }
@@ -14050,7 +15189,9 @@ var ExportValidator = class {
14050
15189
  });
14051
15190
  }
14052
15191
  }
14053
- if (isNaN(node.x) || isNaN(node.y) || isNaN(node.width) || isNaN(node.height)) {
15192
+ const widthIsNaN = typeof node.width === "number" ? isNaN(node.width) : false;
15193
+ const heightIsNaN = typeof node.height === "number" ? isNaN(node.height) : false;
15194
+ if (isNaN(node.x) || isNaN(node.y) || widthIsNaN || heightIsNaN) {
14054
15195
  diagnostics.push({
14055
15196
  severity: "error",
14056
15197
  code: "UNRESOLVED_CONSTRAINTS",
@@ -15563,8 +16704,8 @@ function evaluateOverlayDocument(doc, context = {}, time = 0) {
15563
16704
  resolvedText = dataBindingEngine.evaluateExpression(responsiveNode.text, evalVariables);
15564
16705
  }
15565
16706
  const computedBounds = computedLayout.nodes[responsiveNode.id];
15566
- const finalWidth = computedBounds ? computedBounds.width : animState.width;
15567
- const finalHeight = computedBounds ? computedBounds.height : animState.height;
16707
+ const finalWidth = computedBounds ? computedBounds.width : typeof animState.width === "number" ? animState.width : 400;
16708
+ const finalHeight = computedBounds ? computedBounds.height : typeof animState.height === "number" ? animState.height : 120;
15568
16709
  const finalX = computedBounds ? computedBounds.x : animState.x;
15569
16710
  const finalY = computedBounds ? computedBounds.y : animState.y;
15570
16711
  let transform = {
@@ -15675,7 +16816,8 @@ function evaluateOverlayDocument(doc, context = {}, time = 0) {
15675
16816
  style,
15676
16817
  content,
15677
16818
  geometry,
15678
- children: evaluatedChildren
16819
+ children: evaluatedChildren,
16820
+ metadata: "textEffectRef" in responsiveNode ? { textEffectRef: responsiveNode.textEffectRef } : void 0
15679
16821
  };
15680
16822
  nodeMap[evaluatedNode.id] = evaluatedNode;
15681
16823
  return evaluatedNode;
@@ -16018,10 +17160,141 @@ function resolveBehaviorToAnimationSpec(behavior, node) {
16018
17160
  }
16019
17161
  }
16020
17162
 
17163
+ // src/smartOverlays/runtime/canvasRenderer.ts
17164
+ function alpha(value, fallback = 1) {
17165
+ if (value === void 0) return fallback;
17166
+ return value > 1 ? value / 100 : Math.max(0, Math.min(1, value));
17167
+ }
17168
+ function roundedRect(ctx, x, y, width, height, radius) {
17169
+ const r = Math.max(0, Math.min(radius, Math.min(width, height) / 2));
17170
+ if (typeof ctx.roundRect === "function") {
17171
+ ctx.beginPath();
17172
+ ctx.roundRect(x, y, width, height, r);
17173
+ return;
17174
+ }
17175
+ ctx.beginPath();
17176
+ ctx.rect(x, y, width, height);
17177
+ }
17178
+ function drawText(ctx, node, text) {
17179
+ const style = node.style;
17180
+ const size = Math.max(1, style.fontSize ?? 20);
17181
+ const weight = style.fontWeight ?? "400";
17182
+ const family = style.fontFamily ?? "Inter, sans-serif";
17183
+ const lineHeight = (style.lineHeight ?? 1.2) * size;
17184
+ const maxWidth = Math.max(1, node.transform.width);
17185
+ const lines = [];
17186
+ let line = "";
17187
+ for (const word of text.split(/\s+/)) {
17188
+ const candidate = line ? `${line} ${word}` : word;
17189
+ if (line && ctx.measureText(candidate).width > maxWidth) {
17190
+ lines.push(line);
17191
+ line = word;
17192
+ } else {
17193
+ line = candidate;
17194
+ }
17195
+ }
17196
+ if (line || !lines.length) lines.push(line);
17197
+ const maxLines = style.maxLines;
17198
+ const visibleLines = maxLines ? lines.slice(0, maxLines) : lines;
17199
+ ctx.font = `${weight} ${size}px ${family}`;
17200
+ ctx.fillStyle = style.textColor ?? style.fillColor ?? "#ffffff";
17201
+ ctx.textAlign = style.textAlign ?? "left";
17202
+ ctx.textBaseline = "top";
17203
+ const x = style.textAlign === "center" ? maxWidth / 2 : style.textAlign === "right" ? maxWidth : 0;
17204
+ const progress = node.content?.typewriterProgress;
17205
+ visibleLines.forEach((value, index) => {
17206
+ const lineText = progress === void 0 ? value : value.slice(0, Math.ceil(value.length * progress));
17207
+ ctx.fillText(lineText, x, index * lineHeight, maxWidth);
17208
+ });
17209
+ }
17210
+ function drawPinnedTextEffect(ctx, node, text, time) {
17211
+ const reference = node.metadata?.textEffectRef;
17212
+ const snapshot = reference?.snapshot;
17213
+ if (!snapshot?.effectLayers || !snapshot.text || !snapshot.canvas) return false;
17214
+ const width = Math.max(1, Math.ceil(node.transform.width));
17215
+ const height = Math.max(1, Math.ceil(node.transform.height));
17216
+ const effectCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(width, height) : typeof document !== "undefined" ? Object.assign(document.createElement("canvas"), { width, height }) : null;
17217
+ const effectCtx = effectCanvas?.getContext("2d");
17218
+ if (!effectCtx) return false;
17219
+ const effectScene = JSON.parse(JSON.stringify(snapshot));
17220
+ effectScene.canvas.width = width;
17221
+ effectScene.canvas.height = height;
17222
+ effectScene.text.content = text;
17223
+ effectScene.text.fontFamily = node.style.fontFamily;
17224
+ effectScene.text.fontSize = node.style.fontSize;
17225
+ effectScene.text.fontWeight = node.style.fontWeight;
17226
+ effectScene.text.textPosX = "center";
17227
+ effectScene.text.textPosY = "middle";
17228
+ evaluateScene(effectScene, time, effectCtx);
17229
+ ctx.drawImage(effectCanvas, 0, 0, node.transform.width, node.transform.height);
17230
+ return true;
17231
+ }
17232
+ function drawNode(ctx, node, time) {
17233
+ if (!node.visible || node.style.opacity <= 1e-3) return;
17234
+ const { x, y, width, height, rotation, scaleX, scaleY, translateX, translateY } = node.transform;
17235
+ const style = node.style;
17236
+ ctx.save();
17237
+ ctx.translate(x + width / 2 + translateX, y + height / 2 + translateY);
17238
+ ctx.rotate(rotation * Math.PI / 180);
17239
+ ctx.scale(scaleX || 1, scaleY || 1);
17240
+ ctx.globalAlpha *= alpha(style.opacity);
17241
+ if (style.shadowColor || style.shadowBlur) {
17242
+ ctx.shadowColor = style.shadowColor ?? "rgba(0,0,0,0.5)";
17243
+ ctx.shadowBlur = style.shadowBlur ?? 0;
17244
+ }
17245
+ ctx.translate(-width / 2, -height / 2);
17246
+ if (style.fillGradient?.colors?.length) {
17247
+ const gradient = style.fillGradient.type === "radial" ? ctx.createRadialGradient(width / 2, height / 2, 0, width / 2, height / 2, Math.max(width, height) / 2) : ctx.createLinearGradient(0, 0, width, height);
17248
+ style.fillGradient.colors.forEach((color, index) => gradient.addColorStop(index / Math.max(1, style.fillGradient.colors.length - 1), color));
17249
+ ctx.fillStyle = gradient;
17250
+ ctx.globalAlpha *= alpha(style.fillOpacity);
17251
+ roundedRect(ctx, 0, 0, width, height, style.borderRadius ?? 0);
17252
+ ctx.fill();
17253
+ } else if (style.fillColor || node.type === "shape") {
17254
+ ctx.fillStyle = style.fillColor ?? "#334155";
17255
+ ctx.globalAlpha *= alpha(style.fillOpacity);
17256
+ roundedRect(ctx, 0, 0, width, height, style.borderRadius ?? 0);
17257
+ ctx.fill();
17258
+ }
17259
+ if (style.strokeColor && (style.strokeWidth ?? 0) > 0) {
17260
+ ctx.strokeStyle = style.strokeColor;
17261
+ ctx.lineWidth = style.strokeWidth ?? 1;
17262
+ roundedRect(ctx, 0, 0, width, height, style.borderRadius ?? 0);
17263
+ ctx.stroke();
17264
+ }
17265
+ if (node.type === "text" || node.type === "rich-text" || node.type === "metric" || node.type === "callout" || node.type === "annotation") {
17266
+ const text = node.content?.text ?? node.content?.formattedValue ?? node.content?.props?.body ?? node.content?.props?.label ?? "";
17267
+ if (text && !drawPinnedTextEffect(ctx, node, text, time)) drawText(ctx, node, text);
17268
+ } else if (node.type === "line" || node.type === "divider" || node.type === "connector") {
17269
+ ctx.strokeStyle = style.strokeColor ?? "#94a3b8";
17270
+ ctx.lineWidth = style.strokeWidth ?? 2;
17271
+ ctx.beginPath();
17272
+ ctx.moveTo(0, height / 2);
17273
+ ctx.lineTo(width, height / 2);
17274
+ ctx.stroke();
17275
+ } else if (node.type === "media" || node.type === "video" || node.type === "lottie") {
17276
+ ctx.fillStyle = "rgba(30,41,59,0.65)";
17277
+ ctx.fillRect(0, 0, width, height);
17278
+ ctx.strokeStyle = "rgba(148,163,184,0.65)";
17279
+ ctx.strokeRect(4, 4, Math.max(0, width - 8), Math.max(0, height - 8));
17280
+ }
17281
+ ctx.restore();
17282
+ node.children?.forEach((child) => drawNode(ctx, child, time));
17283
+ }
17284
+ function renderEvaluatedSceneToCanvas(scene, ctx, options = {}) {
17285
+ if (options.clear !== false) ctx.clearRect(0, 0, scene.canvas.width, scene.canvas.height);
17286
+ if (options.background !== false && scene.canvas.backgroundColor && scene.canvas.backgroundColor !== "transparent") {
17287
+ ctx.fillStyle = scene.canvas.backgroundColor;
17288
+ ctx.fillRect(0, 0, scene.canvas.width, scene.canvas.height);
17289
+ }
17290
+ scene.nodes.forEach((node) => drawNode(ctx, node, scene.time));
17291
+ }
17292
+
16021
17293
  // src/index.ts
16022
- var VERSION = "0.1.0";
17294
+ var VERSION = "1.4.0";
16023
17295
  export {
16024
17296
  ALL_TRANSITIONS,
17297
+ ASPECT_RATIO_PRESETS,
16025
17298
  AnimationPresetSchema,
16026
17299
  AnimationRuntime,
16027
17300
  AnimationSchema,
@@ -16115,6 +17388,9 @@ export {
16115
17388
  SmartOverlayRenderer,
16116
17389
  SnapEngine,
16117
17390
  TEMPLATE_CATEGORIES,
17391
+ TEXT_TEMPLATE_KIND,
17392
+ TEXT_TEMPLATE_RENDERER_VERSION,
17393
+ TEXT_TEMPLATE_SCHEMA_VERSION,
16118
17394
  TRANSITION_CATEGORIES,
16119
17395
  TRANSITION_PRESETS,
16120
17396
  TemplateCategorySchema,
@@ -16147,6 +17423,7 @@ export {
16147
17423
  alignToLottieJ,
16148
17424
  animationRuntime,
16149
17425
  animationValidator,
17426
+ applyEasing,
16150
17427
  applyFillColorToAll,
16151
17428
  applyLetterSpacing,
16152
17429
  applyMaskReveal,
@@ -16154,6 +17431,7 @@ export {
16154
17431
  applyStyleToLottie,
16155
17432
  applyStyleToLottieLayer,
16156
17433
  applyTimelineAtTime,
17434
+ assertValidTextTemplateArtifact,
16157
17435
  assetRegistry,
16158
17436
  bakeAnimationIntoLayer,
16159
17437
  blendColors,
@@ -16171,6 +17449,7 @@ export {
16171
17449
  calculateResizeBounds,
16172
17450
  calculateRotationAngle,
16173
17451
  canonicalContentHash,
17452
+ canonicalTemplateHash,
16174
17453
  canonicalizeSceneDocument,
16175
17454
  captureImageSourceDimensions,
16176
17455
  captureLottieFrames,
@@ -16183,6 +17462,7 @@ export {
16183
17462
  cloneSceneWithNewIds,
16184
17463
  commandExecutor,
16185
17464
  compileSemanticOverlay,
17465
+ compileTextTemplate,
16186
17466
  componentRegistry,
16187
17467
  computeAutoFitFontSize,
16188
17468
  computeFitZoom,
@@ -16227,6 +17507,7 @@ export {
16227
17507
  evaluateExportFrame,
16228
17508
  evaluateOverlayDocument,
16229
17509
  evaluateScene,
17510
+ evaluateSplitTextTransforms,
16230
17511
  evaluateTextEffect,
16231
17512
  evaluateTextTemplate,
16232
17513
  exportLottieToMp4,
@@ -16259,9 +17540,11 @@ export {
16259
17540
  getRenderCapabilities,
16260
17541
  getSceneTime,
16261
17542
  getSourceCropRect,
17543
+ getSpanForCharIndex,
16262
17544
  getSupportedWebMMimeType,
16263
17545
  getTemplatePreset,
16264
17546
  getTemplatesByCategory,
17547
+ getTextTemplateControls,
16265
17548
  getTransitionById,
16266
17549
  getTransitionByRenderer,
16267
17550
  getTransitionCategories,
@@ -16281,6 +17564,8 @@ export {
16281
17564
  injectSolidColor,
16282
17565
  injectText,
16283
17566
  injectTextStyle,
17567
+ interpolateColorString,
17568
+ interpolateValue,
16284
17569
  isKeyframed,
16285
17570
  isMp4ExportSupported,
16286
17571
  isWebMExportSupported,
@@ -16299,6 +17584,7 @@ export {
16299
17584
  newLayerId,
16300
17585
  normalizeTextEffect,
16301
17586
  normalizeTextTemplate,
17587
+ normalizeTextTemplateArtifact,
16302
17588
  parseHistorySnapshot,
16303
17589
  parseLottieJson,
16304
17590
  preloadGoogleFont,
@@ -16316,12 +17602,17 @@ export {
16316
17602
  removeKeyframe,
16317
17603
  removeTemplateKeyframe,
16318
17604
  removeTrack,
17605
+ renderCanonicalToCanvas,
17606
+ renderEvaluatedSceneToCanvas,
16319
17607
  renderPngSequence,
16320
17608
  renderSceneWebM,
16321
17609
  renderTextEffectCore,
17610
+ renderTextEffectToCanvas,
17611
+ renderTextTemplateToCanvas,
16322
17612
  resetFontLoader,
16323
17613
  resetSceneTime,
16324
17614
  resizeCharFillColors,
17615
+ resolveAnchorPosition,
16325
17616
  resolveAnimatedScalar,
16326
17617
  resolveBehaviorToAnimationSpec,
16327
17618
  resolveConform,
@@ -16331,6 +17622,8 @@ export {
16331
17622
  resolveMediaLayout,
16332
17623
  resolveNodeForBreakpoint,
16333
17624
  resolveSpatialConstraints,
17625
+ resolveTemplateFontFamily,
17626
+ resolveTextTemplateArtifact,
16334
17627
  restoreLetterSpacing,
16335
17628
  rgbaToComponents,
16336
17629
  rotateCrop,
@@ -16351,7 +17644,9 @@ export {
16351
17644
  smartOverlayRegistry,
16352
17645
  snapEngine,
16353
17646
  snapshotScene,
17647
+ solveSpring,
16354
17648
  sortKeyframes,
17649
+ splitTextContent,
16355
17650
  streamExportFrames,
16356
17651
  supportsCtxFilter,
16357
17652
  supportsLetterSpacing,
@@ -16380,6 +17675,7 @@ export {
16380
17675
  validateTextEffectDefinition,
16381
17676
  validateTextEffectDefinitionStrict,
16382
17677
  validateTextTemplate,
17678
+ validateTextTemplateArtifact,
16383
17679
  validateTextTemplateStrict,
16384
17680
  viewportTransform,
16385
17681
  waitForFontsReady,