@meframe/core 0.5.28 → 0.5.31
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/orchestrator/Orchestrator.d.ts.map +1 -1
- package/dist/orchestrator/Orchestrator.js +7 -2
- package/dist/orchestrator/Orchestrator.js.map +1 -1
- package/dist/stages/compose/text-layer-animation-time.d.ts +5 -0
- package/dist/stages/compose/text-layer-animation-time.d.ts.map +1 -1
- package/dist/stages/compose/text-layer-animation-time.js +10 -0
- package/dist/stages/compose/text-layer-animation-time.js.map +1 -1
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.d.ts +10 -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 +25 -10
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.js.map +1 -1
- package/dist/stages/compose/types.d.ts +5 -0
- package/dist/stages/compose/types.d.ts.map +1 -1
- package/dist/workers/stages/export/{export.worker.CO7nW1W0.js → export.worker.BepPfuIx.js} +36 -11
- package/dist/workers/stages/export/export.worker.BepPfuIx.js.map +1 -0
- package/dist/workers/worker-manifest.json +1 -1
- package/package.json +1 -1
- package/dist/workers/stages/export/export.worker.CO7nW1W0.js.map +0 -1
|
@@ -517,6 +517,15 @@ function attachmentEntranceRelativeTimeUs(clipRelativeTimeUs, activeRanges) {
|
|
|
517
517
|
}
|
|
518
518
|
return Math.max(0, clipRelativeTimeUs - containing.startUs);
|
|
519
519
|
}
|
|
520
|
+
function attachmentActiveDurationUs(clipRelativeTimeUs, activeRanges) {
|
|
521
|
+
const containing = activeRanges?.find(
|
|
522
|
+
(r) => clipRelativeTimeUs >= r.startUs && clipRelativeTimeUs < r.endUs
|
|
523
|
+
);
|
|
524
|
+
if (!containing) {
|
|
525
|
+
return void 0;
|
|
526
|
+
}
|
|
527
|
+
return Math.max(0, containing.endUs - containing.startUs);
|
|
528
|
+
}
|
|
520
529
|
function textAnimationFrameForTextLayer(layer, fallbackFrame, fps) {
|
|
521
530
|
const et = layer.entranceRelativeTimeUs;
|
|
522
531
|
if (et != null && Number.isFinite(et)) {
|
|
@@ -944,6 +953,14 @@ function renderBasicText(ctx, layer, canvasWidth, canvasHeight, _relativeFrame)
|
|
|
944
953
|
}
|
|
945
954
|
const DEFAULT_DURATION_MS = 800;
|
|
946
955
|
const DEFAULT_STAGGER_MS = 50;
|
|
956
|
+
const CAPTION_STATIC_TAIL_MS = 500;
|
|
957
|
+
function computeStaggerScale(rawEndMs, captionDurationMs) {
|
|
958
|
+
if (captionDurationMs == null || !Number.isFinite(captionDurationMs)) return 1;
|
|
959
|
+
if (rawEndMs <= 0) return 1;
|
|
960
|
+
const budget = Math.max(0, captionDurationMs - CAPTION_STATIC_TAIL_MS);
|
|
961
|
+
if (rawEndMs <= budget) return 1;
|
|
962
|
+
return budget / rawEndMs;
|
|
963
|
+
}
|
|
947
964
|
const SLIDE_BASE_PX = 50;
|
|
948
965
|
const LETTER_SPREAD_BASE_PX = 20;
|
|
949
966
|
const BLUR_START_PX = 10;
|
|
@@ -983,7 +1000,7 @@ function layoutCacheKey(layer, canvasWidth, canvasHeight) {
|
|
|
983
1000
|
function staggerRasterKey(layer, canvasWidth, canvasHeight, preset) {
|
|
984
1001
|
return `${layoutCacheKey(layer, canvasWidth, canvasHeight)}${preset}`;
|
|
985
1002
|
}
|
|
986
|
-
function
|
|
1003
|
+
function staggerEntranceRawEndMs(slotCount, preset) {
|
|
987
1004
|
if (slotCount <= 0) return 0;
|
|
988
1005
|
const lastIndex = slotCount - 1;
|
|
989
1006
|
if (preset === "typewriter") {
|
|
@@ -1058,7 +1075,7 @@ function getCachedCharSlots(ctx, layer, canvasWidth, canvasHeight) {
|
|
|
1058
1075
|
}
|
|
1059
1076
|
return built;
|
|
1060
1077
|
}
|
|
1061
|
-
function drawStaggerEntranceFrame(ctx, layer, built, relativeFrame, fps, preset) {
|
|
1078
|
+
function drawStaggerEntranceFrame(ctx, layer, built, relativeFrame, fps, preset, scale, forceComplete = false) {
|
|
1062
1079
|
const { slots, fontSize } = built;
|
|
1063
1080
|
const fontConfig = layer.fontConfig.textStyle;
|
|
1064
1081
|
const fontFamily = fontConfig.fontFamily;
|
|
@@ -1067,7 +1084,8 @@ function drawStaggerEntranceFrame(ctx, layer, built, relativeFrame, fps, preset)
|
|
|
1067
1084
|
const strokeColor = fontConfig.strokeColor;
|
|
1068
1085
|
const strokeWidth = fontConfig.strokeWidth || 0;
|
|
1069
1086
|
const scalePx = fontSize / FONT_REF_PX;
|
|
1070
|
-
const staggerMs = DEFAULT_STAGGER_MS;
|
|
1087
|
+
const staggerMs = DEFAULT_STAGGER_MS * scale;
|
|
1088
|
+
const charDurationMs = DEFAULT_DURATION_MS * scale;
|
|
1071
1089
|
ctx.save();
|
|
1072
1090
|
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
1073
1091
|
ctx.textAlign = "center";
|
|
@@ -1077,11 +1095,13 @@ function drawStaggerEntranceFrame(ctx, layer, built, relativeFrame, fps, preset)
|
|
|
1077
1095
|
const tMsGlobal = relativeFrame / fps * 1e3;
|
|
1078
1096
|
for (const slot of slots) {
|
|
1079
1097
|
let p;
|
|
1080
|
-
if (
|
|
1098
|
+
if (forceComplete) {
|
|
1099
|
+
p = 1;
|
|
1100
|
+
} else if (preset === "typewriter") {
|
|
1081
1101
|
const startMs = slot.globalIndex * staggerMs;
|
|
1082
1102
|
p = tMsGlobal >= startMs ? 1 : 0;
|
|
1083
1103
|
} else {
|
|
1084
|
-
p = charProgress(relativeFrame, fps, slot.globalIndex, staggerMs,
|
|
1104
|
+
p = charProgress(relativeFrame, fps, slot.globalIndex, staggerMs, charDurationMs);
|
|
1085
1105
|
}
|
|
1086
1106
|
if (p <= 0 && preset !== "blur") continue;
|
|
1087
1107
|
const slidePx = SLIDE_BASE_PX * scalePx;
|
|
@@ -1160,7 +1180,10 @@ function clearCaptionStaggerCache() {
|
|
|
1160
1180
|
function renderCaptionStaggerEntrance(ctx, layer, canvasWidth, canvasHeight, relativeFrame, fps, preset) {
|
|
1161
1181
|
const built = getCachedCharSlots(ctx, layer, canvasWidth, canvasHeight);
|
|
1162
1182
|
if (!built) return;
|
|
1163
|
-
const
|
|
1183
|
+
const captionDurationMs = layer.activeDurationUs != null ? layer.activeDurationUs / 1e3 : void 0;
|
|
1184
|
+
const rawEndMs = staggerEntranceRawEndMs(built.slots.length, preset);
|
|
1185
|
+
const scale = computeStaggerScale(rawEndMs, captionDurationMs);
|
|
1186
|
+
const endMs = rawEndMs * scale;
|
|
1164
1187
|
const endFrame = Math.ceil(endMs / 1e3 * fps);
|
|
1165
1188
|
if (relativeFrame >= endFrame) {
|
|
1166
1189
|
const rasterKey = staggerRasterKey(layer, canvasWidth, canvasHeight, preset);
|
|
@@ -1169,17 +1192,17 @@ function renderCaptionStaggerEntrance(ctx, layer, canvasWidth, canvasHeight, rel
|
|
|
1169
1192
|
const offscreen = new OffscreenCanvas(canvasWidth, canvasHeight);
|
|
1170
1193
|
const offCtx = offscreen.getContext("2d");
|
|
1171
1194
|
if (!offCtx) {
|
|
1172
|
-
drawStaggerEntranceFrame(ctx, layer, built, endFrame, fps, preset);
|
|
1195
|
+
drawStaggerEntranceFrame(ctx, layer, built, endFrame, fps, preset, scale, true);
|
|
1173
1196
|
return;
|
|
1174
1197
|
}
|
|
1175
|
-
drawStaggerEntranceFrame(offCtx, layer, built, endFrame, fps, preset);
|
|
1198
|
+
drawStaggerEntranceFrame(offCtx, layer, built, endFrame, fps, preset, scale, true);
|
|
1176
1199
|
bitmap = offscreen.transferToImageBitmap();
|
|
1177
1200
|
staggerFinalRasterCache.set(rasterKey, bitmap);
|
|
1178
1201
|
}
|
|
1179
1202
|
ctx.drawImage(bitmap, 0, 0);
|
|
1180
1203
|
return;
|
|
1181
1204
|
}
|
|
1182
|
-
drawStaggerEntranceFrame(ctx, layer, built, relativeFrame, fps, preset);
|
|
1205
|
+
drawStaggerEntranceFrame(ctx, layer, built, relativeFrame, fps, preset, scale);
|
|
1183
1206
|
}
|
|
1184
1207
|
function usToFrame$2(us, fps) {
|
|
1185
1208
|
return Math.floor(us / (1e6 / fps));
|
|
@@ -3229,6 +3252,7 @@ function materializeLayer(layer, frame, imageMap, globalTimeUs, clipRelativeTime
|
|
|
3229
3252
|
if (layer.type === "text") {
|
|
3230
3253
|
const payload = layer.payload;
|
|
3231
3254
|
const entranceRelativeTimeUs = clipRelativeTimeUs != null ? attachmentEntranceRelativeTimeUs(clipRelativeTimeUs, layer.activeRanges) : void 0;
|
|
3255
|
+
const activeDurationUs = clipRelativeTimeUs != null ? attachmentActiveDurationUs(clipRelativeTimeUs, layer.activeRanges) : void 0;
|
|
3232
3256
|
return {
|
|
3233
3257
|
...baseLayer,
|
|
3234
3258
|
type: "text",
|
|
@@ -3238,7 +3262,8 @@ function materializeLayer(layer, frame, imageMap, globalTimeUs, clipRelativeTime
|
|
|
3238
3262
|
animation: payload.animation,
|
|
3239
3263
|
wordTimings: payload.wordTimings,
|
|
3240
3264
|
letterCase: payload.letterCase,
|
|
3241
|
-
entranceRelativeTimeUs
|
|
3265
|
+
entranceRelativeTimeUs,
|
|
3266
|
+
activeDurationUs
|
|
3242
3267
|
};
|
|
3243
3268
|
}
|
|
3244
3269
|
if (layer.type === "image") {
|
|
@@ -3556,4 +3581,4 @@ const export_worker = null;
|
|
|
3556
3581
|
export {
|
|
3557
3582
|
export_worker as default
|
|
3558
3583
|
};
|
|
3559
|
-
//# sourceMappingURL=export.worker.
|
|
3584
|
+
//# sourceMappingURL=export.worker.BepPfuIx.js.map
|