@clypra-studio/engine 1.5.0 → 1.7.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.
package/dist/index.cjs CHANGED
@@ -348,6 +348,8 @@ __export(index_exports, {
348
348
  resolveMediaLayout: () => resolveMediaLayout,
349
349
  resolveNodeForBreakpoint: () => resolveNodeForBreakpoint,
350
350
  resolveSpatialConstraints: () => resolveSpatialConstraints,
351
+ resolveTemplateControlValues: () => resolveTemplateControlValues,
352
+ resolveTemplateFontFamily: () => resolveTemplateFontFamily,
351
353
  resolveTextTemplateArtifact: () => resolveTextTemplateArtifact,
352
354
  restoreLetterSpacing: () => restoreLetterSpacing,
353
355
  rgbaToComponents: () => rgbaToComponents,
@@ -550,6 +552,12 @@ var BoundingBoxSchema = import_zod.z.object({
550
552
  mode: import_zod.z.enum(["ink", "panel"]).optional()
551
553
  });
552
554
  var EffectFullDefinitionSchema = EffectIndexItemSchema.extend({
555
+ schemaVersion: import_zod.z.number().optional(),
556
+ revisionId: import_zod.z.string().optional(),
557
+ contentHash: import_zod.z.string().optional(),
558
+ rendererVersion: import_zod.z.string().optional(),
559
+ revision: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
560
+ scene: import_zod.z.any().optional(),
553
561
  version: import_zod.z.string().optional(),
554
562
  description: import_zod.z.string(),
555
563
  tags: import_zod.z.array(import_zod.z.string()),
@@ -598,7 +606,15 @@ var TemplateCategorySchema = import_zod.z.enum([
598
606
  "caption",
599
607
  "callout",
600
608
  "social",
601
- "countdown"
609
+ "countdown",
610
+ "kinetic-type",
611
+ "cta",
612
+ "credits",
613
+ "quotes",
614
+ "sports",
615
+ "gaming",
616
+ "news",
617
+ "minimal"
602
618
  ]);
603
619
  var AnimationPresetSchema = import_zod.z.enum([
604
620
  "fade",
@@ -13038,6 +13054,478 @@ var BUILTIN_CANVAS_TEMPLATES = [
13038
13054
  }
13039
13055
  }
13040
13056
  ]
13057
+ },
13058
+ {
13059
+ id: "action-cta-card",
13060
+ label: "Modern Action CTA",
13061
+ category: "cta",
13062
+ duration: 4,
13063
+ canvasWidth: 1920,
13064
+ canvasHeight: 1080,
13065
+ layers: [
13066
+ {
13067
+ kind: "shape",
13068
+ id: "cta-bg",
13069
+ shape: "rect",
13070
+ fill: "rgba(18, 18, 28, 0.95)",
13071
+ stroke: { color: "#6366f1", width: 2 },
13072
+ x: 460,
13073
+ y: 380,
13074
+ width: 1e3,
13075
+ height: 320,
13076
+ animation: {
13077
+ in: "scale-in",
13078
+ out: "fade",
13079
+ inDuration: 0.5,
13080
+ outDuration: 0.3,
13081
+ hold: "full"
13082
+ }
13083
+ },
13084
+ {
13085
+ kind: "text",
13086
+ id: "cta-heading",
13087
+ content: "READY TO LEVEL UP?",
13088
+ fontFamily: "Poppins",
13089
+ fontSize: 64,
13090
+ fontWeight: 800,
13091
+ color: "#ffffff",
13092
+ align: "center",
13093
+ x: 460,
13094
+ y: 420,
13095
+ width: 1e3,
13096
+ height: 80,
13097
+ role: "primary",
13098
+ animation: {
13099
+ in: "slide-down",
13100
+ out: "fade",
13101
+ inDuration: 0.6,
13102
+ outDuration: 0.3,
13103
+ hold: "full"
13104
+ }
13105
+ },
13106
+ {
13107
+ kind: "text",
13108
+ id: "cta-sub",
13109
+ content: "Download Clypra Studio and start creating today.",
13110
+ fontFamily: "Inter Variable",
13111
+ fontSize: 26,
13112
+ fontWeight: 400,
13113
+ color: "#94a3b8",
13114
+ align: "center",
13115
+ x: 460,
13116
+ y: 510,
13117
+ width: 1e3,
13118
+ height: 40,
13119
+ role: "secondary",
13120
+ animation: {
13121
+ in: "fade",
13122
+ out: "fade",
13123
+ inDuration: 0.7,
13124
+ outDuration: 0.3,
13125
+ hold: "full"
13126
+ }
13127
+ },
13128
+ {
13129
+ kind: "text",
13130
+ id: "cta-btn-text",
13131
+ content: "GET STARTED FREE",
13132
+ fontFamily: "Poppins",
13133
+ fontSize: 24,
13134
+ fontWeight: 700,
13135
+ color: "#ffffff",
13136
+ backgroundColor: "#6366f1",
13137
+ backgroundOpacity: 0.95,
13138
+ paddingTop: 10,
13139
+ paddingBottom: 10,
13140
+ paddingLeft: 28,
13141
+ paddingRight: 28,
13142
+ backgroundRadius: 8,
13143
+ align: "center",
13144
+ x: 810,
13145
+ y: 580,
13146
+ width: 300,
13147
+ height: 50,
13148
+ role: "accent",
13149
+ animation: {
13150
+ in: "scale-pop",
13151
+ out: "fade",
13152
+ inDuration: 0.8,
13153
+ outDuration: 0.3,
13154
+ hold: "full"
13155
+ }
13156
+ }
13157
+ ]
13158
+ },
13159
+ {
13160
+ id: "cinematic-credits-card",
13161
+ label: "Cinematic Cast Card",
13162
+ category: "credits",
13163
+ duration: 5,
13164
+ canvasWidth: 1920,
13165
+ canvasHeight: 1080,
13166
+ layers: [
13167
+ {
13168
+ kind: "text",
13169
+ id: "credit-role",
13170
+ content: "DIRECTED BY",
13171
+ fontFamily: "Inter Variable",
13172
+ fontSize: 24,
13173
+ fontWeight: 600,
13174
+ color: "#7c6fff",
13175
+ letterSpacing: 6,
13176
+ align: "center",
13177
+ x: 460,
13178
+ y: 450,
13179
+ width: 1e3,
13180
+ height: 40,
13181
+ role: "secondary",
13182
+ animation: {
13183
+ in: "fade",
13184
+ out: "fade",
13185
+ inDuration: 0.8,
13186
+ outDuration: 0.4,
13187
+ hold: "full"
13188
+ }
13189
+ },
13190
+ {
13191
+ kind: "text",
13192
+ id: "credit-name",
13193
+ content: "MARCUS VANCE",
13194
+ fontFamily: "Poppins",
13195
+ fontSize: 56,
13196
+ fontWeight: 800,
13197
+ color: "#ffffff",
13198
+ letterSpacing: 2,
13199
+ align: "center",
13200
+ x: 460,
13201
+ y: 510,
13202
+ width: 1e3,
13203
+ height: 70,
13204
+ role: "primary",
13205
+ animation: {
13206
+ in: "slide-up",
13207
+ out: "fade",
13208
+ inDuration: 0.8,
13209
+ outDuration: 0.4,
13210
+ hold: "full"
13211
+ }
13212
+ }
13213
+ ]
13214
+ },
13215
+ {
13216
+ id: "editorial-pull-quote",
13217
+ label: "Editorial Pull Quote",
13218
+ category: "quotes",
13219
+ duration: 5,
13220
+ canvasWidth: 1920,
13221
+ canvasHeight: 1080,
13222
+ layers: [
13223
+ {
13224
+ kind: "text",
13225
+ id: "quote-body",
13226
+ content: "\u201CCreativity is intelligence having fun.\u201D",
13227
+ fontFamily: "Poppins",
13228
+ fontSize: 48,
13229
+ fontWeight: 400,
13230
+ fontStyle: "italic",
13231
+ color: "#ffffff",
13232
+ align: "center",
13233
+ x: 360,
13234
+ y: 440,
13235
+ width: 1200,
13236
+ height: 80,
13237
+ role: "primary",
13238
+ animation: {
13239
+ in: "fade",
13240
+ out: "fade",
13241
+ inDuration: 0.8,
13242
+ outDuration: 0.3,
13243
+ hold: "full"
13244
+ }
13245
+ },
13246
+ {
13247
+ kind: "text",
13248
+ id: "quote-author",
13249
+ content: "\u2014 ALBERT EINSTEIN",
13250
+ fontFamily: "Inter Variable",
13251
+ fontSize: 24,
13252
+ fontWeight: 600,
13253
+ color: "#38bdf8",
13254
+ letterSpacing: 3,
13255
+ align: "center",
13256
+ x: 460,
13257
+ y: 540,
13258
+ width: 1e3,
13259
+ height: 40,
13260
+ role: "secondary",
13261
+ animation: {
13262
+ in: "slide-up",
13263
+ out: "fade",
13264
+ inDuration: 0.9,
13265
+ outDuration: 0.3,
13266
+ hold: "full"
13267
+ }
13268
+ }
13269
+ ]
13270
+ },
13271
+ {
13272
+ id: "sports-match-score",
13273
+ label: "Sports Match Scoreboard",
13274
+ category: "sports",
13275
+ duration: 4,
13276
+ canvasWidth: 1920,
13277
+ canvasHeight: 1080,
13278
+ layers: [
13279
+ {
13280
+ kind: "shape",
13281
+ id: "score-bg",
13282
+ shape: "rect",
13283
+ fill: "rgba(15, 23, 42, 0.95)",
13284
+ stroke: { color: "#38bdf8", width: 2 },
13285
+ x: 660,
13286
+ y: 440,
13287
+ width: 600,
13288
+ height: 180,
13289
+ animation: {
13290
+ in: "scale-in",
13291
+ out: "fade",
13292
+ inDuration: 0.4,
13293
+ outDuration: 0.3,
13294
+ hold: "full"
13295
+ }
13296
+ },
13297
+ {
13298
+ kind: "text",
13299
+ id: "team-names",
13300
+ content: "WARRIORS vs CHAMPIONS",
13301
+ fontFamily: "Inter Variable",
13302
+ fontSize: 26,
13303
+ fontWeight: 700,
13304
+ color: "#94a3b8",
13305
+ align: "center",
13306
+ x: 660,
13307
+ y: 460,
13308
+ width: 600,
13309
+ height: 40,
13310
+ role: "secondary",
13311
+ animation: {
13312
+ in: "fade",
13313
+ out: "fade",
13314
+ inDuration: 0.5,
13315
+ outDuration: 0.3,
13316
+ hold: "full"
13317
+ }
13318
+ },
13319
+ {
13320
+ kind: "text",
13321
+ id: "score-digits",
13322
+ content: "3 - 2",
13323
+ fontFamily: "Poppins",
13324
+ fontSize: 72,
13325
+ fontWeight: 900,
13326
+ color: "#ffffff",
13327
+ align: "center",
13328
+ x: 660,
13329
+ y: 505,
13330
+ width: 600,
13331
+ height: 90,
13332
+ role: "primary",
13333
+ animation: {
13334
+ in: "scale-pop",
13335
+ out: "fade",
13336
+ inDuration: 0.6,
13337
+ outDuration: 0.3,
13338
+ hold: "full"
13339
+ }
13340
+ }
13341
+ ]
13342
+ },
13343
+ {
13344
+ id: "gamer-hud-tag",
13345
+ label: "Cyberpunk Gamer HUD",
13346
+ category: "gaming",
13347
+ duration: 4,
13348
+ canvasWidth: 1920,
13349
+ canvasHeight: 1080,
13350
+ layers: [
13351
+ {
13352
+ kind: "text",
13353
+ id: "gamer-lvl",
13354
+ content: "LVL 99 \xB7 PRO",
13355
+ fontFamily: "Inter Variable",
13356
+ fontSize: 22,
13357
+ fontWeight: 800,
13358
+ color: "#a855f7",
13359
+ backgroundColor: "#2e1065",
13360
+ backgroundOpacity: 0.9,
13361
+ paddingTop: 6,
13362
+ paddingBottom: 6,
13363
+ paddingLeft: 16,
13364
+ paddingRight: 16,
13365
+ backgroundRadius: 4,
13366
+ align: "center",
13367
+ x: 810,
13368
+ y: 450,
13369
+ width: 300,
13370
+ height: 40,
13371
+ role: "secondary",
13372
+ animation: {
13373
+ in: "scale-pop",
13374
+ out: "fade",
13375
+ inDuration: 0.3,
13376
+ outDuration: 0.2,
13377
+ hold: "full"
13378
+ }
13379
+ },
13380
+ {
13381
+ kind: "text",
13382
+ id: "gamer-handle",
13383
+ content: "NIGHT_RAVEN",
13384
+ fontFamily: "Poppins",
13385
+ fontSize: 60,
13386
+ fontWeight: 900,
13387
+ color: "#ffffff",
13388
+ align: "center",
13389
+ x: 660,
13390
+ y: 500,
13391
+ width: 600,
13392
+ height: 80,
13393
+ role: "primary",
13394
+ animation: {
13395
+ in: "slide-up",
13396
+ out: "fade",
13397
+ inDuration: 0.5,
13398
+ outDuration: 0.3,
13399
+ hold: "full"
13400
+ }
13401
+ }
13402
+ ]
13403
+ },
13404
+ {
13405
+ id: "breaking-news-live",
13406
+ label: "Live Breaking News Strap",
13407
+ category: "news",
13408
+ duration: 5,
13409
+ canvasWidth: 1920,
13410
+ canvasHeight: 1080,
13411
+ layers: [
13412
+ {
13413
+ kind: "text",
13414
+ id: "news-badge",
13415
+ content: "BREAKING NEWS",
13416
+ fontFamily: "Inter Variable",
13417
+ fontSize: 24,
13418
+ fontWeight: 800,
13419
+ color: "#ffffff",
13420
+ backgroundColor: "#dc2626",
13421
+ backgroundOpacity: 0.95,
13422
+ paddingTop: 8,
13423
+ paddingBottom: 8,
13424
+ paddingLeft: 20,
13425
+ paddingRight: 20,
13426
+ backgroundRadius: 4,
13427
+ align: "left",
13428
+ x: 100,
13429
+ y: 840,
13430
+ width: "auto",
13431
+ height: "auto",
13432
+ role: "accent",
13433
+ animation: {
13434
+ in: "scale-pop",
13435
+ out: "fade",
13436
+ inDuration: 0.3,
13437
+ outDuration: 0.2,
13438
+ hold: "full"
13439
+ }
13440
+ },
13441
+ {
13442
+ kind: "text",
13443
+ id: "news-headline",
13444
+ content: "MAJOR DISCOVERY ANNOUNCED LIVE TODAY",
13445
+ fontFamily: "Poppins",
13446
+ fontSize: 48,
13447
+ fontWeight: 800,
13448
+ color: "#ffffff",
13449
+ backgroundColor: "rgba(15, 23, 42, 0.95)",
13450
+ backgroundOpacity: 0.95,
13451
+ paddingTop: 12,
13452
+ paddingBottom: 12,
13453
+ paddingLeft: 28,
13454
+ paddingRight: 28,
13455
+ backgroundRadius: 4,
13456
+ backgroundBorderColor: "#dc2626",
13457
+ backgroundBorderWidth: 2,
13458
+ align: "left",
13459
+ x: 100,
13460
+ y: 890,
13461
+ width: "auto",
13462
+ height: "auto",
13463
+ role: "primary",
13464
+ animation: {
13465
+ in: "slide-right",
13466
+ out: "fade",
13467
+ inDuration: 0.5,
13468
+ outDuration: 0.3,
13469
+ hold: "full"
13470
+ }
13471
+ }
13472
+ ]
13473
+ },
13474
+ {
13475
+ id: "minimal-editorial-title",
13476
+ label: "Minimalist Editorial Layout",
13477
+ category: "minimal",
13478
+ duration: 4,
13479
+ canvasWidth: 1920,
13480
+ canvasHeight: 1080,
13481
+ layers: [
13482
+ {
13483
+ kind: "text",
13484
+ id: "min-title",
13485
+ content: "ESSENTIAL PERSPECTIVES",
13486
+ fontFamily: "Inter Variable",
13487
+ fontSize: 64,
13488
+ fontWeight: 300,
13489
+ letterSpacing: 8,
13490
+ color: "#ffffff",
13491
+ align: "center",
13492
+ x: 360,
13493
+ y: 470,
13494
+ width: 1200,
13495
+ height: 80,
13496
+ role: "primary",
13497
+ animation: {
13498
+ in: "fade",
13499
+ out: "fade",
13500
+ inDuration: 1,
13501
+ outDuration: 0.4,
13502
+ hold: "full"
13503
+ }
13504
+ },
13505
+ {
13506
+ kind: "text",
13507
+ id: "min-sub",
13508
+ content: "Volume 01 \u2014 Issue 2026",
13509
+ fontFamily: "Inter Variable",
13510
+ fontSize: 22,
13511
+ fontWeight: 500,
13512
+ letterSpacing: 4,
13513
+ color: "#94a3b8",
13514
+ align: "center",
13515
+ x: 460,
13516
+ y: 560,
13517
+ width: 1e3,
13518
+ height: 40,
13519
+ role: "secondary",
13520
+ animation: {
13521
+ in: "fade",
13522
+ out: "fade",
13523
+ inDuration: 1.2,
13524
+ outDuration: 0.4,
13525
+ hold: "full"
13526
+ }
13527
+ }
13528
+ ]
13041
13529
  }
13042
13530
  ];
13043
13531
  function getCanvasTemplatePreset(id) {
@@ -13262,7 +13750,8 @@ function legacyLayerToNode(layer2, index) {
13262
13750
  style: {
13263
13751
  fontFamily: resolveStringProperty(text?.fontFamily, "Inter Variable"),
13264
13752
  fontSize: resolveNumericProperty(text?.fontSize, 48),
13265
- fontWeight: resolveStringProperty(text?.fontWeight, "400"),
13753
+ fontWeight: resolveAnimatableValue(text?.fontWeight, 400),
13754
+ fontStyle: text?.fontStyle === "italic" ? "italic" : "normal",
13266
13755
  textColor: resolveStringProperty(
13267
13756
  text?.color ?? text?.textColor,
13268
13757
  "#FFFFFF"
@@ -13271,7 +13760,26 @@ function legacyLayerToNode(layer2, index) {
13271
13760
  lineHeight: resolveNumericProperty(text?.lineHeight, 1.2),
13272
13761
  letterSpacing: resolveNumericProperty(text?.letterSpacing, 0),
13273
13762
  overflow: text?.overflow,
13274
- verticalAlign: text?.verticalAlign
13763
+ verticalAlign: text?.verticalAlign,
13764
+ strokeColor: text?.stroke?.color ?? text?.strokeColor ? resolveStringProperty(text?.stroke?.color ?? text?.strokeColor, "#000000") : void 0,
13765
+ strokeWidth: text?.stroke?.width ?? text?.strokeWidth ? resolveNumericProperty(text?.stroke?.width ?? text?.strokeWidth, 0) : void 0,
13766
+ shadowColor: text?.shadow?.color ?? text?.shadowColor ? resolveStringProperty(text?.shadow?.color ?? text?.shadowColor, "#000000") : void 0,
13767
+ shadowBlur: text?.shadow?.blur ?? text?.shadowBlur ? resolveNumericProperty(text?.shadow?.blur ?? text?.shadowBlur, 0) : void 0,
13768
+ shadowOffsetX: text?.shadow?.offsetX ?? text?.shadowOffsetX ? resolveNumericProperty(text?.shadow?.offsetX ?? text?.shadowOffsetX, 0) : void 0,
13769
+ shadowOffsetY: text?.shadow?.offsetY ?? text?.shadowOffsetY ? resolveNumericProperty(text?.shadow?.offsetY ?? text?.shadowOffsetY, 0) : void 0,
13770
+ stroke: text?.stroke ? {
13771
+ color: resolveStringProperty(text.stroke.color, "#000000"),
13772
+ width: resolveNumericProperty(text.stroke.width, 1)
13773
+ } : void 0,
13774
+ shadow: text?.shadow ? {
13775
+ color: resolveStringProperty(text.shadow.color, "#000000"),
13776
+ blur: resolveNumericProperty(text.shadow.blur, 0),
13777
+ offsetX: resolveNumericProperty(text.shadow.offsetX, 0),
13778
+ offsetY: resolveNumericProperty(text.shadow.offsetY, 0)
13779
+ } : void 0,
13780
+ fontId: text?.fontId || layer2?.fontId ? resolveStringProperty(text?.fontId ?? layer2?.fontId, "") : void 0,
13781
+ backgroundColor: text?.backgroundColor || layer2?.backgroundColor ? resolveStringProperty(text?.backgroundColor ?? layer2?.backgroundColor, "") : void 0,
13782
+ background: text?.background || layer2?.background ? clone2(text?.background ?? layer2?.background) : void 0
13275
13783
  },
13276
13784
  backgroundPanel: text?.backgroundColor || text?.backgroundPanel ? {
13277
13785
  color: text?.backgroundPanel?.color ?? text?.backgroundColor ? resolveStringProperty(
@@ -13316,9 +13824,10 @@ function legacyLayerToNode(layer2, index) {
13316
13824
  charFillColors: Array.isArray(text?.charFillColors) ? clone2(text.charFillColors) : void 0,
13317
13825
  splitAnimator: text?.splitAnimator ? clone2(text.splitAnimator) : void 0,
13318
13826
  textEffectRef: text?.styleRef ? clone2(text.styleRef) : void 0,
13319
- // Kept as optional metadata for compatibility with role-based editor
13320
- // customizations. The canonical renderer does not depend on roles.
13321
- ...layer2?.role ? { role: String(layer2.role) } : {}
13827
+ role: layer2?.role || text?.role || text?.textRole ? String(layer2?.role ?? text?.role ?? text?.textRole) : void 0,
13828
+ textRole: text?.textRole || (layer2?.role === "primary" || layer2?.role === "secondary" ? "title" : void 0),
13829
+ fontId: text?.fontId || layer2?.fontId ? resolveStringProperty(text?.fontId ?? layer2?.fontId, "") : void 0,
13830
+ maxWidth: resolveNumericProperty(text?.maxWidth ?? layer2?.maxWidth, 0) || void 0
13322
13831
  };
13323
13832
  }
13324
13833
  function inferControls(nodes) {
@@ -13473,6 +13982,51 @@ function normalizeTextTemplateArtifact(input) {
13473
13982
  } : void 0
13474
13983
  };
13475
13984
  }
13985
+ function resolveTemplateControlValues(artifact, optionsOrCustomization, fallbackText) {
13986
+ if (!artifact?.controls) return {};
13987
+ const options = optionsOrCustomization && ("customization" in optionsOrCustomization || "templateControlValues" in optionsOrCustomization || "fallbackText" in optionsOrCustomization) ? optionsOrCustomization : {
13988
+ customization: optionsOrCustomization,
13989
+ fallbackText
13990
+ };
13991
+ const customization = options.customization;
13992
+ const existingValues = options.templateControlValues;
13993
+ const targetFallbackText = options.fallbackText;
13994
+ const firstTextNode = artifact.document?.nodes?.find(
13995
+ (candidate) => candidate.type === "text"
13996
+ );
13997
+ const values = { ...existingValues || {} };
13998
+ for (const control of artifact.controls) {
13999
+ if (control.type !== "text" && control.type !== "color") continue;
14000
+ const node = artifact.document?.nodes?.find(
14001
+ (candidate) => candidate.id === control.target.nodeId
14002
+ );
14003
+ const role = node?.role || "";
14004
+ const labelLower = (control.label || "").toLowerCase();
14005
+ if (control.type === "text") {
14006
+ const explicitText = customization?.layerTexts?.[control.target.nodeId];
14007
+ let roleText;
14008
+ if (role === "primary" || labelLower.includes("primary")) {
14009
+ roleText = customization?.primaryText;
14010
+ } else if (role === "secondary" || labelLower.includes("secondary")) {
14011
+ roleText = customization?.secondaryText;
14012
+ } else if (role === "accent" || labelLower.includes("accent")) {
14013
+ roleText = customization?.accentText;
14014
+ }
14015
+ const firstNodeFallback = targetFallbackText !== void 0 && firstTextNode && control.target.nodeId === firstTextNode.id ? targetFallbackText : void 0;
14016
+ values[control.id] = explicitText ?? roleText ?? firstNodeFallback ?? values[control.id] ?? control.defaultValue;
14017
+ } else if (control.type === "color") {
14018
+ const explicitColor = customization?.layerColors?.[control.target.nodeId];
14019
+ let roleColor;
14020
+ if (role === "secondary" || labelLower.includes("secondary")) {
14021
+ roleColor = customization?.secondaryColor;
14022
+ } else {
14023
+ roleColor = customization?.primaryColor;
14024
+ }
14025
+ values[control.id] = explicitColor ?? roleColor ?? values[control.id] ?? control.defaultValue;
14026
+ }
14027
+ }
14028
+ return values;
14029
+ }
13476
14030
 
13477
14031
  // src/textTemplates/validator.ts
13478
14032
  var MAX_NODES = 500;
@@ -14028,16 +14582,90 @@ function letterSpacedText(ctx, text, x, y, maxWidth, letterSpacing) {
14028
14582
  }
14029
14583
  ctx.textAlign = align;
14030
14584
  }
14585
+ function letterSpacedStrokeText(ctx, text, x, y, maxWidth, letterSpacing) {
14586
+ if (!letterSpacing) {
14587
+ ctx.strokeText(text, x, y, maxWidth);
14588
+ return;
14589
+ }
14590
+ const glyphs = Array.from(text);
14591
+ const widths = glyphs.map((glyph) => ctx.measureText(glyph).width);
14592
+ const total = widths.reduce((sum, value) => sum + value, 0) + Math.max(0, glyphs.length - 1) * letterSpacing;
14593
+ const align = ctx.textAlign;
14594
+ let cursor = x;
14595
+ if (align === "center") cursor -= total / 2;
14596
+ if (align === "right") cursor -= total;
14597
+ ctx.textAlign = "left";
14598
+ for (let index = 0; index < glyphs.length; index += 1) {
14599
+ ctx.strokeText(glyphs[index], cursor, y);
14600
+ cursor += widths[index] + letterSpacing;
14601
+ }
14602
+ ctx.textAlign = align;
14603
+ }
14604
+ var FONT_ALIAS_MAP = {
14605
+ "inter": "Inter Variable",
14606
+ "inter variable": "Inter Variable",
14607
+ "outfit": "Outfit Variable",
14608
+ "outfit variable": "Outfit Variable",
14609
+ "playfair display": "Playfair Display Variable",
14610
+ "playfair display variable": "Playfair Display Variable",
14611
+ "montserrat": "Montserrat Variable",
14612
+ "montserrat variable": "Montserrat Variable",
14613
+ "roboto": "Roboto Variable",
14614
+ "roboto variable": "Roboto Variable",
14615
+ "roboto condensed": "Roboto Condensed Variable",
14616
+ "roboto condensed variable": "Roboto Condensed Variable",
14617
+ "raleway": "Raleway Variable",
14618
+ "raleway variable": "Raleway Variable",
14619
+ "space grotesk": "Space Grotesk Variable",
14620
+ "space grotesk variable": "Space Grotesk Variable",
14621
+ "nunito": "Nunito Variable",
14622
+ "nunito variable": "Nunito Variable",
14623
+ "open sans": "Open Sans Variable",
14624
+ "open sans variable": "Open Sans Variable",
14625
+ "oswald": "Oswald Variable",
14626
+ "oswald variable": "Oswald Variable",
14627
+ "geist": "Geist Variable",
14628
+ "geist variable": "Geist Variable",
14629
+ "dancing script": "Dancing Script Variable",
14630
+ "dancing script variable": "Dancing Script Variable"
14631
+ };
14632
+ function resolveTemplateFontFamily(family) {
14633
+ if (!family) return "sans-serif";
14634
+ const clean = String(family).trim().replace(/^["']|["']$/g, "");
14635
+ const lower = clean.toLowerCase();
14636
+ return FONT_ALIAS_MAP[lower] || clean;
14637
+ }
14638
+ function constructFontStack(fontStyle, fontWeight, fontSize, rawFamily) {
14639
+ const canonical = resolveTemplateFontFamily(rawFamily);
14640
+ const cleanRaw = String(rawFamily || "").trim().replace(/^["']|["']$/g, "");
14641
+ const style = fontStyle === "italic" ? "italic" : "normal";
14642
+ const weight = fontWeight ?? 400;
14643
+ if (canonical && cleanRaw && canonical.toLowerCase() !== cleanRaw.toLowerCase()) {
14644
+ return `${style} ${weight} ${fontSize}px "${canonical}", "${cleanRaw}", sans-serif`;
14645
+ }
14646
+ return `${style} ${weight} ${fontSize}px "${canonical || cleanRaw || "sans-serif"}", sans-serif`;
14647
+ }
14031
14648
  function drawTextLayer(ctx, layer2, style) {
14032
14649
  const text = layer2.text ?? "";
14033
14650
  const fontSize = finite2(style.fontSize, 48);
14034
14651
  const fontWeight = style.fontWeight ?? 400;
14035
- const fontStyle = "normal";
14036
- const fontFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14037
- ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px "${fontFamily}"`;
14652
+ const fontStyle = style.fontStyle || "normal";
14653
+ const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14654
+ ctx.font = constructFontStack(fontStyle, fontWeight, fontSize, rawFamily);
14038
14655
  ctx.fillStyle = cssColor(style.textColor, "#FFFFFF");
14039
14656
  ctx.textAlign = style.textAlign ?? "left";
14040
14657
  ctx.textBaseline = style.verticalAlign === "top" ? "top" : style.verticalAlign === "bottom" ? "bottom" : "middle";
14658
+ const shadowColor = style.shadow?.color ?? style.shadowColor;
14659
+ const shadowBlur = finite2(style.shadow?.blur ?? style.shadowBlur, 0);
14660
+ const shadowOffsetX = finite2(style.shadow?.offsetX ?? style.shadowOffsetX, 0);
14661
+ const shadowOffsetY = finite2(style.shadow?.offsetY ?? style.shadowOffsetY, 0);
14662
+ const hasShadow = !!shadowColor && (shadowBlur > 0 || shadowOffsetX !== 0 || shadowOffsetY !== 0);
14663
+ if (hasShadow) {
14664
+ ctx.shadowColor = cssColor(shadowColor, "#000000");
14665
+ ctx.shadowBlur = shadowBlur;
14666
+ ctx.shadowOffsetX = shadowOffsetX;
14667
+ ctx.shadowOffsetY = shadowOffsetY;
14668
+ }
14041
14669
  const lineHeight = fontSize * finite2(style.lineHeight, 1.2);
14042
14670
  const maxWidth = Math.max(1, layer2.width);
14043
14671
  const lines = style.overflow === "wrap" ? wrapText(ctx, text, maxWidth) : [text];
@@ -14047,12 +14675,30 @@ function drawTextLayer(ctx, layer2, style) {
14047
14675
  for (let index = 0; index < lines.length; index += 1) {
14048
14676
  letterSpacedText(ctx, lines[index], anchorX, startY + index * lineHeight, maxWidth, finite2(style.letterSpacing, 0));
14049
14677
  }
14678
+ if (hasShadow) {
14679
+ ctx.shadowColor = "transparent";
14680
+ ctx.shadowBlur = 0;
14681
+ ctx.shadowOffsetX = 0;
14682
+ ctx.shadowOffsetY = 0;
14683
+ }
14684
+ const strokeColor = style.stroke?.color ?? style.strokeColor;
14685
+ const strokeWidth = finite2(style.stroke?.width ?? style.strokeWidth, 0);
14686
+ if (strokeWidth > 0 && strokeColor) {
14687
+ ctx.strokeStyle = cssColor(strokeColor, "#000000");
14688
+ ctx.lineWidth = strokeWidth;
14689
+ ctx.lineJoin = "round";
14690
+ for (let index = 0; index < lines.length; index += 1) {
14691
+ letterSpacedStrokeText(ctx, lines[index], anchorX, startY + index * lineHeight, maxWidth, finite2(style.letterSpacing, 0));
14692
+ }
14693
+ }
14050
14694
  }
14051
14695
  function drawSplitTextLayer(ctx, layer2, style, animator, progress) {
14052
14696
  const text = layer2.text ?? "";
14053
14697
  const fontSize = finite2(style.fontSize, 48);
14054
- const fontFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14055
- ctx.font = `normal ${style.fontWeight ?? 400} ${fontSize}px "${fontFamily}"`;
14698
+ const fontWeight = style.fontWeight ?? 400;
14699
+ const fontStyle = style.fontStyle || "normal";
14700
+ const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14701
+ ctx.font = constructFontStack(fontStyle, fontWeight, fontSize, rawFamily);
14056
14702
  ctx.textBaseline = "middle";
14057
14703
  ctx.textAlign = "left";
14058
14704
  ctx.fillStyle = cssColor(style.textColor, "#FFFFFF");
@@ -14142,9 +14788,9 @@ function renderTextTemplateToCanvas(ctx, input) {
14142
14788
  // Measure with the exact Canvas context that will draw the layer. This
14143
14789
  // makes auto-sized nodes use loaded font metrics instead of a fixed box.
14144
14790
  measureText: (text, style) => {
14145
- const family = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14791
+ const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14146
14792
  ctx.save();
14147
- ctx.font = `${style.fontWeight ?? 400} ${finite2(style.fontSize, 48)}px "${family}"`;
14793
+ ctx.font = constructFontStack(style.fontStyle, style.fontWeight, finite2(style.fontSize, 48), rawFamily);
14148
14794
  const width = ctx.measureText(text).width + Math.max(0, text.length - 1) * finite2(style.letterSpacing, 0);
14149
14795
  ctx.restore();
14150
14796
  return { width };
@@ -15696,6 +16342,13 @@ function resolveConform(conform, canvasWidth, canvasHeight) {
15696
16342
  if (!sw || !sh) {
15697
16343
  return { x: 0, y: 0, width: canvasWidth, height: canvasHeight };
15698
16344
  }
16345
+ if (mode === "stretch") {
16346
+ const width2 = canvasWidth * userScale;
16347
+ const height2 = canvasHeight * userScale;
16348
+ const x2 = (canvasWidth - width2) / 2 + userOffsetX;
16349
+ const y2 = (canvasHeight - height2) / 2 + userOffsetY;
16350
+ return { x: x2, y: y2, width: width2, height: height2 };
16351
+ }
15699
16352
  let baseScale;
15700
16353
  switch (mode) {
15701
16354
  case "fit":
@@ -25195,6 +25848,8 @@ var VERSION = "1.4.0";
25195
25848
  resolveMediaLayout,
25196
25849
  resolveNodeForBreakpoint,
25197
25850
  resolveSpatialConstraints,
25851
+ resolveTemplateControlValues,
25852
+ resolveTemplateFontFamily,
25198
25853
  resolveTextTemplateArtifact,
25199
25854
  restoreLetterSpacing,
25200
25855
  rgbaToComponents,