@meframe/core 0.5.8 → 0.5.10
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/meframe-service/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js.map +1 -0
- package/dist/meframe-service/node_modules/.pnpm/mp4box@0.5.4/node_modules/mp4box/dist/mp4box.all.js.map +1 -0
- package/dist/model/CompositionModel.js +2 -2
- package/dist/model/CompositionModel.js.map +1 -1
- package/dist/model/types.d.ts +1 -1
- package/dist/model/types.d.ts.map +1 -1
- package/dist/model/types.js.map +1 -1
- package/dist/orchestrator/CompositionPlanner.d.ts.map +1 -1
- package/dist/orchestrator/CompositionPlanner.js +14 -3
- package/dist/orchestrator/CompositionPlanner.js.map +1 -1
- package/dist/stages/compose/font-system/FontManager.js +1 -1
- package/dist/stages/compose/font-system/FontManager.js.map +1 -1
- package/dist/stages/compose/font-system/font-templates.js +4 -4
- package/dist/stages/compose/font-system/font-templates.js.map +1 -1
- package/dist/stages/compose/font-system/types.d.ts +1 -1
- package/dist/stages/compose/font-system/types.d.ts.map +1 -1
- package/dist/stages/compose/instructions.d.ts +2 -2
- package/dist/stages/compose/instructions.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/basic-text-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/basic-text-renderer.js +9 -21
- package/dist/stages/compose/text-renderers/basic-text-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.js +12 -21
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/character-ktv-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/character-ktv-renderer.js +9 -21
- package/dist/stages/compose/text-renderers/character-ktv-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/word-by-word-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/word-by-word-renderer.js +13 -25
- package/dist/stages/compose/text-renderers/word-by-word-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/word-fancy-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/word-fancy-renderer.js +9 -21
- package/dist/stages/compose/text-renderers/word-fancy-renderer.js.map +1 -1
- package/dist/stages/compose/text-utils/caption-layout.d.ts +1 -1
- package/dist/stages/compose/text-utils/caption-layout.d.ts.map +1 -1
- package/dist/stages/compose/text-utils/caption-layout.js +1 -1
- package/dist/stages/compose/text-utils/caption-layout.js.map +1 -1
- package/dist/stages/compose/text-utils/caption-position.d.ts +12 -0
- package/dist/stages/compose/text-utils/caption-position.d.ts.map +1 -0
- package/dist/stages/compose/text-utils/caption-position.js +21 -0
- package/dist/stages/compose/text-utils/caption-position.js.map +1 -0
- package/dist/stages/compose/text-utils/text-layout-cache.js +1 -1
- package/dist/stages/compose/text-utils/text-layout-cache.js.map +1 -1
- package/dist/stages/compose/types.d.ts +2 -2
- package/dist/stages/compose/types.d.ts.map +1 -1
- package/dist/stages/mux/MP4Muxer.js +1 -1
- package/dist/utils/mp4box.js +2 -3
- package/dist/workers/stages/export/{export.worker.p7X_YtxQ.js → export.worker.XX9XDu3o.js} +66 -111
- package/dist/workers/stages/export/export.worker.XX9XDu3o.js.map +1 -0
- package/dist/workers/worker-manifest.json +1 -1
- package/package.json +1 -1
- package/dist/medeo-fe/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js.map +0 -1
- package/dist/medeo-fe/node_modules/.pnpm/mp4box@0.5.4/node_modules/mp4box/dist/mp4box.all.js.map +0 -1
- package/dist/workers/stages/export/export.worker.p7X_YtxQ.js.map +0 -1
- /package/dist/{medeo-fe → meframe-service}/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js +0 -0
- /package/dist/{medeo-fe → meframe-service}/node_modules/.pnpm/mp4box@0.5.4/node_modules/mp4box/dist/mp4box.all.js +0 -0
|
@@ -2,26 +2,10 @@ import { formEvenLinesWithWords } from "../text-utils/text-wrapper.js";
|
|
|
2
2
|
import { getLetterCaseText, measureTextWidth } from "../text-utils/text-metrics.js";
|
|
3
3
|
import { interpolate, interpolateColor } from "./animation-utils.js";
|
|
4
4
|
import { needsSpaceBetweenWords } from "../text-utils/locale-detector.js";
|
|
5
|
+
import { calculateCaptionStartY } from "../text-utils/caption-position.js";
|
|
5
6
|
function usToFrame(us, fps) {
|
|
6
7
|
return Math.floor(us / (1e6 / fps));
|
|
7
8
|
}
|
|
8
|
-
function calculateYPosition(canvasHeight, totalHeight, globalPosition) {
|
|
9
|
-
if (!globalPosition) {
|
|
10
|
-
return canvasHeight / 2 - totalHeight / 2;
|
|
11
|
-
}
|
|
12
|
-
if (globalPosition.top) {
|
|
13
|
-
const topPercent = parseFloat(globalPosition.top) / 100;
|
|
14
|
-
return canvasHeight * topPercent;
|
|
15
|
-
}
|
|
16
|
-
if (globalPosition.bottom) {
|
|
17
|
-
const bottomPercent = parseFloat(globalPosition.bottom) / 100;
|
|
18
|
-
return canvasHeight * (1 - bottomPercent) - totalHeight;
|
|
19
|
-
}
|
|
20
|
-
if (globalPosition.justifyContent === "center" || globalPosition.alignItems === "center") {
|
|
21
|
-
return canvasHeight / 2 - totalHeight / 2;
|
|
22
|
-
}
|
|
23
|
-
return canvasHeight / 2 - totalHeight / 2;
|
|
24
|
-
}
|
|
25
9
|
function renderWordByWord(ctx, layer, canvasWidth, canvasHeight, relativeFrame, fps = 30) {
|
|
26
10
|
const fontConfig = layer.fontConfig?.textStyle;
|
|
27
11
|
if (!fontConfig) return;
|
|
@@ -29,11 +13,11 @@ function renderWordByWord(ctx, layer, canvasWidth, canvasHeight, relativeFrame,
|
|
|
29
13
|
const fontFamily = fontConfig.fontFamily;
|
|
30
14
|
const fontWeight = fontConfig.fontWeight;
|
|
31
15
|
const fill = fontConfig.fill;
|
|
32
|
-
const
|
|
16
|
+
const strokeColor = fontConfig.strokeColor;
|
|
33
17
|
const strokeWidth = fontConfig.strokeWidth || 0;
|
|
34
18
|
const lineHeight = fontConfig.lineHeight || 1.2;
|
|
35
19
|
const highlightFill = layer.animation?.highlightTextStyle?.fill || "rgb(255, 215, 0)";
|
|
36
|
-
const highlightStroke = layer.animation?.highlightTextStyle?.
|
|
20
|
+
const highlightStroke = layer.animation?.highlightTextStyle?.strokeColor || strokeColor;
|
|
37
21
|
const maxWidth = canvasWidth * 0.64;
|
|
38
22
|
const text = getLetterCaseText(layer.text, layer.letterCase);
|
|
39
23
|
const needsSpace = needsSpaceBetweenWords(layer.localeCode || "en-US", text);
|
|
@@ -50,7 +34,11 @@ function renderWordByWord(ctx, layer, canvasWidth, canvasHeight, relativeFrame,
|
|
|
50
34
|
const wordPositions = [];
|
|
51
35
|
let wordIndex = 0;
|
|
52
36
|
const totalHeight = lines.length * fontSize * lineHeight;
|
|
53
|
-
const startY =
|
|
37
|
+
const startY = calculateCaptionStartY(
|
|
38
|
+
canvasHeight,
|
|
39
|
+
totalHeight,
|
|
40
|
+
layer.fontConfig?.globalPosition
|
|
41
|
+
);
|
|
54
42
|
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
55
43
|
const line = lines[lineIndex];
|
|
56
44
|
const lineWords = line.split(needsSpace ? /\s+/ : "");
|
|
@@ -84,7 +72,7 @@ function renderWordByWord(ctx, layer, canvasWidth, canvasHeight, relativeFrame,
|
|
|
84
72
|
ctx.lineCap = "round";
|
|
85
73
|
for (const wordPos of wordPositions) {
|
|
86
74
|
let currentFill = fill;
|
|
87
|
-
let currentStroke =
|
|
75
|
+
let currentStroke = strokeColor;
|
|
88
76
|
if (wordPos.timing) {
|
|
89
77
|
const { startFrame, endFrame } = wordPos.timing;
|
|
90
78
|
if (relativeFrame >= startFrame && relativeFrame <= endFrame) {
|
|
@@ -98,8 +86,8 @@ function renderWordByWord(ctx, layer, canvasWidth, canvasHeight, relativeFrame,
|
|
|
98
86
|
}
|
|
99
87
|
);
|
|
100
88
|
currentFill = interpolateColor(fill, highlightFill, transitionProgressIn);
|
|
101
|
-
if (
|
|
102
|
-
currentStroke = interpolateColor(
|
|
89
|
+
if (strokeColor && highlightStroke) {
|
|
90
|
+
currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressIn);
|
|
103
91
|
}
|
|
104
92
|
} else if (relativeFrame > endFrame) {
|
|
105
93
|
const transitionProgressOut = interpolate(relativeFrame, [endFrame, endFrame + 3], [1, 0], {
|
|
@@ -107,8 +95,8 @@ function renderWordByWord(ctx, layer, canvasWidth, canvasHeight, relativeFrame,
|
|
|
107
95
|
extrapolateRight: "clamp"
|
|
108
96
|
});
|
|
109
97
|
currentFill = interpolateColor(fill, highlightFill, transitionProgressOut);
|
|
110
|
-
if (
|
|
111
|
-
currentStroke = interpolateColor(
|
|
98
|
+
if (strokeColor && highlightStroke) {
|
|
99
|
+
currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressOut);
|
|
112
100
|
}
|
|
113
101
|
}
|
|
114
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"word-by-word-renderer.js","sources":["../../../../src/stages/compose/text-renderers/word-by-word-renderer.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { formEvenLinesWithWords } from '../text-utils/text-wrapper';\nimport { getLetterCaseText, measureTextWidth } from '../text-utils/text-metrics';\nimport { interpolate, interpolateColor } from './animation-utils';\nimport { needsSpaceBetweenWords } from '../text-utils/locale-detector';\n\ninterface WordPosition {\n text: string;\n x: number;\n y: number;\n lineIndex: number;\n wordIndex: number;\n timing?: { startFrame: number; endFrame: number };\n}\n\nfunction usToFrame(us: number, fps: number): number {\n return Math.floor(us / (1000000 / fps));\n}\n\
|
|
1
|
+
{"version":3,"file":"word-by-word-renderer.js","sources":["../../../../src/stages/compose/text-renderers/word-by-word-renderer.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { formEvenLinesWithWords } from '../text-utils/text-wrapper';\nimport { getLetterCaseText, measureTextWidth } from '../text-utils/text-metrics';\nimport { interpolate, interpolateColor } from './animation-utils';\nimport { needsSpaceBetweenWords } from '../text-utils/locale-detector';\nimport { calculateCaptionStartY } from '../text-utils/caption-position';\n\ninterface WordPosition {\n text: string;\n x: number;\n y: number;\n lineIndex: number;\n wordIndex: number;\n timing?: { startFrame: number; endFrame: number };\n}\n\nfunction usToFrame(us: number, fps: number): number {\n return Math.floor(us / (1000000 / fps));\n}\n\nexport function renderWordByWord(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n layer: TextLayer,\n canvasWidth: number,\n canvasHeight: number,\n relativeFrame: number,\n fps: number = 30\n): void {\n const fontConfig = layer.fontConfig?.textStyle;\n if (!fontConfig) return;\n\n const fontSize = fontConfig.fontSize;\n const fontFamily = fontConfig.fontFamily;\n const fontWeight = fontConfig.fontWeight;\n const fill = fontConfig.fill;\n const strokeColor = fontConfig.strokeColor;\n const strokeWidth = fontConfig.strokeWidth || 0;\n const lineHeight = fontConfig.lineHeight || 1.2;\n\n const highlightFill = layer.animation?.highlightTextStyle?.fill || 'rgb(255, 215, 0)';\n const highlightStroke = layer.animation?.highlightTextStyle?.strokeColor || strokeColor;\n\n const maxWidth = canvasWidth * 0.64;\n const text = getLetterCaseText(layer.text, layer.letterCase);\n const needsSpace = needsSpaceBetweenWords(layer.localeCode || 'en-US', text);\n const words = text.split(needsSpace ? /\\s+/ : '');\n const lines = formEvenLinesWithWords(\n ctx,\n words,\n maxWidth,\n fontSize,\n needsSpace,\n fontFamily,\n fontWeight\n );\n\n const wordPositions: WordPosition[] = [];\n let wordIndex = 0;\n\n const totalHeight = lines.length * fontSize * lineHeight;\n const startY = calculateCaptionStartY(\n canvasHeight,\n totalHeight,\n layer.fontConfig?.globalPosition\n );\n\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\n const line = lines[lineIndex]!;\n const lineWords = line.split(needsSpace ? /\\s+/ : '');\n const y = startY + lineIndex * fontSize * lineHeight + fontSize / 2;\n\n const lineWidth = measureTextWidth(ctx, line, fontSize, fontFamily, fontWeight);\n let currentX = canvasWidth / 2 - lineWidth / 2;\n\n for (const word of lineWords) {\n const wordWidth = measureTextWidth(ctx, word, fontSize, fontFamily, fontWeight);\n const wordTimingUs = layer.wordTimings?.[wordIndex];\n\n const wordTiming = wordTimingUs\n ? {\n startFrame: usToFrame(wordTimingUs.startUs, fps),\n endFrame: usToFrame(wordTimingUs.endUs, fps),\n }\n : undefined;\n\n wordPositions.push({\n text: word,\n x: currentX + wordWidth / 2,\n y,\n lineIndex,\n wordIndex,\n timing: wordTiming,\n });\n\n currentX +=\n wordWidth + (needsSpace ? measureTextWidth(ctx, ' ', fontSize, fontFamily, fontWeight) : 0);\n wordIndex++;\n }\n }\n\n ctx.save();\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.lineJoin = 'round';\n ctx.lineCap = 'round';\n\n for (const wordPos of wordPositions) {\n let currentFill = fill;\n let currentStroke = strokeColor;\n\n if (wordPos.timing) {\n const { startFrame, endFrame } = wordPos.timing;\n\n if (relativeFrame >= startFrame && relativeFrame <= endFrame) {\n const transitionProgressIn = interpolate(\n relativeFrame,\n [startFrame, startFrame + 3],\n [0, 1],\n {\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n }\n );\n\n currentFill = interpolateColor(fill, highlightFill, transitionProgressIn);\n if (strokeColor && highlightStroke) {\n currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressIn);\n }\n } else if (relativeFrame > endFrame) {\n const transitionProgressOut = interpolate(relativeFrame, [endFrame, endFrame + 3], [1, 0], {\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n });\n\n currentFill = interpolateColor(fill, highlightFill, transitionProgressOut);\n if (strokeColor && highlightStroke) {\n currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressOut);\n }\n }\n }\n\n if (currentStroke && strokeWidth > 0) {\n ctx.strokeStyle = currentStroke;\n ctx.lineWidth = strokeWidth;\n ctx.strokeText(wordPos.text, wordPos.x, wordPos.y);\n }\n ctx.fillStyle = currentFill;\n ctx.fillText(wordPos.text, wordPos.x, wordPos.y);\n }\n\n ctx.restore();\n}\n"],"names":[],"mappings":";;;;;AAgBA,SAAS,UAAU,IAAY,KAAqB;AAClD,SAAO,KAAK,MAAM,MAAM,MAAU,IAAI;AACxC;AAEO,SAAS,iBACd,KACA,OACA,aACA,cACA,eACA,MAAc,IACR;AACN,QAAM,aAAa,MAAM,YAAY;AACrC,MAAI,CAAC,WAAY;AAEjB,QAAM,WAAW,WAAW;AAC5B,QAAM,aAAa,WAAW;AAC9B,QAAM,aAAa,WAAW;AAC9B,QAAM,OAAO,WAAW;AACxB,QAAM,cAAc,WAAW;AAC/B,QAAM,cAAc,WAAW,eAAe;AAC9C,QAAM,aAAa,WAAW,cAAc;AAE5C,QAAM,gBAAgB,MAAM,WAAW,oBAAoB,QAAQ;AACnE,QAAM,kBAAkB,MAAM,WAAW,oBAAoB,eAAe;AAE5E,QAAM,WAAW,cAAc;AAC/B,QAAM,OAAO,kBAAkB,MAAM,MAAM,MAAM,UAAU;AAC3D,QAAM,aAAa,uBAAuB,MAAM,cAAc,SAAS,IAAI;AAC3E,QAAM,QAAQ,KAAK,MAAM,aAAa,QAAQ,EAAE;AAChD,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,gBAAgC,CAAA;AACtC,MAAI,YAAY;AAEhB,QAAM,cAAc,MAAM,SAAS,WAAW;AAC9C,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA,MAAM,YAAY;AAAA,EAAA;AAGpB,WAAS,YAAY,GAAG,YAAY,MAAM,QAAQ,aAAa;AAC7D,UAAM,OAAO,MAAM,SAAS;AAC5B,UAAM,YAAY,KAAK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AiB,aAAa,iBAAiB,oBAAoB;AAAA,QACrF;AAAA,MACF,WAAW,gBAAgB,UAAU;AACnC,cAAM,wBAAwB,YAAY,eAAe,CAAC,UAAU,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;AAAA,UACzF,iBAAiB;AAAA,UACjB,kBAAkB;AAAA,QAAA,CACnB;AAED,sBAAc,iBAAiB,MAAM,eAAe,qBAAqB;AACzE,YAAI,eAAe,iBAAiB;AAClC,0BAAgB,iBAAiB,aAAa,iBAAiB,qBAAqB;AAAA,QACtF;AAAA,MACF;AAAA,IACF;AAEA,QAAI,iBAAiB,cAAc,GAAG;AACpC,UAAI,cAAc;AAClB,UAAI,YAAY;AAChB,UAAI,WAAW,QAAQ,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAAA,IACnD;AACA,QAAI,YAAY;AAChB,QAAI,SAAS,QAAQ,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAAA,EACjD;AAEA,MAAI,QAAA;AACN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"word-fancy-renderer.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-renderers/word-fancy-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"word-fancy-renderer.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-renderers/word-fancy-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAqB1C,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,iCAAiC,GAAG,wBAAwB,EACjE,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,GAAG,GAAE,MAAW,GACf,IAAI,CAsIN"}
|
|
@@ -2,26 +2,10 @@ import { formEvenLinesWithWords } from "../text-utils/text-wrapper.js";
|
|
|
2
2
|
import { getLetterCaseText, measureTextWidth } from "../text-utils/text-metrics.js";
|
|
3
3
|
import { interpolate, springEasing } from "./animation-utils.js";
|
|
4
4
|
import { needsSpaceBetweenWords } from "../text-utils/locale-detector.js";
|
|
5
|
+
import { calculateCaptionStartY } from "../text-utils/caption-position.js";
|
|
5
6
|
function usToFrame(us, fps) {
|
|
6
7
|
return Math.floor(us / (1e6 / fps));
|
|
7
8
|
}
|
|
8
|
-
function calculateYPosition(canvasHeight, totalHeight, globalPosition) {
|
|
9
|
-
if (!globalPosition) {
|
|
10
|
-
return canvasHeight / 2 - totalHeight / 2;
|
|
11
|
-
}
|
|
12
|
-
if (globalPosition.top) {
|
|
13
|
-
const topPercent = parseFloat(globalPosition.top) / 100;
|
|
14
|
-
return canvasHeight * topPercent;
|
|
15
|
-
}
|
|
16
|
-
if (globalPosition.bottom) {
|
|
17
|
-
const bottomPercent = parseFloat(globalPosition.bottom) / 100;
|
|
18
|
-
return canvasHeight * (1 - bottomPercent) - totalHeight;
|
|
19
|
-
}
|
|
20
|
-
if (globalPosition.justifyContent === "center" || globalPosition.alignItems === "center") {
|
|
21
|
-
return canvasHeight / 2 - totalHeight / 2;
|
|
22
|
-
}
|
|
23
|
-
return canvasHeight / 2 - totalHeight / 2;
|
|
24
|
-
}
|
|
25
9
|
function renderWordByWordFancy(ctx, layer, canvasWidth, canvasHeight, relativeFrame, fps = 30) {
|
|
26
10
|
const fontConfig = layer.fontConfig?.textStyle;
|
|
27
11
|
if (!fontConfig) return;
|
|
@@ -29,7 +13,7 @@ function renderWordByWordFancy(ctx, layer, canvasWidth, canvasHeight, relativeFr
|
|
|
29
13
|
const fontFamily = fontConfig.fontFamily;
|
|
30
14
|
const fontWeight = fontConfig.fontWeight;
|
|
31
15
|
const fill = fontConfig.fill;
|
|
32
|
-
const
|
|
16
|
+
const strokeColor = fontConfig.strokeColor;
|
|
33
17
|
const strokeWidth = fontConfig.strokeWidth || 0;
|
|
34
18
|
const lineHeight = fontConfig.lineHeight || 1.2;
|
|
35
19
|
const highlightBackgroundColor = layer.animation?.highlightColor || "rgb(255, 215, 0)";
|
|
@@ -49,7 +33,11 @@ function renderWordByWordFancy(ctx, layer, canvasWidth, canvasHeight, relativeFr
|
|
|
49
33
|
const wordPositions = [];
|
|
50
34
|
let wordIndex = 0;
|
|
51
35
|
const totalHeight = lines.length * fontSize * lineHeight;
|
|
52
|
-
const startY =
|
|
36
|
+
const startY = calculateCaptionStartY(
|
|
37
|
+
canvasHeight,
|
|
38
|
+
totalHeight,
|
|
39
|
+
layer.fontConfig?.globalPosition
|
|
40
|
+
);
|
|
53
41
|
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
54
42
|
const line = lines[lineIndex];
|
|
55
43
|
const lineWords = line.split(needsSpace ? /\s+/ : "");
|
|
@@ -119,8 +107,8 @@ function renderWordByWordFancy(ctx, layer, canvasWidth, canvasHeight, relativeFr
|
|
|
119
107
|
ctx.restore();
|
|
120
108
|
}
|
|
121
109
|
}
|
|
122
|
-
if (
|
|
123
|
-
ctx.strokeStyle =
|
|
110
|
+
if (strokeColor && strokeWidth > 0) {
|
|
111
|
+
ctx.strokeStyle = strokeColor;
|
|
124
112
|
ctx.lineWidth = strokeWidth;
|
|
125
113
|
ctx.strokeText(wordPos.text, wordPos.x, wordPos.y);
|
|
126
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"word-fancy-renderer.js","sources":["../../../../src/stages/compose/text-renderers/word-fancy-renderer.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { formEvenLinesWithWords } from '../text-utils/text-wrapper';\nimport { getLetterCaseText, measureTextWidth } from '../text-utils/text-metrics';\nimport { springEasing, interpolate } from './animation-utils';\nimport { needsSpaceBetweenWords } from '../text-utils/locale-detector';\n\ninterface WordPosition {\n text: string;\n x: number;\n y: number;\n width: number;\n lineIndex: number;\n wordIndex: number;\n timing?: { startFrame: number; endFrame: number };\n}\n\nfunction usToFrame(us: number, fps: number): number {\n return Math.floor(us / (1000000 / fps));\n}\n\
|
|
1
|
+
{"version":3,"file":"word-fancy-renderer.js","sources":["../../../../src/stages/compose/text-renderers/word-fancy-renderer.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { formEvenLinesWithWords } from '../text-utils/text-wrapper';\nimport { getLetterCaseText, measureTextWidth } from '../text-utils/text-metrics';\nimport { springEasing, interpolate } from './animation-utils';\nimport { needsSpaceBetweenWords } from '../text-utils/locale-detector';\nimport { calculateCaptionStartY } from '../text-utils/caption-position';\n\ninterface WordPosition {\n text: string;\n x: number;\n y: number;\n width: number;\n lineIndex: number;\n wordIndex: number;\n timing?: { startFrame: number; endFrame: number };\n}\n\nfunction usToFrame(us: number, fps: number): number {\n return Math.floor(us / (1000000 / fps));\n}\n\nexport function renderWordByWordFancy(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n layer: TextLayer,\n canvasWidth: number,\n canvasHeight: number,\n relativeFrame: number,\n fps: number = 30\n): void {\n const fontConfig = layer.fontConfig?.textStyle;\n if (!fontConfig) return;\n\n const fontSize = fontConfig.fontSize;\n const fontFamily = fontConfig.fontFamily;\n const fontWeight = fontConfig.fontWeight;\n const fill = fontConfig.fill;\n const strokeColor = fontConfig.strokeColor;\n const strokeWidth = fontConfig.strokeWidth || 0;\n const lineHeight = fontConfig.lineHeight || 1.2;\n\n const highlightBackgroundColor = layer.animation?.highlightColor || 'rgb(255, 215, 0)';\n\n const maxWidth = canvasWidth * 0.64;\n const text = getLetterCaseText(layer.text, layer.letterCase);\n const needsSpace = needsSpaceBetweenWords(layer.localeCode || 'en-US', text);\n const words = text.split(needsSpace ? /\\s+/ : '');\n const lines = formEvenLinesWithWords(\n ctx,\n words,\n maxWidth,\n fontSize,\n needsSpace,\n fontFamily,\n fontWeight\n );\n\n const wordPositions: WordPosition[] = [];\n let wordIndex = 0;\n\n const totalHeight = lines.length * fontSize * lineHeight;\n const startY = calculateCaptionStartY(\n canvasHeight,\n totalHeight,\n layer.fontConfig?.globalPosition\n );\n\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\n const line = lines[lineIndex]!;\n const lineWords = line.split(needsSpace ? /\\s+/ : '');\n const y = startY + lineIndex * fontSize * lineHeight + fontSize / 2;\n\n const lineWidth = measureTextWidth(ctx, line, fontSize, fontFamily, fontWeight);\n let currentX = canvasWidth / 2 - lineWidth / 2;\n\n for (const word of lineWords) {\n const wordWidth = measureTextWidth(ctx, word, fontSize, fontFamily, fontWeight);\n const wordTimingUs = layer.wordTimings?.[wordIndex];\n\n const wordTiming = wordTimingUs\n ? {\n startFrame: usToFrame(wordTimingUs.startUs, fps),\n endFrame: usToFrame(wordTimingUs.endUs, fps),\n }\n : undefined;\n\n wordPositions.push({\n text: word,\n x: currentX + wordWidth / 2,\n y,\n width: wordWidth,\n lineIndex,\n wordIndex,\n timing: wordTiming,\n });\n\n currentX +=\n wordWidth + (needsSpace ? measureTextWidth(ctx, ' ', fontSize, fontFamily, fontWeight) : 0);\n wordIndex++;\n }\n }\n\n ctx.save();\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.lineJoin = 'round';\n ctx.lineCap = 'round';\n\n for (const wordPos of wordPositions) {\n let backgroundOpacity = 0;\n let backgroundScale = 0.8;\n\n if (wordPos.timing) {\n const { startFrame, endFrame } = wordPos.timing;\n const preStartFrames = 3;\n const isActive = relativeFrame >= startFrame && relativeFrame <= endFrame;\n\n if (isActive) {\n const scaleSpringIn = springEasing(relativeFrame - (startFrame - preStartFrames), {\n damping: 6,\n mass: 0.35,\n stiffness: 200,\n overshootClamping: false,\n });\n\n const inProgress = interpolate(relativeFrame, [startFrame, startFrame + 1], [0, 1], {\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n });\n\n backgroundOpacity = 0.9 * inProgress;\n backgroundScale = 0.8 + scaleSpringIn * 0.45;\n } else if (relativeFrame > endFrame) {\n backgroundOpacity = 0;\n backgroundScale = 0.8;\n }\n\n if (backgroundOpacity > 0) {\n const padding = 8;\n const bgWidth = (wordPos.width + padding * 2) * backgroundScale;\n const bgHeight = (fontSize + padding) * backgroundScale;\n\n ctx.save();\n ctx.globalAlpha = backgroundOpacity;\n ctx.fillStyle = highlightBackgroundColor;\n ctx.beginPath();\n ctx.roundRect(wordPos.x - bgWidth / 2, wordPos.y - bgHeight / 2, bgWidth, bgHeight, 8);\n ctx.fill();\n ctx.restore();\n }\n }\n\n if (strokeColor && strokeWidth > 0) {\n ctx.strokeStyle = strokeColor;\n ctx.lineWidth = strokeWidth;\n ctx.strokeText(wordPos.text, wordPos.x, wordPos.y);\n }\n ctx.fillStyle = fill;\n ctx.fillText(wordPos.text, wordPos.x, wordPos.y);\n }\n\n ctx.restore();\n}\n"],"names":[],"mappings":";;;;;AAiBA,SAAS,UAAU,IAAY,KAAqB;AAClD,SAAO,KAAK,MAAM,MAAM,MAAU,IAAI;AACxC;AAEO,SAAS,sBACd,KACA,OACA,aACA,cACA,eACA,MAAc,IACR;AACN,QAAM,aAAa,MAAM,YAAY;AACrC,MAAI,CAAC,WAAY;AAEjB,QAAM,WAAW,WAAW;AAC5B,QAAM,aAAa,WAAW;AAC9B,QAAM,aAAa,WAAW;AAC9B,QAAM,OAAO,WAAW;AACxB,QAAM,cAAc,WAAW;AAC/B,QAAM,cAAc,WAAW,eAAe;AAC9C,QAAM,aAAa,WAAW,cAAc;AAE5C,QAAM,2BAA2B,MAAM,WAAW,kBAAkB;AAEpE,QAAM,WAAW,cAAc;AAC/B,QAAM,OAAO,kBAAkB,MAAM,MAAM,MAAM,UAAU;AAC3D,QAAM,aAAa,uBAAuB,MAAM,cAAc,SAAS,IAAI;AAC3E,QAAM,QAAQ,KAAK,MAAM,aAAa,QAAQ,EAAE;AAChD,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AA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,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"caption-layout.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-utils/caption-layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAQ5F,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;IACxC,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACtD;AAID,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,mBAAmB,EAAE,KAAK,GAAG,QAAQ,GAAG,YAAY,GAAG,gBAAgB,CAAC,CAAC;IACxF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAqFD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CA4E7E"}
|
|
@@ -114,7 +114,7 @@ function computeCaptionLayout(input) {
|
|
|
114
114
|
fontFamily,
|
|
115
115
|
fontWeight,
|
|
116
116
|
fill: textStyle.fill,
|
|
117
|
-
|
|
117
|
+
strokeColor: textStyle.strokeColor,
|
|
118
118
|
strokeWidth: textStyle.strokeWidth,
|
|
119
119
|
lineHeight: textStyle.lineHeight || 1.2,
|
|
120
120
|
letterSpacing: textStyle.letterSpacing,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caption-layout.js","sources":["../../../../src/stages/compose/text-utils/caption-layout.ts"],"sourcesContent":["import type { LocaleCode, ContainerStyle, GlobalPositionStyle } from '../font-system/types';\nimport { getFontConfig } from '../font-system/FontManager';\nimport { wrapText, formEvenLinesWithWords } from './text-wrapper';\nimport { getLetterCaseText } from './text-metrics';\nimport { needsSpaceBetweenWords } from './locale-detector';\n\n// ────── Input ──────\n\nexport interface CaptionLayoutInput {\n text: string;\n canvasWidth: number;\n canvasHeight: number;\n localeCode?: string;\n fontTemplate?: string;\n fontFamily?: string;\n /** When set, overrides the font template (same as compose `fontConfig.textStyle` merge). */\n fontSize?: number;\n fontWeight?: string | number;\n fill?: string;\n wordTimings?: Array<{ text: string; startUs: number; endUs: number }>;\n letterCase?: 'upper' | 'lower' | 'none';\n animation?: { type: string; [key: string]: unknown };\n}\n\n// ────── Output ──────\n\nexport interface CaptionLayout {\n lines: CaptionLine[];\n style: CaptionStyle;\n container: CaptionContainer;\n}\n\nexport interface CaptionLine {\n text: string;\n lineIndex: number;\n words: CaptionWord[];\n}\n\nexport interface CaptionWord {\n text: string;\n wordIndex: number;\n timing?: { startUs: number; endUs: number };\n}\n\nexport interface CaptionStyle {\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n fill: string;\n
|
|
1
|
+
{"version":3,"file":"caption-layout.js","sources":["../../../../src/stages/compose/text-utils/caption-layout.ts"],"sourcesContent":["import type { LocaleCode, ContainerStyle, GlobalPositionStyle } from '../font-system/types';\nimport { getFontConfig } from '../font-system/FontManager';\nimport { wrapText, formEvenLinesWithWords } from './text-wrapper';\nimport { getLetterCaseText } from './text-metrics';\nimport { needsSpaceBetweenWords } from './locale-detector';\n\n// ────── Input ──────\n\nexport interface CaptionLayoutInput {\n text: string;\n canvasWidth: number;\n canvasHeight: number;\n localeCode?: string;\n fontTemplate?: string;\n fontFamily?: string;\n /** When set, overrides the font template (same as compose `fontConfig.textStyle` merge). */\n fontSize?: number;\n fontWeight?: string | number;\n fill?: string;\n wordTimings?: Array<{ text: string; startUs: number; endUs: number }>;\n letterCase?: 'upper' | 'lower' | 'none';\n animation?: { type: string; [key: string]: unknown };\n}\n\n// ────── Output ──────\n\nexport interface CaptionLayout {\n lines: CaptionLine[];\n style: CaptionStyle;\n container: CaptionContainer;\n}\n\nexport interface CaptionLine {\n text: string;\n lineIndex: number;\n words: CaptionWord[];\n}\n\nexport interface CaptionWord {\n text: string;\n wordIndex: number;\n timing?: { startUs: number; endUs: number };\n}\n\nexport interface CaptionStyle {\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n fill: string;\n strokeColor?: string;\n strokeWidth?: number;\n lineHeight: number;\n letterSpacing?: string | number;\n paintOrder?: string;\n}\n\nexport interface CaptionContainer {\n maxWidth: number;\n maxWidthPercent: number;\n position: Pick<GlobalPositionStyle, 'top' | 'bottom' | 'alignItems' | 'justifyContent'>;\n backgroundColor?: string;\n padding?: string;\n borderRadius?: number;\n}\n\n// ────── Constants ──────\n\nconst DEFAULT_MAX_WIDTH_RATIO = 0.64;\nconst KTV_MAX_WIDTH_RATIO = 0.9;\nconst DEFAULT_FONT_TEMPLATE = 'baseSubtitle';\n\n// ────── Implementation ──────\n\nlet sharedCtx: OffscreenCanvasRenderingContext2D | null = null;\n\nfunction getSharedCtx(): OffscreenCanvasRenderingContext2D {\n if (!sharedCtx) {\n const canvas = new OffscreenCanvas(1, 1);\n sharedCtx = canvas.getContext('2d')!;\n }\n return sharedCtx;\n}\n\nfunction getMaxWidthRatio(animationType?: string): number {\n return animationType === 'characterKTV' ? KTV_MAX_WIDTH_RATIO : DEFAULT_MAX_WIDTH_RATIO;\n}\n\nfunction buildContainer(\n maxWidth: number,\n maxWidthPercent: number,\n globalPosition?: Partial<GlobalPositionStyle>,\n containerStyle?: Partial<ContainerStyle>\n): CaptionContainer {\n return {\n maxWidth,\n maxWidthPercent,\n position: {\n top: globalPosition?.top,\n bottom: globalPosition?.bottom,\n alignItems: globalPosition?.alignItems,\n justifyContent: globalPosition?.justifyContent,\n },\n backgroundColor: containerStyle?.backgroundColor,\n padding: containerStyle?.padding,\n borderRadius: containerStyle?.borderRadius,\n };\n}\n\n/**\n * Build CaptionLine[] with word-to-line mapping from lines produced by\n * formEvenLinesWithWords (wordTimings path).\n */\nfunction buildLinesWithWordMapping(\n lines: string[],\n needsSpace: boolean,\n wordTimings?: CaptionLayoutInput['wordTimings']\n): CaptionLine[] {\n let globalWordIndex = 0;\n\n return lines.map((lineText, lineIndex) => {\n const lineWords = lineText.split(needsSpace ? /\\s+/ : '').filter(Boolean);\n const words: CaptionWord[] = lineWords.map((wordText) => {\n const timing = wordTimings?.[globalWordIndex];\n const word: CaptionWord = {\n text: wordText,\n wordIndex: globalWordIndex,\n timing: timing ? { startUs: timing.startUs, endUs: timing.endUs } : undefined,\n };\n globalWordIndex++;\n return word;\n });\n\n return { text: lineText, lineIndex, words };\n });\n}\n\n/**\n * Build CaptionLine[] from lines produced by wrapText (no wordTimings).\n * Each line gets a single word entry covering the entire line text.\n */\nfunction buildLinesWithoutWordMapping(lines: string[]): CaptionLine[] {\n return lines.map((lineText, lineIndex) => ({\n text: lineText,\n lineIndex,\n words: [{ text: lineText, wordIndex: lineIndex }],\n }));\n}\n\nexport function computeCaptionLayout(input: CaptionLayoutInput): CaptionLayout {\n const {\n text: rawText,\n canvasWidth,\n localeCode: inputLocale,\n fontTemplate: inputTemplate,\n fontFamily: inputFontFamily,\n fontSize: inputFontSize,\n fontWeight: inputFontWeight,\n fill: inputFill,\n wordTimings,\n letterCase,\n animation,\n } = input;\n\n const locale = (inputLocale || 'en-US') as LocaleCode;\n const fontTemplate = inputTemplate || DEFAULT_FONT_TEMPLATE;\n const fontConfig = getFontConfig(locale, fontTemplate, inputFontFamily);\n let textStyle = { ...fontConfig.textStyle };\n if (inputFontSize != null) {\n textStyle.fontSize = inputFontSize;\n }\n if (inputFontWeight != null) {\n textStyle.fontWeight = inputFontWeight;\n }\n if (inputFill != null) {\n textStyle.fill = inputFill;\n }\n const { containerStyle, globalPosition } = fontConfig;\n\n const text = getLetterCaseText(rawText, letterCase);\n const hasWordTimings = wordTimings && wordTimings.length > 0;\n\n const ratio = getMaxWidthRatio(animation?.type);\n const maxWidth = canvasWidth * ratio;\n const maxWidthPercent = ratio * 100;\n\n const ctx = getSharedCtx();\n const { fontSize, fontFamily, fontWeight } = textStyle;\n\n let lines: string[];\n let captionLines: CaptionLine[];\n\n if (hasWordTimings) {\n const needsSpace = needsSpaceBetweenWords(locale, text);\n const words = text.split(needsSpace ? /\\s+/ : '');\n lines = formEvenLinesWithWords(\n ctx,\n words,\n maxWidth,\n fontSize,\n needsSpace,\n fontFamily,\n fontWeight\n );\n captionLines = buildLinesWithWordMapping(lines, needsSpace, wordTimings);\n } else {\n lines = wrapText(ctx, text, maxWidth, fontSize, fontFamily, fontWeight);\n captionLines = buildLinesWithoutWordMapping(lines);\n }\n\n const style: CaptionStyle = {\n fontSize,\n fontFamily,\n fontWeight,\n fill: textStyle.fill,\n strokeColor: textStyle.strokeColor,\n strokeWidth: textStyle.strokeWidth,\n lineHeight: textStyle.lineHeight || 1.2,\n letterSpacing: textStyle.letterSpacing,\n paintOrder: textStyle.paintOrder,\n };\n\n const container = buildContainer(maxWidth, maxWidthPercent, globalPosition, containerStyle);\n\n return { lines: captionLines, style, container };\n}\n"],"names":[],"mappings":";;;;AAmEA,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAI9B,IAAI,YAAsD;AAE1D,SAAS,eAAkD;AACzD,MAAI,CAAC,WAAW;AACd,UAAM,SAAS,IAAI,gBAAgB,GAAG,CAAC;AACvC,gBAAY,OAAO,WAAW,IAAI;AAAA,EACpC;AACA,SAAO;AACT;AAEA,SAAS,iBAAiB,eAAgC;AACxD,SAAO,kBAAkB,iBAAiB,sBAAsB;AAClE;AAEA,SAAS,eACP,UACA,iBACA,gBACA,gBACkB;AAClB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU;AAAA,MACR,KAAK,gBAAgB;AAAA,MACrB,QAAQ,gBAAgB;AAAA,MACxB,YAAY,gBAAgB;AAAA,MAC5B,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Aa;AAAA,EACzB;AACA,MAAI,aAAa,MAAM;AACrB,cAAU,OAAO;AAAA,EACnB;AACA,QAAM,EAAE,gBAAgB,eAAA,IAAmB;AAE3C,QAAM,OAAO,kBAAkB,SAAS,UAAU;AAClD,QAAM,iBAAiB,eAAe,YAAY,SAAS;AAE3D,QAAM,QAAQ,iBAAiB,WAAW,IAAI;AAC9C,QAAM,WAAW,cAAc;AAC/B,QAAM,kBAAkB,QAAQ;AAEhC,QAAM,MAAM,aAAA;AACZ,QAAM,EAAE,UAAU,YAAY,WAAA,IAAe;AAE7C,MAAI;AACJ,MAAI;AAEJ,MAAI,gBAAgB;AAClB,UAAM,aAAa,uBAAuB,QAAQ,IAAI;AACtD,UAAM,QAAQ,KAAK,MAAM,aAAa,QAAQ,EAAE;AAChD,YAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAEF,mBAAe,0BAA0B,OAAO,YAAY,WAAW;AAAA,EACzE,OAAO;AACL,YAAQ,SAAS,KAAK,MAAM,UAAU,UAAU,YAAY,UAAU;AACtE,mBAAe,6BAA6B,KAAK;AAAA,EACnD;AAEA,QAAM,QAAsB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,UAAU;AAAA,IAChB,aAAa,UAAU;AAAA,IACvB,aAAa,UAAU;AAAA,IACvB,YAAY,UAAU,cAAc;AAAA,IACpC,eAAe,UAAU;AAAA,IACzB,YAAY,UAAU;AAAA,EAAA;AAGxB,QAAM,YAAY,eAAe,UAAU,iBAAiB,gBAAgB,cAAc;AAE1F,SAAO,EAAE,OAAO,cAAc,OAAO,UAAA;AACvC;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GlobalPositionStyle } from '../font-system/types';
|
|
2
|
+
|
|
3
|
+
export type CaptionGlobalPosition = Pick<GlobalPositionStyle, 'position' | 'top' | 'bottom' | 'left' | 'right' | 'display' | 'alignItems' | 'justifyContent'>;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve vertical start Y (top edge of the text block) from globalPosition.
|
|
6
|
+
*
|
|
7
|
+
* - `top: 'N%'` — vertical center of the caption block at N% of canvas height
|
|
8
|
+
* (matches medeo-web CaptionCover preview `positionY` semantics).
|
|
9
|
+
* - `bottom: 'N%'` — bottom edge of the block sits N% above the canvas bottom.
|
|
10
|
+
*/
|
|
11
|
+
export declare function calculateCaptionStartY(canvasHeight: number, totalHeight: number, globalPosition?: Partial<CaptionGlobalPosition>): number;
|
|
12
|
+
//# sourceMappingURL=caption-position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caption-position.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-utils/caption-position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,mBAAmB,EACnB,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,gBAAgB,CAC/F,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAC9C,MAAM,CAoBR"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function calculateCaptionStartY(canvasHeight, totalHeight, globalPosition) {
|
|
2
|
+
if (!globalPosition) {
|
|
3
|
+
return canvasHeight / 2 - totalHeight / 2;
|
|
4
|
+
}
|
|
5
|
+
if (globalPosition.top) {
|
|
6
|
+
const centerPercent = parseFloat(globalPosition.top) / 100;
|
|
7
|
+
return canvasHeight * centerPercent - totalHeight / 2;
|
|
8
|
+
}
|
|
9
|
+
if (globalPosition.bottom) {
|
|
10
|
+
const bottomPercent = parseFloat(globalPosition.bottom) / 100;
|
|
11
|
+
return canvasHeight * (1 - bottomPercent) - totalHeight;
|
|
12
|
+
}
|
|
13
|
+
if (globalPosition.justifyContent === "center" || globalPosition.alignItems === "center") {
|
|
14
|
+
return canvasHeight / 2 - totalHeight / 2;
|
|
15
|
+
}
|
|
16
|
+
return canvasHeight / 2 - totalHeight / 2;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
calculateCaptionStartY
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=caption-position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caption-position.js","sources":["../../../../src/stages/compose/text-utils/caption-position.ts"],"sourcesContent":["import type { GlobalPositionStyle } from '../font-system/types';\n\nexport type CaptionGlobalPosition = Pick<\n GlobalPositionStyle,\n 'position' | 'top' | 'bottom' | 'left' | 'right' | 'display' | 'alignItems' | 'justifyContent'\n>;\n\n/**\n * Resolve vertical start Y (top edge of the text block) from globalPosition.\n *\n * - `top: 'N%'` — vertical center of the caption block at N% of canvas height\n * (matches medeo-web CaptionCover preview `positionY` semantics).\n * - `bottom: 'N%'` — bottom edge of the block sits N% above the canvas bottom.\n */\nexport function calculateCaptionStartY(\n canvasHeight: number,\n totalHeight: number,\n globalPosition?: Partial<CaptionGlobalPosition>\n): number {\n if (!globalPosition) {\n return canvasHeight / 2 - totalHeight / 2;\n }\n\n if (globalPosition.top) {\n const centerPercent = parseFloat(globalPosition.top) / 100;\n return canvasHeight * centerPercent - totalHeight / 2;\n }\n\n if (globalPosition.bottom) {\n const bottomPercent = parseFloat(globalPosition.bottom) / 100;\n return canvasHeight * (1 - bottomPercent) - totalHeight;\n }\n\n if (globalPosition.justifyContent === 'center' || globalPosition.alignItems === 'center') {\n return canvasHeight / 2 - totalHeight / 2;\n }\n\n return canvasHeight / 2 - totalHeight / 2;\n}\n"],"names":[],"mappings":"AAcO,SAAS,uBACd,cACA,aACA,gBACQ;AACR,MAAI,CAAC,gBAAgB;AACnB,WAAO,eAAe,IAAI,cAAc;AAAA,EAC1C;AAEA,MAAI,eAAe,KAAK;AACtB,UAAM,gBAAgB,WAAW,eAAe,GAAG,IAAI;AACvD,WAAO,eAAe,gBAAgB,cAAc;AAAA,EACtD;AAEA,MAAI,eAAe,QAAQ;AACzB,UAAM,gBAAgB,WAAW,eAAe,MAAM,IAAI;AAC1D,WAAO,gBAAgB,IAAI,iBAAiB;AAAA,EAC9C;AAEA,MAAI,eAAe,mBAAmB,YAAY,eAAe,eAAe,UAAU;AACxF,WAAO,eAAe,IAAI,cAAc;AAAA,EAC1C;AAEA,SAAO,eAAe,IAAI,cAAc;AAC1C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-layout-cache.js","sources":["../../../../src/stages/compose/text-utils/text-layout-cache.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { formEvenLinesWithWords, wrapText } from './text-wrapper';\n\nconst wrapTextCache = new Map<string, string[]>();\nconst evenLinesCache = new Map<string, string[]>();\n\nfunction cacheKey(parts: (string | number | boolean)[]): string {\n return parts.join('\\x1f');\n}\n\nexport function getCachedWrapText(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n text: string,\n maxWidth: number,\n fontSize: number,\n fontFamily: string,\n fontWeight: string | number = 400\n): string[] {\n const key = cacheKey([text, maxWidth, fontSize, fontFamily, fontWeight]);\n let lines = wrapTextCache.get(key);\n if (!lines) {\n lines = wrapText(ctx, text, maxWidth, fontSize, fontFamily, fontWeight);\n wrapTextCache.set(key, lines);\n }\n return lines;\n}\n\nexport function getCachedEvenLinesWithWords(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n words: string[],\n maxWidth: number,\n fontSize: number,\n needsSpace: boolean,\n fontFamily: string,\n fontWeight: string | number = 400\n): string[] {\n const key = cacheKey([\n words.join('\\x1e'),\n maxWidth,\n fontSize,\n needsSpace,\n fontFamily,\n fontWeight,\n ]);\n let lines = evenLinesCache.get(key);\n if (!lines) {\n lines = formEvenLinesWithWords(\n ctx,\n words,\n maxWidth,\n fontSize,\n needsSpace,\n fontFamily,\n fontWeight\n );\n evenLinesCache.set(key, lines);\n }\n return lines;\n}\n\nconst basicTextRasterCache = new Map<string, ImageBitmap>();\n\nfunction basicTextRasterKey(layer: TextLayer, canvasWidth: number, canvasHeight: number): string {\n const ts = layer.fontConfig?.textStyle;\n return [\n layer.id,\n layer.text,\n layer.letterCase ?? '',\n canvasWidth,\n canvasHeight,\n ts?.fontSize,\n ts?.fontFamily,\n ts?.fontWeight,\n ts?.fill,\n ts?.
|
|
1
|
+
{"version":3,"file":"text-layout-cache.js","sources":["../../../../src/stages/compose/text-utils/text-layout-cache.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { formEvenLinesWithWords, wrapText } from './text-wrapper';\n\nconst wrapTextCache = new Map<string, string[]>();\nconst evenLinesCache = new Map<string, string[]>();\n\nfunction cacheKey(parts: (string | number | boolean)[]): string {\n return parts.join('\\x1f');\n}\n\nexport function getCachedWrapText(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n text: string,\n maxWidth: number,\n fontSize: number,\n fontFamily: string,\n fontWeight: string | number = 400\n): string[] {\n const key = cacheKey([text, maxWidth, fontSize, fontFamily, fontWeight]);\n let lines = wrapTextCache.get(key);\n if (!lines) {\n lines = wrapText(ctx, text, maxWidth, fontSize, fontFamily, fontWeight);\n wrapTextCache.set(key, lines);\n }\n return lines;\n}\n\nexport function getCachedEvenLinesWithWords(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n words: string[],\n maxWidth: number,\n fontSize: number,\n needsSpace: boolean,\n fontFamily: string,\n fontWeight: string | number = 400\n): string[] {\n const key = cacheKey([\n words.join('\\x1e'),\n maxWidth,\n fontSize,\n needsSpace,\n fontFamily,\n fontWeight,\n ]);\n let lines = evenLinesCache.get(key);\n if (!lines) {\n lines = formEvenLinesWithWords(\n ctx,\n words,\n maxWidth,\n fontSize,\n needsSpace,\n fontFamily,\n fontWeight\n );\n evenLinesCache.set(key, lines);\n }\n return lines;\n}\n\nconst basicTextRasterCache = new Map<string, ImageBitmap>();\n\nfunction basicTextRasterKey(layer: TextLayer, canvasWidth: number, canvasHeight: number): string {\n const ts = layer.fontConfig?.textStyle;\n return [\n layer.id,\n layer.text,\n layer.letterCase ?? '',\n canvasWidth,\n canvasHeight,\n ts?.fontSize,\n ts?.fontFamily,\n ts?.fontWeight,\n ts?.fill,\n ts?.strokeColor,\n ts?.strokeWidth,\n ts?.lineHeight,\n JSON.stringify(layer.fontConfig?.globalPosition ?? null),\n ].join('\\x1f');\n}\n\nexport function getCachedBasicTextRaster(\n layer: TextLayer,\n canvasWidth: number,\n canvasHeight: number,\n draw: (ctx: OffscreenCanvasRenderingContext2D) => void\n): ImageBitmap | null {\n const key = basicTextRasterKey(layer, canvasWidth, canvasHeight);\n const cached = basicTextRasterCache.get(key);\n if (cached) {\n return cached;\n }\n\n const offscreen = new OffscreenCanvas(canvasWidth, canvasHeight);\n const offCtx = offscreen.getContext('2d');\n if (!offCtx) {\n return null;\n }\n\n draw(offCtx);\n const bitmap = offscreen.transferToImageBitmap();\n basicTextRasterCache.set(key, bitmap);\n return bitmap;\n}\n\nexport function clearTextLayoutCache(): void {\n wrapTextCache.clear();\n evenLinesCache.clear();\n for (const bitmap of basicTextRasterCache.values()) {\n bitmap.close();\n }\n basicTextRasterCache.clear();\n}\n"],"names":[],"mappings":";AAGA,MAAM,oCAAoB,IAAA;AAC1B,MAAM,qCAAqB,IAAA;AAE3B,SAAS,SAAS,OAA8C;AAC9D,SAAO,MAAM,KAAK,GAAM;AAC1B;AAEO,SAAS,kBACd,KACA,MACA,UACA,UACA,YACA,aAA8B,KACpB;AACV,QAAM,MAAM,SAAS,CAAC,MAAM,UAAU,UAAU,YAAY,UAAU,CAAC;AACvE,MAAI,QAAQ,cAAc,IAAI,GAAG;AACjC,MAAI,CAAC,OAAO;AACV,YAAQ,SAAS,KAAK,MAAM,UAAU,UAAU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BAAqB,IAAI,KAAK,MAAM;AACpC,SAAO;AACT;AAEO,SAAS,uBAA6B;AAC3C,gBAAc,MAAA;AACd,iBAAe,MAAA;AACf,aAAW,UAAU,qBAAqB,UAAU;AAClD,WAAO,MAAA;AAAA,EACT;AACA,uBAAqB,MAAA;AACvB;"}
|
|
@@ -187,7 +187,7 @@ export interface TextLayer extends Layer {
|
|
|
187
187
|
fontWeight: string | number;
|
|
188
188
|
fontFamily: string;
|
|
189
189
|
fill: string;
|
|
190
|
-
|
|
190
|
+
strokeColor?: string;
|
|
191
191
|
strokeWidth?: number;
|
|
192
192
|
letterSpacing?: string | number;
|
|
193
193
|
lineHeight?: number;
|
|
@@ -233,7 +233,7 @@ export interface TextAnimation {
|
|
|
233
233
|
highlightColor?: string;
|
|
234
234
|
highlightTextStyle?: {
|
|
235
235
|
fill?: string;
|
|
236
|
-
|
|
236
|
+
strokeColor?: string;
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
239
|
export interface VideoLayer extends Layer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/stages/compose/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CAC/C;AAED,KAAK,MAAM,GAAG,MAAM,CAAC;AAGrB,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM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CAAC;IAChB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC3C;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EACA,WAAW,GACX,SAAS,GACT,UAAU,GACV,aAAa,GACb,aAAa,GACb,iBAAiB,GACjB,OAAO,GACP,SAAS,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EACA,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,cAAc,GACd,cAAc,GACd,mBAAmB,GACnB,OAAO,GACP,UAAU,GACV,OAAO,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StreamTarget, ArrayBufferTarget, Muxer } from "../../
|
|
1
|
+
import { StreamTarget, ArrayBufferTarget, Muxer } from "../../meframe-service/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js";
|
|
2
2
|
import { checkBrowserCompatibility } from "../../utils/platform-utils.js";
|
|
3
3
|
class MP4Muxer {
|
|
4
4
|
muxer;
|
package/dist/utils/mp4box.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as mp4box_all from "../
|
|
1
|
+
import * as mp4box_all from "../meframe-service/node_modules/.pnpm/mp4box@0.5.4/node_modules/mp4box/dist/mp4box.all.js";
|
|
2
2
|
const lib = mp4box_all;
|
|
3
3
|
const MP4Box = lib.default && typeof lib.default.createFile === "function" ? lib.default : lib;
|
|
4
4
|
if (typeof MP4Box.createFile !== "function") {
|
|
@@ -11,7 +11,6 @@ if (typeof MP4Box.createFile !== "function") {
|
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
|
-
MP4Box
|
|
15
|
-
MP4Box as default
|
|
14
|
+
MP4Box
|
|
16
15
|
};
|
|
17
16
|
//# sourceMappingURL=mp4box.js.map
|