@clypra-studio/engine 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -348,6 +348,7 @@ __export(index_exports, {
348
348
  resolveMediaLayout: () => resolveMediaLayout,
349
349
  resolveNodeForBreakpoint: () => resolveNodeForBreakpoint,
350
350
  resolveSpatialConstraints: () => resolveSpatialConstraints,
351
+ resolveTemplateFontFamily: () => resolveTemplateFontFamily,
351
352
  resolveTextTemplateArtifact: () => resolveTextTemplateArtifact,
352
353
  restoreLetterSpacing: () => restoreLetterSpacing,
353
354
  rgbaToComponents: () => rgbaToComponents,
@@ -598,7 +599,15 @@ var TemplateCategorySchema = import_zod.z.enum([
598
599
  "caption",
599
600
  "callout",
600
601
  "social",
601
- "countdown"
602
+ "countdown",
603
+ "kinetic-type",
604
+ "cta",
605
+ "credits",
606
+ "quotes",
607
+ "sports",
608
+ "gaming",
609
+ "news",
610
+ "minimal"
602
611
  ]);
603
612
  var AnimationPresetSchema = import_zod.z.enum([
604
613
  "fade",
@@ -13038,6 +13047,478 @@ var BUILTIN_CANVAS_TEMPLATES = [
13038
13047
  }
13039
13048
  }
13040
13049
  ]
13050
+ },
13051
+ {
13052
+ id: "action-cta-card",
13053
+ label: "Modern Action CTA",
13054
+ category: "cta",
13055
+ duration: 4,
13056
+ canvasWidth: 1920,
13057
+ canvasHeight: 1080,
13058
+ layers: [
13059
+ {
13060
+ kind: "shape",
13061
+ id: "cta-bg",
13062
+ shape: "rect",
13063
+ fill: "rgba(18, 18, 28, 0.95)",
13064
+ stroke: { color: "#6366f1", width: 2 },
13065
+ x: 460,
13066
+ y: 380,
13067
+ width: 1e3,
13068
+ height: 320,
13069
+ animation: {
13070
+ in: "scale-in",
13071
+ out: "fade",
13072
+ inDuration: 0.5,
13073
+ outDuration: 0.3,
13074
+ hold: "full"
13075
+ }
13076
+ },
13077
+ {
13078
+ kind: "text",
13079
+ id: "cta-heading",
13080
+ content: "READY TO LEVEL UP?",
13081
+ fontFamily: "Poppins",
13082
+ fontSize: 64,
13083
+ fontWeight: 800,
13084
+ color: "#ffffff",
13085
+ align: "center",
13086
+ x: 460,
13087
+ y: 420,
13088
+ width: 1e3,
13089
+ height: 80,
13090
+ role: "primary",
13091
+ animation: {
13092
+ in: "slide-down",
13093
+ out: "fade",
13094
+ inDuration: 0.6,
13095
+ outDuration: 0.3,
13096
+ hold: "full"
13097
+ }
13098
+ },
13099
+ {
13100
+ kind: "text",
13101
+ id: "cta-sub",
13102
+ content: "Download Clypra Studio and start creating today.",
13103
+ fontFamily: "Inter Variable",
13104
+ fontSize: 26,
13105
+ fontWeight: 400,
13106
+ color: "#94a3b8",
13107
+ align: "center",
13108
+ x: 460,
13109
+ y: 510,
13110
+ width: 1e3,
13111
+ height: 40,
13112
+ role: "secondary",
13113
+ animation: {
13114
+ in: "fade",
13115
+ out: "fade",
13116
+ inDuration: 0.7,
13117
+ outDuration: 0.3,
13118
+ hold: "full"
13119
+ }
13120
+ },
13121
+ {
13122
+ kind: "text",
13123
+ id: "cta-btn-text",
13124
+ content: "GET STARTED FREE",
13125
+ fontFamily: "Poppins",
13126
+ fontSize: 24,
13127
+ fontWeight: 700,
13128
+ color: "#ffffff",
13129
+ backgroundColor: "#6366f1",
13130
+ backgroundOpacity: 0.95,
13131
+ paddingTop: 10,
13132
+ paddingBottom: 10,
13133
+ paddingLeft: 28,
13134
+ paddingRight: 28,
13135
+ backgroundRadius: 8,
13136
+ align: "center",
13137
+ x: 810,
13138
+ y: 580,
13139
+ width: 300,
13140
+ height: 50,
13141
+ role: "accent",
13142
+ animation: {
13143
+ in: "scale-pop",
13144
+ out: "fade",
13145
+ inDuration: 0.8,
13146
+ outDuration: 0.3,
13147
+ hold: "full"
13148
+ }
13149
+ }
13150
+ ]
13151
+ },
13152
+ {
13153
+ id: "cinematic-credits-card",
13154
+ label: "Cinematic Cast Card",
13155
+ category: "credits",
13156
+ duration: 5,
13157
+ canvasWidth: 1920,
13158
+ canvasHeight: 1080,
13159
+ layers: [
13160
+ {
13161
+ kind: "text",
13162
+ id: "credit-role",
13163
+ content: "DIRECTED BY",
13164
+ fontFamily: "Inter Variable",
13165
+ fontSize: 24,
13166
+ fontWeight: 600,
13167
+ color: "#7c6fff",
13168
+ letterSpacing: 6,
13169
+ align: "center",
13170
+ x: 460,
13171
+ y: 450,
13172
+ width: 1e3,
13173
+ height: 40,
13174
+ role: "secondary",
13175
+ animation: {
13176
+ in: "fade",
13177
+ out: "fade",
13178
+ inDuration: 0.8,
13179
+ outDuration: 0.4,
13180
+ hold: "full"
13181
+ }
13182
+ },
13183
+ {
13184
+ kind: "text",
13185
+ id: "credit-name",
13186
+ content: "MARCUS VANCE",
13187
+ fontFamily: "Poppins",
13188
+ fontSize: 56,
13189
+ fontWeight: 800,
13190
+ color: "#ffffff",
13191
+ letterSpacing: 2,
13192
+ align: "center",
13193
+ x: 460,
13194
+ y: 510,
13195
+ width: 1e3,
13196
+ height: 70,
13197
+ role: "primary",
13198
+ animation: {
13199
+ in: "slide-up",
13200
+ out: "fade",
13201
+ inDuration: 0.8,
13202
+ outDuration: 0.4,
13203
+ hold: "full"
13204
+ }
13205
+ }
13206
+ ]
13207
+ },
13208
+ {
13209
+ id: "editorial-pull-quote",
13210
+ label: "Editorial Pull Quote",
13211
+ category: "quotes",
13212
+ duration: 5,
13213
+ canvasWidth: 1920,
13214
+ canvasHeight: 1080,
13215
+ layers: [
13216
+ {
13217
+ kind: "text",
13218
+ id: "quote-body",
13219
+ content: "\u201CCreativity is intelligence having fun.\u201D",
13220
+ fontFamily: "Poppins",
13221
+ fontSize: 48,
13222
+ fontWeight: 400,
13223
+ fontStyle: "italic",
13224
+ color: "#ffffff",
13225
+ align: "center",
13226
+ x: 360,
13227
+ y: 440,
13228
+ width: 1200,
13229
+ height: 80,
13230
+ role: "primary",
13231
+ animation: {
13232
+ in: "fade",
13233
+ out: "fade",
13234
+ inDuration: 0.8,
13235
+ outDuration: 0.3,
13236
+ hold: "full"
13237
+ }
13238
+ },
13239
+ {
13240
+ kind: "text",
13241
+ id: "quote-author",
13242
+ content: "\u2014 ALBERT EINSTEIN",
13243
+ fontFamily: "Inter Variable",
13244
+ fontSize: 24,
13245
+ fontWeight: 600,
13246
+ color: "#38bdf8",
13247
+ letterSpacing: 3,
13248
+ align: "center",
13249
+ x: 460,
13250
+ y: 540,
13251
+ width: 1e3,
13252
+ height: 40,
13253
+ role: "secondary",
13254
+ animation: {
13255
+ in: "slide-up",
13256
+ out: "fade",
13257
+ inDuration: 0.9,
13258
+ outDuration: 0.3,
13259
+ hold: "full"
13260
+ }
13261
+ }
13262
+ ]
13263
+ },
13264
+ {
13265
+ id: "sports-match-score",
13266
+ label: "Sports Match Scoreboard",
13267
+ category: "sports",
13268
+ duration: 4,
13269
+ canvasWidth: 1920,
13270
+ canvasHeight: 1080,
13271
+ layers: [
13272
+ {
13273
+ kind: "shape",
13274
+ id: "score-bg",
13275
+ shape: "rect",
13276
+ fill: "rgba(15, 23, 42, 0.95)",
13277
+ stroke: { color: "#38bdf8", width: 2 },
13278
+ x: 660,
13279
+ y: 440,
13280
+ width: 600,
13281
+ height: 180,
13282
+ animation: {
13283
+ in: "scale-in",
13284
+ out: "fade",
13285
+ inDuration: 0.4,
13286
+ outDuration: 0.3,
13287
+ hold: "full"
13288
+ }
13289
+ },
13290
+ {
13291
+ kind: "text",
13292
+ id: "team-names",
13293
+ content: "WARRIORS vs CHAMPIONS",
13294
+ fontFamily: "Inter Variable",
13295
+ fontSize: 26,
13296
+ fontWeight: 700,
13297
+ color: "#94a3b8",
13298
+ align: "center",
13299
+ x: 660,
13300
+ y: 460,
13301
+ width: 600,
13302
+ height: 40,
13303
+ role: "secondary",
13304
+ animation: {
13305
+ in: "fade",
13306
+ out: "fade",
13307
+ inDuration: 0.5,
13308
+ outDuration: 0.3,
13309
+ hold: "full"
13310
+ }
13311
+ },
13312
+ {
13313
+ kind: "text",
13314
+ id: "score-digits",
13315
+ content: "3 - 2",
13316
+ fontFamily: "Poppins",
13317
+ fontSize: 72,
13318
+ fontWeight: 900,
13319
+ color: "#ffffff",
13320
+ align: "center",
13321
+ x: 660,
13322
+ y: 505,
13323
+ width: 600,
13324
+ height: 90,
13325
+ role: "primary",
13326
+ animation: {
13327
+ in: "scale-pop",
13328
+ out: "fade",
13329
+ inDuration: 0.6,
13330
+ outDuration: 0.3,
13331
+ hold: "full"
13332
+ }
13333
+ }
13334
+ ]
13335
+ },
13336
+ {
13337
+ id: "gamer-hud-tag",
13338
+ label: "Cyberpunk Gamer HUD",
13339
+ category: "gaming",
13340
+ duration: 4,
13341
+ canvasWidth: 1920,
13342
+ canvasHeight: 1080,
13343
+ layers: [
13344
+ {
13345
+ kind: "text",
13346
+ id: "gamer-lvl",
13347
+ content: "LVL 99 \xB7 PRO",
13348
+ fontFamily: "Inter Variable",
13349
+ fontSize: 22,
13350
+ fontWeight: 800,
13351
+ color: "#a855f7",
13352
+ backgroundColor: "#2e1065",
13353
+ backgroundOpacity: 0.9,
13354
+ paddingTop: 6,
13355
+ paddingBottom: 6,
13356
+ paddingLeft: 16,
13357
+ paddingRight: 16,
13358
+ backgroundRadius: 4,
13359
+ align: "center",
13360
+ x: 810,
13361
+ y: 450,
13362
+ width: 300,
13363
+ height: 40,
13364
+ role: "secondary",
13365
+ animation: {
13366
+ in: "scale-pop",
13367
+ out: "fade",
13368
+ inDuration: 0.3,
13369
+ outDuration: 0.2,
13370
+ hold: "full"
13371
+ }
13372
+ },
13373
+ {
13374
+ kind: "text",
13375
+ id: "gamer-handle",
13376
+ content: "NIGHT_RAVEN",
13377
+ fontFamily: "Poppins",
13378
+ fontSize: 60,
13379
+ fontWeight: 900,
13380
+ color: "#ffffff",
13381
+ align: "center",
13382
+ x: 660,
13383
+ y: 500,
13384
+ width: 600,
13385
+ height: 80,
13386
+ role: "primary",
13387
+ animation: {
13388
+ in: "slide-up",
13389
+ out: "fade",
13390
+ inDuration: 0.5,
13391
+ outDuration: 0.3,
13392
+ hold: "full"
13393
+ }
13394
+ }
13395
+ ]
13396
+ },
13397
+ {
13398
+ id: "breaking-news-live",
13399
+ label: "Live Breaking News Strap",
13400
+ category: "news",
13401
+ duration: 5,
13402
+ canvasWidth: 1920,
13403
+ canvasHeight: 1080,
13404
+ layers: [
13405
+ {
13406
+ kind: "text",
13407
+ id: "news-badge",
13408
+ content: "BREAKING NEWS",
13409
+ fontFamily: "Inter Variable",
13410
+ fontSize: 24,
13411
+ fontWeight: 800,
13412
+ color: "#ffffff",
13413
+ backgroundColor: "#dc2626",
13414
+ backgroundOpacity: 0.95,
13415
+ paddingTop: 8,
13416
+ paddingBottom: 8,
13417
+ paddingLeft: 20,
13418
+ paddingRight: 20,
13419
+ backgroundRadius: 4,
13420
+ align: "left",
13421
+ x: 100,
13422
+ y: 840,
13423
+ width: "auto",
13424
+ height: "auto",
13425
+ role: "accent",
13426
+ animation: {
13427
+ in: "scale-pop",
13428
+ out: "fade",
13429
+ inDuration: 0.3,
13430
+ outDuration: 0.2,
13431
+ hold: "full"
13432
+ }
13433
+ },
13434
+ {
13435
+ kind: "text",
13436
+ id: "news-headline",
13437
+ content: "MAJOR DISCOVERY ANNOUNCED LIVE TODAY",
13438
+ fontFamily: "Poppins",
13439
+ fontSize: 48,
13440
+ fontWeight: 800,
13441
+ color: "#ffffff",
13442
+ backgroundColor: "rgba(15, 23, 42, 0.95)",
13443
+ backgroundOpacity: 0.95,
13444
+ paddingTop: 12,
13445
+ paddingBottom: 12,
13446
+ paddingLeft: 28,
13447
+ paddingRight: 28,
13448
+ backgroundRadius: 4,
13449
+ backgroundBorderColor: "#dc2626",
13450
+ backgroundBorderWidth: 2,
13451
+ align: "left",
13452
+ x: 100,
13453
+ y: 890,
13454
+ width: "auto",
13455
+ height: "auto",
13456
+ role: "primary",
13457
+ animation: {
13458
+ in: "slide-right",
13459
+ out: "fade",
13460
+ inDuration: 0.5,
13461
+ outDuration: 0.3,
13462
+ hold: "full"
13463
+ }
13464
+ }
13465
+ ]
13466
+ },
13467
+ {
13468
+ id: "minimal-editorial-title",
13469
+ label: "Minimalist Editorial Layout",
13470
+ category: "minimal",
13471
+ duration: 4,
13472
+ canvasWidth: 1920,
13473
+ canvasHeight: 1080,
13474
+ layers: [
13475
+ {
13476
+ kind: "text",
13477
+ id: "min-title",
13478
+ content: "ESSENTIAL PERSPECTIVES",
13479
+ fontFamily: "Inter Variable",
13480
+ fontSize: 64,
13481
+ fontWeight: 300,
13482
+ letterSpacing: 8,
13483
+ color: "#ffffff",
13484
+ align: "center",
13485
+ x: 360,
13486
+ y: 470,
13487
+ width: 1200,
13488
+ height: 80,
13489
+ role: "primary",
13490
+ animation: {
13491
+ in: "fade",
13492
+ out: "fade",
13493
+ inDuration: 1,
13494
+ outDuration: 0.4,
13495
+ hold: "full"
13496
+ }
13497
+ },
13498
+ {
13499
+ kind: "text",
13500
+ id: "min-sub",
13501
+ content: "Volume 01 \u2014 Issue 2026",
13502
+ fontFamily: "Inter Variable",
13503
+ fontSize: 22,
13504
+ fontWeight: 500,
13505
+ letterSpacing: 4,
13506
+ color: "#94a3b8",
13507
+ align: "center",
13508
+ x: 460,
13509
+ y: 560,
13510
+ width: 1e3,
13511
+ height: 40,
13512
+ role: "secondary",
13513
+ animation: {
13514
+ in: "fade",
13515
+ out: "fade",
13516
+ inDuration: 1.2,
13517
+ outDuration: 0.4,
13518
+ hold: "full"
13519
+ }
13520
+ }
13521
+ ]
13041
13522
  }
13042
13523
  ];
13043
13524
  function getCanvasTemplatePreset(id) {
@@ -13262,7 +13743,8 @@ function legacyLayerToNode(layer2, index) {
13262
13743
  style: {
13263
13744
  fontFamily: resolveStringProperty(text?.fontFamily, "Inter Variable"),
13264
13745
  fontSize: resolveNumericProperty(text?.fontSize, 48),
13265
- fontWeight: resolveStringProperty(text?.fontWeight, "400"),
13746
+ fontWeight: resolveAnimatableValue(text?.fontWeight, 400),
13747
+ fontStyle: text?.fontStyle === "italic" ? "italic" : "normal",
13266
13748
  textColor: resolveStringProperty(
13267
13749
  text?.color ?? text?.textColor,
13268
13750
  "#FFFFFF"
@@ -14028,13 +14510,57 @@ function letterSpacedText(ctx, text, x, y, maxWidth, letterSpacing) {
14028
14510
  }
14029
14511
  ctx.textAlign = align;
14030
14512
  }
14513
+ var FONT_ALIAS_MAP = {
14514
+ "inter": "Inter Variable",
14515
+ "inter variable": "Inter Variable",
14516
+ "outfit": "Outfit Variable",
14517
+ "outfit variable": "Outfit Variable",
14518
+ "playfair display": "Playfair Display Variable",
14519
+ "playfair display variable": "Playfair Display Variable",
14520
+ "montserrat": "Montserrat Variable",
14521
+ "montserrat variable": "Montserrat Variable",
14522
+ "roboto": "Roboto Variable",
14523
+ "roboto variable": "Roboto Variable",
14524
+ "roboto condensed": "Roboto Condensed Variable",
14525
+ "roboto condensed variable": "Roboto Condensed Variable",
14526
+ "raleway": "Raleway Variable",
14527
+ "raleway variable": "Raleway Variable",
14528
+ "space grotesk": "Space Grotesk Variable",
14529
+ "space grotesk variable": "Space Grotesk Variable",
14530
+ "nunito": "Nunito Variable",
14531
+ "nunito variable": "Nunito Variable",
14532
+ "open sans": "Open Sans Variable",
14533
+ "open sans variable": "Open Sans Variable",
14534
+ "oswald": "Oswald Variable",
14535
+ "oswald variable": "Oswald Variable",
14536
+ "geist": "Geist Variable",
14537
+ "geist variable": "Geist Variable",
14538
+ "dancing script": "Dancing Script Variable",
14539
+ "dancing script variable": "Dancing Script Variable"
14540
+ };
14541
+ function resolveTemplateFontFamily(family) {
14542
+ if (!family) return "sans-serif";
14543
+ const clean = String(family).trim().replace(/^["']|["']$/g, "");
14544
+ const lower = clean.toLowerCase();
14545
+ return FONT_ALIAS_MAP[lower] || clean;
14546
+ }
14547
+ function constructFontStack(fontStyle, fontWeight, fontSize, rawFamily) {
14548
+ const canonical = resolveTemplateFontFamily(rawFamily);
14549
+ const cleanRaw = String(rawFamily || "").trim().replace(/^["']|["']$/g, "");
14550
+ const style = fontStyle === "italic" ? "italic" : "normal";
14551
+ const weight = fontWeight ?? 400;
14552
+ if (canonical && cleanRaw && canonical.toLowerCase() !== cleanRaw.toLowerCase()) {
14553
+ return `${style} ${weight} ${fontSize}px "${canonical}", "${cleanRaw}", sans-serif`;
14554
+ }
14555
+ return `${style} ${weight} ${fontSize}px "${canonical || cleanRaw || "sans-serif"}", sans-serif`;
14556
+ }
14031
14557
  function drawTextLayer(ctx, layer2, style) {
14032
14558
  const text = layer2.text ?? "";
14033
14559
  const fontSize = finite2(style.fontSize, 48);
14034
14560
  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}"`;
14561
+ const fontStyle = style.fontStyle || "normal";
14562
+ const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14563
+ ctx.font = constructFontStack(fontStyle, fontWeight, fontSize, rawFamily);
14038
14564
  ctx.fillStyle = cssColor(style.textColor, "#FFFFFF");
14039
14565
  ctx.textAlign = style.textAlign ?? "left";
14040
14566
  ctx.textBaseline = style.verticalAlign === "top" ? "top" : style.verticalAlign === "bottom" ? "bottom" : "middle";
@@ -14051,8 +14577,10 @@ function drawTextLayer(ctx, layer2, style) {
14051
14577
  function drawSplitTextLayer(ctx, layer2, style, animator, progress) {
14052
14578
  const text = layer2.text ?? "";
14053
14579
  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}"`;
14580
+ const fontWeight = style.fontWeight ?? 400;
14581
+ const fontStyle = style.fontStyle || "normal";
14582
+ const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14583
+ ctx.font = constructFontStack(fontStyle, fontWeight, fontSize, rawFamily);
14056
14584
  ctx.textBaseline = "middle";
14057
14585
  ctx.textAlign = "left";
14058
14586
  ctx.fillStyle = cssColor(style.textColor, "#FFFFFF");
@@ -14142,9 +14670,9 @@ function renderTextTemplateToCanvas(ctx, input) {
14142
14670
  // Measure with the exact Canvas context that will draw the layer. This
14143
14671
  // makes auto-sized nodes use loaded font metrics instead of a fixed box.
14144
14672
  measureText: (text, style) => {
14145
- const family = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14673
+ const rawFamily = String(style.fontFamily || "sans-serif").replace(/"/g, "");
14146
14674
  ctx.save();
14147
- ctx.font = `${style.fontWeight ?? 400} ${finite2(style.fontSize, 48)}px "${family}"`;
14675
+ ctx.font = constructFontStack(style.fontStyle, style.fontWeight, finite2(style.fontSize, 48), rawFamily);
14148
14676
  const width = ctx.measureText(text).width + Math.max(0, text.length - 1) * finite2(style.letterSpacing, 0);
14149
14677
  ctx.restore();
14150
14678
  return { width };
@@ -15696,6 +16224,13 @@ function resolveConform(conform, canvasWidth, canvasHeight) {
15696
16224
  if (!sw || !sh) {
15697
16225
  return { x: 0, y: 0, width: canvasWidth, height: canvasHeight };
15698
16226
  }
16227
+ if (mode === "stretch") {
16228
+ const width2 = canvasWidth * userScale;
16229
+ const height2 = canvasHeight * userScale;
16230
+ const x2 = (canvasWidth - width2) / 2 + userOffsetX;
16231
+ const y2 = (canvasHeight - height2) / 2 + userOffsetY;
16232
+ return { x: x2, y: y2, width: width2, height: height2 };
16233
+ }
15699
16234
  let baseScale;
15700
16235
  switch (mode) {
15701
16236
  case "fit":
@@ -25195,6 +25730,7 @@ var VERSION = "1.4.0";
25195
25730
  resolveMediaLayout,
25196
25731
  resolveNodeForBreakpoint,
25197
25732
  resolveSpatialConstraints,
25733
+ resolveTemplateFontFamily,
25198
25734
  resolveTextTemplateArtifact,
25199
25735
  restoreLetterSpacing,
25200
25736
  rgbaToComponents,