@clypra-studio/engine 1.6.0 → 1.8.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/{chunk-V5D5SJPO.js → chunk-B2KQXJLS.js} +170 -5
- package/dist/chunk-B2KQXJLS.js.map +1 -0
- package/dist/{index-QSvA1MMy.d.ts → index-9ozUyd9c.d.ts} +1 -1
- package/dist/{index-DKJxLj6P.d.cts → index-CHLTQy2v.d.cts} +1 -1
- package/dist/{index-DbojK0dC.d.ts → index-FDQDo2pR.d.cts} +48 -2
- package/dist/{index-l2Qgw6Dt.d.cts → index-XWLBYyFQ.d.ts} +48 -2
- package/dist/index.cjs +176 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -10
- package/dist/index.d.ts +57 -10
- package/dist/index.js +25 -17
- package/dist/index.js.map +1 -1
- package/dist/rendering/index.cjs +88 -4
- package/dist/rendering/index.cjs.map +1 -1
- package/dist/rendering/index.d.cts +2 -2
- package/dist/rendering/index.d.ts +2 -2
- package/dist/rendering/index.js +1 -1
- package/dist/textEffects/index.d.cts +2 -2
- package/dist/textEffects/index.d.ts +2 -2
- package/dist/{types-CoshNXmU.d.cts → types-BsF33bC4.d.cts} +38 -0
- package/dist/{types-CoshNXmU.d.ts → types-BsF33bC4.d.ts} +38 -0
- package/package.json +1 -1
- package/dist/chunk-V5D5SJPO.js.map +0 -1
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
|
+
resolveTemplateControlValues: () => resolveTemplateControlValues,
|
|
351
352
|
resolveTemplateFontFamily: () => resolveTemplateFontFamily,
|
|
352
353
|
resolveTextTemplateArtifact: () => resolveTextTemplateArtifact,
|
|
353
354
|
restoreLetterSpacing: () => restoreLetterSpacing,
|
|
@@ -551,6 +552,12 @@ var BoundingBoxSchema = import_zod.z.object({
|
|
|
551
552
|
mode: import_zod.z.enum(["ink", "panel"]).optional()
|
|
552
553
|
});
|
|
553
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(),
|
|
554
561
|
version: import_zod.z.string().optional(),
|
|
555
562
|
description: import_zod.z.string(),
|
|
556
563
|
tags: import_zod.z.array(import_zod.z.string()),
|
|
@@ -13753,7 +13760,26 @@ function legacyLayerToNode(layer2, index) {
|
|
|
13753
13760
|
lineHeight: resolveNumericProperty(text?.lineHeight, 1.2),
|
|
13754
13761
|
letterSpacing: resolveNumericProperty(text?.letterSpacing, 0),
|
|
13755
13762
|
overflow: text?.overflow,
|
|
13756
|
-
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
|
|
13757
13783
|
},
|
|
13758
13784
|
backgroundPanel: text?.backgroundColor || text?.backgroundPanel ? {
|
|
13759
13785
|
color: text?.backgroundPanel?.color ?? text?.backgroundColor ? resolveStringProperty(
|
|
@@ -13798,9 +13824,10 @@ function legacyLayerToNode(layer2, index) {
|
|
|
13798
13824
|
charFillColors: Array.isArray(text?.charFillColors) ? clone2(text.charFillColors) : void 0,
|
|
13799
13825
|
splitAnimator: text?.splitAnimator ? clone2(text.splitAnimator) : void 0,
|
|
13800
13826
|
textEffectRef: text?.styleRef ? clone2(text.styleRef) : void 0,
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
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
|
|
13804
13831
|
};
|
|
13805
13832
|
}
|
|
13806
13833
|
function inferControls(nodes) {
|
|
@@ -13955,6 +13982,86 @@ function normalizeTextTemplateArtifact(input) {
|
|
|
13955
13982
|
} : void 0
|
|
13956
13983
|
};
|
|
13957
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" && control.type !== "font") 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
|
+
} else if (control.type === "font") {
|
|
14027
|
+
const explicitFont = customization?.layerFontFamilies?.[control.target.nodeId];
|
|
14028
|
+
let roleFont;
|
|
14029
|
+
if (role === "secondary" || labelLower.includes("secondary")) {
|
|
14030
|
+
roleFont = customization?.secondaryFontFamily;
|
|
14031
|
+
} else {
|
|
14032
|
+
roleFont = customization?.primaryFontFamily;
|
|
14033
|
+
}
|
|
14034
|
+
values[control.id] = explicitFont ?? roleFont ?? values[control.id] ?? control.defaultValue;
|
|
14035
|
+
}
|
|
14036
|
+
}
|
|
14037
|
+
for (const node of artifact.document?.nodes || []) {
|
|
14038
|
+
if (node.type === "text") {
|
|
14039
|
+
const role = node.role || "";
|
|
14040
|
+
const textKey = `text-${node.id}`;
|
|
14041
|
+
const fontKey = `font-${node.id}`;
|
|
14042
|
+
const colorKey = `color-${node.id}`;
|
|
14043
|
+
const explicitText = customization?.layerTexts?.[node.id];
|
|
14044
|
+
const roleText = role === "secondary" ? customization?.secondaryText : role === "accent" ? customization?.accentText : customization?.primaryText;
|
|
14045
|
+
const resolvedText = explicitText ?? roleText ?? (firstTextNode && node.id === firstTextNode.id ? targetFallbackText : void 0) ?? values[textKey] ?? node.text;
|
|
14046
|
+
if (resolvedText !== void 0) {
|
|
14047
|
+
values[textKey] = resolvedText;
|
|
14048
|
+
}
|
|
14049
|
+
const explicitFont = customization?.layerFontFamilies?.[node.id];
|
|
14050
|
+
const roleFont = role === "secondary" ? customization?.secondaryFontFamily : customization?.primaryFontFamily;
|
|
14051
|
+
const resolvedFont = explicitFont ?? roleFont ?? values[fontKey] ?? node.style?.fontFamily;
|
|
14052
|
+
if (resolvedFont !== void 0) {
|
|
14053
|
+
values[fontKey] = resolvedFont;
|
|
14054
|
+
}
|
|
14055
|
+
const explicitColor = customization?.layerColors?.[node.id];
|
|
14056
|
+
const roleColor = role === "secondary" ? customization?.secondaryColor : customization?.primaryColor;
|
|
14057
|
+
const resolvedColor = explicitColor ?? roleColor ?? values[colorKey] ?? node.style?.textColor;
|
|
14058
|
+
if (resolvedColor !== void 0) {
|
|
14059
|
+
values[colorKey] = resolvedColor;
|
|
14060
|
+
}
|
|
14061
|
+
}
|
|
14062
|
+
}
|
|
14063
|
+
return values;
|
|
14064
|
+
}
|
|
13958
14065
|
|
|
13959
14066
|
// src/textTemplates/validator.ts
|
|
13960
14067
|
var MAX_NODES = 500;
|
|
@@ -14253,6 +14360,24 @@ function compileTextTemplate(artifact, context) {
|
|
|
14253
14360
|
const node = findNode(document2.nodes, control.target.nodeId);
|
|
14254
14361
|
if (node) setPath(node, control.target.propertyPath, resolvedControls[control.id]);
|
|
14255
14362
|
}
|
|
14363
|
+
if (context.controlValues) {
|
|
14364
|
+
for (const node of document2.nodes || []) {
|
|
14365
|
+
if (node.type === "text") {
|
|
14366
|
+
const textVal = context.controlValues[`text-${node.id}`];
|
|
14367
|
+
if (typeof textVal === "string") {
|
|
14368
|
+
node.text = textVal;
|
|
14369
|
+
}
|
|
14370
|
+
const fontVal = context.controlValues[`font-${node.id}`];
|
|
14371
|
+
if (typeof fontVal === "string") {
|
|
14372
|
+
node.style = { ...node.style, fontFamily: fontVal };
|
|
14373
|
+
}
|
|
14374
|
+
const colorVal = context.controlValues[`color-${node.id}`];
|
|
14375
|
+
if (typeof colorVal === "string") {
|
|
14376
|
+
node.style = { ...node.style, textColor: colorVal };
|
|
14377
|
+
}
|
|
14378
|
+
}
|
|
14379
|
+
}
|
|
14380
|
+
}
|
|
14256
14381
|
const time = mapTime(context.time, artifact, context.clipDuration);
|
|
14257
14382
|
const flexPositions = /* @__PURE__ */ new Map();
|
|
14258
14383
|
const containers = (document2.nodes || []).filter((n) => n.type === "container");
|
|
@@ -14510,6 +14635,25 @@ function letterSpacedText(ctx, text, x, y, maxWidth, letterSpacing) {
|
|
|
14510
14635
|
}
|
|
14511
14636
|
ctx.textAlign = align;
|
|
14512
14637
|
}
|
|
14638
|
+
function letterSpacedStrokeText(ctx, text, x, y, maxWidth, letterSpacing) {
|
|
14639
|
+
if (!letterSpacing) {
|
|
14640
|
+
ctx.strokeText(text, x, y, maxWidth);
|
|
14641
|
+
return;
|
|
14642
|
+
}
|
|
14643
|
+
const glyphs = Array.from(text);
|
|
14644
|
+
const widths = glyphs.map((glyph) => ctx.measureText(glyph).width);
|
|
14645
|
+
const total = widths.reduce((sum, value) => sum + value, 0) + Math.max(0, glyphs.length - 1) * letterSpacing;
|
|
14646
|
+
const align = ctx.textAlign;
|
|
14647
|
+
let cursor = x;
|
|
14648
|
+
if (align === "center") cursor -= total / 2;
|
|
14649
|
+
if (align === "right") cursor -= total;
|
|
14650
|
+
ctx.textAlign = "left";
|
|
14651
|
+
for (let index = 0; index < glyphs.length; index += 1) {
|
|
14652
|
+
ctx.strokeText(glyphs[index], cursor, y);
|
|
14653
|
+
cursor += widths[index] + letterSpacing;
|
|
14654
|
+
}
|
|
14655
|
+
ctx.textAlign = align;
|
|
14656
|
+
}
|
|
14513
14657
|
var FONT_ALIAS_MAP = {
|
|
14514
14658
|
"inter": "Inter Variable",
|
|
14515
14659
|
"inter variable": "Inter Variable",
|
|
@@ -14564,6 +14708,17 @@ function drawTextLayer(ctx, layer2, style) {
|
|
|
14564
14708
|
ctx.fillStyle = cssColor(style.textColor, "#FFFFFF");
|
|
14565
14709
|
ctx.textAlign = style.textAlign ?? "left";
|
|
14566
14710
|
ctx.textBaseline = style.verticalAlign === "top" ? "top" : style.verticalAlign === "bottom" ? "bottom" : "middle";
|
|
14711
|
+
const shadowColor = style.shadow?.color ?? style.shadowColor;
|
|
14712
|
+
const shadowBlur = finite2(style.shadow?.blur ?? style.shadowBlur, 0);
|
|
14713
|
+
const shadowOffsetX = finite2(style.shadow?.offsetX ?? style.shadowOffsetX, 0);
|
|
14714
|
+
const shadowOffsetY = finite2(style.shadow?.offsetY ?? style.shadowOffsetY, 0);
|
|
14715
|
+
const hasShadow = !!shadowColor && (shadowBlur > 0 || shadowOffsetX !== 0 || shadowOffsetY !== 0);
|
|
14716
|
+
if (hasShadow) {
|
|
14717
|
+
ctx.shadowColor = cssColor(shadowColor, "#000000");
|
|
14718
|
+
ctx.shadowBlur = shadowBlur;
|
|
14719
|
+
ctx.shadowOffsetX = shadowOffsetX;
|
|
14720
|
+
ctx.shadowOffsetY = shadowOffsetY;
|
|
14721
|
+
}
|
|
14567
14722
|
const lineHeight = fontSize * finite2(style.lineHeight, 1.2);
|
|
14568
14723
|
const maxWidth = Math.max(1, layer2.width);
|
|
14569
14724
|
const lines = style.overflow === "wrap" ? wrapText(ctx, text, maxWidth) : [text];
|
|
@@ -14573,6 +14728,22 @@ function drawTextLayer(ctx, layer2, style) {
|
|
|
14573
14728
|
for (let index = 0; index < lines.length; index += 1) {
|
|
14574
14729
|
letterSpacedText(ctx, lines[index], anchorX, startY + index * lineHeight, maxWidth, finite2(style.letterSpacing, 0));
|
|
14575
14730
|
}
|
|
14731
|
+
if (hasShadow) {
|
|
14732
|
+
ctx.shadowColor = "transparent";
|
|
14733
|
+
ctx.shadowBlur = 0;
|
|
14734
|
+
ctx.shadowOffsetX = 0;
|
|
14735
|
+
ctx.shadowOffsetY = 0;
|
|
14736
|
+
}
|
|
14737
|
+
const strokeColor = style.stroke?.color ?? style.strokeColor;
|
|
14738
|
+
const strokeWidth = finite2(style.stroke?.width ?? style.strokeWidth, 0);
|
|
14739
|
+
if (strokeWidth > 0 && strokeColor) {
|
|
14740
|
+
ctx.strokeStyle = cssColor(strokeColor, "#000000");
|
|
14741
|
+
ctx.lineWidth = strokeWidth;
|
|
14742
|
+
ctx.lineJoin = "round";
|
|
14743
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
14744
|
+
letterSpacedStrokeText(ctx, lines[index], anchorX, startY + index * lineHeight, maxWidth, finite2(style.letterSpacing, 0));
|
|
14745
|
+
}
|
|
14746
|
+
}
|
|
14576
14747
|
}
|
|
14577
14748
|
function drawSplitTextLayer(ctx, layer2, style, animator, progress) {
|
|
14578
14749
|
const text = layer2.text ?? "";
|
|
@@ -25730,6 +25901,7 @@ var VERSION = "1.4.0";
|
|
|
25730
25901
|
resolveMediaLayout,
|
|
25731
25902
|
resolveNodeForBreakpoint,
|
|
25732
25903
|
resolveSpatialConstraints,
|
|
25904
|
+
resolveTemplateControlValues,
|
|
25733
25905
|
resolveTemplateFontFamily,
|
|
25734
25906
|
resolveTextTemplateArtifact,
|
|
25735
25907
|
restoreLetterSpacing,
|