@clypra-studio/engine 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{chunk-E6O6LZME.js → chunk-7ORA5BPW.js} +14 -299
  2. package/dist/chunk-7ORA5BPW.js.map +1 -0
  3. package/dist/chunk-NG4F55V7.js +300 -0
  4. package/dist/chunk-NG4F55V7.js.map +1 -0
  5. package/dist/chunk-Q7XYDP4X.js +1898 -0
  6. package/dist/chunk-Q7XYDP4X.js.map +1 -0
  7. package/dist/{chunk-3UEOLDJJ.js → chunk-SH7HOGVX.js} +1 -1
  8. package/dist/chunk-SH7HOGVX.js.map +1 -0
  9. package/dist/index-B1lFl4p2.d.ts +122 -0
  10. package/dist/index-Cpps1DKP.d.ts +489 -0
  11. package/dist/index-DrzRbR7G.d.cts +122 -0
  12. package/dist/index-WsvrOpAy.d.cts +489 -0
  13. package/dist/index.cjs +3131 -482
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +185 -103
  16. package/dist/index.d.ts +185 -103
  17. package/dist/index.js +1599 -792
  18. package/dist/index.js.map +1 -1
  19. package/dist/rendering/index.cjs +3694 -0
  20. package/dist/rendering/index.cjs.map +1 -0
  21. package/dist/rendering/index.d.cts +2 -0
  22. package/dist/rendering/index.d.ts +2 -0
  23. package/dist/rendering/index.js +21 -0
  24. package/dist/rendering/index.js.map +1 -0
  25. package/dist/textEffects/index.cjs +13 -5
  26. package/dist/textEffects/index.cjs.map +1 -1
  27. package/dist/textEffects/index.d.cts +2 -1
  28. package/dist/textEffects/index.d.ts +2 -1
  29. package/dist/textEffects/index.js +6 -4
  30. package/dist/{index-C18SQ-y6.d.cts → types-IYwXGYkB.d.cts} +141 -129
  31. package/dist/{index-C18SQ-y6.d.ts → types-IYwXGYkB.d.ts} +141 -129
  32. package/dist/videoEffects/index.cjs.map +1 -1
  33. package/dist/videoEffects/index.js +1 -1
  34. package/package.json +6 -1
  35. package/dist/chunk-3UEOLDJJ.js.map +0 -1
  36. package/dist/chunk-E6O6LZME.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,3 +1,65 @@
1
+ import {
2
+ FontLoader,
3
+ checkFontVariant,
4
+ ensureFontsLoaded,
5
+ getFontLoader,
6
+ initializeFontSystem,
7
+ injectFontVariantRules,
8
+ resetFontLoader
9
+ } from "./chunk-NG4F55V7.js";
10
+ import {
11
+ ALL_TRANSITIONS,
12
+ TRANSITION_CATEGORIES,
13
+ TRANSITION_PRESETS,
14
+ TransitionRenderer,
15
+ getAllTransitionTags,
16
+ getAllTransitions,
17
+ getRecommendedDuration,
18
+ getTransitionById,
19
+ getTransitionByRenderer,
20
+ getTransitionCategories,
21
+ getTransitionCountByCategory,
22
+ getTransitionsByCategory,
23
+ getTransitionsByTags,
24
+ searchTransitions
25
+ } from "./chunk-PU3Q4QI7.js";
26
+ import {
27
+ CANONICAL_RENDERER_VERSION,
28
+ CANONICAL_SCHEMA_VERSION,
29
+ TEXT_TEMPLATE_KIND,
30
+ TEXT_TEMPLATE_RENDERER_VERSION,
31
+ TEXT_TEMPLATE_SCHEMA_VERSION,
32
+ addKeyframe,
33
+ applyEasing,
34
+ assertValidTextTemplateArtifact,
35
+ canonicalContentHash,
36
+ canonicalTemplateHash,
37
+ canonicalizeSceneDocument,
38
+ compileTextTemplate,
39
+ createKeyframed,
40
+ cubicBezier,
41
+ evaluateAnimatable,
42
+ evaluateSplitTextTransforms,
43
+ evaluateTextEffect,
44
+ evaluateTextTemplate,
45
+ getRenderCapabilities,
46
+ getSpanForCharIndex,
47
+ getTextTemplateControls,
48
+ interpolateColorString,
49
+ interpolateValue,
50
+ isKeyframed,
51
+ normalizeTextEffect,
52
+ normalizeTextTemplate,
53
+ normalizeTextTemplateArtifact,
54
+ removeTemplateKeyframe,
55
+ renderCanonicalToCanvas,
56
+ renderTextEffectToCanvas,
57
+ renderTextTemplateToCanvas,
58
+ resolveTextTemplateArtifact,
59
+ solveSpring,
60
+ splitTextContent,
61
+ validateTextTemplateArtifact
62
+ } from "./chunk-Q7XYDP4X.js";
1
63
  import {
2
64
  COMPOSITION_PRESETS,
3
65
  CanvasDevice,
@@ -6,7 +68,6 @@ import {
6
68
  DEFAULT_DURATION,
7
69
  DEFAULT_FONT_SIZE,
8
70
  DEFAULT_FPS,
9
- FontLoader,
10
71
  SCENE_SCHEMA_VERSION,
11
72
  SCENE_VERSION,
12
73
  TextEffectRenderer,
@@ -18,7 +79,6 @@ import {
18
79
  applyMaskReveal,
19
80
  applyTimelineAtTime,
20
81
  builtInPresets,
21
- checkFontVariant,
22
82
  cloneSceneWithNewIds,
23
83
  computeAutoFitFontSize,
24
84
  computeFitZoom,
@@ -34,13 +94,9 @@ import {
34
94
  drawRoundedRect,
35
95
  ease,
36
96
  ensureDefaultTimeline,
37
- ensureFontsLoaded,
38
97
  evaluateConfig,
39
98
  evaluateScene,
40
- getFontLoader,
41
99
  getSceneTime,
42
- initializeFontSystem,
43
- injectFontVariantRules,
44
100
  layerToTextEffectConfig,
45
101
  measureTextFits,
46
102
  mergeSceneIntoConfig,
@@ -48,7 +104,6 @@ import {
48
104
  rainbowCharFillColors,
49
105
  releaseCanvas,
50
106
  renderTextEffectCore,
51
- resetFontLoader,
52
107
  resetSceneTime,
53
108
  resizeCharFillColors,
54
109
  resolveAnimatedScalar,
@@ -65,23 +120,7 @@ import {
65
120
  syncCompositorFromScene,
66
121
  textEffectConfigToScene,
67
122
  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";
123
+ } from "./chunk-7ORA5BPW.js";
85
124
  import {
86
125
  EFFECTS_REGISTRY,
87
126
  EffectEngine,
@@ -107,7 +146,7 @@ import {
107
146
  searchEffects,
108
147
  searchEffectsForApi,
109
148
  withContext
110
- } from "./chunk-3UEOLDJJ.js";
149
+ } from "./chunk-SH7HOGVX.js";
111
150
  import "./chunk-PZ5AY32C.js";
112
151
 
113
152
  // src/validation.ts
@@ -594,16 +633,16 @@ function reindexLayers(lottieData) {
594
633
  });
595
634
  }
596
635
  function addSolidLayer(lottieData, name, color, w, h) {
597
- const clone2 = JSON.parse(JSON.stringify(lottieData));
598
- if (!Array.isArray(clone2.layers)) clone2.layers = [];
636
+ const clone = JSON.parse(JSON.stringify(lottieData));
637
+ if (!Array.isArray(clone.layers)) clone.layers = [];
599
638
  const newLayer = {
600
639
  ty: 1,
601
640
  nm: name,
602
641
  sr: 1,
603
642
  st: 0,
604
643
  ip: 0,
605
- op: clone2.op,
606
- ind: clone2.layers.length + 1,
644
+ op: clone.op,
645
+ ind: clone.layers.length + 1,
607
646
  sw: w,
608
647
  sh: h,
609
648
  sc: color,
@@ -616,23 +655,23 @@ function addSolidLayer(lottieData, name, color, w, h) {
616
655
  o: { a: 0, k: 100 }
617
656
  }
618
657
  };
619
- clone2.layers.push(newLayer);
620
- reindexLayers(clone2);
621
- return clone2;
658
+ clone.layers.push(newLayer);
659
+ reindexLayers(clone);
660
+ return clone;
622
661
  }
623
662
  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;
663
+ const clone = JSON.parse(JSON.stringify(lottieData));
664
+ if (!Array.isArray(clone.layers)) clone.layers = [];
665
+ const w = clone.w || 1920;
666
+ const h = clone.h || 1080;
628
667
  const newLayer = {
629
668
  ty: 5,
630
669
  nm: name,
631
670
  sr: 1,
632
671
  st: 0,
633
672
  ip: 0,
634
- op: clone2.op,
635
- ind: clone2.layers.length + 1,
673
+ op: clone.op,
674
+ ind: clone.layers.length + 1,
636
675
  ks: {
637
676
  a: { a: 0, k: [0, 0, 0] },
638
677
  p: { a: 0, k: [w / 2, h / 2, 0] },
@@ -674,23 +713,23 @@ function addTextLayer(lottieData, name, text) {
674
713
  }
675
714
  }
676
715
  };
677
- clone2.layers.unshift(newLayer);
678
- reindexLayers(clone2);
679
- return clone2;
716
+ clone.layers.unshift(newLayer);
717
+ reindexLayers(clone);
718
+ return clone;
680
719
  }
681
720
  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;
721
+ const clone = JSON.parse(JSON.stringify(lottieData));
722
+ if (!Array.isArray(clone.layers)) clone.layers = [];
723
+ const w = clone.w || 1920;
724
+ const h = clone.h || 1080;
686
725
  const newLayer = {
687
726
  ty: 4,
688
727
  nm: name,
689
728
  sr: 1,
690
729
  st: 0,
691
730
  ip: 0,
692
- op: clone2.op,
693
- ind: clone2.layers.length + 1,
731
+ op: clone.op,
732
+ ind: clone.layers.length + 1,
694
733
  ks: {
695
734
  a: { a: 0, k: [0, 0, 0] },
696
735
  p: { a: 0, k: [w / 2, h / 2, 0] },
@@ -700,14 +739,14 @@ function addShapeLayer(lottieData, name) {
700
739
  },
701
740
  shapes: []
702
741
  };
703
- clone2.layers.unshift(newLayer);
704
- reindexLayers(clone2);
705
- return clone2;
742
+ clone.layers.unshift(newLayer);
743
+ reindexLayers(clone);
744
+ return clone;
706
745
  }
707
746
  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;
747
+ const clone = JSON.parse(JSON.stringify(lottieData));
748
+ const layer = clone.layers[layerIndex];
749
+ if (!layer || layer.ty !== 4) return clone;
711
750
  if (!Array.isArray(layer.shapes)) layer.shapes = [];
712
751
  const cleanHex = colorHex.startsWith("#") ? colorHex.slice(1) : colorHex;
713
752
  const r = parseInt(cleanHex.slice(0, 2), 16) / 255 || 0.5;
@@ -781,7 +820,7 @@ function addVectorShape(lottieData, layerIndex, shapeType, colorHex) {
781
820
  };
782
821
  }
783
822
  layer.shapes.push(shapeContent);
784
- return clone2;
823
+ return clone;
785
824
  }
786
825
  function getProperty(layer, path) {
787
826
  if (!layer) return null;
@@ -794,9 +833,9 @@ function getProperty(layer, path) {
794
833
  return current;
795
834
  }
796
835
  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;
836
+ const clone = JSON.parse(JSON.stringify(lottieData));
837
+ const layer = clone.layers[layerIndex];
838
+ if (!layer) return clone;
800
839
  const propObj = getProperty(layer, path);
801
840
  if (propObj) {
802
841
  propObj.a = 0;
@@ -806,7 +845,7 @@ function updateStaticProperty(lottieData, layerIndex, path, value) {
806
845
  propObj.k = value;
807
846
  }
808
847
  }
809
- return clone2;
848
+ return clone;
810
849
  }
811
850
  var EASING_CURVES = {
812
851
  linear: {
@@ -827,9 +866,9 @@ var EASING_CURVES = {
827
866
  }
828
867
  };
829
868
  function enableKeyframing(lottieData, layerIndex, path) {
830
- const clone2 = JSON.parse(JSON.stringify(lottieData));
831
- const layer = clone2.layers[layerIndex];
832
- if (!layer) return clone2;
869
+ const clone = JSON.parse(JSON.stringify(lottieData));
870
+ const layer = clone.layers[layerIndex];
871
+ if (!layer) return clone;
833
872
  const propObj = getProperty(layer, path);
834
873
  if (propObj && propObj.a === 0) {
835
874
  const staticValue = propObj.k;
@@ -843,14 +882,14 @@ function enableKeyframing(lottieData, layerIndex, path) {
843
882
  }
844
883
  ];
845
884
  }
846
- return clone2;
885
+ return clone;
847
886
  }
848
887
  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;
888
+ const clone = JSON.parse(JSON.stringify(lottieData));
889
+ const layer = clone.layers[layerIndex];
890
+ if (!layer) return clone;
852
891
  const propObj = getProperty(layer, path);
853
- if (!propObj) return clone2;
892
+ if (!propObj) return clone;
854
893
  if (propObj.a === 0) {
855
894
  propObj.a = 1;
856
895
  propObj.k = [
@@ -891,14 +930,14 @@ function addOrUpdateKeyframe(lottieData, layerIndex, path, frame, value, easing
891
930
  kf2.o = kf2.o || curves.o;
892
931
  }
893
932
  });
894
- return clone2;
933
+ return clone;
895
934
  }
896
935
  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;
936
+ const clone = JSON.parse(JSON.stringify(lottieData));
937
+ const layer = clone.layers[layerIndex];
938
+ if (!layer) return clone;
900
939
  const propObj = getProperty(layer, path);
901
- if (!propObj || propObj.a === 0) return clone2;
940
+ if (!propObj || propObj.a === 0) return clone;
902
941
  let keyframes = propObj.k;
903
942
  keyframes = keyframes.filter((kf2) => kf2.t !== frame);
904
943
  if (keyframes.length === 0) {
@@ -913,14 +952,14 @@ function deleteKeyframe(lottieData, layerIndex, path, frame) {
913
952
  }
914
953
  });
915
954
  }
916
- return clone2;
955
+ return clone;
917
956
  }
918
957
  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 = [];
958
+ const clone = JSON.parse(JSON.stringify(lottieData));
959
+ if (!Array.isArray(clone.assets)) clone.assets = [];
960
+ if (!Array.isArray(clone.layers)) clone.layers = [];
922
961
  const assetId = `img_${Date.now()}`;
923
- clone2.assets.push({
962
+ clone.assets.push({
924
963
  id: assetId,
925
964
  w,
926
965
  h,
@@ -929,8 +968,8 @@ function addImageLayer(lottieData, name, base64Data, w, h) {
929
968
  // data:image/png;base64,...
930
969
  e: 1
931
970
  });
932
- const compW = clone2.w || 1920;
933
- const compH = clone2.h || 1080;
971
+ const compW = clone.w || 1920;
972
+ const compH = clone.h || 1080;
934
973
  const newLayer = {
935
974
  ty: 2,
936
975
  nm: name,
@@ -938,8 +977,8 @@ function addImageLayer(lottieData, name, base64Data, w, h) {
938
977
  sr: 1,
939
978
  st: 0,
940
979
  ip: 0,
941
- op: clone2.op,
942
- ind: clone2.layers.length + 1,
980
+ op: clone.op,
981
+ ind: clone.layers.length + 1,
943
982
  ks: {
944
983
  a: { a: 0, k: [w / 2, h / 2, 0] },
945
984
  p: { a: 0, k: [compW / 2, compH / 2, 0] },
@@ -948,20 +987,20 @@ function addImageLayer(lottieData, name, base64Data, w, h) {
948
987
  o: { a: 0, k: 100 }
949
988
  }
950
989
  };
951
- clone2.layers.unshift(newLayer);
952
- reindexLayers(clone2);
953
- return clone2;
990
+ clone.layers.unshift(newLayer);
991
+ reindexLayers(clone);
992
+ return clone;
954
993
  }
955
994
  function updateTrackMatte(lottieData, layerIndex, matteType) {
956
- const clone2 = JSON.parse(JSON.stringify(lottieData));
957
- const layer = clone2.layers[layerIndex];
958
- if (!layer) return clone2;
995
+ const clone = JSON.parse(JSON.stringify(lottieData));
996
+ const layer = clone.layers[layerIndex];
997
+ if (!layer) return clone;
959
998
  if (matteType === 0) {
960
999
  delete layer.tt;
961
1000
  } else {
962
1001
  layer.tt = matteType;
963
1002
  }
964
- return clone2;
1003
+ return clone;
965
1004
  }
966
1005
 
967
1006
  // src/engine/lottieParser.ts
@@ -1088,9 +1127,9 @@ function traverseAllLayers(lottieData, fn) {
1088
1127
  }
1089
1128
  function injectText(lottieData, customization, textLayers) {
1090
1129
  if (!lottieData) return lottieData;
1091
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1130
+ const clone = JSON.parse(JSON.stringify(lottieData));
1092
1131
  const configMap = new Map(textLayers.map((l) => [l.layerName, l]));
1093
- traverseAllLayers(clone2, (layer) => {
1132
+ traverseAllLayers(clone, (layer) => {
1094
1133
  if (layer.ty !== 5) return;
1095
1134
  const config = configMap.get(layer.nm);
1096
1135
  if (!config) return;
@@ -1098,29 +1137,29 @@ function injectText(lottieData, customization, textLayers) {
1098
1137
  const text = raw.slice(0, config.maxCharacters);
1099
1138
  mutateTextLayer(layer, { text });
1100
1139
  });
1101
- return clone2;
1140
+ return clone;
1102
1141
  }
1103
1142
  function injectTextStyle(lottieData, layerName, override) {
1104
1143
  if (!lottieData) return lottieData;
1105
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1106
- traverseAllLayers(clone2, (layer) => {
1144
+ const clone = JSON.parse(JSON.stringify(lottieData));
1145
+ traverseAllLayers(clone, (layer) => {
1107
1146
  if (layer.ty !== 5 || layer.nm !== layerName) return;
1108
1147
  mutateTextLayer(layer, override);
1109
1148
  });
1110
- return clone2;
1149
+ return clone;
1111
1150
  }
1112
1151
  function injectGlobalTextStyle(lottieData, override) {
1113
1152
  if (!lottieData) return lottieData;
1114
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1115
- traverseAllLayers(clone2, (layer) => {
1153
+ const clone = JSON.parse(JSON.stringify(lottieData));
1154
+ traverseAllLayers(clone, (layer) => {
1116
1155
  if (layer.ty !== 5) return;
1117
1156
  mutateTextLayer(layer, override);
1118
1157
  });
1119
- return clone2;
1158
+ return clone;
1120
1159
  }
1121
1160
  function injectColor(lottieData, layerName, hexColor) {
1122
1161
  if (!lottieData || !layerName) return lottieData;
1123
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1162
+ const clone = JSON.parse(JSON.stringify(lottieData));
1124
1163
  const targetRgb = hexToLottieRgb(hexColor);
1125
1164
  function traverseShapes(obj) {
1126
1165
  if (!obj || typeof obj !== "object") return;
@@ -1140,33 +1179,33 @@ function injectColor(lottieData, layerName, hexColor) {
1140
1179
  else if (val && typeof val === "object") traverseShapes(val);
1141
1180
  }
1142
1181
  }
1143
- traverseAllLayers(clone2, (layer) => {
1182
+ traverseAllLayers(clone, (layer) => {
1144
1183
  if (layer.nm === layerName) traverseShapes(layer);
1145
1184
  });
1146
- return clone2;
1185
+ return clone;
1147
1186
  }
1148
1187
  function injectSolidColor(lottieData, layerName, hexColor) {
1149
1188
  if (!lottieData) return lottieData;
1150
- const clone2 = JSON.parse(JSON.stringify(lottieData));
1151
- traverseAllLayers(clone2, (layer) => {
1189
+ const clone = JSON.parse(JSON.stringify(lottieData));
1190
+ traverseAllLayers(clone, (layer) => {
1152
1191
  if (layer.ty === 1 && layer.nm === layerName) {
1153
1192
  layer.sc = hexColor;
1154
1193
  }
1155
1194
  });
1156
- return clone2;
1195
+ return clone;
1157
1196
  }
1158
1197
  function injectBatch(lottieData, batch) {
1159
1198
  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) => {
1199
+ let clone = JSON.parse(JSON.stringify(lottieData));
1200
+ if (batch.hiddenLayers && Array.isArray(clone.layers)) {
1201
+ clone.layers.forEach((layer, idx) => {
1163
1202
  layer.hd = batch.hiddenLayers.has(idx);
1164
1203
  });
1165
1204
  }
1166
1205
  if (batch.textCustomization) {
1167
1206
  const { customization, layers } = batch.textCustomization;
1168
1207
  const configMap = new Map(layers.map((l) => [l.layerName, l]));
1169
- traverseAllLayers(clone2, (layer) => {
1208
+ traverseAllLayers(clone, (layer) => {
1170
1209
  if (layer.ty !== 5) return;
1171
1210
  const config = configMap.get(layer.nm);
1172
1211
  if (!config) return;
@@ -1176,7 +1215,7 @@ function injectBatch(lottieData, batch) {
1176
1215
  }
1177
1216
  if (batch.styleOverrides) {
1178
1217
  const styleMap = new Map(batch.styleOverrides.map((s) => [s.layerName, s.override]));
1179
- traverseAllLayers(clone2, (layer) => {
1218
+ traverseAllLayers(clone, (layer) => {
1180
1219
  if (layer.ty !== 5) return;
1181
1220
  const override = styleMap.get(layer.nm);
1182
1221
  if (override) mutateTextLayer(layer, override);
@@ -1184,15 +1223,15 @@ function injectBatch(lottieData, batch) {
1184
1223
  }
1185
1224
  if (batch.colorOverrides) {
1186
1225
  for (const { layerName, color } of batch.colorOverrides) {
1187
- clone2 = injectColor(clone2, layerName, color);
1226
+ clone = injectColor(clone, layerName, color);
1188
1227
  }
1189
1228
  }
1190
1229
  if (batch.solidOverrides) {
1191
1230
  for (const { layerName, color } of batch.solidOverrides) {
1192
- clone2 = injectSolidColor(clone2, layerName, color);
1231
+ clone = injectSolidColor(clone, layerName, color);
1193
1232
  }
1194
1233
  }
1195
- return clone2;
1234
+ return clone;
1196
1235
  }
1197
1236
 
1198
1237
  // src/engine/lottieTextAnimations.ts
@@ -1692,9 +1731,9 @@ function getAnimPreset(id) {
1692
1731
  return LOTTIE_ANIM_PRESETS.find((p) => p.id === id);
1693
1732
  }
1694
1733
  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;
1734
+ const clone = JSON.parse(JSON.stringify(lottieData));
1735
+ const layer = clone.layers?.[layerIndex];
1736
+ if (!layer) return clone;
1698
1737
  const tracks = preset.buildTracks({ ...opts, layerIndex });
1699
1738
  for (const track of tracks) {
1700
1739
  const keys = track.path.split(".");
@@ -1726,12 +1765,12 @@ function bakeAnimationIntoLayer(lottieData, layerIndex, preset, opts) {
1726
1765
  });
1727
1766
  prop.k = existing;
1728
1767
  }
1729
- return clone2;
1768
+ return clone;
1730
1769
  }
1731
1770
  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;
1771
+ const clone = JSON.parse(JSON.stringify(lottieData));
1772
+ const layer = clone.layers?.[layerIndex];
1773
+ if (!layer) return clone;
1735
1774
  for (const path of paths) {
1736
1775
  const keys = path.split(".");
1737
1776
  let prop = layer;
@@ -1747,7 +1786,7 @@ function clearAnimationFromLayer(lottieData, layerIndex, paths = ["ks.p", "ks.s"
1747
1786
  }
1748
1787
  }
1749
1788
  }
1750
- return clone2;
1789
+ return clone;
1751
1790
  }
1752
1791
 
1753
1792
  // src/engine/lottieTextStyle.ts
@@ -1883,9 +1922,9 @@ function readStyleFromLottieLayer(layer) {
1883
1922
  return style;
1884
1923
  }
1885
1924
  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 || {};
1925
+ const clone = JSON.parse(JSON.stringify(layer));
1926
+ if (!clone || clone.ty !== 5) return clone;
1927
+ const ks = clone.ks || {};
1889
1928
  if (ks.p) {
1890
1929
  if (ks.p.a === 0) {
1891
1930
  const base = Array.isArray(ks.p.k) ? ks.p.k : [0, 0, 0];
@@ -1903,9 +1942,9 @@ function applyStyleToLottieLayer(layer, style) {
1903
1942
  if (ks.o) {
1904
1943
  if (ks.o.a === 0) ks.o.k = style.opacity;
1905
1944
  }
1906
- clone2.ks = ks;
1907
- const td = clone2.t?.d;
1908
- if (!td) return clone2;
1945
+ clone.ks = ks;
1946
+ const td = clone.t?.d;
1947
+ if (!td) return clone;
1909
1948
  const applyToDoc = (doc) => {
1910
1949
  if (!doc) return;
1911
1950
  doc.s = style.fontSize;
@@ -1929,21 +1968,21 @@ function applyStyleToLottieLayer(layer, style) {
1929
1968
  } else if (td.k?.s) {
1930
1969
  applyToDoc(td.k.s);
1931
1970
  }
1932
- return clone2;
1971
+ return clone;
1933
1972
  }
1934
1973
  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;
1974
+ const clone = JSON.parse(JSON.stringify(lottieData));
1975
+ if (!clone.layers?.[layerIndex]) return clone;
1976
+ clone.layers[layerIndex] = applyStyleToLottieLayer(clone.layers[layerIndex], style);
1977
+ return clone;
1939
1978
  }
1940
1979
  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;
1980
+ const clone = JSON.parse(JSON.stringify(lottieData));
1981
+ if (!clone.fonts) clone.fonts = { list: [] };
1982
+ if (!Array.isArray(clone.fonts.list)) clone.fonts.list = [];
1983
+ const exists = clone.fonts.list.some((f) => f.fName === entry.fName);
1984
+ if (!exists) clone.fonts.list.push(entry);
1985
+ return clone;
1947
1986
  }
1948
1987
  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
1988
  var FONT_WEIGHT_OPTIONS = [
@@ -1981,7 +2020,7 @@ function hex2lottie(hex) {
1981
2020
  return [parseInt(c.slice(0, 2), 16) / 255, parseInt(c.slice(2, 4), 16) / 255, parseInt(c.slice(4, 6), 16) / 255];
1982
2021
  }
1983
2022
  function applyTextDoc(layer, opts) {
1984
- const clone2 = JSON.parse(JSON.stringify(layer));
2023
+ const clone = JSON.parse(JSON.stringify(layer));
1985
2024
  const applyDoc = (doc) => {
1986
2025
  doc.t = opts.text;
1987
2026
  doc.f = opts.font;
@@ -1995,22 +2034,22 @@ function applyTextDoc(layer, opts) {
1995
2034
  doc.sw = opts.strokeWidth;
1996
2035
  }
1997
2036
  };
1998
- const td = clone2.t?.d;
1999
- if (!td) return clone2;
2037
+ const td = clone.t?.d;
2038
+ if (!td) return clone;
2000
2039
  if (Array.isArray(td.k))
2001
2040
  td.k.forEach((kf2) => {
2002
2041
  if (kf2?.s) applyDoc(kf2.s);
2003
2042
  });
2004
2043
  else if (td.k?.s) applyDoc(td.k.s);
2005
- return clone2;
2044
+ return clone;
2006
2045
  }
2007
2046
  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;
2047
+ const clone = JSON.parse(JSON.stringify(layer));
2048
+ if (clone.ks?.p?.a === 0) clone.ks.p.k = [x, y, 0];
2049
+ return clone;
2011
2050
  }
2012
2051
  function addRoundedRect(lottie, name, cx, cy, w, h, r, color) {
2013
- let clone2 = JSON.parse(JSON.stringify(lottie));
2052
+ let clone = JSON.parse(JSON.stringify(lottie));
2014
2053
  const [cr, cg, cb] = hex2lottie(color);
2015
2054
  const shapeLayer = {
2016
2055
  ty: 4,
@@ -2018,7 +2057,7 @@ function addRoundedRect(lottie, name, cx, cy, w, h, r, color) {
2018
2057
  sr: 1,
2019
2058
  st: 0,
2020
2059
  ip: 0,
2021
- op: clone2.op,
2060
+ op: clone.op,
2022
2061
  ind: 1,
2023
2062
  ks: {
2024
2063
  a: { a: 0, k: [0, 0, 0] },
@@ -2039,9 +2078,9 @@ function addRoundedRect(lottie, name, cx, cy, w, h, r, color) {
2039
2078
  }
2040
2079
  ]
2041
2080
  };
2042
- clone2.layers.push(shapeLayer);
2043
- reindexLayers(clone2);
2044
- return clone2;
2081
+ clone.layers.push(shapeLayer);
2082
+ reindexLayers(clone);
2083
+ return clone;
2045
2084
  }
2046
2085
  function buildCleanLowerThird() {
2047
2086
  let l = createBlankLottie(1920, 1080, 30, 120);
@@ -2649,8 +2688,8 @@ function quantizeTopalette(pixels, maxColors) {
2649
2688
  function mapPixelsToPalette(pixels, palette, transparentIndex) {
2650
2689
  const indices = new Uint8Array(pixels.length / 4);
2651
2690
  for (let i = 0; i < pixels.length; i += 4) {
2652
- const alpha = pixels[i + 3];
2653
- if (alpha < 128) {
2691
+ const alpha2 = pixels[i + 3];
2692
+ if (alpha2 < 128) {
2654
2693
  indices[i / 4] = transparentIndex;
2655
2694
  continue;
2656
2695
  }
@@ -4258,448 +4297,73 @@ var TextEffectBuilder = class _TextEffectBuilder {
4258
4297
  }
4259
4298
  };
4260
4299
 
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;
4300
+ // src/templates/responsiveLayout.ts
4301
+ function resolveAnchorPosition(anchor, currentBounds, canvasWidth, canvasHeight) {
4302
+ if (!anchor) {
4303
+ return currentBounds;
4304
+ }
4305
+ let { width, height } = currentBounds;
4306
+ if (anchor.maxWidthPercentage && anchor.maxWidthPercentage > 0) {
4307
+ const maxW = canvasWidth * anchor.maxWidthPercentage / 100;
4308
+ if (width > maxW) {
4309
+ width = maxW;
4310
+ }
4311
+ }
4312
+ const point = anchor.anchorPoint || "center";
4313
+ const pctX = (anchor.offsetPercentageX ?? 0) / 100;
4314
+ const pctY = (anchor.offsetPercentageY ?? 0) / 100;
4315
+ const pxX = anchor.pixelOffsetX ?? 0;
4316
+ const pxY = anchor.pixelOffsetY ?? 0;
4317
+ let x = currentBounds.x;
4318
+ let y = currentBounds.y;
4319
+ switch (point) {
4320
+ case "top-left":
4321
+ x = canvasWidth * pctX + pxX;
4322
+ y = canvasHeight * pctY + pxY;
4323
+ break;
4324
+ case "top-center":
4325
+ x = canvasWidth / 2 - width / 2 + canvasWidth * pctX + pxX;
4326
+ y = canvasHeight * pctY + pxY;
4327
+ break;
4328
+ case "top-right":
4329
+ x = canvasWidth - width - canvasWidth * pctX + pxX;
4330
+ y = canvasHeight * pctY + pxY;
4331
+ break;
4332
+ case "middle-left":
4333
+ x = canvasWidth * pctX + pxX;
4334
+ y = canvasHeight / 2 - height / 2 + canvasHeight * pctY + pxY;
4335
+ break;
4336
+ case "center":
4337
+ x = canvasWidth / 2 - width / 2 + canvasWidth * pctX + pxX;
4338
+ y = canvasHeight / 2 - height / 2 + canvasHeight * pctY + pxY;
4339
+ break;
4340
+ case "middle-right":
4341
+ x = canvasWidth - width - canvasWidth * pctX + pxX;
4342
+ y = canvasHeight / 2 - height / 2 + canvasHeight * pctY + pxY;
4343
+ break;
4344
+ case "bottom-left":
4345
+ x = canvasWidth * pctX + pxX;
4346
+ y = canvasHeight - height - canvasHeight * pctY + pxY;
4347
+ break;
4348
+ case "bottom-center":
4349
+ x = canvasWidth / 2 - width / 2 + canvasWidth * pctX + pxX;
4350
+ y = canvasHeight - height - canvasHeight * pctY + pxY;
4351
+ break;
4352
+ case "bottom-right":
4353
+ x = canvasWidth - width - canvasWidth * pctX + pxX;
4354
+ y = canvasHeight - height - canvasHeight * pctY + pxY;
4287
4355
  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
4356
  }
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];
4357
+ return { x, y, width, height };
4686
4358
  }
4359
+ var ASPECT_RATIO_PRESETS = {
4360
+ "16:9": { width: 1920, height: 1080, label: "16:9 Widescreen (1920x1080)" },
4361
+ "9:16": { width: 1080, height: 1920, label: "9:16 Vertical (1080x1920)" },
4362
+ "1:1": { width: 1080, height: 1080, label: "1:1 Square (1080x1080)" },
4363
+ "4:5": { width: 1080, height: 1350, label: "4:5 Social (1080x1350)" }
4364
+ };
4687
4365
 
4688
4366
  // 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
4367
  var TemplateRenderer = class {
4704
4368
  template;
4705
4369
  editedValues;
@@ -4708,6 +4372,7 @@ var TemplateRenderer = class {
4708
4372
  currentTime = 0;
4709
4373
  // Track current time for keyframe evaluation
4710
4374
  lastLayerLayouts = /* @__PURE__ */ new Map();
4375
+ computedFlexLayouts = /* @__PURE__ */ new Map();
4711
4376
  constructor(template) {
4712
4377
  this.template = normalizeTextTemplate(template);
4713
4378
  this.editedValues = /* @__PURE__ */ new Map();
@@ -4718,7 +4383,10 @@ var TemplateRenderer = class {
4718
4383
  }
4719
4384
  updateLayer(layerId, changes) {
4720
4385
  const existing = this.editedValues.get(layerId) ?? {};
4721
- this.editedValues.set(layerId, { ...existing, ...changes });
4386
+ this.editedValues.set(layerId, {
4387
+ ...existing,
4388
+ ...changes
4389
+ });
4722
4390
  }
4723
4391
  getLayerLayout(layerId) {
4724
4392
  return this.lastLayerLayouts.get(layerId) ?? null;
@@ -4737,7 +4405,11 @@ var TemplateRenderer = class {
4737
4405
  evaluateTextDimension(layer, prop) {
4738
4406
  const value = layer[prop];
4739
4407
  if (value === "auto") return "auto";
4740
- return evaluateAnimatable(value, this.currentTime, this.template.duration);
4408
+ return evaluateAnimatable(
4409
+ value,
4410
+ this.currentTime,
4411
+ this.template.duration
4412
+ );
4741
4413
  }
4742
4414
  // Compute animation parameters (transforms, opacity, scale, typewriter, etc.)
4743
4415
  computeTransform(layer, time) {
@@ -4801,12 +4473,47 @@ var TemplateRenderer = class {
4801
4473
  case "typewriter":
4802
4474
  typewriterProgress = p;
4803
4475
  break;
4476
+ case "3d-flip":
4477
+ opacity = p;
4478
+ scale = 0.6 + p * 0.4;
4479
+ y = (1 - p) * 25;
4480
+ break;
4481
+ case "scale-pop":
4482
+ opacity = p;
4483
+ scale = p < 0.7 ? p / 0.7 * 1.15 : 1.15 - (p - 0.7) / 0.3 * 0.15;
4484
+ break;
4485
+ case "track-in":
4486
+ opacity = p;
4487
+ blur = (1 - p) * 8;
4488
+ break;
4489
+ case "wave":
4490
+ opacity = p;
4491
+ y = Math.sin(p * Math.PI) * -15;
4492
+ break;
4493
+ case "glitch":
4494
+ opacity = p > 0.05 ? 1 : 0;
4495
+ x = Math.sin(p * 25) * 6 * (1 - p);
4496
+ break;
4804
4497
  case "none":
4805
4498
  default:
4806
4499
  break;
4807
4500
  }
4808
4501
  return { opacity, x, y, scale, blur, typewriterProgress };
4809
4502
  }
4503
+ /** Resolve dynamic {{variable}} tokens in string content */
4504
+ resolveDynamicContent(rawContent) {
4505
+ if (!rawContent || !rawContent.includes("{{")) return rawContent;
4506
+ const vars = this.template.variables || {};
4507
+ return rawContent.replace(/\{\{([^}]+)\}\}/g, (_, key) => {
4508
+ const trimmed = key.trim();
4509
+ const override = this.template.variableValues?.[trimmed];
4510
+ if (override !== void 0) return String(override);
4511
+ const def = vars[trimmed];
4512
+ if (def && def.defaultValue !== void 0)
4513
+ return String(def.defaultValue);
4514
+ return `{{${trimmed}}}`;
4515
+ });
4516
+ }
4810
4517
  drawFrame(ctx, time, fitToContentOrOpts = false) {
4811
4518
  const fitToContent = typeof fitToContentOrOpts === "boolean" ? fitToContentOrOpts : !!fitToContentOrOpts?.fitToContent;
4812
4519
  const skipClear = typeof fitToContentOrOpts === "object" ? !!fitToContentOrOpts?.skipClear : false;
@@ -4819,15 +4526,26 @@ var TemplateRenderer = class {
4819
4526
  const bounds = this.getContentBounds();
4820
4527
  if (bounds && bounds.width > 0 && bounds.height > 0) {
4821
4528
  if (!skipClear) {
4822
- ctx.clearRect(0, 0, this.template.canvasWidth, this.template.canvasHeight);
4529
+ ctx.clearRect(
4530
+ 0,
4531
+ 0,
4532
+ this.template.canvasWidth,
4533
+ this.template.canvasHeight
4534
+ );
4823
4535
  }
4824
4536
  ctx.save();
4825
4537
  const padding = 0.85;
4826
- const scale = Math.min(this.template.canvasWidth / bounds.width, this.template.canvasHeight / bounds.height) * padding;
4538
+ const scale = Math.min(
4539
+ this.template.canvasWidth / bounds.width,
4540
+ this.template.canvasHeight / bounds.height
4541
+ ) * padding;
4827
4542
  const finalScale = Math.min(3, scale);
4828
4543
  const cx = bounds.x + bounds.width / 2;
4829
4544
  const cy = bounds.y + bounds.height / 2;
4830
- ctx.translate(this.template.canvasWidth / 2, this.template.canvasHeight / 2);
4545
+ ctx.translate(
4546
+ this.template.canvasWidth / 2,
4547
+ this.template.canvasHeight / 2
4548
+ );
4831
4549
  ctx.scale(finalScale, finalScale);
4832
4550
  ctx.translate(-cx, -cy);
4833
4551
  this.drawLayers(ctx, time);
@@ -4836,7 +4554,12 @@ var TemplateRenderer = class {
4836
4554
  }
4837
4555
  }
4838
4556
  if (!skipClear) {
4839
- ctx.clearRect(0, 0, this.template.canvasWidth, this.template.canvasHeight);
4557
+ ctx.clearRect(
4558
+ 0,
4559
+ 0,
4560
+ this.template.canvasWidth,
4561
+ this.template.canvasHeight
4562
+ );
4840
4563
  }
4841
4564
  this.drawLayers(ctx, time);
4842
4565
  }
@@ -4849,6 +4572,7 @@ var TemplateRenderer = class {
4849
4572
  let hasTextLayers = false;
4850
4573
  for (const [layerId, layout] of this.lastLayerLayouts.entries()) {
4851
4574
  const layer = this.template?.layers?.find((l) => l.id === layerId);
4575
+ if (layer && layer.visible === false) continue;
4852
4576
  if (layer && layer.kind === "text") {
4853
4577
  hasTextLayers = true;
4854
4578
  minX = Math.min(minX, layout.x);
@@ -4873,28 +4597,449 @@ var TemplateRenderer = class {
4873
4597
  height: maxY - minY
4874
4598
  };
4875
4599
  }
4600
+ computeFlexLayouts(time) {
4601
+ this.computedFlexLayouts.clear();
4602
+ if (!this.template || !Array.isArray(this.template.layers)) return;
4603
+ const layers = this.template.layers.map((l) => this.resolveLayer(l));
4604
+ const containers = layers.filter(
4605
+ (l) => l.kind === "container"
4606
+ );
4607
+ if (containers.length === 0) return;
4608
+ const measuredBounds = /* @__PURE__ */ new Map();
4609
+ for (const layer of layers) {
4610
+ if (layer.kind === "text") {
4611
+ const textLayer = layer;
4612
+ const rawW = this.evaluateTextDimension(textLayer, "width");
4613
+ const rawH = this.evaluateTextDimension(textLayer, "height");
4614
+ const fontSize = Number(
4615
+ evaluateAnimatable(
4616
+ textLayer.fontSize,
4617
+ this.currentTime,
4618
+ this.template.duration
4619
+ )
4620
+ ) || 48;
4621
+ const fontWeight = evaluateAnimatable(
4622
+ textLayer.fontWeight,
4623
+ this.currentTime,
4624
+ this.template.duration
4625
+ ) || 400;
4626
+ const rawFontFamily = textLayer.fontFamily || "Space Grotesk";
4627
+ const fontFamily = resolveFontFamilyName(rawFontFamily);
4628
+ const legacyPad = Number(
4629
+ evaluateAnimatable(
4630
+ textLayer.padding ?? 0,
4631
+ this.currentTime,
4632
+ this.template.duration
4633
+ )
4634
+ ) || 0;
4635
+ const padL = Number(
4636
+ evaluateAnimatable(
4637
+ textLayer.paddingLeft ?? legacyPad,
4638
+ this.currentTime,
4639
+ this.template.duration
4640
+ )
4641
+ ) || 0;
4642
+ const padR = Number(
4643
+ evaluateAnimatable(
4644
+ textLayer.paddingRight ?? legacyPad,
4645
+ this.currentTime,
4646
+ this.template.duration
4647
+ )
4648
+ ) || 0;
4649
+ const padT = Number(
4650
+ evaluateAnimatable(
4651
+ textLayer.paddingTop ?? legacyPad,
4652
+ this.currentTime,
4653
+ this.template.duration
4654
+ )
4655
+ ) || 0;
4656
+ const padB = Number(
4657
+ evaluateAnimatable(
4658
+ textLayer.paddingBottom ?? legacyPad,
4659
+ this.currentTime,
4660
+ this.template.duration
4661
+ )
4662
+ ) || 0;
4663
+ const text = this.resolveDynamicContent(textLayer.content || "");
4664
+ const lines = text.split("\n");
4665
+ let textW = 0;
4666
+ if (typeof document !== "undefined") {
4667
+ const mCanvas = document.createElement("canvas");
4668
+ const mCtx = mCanvas.getContext("2d");
4669
+ if (mCtx) {
4670
+ mCtx.font = `${fontWeight} ${fontSize}px "${fontFamily}", "${rawFontFamily}", sans-serif`;
4671
+ textW = Math.max(
4672
+ ...lines.map((l) => mCtx.measureText(l || "Ag").width),
4673
+ 20
4674
+ );
4675
+ }
4676
+ }
4677
+ if (!textW) {
4678
+ const charFactor = Number(fontWeight) >= 600 ? 0.72 : 0.65;
4679
+ textW = Math.max(
4680
+ ...lines.map((l) => l.length * fontSize * charFactor),
4681
+ 20
4682
+ );
4683
+ }
4684
+ const lineHeightMultiplier = Number(
4685
+ evaluateAnimatable(
4686
+ textLayer.lineHeight,
4687
+ this.currentTime,
4688
+ this.template.duration
4689
+ )
4690
+ ) || 1.25;
4691
+ const lineAdvance = fontSize * lineHeightMultiplier;
4692
+ const textH = lines.length === 1 ? fontSize * 1.2 : fontSize * 1 + (lines.length - 1) * lineAdvance;
4693
+ const isAutoOrBox = rawW === "auto" || textLayer.overflow === "expand-panel" || textLayer.backgroundColor !== void 0 && textLayer.backgroundColor !== null;
4694
+ const w = isAutoOrBox ? textW + padL + padR : Number(rawW);
4695
+ const h = rawH === "auto" ? textH + padT + padB : Number(rawH);
4696
+ measuredBounds.set(layer.id, { width: w, height: h });
4697
+ } else if (layer.kind === "shape" || layer.kind === "image") {
4698
+ const w = Number(
4699
+ evaluateAnimatable(
4700
+ layer.width,
4701
+ this.currentTime,
4702
+ this.template.duration
4703
+ )
4704
+ ) || 100;
4705
+ const h = Number(
4706
+ evaluateAnimatable(
4707
+ layer.height,
4708
+ this.currentTime,
4709
+ this.template.duration
4710
+ )
4711
+ ) || 100;
4712
+ measuredBounds.set(layer.id, { width: w, height: h });
4713
+ }
4714
+ }
4715
+ for (const container of containers) {
4716
+ const children = layers.filter(
4717
+ (l) => l.parentId === container.id && l.visible !== false
4718
+ );
4719
+ const layout = container.layout || {
4720
+ type: "flex",
4721
+ direction: "column",
4722
+ gap: 0,
4723
+ alignItems: "start",
4724
+ justifyContent: "start"
4725
+ };
4726
+ const direction = layout.direction || "column";
4727
+ const gap = Number(
4728
+ evaluateAnimatable(
4729
+ layout.gap,
4730
+ this.currentTime,
4731
+ this.template.duration
4732
+ )
4733
+ ) || 0;
4734
+ const padTop = Number(
4735
+ evaluateAnimatable(
4736
+ layout.paddingTop,
4737
+ this.currentTime,
4738
+ this.template.duration
4739
+ )
4740
+ ) || 0;
4741
+ const padRight = Number(
4742
+ evaluateAnimatable(
4743
+ layout.paddingRight,
4744
+ this.currentTime,
4745
+ this.template.duration
4746
+ )
4747
+ ) || 0;
4748
+ const padBottom = Number(
4749
+ evaluateAnimatable(
4750
+ layout.paddingBottom,
4751
+ this.currentTime,
4752
+ this.template.duration
4753
+ )
4754
+ ) || 0;
4755
+ const padLeft = Number(
4756
+ evaluateAnimatable(
4757
+ layout.paddingLeft,
4758
+ this.currentTime,
4759
+ this.template.duration
4760
+ )
4761
+ ) || 0;
4762
+ const alignItems = layout.alignItems || "center";
4763
+ const containerX = Number(
4764
+ evaluateAnimatable(
4765
+ container.x,
4766
+ this.currentTime,
4767
+ this.template.duration
4768
+ )
4769
+ ) || 0;
4770
+ const containerY = Number(
4771
+ evaluateAnimatable(
4772
+ container.y,
4773
+ this.currentTime,
4774
+ this.template.duration
4775
+ )
4776
+ ) || 0;
4777
+ if (direction === "column") {
4778
+ let totalChildHeight = 0;
4779
+ let maxChildWidth = 0;
4780
+ const childSizes = [];
4781
+ for (const child of children) {
4782
+ const sz = measuredBounds.get(child.id) || { width: 100, height: 50 };
4783
+ childSizes.push({ id: child.id, width: sz.width, height: sz.height });
4784
+ totalChildHeight += sz.height;
4785
+ maxChildWidth = Math.max(maxChildWidth, sz.width);
4786
+ }
4787
+ if (children.length > 1) {
4788
+ totalChildHeight += (children.length - 1) * gap;
4789
+ }
4790
+ const rawContainerW = container.width;
4791
+ const rawContainerH = container.height;
4792
+ const declaredW = rawContainerW === "auto" || !rawContainerW ? 0 : Number(
4793
+ evaluateAnimatable(
4794
+ rawContainerW,
4795
+ this.currentTime,
4796
+ this.template.duration
4797
+ )
4798
+ ) || 0;
4799
+ const declaredH = rawContainerH === "auto" || !rawContainerH ? 0 : Number(
4800
+ evaluateAnimatable(
4801
+ rawContainerH,
4802
+ this.currentTime,
4803
+ this.template.duration
4804
+ )
4805
+ ) || 0;
4806
+ const containerW = Math.max(
4807
+ declaredW,
4808
+ maxChildWidth + padLeft + padRight
4809
+ );
4810
+ const containerH = Math.max(
4811
+ declaredH,
4812
+ totalChildHeight + padTop + padBottom
4813
+ );
4814
+ this.computedFlexLayouts.set(container.id, {
4815
+ x: containerX,
4816
+ y: containerY,
4817
+ width: containerW,
4818
+ height: containerH
4819
+ });
4820
+ let currentY = containerY + padTop;
4821
+ const innerW = Math.max(0, containerW - padLeft - padRight);
4822
+ for (const child of childSizes) {
4823
+ let childW = child.width;
4824
+ let childX = containerX + padLeft;
4825
+ if (alignItems === "center") {
4826
+ childX = containerX + padLeft + (innerW - childW) / 2;
4827
+ } else if (alignItems === "end") {
4828
+ childX = containerX + padLeft + (innerW - childW);
4829
+ } else if (alignItems === "stretch") {
4830
+ childW = innerW;
4831
+ }
4832
+ this.computedFlexLayouts.set(child.id, {
4833
+ x: childX,
4834
+ y: currentY,
4835
+ width: childW,
4836
+ height: child.height
4837
+ });
4838
+ currentY += child.height + gap;
4839
+ }
4840
+ } else {
4841
+ let totalChildWidth = 0;
4842
+ let maxChildHeight = 0;
4843
+ const childSizes = [];
4844
+ for (const child of children) {
4845
+ const sz = measuredBounds.get(child.id) || { width: 100, height: 50 };
4846
+ childSizes.push({ id: child.id, width: sz.width, height: sz.height });
4847
+ totalChildWidth += sz.width;
4848
+ maxChildHeight = Math.max(maxChildHeight, sz.height);
4849
+ }
4850
+ if (children.length > 1) {
4851
+ totalChildWidth += (children.length - 1) * gap;
4852
+ }
4853
+ const rawContainerW = container.width;
4854
+ const rawContainerH = container.height;
4855
+ const declaredW = rawContainerW === "auto" || !rawContainerW ? 0 : Number(
4856
+ evaluateAnimatable(
4857
+ rawContainerW,
4858
+ this.currentTime,
4859
+ this.template.duration
4860
+ )
4861
+ ) || 0;
4862
+ const declaredH = rawContainerH === "auto" || !rawContainerH ? 0 : Number(
4863
+ evaluateAnimatable(
4864
+ rawContainerH,
4865
+ this.currentTime,
4866
+ this.template.duration
4867
+ )
4868
+ ) || 0;
4869
+ const containerW = Math.max(
4870
+ declaredW,
4871
+ totalChildWidth + padLeft + padRight
4872
+ );
4873
+ const containerH = Math.max(
4874
+ declaredH,
4875
+ maxChildHeight + padTop + padBottom
4876
+ );
4877
+ this.computedFlexLayouts.set(container.id, {
4878
+ x: containerX,
4879
+ y: containerY,
4880
+ width: containerW,
4881
+ height: containerH
4882
+ });
4883
+ let currentX = containerX + padLeft;
4884
+ const innerH = Math.max(0, containerH - padTop - padBottom);
4885
+ for (const child of childSizes) {
4886
+ let childH = child.height;
4887
+ let childY = containerY + padTop;
4888
+ if (alignItems === "center") {
4889
+ childY = containerY + padTop + (innerH - childH) / 2;
4890
+ } else if (alignItems === "end") {
4891
+ childY = containerY + padTop + (innerH - childH);
4892
+ } else if (alignItems === "stretch") {
4893
+ childH = innerH;
4894
+ }
4895
+ this.computedFlexLayouts.set(child.id, {
4896
+ x: currentX,
4897
+ y: childY,
4898
+ width: child.width,
4899
+ height: childH
4900
+ });
4901
+ currentX += child.width + gap;
4902
+ }
4903
+ }
4904
+ }
4905
+ }
4906
+ drawContainerLayer(ctx, layer) {
4907
+ const resolved = layer;
4908
+ const layout = this.computedFlexLayouts.get(resolved.id);
4909
+ const x = layout?.x ?? (Number(
4910
+ evaluateAnimatable(
4911
+ resolved.x,
4912
+ this.currentTime,
4913
+ this.template.duration
4914
+ )
4915
+ ) || 0);
4916
+ const y = layout?.y ?? (Number(
4917
+ evaluateAnimatable(
4918
+ resolved.y,
4919
+ this.currentTime,
4920
+ this.template.duration
4921
+ )
4922
+ ) || 0);
4923
+ const width = layout?.width ?? (resolved.width === "auto" ? 400 : Number(
4924
+ evaluateAnimatable(
4925
+ resolved.width,
4926
+ this.currentTime,
4927
+ this.template.duration
4928
+ )
4929
+ ) || 400);
4930
+ const height = layout?.height ?? (resolved.height === "auto" ? 200 : Number(
4931
+ evaluateAnimatable(
4932
+ resolved.height,
4933
+ this.currentTime,
4934
+ this.template.duration
4935
+ )
4936
+ ) || 200);
4937
+ this.lastLayerLayouts.set(resolved.id, { x, y, width, height });
4938
+ const bgColor = resolved.backgroundColor ? evaluateAnimatable(
4939
+ resolved.backgroundColor,
4940
+ this.currentTime,
4941
+ this.template.duration
4942
+ ) : null;
4943
+ const bgOpacity = resolved.backgroundOpacity !== void 0 ? Number(
4944
+ evaluateAnimatable(
4945
+ resolved.backgroundOpacity,
4946
+ this.currentTime,
4947
+ this.template.duration
4948
+ )
4949
+ ) : 1;
4950
+ const bgRadius = resolved.backgroundRadius !== void 0 ? Number(
4951
+ evaluateAnimatable(
4952
+ resolved.backgroundRadius,
4953
+ this.currentTime,
4954
+ this.template.duration
4955
+ )
4956
+ ) : 0;
4957
+ const borderColor = resolved.backgroundBorderColor ? evaluateAnimatable(
4958
+ resolved.backgroundBorderColor,
4959
+ this.currentTime,
4960
+ this.template.duration
4961
+ ) : null;
4962
+ const borderWidth = resolved.backgroundBorderWidth !== void 0 ? Number(
4963
+ evaluateAnimatable(
4964
+ resolved.backgroundBorderWidth,
4965
+ this.currentTime,
4966
+ this.template.duration
4967
+ )
4968
+ ) : 0;
4969
+ if (bgColor || borderColor && borderWidth > 0) {
4970
+ const currentAlpha = ctx.globalAlpha;
4971
+ ctx.save();
4972
+ ctx.globalAlpha = currentAlpha * bgOpacity;
4973
+ ctx.beginPath();
4974
+ if (bgRadius > 0) {
4975
+ ctx.moveTo(x + bgRadius, y);
4976
+ ctx.lineTo(x + width - bgRadius, y);
4977
+ ctx.quadraticCurveTo(x + width, y, x + width, y + bgRadius);
4978
+ ctx.lineTo(x + width, y + height - bgRadius);
4979
+ ctx.quadraticCurveTo(
4980
+ x + width,
4981
+ y + height,
4982
+ x + width - bgRadius,
4983
+ y + height
4984
+ );
4985
+ ctx.lineTo(x + bgRadius, y + height);
4986
+ ctx.quadraticCurveTo(x, y + height, x, y + height - bgRadius);
4987
+ ctx.lineTo(x, y + bgRadius);
4988
+ ctx.quadraticCurveTo(x, y, x + bgRadius, y);
4989
+ } else {
4990
+ ctx.rect(x, y, width, height);
4991
+ }
4992
+ ctx.closePath();
4993
+ if (bgColor) {
4994
+ ctx.fillStyle = bgColor;
4995
+ ctx.fill();
4996
+ }
4997
+ if (borderColor && borderWidth > 0) {
4998
+ ctx.strokeStyle = borderColor;
4999
+ ctx.lineWidth = borderWidth;
5000
+ ctx.globalAlpha = currentAlpha;
5001
+ ctx.stroke();
5002
+ }
5003
+ ctx.restore();
5004
+ }
5005
+ }
4876
5006
  drawLayers(ctx, time) {
4877
5007
  if (!this.template || !Array.isArray(this.template.layers)) return;
4878
5008
  this.lastLayerLayouts.clear();
5009
+ this.computeFlexLayouts(time);
4879
5010
  for (const layer of this.template.layers) {
4880
5011
  const resolved = this.resolveLayer(layer);
5012
+ if (resolved.visible === false) continue;
4881
5013
  const transform = this.computeTransform(resolved, time);
4882
- const layerOpacity = resolved.opacity !== void 0 ? evaluateAnimatable(resolved.opacity, this.currentTime, this.template.duration) : 1;
5014
+ const layerOpacity = resolved.opacity !== void 0 ? evaluateAnimatable(
5015
+ resolved.opacity,
5016
+ this.currentTime,
5017
+ this.template.duration
5018
+ ) : 1;
4883
5019
  ctx.save();
4884
5020
  ctx.globalAlpha = transform.opacity * layerOpacity;
4885
- const x = this.evaluateLayerProperty(resolved, "x");
4886
- const y = this.evaluateLayerProperty(resolved, "y");
5021
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5022
+ const x = flexLayout?.x ?? this.evaluateLayerProperty(resolved, "x");
5023
+ const y = flexLayout?.y ?? this.evaluateLayerProperty(resolved, "y");
4887
5024
  let cx;
4888
5025
  let cy;
4889
5026
  if (resolved.kind === "text") {
4890
5027
  const textLayer = resolved;
4891
- const rawW = this.evaluateTextDimension(textLayer, "width");
4892
- const rawH = this.evaluateTextDimension(textLayer, "height");
5028
+ const rawW = flexLayout?.width ?? this.evaluateTextDimension(textLayer, "width");
5029
+ const rawH = flexLayout?.height ?? this.evaluateTextDimension(textLayer, "height");
4893
5030
  cx = rawW === "auto" ? x : x + rawW / 2;
4894
5031
  cy = rawH === "auto" ? y : y + rawH / 2;
4895
5032
  } else {
4896
- const width = evaluateAnimatable(resolved.width, this.currentTime, this.template.duration);
4897
- const height = evaluateAnimatable(resolved.height, this.currentTime, this.template.duration);
5033
+ const width = flexLayout?.width ?? evaluateAnimatable(
5034
+ resolved.width,
5035
+ this.currentTime,
5036
+ this.template.duration
5037
+ );
5038
+ const height = flexLayout?.height ?? evaluateAnimatable(
5039
+ resolved.height,
5040
+ this.currentTime,
5041
+ this.template.duration
5042
+ );
4898
5043
  cx = x + width / 2;
4899
5044
  cy = y + height / 2;
4900
5045
  }
@@ -4905,59 +5050,142 @@ var TemplateRenderer = class {
4905
5050
  ctx.filter = `blur(${transform.blur}px)`;
4906
5051
  }
4907
5052
  if (resolved.kind === "text") {
4908
- this.drawTextLayer(ctx, resolved, transform);
5053
+ this.drawTextLayer(
5054
+ ctx,
5055
+ resolved,
5056
+ transform
5057
+ );
4909
5058
  } else if (resolved.kind === "shape") {
4910
- this.drawShapeLayer(ctx, resolved);
5059
+ this.drawShapeLayer(
5060
+ ctx,
5061
+ resolved
5062
+ );
4911
5063
  } else if (resolved.kind === "image") {
4912
- this.drawImageLayer(ctx, resolved);
5064
+ this.drawImageLayer(
5065
+ ctx,
5066
+ resolved
5067
+ );
5068
+ } else if (resolved.kind === "container") {
5069
+ this.drawContainerLayer(
5070
+ ctx,
5071
+ resolved
5072
+ );
4913
5073
  }
4914
5074
  ctx.restore();
4915
5075
  }
4916
5076
  }
4917
5077
  drawTextLayer(ctx, layer, transform) {
4918
5078
  const resolved = layer;
4919
- const content = resolved.content;
5079
+ const rawContent = resolved.content;
5080
+ const content = this.resolveDynamicContent(rawContent);
4920
5081
  const rawFontFamily = resolved.fontFamily;
4921
5082
  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);
5083
+ const fontSize = evaluateAnimatable(
5084
+ resolved.fontSize,
5085
+ this.currentTime,
5086
+ this.template.duration
5087
+ );
5088
+ const fontWeight = evaluateAnimatable(
5089
+ resolved.fontWeight,
5090
+ this.currentTime,
5091
+ this.template.duration
5092
+ );
5093
+ const color = evaluateAnimatable(
5094
+ resolved.color,
5095
+ this.currentTime,
5096
+ this.template.duration
5097
+ );
4925
5098
  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;
5099
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5100
+ const x = flexLayout?.x ?? evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5101
+ const y = flexLayout?.y ?? evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5102
+ const rawWidth = flexLayout?.width ?? this.evaluateTextDimension(resolved, "width");
5103
+ const rawHeight = flexLayout?.height ?? this.evaluateTextDimension(resolved, "height");
5104
+ const backgroundColor = resolved.backgroundColor ? evaluateAnimatable(
5105
+ resolved.backgroundColor,
5106
+ this.currentTime,
5107
+ this.template.duration
5108
+ ) : null;
5109
+ const backgroundOpacity = resolved.backgroundOpacity !== void 0 ? evaluateAnimatable(
5110
+ resolved.backgroundOpacity,
5111
+ this.currentTime,
5112
+ this.template.duration
5113
+ ) : 1;
5114
+ const backgroundRadius = resolved.backgroundRadius !== void 0 ? evaluateAnimatable(
5115
+ resolved.backgroundRadius,
5116
+ this.currentTime,
5117
+ this.template.duration
5118
+ ) : 0;
5119
+ const backgroundBorderColor = resolved.backgroundBorderColor ? evaluateAnimatable(
5120
+ resolved.backgroundBorderColor,
5121
+ this.currentTime,
5122
+ this.template.duration
5123
+ ) : null;
5124
+ const backgroundBorderWidth = resolved.backgroundBorderWidth !== void 0 ? evaluateAnimatable(
5125
+ resolved.backgroundBorderWidth,
5126
+ this.currentTime,
5127
+ this.template.duration
5128
+ ) : 0;
5129
+ const legacyPadding = resolved.padding !== void 0 ? evaluateAnimatable(
5130
+ resolved.padding,
5131
+ this.currentTime,
5132
+ this.template.duration
5133
+ ) : 0;
5134
+ const pt = resolved.paddingTop !== void 0 ? evaluateAnimatable(
5135
+ resolved.paddingTop,
5136
+ this.currentTime,
5137
+ this.template.duration
5138
+ ) : legacyPadding;
5139
+ const pr = resolved.paddingRight !== void 0 ? evaluateAnimatable(
5140
+ resolved.paddingRight,
5141
+ this.currentTime,
5142
+ this.template.duration
5143
+ ) : legacyPadding;
5144
+ const pb = resolved.paddingBottom !== void 0 ? evaluateAnimatable(
5145
+ resolved.paddingBottom,
5146
+ this.currentTime,
5147
+ this.template.duration
5148
+ ) : legacyPadding;
5149
+ const pl = resolved.paddingLeft !== void 0 ? evaluateAnimatable(
5150
+ resolved.paddingLeft,
5151
+ this.currentTime,
5152
+ this.template.duration
5153
+ ) : legacyPadding;
4940
5154
  const overflow = resolved.overflow;
4941
5155
  const verticalAlign = resolved.verticalAlign || "middle";
4942
- const visibleCharsCount = Math.floor(transform.typewriterProgress * content.length);
5156
+ const visibleCharsCount = Math.floor(
5157
+ transform.typewriterProgress * content.length
5158
+ );
4943
5159
  const textToDraw = content.slice(0, visibleCharsCount);
4944
5160
  ctx.save();
4945
5161
  ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", "${rawFontFamily}", sans-serif`;
4946
5162
  ctx.textBaseline = "alphabetic";
4947
5163
  ctx.textAlign = align;
4948
5164
  let adjustedFontSize = fontSize;
4949
- let lines = [textToDraw];
5165
+ const lineHeightMultiplier = Number(
5166
+ evaluateAnimatable(
5167
+ resolved.lineHeight,
5168
+ this.currentTime,
5169
+ this.template.duration
5170
+ )
5171
+ ) || 1.25;
5172
+ const rawLines = textToDraw.split("\n");
5173
+ let lines = rawLines;
5174
+ const maxLineTextWidth = Math.max(
5175
+ ...rawLines.map((l) => ctx.measureText(l || "Ag").width),
5176
+ 20
5177
+ );
4950
5178
  let resolvedWidth;
4951
- if (rawWidth === "auto") {
4952
- const measured = ctx.measureText(textToDraw || "Ag").width;
4953
- resolvedWidth = measured + pl + pr;
5179
+ if (rawWidth === "auto" || overflow === "expand-panel" || backgroundColor && !rawWidth) {
5180
+ resolvedWidth = maxLineTextWidth + pl + pr;
5181
+ } else if (flexLayout) {
5182
+ resolvedWidth = overflow === "shrink" || overflow === "wrap" ? flexLayout.width : Math.max(flexLayout.width, maxLineTextWidth + pl + pr);
4954
5183
  } else {
4955
5184
  resolvedWidth = rawWidth;
4956
5185
  }
4957
5186
  const contentW = Math.max(0, resolvedWidth - pl - pr);
4958
5187
  if (overflow === "shrink") {
4959
- const measuredWidth = ctx.measureText(textToDraw).width;
4960
- let scale = measuredWidth > contentW && contentW > 0 ? contentW / measuredWidth : 1;
5188
+ let scale = maxLineTextWidth > contentW && contentW > 0 ? contentW / maxLineTextWidth : 1;
4961
5189
  if (rawHeight !== "auto") {
4962
5190
  const declaredContentH = Math.max(0, rawHeight - pt - pb);
4963
5191
  const singleLineH = fontSize * 1;
@@ -4969,20 +5197,22 @@ var TemplateRenderer = class {
4969
5197
  adjustedFontSize = fontSize * scale;
4970
5198
  ctx.font = `${fontWeight} ${adjustedFontSize}px "${fontFamily}", "${rawFontFamily}", sans-serif`;
4971
5199
  }
4972
- } else if (overflow === "wrap") {
4973
- lines = wrapTextToWidth(ctx, textToDraw, contentW, 0);
5200
+ } else if (overflow === "wrap" && contentW > 0) {
5201
+ lines = [];
5202
+ for (const rLine of rawLines) {
5203
+ lines.push(...wrapTextToWidth(ctx, rLine, contentW, 0));
5204
+ }
4974
5205
  } else if (overflow === "expand-panel") {
4975
- const measuredWidth = ctx.measureText(textToDraw).width;
4976
- resolvedWidth = measuredWidth + pl + pr;
5206
+ resolvedWidth = maxLineTextWidth + pl + pr;
4977
5207
  }
5208
+ const lineAdvance = adjustedFontSize * lineHeightMultiplier;
5209
+ const sampleMetrics = ctx.measureText(lines[0] || "Ag");
5210
+ const ascent = sampleMetrics.actualBoundingBoxAscent ?? adjustedFontSize * 0.8;
5211
+ const descent = sampleMetrics.actualBoundingBoxDescent ?? adjustedFontSize * 0.2;
5212
+ const inkLineH = ascent + descent;
5213
+ const totalInkH = lines.length === 1 ? inkLineH : inkLineH + (lines.length - 1) * lineAdvance;
4978
5214
  let resolvedHeight;
4979
5215
  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
5216
  resolvedHeight = totalInkH + pt + pb;
4987
5217
  } else {
4988
5218
  resolvedHeight = rawHeight;
@@ -5000,10 +5230,30 @@ var TemplateRenderer = class {
5000
5230
  bgX = x;
5001
5231
  }
5002
5232
  }
5003
- this.lastLayerLayouts.set(resolved.id, { x: bgX, y: bgY, width: bgWidth, height: bgHeight });
5233
+ if (resolved.anchor) {
5234
+ const anchored = resolveAnchorPosition(
5235
+ resolved.anchor,
5236
+ { x: bgX, y: bgY, width: bgWidth, height: bgHeight },
5237
+ this.template.canvasWidth,
5238
+ this.template.canvasHeight
5239
+ );
5240
+ bgX = anchored.x;
5241
+ bgY = anchored.y;
5242
+ bgWidth = anchored.width;
5243
+ bgHeight = anchored.height;
5244
+ }
5245
+ this.lastLayerLayouts.set(resolved.id, {
5246
+ x: bgX,
5247
+ y: bgY,
5248
+ width: bgWidth,
5249
+ height: bgHeight
5250
+ });
5004
5251
  const styleRef = resolved.styleRef;
5005
5252
  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"), {
5253
+ const effectCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(
5254
+ Math.max(1, Math.ceil(bgWidth)),
5255
+ Math.max(1, Math.ceil(bgHeight))
5256
+ ) : typeof document !== "undefined" ? Object.assign(document.createElement("canvas"), {
5007
5257
  width: Math.max(1, Math.ceil(bgWidth)),
5008
5258
  height: Math.max(1, Math.ceil(bgHeight))
5009
5259
  }) : null;
@@ -5019,7 +5269,13 @@ var TemplateRenderer = class {
5019
5269
  effectScene.text.textPosX = "center";
5020
5270
  effectScene.text.textPosY = "middle";
5021
5271
  evaluateScene(effectScene, this.currentTime, effectCtx);
5022
- ctx.drawImage(effectCanvas, bgX, bgY, bgWidth, bgHeight);
5272
+ ctx.drawImage(
5273
+ effectCanvas,
5274
+ bgX,
5275
+ bgY,
5276
+ bgWidth,
5277
+ bgHeight
5278
+ );
5023
5279
  ctx.restore();
5024
5280
  return;
5025
5281
  }
@@ -5028,22 +5284,39 @@ var TemplateRenderer = class {
5028
5284
  let contentY = bgY + pt;
5029
5285
  let contentH = Math.max(0, bgHeight - pt - pb);
5030
5286
  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);
5287
+ if (overflow === "clip") {
5288
+ ctx.beginPath();
5289
+ if (backgroundRadius > 0) {
5290
+ ctx.moveTo(bgX + backgroundRadius, bgY);
5291
+ ctx.lineTo(bgX + bgWidth - backgroundRadius, bgY);
5292
+ ctx.quadraticCurveTo(
5293
+ bgX + bgWidth,
5294
+ bgY,
5295
+ bgX + bgWidth,
5296
+ bgY + backgroundRadius
5297
+ );
5298
+ ctx.lineTo(bgX + bgWidth, bgY + bgHeight - backgroundRadius);
5299
+ ctx.quadraticCurveTo(
5300
+ bgX + bgWidth,
5301
+ bgY + bgHeight,
5302
+ bgX + bgWidth - backgroundRadius,
5303
+ bgY + bgHeight
5304
+ );
5305
+ ctx.lineTo(bgX + backgroundRadius, bgY + bgHeight);
5306
+ ctx.quadraticCurveTo(
5307
+ bgX,
5308
+ bgY + bgHeight,
5309
+ bgX,
5310
+ bgY + bgHeight - backgroundRadius
5311
+ );
5312
+ ctx.lineTo(bgX, bgY + backgroundRadius);
5313
+ ctx.quadraticCurveTo(bgX, bgY, bgX + backgroundRadius, bgY);
5314
+ } else {
5315
+ ctx.rect(bgX, bgY, bgWidth, bgHeight);
5316
+ }
5317
+ ctx.closePath();
5318
+ ctx.clip();
5044
5319
  }
5045
- ctx.closePath();
5046
- ctx.clip();
5047
5320
  if (backgroundColor) {
5048
5321
  const currentAlpha = ctx.globalAlpha;
5049
5322
  ctx.save();
@@ -5053,11 +5326,26 @@ var TemplateRenderer = class {
5053
5326
  ctx.beginPath();
5054
5327
  ctx.moveTo(bgX + backgroundRadius, bgY);
5055
5328
  ctx.lineTo(bgX + bgWidth - backgroundRadius, bgY);
5056
- ctx.quadraticCurveTo(bgX + bgWidth, bgY, bgX + bgWidth, bgY + backgroundRadius);
5329
+ ctx.quadraticCurveTo(
5330
+ bgX + bgWidth,
5331
+ bgY,
5332
+ bgX + bgWidth,
5333
+ bgY + backgroundRadius
5334
+ );
5057
5335
  ctx.lineTo(bgX + bgWidth, bgY + bgHeight - backgroundRadius);
5058
- ctx.quadraticCurveTo(bgX + bgWidth, bgY + bgHeight, bgX + bgWidth - backgroundRadius, bgY + bgHeight);
5336
+ ctx.quadraticCurveTo(
5337
+ bgX + bgWidth,
5338
+ bgY + bgHeight,
5339
+ bgX + bgWidth - backgroundRadius,
5340
+ bgY + bgHeight
5341
+ );
5059
5342
  ctx.lineTo(bgX + backgroundRadius, bgY + bgHeight);
5060
- ctx.quadraticCurveTo(bgX, bgY + bgHeight, bgX, bgY + bgHeight - backgroundRadius);
5343
+ ctx.quadraticCurveTo(
5344
+ bgX,
5345
+ bgY + bgHeight,
5346
+ bgX,
5347
+ bgY + bgHeight - backgroundRadius
5348
+ );
5061
5349
  ctx.lineTo(bgX, bgY + backgroundRadius);
5062
5350
  ctx.quadraticCurveTo(bgX, bgY, bgX + backgroundRadius, bgY);
5063
5351
  ctx.closePath();
@@ -5089,13 +5377,93 @@ var TemplateRenderer = class {
5089
5377
  } else {
5090
5378
  drawX = contentX;
5091
5379
  }
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;
5380
+ if (resolved.splitAnimator) {
5381
+ const inEnd = resolved.animation.inDuration;
5382
+ const animProgress = inEnd > 0 ? Math.min(1, Math.max(0, this.currentTime / inEnd)) : 1;
5383
+ const splitUnits = splitTextContent(
5384
+ textToDraw,
5385
+ resolved.splitAnimator.splitBy
5386
+ );
5387
+ const computedUnits = evaluateSplitTextTransforms(
5388
+ splitUnits,
5389
+ resolved.splitAnimator,
5390
+ animProgress,
5391
+ "in"
5392
+ );
5393
+ let currentX = drawX;
5394
+ if (align === "center") {
5395
+ const fullW = ctx.measureText(textToDraw).width;
5396
+ currentX = contentX + (contentW - fullW) / 2;
5397
+ } else if (align === "right") {
5398
+ const fullW = ctx.measureText(textToDraw).width;
5399
+ currentX = contentX + contentW - fullW;
5400
+ }
5401
+ const drawY = verticalAlign === "top" ? contentY + ascent : verticalAlign === "bottom" ? contentY + contentH - descent : contentY + (contentH - inkLineH) / 2 + ascent;
5402
+ computedUnits.forEach((item, unitIdx) => {
5403
+ const span = getSpanForCharIndex(
5404
+ resolved.spans,
5405
+ item.unit.charStartIndex
5406
+ );
5407
+ const charColor = resolved.perCharFillEnabled && resolved.charFillColors?.[unitIdx] ? resolved.charFillColors[unitIdx] : span?.color || color;
5408
+ ctx.save();
5409
+ ctx.globalAlpha = ctx.globalAlpha * item.opacity;
5410
+ ctx.fillStyle = charColor;
5411
+ const uW = ctx.measureText(item.unit.text).width;
5412
+ const uCX = currentX + uW / 2 + item.x;
5413
+ const uCY = drawY - ascent / 2 + item.y;
5414
+ ctx.translate(uCX, uCY);
5415
+ ctx.scale(item.scale * item.scaleX, item.scale * item.scaleY);
5416
+ if (item.rotation !== 0) ctx.rotate(item.rotation * Math.PI / 180);
5417
+ ctx.translate(-uCX, -uCY);
5418
+ if (item.blur > 0 && "filter" in ctx) {
5419
+ ctx.filter = `blur(${item.blur}px)`;
5420
+ }
5421
+ ctx.fillText(
5422
+ item.unit.text,
5423
+ currentX + item.x,
5424
+ drawY + item.y + (span?.baselineShift || 0)
5425
+ );
5426
+ ctx.restore();
5427
+ currentX += uW + (item.letterSpacingOffset || 0);
5428
+ });
5429
+ } else if (resolved.spans && resolved.spans.length > 0) {
5430
+ const totalInkHeight = lines.length === 1 ? inkLineH : inkLineH + (lines.length - 1) * lineAdvance;
5431
+ let firstBaselineY = verticalAlign === "top" ? contentY + ascent : verticalAlign === "bottom" ? contentY + contentH - totalInkHeight + ascent : contentY + (contentH - totalInkHeight) / 2 + ascent;
5432
+ let globalCharIndex = 0;
5433
+ ctx.textAlign = "left";
5434
+ lines.forEach((line, lineIndex) => {
5435
+ let curX = contentX;
5436
+ if (align === "center") {
5437
+ const lW = ctx.measureText(line).width;
5438
+ curX = contentX + (contentW - lW) / 2;
5439
+ } else if (align === "right") {
5440
+ const lW = ctx.measureText(line).width;
5441
+ curX = contentX + contentW - lW;
5442
+ }
5443
+ const chars = Array.from(line);
5444
+ chars.forEach((ch) => {
5445
+ const span = getSpanForCharIndex(resolved.spans, globalCharIndex);
5446
+ const chColor = resolved.perCharFillEnabled && resolved.charFillColors?.[globalCharIndex] ? resolved.charFillColors[globalCharIndex] : span?.color || color;
5447
+ ctx.save();
5448
+ if (span?.fontFamily || span?.fontWeight || span?.fontSize) {
5449
+ ctx.font = `${span.fontWeight || fontWeight} ${span.fontSize || adjustedFontSize}px "${resolveFontFamilyName(
5450
+ span.fontFamily || rawFontFamily
5451
+ )}", sans-serif`;
5452
+ }
5453
+ ctx.fillStyle = chColor;
5454
+ ctx.fillText(
5455
+ ch,
5456
+ curX,
5457
+ firstBaselineY + lineIndex * lineAdvance + (span?.baselineShift || 0)
5458
+ );
5459
+ ctx.restore();
5460
+ curX += ctx.measureText(ch).width + (span?.letterSpacing || 0);
5461
+ globalCharIndex += ch.length;
5462
+ });
5463
+ globalCharIndex += 1;
5464
+ });
5465
+ } else {
5466
+ const totalInkHeight = lines.length === 1 ? inkLineH : inkLineH + (lines.length - 1) * lineAdvance;
5099
5467
  let firstBaselineY;
5100
5468
  if (verticalAlign === "top") {
5101
5469
  firstBaselineY = contentY + ascent;
@@ -5104,19 +5472,10 @@ var TemplateRenderer = class {
5104
5472
  } else {
5105
5473
  firstBaselineY = contentY + (contentH - totalInkHeight) / 2 + ascent;
5106
5474
  }
5475
+ ctx.textAlign = align;
5107
5476
  lines.forEach((line, index) => {
5108
- ctx.fillText(line, drawX, firstBaselineY + index * lineHeight);
5477
+ ctx.fillText(line, drawX, firstBaselineY + index * lineAdvance);
5109
5478
  });
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
5479
  }
5121
5480
  ctx.restore();
5122
5481
  ctx.restore();
@@ -5124,11 +5483,24 @@ var TemplateRenderer = class {
5124
5483
  drawShapeLayer(ctx, layer) {
5125
5484
  const resolved = layer;
5126
5485
  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);
5486
+ const fill = evaluateAnimatable(
5487
+ resolved.fill,
5488
+ this.currentTime,
5489
+ this.template.duration
5490
+ );
5491
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5492
+ const x = flexLayout?.x ?? evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5493
+ const y = flexLayout?.y ?? evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5494
+ const width = flexLayout?.width ?? evaluateAnimatable(
5495
+ resolved.width,
5496
+ this.currentTime,
5497
+ this.template.duration
5498
+ );
5499
+ const height = flexLayout?.height ?? evaluateAnimatable(
5500
+ resolved.height,
5501
+ this.currentTime,
5502
+ this.template.duration
5503
+ );
5132
5504
  const stroke = resolved.stroke;
5133
5505
  this.lastLayerLayouts.set(resolved.id, { x, y, width, height });
5134
5506
  ctx.fillStyle = fill;
@@ -5145,8 +5517,16 @@ var TemplateRenderer = class {
5145
5517
  }
5146
5518
  ctx.fill();
5147
5519
  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);
5520
+ const strokeWidth = evaluateAnimatable(
5521
+ stroke.width,
5522
+ this.currentTime,
5523
+ this.template.duration
5524
+ );
5525
+ const strokeColor = evaluateAnimatable(
5526
+ stroke.color,
5527
+ this.currentTime,
5528
+ this.template.duration
5529
+ );
5150
5530
  if (strokeWidth > 0) {
5151
5531
  ctx.strokeStyle = strokeColor;
5152
5532
  ctx.lineWidth = strokeWidth;
@@ -5157,10 +5537,19 @@ var TemplateRenderer = class {
5157
5537
  drawImageLayer(ctx, layer) {
5158
5538
  const resolved = layer;
5159
5539
  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);
5540
+ const flexLayout = this.computedFlexLayouts.get(resolved.id);
5541
+ const x = flexLayout?.x ?? evaluateAnimatable(resolved.x, this.currentTime, this.template.duration);
5542
+ const y = flexLayout?.y ?? evaluateAnimatable(resolved.y, this.currentTime, this.template.duration);
5543
+ const width = flexLayout?.width ?? evaluateAnimatable(
5544
+ resolved.width,
5545
+ this.currentTime,
5546
+ this.template.duration
5547
+ );
5548
+ const height = flexLayout?.height ?? evaluateAnimatable(
5549
+ resolved.height,
5550
+ this.currentTime,
5551
+ this.template.duration
5552
+ );
5164
5553
  this.lastLayerLayouts.set(resolved.id, { x, y, width, height });
5165
5554
  if (!url) return;
5166
5555
  let img = this.imageCache.get(url);
@@ -5173,6 +5562,33 @@ var TemplateRenderer = class {
5173
5562
  ctx.drawImage(img, x, y, width, height);
5174
5563
  }
5175
5564
  }
5565
+ /**
5566
+ * Renders multi-frame ghost/onion-skin frames onto the canvas for precision motion tuning.
5567
+ */
5568
+ drawOnionSkin(ctx, time, options = {}) {
5569
+ const frameCount = options.frameCount ?? 2;
5570
+ const delta = options.frameDelta ?? 0.066;
5571
+ const duration = this.template.duration || 3;
5572
+ for (let i = frameCount; i >= 1; i--) {
5573
+ const ghostTime = Math.max(0, time - i * delta);
5574
+ if (ghostTime !== time) {
5575
+ ctx.save();
5576
+ ctx.globalAlpha = 0.25 / i;
5577
+ this.drawLayers(ctx, ghostTime);
5578
+ ctx.restore();
5579
+ }
5580
+ }
5581
+ for (let i = frameCount; i >= 1; i--) {
5582
+ const ghostTime = Math.min(duration, 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
+ this.drawFrame(ctx, time, { skipClear: true });
5591
+ }
5176
5592
  };
5177
5593
 
5178
5594
  // src/templates/presets.ts
@@ -5528,6 +5944,194 @@ var BUILTIN_CANVAS_TEMPLATES = [
5528
5944
  }
5529
5945
  }
5530
5946
  ]
5947
+ },
5948
+ {
5949
+ id: "kinetic-split-title",
5950
+ label: "Kinetic Stagger Opener",
5951
+ category: "kinetic-type",
5952
+ duration: 4,
5953
+ canvasWidth: 1920,
5954
+ canvasHeight: 1080,
5955
+ variables: {
5956
+ title: {
5957
+ key: "title",
5958
+ label: "Title Text",
5959
+ type: "string",
5960
+ defaultValue: "FUTURE MOTION"
5961
+ },
5962
+ subtitle: {
5963
+ key: "subtitle",
5964
+ label: "Subtitle Text",
5965
+ type: "string",
5966
+ defaultValue: "ADVANCED TYPOGRAPHY STUDIO"
5967
+ }
5968
+ },
5969
+ layers: [
5970
+ {
5971
+ kind: "text",
5972
+ id: "main-title",
5973
+ content: "{{title}}",
5974
+ fontFamily: "Poppins",
5975
+ fontSize: 72,
5976
+ fontWeight: 900,
5977
+ color: "#ffffff",
5978
+ align: "center",
5979
+ x: 460,
5980
+ y: 440,
5981
+ width: 1e3,
5982
+ height: 100,
5983
+ role: "primary",
5984
+ animation: {
5985
+ in: "scale-pop",
5986
+ out: "fade",
5987
+ inDuration: 0.8,
5988
+ outDuration: 0.4,
5989
+ hold: "full"
5990
+ },
5991
+ splitAnimator: {
5992
+ splitBy: "character",
5993
+ direction: "start-to-end",
5994
+ delayPerUnit: 0.03,
5995
+ overlap: 0.6,
5996
+ initialTransform: {
5997
+ y: 40,
5998
+ opacity: 0,
5999
+ scale: 0.7,
6000
+ rotateX: 45,
6001
+ blur: 8
6002
+ },
6003
+ easing: "cubic-bezier",
6004
+ bezier: { x1: 0.2, y1: 0.8, x2: 0.2, y2: 1 }
6005
+ },
6006
+ anchor: {
6007
+ anchorPoint: "center",
6008
+ maxWidthPercentage: 90
6009
+ }
6010
+ },
6011
+ {
6012
+ kind: "text",
6013
+ id: "sub-title",
6014
+ content: "{{subtitle}}",
6015
+ fontFamily: "Inter Variable",
6016
+ fontSize: 22,
6017
+ fontWeight: 600,
6018
+ color: "#7c6fff",
6019
+ letterSpacing: 6,
6020
+ align: "center",
6021
+ x: 460,
6022
+ y: 550,
6023
+ width: 1e3,
6024
+ height: 40,
6025
+ role: "secondary",
6026
+ animation: {
6027
+ in: "track-in",
6028
+ out: "fade",
6029
+ inDuration: 0.9,
6030
+ outDuration: 0.4,
6031
+ hold: "full"
6032
+ },
6033
+ anchor: {
6034
+ anchorPoint: "center",
6035
+ maxWidthPercentage: 85
6036
+ }
6037
+ }
6038
+ ]
6039
+ },
6040
+ {
6041
+ id: "responsive-speaker-lower-third",
6042
+ label: "Responsive Speaker Badge",
6043
+ category: "lower-third",
6044
+ duration: 5,
6045
+ canvasWidth: 1920,
6046
+ canvasHeight: 1080,
6047
+ variables: {
6048
+ speakerName: {
6049
+ key: "speakerName",
6050
+ label: "Speaker Name",
6051
+ type: "string",
6052
+ defaultValue: "Sarah Chen"
6053
+ },
6054
+ speakerRole: {
6055
+ key: "speakerRole",
6056
+ label: "Role / Organization",
6057
+ type: "string",
6058
+ defaultValue: "VP of Product @ Clypra"
6059
+ }
6060
+ },
6061
+ layers: [
6062
+ {
6063
+ kind: "text",
6064
+ id: "badge-name",
6065
+ content: "{{speakerName}}",
6066
+ fontFamily: "Poppins",
6067
+ fontSize: 32,
6068
+ fontWeight: 700,
6069
+ color: "#ffffff",
6070
+ backgroundColor: "#1E1E28",
6071
+ backgroundOpacity: 0.95,
6072
+ backgroundRadius: 8,
6073
+ backgroundBorderColor: "#7c6fff",
6074
+ backgroundBorderWidth: 2,
6075
+ paddingTop: 12,
6076
+ paddingBottom: 12,
6077
+ paddingLeft: 20,
6078
+ paddingRight: 20,
6079
+ align: "left",
6080
+ x: 100,
6081
+ y: 860,
6082
+ width: "auto",
6083
+ height: "auto",
6084
+ overflow: "expand-panel",
6085
+ role: "primary",
6086
+ animation: {
6087
+ in: "slide-right",
6088
+ out: "fade",
6089
+ inDuration: 0.5,
6090
+ outDuration: 0.3,
6091
+ hold: "full"
6092
+ },
6093
+ anchor: {
6094
+ anchorPoint: "bottom-left",
6095
+ offsetPercentageX: 5,
6096
+ offsetPercentageY: 10
6097
+ }
6098
+ },
6099
+ {
6100
+ kind: "text",
6101
+ id: "badge-role",
6102
+ content: "{{speakerRole}}",
6103
+ fontFamily: "Inter Variable",
6104
+ fontSize: 18,
6105
+ fontWeight: 500,
6106
+ color: "#9A9AAA",
6107
+ backgroundColor: "#121218",
6108
+ backgroundOpacity: 0.85,
6109
+ backgroundRadius: 6,
6110
+ paddingTop: 8,
6111
+ paddingBottom: 8,
6112
+ paddingLeft: 16,
6113
+ paddingRight: 16,
6114
+ align: "left",
6115
+ x: 100,
6116
+ y: 930,
6117
+ width: "auto",
6118
+ height: "auto",
6119
+ overflow: "expand-panel",
6120
+ role: "secondary",
6121
+ animation: {
6122
+ in: "slide-right",
6123
+ out: "fade",
6124
+ inDuration: 0.6,
6125
+ outDuration: 0.3,
6126
+ hold: "full"
6127
+ },
6128
+ anchor: {
6129
+ anchorPoint: "bottom-left",
6130
+ offsetPercentageX: 5,
6131
+ offsetPercentageY: 4
6132
+ }
6133
+ }
6134
+ ]
5531
6135
  }
5532
6136
  ];
5533
6137
  function getCanvasTemplatePreset(id) {
@@ -6253,7 +6857,7 @@ var ProjectCompiler = class {
6253
6857
  if (!definition) {
6254
6858
  throw new Error(`Unknown effect type: ${effect.type}. Ensure it is registered in NodeRegistry.`);
6255
6859
  }
6256
- const { capabilities: capabilities2, requirements } = definition;
6860
+ const { capabilities, requirements } = definition;
6257
6861
  const effectNode = {
6258
6862
  id: effectNodeId,
6259
6863
  type: effect.type,
@@ -6265,7 +6869,7 @@ var ProjectCompiler = class {
6265
6869
  outputs: {
6266
6870
  output: { id: "output", name: "Color Output", type: "Texture" }
6267
6871
  },
6268
- capabilities: capabilities2,
6872
+ capabilities,
6269
6873
  requirements,
6270
6874
  lifecycle: "Created"
6271
6875
  };
@@ -9023,11 +9627,13 @@ var DataBindingEngine = class {
9023
9627
  }
9024
9628
  }
9025
9629
  if (direction === "horizontal") {
9026
- clonedNode.x = repeater.x + idx * (clonedNode.width + gap);
9630
+ const nodeW = typeof clonedNode.width === "number" ? clonedNode.width : 0;
9631
+ clonedNode.x = repeater.x + idx * (nodeW + gap);
9027
9632
  clonedNode.y = repeater.y;
9028
9633
  } else {
9634
+ const nodeH = typeof clonedNode.height === "number" ? clonedNode.height : 0;
9029
9635
  clonedNode.x = repeater.x;
9030
- clonedNode.y = repeater.y + idx * (clonedNode.height + gap);
9636
+ clonedNode.y = repeater.y + idx * (nodeH + gap);
9031
9637
  }
9032
9638
  if (clonedNode.animation?.entrance) {
9033
9639
  clonedNode.animation.entrance = {
@@ -10016,8 +10622,8 @@ var CommandExecutor = class {
10016
10622
  for (const n of targetNodes) {
10017
10623
  if (n.x < minX) minX = n.x;
10018
10624
  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;
10625
+ if (typeof n.width === "number" && n.x + n.width > maxX) maxX = n.x + n.width;
10626
+ if (typeof n.height === "number" && n.y + n.height > maxY) maxY = n.y + n.height;
10021
10627
  }
10022
10628
  const frameId = `frame-${Date.now().toString(36)}`;
10023
10629
  const frameNode = {
@@ -10473,17 +11079,19 @@ var DocumentValidator = class {
10473
11079
  });
10474
11080
  }
10475
11081
  }
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
- });
11082
+ if (typeof node.width === "number" && typeof node.height === "number") {
11083
+ const absX = node.x < 100 ? node.x / 100 * doc.canvas.width : node.x;
11084
+ const absY = node.y < 100 ? node.y / 100 * doc.canvas.height : node.y;
11085
+ const absW = node.width <= 100 ? node.width / 100 * doc.canvas.width : node.width;
11086
+ const absH = node.height <= 100 ? node.height / 100 * doc.canvas.height : node.height;
11087
+ if (absX + absW > doc.canvas.width || absY + absH > doc.canvas.height) {
11088
+ diagnostics.push({
11089
+ severity: "warning",
11090
+ code: "WARN_OUT_OF_BOUNDS",
11091
+ message: `Node "${node.name || node.id}" extends outside canvas bounds.`,
11092
+ nodeId: node.id
11093
+ });
11094
+ }
10487
11095
  }
10488
11096
  if ("children" in node && Array.isArray(node.children)) {
10489
11097
  for (const child of node.children) {
@@ -10805,43 +11413,45 @@ var SnapEngine = class {
10805
11413
  let snappedX = movingNode.x;
10806
11414
  let snappedY = movingNode.y;
10807
11415
  const guides = [];
11416
+ const movingW = typeof movingNode.width === "number" ? movingNode.width : 0;
11417
+ const movingH = typeof movingNode.height === "number" ? movingNode.height : 0;
10808
11418
  const nodeLeft = movingNode.x;
10809
- const nodeCenter = movingNode.x + movingNode.width / 2;
10810
- const nodeRight = movingNode.x + movingNode.width;
11419
+ const nodeCenter = movingNode.x + movingW / 2;
11420
+ const nodeRight = movingNode.x + movingW;
10811
11421
  const nodeTop = movingNode.y;
10812
- const nodeMiddle = movingNode.y + movingNode.height / 2;
10813
- const nodeBottom = movingNode.y + movingNode.height;
11422
+ const nodeMiddle = movingNode.y + movingH / 2;
11423
+ const nodeBottom = movingNode.y + movingH;
10814
11424
  const safeMarginX = Math.round(canvasWidth * 0.05);
10815
11425
  const safeMarginY = Math.round(canvasHeight * 0.05);
10816
11426
  const canvasCenterX = canvasWidth / 2;
10817
11427
  const canvasCenterY = canvasHeight / 2;
10818
11428
  if (Math.abs(nodeCenter - canvasCenterX) < threshold) {
10819
- snappedX = canvasCenterX - movingNode.width / 2;
11429
+ snappedX = canvasCenterX - movingW / 2;
10820
11430
  guides.push({ type: "vertical", position: canvasCenterX });
10821
11431
  }
10822
11432
  if (Math.abs(nodeMiddle - canvasCenterY) < threshold) {
10823
- snappedY = canvasCenterY - movingNode.height / 2;
11433
+ snappedY = canvasCenterY - movingH / 2;
10824
11434
  guides.push({ type: "horizontal", position: canvasCenterY });
10825
11435
  }
10826
11436
  if (Math.abs(nodeLeft - safeMarginX) < threshold) {
10827
11437
  snappedX = safeMarginX;
10828
11438
  guides.push({ type: "vertical", position: safeMarginX });
10829
11439
  } else if (Math.abs(nodeRight - (canvasWidth - safeMarginX)) < threshold) {
10830
- snappedX = canvasWidth - safeMarginX - movingNode.width;
11440
+ snappedX = canvasWidth - safeMarginX - movingW;
10831
11441
  guides.push({ type: "vertical", position: canvasWidth - safeMarginX });
10832
11442
  }
10833
11443
  if (Math.abs(nodeTop - safeMarginY) < threshold) {
10834
11444
  snappedY = safeMarginY;
10835
11445
  guides.push({ type: "horizontal", position: safeMarginY });
10836
11446
  } else if (Math.abs(nodeBottom - (canvasHeight - safeMarginY)) < threshold) {
10837
- snappedY = canvasHeight - safeMarginY - movingNode.height;
11447
+ snappedY = canvasHeight - safeMarginY - movingH;
10838
11448
  guides.push({ type: "horizontal", position: canvasHeight - safeMarginY });
10839
11449
  }
10840
11450
  for (const other of otherNodes) {
10841
11451
  const otherX = other.x;
10842
11452
  const otherY = other.y;
10843
- const otherW = other.width;
10844
- const otherH = other.height;
11453
+ const otherW = typeof other.width === "number" ? other.width : 0;
11454
+ const otherH = typeof other.height === "number" ? other.height : 0;
10845
11455
  const otherCenter = otherX + otherW / 2;
10846
11456
  const otherMiddle = otherY + otherH / 2;
10847
11457
  const minXDist = Math.min(
@@ -10861,29 +11471,31 @@ var SnapEngine = class {
10861
11471
  snappedX = otherX;
10862
11472
  guides.push({ type: "vertical", position: otherX });
10863
11473
  } else if (Math.abs(nodeCenter - otherCenter) < threshold) {
10864
- snappedX = otherCenter - movingNode.width / 2;
11474
+ snappedX = otherCenter - movingW / 2;
10865
11475
  guides.push({ type: "vertical", position: otherCenter });
10866
11476
  } else if (Math.abs(nodeRight - (otherX + otherW)) < threshold) {
10867
- snappedX = otherX + otherW - movingNode.width;
11477
+ snappedX = otherX + otherW - movingW;
10868
11478
  guides.push({ type: "vertical", position: otherX + otherW });
10869
11479
  }
10870
11480
  if (Math.abs(nodeTop - otherY) < threshold) {
10871
11481
  snappedY = otherY;
10872
11482
  guides.push({ type: "horizontal", position: otherY });
10873
11483
  } else if (Math.abs(nodeMiddle - otherMiddle) < threshold) {
10874
- snappedY = otherMiddle - movingNode.height / 2;
11484
+ snappedY = otherMiddle - movingH / 2;
10875
11485
  guides.push({ type: "horizontal", position: otherMiddle });
10876
11486
  } else if (Math.abs(nodeBottom - (otherY + otherH)) < threshold) {
10877
- snappedY = otherY + otherH - movingNode.height;
11487
+ snappedY = otherY + otherH - movingH;
10878
11488
  guides.push({ type: "horizontal", position: otherY + otherH });
10879
11489
  }
10880
11490
  }
10881
11491
  if (otherNodes.length >= 2) {
10882
11492
  const sortedX = [...otherNodes].sort((a, b) => a.x - b.x);
10883
11493
  for (let i = 0; i < sortedX.length - 1; i++) {
10884
- const gap = sortedX[i + 1].x - (sortedX[i].x + sortedX[i].width);
11494
+ const itemW = typeof sortedX[i].width === "number" ? sortedX[i].width : 0;
11495
+ const nextItemW = typeof sortedX[i + 1].width === "number" ? sortedX[i + 1].width : 0;
11496
+ const gap = sortedX[i + 1].x - (sortedX[i].x + itemW);
10885
11497
  if (gap > 0) {
10886
- const targetNextX = sortedX[i + 1].x + sortedX[i + 1].width + gap;
11498
+ const targetNextX = sortedX[i + 1].x + nextItemW + gap;
10887
11499
  if (Math.abs(nodeLeft - targetNextX) < threshold) {
10888
11500
  snappedX = targetNextX;
10889
11501
  guides.push({ type: "vertical", position: targetNextX });
@@ -11281,7 +11893,12 @@ var LayoutEngine = class {
11281
11893
  const anchor = node.anchor;
11282
11894
  if (anchor && anchor.targetId && result[anchor.targetId]) {
11283
11895
  const targetBounds = result[anchor.targetId];
11284
- const currentBounds = result[node.id] || { x: node.x, y: node.y, width: node.width, height: node.height };
11896
+ const currentBounds = result[node.id] || {
11897
+ x: node.x,
11898
+ y: node.y,
11899
+ width: typeof node.width === "number" ? node.width : 400,
11900
+ height: typeof node.height === "number" ? node.height : 120
11901
+ };
11285
11902
  let targetPointX = targetBounds.x + targetBounds.width / 2;
11286
11903
  let targetPointY = targetBounds.y + targetBounds.height / 2;
11287
11904
  const targetSide = anchor.targetSide || "right";
@@ -11320,10 +11937,12 @@ var LayoutEngine = class {
11320
11937
  const startTarget = lineNode.startNodeId ? result[lineNode.startNodeId] : void 0;
11321
11938
  const endTarget = lineNode.endNodeId ? result[lineNode.endNodeId] : void 0;
11322
11939
  if (startTarget || endTarget || lineNode.startX !== void 0 || lineNode.endX !== void 0) {
11940
+ const fallbackEndW = typeof node.width === "number" ? node.width : 0;
11941
+ const fallbackEndH = typeof node.height === "number" ? node.height : 0;
11323
11942
  const startX = startTarget ? startTarget.x + startTarget.width / 2 : lineNode.startX ?? node.x;
11324
11943
  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;
11944
+ const endX = endTarget ? endTarget.x + endTarget.width / 2 : lineNode.endX ?? node.x + fallbackEndW;
11945
+ const endY = endTarget ? endTarget.y + endTarget.height / 2 : lineNode.endY ?? node.y + fallbackEndH;
11327
11946
  const minX = Math.min(startX, endX);
11328
11947
  const minY = Math.min(startY, endY);
11329
11948
  const lineW = Math.max(1, Math.abs(endX - startX));
@@ -11343,7 +11962,9 @@ var LayoutEngine = class {
11343
11962
  const fromTarget = conn.fromNodeId ? result[conn.fromNodeId] : void 0;
11344
11963
  const toTarget = conn.toNodeId ? result[conn.toNodeId] : void 0;
11345
11964
  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) };
11965
+ const fallbackConnW = typeof node.width === "number" ? node.width : 100;
11966
+ const fallbackConnH = typeof node.height === "number" ? node.height : 100;
11967
+ const toPt = toTarget ? this.resolveAnchorPoint(toTarget, conn.toAnchor || conn.toElement) : { x: node.x + fallbackConnW, y: node.y + fallbackConnH };
11347
11968
  const minX = Math.min(fromPt.x, toPt.x);
11348
11969
  const minY = Math.min(fromPt.y, toPt.y);
11349
11970
  const connW = Math.max(1, Math.abs(toPt.x - fromPt.x));
@@ -11396,8 +12017,22 @@ var LayoutEngine = class {
11396
12017
  computeNodeGeometry(node, doc, context, result, parentX = 0, parentY = 0, isAbsoluteSlot = false) {
11397
12018
  let absX = isAbsoluteSlot ? parentX : parentX + node.x;
11398
12019
  let absY = isAbsoluteSlot ? parentY : parentY + node.y;
11399
- let width = node.width;
11400
- let height = node.height;
12020
+ let width;
12021
+ let height;
12022
+ if (node.type === "text") {
12023
+ const fontSize = node.style?.fontSize ?? 48;
12024
+ const fontWeight = node.style?.fontWeight ?? "normal";
12025
+ const fontFamily = node.style?.fontFamily ?? "Inter, sans-serif";
12026
+ const textContent = node.text ?? "Text";
12027
+ const measuredW = measureTextWidth(textContent, fontSize, fontWeight, fontFamily);
12028
+ width = typeof node.width === "number" && node.width > 0 ? node.width : measuredW;
12029
+ const lineHeight = node.style?.lineHeight ?? 1.2;
12030
+ const measuredH = Math.ceil(fontSize * lineHeight);
12031
+ height = typeof node.height === "number" && node.height > 0 ? node.height : measuredH;
12032
+ } else {
12033
+ width = typeof node.width === "number" ? node.width : 400;
12034
+ height = typeof node.height === "number" ? node.height : 120;
12035
+ }
11401
12036
  if (node.type === "line" || node.shapeKind === "line") {
11402
12037
  const strokeW = node.style?.strokeWidth ?? node.strokeWidth;
11403
12038
  if (typeof strokeW === "number" && strokeW > 0) {
@@ -11430,7 +12065,8 @@ var LayoutEngine = class {
11430
12065
  const scaleX = containerW / (doc.canvas.width || 1280);
11431
12066
  absX = Math.round(parentX + node.x * scaleX);
11432
12067
  if (node.layout?.constraints?.widthMode !== "fixed") {
11433
- width = Math.round(node.width * scaleX);
12068
+ const baseW = typeof node.width === "number" ? node.width : width;
12069
+ width = Math.round(baseW * scaleX);
11434
12070
  }
11435
12071
  }
11436
12072
  if (verticalPin === "center") {
@@ -11441,7 +12077,8 @@ var LayoutEngine = class {
11441
12077
  const scaleY = containerH / (doc.canvas.height || 720);
11442
12078
  absY = Math.round(parentY + node.y * scaleY);
11443
12079
  if (node.layout?.constraints?.heightMode !== "fixed") {
11444
- height = Math.round(node.height * scaleY);
12080
+ const baseH = typeof node.height === "number" ? node.height : height;
12081
+ height = Math.round(baseH * scaleY);
11445
12082
  }
11446
12083
  }
11447
12084
  }
@@ -11614,7 +12251,7 @@ var LayoutEngine = class {
11614
12251
  }
11615
12252
  }
11616
12253
  if (effectiveHeightMode === "hug") {
11617
- height = activeChildren.length > 0 ? hugHeight : node.height || 240;
12254
+ height = activeChildren.length > 0 ? hugHeight : typeof node.height === "number" ? node.height : 240;
11618
12255
  } else if (effectiveHeightMode !== "fill") {
11619
12256
  if (activeChildren.length > 0 && hugHeight > height) {
11620
12257
  height = hugHeight;
@@ -11711,14 +12348,14 @@ var LayoutEngine = class {
11711
12348
  const hugWidth = maxChildW + normPadding.left + normPadding.right;
11712
12349
  const hugHeight = totalContentH + normPadding.top + normPadding.bottom;
11713
12350
  if (effectiveWidthMode === "hug") {
11714
- width = activeColChildren.length > 0 ? hugWidth : node.width || 320;
12351
+ width = activeColChildren.length > 0 ? hugWidth : typeof node.width === "number" ? node.width : 320;
11715
12352
  } else if (effectiveWidthMode !== "fill") {
11716
12353
  if (activeColChildren.length > 0 && hugWidth > width) {
11717
12354
  width = hugWidth;
11718
12355
  }
11719
12356
  }
11720
12357
  if (effectiveHeightMode === "hug") {
11721
- height = activeColChildren.length > 0 ? hugHeight : node.height || 240;
12358
+ height = activeColChildren.length > 0 ? hugHeight : typeof node.height === "number" ? node.height : 240;
11722
12359
  } else if (effectiveHeightMode !== "fill") {
11723
12360
  if (activeColChildren.length > 0 && hugHeight > height) {
11724
12361
  height = hugHeight;
@@ -12043,7 +12680,9 @@ var SelectionEngine = class {
12043
12680
  for (let i = container.children.length - 1; i >= 0; i--) {
12044
12681
  const child = container.children[i];
12045
12682
  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) {
12683
+ const childW = typeof child.width === "number" ? child.width : 0;
12684
+ const childH = typeof child.height === "number" ? child.height : 0;
12685
+ if (clickPoint.x >= child.x && clickPoint.x <= child.x + childW && clickPoint.y >= child.y && clickPoint.y <= child.y + childH) {
12047
12686
  this.select(child.id, doc);
12048
12687
  return true;
12049
12688
  }
@@ -12175,56 +12814,58 @@ var TransformEngine = class {
12175
12814
  */
12176
12815
  static resizeNode(node, handle, dx, dy, options = {}) {
12177
12816
  const { lockAspectRatio = false, minWidth = 10, minHeight = 10 } = options;
12817
+ const initialW = typeof node.width === "number" ? node.width : 200;
12818
+ const initialH = typeof node.height === "number" ? node.height : 50;
12178
12819
  let newX = node.x;
12179
12820
  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;
12821
+ let newWidth = initialW;
12822
+ let newHeight = initialH;
12823
+ const initialAspect = initialW > 0 && initialH > 0 ? initialW / initialH : 1;
12183
12824
  switch (handle) {
12184
12825
  case "e":
12185
- newWidth = Math.max(minWidth, node.width + dx);
12826
+ newWidth = Math.max(minWidth, initialW + dx);
12186
12827
  if (lockAspectRatio) newHeight = Math.max(minHeight, newWidth / initialAspect);
12187
12828
  break;
12188
12829
  case "w": {
12189
- const potentialW = node.width - dx;
12830
+ const potentialW = initialW - dx;
12190
12831
  if (potentialW >= minWidth) {
12191
12832
  newWidth = potentialW;
12192
12833
  newX = node.x + dx;
12193
12834
  } else {
12194
12835
  newWidth = minWidth;
12195
- newX = node.x + (node.width - minWidth);
12836
+ newX = node.x + (initialW - minWidth);
12196
12837
  }
12197
12838
  if (lockAspectRatio) newHeight = Math.max(minHeight, newWidth / initialAspect);
12198
12839
  break;
12199
12840
  }
12200
12841
  case "s":
12201
- newHeight = Math.max(minHeight, node.height + dy);
12842
+ newHeight = Math.max(minHeight, initialH + dy);
12202
12843
  if (lockAspectRatio) newWidth = Math.max(minWidth, newHeight * initialAspect);
12203
12844
  break;
12204
12845
  case "n": {
12205
- const potentialH = node.height - dy;
12846
+ const potentialH = initialH - dy;
12206
12847
  if (potentialH >= minHeight) {
12207
12848
  newHeight = potentialH;
12208
12849
  newY = node.y + dy;
12209
12850
  } else {
12210
12851
  newHeight = minHeight;
12211
- newY = node.y + (node.height - minHeight);
12852
+ newY = node.y + (initialH - minHeight);
12212
12853
  }
12213
12854
  if (lockAspectRatio) newWidth = Math.max(minWidth, newHeight * initialAspect);
12214
12855
  break;
12215
12856
  }
12216
12857
  case "se":
12217
- newWidth = Math.max(minWidth, node.width + dx);
12218
- newHeight = Math.max(minHeight, node.height + dy);
12858
+ newWidth = Math.max(minWidth, initialW + dx);
12859
+ newHeight = Math.max(minHeight, initialH + dy);
12219
12860
  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);
12861
+ const scale = Math.max(newWidth / initialW, newHeight / initialH);
12862
+ newWidth = Math.max(minWidth, initialW * scale);
12863
+ newHeight = Math.max(minHeight, initialH * scale);
12223
12864
  }
12224
12865
  break;
12225
12866
  case "nw": {
12226
- const potW = node.width - dx;
12227
- const potH = node.height - dy;
12867
+ const potW = initialW - dx;
12868
+ const potH = initialH - dy;
12228
12869
  if (potW >= minWidth) {
12229
12870
  newWidth = potW;
12230
12871
  newX = node.x + dx;
@@ -12234,15 +12875,15 @@ var TransformEngine = class {
12234
12875
  newY = node.y + dy;
12235
12876
  }
12236
12877
  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);
12878
+ const scale = Math.max(newWidth / initialW, newHeight / initialH);
12879
+ newWidth = Math.max(minWidth, initialW * scale);
12880
+ newHeight = Math.max(minHeight, initialH * scale);
12240
12881
  }
12241
12882
  break;
12242
12883
  }
12243
12884
  case "ne": {
12244
- newWidth = Math.max(minWidth, node.width + dx);
12245
- const potH = node.height - dy;
12885
+ newWidth = Math.max(minWidth, initialW + dx);
12886
+ const potH = initialH - dy;
12246
12887
  if (potH >= minHeight) {
12247
12888
  newHeight = potH;
12248
12889
  newY = node.y + dy;
@@ -12253,12 +12894,12 @@ var TransformEngine = class {
12253
12894
  break;
12254
12895
  }
12255
12896
  case "sw": {
12256
- const potW = node.width - dx;
12897
+ const potW = initialW - dx;
12257
12898
  if (potW >= minWidth) {
12258
12899
  newWidth = potW;
12259
12900
  newX = node.x + dx;
12260
12901
  }
12261
- newHeight = Math.max(minHeight, node.height + dy);
12902
+ newHeight = Math.max(minHeight, initialH + dy);
12262
12903
  if (lockAspectRatio) {
12263
12904
  newWidth = Math.max(minWidth, newHeight * initialAspect);
12264
12905
  }
@@ -12302,9 +12943,9 @@ var TransformEngine = class {
12302
12943
  }
12303
12944
  } else {
12304
12945
  const minX = Math.min(...nodes.map((n) => n.x));
12305
- const maxX = Math.max(...nodes.map((n) => n.x + n.width));
12946
+ const maxX = Math.max(...nodes.map((n) => n.x + (typeof n.width === "number" ? n.width : 0)));
12306
12947
  const minY = Math.min(...nodes.map((n) => n.y));
12307
- const maxY = Math.max(...nodes.map((n) => n.y + n.height));
12948
+ const maxY = Math.max(...nodes.map((n) => n.y + (typeof n.height === "number" ? n.height : 0)));
12308
12949
  switch (alignment) {
12309
12950
  case "left":
12310
12951
  targetCoord = minX;
@@ -12329,24 +12970,26 @@ var TransformEngine = class {
12329
12970
  return nodes.map((node) => {
12330
12971
  let updatedX = node.x;
12331
12972
  let updatedY = node.y;
12973
+ const nW = typeof node.width === "number" ? node.width : 0;
12974
+ const nH = typeof node.height === "number" ? node.height : 0;
12332
12975
  switch (alignment) {
12333
12976
  case "left":
12334
12977
  updatedX = targetCoord;
12335
12978
  break;
12336
12979
  case "center":
12337
- updatedX = Math.round(targetCoord - node.width / 2);
12980
+ updatedX = Math.round(targetCoord - nW / 2);
12338
12981
  break;
12339
12982
  case "right":
12340
- updatedX = Math.round(targetCoord - node.width);
12983
+ updatedX = Math.round(targetCoord - nW);
12341
12984
  break;
12342
12985
  case "top":
12343
12986
  updatedY = targetCoord;
12344
12987
  break;
12345
12988
  case "middle":
12346
- updatedY = Math.round(targetCoord - node.height / 2);
12989
+ updatedY = Math.round(targetCoord - nH / 2);
12347
12990
  break;
12348
12991
  case "bottom":
12349
- updatedY = Math.round(targetCoord - node.height);
12992
+ updatedY = Math.round(targetCoord - nH);
12350
12993
  break;
12351
12994
  }
12352
12995
  return { ...node, x: updatedX, y: updatedY };
@@ -12361,33 +13004,37 @@ var TransformEngine = class {
12361
13004
  const first = sorted[0];
12362
13005
  const last = sorted[sorted.length - 1];
12363
13006
  if (axis === "horizontal") {
12364
- const totalSpan = last.x + last.width - first.x;
12365
- const totalNodeWidths = sorted.reduce((sum, n) => sum + n.width, 0);
13007
+ const lastW = typeof last.width === "number" ? last.width : 0;
13008
+ const totalSpan = last.x + lastW - first.x;
13009
+ const totalNodeWidths = sorted.reduce((sum, n) => sum + (typeof n.width === "number" ? n.width : 0), 0);
12366
13010
  const totalGapSpace = totalSpan - totalNodeWidths;
12367
13011
  const gap = totalGapSpace / (sorted.length - 1);
12368
13012
  let currentX = first.x;
12369
13013
  return sorted.map((node, i) => {
13014
+ const nW = typeof node.width === "number" ? node.width : 0;
12370
13015
  if (i === 0) {
12371
- currentX += node.width + gap;
13016
+ currentX += nW + gap;
12372
13017
  return node;
12373
13018
  }
12374
13019
  const updated = { ...node, x: Math.round(currentX) };
12375
- currentX += node.width + gap;
13020
+ currentX += nW + gap;
12376
13021
  return updated;
12377
13022
  });
12378
13023
  } else {
12379
- const totalSpan = last.y + last.height - first.y;
12380
- const totalNodeHeights = sorted.reduce((sum, n) => sum + n.height, 0);
13024
+ const lastH = typeof last.height === "number" ? last.height : 0;
13025
+ const totalSpan = last.y + lastH - first.y;
13026
+ const totalNodeHeights = sorted.reduce((sum, n) => sum + (typeof n.height === "number" ? n.height : 0), 0);
12381
13027
  const totalGapSpace = totalSpan - totalNodeHeights;
12382
13028
  const gap = totalGapSpace / (sorted.length - 1);
12383
13029
  let currentY = first.y;
12384
13030
  return sorted.map((node, i) => {
13031
+ const nH = typeof node.height === "number" ? node.height : 0;
12385
13032
  if (i === 0) {
12386
- currentY += node.height + gap;
13033
+ currentY += nH + gap;
12387
13034
  return node;
12388
13035
  }
12389
13036
  const updated = { ...node, y: Math.round(currentY) };
12390
- currentY += node.height + gap;
13037
+ currentY += nH + gap;
12391
13038
  return updated;
12392
13039
  });
12393
13040
  }
@@ -12868,21 +13515,23 @@ var SmartGuideEngine = class {
12868
13515
  let snappedX = false;
12869
13516
  let snappedY = false;
12870
13517
  const guides = [];
13518
+ const movingW = typeof moving.width === "number" ? moving.width : 0;
13519
+ const movingH = typeof moving.height === "number" ? moving.height : 0;
12871
13520
  const left = moving.x;
12872
- const centerX = moving.x + moving.width / 2;
12873
- const right = moving.x + moving.width;
13521
+ const centerX = moving.x + movingW / 2;
13522
+ const right = moving.x + movingW;
12874
13523
  const top = moving.y;
12875
- const centerY = moving.y + moving.height / 2;
12876
- const bottom = moving.y + moving.height;
13524
+ const centerY = moving.y + movingH / 2;
13525
+ const bottom = moving.y + movingH;
12877
13526
  const canvasCenterX = canvasWidth / 2;
12878
13527
  const canvasCenterY = canvasHeight / 2;
12879
13528
  if (Math.abs(centerX - canvasCenterX) <= threshold) {
12880
- finalX = Math.round(canvasCenterX - moving.width / 2);
13529
+ finalX = Math.round(canvasCenterX - movingW / 2);
12881
13530
  snappedX = true;
12882
13531
  guides.push({ type: "vertical", position: canvasCenterX, label: "Canvas Center X" });
12883
13532
  }
12884
13533
  if (Math.abs(centerY - canvasCenterY) <= threshold) {
12885
- finalY = Math.round(canvasCenterY - moving.height / 2);
13534
+ finalY = Math.round(canvasCenterY - movingH / 2);
12886
13535
  snappedY = true;
12887
13536
  guides.push({ type: "horizontal", position: canvasCenterY, label: "Canvas Center Y" });
12888
13537
  }
@@ -12894,7 +13543,7 @@ var SmartGuideEngine = class {
12894
13543
  snappedX = true;
12895
13544
  guides.push({ type: "vertical", position: safeMarginX, label: "Safe Margin Left" });
12896
13545
  } else if (Math.abs(right - (canvasWidth - safeMarginX)) <= threshold) {
12897
- finalX = canvasWidth - safeMarginX - moving.width;
13546
+ finalX = canvasWidth - safeMarginX - movingW;
12898
13547
  snappedX = true;
12899
13548
  guides.push({ type: "vertical", position: canvasWidth - safeMarginX, label: "Safe Margin Right" });
12900
13549
  }
@@ -12905,29 +13554,31 @@ var SmartGuideEngine = class {
12905
13554
  snappedY = true;
12906
13555
  guides.push({ type: "horizontal", position: safeMarginY, label: "Safe Margin Top" });
12907
13556
  } else if (Math.abs(bottom - (canvasHeight - safeMarginY)) <= threshold) {
12908
- finalY = canvasHeight - safeMarginY - moving.height;
13557
+ finalY = canvasHeight - safeMarginY - movingH;
12909
13558
  snappedY = true;
12910
13559
  guides.push({ type: "horizontal", position: canvasHeight - safeMarginY, label: "Safe Margin Bottom" });
12911
13560
  }
12912
13561
  }
12913
13562
  for (const other of otherNodes) {
13563
+ const otherW = typeof other.width === "number" ? other.width : 0;
13564
+ const otherH = typeof other.height === "number" ? other.height : 0;
12914
13565
  const oLeft = other.x;
12915
- const oCenterX = other.x + other.width / 2;
12916
- const oRight = other.x + other.width;
13566
+ const oCenterX = other.x + otherW / 2;
13567
+ const oRight = other.x + otherW;
12917
13568
  const oTop = other.y;
12918
- const oCenterY = other.y + other.height / 2;
12919
- const oBottom = other.y + other.height;
13569
+ const oCenterY = other.y + otherH / 2;
13570
+ const oBottom = other.y + otherH;
12920
13571
  if (!snappedX) {
12921
13572
  if (Math.abs(left - oLeft) <= threshold) {
12922
13573
  finalX = oLeft;
12923
13574
  snappedX = true;
12924
13575
  guides.push({ type: "vertical", position: oLeft, label: "Align Left" });
12925
13576
  } else if (Math.abs(centerX - oCenterX) <= threshold) {
12926
- finalX = Math.round(oCenterX - moving.width / 2);
13577
+ finalX = Math.round(oCenterX - movingW / 2);
12927
13578
  snappedX = true;
12928
13579
  guides.push({ type: "vertical", position: oCenterX, label: "Align Center X" });
12929
13580
  } else if (Math.abs(right - oRight) <= threshold) {
12930
- finalX = Math.round(oRight - moving.width);
13581
+ finalX = Math.round(oRight - movingW);
12931
13582
  snappedX = true;
12932
13583
  guides.push({ type: "vertical", position: oRight, label: "Align Right" });
12933
13584
  } else if (Math.abs(left - oRight) <= threshold) {
@@ -12935,7 +13586,7 @@ var SmartGuideEngine = class {
12935
13586
  snappedX = true;
12936
13587
  guides.push({ type: "vertical", position: oRight, label: "Edge Flush Right" });
12937
13588
  } else if (Math.abs(right - oLeft) <= threshold) {
12938
- finalX = Math.round(oLeft - moving.width);
13589
+ finalX = Math.round(oLeft - movingW);
12939
13590
  snappedX = true;
12940
13591
  guides.push({ type: "vertical", position: oLeft, label: "Edge Flush Left" });
12941
13592
  }
@@ -12946,11 +13597,11 @@ var SmartGuideEngine = class {
12946
13597
  snappedY = true;
12947
13598
  guides.push({ type: "horizontal", position: oTop, label: "Align Top" });
12948
13599
  } else if (Math.abs(centerY - oCenterY) <= threshold) {
12949
- finalY = Math.round(oCenterY - moving.height / 2);
13600
+ finalY = Math.round(oCenterY - movingH / 2);
12950
13601
  snappedY = true;
12951
13602
  guides.push({ type: "horizontal", position: oCenterY, label: "Align Center Y" });
12952
13603
  } else if (Math.abs(bottom - oBottom) <= threshold) {
12953
- finalY = Math.round(oBottom - moving.height);
13604
+ finalY = Math.round(oBottom - movingH);
12954
13605
  snappedY = true;
12955
13606
  guides.push({ type: "horizontal", position: oBottom, label: "Align Bottom" });
12956
13607
  } else if (Math.abs(top - oBottom) <= threshold) {
@@ -12958,7 +13609,7 @@ var SmartGuideEngine = class {
12958
13609
  snappedY = true;
12959
13610
  guides.push({ type: "horizontal", position: oBottom, label: "Edge Flush Bottom" });
12960
13611
  } else if (Math.abs(bottom - oTop) <= threshold) {
12961
- finalY = Math.round(oTop - moving.height);
13612
+ finalY = Math.round(oTop - movingH);
12962
13613
  snappedY = true;
12963
13614
  guides.push({ type: "horizontal", position: oTop, label: "Edge Flush Top" });
12964
13615
  }
@@ -14050,7 +14701,9 @@ var ExportValidator = class {
14050
14701
  });
14051
14702
  }
14052
14703
  }
14053
- if (isNaN(node.x) || isNaN(node.y) || isNaN(node.width) || isNaN(node.height)) {
14704
+ const widthIsNaN = typeof node.width === "number" ? isNaN(node.width) : false;
14705
+ const heightIsNaN = typeof node.height === "number" ? isNaN(node.height) : false;
14706
+ if (isNaN(node.x) || isNaN(node.y) || widthIsNaN || heightIsNaN) {
14054
14707
  diagnostics.push({
14055
14708
  severity: "error",
14056
14709
  code: "UNRESOLVED_CONSTRAINTS",
@@ -15563,8 +16216,8 @@ function evaluateOverlayDocument(doc, context = {}, time = 0) {
15563
16216
  resolvedText = dataBindingEngine.evaluateExpression(responsiveNode.text, evalVariables);
15564
16217
  }
15565
16218
  const computedBounds = computedLayout.nodes[responsiveNode.id];
15566
- const finalWidth = computedBounds ? computedBounds.width : animState.width;
15567
- const finalHeight = computedBounds ? computedBounds.height : animState.height;
16219
+ const finalWidth = computedBounds ? computedBounds.width : typeof animState.width === "number" ? animState.width : 400;
16220
+ const finalHeight = computedBounds ? computedBounds.height : typeof animState.height === "number" ? animState.height : 120;
15568
16221
  const finalX = computedBounds ? computedBounds.x : animState.x;
15569
16222
  const finalY = computedBounds ? computedBounds.y : animState.y;
15570
16223
  let transform = {
@@ -15675,7 +16328,8 @@ function evaluateOverlayDocument(doc, context = {}, time = 0) {
15675
16328
  style,
15676
16329
  content,
15677
16330
  geometry,
15678
- children: evaluatedChildren
16331
+ children: evaluatedChildren,
16332
+ metadata: "textEffectRef" in responsiveNode ? { textEffectRef: responsiveNode.textEffectRef } : void 0
15679
16333
  };
15680
16334
  nodeMap[evaluatedNode.id] = evaluatedNode;
15681
16335
  return evaluatedNode;
@@ -16018,10 +16672,141 @@ function resolveBehaviorToAnimationSpec(behavior, node) {
16018
16672
  }
16019
16673
  }
16020
16674
 
16675
+ // src/smartOverlays/runtime/canvasRenderer.ts
16676
+ function alpha(value, fallback = 1) {
16677
+ if (value === void 0) return fallback;
16678
+ return value > 1 ? value / 100 : Math.max(0, Math.min(1, value));
16679
+ }
16680
+ function roundedRect(ctx, x, y, width, height, radius) {
16681
+ const r = Math.max(0, Math.min(radius, Math.min(width, height) / 2));
16682
+ if (typeof ctx.roundRect === "function") {
16683
+ ctx.beginPath();
16684
+ ctx.roundRect(x, y, width, height, r);
16685
+ return;
16686
+ }
16687
+ ctx.beginPath();
16688
+ ctx.rect(x, y, width, height);
16689
+ }
16690
+ function drawText(ctx, node, text) {
16691
+ const style = node.style;
16692
+ const size = Math.max(1, style.fontSize ?? 20);
16693
+ const weight = style.fontWeight ?? "400";
16694
+ const family = style.fontFamily ?? "Inter, sans-serif";
16695
+ const lineHeight = (style.lineHeight ?? 1.2) * size;
16696
+ const maxWidth = Math.max(1, node.transform.width);
16697
+ const lines = [];
16698
+ let line = "";
16699
+ for (const word of text.split(/\s+/)) {
16700
+ const candidate = line ? `${line} ${word}` : word;
16701
+ if (line && ctx.measureText(candidate).width > maxWidth) {
16702
+ lines.push(line);
16703
+ line = word;
16704
+ } else {
16705
+ line = candidate;
16706
+ }
16707
+ }
16708
+ if (line || !lines.length) lines.push(line);
16709
+ const maxLines = style.maxLines;
16710
+ const visibleLines = maxLines ? lines.slice(0, maxLines) : lines;
16711
+ ctx.font = `${weight} ${size}px ${family}`;
16712
+ ctx.fillStyle = style.textColor ?? style.fillColor ?? "#ffffff";
16713
+ ctx.textAlign = style.textAlign ?? "left";
16714
+ ctx.textBaseline = "top";
16715
+ const x = style.textAlign === "center" ? maxWidth / 2 : style.textAlign === "right" ? maxWidth : 0;
16716
+ const progress = node.content?.typewriterProgress;
16717
+ visibleLines.forEach((value, index) => {
16718
+ const lineText = progress === void 0 ? value : value.slice(0, Math.ceil(value.length * progress));
16719
+ ctx.fillText(lineText, x, index * lineHeight, maxWidth);
16720
+ });
16721
+ }
16722
+ function drawPinnedTextEffect(ctx, node, text, time) {
16723
+ const reference = node.metadata?.textEffectRef;
16724
+ const snapshot = reference?.snapshot;
16725
+ if (!snapshot?.effectLayers || !snapshot.text || !snapshot.canvas) return false;
16726
+ const width = Math.max(1, Math.ceil(node.transform.width));
16727
+ const height = Math.max(1, Math.ceil(node.transform.height));
16728
+ const effectCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(width, height) : typeof document !== "undefined" ? Object.assign(document.createElement("canvas"), { width, height }) : null;
16729
+ const effectCtx = effectCanvas?.getContext("2d");
16730
+ if (!effectCtx) return false;
16731
+ const effectScene = JSON.parse(JSON.stringify(snapshot));
16732
+ effectScene.canvas.width = width;
16733
+ effectScene.canvas.height = height;
16734
+ effectScene.text.content = text;
16735
+ effectScene.text.fontFamily = node.style.fontFamily;
16736
+ effectScene.text.fontSize = node.style.fontSize;
16737
+ effectScene.text.fontWeight = node.style.fontWeight;
16738
+ effectScene.text.textPosX = "center";
16739
+ effectScene.text.textPosY = "middle";
16740
+ evaluateScene(effectScene, time, effectCtx);
16741
+ ctx.drawImage(effectCanvas, 0, 0, node.transform.width, node.transform.height);
16742
+ return true;
16743
+ }
16744
+ function drawNode(ctx, node, time) {
16745
+ if (!node.visible || node.style.opacity <= 1e-3) return;
16746
+ const { x, y, width, height, rotation, scaleX, scaleY, translateX, translateY } = node.transform;
16747
+ const style = node.style;
16748
+ ctx.save();
16749
+ ctx.translate(x + width / 2 + translateX, y + height / 2 + translateY);
16750
+ ctx.rotate(rotation * Math.PI / 180);
16751
+ ctx.scale(scaleX || 1, scaleY || 1);
16752
+ ctx.globalAlpha *= alpha(style.opacity);
16753
+ if (style.shadowColor || style.shadowBlur) {
16754
+ ctx.shadowColor = style.shadowColor ?? "rgba(0,0,0,0.5)";
16755
+ ctx.shadowBlur = style.shadowBlur ?? 0;
16756
+ }
16757
+ ctx.translate(-width / 2, -height / 2);
16758
+ if (style.fillGradient?.colors?.length) {
16759
+ 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);
16760
+ style.fillGradient.colors.forEach((color, index) => gradient.addColorStop(index / Math.max(1, style.fillGradient.colors.length - 1), color));
16761
+ ctx.fillStyle = gradient;
16762
+ ctx.globalAlpha *= alpha(style.fillOpacity);
16763
+ roundedRect(ctx, 0, 0, width, height, style.borderRadius ?? 0);
16764
+ ctx.fill();
16765
+ } else if (style.fillColor || node.type === "shape") {
16766
+ ctx.fillStyle = style.fillColor ?? "#334155";
16767
+ ctx.globalAlpha *= alpha(style.fillOpacity);
16768
+ roundedRect(ctx, 0, 0, width, height, style.borderRadius ?? 0);
16769
+ ctx.fill();
16770
+ }
16771
+ if (style.strokeColor && (style.strokeWidth ?? 0) > 0) {
16772
+ ctx.strokeStyle = style.strokeColor;
16773
+ ctx.lineWidth = style.strokeWidth ?? 1;
16774
+ roundedRect(ctx, 0, 0, width, height, style.borderRadius ?? 0);
16775
+ ctx.stroke();
16776
+ }
16777
+ if (node.type === "text" || node.type === "rich-text" || node.type === "metric" || node.type === "callout" || node.type === "annotation") {
16778
+ const text = node.content?.text ?? node.content?.formattedValue ?? node.content?.props?.body ?? node.content?.props?.label ?? "";
16779
+ if (text && !drawPinnedTextEffect(ctx, node, text, time)) drawText(ctx, node, text);
16780
+ } else if (node.type === "line" || node.type === "divider" || node.type === "connector") {
16781
+ ctx.strokeStyle = style.strokeColor ?? "#94a3b8";
16782
+ ctx.lineWidth = style.strokeWidth ?? 2;
16783
+ ctx.beginPath();
16784
+ ctx.moveTo(0, height / 2);
16785
+ ctx.lineTo(width, height / 2);
16786
+ ctx.stroke();
16787
+ } else if (node.type === "media" || node.type === "video" || node.type === "lottie") {
16788
+ ctx.fillStyle = "rgba(30,41,59,0.65)";
16789
+ ctx.fillRect(0, 0, width, height);
16790
+ ctx.strokeStyle = "rgba(148,163,184,0.65)";
16791
+ ctx.strokeRect(4, 4, Math.max(0, width - 8), Math.max(0, height - 8));
16792
+ }
16793
+ ctx.restore();
16794
+ node.children?.forEach((child) => drawNode(ctx, child, time));
16795
+ }
16796
+ function renderEvaluatedSceneToCanvas(scene, ctx, options = {}) {
16797
+ if (options.clear !== false) ctx.clearRect(0, 0, scene.canvas.width, scene.canvas.height);
16798
+ if (options.background !== false && scene.canvas.backgroundColor && scene.canvas.backgroundColor !== "transparent") {
16799
+ ctx.fillStyle = scene.canvas.backgroundColor;
16800
+ ctx.fillRect(0, 0, scene.canvas.width, scene.canvas.height);
16801
+ }
16802
+ scene.nodes.forEach((node) => drawNode(ctx, node, scene.time));
16803
+ }
16804
+
16021
16805
  // src/index.ts
16022
- var VERSION = "0.1.0";
16806
+ var VERSION = "1.4.0";
16023
16807
  export {
16024
16808
  ALL_TRANSITIONS,
16809
+ ASPECT_RATIO_PRESETS,
16025
16810
  AnimationPresetSchema,
16026
16811
  AnimationRuntime,
16027
16812
  AnimationSchema,
@@ -16115,6 +16900,9 @@ export {
16115
16900
  SmartOverlayRenderer,
16116
16901
  SnapEngine,
16117
16902
  TEMPLATE_CATEGORIES,
16903
+ TEXT_TEMPLATE_KIND,
16904
+ TEXT_TEMPLATE_RENDERER_VERSION,
16905
+ TEXT_TEMPLATE_SCHEMA_VERSION,
16118
16906
  TRANSITION_CATEGORIES,
16119
16907
  TRANSITION_PRESETS,
16120
16908
  TemplateCategorySchema,
@@ -16147,6 +16935,7 @@ export {
16147
16935
  alignToLottieJ,
16148
16936
  animationRuntime,
16149
16937
  animationValidator,
16938
+ applyEasing,
16150
16939
  applyFillColorToAll,
16151
16940
  applyLetterSpacing,
16152
16941
  applyMaskReveal,
@@ -16154,6 +16943,7 @@ export {
16154
16943
  applyStyleToLottie,
16155
16944
  applyStyleToLottieLayer,
16156
16945
  applyTimelineAtTime,
16946
+ assertValidTextTemplateArtifact,
16157
16947
  assetRegistry,
16158
16948
  bakeAnimationIntoLayer,
16159
16949
  blendColors,
@@ -16171,6 +16961,7 @@ export {
16171
16961
  calculateResizeBounds,
16172
16962
  calculateRotationAngle,
16173
16963
  canonicalContentHash,
16964
+ canonicalTemplateHash,
16174
16965
  canonicalizeSceneDocument,
16175
16966
  captureImageSourceDimensions,
16176
16967
  captureLottieFrames,
@@ -16183,6 +16974,7 @@ export {
16183
16974
  cloneSceneWithNewIds,
16184
16975
  commandExecutor,
16185
16976
  compileSemanticOverlay,
16977
+ compileTextTemplate,
16186
16978
  componentRegistry,
16187
16979
  computeAutoFitFontSize,
16188
16980
  computeFitZoom,
@@ -16227,6 +17019,7 @@ export {
16227
17019
  evaluateExportFrame,
16228
17020
  evaluateOverlayDocument,
16229
17021
  evaluateScene,
17022
+ evaluateSplitTextTransforms,
16230
17023
  evaluateTextEffect,
16231
17024
  evaluateTextTemplate,
16232
17025
  exportLottieToMp4,
@@ -16259,9 +17052,11 @@ export {
16259
17052
  getRenderCapabilities,
16260
17053
  getSceneTime,
16261
17054
  getSourceCropRect,
17055
+ getSpanForCharIndex,
16262
17056
  getSupportedWebMMimeType,
16263
17057
  getTemplatePreset,
16264
17058
  getTemplatesByCategory,
17059
+ getTextTemplateControls,
16265
17060
  getTransitionById,
16266
17061
  getTransitionByRenderer,
16267
17062
  getTransitionCategories,
@@ -16281,6 +17076,8 @@ export {
16281
17076
  injectSolidColor,
16282
17077
  injectText,
16283
17078
  injectTextStyle,
17079
+ interpolateColorString,
17080
+ interpolateValue,
16284
17081
  isKeyframed,
16285
17082
  isMp4ExportSupported,
16286
17083
  isWebMExportSupported,
@@ -16299,6 +17096,7 @@ export {
16299
17096
  newLayerId,
16300
17097
  normalizeTextEffect,
16301
17098
  normalizeTextTemplate,
17099
+ normalizeTextTemplateArtifact,
16302
17100
  parseHistorySnapshot,
16303
17101
  parseLottieJson,
16304
17102
  preloadGoogleFont,
@@ -16316,12 +17114,17 @@ export {
16316
17114
  removeKeyframe,
16317
17115
  removeTemplateKeyframe,
16318
17116
  removeTrack,
17117
+ renderCanonicalToCanvas,
17118
+ renderEvaluatedSceneToCanvas,
16319
17119
  renderPngSequence,
16320
17120
  renderSceneWebM,
16321
17121
  renderTextEffectCore,
17122
+ renderTextEffectToCanvas,
17123
+ renderTextTemplateToCanvas,
16322
17124
  resetFontLoader,
16323
17125
  resetSceneTime,
16324
17126
  resizeCharFillColors,
17127
+ resolveAnchorPosition,
16325
17128
  resolveAnimatedScalar,
16326
17129
  resolveBehaviorToAnimationSpec,
16327
17130
  resolveConform,
@@ -16331,6 +17134,7 @@ export {
16331
17134
  resolveMediaLayout,
16332
17135
  resolveNodeForBreakpoint,
16333
17136
  resolveSpatialConstraints,
17137
+ resolveTextTemplateArtifact,
16334
17138
  restoreLetterSpacing,
16335
17139
  rgbaToComponents,
16336
17140
  rotateCrop,
@@ -16351,7 +17155,9 @@ export {
16351
17155
  smartOverlayRegistry,
16352
17156
  snapEngine,
16353
17157
  snapshotScene,
17158
+ solveSpring,
16354
17159
  sortKeyframes,
17160
+ splitTextContent,
16355
17161
  streamExportFrames,
16356
17162
  supportsCtxFilter,
16357
17163
  supportsLetterSpacing,
@@ -16380,6 +17186,7 @@ export {
16380
17186
  validateTextEffectDefinition,
16381
17187
  validateTextEffectDefinitionStrict,
16382
17188
  validateTextTemplate,
17189
+ validateTextTemplateArtifact,
16383
17190
  validateTextTemplateStrict,
16384
17191
  viewportTransform,
16385
17192
  waitForFontsReady,