@shotstack/shotstack-canvas 2.0.17 → 2.1.1
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/entry.node.cjs +9 -7
- package/dist/entry.node.d.cts +8 -2
- package/dist/entry.node.d.ts +8 -2
- package/dist/entry.node.js +9 -7
- package/dist/entry.web.d.ts +8 -2
- package/dist/entry.web.js +8 -6
- package/package.json +3 -1
package/dist/entry.node.cjs
CHANGED
|
@@ -5317,16 +5317,18 @@ var CaptionLayoutEngine = class {
|
|
|
5317
5317
|
};
|
|
5318
5318
|
}).filter((g) => g !== null);
|
|
5319
5319
|
});
|
|
5320
|
+
const contentHeight = config.frameHeight - config.padding.top - config.padding.bottom;
|
|
5321
|
+
const contentWidth = config.frameWidth - config.padding.left - config.padding.right;
|
|
5320
5322
|
const calculateGroupY = (group) => {
|
|
5321
5323
|
const totalHeight = group.lines.length * config.fontSize * config.lineHeight;
|
|
5322
5324
|
switch (config.verticalAlign) {
|
|
5323
5325
|
case "top":
|
|
5324
|
-
return config.fontSize * 1.5;
|
|
5326
|
+
return config.padding.top + config.fontSize * 1.5;
|
|
5325
5327
|
case "bottom":
|
|
5326
|
-
return config.frameHeight - totalHeight - config.fontSize * 0.5;
|
|
5328
|
+
return config.frameHeight - config.padding.bottom - totalHeight - config.fontSize * 0.5;
|
|
5327
5329
|
case "middle":
|
|
5328
5330
|
default:
|
|
5329
|
-
return
|
|
5331
|
+
return config.padding.top + (contentHeight - totalHeight) / 2 + config.fontSize;
|
|
5330
5332
|
}
|
|
5331
5333
|
};
|
|
5332
5334
|
const allWordTexts = store.words.slice(0, store.length);
|
|
@@ -5334,12 +5336,12 @@ var CaptionLayoutEngine = class {
|
|
|
5334
5336
|
const calculateLineX = (lineWidth) => {
|
|
5335
5337
|
switch (config.horizontalAlign) {
|
|
5336
5338
|
case "left":
|
|
5337
|
-
return config.
|
|
5339
|
+
return config.padding.left;
|
|
5338
5340
|
case "right":
|
|
5339
|
-
return config.frameWidth - lineWidth - config.
|
|
5341
|
+
return config.frameWidth - lineWidth - config.padding.right;
|
|
5340
5342
|
case "center":
|
|
5341
5343
|
default:
|
|
5342
|
-
return
|
|
5344
|
+
return config.padding.left + (contentWidth - lineWidth) / 2;
|
|
5343
5345
|
}
|
|
5344
5346
|
};
|
|
5345
5347
|
for (const group of groups) {
|
|
@@ -6212,7 +6214,7 @@ var RichCaptionRenderer = class {
|
|
|
6212
6214
|
maxLines: computedMaxLines,
|
|
6213
6215
|
verticalAlign,
|
|
6214
6216
|
horizontalAlign,
|
|
6215
|
-
|
|
6217
|
+
padding,
|
|
6216
6218
|
fontSize,
|
|
6217
6219
|
fontFamily: font?.family ?? "Roboto",
|
|
6218
6220
|
fontWeight: String(font?.weight ?? "400"),
|
package/dist/entry.node.d.cts
CHANGED
|
@@ -609,6 +609,12 @@ interface WordTiming {
|
|
|
609
609
|
end: number;
|
|
610
610
|
confidence?: number;
|
|
611
611
|
}
|
|
612
|
+
interface CaptionPadding {
|
|
613
|
+
top: number;
|
|
614
|
+
right: number;
|
|
615
|
+
bottom: number;
|
|
616
|
+
left: number;
|
|
617
|
+
}
|
|
612
618
|
interface CaptionLayoutConfig {
|
|
613
619
|
frameWidth: number;
|
|
614
620
|
frameHeight: number;
|
|
@@ -616,7 +622,7 @@ interface CaptionLayoutConfig {
|
|
|
616
622
|
maxLines: number;
|
|
617
623
|
verticalAlign: "top" | "middle" | "bottom";
|
|
618
624
|
horizontalAlign: "left" | "center" | "right";
|
|
619
|
-
|
|
625
|
+
padding: CaptionPadding;
|
|
620
626
|
fontSize: number;
|
|
621
627
|
fontFamily: string;
|
|
622
628
|
fontWeight: string | number;
|
|
@@ -1342,4 +1348,4 @@ declare function createTextEngine(opts?: {
|
|
|
1342
1348
|
destroy(): void;
|
|
1343
1349
|
}>;
|
|
1344
1350
|
|
|
1345
|
-
export { ASCENT_RATIO, type AnimationDirection, type AnimationStyle, type ArcCommand, type BackgroundConfig, type BoundingBox, type CanvasRichCaptionAsset, CanvasRichCaptionAssetSchema, type CanvasRichTextAsset, CanvasRichTextAssetSchema, type CanvasSvgAsset, CanvasSvgAssetSchema, type CaptionGroup, type CaptionLayout, type CaptionLayoutConfig, CaptionLayoutEngine, type CaptionLine, type ClosePathCommand, type CubicBezierCommand, DESCENT_RATIO, type DrawOp, type EngineInit, type FastVideoOptions, type FastVideoResult, type FontConfig, FontRegistry, type FrameSchedule, type Glyph, type GradientSpec, type IVideoEncoder, type LineToCommand, type MoveToCommand, NodeRawEncoder, type NormalizedPathCommand, type ParagraphDirection, type ParsedPathCommand, type PathCommandType, type Point2D, type PositionedWord, type QuadraticBezierCommand, type RGBA, type RenderFrame, type RenderStats, type Renderer, type ResvgRenderOptions, type ResvgRenderResult, type RichCaptionGeneratorConfig, RichCaptionRenderer, type RichCaptionRendererOptions, type ShadowConfig, type ShapedLine, type ShapedWord, type ShapedWordGlyph, type ShotstackRichTextAsset, type ShotstackSvgAsset, type StrokeConfig, type StrokeSpec, type ValidAsset, type VideoEncoderCapabilities, type VideoEncoderConfig, type VideoEncoderProgress, WORD_BG_BORDER_RADIUS, WORD_BG_OPACITY, WORD_BG_PADDING_RATIO, type WordAnimationConfig, type WordAnimationState, type WordTiming, WordTimingStore, arcToCubicBeziers, breakIntoLines, calculateAnimationStatesForGroup, commandsToPathString, computeSimplePathBounds, containsRTLCharacters, createDefaultGeneratorConfig, createFrameSchedule, createNodePainter, createNodeRawEncoder, createRichCaptionRenderer, createTextEngine, createVideoEncoder, detectParagraphDirection, detectParagraphDirectionFromWords, detectPlatform, detectSubtitleFormat, extractCaptionPadding, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, getVisibleText, groupWordsByPause, isDrawCaptionWordOp, isRTLText, isWebCodecsH264Supported, mirrorAnimationDirection, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, reorderWordsForLine, richCaptionAssetSchema, shapeToSvgString };
|
|
1351
|
+
export { ASCENT_RATIO, type AnimationDirection, type AnimationStyle, type ArcCommand, type BackgroundConfig, type BoundingBox, type CanvasRichCaptionAsset, CanvasRichCaptionAssetSchema, type CanvasRichTextAsset, CanvasRichTextAssetSchema, type CanvasSvgAsset, CanvasSvgAssetSchema, type CaptionGroup, type CaptionLayout, type CaptionLayoutConfig, CaptionLayoutEngine, type CaptionLine, type CaptionPadding, type ClosePathCommand, type CubicBezierCommand, DESCENT_RATIO, type DrawOp, type EngineInit, type FastVideoOptions, type FastVideoResult, type FontConfig, FontRegistry, type FrameSchedule, type Glyph, type GradientSpec, type IVideoEncoder, type LineToCommand, type MoveToCommand, NodeRawEncoder, type NormalizedPathCommand, type ParagraphDirection, type ParsedPathCommand, type PathCommandType, type Point2D, type PositionedWord, type QuadraticBezierCommand, type RGBA, type RenderFrame, type RenderStats, type Renderer, type ResvgRenderOptions, type ResvgRenderResult, type RichCaptionGeneratorConfig, RichCaptionRenderer, type RichCaptionRendererOptions, type ShadowConfig, type ShapedLine, type ShapedWord, type ShapedWordGlyph, type ShotstackRichTextAsset, type ShotstackSvgAsset, type StrokeConfig, type StrokeSpec, type ValidAsset, type VideoEncoderCapabilities, type VideoEncoderConfig, type VideoEncoderProgress, WORD_BG_BORDER_RADIUS, WORD_BG_OPACITY, WORD_BG_PADDING_RATIO, type WordAnimationConfig, type WordAnimationState, type WordTiming, WordTimingStore, arcToCubicBeziers, breakIntoLines, calculateAnimationStatesForGroup, commandsToPathString, computeSimplePathBounds, containsRTLCharacters, createDefaultGeneratorConfig, createFrameSchedule, createNodePainter, createNodeRawEncoder, createRichCaptionRenderer, createTextEngine, createVideoEncoder, detectParagraphDirection, detectParagraphDirectionFromWords, detectPlatform, detectSubtitleFormat, extractCaptionPadding, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, getVisibleText, groupWordsByPause, isDrawCaptionWordOp, isRTLText, isWebCodecsH264Supported, mirrorAnimationDirection, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, reorderWordsForLine, richCaptionAssetSchema, shapeToSvgString };
|
package/dist/entry.node.d.ts
CHANGED
|
@@ -609,6 +609,12 @@ interface WordTiming {
|
|
|
609
609
|
end: number;
|
|
610
610
|
confidence?: number;
|
|
611
611
|
}
|
|
612
|
+
interface CaptionPadding {
|
|
613
|
+
top: number;
|
|
614
|
+
right: number;
|
|
615
|
+
bottom: number;
|
|
616
|
+
left: number;
|
|
617
|
+
}
|
|
612
618
|
interface CaptionLayoutConfig {
|
|
613
619
|
frameWidth: number;
|
|
614
620
|
frameHeight: number;
|
|
@@ -616,7 +622,7 @@ interface CaptionLayoutConfig {
|
|
|
616
622
|
maxLines: number;
|
|
617
623
|
verticalAlign: "top" | "middle" | "bottom";
|
|
618
624
|
horizontalAlign: "left" | "center" | "right";
|
|
619
|
-
|
|
625
|
+
padding: CaptionPadding;
|
|
620
626
|
fontSize: number;
|
|
621
627
|
fontFamily: string;
|
|
622
628
|
fontWeight: string | number;
|
|
@@ -1342,4 +1348,4 @@ declare function createTextEngine(opts?: {
|
|
|
1342
1348
|
destroy(): void;
|
|
1343
1349
|
}>;
|
|
1344
1350
|
|
|
1345
|
-
export { ASCENT_RATIO, type AnimationDirection, type AnimationStyle, type ArcCommand, type BackgroundConfig, type BoundingBox, type CanvasRichCaptionAsset, CanvasRichCaptionAssetSchema, type CanvasRichTextAsset, CanvasRichTextAssetSchema, type CanvasSvgAsset, CanvasSvgAssetSchema, type CaptionGroup, type CaptionLayout, type CaptionLayoutConfig, CaptionLayoutEngine, type CaptionLine, type ClosePathCommand, type CubicBezierCommand, DESCENT_RATIO, type DrawOp, type EngineInit, type FastVideoOptions, type FastVideoResult, type FontConfig, FontRegistry, type FrameSchedule, type Glyph, type GradientSpec, type IVideoEncoder, type LineToCommand, type MoveToCommand, NodeRawEncoder, type NormalizedPathCommand, type ParagraphDirection, type ParsedPathCommand, type PathCommandType, type Point2D, type PositionedWord, type QuadraticBezierCommand, type RGBA, type RenderFrame, type RenderStats, type Renderer, type ResvgRenderOptions, type ResvgRenderResult, type RichCaptionGeneratorConfig, RichCaptionRenderer, type RichCaptionRendererOptions, type ShadowConfig, type ShapedLine, type ShapedWord, type ShapedWordGlyph, type ShotstackRichTextAsset, type ShotstackSvgAsset, type StrokeConfig, type StrokeSpec, type ValidAsset, type VideoEncoderCapabilities, type VideoEncoderConfig, type VideoEncoderProgress, WORD_BG_BORDER_RADIUS, WORD_BG_OPACITY, WORD_BG_PADDING_RATIO, type WordAnimationConfig, type WordAnimationState, type WordTiming, WordTimingStore, arcToCubicBeziers, breakIntoLines, calculateAnimationStatesForGroup, commandsToPathString, computeSimplePathBounds, containsRTLCharacters, createDefaultGeneratorConfig, createFrameSchedule, createNodePainter, createNodeRawEncoder, createRichCaptionRenderer, createTextEngine, createVideoEncoder, detectParagraphDirection, detectParagraphDirectionFromWords, detectPlatform, detectSubtitleFormat, extractCaptionPadding, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, getVisibleText, groupWordsByPause, isDrawCaptionWordOp, isRTLText, isWebCodecsH264Supported, mirrorAnimationDirection, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, reorderWordsForLine, richCaptionAssetSchema, shapeToSvgString };
|
|
1351
|
+
export { ASCENT_RATIO, type AnimationDirection, type AnimationStyle, type ArcCommand, type BackgroundConfig, type BoundingBox, type CanvasRichCaptionAsset, CanvasRichCaptionAssetSchema, type CanvasRichTextAsset, CanvasRichTextAssetSchema, type CanvasSvgAsset, CanvasSvgAssetSchema, type CaptionGroup, type CaptionLayout, type CaptionLayoutConfig, CaptionLayoutEngine, type CaptionLine, type CaptionPadding, type ClosePathCommand, type CubicBezierCommand, DESCENT_RATIO, type DrawOp, type EngineInit, type FastVideoOptions, type FastVideoResult, type FontConfig, FontRegistry, type FrameSchedule, type Glyph, type GradientSpec, type IVideoEncoder, type LineToCommand, type MoveToCommand, NodeRawEncoder, type NormalizedPathCommand, type ParagraphDirection, type ParsedPathCommand, type PathCommandType, type Point2D, type PositionedWord, type QuadraticBezierCommand, type RGBA, type RenderFrame, type RenderStats, type Renderer, type ResvgRenderOptions, type ResvgRenderResult, type RichCaptionGeneratorConfig, RichCaptionRenderer, type RichCaptionRendererOptions, type ShadowConfig, type ShapedLine, type ShapedWord, type ShapedWordGlyph, type ShotstackRichTextAsset, type ShotstackSvgAsset, type StrokeConfig, type StrokeSpec, type ValidAsset, type VideoEncoderCapabilities, type VideoEncoderConfig, type VideoEncoderProgress, WORD_BG_BORDER_RADIUS, WORD_BG_OPACITY, WORD_BG_PADDING_RATIO, type WordAnimationConfig, type WordAnimationState, type WordTiming, WordTimingStore, arcToCubicBeziers, breakIntoLines, calculateAnimationStatesForGroup, commandsToPathString, computeSimplePathBounds, containsRTLCharacters, createDefaultGeneratorConfig, createFrameSchedule, createNodePainter, createNodeRawEncoder, createRichCaptionRenderer, createTextEngine, createVideoEncoder, detectParagraphDirection, detectParagraphDirectionFromWords, detectPlatform, detectSubtitleFormat, extractCaptionPadding, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, getVisibleText, groupWordsByPause, isDrawCaptionWordOp, isRTLText, isWebCodecsH264Supported, mirrorAnimationDirection, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, reorderWordsForLine, richCaptionAssetSchema, shapeToSvgString };
|
package/dist/entry.node.js
CHANGED
|
@@ -4914,16 +4914,18 @@ var CaptionLayoutEngine = class {
|
|
|
4914
4914
|
};
|
|
4915
4915
|
}).filter((g) => g !== null);
|
|
4916
4916
|
});
|
|
4917
|
+
const contentHeight = config.frameHeight - config.padding.top - config.padding.bottom;
|
|
4918
|
+
const contentWidth = config.frameWidth - config.padding.left - config.padding.right;
|
|
4917
4919
|
const calculateGroupY = (group) => {
|
|
4918
4920
|
const totalHeight = group.lines.length * config.fontSize * config.lineHeight;
|
|
4919
4921
|
switch (config.verticalAlign) {
|
|
4920
4922
|
case "top":
|
|
4921
|
-
return config.fontSize * 1.5;
|
|
4923
|
+
return config.padding.top + config.fontSize * 1.5;
|
|
4922
4924
|
case "bottom":
|
|
4923
|
-
return config.frameHeight - totalHeight - config.fontSize * 0.5;
|
|
4925
|
+
return config.frameHeight - config.padding.bottom - totalHeight - config.fontSize * 0.5;
|
|
4924
4926
|
case "middle":
|
|
4925
4927
|
default:
|
|
4926
|
-
return
|
|
4928
|
+
return config.padding.top + (contentHeight - totalHeight) / 2 + config.fontSize;
|
|
4927
4929
|
}
|
|
4928
4930
|
};
|
|
4929
4931
|
const allWordTexts = store.words.slice(0, store.length);
|
|
@@ -4931,12 +4933,12 @@ var CaptionLayoutEngine = class {
|
|
|
4931
4933
|
const calculateLineX = (lineWidth) => {
|
|
4932
4934
|
switch (config.horizontalAlign) {
|
|
4933
4935
|
case "left":
|
|
4934
|
-
return config.
|
|
4936
|
+
return config.padding.left;
|
|
4935
4937
|
case "right":
|
|
4936
|
-
return config.frameWidth - lineWidth - config.
|
|
4938
|
+
return config.frameWidth - lineWidth - config.padding.right;
|
|
4937
4939
|
case "center":
|
|
4938
4940
|
default:
|
|
4939
|
-
return
|
|
4941
|
+
return config.padding.left + (contentWidth - lineWidth) / 2;
|
|
4940
4942
|
}
|
|
4941
4943
|
};
|
|
4942
4944
|
for (const group of groups) {
|
|
@@ -5809,7 +5811,7 @@ var RichCaptionRenderer = class {
|
|
|
5809
5811
|
maxLines: computedMaxLines,
|
|
5810
5812
|
verticalAlign,
|
|
5811
5813
|
horizontalAlign,
|
|
5812
|
-
|
|
5814
|
+
padding,
|
|
5813
5815
|
fontSize,
|
|
5814
5816
|
fontFamily: font?.family ?? "Roboto",
|
|
5815
5817
|
fontWeight: String(font?.weight ?? "400"),
|
package/dist/entry.web.d.ts
CHANGED
|
@@ -609,6 +609,12 @@ interface WordTiming {
|
|
|
609
609
|
end: number;
|
|
610
610
|
confidence?: number;
|
|
611
611
|
}
|
|
612
|
+
interface CaptionPadding {
|
|
613
|
+
top: number;
|
|
614
|
+
right: number;
|
|
615
|
+
bottom: number;
|
|
616
|
+
left: number;
|
|
617
|
+
}
|
|
612
618
|
interface CaptionLayoutConfig {
|
|
613
619
|
frameWidth: number;
|
|
614
620
|
frameHeight: number;
|
|
@@ -616,7 +622,7 @@ interface CaptionLayoutConfig {
|
|
|
616
622
|
maxLines: number;
|
|
617
623
|
verticalAlign: "top" | "middle" | "bottom";
|
|
618
624
|
horizontalAlign: "left" | "center" | "right";
|
|
619
|
-
|
|
625
|
+
padding: CaptionPadding;
|
|
620
626
|
fontSize: number;
|
|
621
627
|
fontFamily: string;
|
|
622
628
|
fontWeight: string | number;
|
|
@@ -1285,4 +1291,4 @@ declare function createTextEngine(opts?: {
|
|
|
1285
1291
|
destroy(): void;
|
|
1286
1292
|
}>;
|
|
1287
1293
|
|
|
1288
|
-
export { ASCENT_RATIO, type AnimationDirection, type AnimationStyle, type ArcCommand, type BackgroundConfig, type BoundingBox, type CanvasRichCaptionAsset, CanvasRichCaptionAssetSchema, type CanvasRichTextAsset, CanvasRichTextAssetSchema, type CanvasSvgAsset, CanvasSvgAssetSchema, type CaptionGroup, type CaptionLayout, type CaptionLayoutConfig, CaptionLayoutEngine, type CaptionLine, type ClosePathCommand, type CubicBezierCommand, DESCENT_RATIO, type DrawOp, type EngineInit, type FastVideoOptions, type FastVideoResult, type FontConfig, FontRegistry, type FrameSchedule, type Glyph, type GradientSpec, type IVideoEncoder, type LineToCommand, MediaRecorderFallback, type MoveToCommand, type NormalizedPathCommand, type ParagraphDirection, type ParsedPathCommand, type PathCommandType, type Point2D, type PositionedWord, type QuadraticBezierCommand, type RGBA, type RenderFrame, type RenderStats, type Renderer, type ResvgRenderOptions, type ResvgRenderResult, type RichCaptionGeneratorConfig, type RichCaptionRendererOptions, type ShadowConfig, type ShapedLine, type ShapedWord, type ShapedWordGlyph, type ShotstackRichTextAsset, type ShotstackSvgAsset, type StrokeConfig, type StrokeSpec, type ValidAsset, type VideoEncoderCapabilities, type VideoEncoderConfig, type VideoEncoderProgress, WORD_BG_BORDER_RADIUS, WORD_BG_OPACITY, WORD_BG_PADDING_RATIO, WebCodecsEncoder, type WordAnimationConfig, type WordAnimationState, type WordTiming, WordTimingStore, arcToCubicBeziers, breakIntoLines, calculateAnimationStatesForGroup, commandsToPathString, computeSimplePathBounds, containsRTLCharacters, createDefaultGeneratorConfig, createFrameSchedule, createMediaRecorderFallback, createTextEngine, createVideoEncoder, createWebCodecsEncoder, createWebPainter, detectParagraphDirection, detectParagraphDirectionFromWords, detectPlatform, detectSubtitleFormat, extractCaptionPadding, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, getVisibleText, groupWordsByPause, initResvg, isDrawCaptionWordOp, isMediaRecorderSupported, isRTLText, isWebCodecsH264Supported, mirrorAnimationDirection, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, reorderWordsForLine, richCaptionAssetSchema, shapeToSvgString };
|
|
1294
|
+
export { ASCENT_RATIO, type AnimationDirection, type AnimationStyle, type ArcCommand, type BackgroundConfig, type BoundingBox, type CanvasRichCaptionAsset, CanvasRichCaptionAssetSchema, type CanvasRichTextAsset, CanvasRichTextAssetSchema, type CanvasSvgAsset, CanvasSvgAssetSchema, type CaptionGroup, type CaptionLayout, type CaptionLayoutConfig, CaptionLayoutEngine, type CaptionLine, type CaptionPadding, type ClosePathCommand, type CubicBezierCommand, DESCENT_RATIO, type DrawOp, type EngineInit, type FastVideoOptions, type FastVideoResult, type FontConfig, FontRegistry, type FrameSchedule, type Glyph, type GradientSpec, type IVideoEncoder, type LineToCommand, MediaRecorderFallback, type MoveToCommand, type NormalizedPathCommand, type ParagraphDirection, type ParsedPathCommand, type PathCommandType, type Point2D, type PositionedWord, type QuadraticBezierCommand, type RGBA, type RenderFrame, type RenderStats, type Renderer, type ResvgRenderOptions, type ResvgRenderResult, type RichCaptionGeneratorConfig, type RichCaptionRendererOptions, type ShadowConfig, type ShapedLine, type ShapedWord, type ShapedWordGlyph, type ShotstackRichTextAsset, type ShotstackSvgAsset, type StrokeConfig, type StrokeSpec, type ValidAsset, type VideoEncoderCapabilities, type VideoEncoderConfig, type VideoEncoderProgress, WORD_BG_BORDER_RADIUS, WORD_BG_OPACITY, WORD_BG_PADDING_RATIO, WebCodecsEncoder, type WordAnimationConfig, type WordAnimationState, type WordTiming, WordTimingStore, arcToCubicBeziers, breakIntoLines, calculateAnimationStatesForGroup, commandsToPathString, computeSimplePathBounds, containsRTLCharacters, createDefaultGeneratorConfig, createFrameSchedule, createMediaRecorderFallback, createTextEngine, createVideoEncoder, createWebCodecsEncoder, createWebPainter, detectParagraphDirection, detectParagraphDirectionFromWords, detectPlatform, detectSubtitleFormat, extractCaptionPadding, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, getVisibleText, groupWordsByPause, initResvg, isDrawCaptionWordOp, isMediaRecorderSupported, isRTLText, isWebCodecsH264Supported, mirrorAnimationDirection, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, reorderWordsForLine, richCaptionAssetSchema, shapeToSvgString };
|
package/dist/entry.web.js
CHANGED
|
@@ -37220,16 +37220,18 @@ var CaptionLayoutEngine = class {
|
|
|
37220
37220
|
};
|
|
37221
37221
|
}).filter((g) => g !== null);
|
|
37222
37222
|
});
|
|
37223
|
+
const contentHeight = config2.frameHeight - config2.padding.top - config2.padding.bottom;
|
|
37224
|
+
const contentWidth = config2.frameWidth - config2.padding.left - config2.padding.right;
|
|
37223
37225
|
const calculateGroupY = (group) => {
|
|
37224
37226
|
const totalHeight = group.lines.length * config2.fontSize * config2.lineHeight;
|
|
37225
37227
|
switch (config2.verticalAlign) {
|
|
37226
37228
|
case "top":
|
|
37227
|
-
return config2.fontSize * 1.5;
|
|
37229
|
+
return config2.padding.top + config2.fontSize * 1.5;
|
|
37228
37230
|
case "bottom":
|
|
37229
|
-
return config2.frameHeight - totalHeight - config2.fontSize * 0.5;
|
|
37231
|
+
return config2.frameHeight - config2.padding.bottom - totalHeight - config2.fontSize * 0.5;
|
|
37230
37232
|
case "middle":
|
|
37231
37233
|
default:
|
|
37232
|
-
return
|
|
37234
|
+
return config2.padding.top + (contentHeight - totalHeight) / 2 + config2.fontSize;
|
|
37233
37235
|
}
|
|
37234
37236
|
};
|
|
37235
37237
|
const allWordTexts = store.words.slice(0, store.length);
|
|
@@ -37237,12 +37239,12 @@ var CaptionLayoutEngine = class {
|
|
|
37237
37239
|
const calculateLineX = (lineWidth) => {
|
|
37238
37240
|
switch (config2.horizontalAlign) {
|
|
37239
37241
|
case "left":
|
|
37240
|
-
return config2.
|
|
37242
|
+
return config2.padding.left;
|
|
37241
37243
|
case "right":
|
|
37242
|
-
return config2.frameWidth - lineWidth - config2.
|
|
37244
|
+
return config2.frameWidth - lineWidth - config2.padding.right;
|
|
37243
37245
|
case "center":
|
|
37244
37246
|
default:
|
|
37245
|
-
return
|
|
37247
|
+
return config2.padding.left + (contentWidth - lineWidth) / 2;
|
|
37246
37248
|
}
|
|
37247
37249
|
};
|
|
37248
37250
|
for (const group of groups) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shotstack/shotstack-canvas",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Text layout & animation engine (HarfBuzz) for Node & Web - fully self-contained.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/entry.node.cjs",
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"example:video": "node examples/node-video.mjs",
|
|
33
33
|
"example:web": "vite dev examples/web-example",
|
|
34
34
|
"test:caption-web": "vite dev examples/caption-tests",
|
|
35
|
+
"test:padding-node": "node examples/captionpaddingtests/node-test.mjs",
|
|
36
|
+
"test:padding-web": "vite dev examples/captionpaddingtests",
|
|
35
37
|
"prepublishOnly": "node scripts/publish-guard.cjs && pnpm build",
|
|
36
38
|
"test": "node --test tests/build-verify.mjs"
|
|
37
39
|
},
|