@meframe/core 0.6.13 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +17 -5
- package/dist/Meframe.d.ts +14 -3
- package/dist/Meframe.d.ts.map +1 -1
- package/dist/Meframe.js +22 -12
- package/dist/Meframe.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +2 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +5 -0
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/l1/VideoL1Cache.d.ts +2 -0
- package/dist/cache/l1/VideoL1Cache.d.ts.map +1 -1
- package/dist/cache/l1/VideoL1Cache.js +13 -7
- package/dist/cache/l1/VideoL1Cache.js.map +1 -1
- package/dist/cache/resource/ResourceCache.d.ts +0 -12
- package/dist/cache/resource/ResourceCache.d.ts.map +1 -1
- package/dist/cache/resource/ResourceCache.js +0 -24
- package/dist/cache/resource/ResourceCache.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +4 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/types.d.ts +29 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/validation.d.ts.map +1 -1
- package/dist/config/validation.js +3 -0
- package/dist/config/validation.js.map +1 -1
- package/dist/controllers/PlaybackController.d.ts +38 -9
- package/dist/controllers/PlaybackController.d.ts.map +1 -1
- package/dist/controllers/PlaybackController.js +269 -154
- package/dist/controllers/PlaybackController.js.map +1 -1
- package/dist/controllers/PlaybackStateMachine.d.ts.map +1 -1
- package/dist/controllers/PlaybackStateMachine.js +2 -1
- package/dist/controllers/PlaybackStateMachine.js.map +1 -1
- package/dist/controllers/types.d.ts +10 -2
- package/dist/controllers/types.d.ts.map +1 -1
- package/dist/controllers/types.js.map +1 -1
- package/dist/event/events.d.ts +2 -0
- package/dist/event/events.d.ts.map +1 -1
- package/dist/event/events.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/CompositionModel.d.ts +0 -1
- package/dist/model/CompositionModel.d.ts.map +1 -1
- package/dist/model/CompositionModel.js +0 -6
- package/dist/model/CompositionModel.js.map +1 -1
- package/dist/model/patch.js +12 -12
- package/dist/model/patch.js.map +1 -1
- package/dist/node_modules/.pnpm/{mp4-muxer@5.2.2 → mp4-muxer@5.2.2_patch_hash_452653ac44da4ef32d244694e500e34d084eaa3c4232515ddec962eacc5f30ea}/node_modules/mp4-muxer/build/mp4-muxer.js +17 -3
- package/dist/node_modules/.pnpm/mp4-muxer@5.2.2_patch_hash_452653ac44da4ef32d244694e500e34d084eaa3c4232515ddec962eacc5f30ea/node_modules/mp4-muxer/build/mp4-muxer.js.map +1 -0
- package/dist/orchestrator/AudioExportSession.d.ts +28 -3
- package/dist/orchestrator/AudioExportSession.d.ts.map +1 -1
- package/dist/orchestrator/AudioExportSession.js +131 -15
- package/dist/orchestrator/AudioExportSession.js.map +1 -1
- package/dist/orchestrator/AudioPreviewSession.d.ts +6 -1
- package/dist/orchestrator/AudioPreviewSession.d.ts.map +1 -1
- package/dist/orchestrator/AudioPreviewSession.js +57 -18
- package/dist/orchestrator/AudioPreviewSession.js.map +1 -1
- package/dist/orchestrator/AudioWindowPreparer.d.ts +5 -4
- package/dist/orchestrator/AudioWindowPreparer.d.ts.map +1 -1
- package/dist/orchestrator/AudioWindowPreparer.js +76 -28
- package/dist/orchestrator/AudioWindowPreparer.js.map +1 -1
- package/dist/orchestrator/CompositionPlanner.d.ts +5 -2
- package/dist/orchestrator/CompositionPlanner.d.ts.map +1 -1
- package/dist/orchestrator/CompositionPlanner.js +8 -3
- package/dist/orchestrator/CompositionPlanner.js.map +1 -1
- package/dist/orchestrator/ExportScheduler.d.ts +1 -0
- package/dist/orchestrator/ExportScheduler.d.ts.map +1 -1
- package/dist/orchestrator/ExportScheduler.js +177 -106
- package/dist/orchestrator/ExportScheduler.js.map +1 -1
- package/dist/orchestrator/Orchestrator.d.ts +30 -4
- package/dist/orchestrator/Orchestrator.d.ts.map +1 -1
- package/dist/orchestrator/Orchestrator.js +264 -111
- package/dist/orchestrator/Orchestrator.js.map +1 -1
- package/dist/orchestrator/PreviewFrameScheduler.d.ts +21 -1
- package/dist/orchestrator/PreviewFrameScheduler.d.ts.map +1 -1
- package/dist/orchestrator/PreviewFrameScheduler.js +129 -30
- package/dist/orchestrator/PreviewFrameScheduler.js.map +1 -1
- package/dist/orchestrator/VideoWindowDecodeSession.d.ts +22 -1
- package/dist/orchestrator/VideoWindowDecodeSession.d.ts.map +1 -1
- package/dist/orchestrator/VideoWindowDecodeSession.js +426 -198
- package/dist/orchestrator/VideoWindowDecodeSession.js.map +1 -1
- package/dist/orchestrator/aac-window-timeline.d.ts +1 -1
- package/dist/orchestrator/aac-window-timeline.d.ts.map +1 -1
- package/dist/orchestrator/aac-window-timeline.js +10 -2
- package/dist/orchestrator/aac-window-timeline.js.map +1 -1
- package/dist/orchestrator/types.d.ts +5 -1
- package/dist/orchestrator/types.d.ts.map +1 -1
- package/dist/stages/compose/FrameRateConverter.d.ts +2 -1
- package/dist/stages/compose/FrameRateConverter.d.ts.map +1 -1
- package/dist/stages/compose/LayerRenderPolicy.d.ts +14 -0
- package/dist/stages/compose/LayerRenderPolicy.d.ts.map +1 -0
- package/dist/stages/compose/LayerRenderPolicy.js +18 -0
- package/dist/stages/compose/LayerRenderPolicy.js.map +1 -0
- package/dist/stages/compose/OfflineAudioMixer.d.ts +2 -0
- package/dist/stages/compose/OfflineAudioMixer.d.ts.map +1 -1
- package/dist/stages/compose/OfflineAudioMixer.js +14 -2
- package/dist/stages/compose/OfflineAudioMixer.js.map +1 -1
- package/dist/stages/compose/OwnedFrameTransform.d.ts +52 -0
- package/dist/stages/compose/OwnedFrameTransform.d.ts.map +1 -0
- package/dist/stages/compose/OwnedFrameTransform.js +154 -0
- package/dist/stages/compose/OwnedFrameTransform.js.map +1 -0
- package/dist/stages/compose/TransitionProcessor.js +0 -1
- package/dist/stages/compose/TransitionProcessor.js.map +1 -1
- package/dist/stages/compose/VideoComposer.d.ts +12 -2
- package/dist/stages/compose/VideoComposer.d.ts.map +1 -1
- package/dist/stages/compose/VideoComposer.js +100 -92
- package/dist/stages/compose/VideoComposer.js.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 +24 -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 +110 -99
- 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 +41 -38
- 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 +47 -39
- 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 +54 -48
- package/dist/stages/compose/text-renderers/word-fancy-renderer.js.map +1 -1
- package/dist/stages/compose/text-utils/text-metrics.d.ts.map +1 -1
- package/dist/stages/compose/text-utils/text-metrics.js +6 -4
- package/dist/stages/compose/text-utils/text-metrics.js.map +1 -1
- package/dist/stages/compose/types.d.ts +12 -0
- package/dist/stages/compose/types.d.ts.map +1 -1
- package/dist/stages/decode/BaseDecoder.d.ts +5 -0
- package/dist/stages/decode/BaseDecoder.d.ts.map +1 -1
- package/dist/stages/decode/BaseDecoder.js +52 -10
- package/dist/stages/decode/BaseDecoder.js.map +1 -1
- package/dist/stages/decode/preview-video-decoder.d.ts +48 -2
- package/dist/stages/decode/preview-video-decoder.d.ts.map +1 -1
- package/dist/stages/decode/preview-video-decoder.js +241 -71
- package/dist/stages/decode/preview-video-decoder.js.map +1 -1
- package/dist/stages/decode/video-decoder.d.ts +2 -11
- package/dist/stages/decode/video-decoder.d.ts.map +1 -1
- package/dist/stages/decode/video-decoder.js +60 -61
- package/dist/stages/decode/video-decoder.js.map +1 -1
- package/dist/stages/encode/BaseEncoder.d.ts +9 -2
- package/dist/stages/encode/BaseEncoder.d.ts.map +1 -1
- package/dist/stages/encode/BaseEncoder.js +90 -59
- package/dist/stages/encode/BaseEncoder.js.map +1 -1
- package/dist/stages/load/ResourceLoader.d.ts +69 -8
- package/dist/stages/load/ResourceLoader.d.ts.map +1 -1
- package/dist/stages/load/ResourceLoader.js +248 -67
- package/dist/stages/load/ResourceLoader.js.map +1 -1
- package/dist/stages/load/TaskManager.d.ts.map +1 -1
- package/dist/stages/load/TaskManager.js +9 -3
- package/dist/stages/load/TaskManager.js.map +1 -1
- package/dist/stages/load/types.d.ts +2 -2
- package/dist/stages/load/types.d.ts.map +1 -1
- package/dist/stages/mux/MP4Muxer.d.ts +7 -1
- package/dist/stages/mux/MP4Muxer.d.ts.map +1 -1
- package/dist/stages/mux/MP4Muxer.js +8 -10
- package/dist/stages/mux/MP4Muxer.js.map +1 -1
- package/dist/stages/mux/MuxManager.d.ts +7 -0
- package/dist/stages/mux/MuxManager.d.ts.map +1 -1
- package/dist/stages/mux/MuxManager.js +9 -0
- package/dist/stages/mux/MuxManager.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +10 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/until-aborted.d.ts +8 -0
- package/dist/utils/until-aborted.d.ts.map +1 -0
- package/dist/utils/until-aborted.js +33 -0
- package/dist/utils/until-aborted.js.map +1 -0
- package/dist/worker/WorkerChannel.d.ts.map +1 -1
- package/dist/worker/WorkerChannel.js +45 -10
- package/dist/worker/WorkerChannel.js.map +1 -1
- package/dist/worker/worker-manifest.js +1 -1
- package/dist/worker/worker-manifest.js.map +1 -1
- package/dist/workers/stages/export/{export.worker.C8jKSbVj.js → export.worker.BG8HA7dY.js} +745 -450
- package/dist/workers/stages/export/export.worker.BG8HA7dY.js.map +1 -0
- package/dist/workers/worker-manifest.json +1 -1
- package/package.json +1 -1
- package/dist/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js.map +0 -1
- package/dist/workers/stages/export/export.worker.C8jKSbVj.js.map +0 -1
|
@@ -70,49 +70,52 @@ function renderCharacterKTV(ctx, layer, canvasWidth, canvasHeight, relativeFrame
|
|
|
70
70
|
const fullText = characterTimings.map((ct) => ct.char).join("");
|
|
71
71
|
const fullTextLines = wrapText(ctx, fullText, maxWidth, fontSize, fontFamily, fontWeight);
|
|
72
72
|
ctx.save();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
73
|
+
try {
|
|
74
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
75
|
+
ctx.textAlign = "left";
|
|
76
|
+
ctx.textBaseline = "middle";
|
|
77
|
+
ctx.lineJoin = "round";
|
|
78
|
+
ctx.lineCap = "round";
|
|
79
|
+
const totalHeight = fullTextLines.length * fontSize * lineHeight;
|
|
80
|
+
const startY = calculateCaptionStartY(
|
|
81
|
+
canvasHeight,
|
|
82
|
+
totalHeight,
|
|
83
|
+
layer.fontConfig?.globalPosition
|
|
84
|
+
);
|
|
85
|
+
let charIndexInText = 0;
|
|
86
|
+
for (let lineIndex = 0; lineIndex < fullTextLines.length; lineIndex++) {
|
|
87
|
+
const line = fullTextLines[lineIndex];
|
|
88
|
+
const y = startY + lineIndex * fontSize * lineHeight + fontSize / 2;
|
|
89
|
+
const lineWidth = measureTextWidth(ctx, line, fontSize, fontFamily, fontWeight);
|
|
90
|
+
let currentX = canvasWidth / 2 - lineWidth / 2;
|
|
91
|
+
for (let i = 0; i < line.length; i++) {
|
|
92
|
+
const char = line[i];
|
|
93
|
+
const timing = characterTimings[charIndexInText];
|
|
94
|
+
if (timing) {
|
|
95
|
+
const hasScanned = relativeFrame >= timing.startFrame;
|
|
96
|
+
const isCurrentlySinging = hasScanned && relativeFrame < timing.startFrame + transitionFrames;
|
|
97
|
+
ctx.fillStyle = hasScanned ? highlightFill : baseFill;
|
|
98
|
+
if (isCurrentlySinging) {
|
|
99
|
+
ctx.shadowColor = glowColor;
|
|
100
|
+
ctx.shadowBlur = glowIntensity * 10;
|
|
101
|
+
} else {
|
|
102
|
+
ctx.shadowBlur = 0;
|
|
103
|
+
}
|
|
104
|
+
if (strokeColor && strokeWidth > 0) {
|
|
105
|
+
ctx.strokeStyle = strokeColor;
|
|
106
|
+
ctx.lineWidth = strokeWidth;
|
|
107
|
+
ctx.strokeText(char, currentX, y);
|
|
108
|
+
}
|
|
109
|
+
ctx.fillText(char, currentX, y);
|
|
101
110
|
ctx.shadowBlur = 0;
|
|
102
111
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
ctx.lineWidth = strokeWidth;
|
|
106
|
-
ctx.strokeText(char, currentX, y);
|
|
107
|
-
}
|
|
108
|
-
ctx.fillText(char, currentX, y);
|
|
109
|
-
ctx.shadowBlur = 0;
|
|
112
|
+
currentX += measureTextWidth(ctx, char, fontSize, fontFamily, fontWeight);
|
|
113
|
+
charIndexInText++;
|
|
110
114
|
}
|
|
111
|
-
currentX += measureTextWidth(ctx, char, fontSize, fontFamily, fontWeight);
|
|
112
|
-
charIndexInText++;
|
|
113
115
|
}
|
|
116
|
+
} finally {
|
|
117
|
+
ctx.restore();
|
|
114
118
|
}
|
|
115
|
-
ctx.restore();
|
|
116
119
|
}
|
|
117
120
|
export {
|
|
118
121
|
renderCharacterKTV
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character-ktv-renderer.js","sources":["../../../../src/stages/compose/text-renderers/character-ktv-renderer.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { wrapText } from '../text-utils/text-wrapper';\nimport { getLetterCaseText, measureTextWidth } from '../text-utils/text-metrics';\nimport { needsSpaceBetweenWords } from '../text-utils/locale-detector';\nimport { calculateCaptionStartY } from '../text-utils/caption-position';\n\ninterface CharacterTiming {\n char: string;\n index: number;\n startFrame: number;\n}\n\nfunction usToFrame(us: number, fps: number): number {\n return Math.floor(us / (1000000 / fps));\n}\n\nexport function renderCharacterKTV(\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 baseFill = 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 glowColor = layer.animation?.glowColor || '#ffffff';\n const glowIntensity = layer.animation?.glowIntensity || 3;\n const transitionFrames = layer.animation?.transitionFrames || 10;\n\n const maxWidth = canvasWidth * 0.9;\n const text = getLetterCaseText(layer.text, layer.letterCase);\n const needsSpace = needsSpaceBetweenWords(layer.localeCode || 'en-US', text);\n const characterTimings: CharacterTiming[] = [];\n\n if (layer.wordTimings && layer.wordTimings.length > 0) {\n let charIndex = 0;\n\n for (let wordIndex = 0; wordIndex < layer.wordTimings.length; wordIndex++) {\n const word = layer.wordTimings[wordIndex]!;\n const wordChars = word.text.split('');\n const wordStartFrame = usToFrame(word.startUs, fps);\n const wordEndFrame = usToFrame(word.endUs, fps);\n const framesPerChar =\n wordChars.length > 0 ? (wordEndFrame - wordStartFrame) / wordChars.length : 0;\n\n for (let i = 0; i < wordChars.length; i++) {\n const charStartFrame = Math.floor(wordStartFrame + i * framesPerChar);\n characterTimings.push({\n char: wordChars[i]!,\n index: charIndex,\n startFrame: charStartFrame,\n });\n charIndex++;\n }\n\n if (needsSpace && wordIndex < layer.wordTimings.length - 1) {\n const nextWord = layer.wordTimings[wordIndex + 1];\n const nextWordFirstChar = nextWord?.text?.[0] || '';\n const isPunctuation = /[.,!?;:)]/.test(nextWordFirstChar);\n\n if (!isPunctuation) {\n const spaceStartFrame = characterTimings[characterTimings.length - 1]?.startFrame || 0;\n characterTimings.push({\n char: ' ',\n index: charIndex,\n startFrame: spaceStartFrame,\n });\n charIndex++;\n }\n }\n }\n } else {\n const totalFrames = 100;\n const chars = text.split('');\n const framesPerChar = chars.length > 0 ? totalFrames / chars.length : 0;\n\n for (let i = 0; i < chars.length; i++) {\n characterTimings.push({\n char: chars[i]!,\n index: i,\n startFrame: Math.floor(i * framesPerChar),\n });\n }\n }\n\n const fullText = characterTimings.map((ct) => ct.char).join('');\n const fullTextLines = wrapText(ctx, fullText, maxWidth, fontSize, fontFamily, fontWeight);\n\n ctx.save();\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n
|
|
1
|
+
{"version":3,"file":"character-ktv-renderer.js","sources":["../../../../src/stages/compose/text-renderers/character-ktv-renderer.ts"],"sourcesContent":["import type { TextLayer } from '../types';\nimport { wrapText } from '../text-utils/text-wrapper';\nimport { getLetterCaseText, measureTextWidth } from '../text-utils/text-metrics';\nimport { needsSpaceBetweenWords } from '../text-utils/locale-detector';\nimport { calculateCaptionStartY } from '../text-utils/caption-position';\n\ninterface CharacterTiming {\n char: string;\n index: number;\n startFrame: number;\n}\n\nfunction usToFrame(us: number, fps: number): number {\n return Math.floor(us / (1000000 / fps));\n}\n\nexport function renderCharacterKTV(\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 baseFill = 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 glowColor = layer.animation?.glowColor || '#ffffff';\n const glowIntensity = layer.animation?.glowIntensity || 3;\n const transitionFrames = layer.animation?.transitionFrames || 10;\n\n const maxWidth = canvasWidth * 0.9;\n const text = getLetterCaseText(layer.text, layer.letterCase);\n const needsSpace = needsSpaceBetweenWords(layer.localeCode || 'en-US', text);\n const characterTimings: CharacterTiming[] = [];\n\n if (layer.wordTimings && layer.wordTimings.length > 0) {\n let charIndex = 0;\n\n for (let wordIndex = 0; wordIndex < layer.wordTimings.length; wordIndex++) {\n const word = layer.wordTimings[wordIndex]!;\n const wordChars = word.text.split('');\n const wordStartFrame = usToFrame(word.startUs, fps);\n const wordEndFrame = usToFrame(word.endUs, fps);\n const framesPerChar =\n wordChars.length > 0 ? (wordEndFrame - wordStartFrame) / wordChars.length : 0;\n\n for (let i = 0; i < wordChars.length; i++) {\n const charStartFrame = Math.floor(wordStartFrame + i * framesPerChar);\n characterTimings.push({\n char: wordChars[i]!,\n index: charIndex,\n startFrame: charStartFrame,\n });\n charIndex++;\n }\n\n if (needsSpace && wordIndex < layer.wordTimings.length - 1) {\n const nextWord = layer.wordTimings[wordIndex + 1];\n const nextWordFirstChar = nextWord?.text?.[0] || '';\n const isPunctuation = /[.,!?;:)]/.test(nextWordFirstChar);\n\n if (!isPunctuation) {\n const spaceStartFrame = characterTimings[characterTimings.length - 1]?.startFrame || 0;\n characterTimings.push({\n char: ' ',\n index: charIndex,\n startFrame: spaceStartFrame,\n });\n charIndex++;\n }\n }\n }\n } else {\n const totalFrames = 100;\n const chars = text.split('');\n const framesPerChar = chars.length > 0 ? totalFrames / chars.length : 0;\n\n for (let i = 0; i < chars.length; i++) {\n characterTimings.push({\n char: chars[i]!,\n index: i,\n startFrame: Math.floor(i * framesPerChar),\n });\n }\n }\n\n const fullText = characterTimings.map((ct) => ct.char).join('');\n const fullTextLines = wrapText(ctx, fullText, maxWidth, fontSize, fontFamily, fontWeight);\n\n ctx.save();\n try {\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n ctx.lineJoin = 'round';\n ctx.lineCap = 'round';\n\n const totalHeight = fullTextLines.length * fontSize * lineHeight;\n const startY = calculateCaptionStartY(\n canvasHeight,\n totalHeight,\n layer.fontConfig?.globalPosition\n );\n\n let charIndexInText = 0;\n\n for (let lineIndex = 0; lineIndex < fullTextLines.length; lineIndex++) {\n const line = fullTextLines[lineIndex]!;\n const y = startY + lineIndex * fontSize * lineHeight + fontSize / 2;\n const lineWidth = measureTextWidth(ctx, line, fontSize, fontFamily, fontWeight);\n let currentX = canvasWidth / 2 - lineWidth / 2;\n\n for (let i = 0; i < line.length; i++) {\n const char = line[i]!;\n const timing = characterTimings[charIndexInText];\n\n if (timing) {\n const hasScanned = relativeFrame >= timing.startFrame;\n const isCurrentlySinging =\n hasScanned && relativeFrame < timing.startFrame + transitionFrames;\n\n ctx.fillStyle = hasScanned ? highlightFill : baseFill;\n\n if (isCurrentlySinging) {\n ctx.shadowColor = glowColor;\n ctx.shadowBlur = glowIntensity * 10;\n } else {\n ctx.shadowBlur = 0;\n }\n\n if (strokeColor && strokeWidth > 0) {\n ctx.strokeStyle = strokeColor;\n ctx.lineWidth = strokeWidth;\n ctx.strokeText(char, currentX, y);\n }\n ctx.fillText(char, currentX, y);\n ctx.shadowBlur = 0;\n }\n\n currentX += measureTextWidth(ctx, char, fontSize, fontFamily, fontWeight);\n charIndexInText++;\n }\n }\n } finally {\n ctx.restore();\n }\n}\n"],"names":[],"mappings":";;;;AAYA,SAAS,UAAU,IAAY,KAAqB;AAClD,SAAO,KAAK,MAAM,MAAM,MAAU,IAAI;AACxC;AAEO,SAAS,mBACd,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,WAAW,WAAW;AAC5B,QAAM,cAAc,WAAW;AAC/B,QAAM,cAAc,WAAW,eAAe;AAC9C,QAAM,aAAa,WAAW,cAAc;AAE5C,QAAM,gBAAgB,MAAM,WAAW,oBAAoB,QAAQ;AACnE,QAAM,YAAY,MAAM,WAAW,aAAa;AAChD,QAAM,gBAAgB,MAAM,WAAW,iBAAiB;AACxD,QAAM,mBAAmB,MAAM,WAAW,oBAAoB;AAE9D,QAAM,WAAW,cAAc;AAC/B,QAAM,OAAO,kBAAkB,MAAM,MAAM,MAAM,UAAU;AAC3D,QAAM,aAAa,uBAAuB,MAAM,cAAc,SAAS,IAAI;AAC3E,QAAM,mBAAsC,CAAA;AAE5C,MAAI,MAAM,eAAe,MAAM,YAAY,SAAS,GAAG;AACrD,QAAI,YAAY;AAEhB,aAAS,YAAY,GAAG,YAAY,MAAM,YAAY,QAAQ,aAAa;AACzE,YAAM,O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;AAAA,EACN;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"word-by-word-renderer.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-renderers/word-by-word-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAoB1C,wBAAgB,gBAAgB,CAC9B,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,
|
|
1
|
+
{"version":3,"file":"word-by-word-renderer.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-renderers/word-by-word-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAoB1C,wBAAgB,gBAAgB,CAC9B,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,CAoIN"}
|
|
@@ -65,50 +65,58 @@ function renderWordByWord(ctx, layer, canvasWidth, canvasHeight, relativeFrame,
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
ctx.save();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
try {
|
|
69
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
70
|
+
ctx.textAlign = "center";
|
|
71
|
+
ctx.textBaseline = "middle";
|
|
72
|
+
ctx.lineJoin = "round";
|
|
73
|
+
ctx.lineCap = "round";
|
|
74
|
+
for (const wordPos of wordPositions) {
|
|
75
|
+
let currentFill = fill;
|
|
76
|
+
let currentStroke = strokeColor;
|
|
77
|
+
if (wordPos.timing) {
|
|
78
|
+
const { startFrame, endFrame } = wordPos.timing;
|
|
79
|
+
if (relativeFrame >= startFrame && relativeFrame <= endFrame) {
|
|
80
|
+
const transitionProgressIn = interpolate(
|
|
81
|
+
relativeFrame,
|
|
82
|
+
[startFrame, startFrame + 3],
|
|
83
|
+
[0, 1],
|
|
84
|
+
{
|
|
85
|
+
extrapolateLeft: "clamp",
|
|
86
|
+
extrapolateRight: "clamp"
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
currentFill = interpolateColor(fill, highlightFill, transitionProgressIn);
|
|
90
|
+
if (strokeColor && highlightStroke) {
|
|
91
|
+
currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressIn);
|
|
92
|
+
}
|
|
93
|
+
} else if (relativeFrame > endFrame) {
|
|
94
|
+
const transitionProgressOut = interpolate(
|
|
95
|
+
relativeFrame,
|
|
96
|
+
[endFrame, endFrame + 3],
|
|
97
|
+
[1, 0],
|
|
98
|
+
{
|
|
99
|
+
extrapolateLeft: "clamp",
|
|
100
|
+
extrapolateRight: "clamp"
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
currentFill = interpolateColor(fill, highlightFill, transitionProgressOut);
|
|
104
|
+
if (strokeColor && highlightStroke) {
|
|
105
|
+
currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressOut);
|
|
86
106
|
}
|
|
87
|
-
);
|
|
88
|
-
currentFill = interpolateColor(fill, highlightFill, transitionProgressIn);
|
|
89
|
-
if (strokeColor && highlightStroke) {
|
|
90
|
-
currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressIn);
|
|
91
|
-
}
|
|
92
|
-
} else if (relativeFrame > endFrame) {
|
|
93
|
-
const transitionProgressOut = interpolate(relativeFrame, [endFrame, endFrame + 3], [1, 0], {
|
|
94
|
-
extrapolateLeft: "clamp",
|
|
95
|
-
extrapolateRight: "clamp"
|
|
96
|
-
});
|
|
97
|
-
currentFill = interpolateColor(fill, highlightFill, transitionProgressOut);
|
|
98
|
-
if (strokeColor && highlightStroke) {
|
|
99
|
-
currentStroke = interpolateColor(strokeColor, highlightStroke, transitionProgressOut);
|
|
100
107
|
}
|
|
101
108
|
}
|
|
109
|
+
if (currentStroke && strokeWidth > 0) {
|
|
110
|
+
ctx.strokeStyle = currentStroke;
|
|
111
|
+
ctx.lineWidth = strokeWidth;
|
|
112
|
+
ctx.strokeText(wordPos.text, wordPos.x, wordPos.y);
|
|
113
|
+
}
|
|
114
|
+
ctx.fillStyle = currentFill;
|
|
115
|
+
ctx.fillText(wordPos.text, wordPos.x, wordPos.y);
|
|
102
116
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
ctx.lineWidth = strokeWidth;
|
|
106
|
-
ctx.strokeText(wordPos.text, wordPos.x, wordPos.y);
|
|
107
|
-
}
|
|
108
|
-
ctx.fillStyle = currentFill;
|
|
109
|
-
ctx.fillText(wordPos.text, wordPos.x, wordPos.y);
|
|
117
|
+
} finally {
|
|
118
|
+
ctx.restore();
|
|
110
119
|
}
|
|
111
|
-
ctx.restore();
|
|
112
120
|
}
|
|
113
121
|
export {
|
|
114
122
|
renderWordByWord
|
|
@@ -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';\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
|
|
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 try {\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(\n relativeFrame,\n [endFrame, endFrame + 3],\n [1, 0],\n {\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n }\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 } finally {\n ctx.restore();\n }\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,k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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,
|
|
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,CA2IN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formEvenLinesWithWords } from "../text-utils/text-wrapper.js";
|
|
2
2
|
import { getLetterCaseText, measureTextWidth } from "../text-utils/text-metrics.js";
|
|
3
|
-
import {
|
|
3
|
+
import { springEasing, interpolate } from "./animation-utils.js";
|
|
4
4
|
import { needsSpaceBetweenWords } from "../text-utils/locale-detector.js";
|
|
5
5
|
import { calculateCaptionStartY } from "../text-utils/caption-position.js";
|
|
6
6
|
function usToFrame(us, fps) {
|
|
@@ -65,57 +65,63 @@ function renderWordByWordFancy(ctx, layer, canvasWidth, canvasHeight, relativeFr
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
ctx.save();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
68
|
+
try {
|
|
69
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
70
|
+
ctx.textAlign = "center";
|
|
71
|
+
ctx.textBaseline = "middle";
|
|
72
|
+
ctx.lineJoin = "round";
|
|
73
|
+
ctx.lineCap = "round";
|
|
74
|
+
for (const wordPos of wordPositions) {
|
|
75
|
+
let backgroundOpacity = 0;
|
|
76
|
+
let backgroundScale = 0.8;
|
|
77
|
+
if (wordPos.timing) {
|
|
78
|
+
const { startFrame, endFrame } = wordPos.timing;
|
|
79
|
+
const preStartFrames = 3;
|
|
80
|
+
const isActive = relativeFrame >= startFrame && relativeFrame <= endFrame;
|
|
81
|
+
if (isActive) {
|
|
82
|
+
const scaleSpringIn = springEasing(relativeFrame - (startFrame - preStartFrames), {
|
|
83
|
+
damping: 6,
|
|
84
|
+
mass: 0.35,
|
|
85
|
+
stiffness: 200,
|
|
86
|
+
overshootClamping: false
|
|
87
|
+
});
|
|
88
|
+
const inProgress = interpolate(relativeFrame, [startFrame, startFrame + 1], [0, 1], {
|
|
89
|
+
extrapolateLeft: "clamp",
|
|
90
|
+
extrapolateRight: "clamp"
|
|
91
|
+
});
|
|
92
|
+
backgroundOpacity = 0.9 * inProgress;
|
|
93
|
+
backgroundScale = 0.8 + scaleSpringIn * 0.45;
|
|
94
|
+
} else if (relativeFrame > endFrame) {
|
|
95
|
+
backgroundOpacity = 0;
|
|
96
|
+
backgroundScale = 0.8;
|
|
97
|
+
}
|
|
98
|
+
if (backgroundOpacity > 0) {
|
|
99
|
+
const padding = 8;
|
|
100
|
+
const bgWidth = (wordPos.width + padding * 2) * backgroundScale;
|
|
101
|
+
const bgHeight = (fontSize + padding) * backgroundScale;
|
|
102
|
+
ctx.save();
|
|
103
|
+
try {
|
|
104
|
+
ctx.globalAlpha = backgroundOpacity;
|
|
105
|
+
ctx.fillStyle = highlightBackgroundColor;
|
|
106
|
+
ctx.beginPath();
|
|
107
|
+
ctx.roundRect(wordPos.x - bgWidth / 2, wordPos.y - bgHeight / 2, bgWidth, bgHeight, 8);
|
|
108
|
+
ctx.fill();
|
|
109
|
+
} finally {
|
|
110
|
+
ctx.restore();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
96
113
|
}
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
ctx.save();
|
|
102
|
-
ctx.globalAlpha = backgroundOpacity;
|
|
103
|
-
ctx.fillStyle = highlightBackgroundColor;
|
|
104
|
-
ctx.beginPath();
|
|
105
|
-
ctx.roundRect(wordPos.x - bgWidth / 2, wordPos.y - bgHeight / 2, bgWidth, bgHeight, 8);
|
|
106
|
-
ctx.fill();
|
|
107
|
-
ctx.restore();
|
|
114
|
+
if (strokeColor && strokeWidth > 0) {
|
|
115
|
+
ctx.strokeStyle = strokeColor;
|
|
116
|
+
ctx.lineWidth = strokeWidth;
|
|
117
|
+
ctx.strokeText(wordPos.text, wordPos.x, wordPos.y);
|
|
108
118
|
}
|
|
119
|
+
ctx.fillStyle = fill;
|
|
120
|
+
ctx.fillText(wordPos.text, wordPos.x, wordPos.y);
|
|
109
121
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
ctx.lineWidth = strokeWidth;
|
|
113
|
-
ctx.strokeText(wordPos.text, wordPos.x, wordPos.y);
|
|
114
|
-
}
|
|
115
|
-
ctx.fillStyle = fill;
|
|
116
|
-
ctx.fillText(wordPos.text, wordPos.x, wordPos.y);
|
|
122
|
+
} finally {
|
|
123
|
+
ctx.restore();
|
|
117
124
|
}
|
|
118
|
-
ctx.restore();
|
|
119
125
|
}
|
|
120
126
|
export {
|
|
121
127
|
renderWordByWordFancy
|
|
@@ -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';\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
|
|
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 try {\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 try {\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 } finally {\n ctx.restore();\n }\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 } finally {\n ctx.restore();\n }\n}\n"],"names":[],"m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AAU;AAChB,gBAAM,WAAW,QAAQ,QAAQ,UAAU,KAAK;AAChD,gBAAM,YAAY,WAAW,WAAW;AAExC,cAAI,KAAA;AACJ,cAAI;AACF,gBAAI,cAAc;AAClB,gBAAI,YAAY;AAChB,gBAAI,UAAA;AACJ,gBAAI,UAAU,QAAQ,IAAI,UAAU,GAAG,QAAQ,IAAI,WAAW,GAAG,SAAS,UAAU,CAAC;AACrF,gBAAI,KAAA;AAAA,UACN,UAAA;AACE,gBAAI,QAAA;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAEA,UAAI,eAAe,cAAc,GAAG;AAClC,YAAI,cAAc;AAClB,YAAI,YAAY;AAChB,YAAI,WAAW,QAAQ,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAAA,MACnD;AACA,UAAI,YAAY;AAChB,UAAI,SAAS,QAAQ,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAAA,IACjD;AAAA,EACF,UAAA;AACE,QAAI,QAAA;AAAA,EACN;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-metrics.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-utils/text-metrics.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,iCAAiC,GAAG,wBAAwB,EACjE,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAAM,GAAG,MAAY,GAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"text-metrics.d.ts","sourceRoot":"","sources":["../../../../src/stages/compose/text-utils/text-metrics.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,iCAAiC,GAAG,wBAAwB,EACjE,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAAM,GAAG,MAAY,GAChC,MAAM,CAQR;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAQ/F"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
function measureTextWidth(ctx, text, fontSize, fontFamily, fontWeight = 400) {
|
|
2
2
|
ctx.save();
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
try {
|
|
4
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
5
|
+
return ctx.measureText(text).width;
|
|
6
|
+
} finally {
|
|
7
|
+
ctx.restore();
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
function getLetterCaseText(text, letterCase) {
|
|
9
11
|
if (letterCase === "upper") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-metrics.js","sources":["../../../../src/stages/compose/text-utils/text-metrics.ts"],"sourcesContent":["export function measureTextWidth(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n text: string,\n fontSize: number,\n fontFamily: string,\n fontWeight: string | number = 400\n): number {\n ctx.save();\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n
|
|
1
|
+
{"version":3,"file":"text-metrics.js","sources":["../../../../src/stages/compose/text-utils/text-metrics.ts"],"sourcesContent":["export function measureTextWidth(\n ctx: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D,\n text: string,\n fontSize: number,\n fontFamily: string,\n fontWeight: string | number = 400\n): number {\n ctx.save();\n try {\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n return ctx.measureText(text).width;\n } finally {\n ctx.restore();\n }\n}\n\nexport function getLetterCaseText(text: string, letterCase?: 'upper' | 'lower' | 'none'): string {\n if (letterCase === 'upper') {\n return text.toUpperCase();\n }\n if (letterCase === 'lower') {\n return text.toLowerCase();\n }\n return text;\n}\n"],"names":[],"mappings":"AAAO,SAAS,iBACd,KACA,MACA,UACA,YACA,aAA8B,KACtB;AACR,MAAI,KAAA;AACJ,MAAI;AACF,QAAI,OAAO,GAAG,UAAU,IAAI,QAAQ,MAAM,UAAU;AACpD,WAAO,IAAI,YAAY,IAAI,EAAE;AAAA,EAC/B,UAAA;AACE,QAAI,QAAA;AAAA,EACN;AACF;AAEO,SAAS,kBAAkB,MAAc,YAAiD;AAC/F,MAAI,eAAe,SAAS;AAC1B,WAAO,KAAK,YAAA;AAAA,EACd;AACA,MAAI,eAAe,SAAS;AAC1B,WAAO,KAAK,YAAA;AAAA,EACd;AACA,SAAO;AACT;"}
|
|
@@ -130,6 +130,11 @@ export interface Layer {
|
|
|
130
130
|
transform?: Transform2D;
|
|
131
131
|
mask?: MaskConfig;
|
|
132
132
|
filters?: VisualFilter[];
|
|
133
|
+
/** Where the layer comes from; failure reports name the clip and resource. */
|
|
134
|
+
origin?: {
|
|
135
|
+
clipId: string;
|
|
136
|
+
resourceId?: string;
|
|
137
|
+
};
|
|
133
138
|
}
|
|
134
139
|
export interface Transform2D {
|
|
135
140
|
x: number;
|
|
@@ -254,6 +259,7 @@ export interface VideoLayer extends Layer {
|
|
|
254
259
|
};
|
|
255
260
|
}
|
|
256
261
|
export interface ImageLayer extends Layer {
|
|
262
|
+
ownedSource?: boolean;
|
|
257
263
|
type: 'image';
|
|
258
264
|
source: ImageBitmap | ImageData | null;
|
|
259
265
|
attachmentId?: string;
|
|
@@ -273,6 +279,12 @@ export interface TransitionEffect {
|
|
|
273
279
|
params?: Record<string, any>;
|
|
274
280
|
}
|
|
275
281
|
export interface ComposeRequest {
|
|
282
|
+
signal?: AbortSignal;
|
|
283
|
+
/**
|
|
284
|
+
* Preview only. When set, a layer that throws while rendering is left out of the frame and reported here; the other layers
|
|
285
|
+
* are still drawn. When unset (export, and preview with `preview.layerFailure: 'pause'`), the frame fails.
|
|
286
|
+
*/
|
|
287
|
+
onLayerError?: (layer: Layer, error: unknown) => void;
|
|
276
288
|
timeUs: number;
|
|
277
289
|
globalTimeUs?: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ecoder | AudioD
|
|
|
4
4
|
protected decoder?: TDecoder;
|
|
5
5
|
protected config: TConfig;
|
|
6
6
|
protected controller: TransformStreamDefaultController<TOutput> | null;
|
|
7
|
+
private cancelError;
|
|
8
|
+
private readonly queueWaiters;
|
|
7
9
|
constructor(config: TConfig);
|
|
8
10
|
initialize(): Promise<void>;
|
|
9
11
|
reconfigure(config: Partial<TConfig>): Promise<void>;
|
|
10
12
|
flush(): Promise<void>;
|
|
11
13
|
reset(): Promise<void>;
|
|
14
|
+
private waitForQueueDrain;
|
|
15
|
+
/** Aborts the owner's work: rejects pending waits, closes the native decoder and errors the stream. */
|
|
16
|
+
cancel(reason?: unknown): void;
|
|
12
17
|
close(): Promise<void>;
|
|
13
18
|
get isReady(): boolean;
|
|
14
19
|
get queueSize(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDecoder.d.ts","sourceRoot":"","sources":["../../../src/stages/decode/BaseDecoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEpF,8BAAsB,WAAW,CAC/B,QAAQ,SAAS,YAAY,GAAG,YAAY,EAC5C,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EACvD,MAAM,SAAS,iBAAiB,GAAG,iBAAiB,EACpD,OAAO,SAAS,UAAU,GAAG,SAAS,GAAG,iBAAiB;IAE1D,SAAS,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,UAAU,EAAE,gCAAgC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAQ;
|
|
1
|
+
{"version":3,"file":"BaseDecoder.d.ts","sourceRoot":"","sources":["../../../src/stages/decode/BaseDecoder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAk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