@shotstack/shotstack-canvas 2.0.9 → 2.0.11

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.
@@ -263,7 +263,7 @@ declare const richCaptionAssetSchema: z.ZodObject<{
263
263
  start: z.ZodNumber;
264
264
  end: z.ZodNumber;
265
265
  confidence: z.ZodOptional<z.ZodNumber>;
266
- }, z.core.$strict>>>;
266
+ }, z.core.$strip>>>;
267
267
  font: z.ZodOptional<z.ZodObject<{
268
268
  family: z.ZodDefault<z.ZodString>;
269
269
  size: z.ZodDefault<z.ZodNumber>;
@@ -316,6 +316,12 @@ declare const richCaptionAssetSchema: z.ZodObject<{
316
316
  color: z.ZodOptional<z.ZodString>;
317
317
  opacity: z.ZodDefault<z.ZodNumber>;
318
318
  }, z.core.$strict>>;
319
+ border: z.ZodOptional<z.ZodObject<{
320
+ width: z.ZodDefault<z.ZodNumber>;
321
+ color: z.ZodDefault<z.ZodString>;
322
+ opacity: z.ZodDefault<z.ZodNumber>;
323
+ radius: z.ZodDefault<z.ZodNumber>;
324
+ }, z.core.$strip>>;
319
325
  padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
320
326
  top: z.ZodDefault<z.ZodNumber>;
321
327
  right: z.ZodDefault<z.ZodNumber>;
@@ -366,13 +372,6 @@ declare const richCaptionAssetSchema: z.ZodObject<{
366
372
  down: "down";
367
373
  }>>;
368
374
  }, z.core.$strict>>;
369
- position: z.ZodDefault<z.ZodEnum<{
370
- center: "center";
371
- top: "top";
372
- bottom: "bottom";
373
- }>>;
374
- maxWidth: z.ZodDefault<z.ZodNumber>;
375
- maxLines: z.ZodDefault<z.ZodNumber>;
376
375
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
377
376
  src: z.ZodString;
378
377
  family: z.ZodString;
@@ -389,7 +388,7 @@ declare const CanvasRichCaptionAssetSchema: z.ZodObject<{
389
388
  start: z.ZodNumber;
390
389
  end: z.ZodNumber;
391
390
  confidence: z.ZodOptional<z.ZodNumber>;
392
- }, z.core.$strict>>>;
391
+ }, z.core.$strip>>>;
393
392
  font: z.ZodOptional<z.ZodObject<{
394
393
  family: z.ZodDefault<z.ZodString>;
395
394
  size: z.ZodDefault<z.ZodNumber>;
@@ -442,6 +441,12 @@ declare const CanvasRichCaptionAssetSchema: z.ZodObject<{
442
441
  color: z.ZodOptional<z.ZodString>;
443
442
  opacity: z.ZodDefault<z.ZodNumber>;
444
443
  }, z.core.$strict>>;
444
+ border: z.ZodOptional<z.ZodObject<{
445
+ width: z.ZodDefault<z.ZodNumber>;
446
+ color: z.ZodDefault<z.ZodString>;
447
+ opacity: z.ZodDefault<z.ZodNumber>;
448
+ radius: z.ZodDefault<z.ZodNumber>;
449
+ }, z.core.$strip>>;
445
450
  padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
446
451
  top: z.ZodDefault<z.ZodNumber>;
447
452
  right: z.ZodDefault<z.ZodNumber>;
@@ -492,13 +497,6 @@ declare const CanvasRichCaptionAssetSchema: z.ZodObject<{
492
497
  down: "down";
493
498
  }>>;
494
499
  }, z.core.$strict>>;
495
- position: z.ZodDefault<z.ZodEnum<{
496
- center: "center";
497
- top: "top";
498
- bottom: "bottom";
499
- }>>;
500
- maxWidth: z.ZodDefault<z.ZodNumber>;
501
- maxLines: z.ZodDefault<z.ZodNumber>;
502
500
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
503
501
  src: z.ZodString;
504
502
  family: z.ZodString;
@@ -603,9 +601,11 @@ interface WordTiming {
603
601
  interface CaptionLayoutConfig {
604
602
  frameWidth: number;
605
603
  frameHeight: number;
606
- maxWidth: number;
604
+ availableWidth: number;
607
605
  maxLines: number;
608
- position: "top" | "center" | "bottom";
606
+ verticalAlign: "top" | "middle" | "bottom";
607
+ horizontalAlign: "left" | "center" | "right";
608
+ paddingLeft: number;
609
609
  fontSize: number;
610
610
  fontFamily: string;
611
611
  fontWeight: string | number;
@@ -1040,6 +1040,11 @@ declare function renderSvgAssetToPng(asset: CanvasSvgAsset, options?: {
1040
1040
  background?: string;
1041
1041
  }): Promise<ResvgRenderResult>;
1042
1042
 
1043
+ declare const ASCENT_RATIO = 0.8;
1044
+ declare const DESCENT_RATIO = 0.2;
1045
+ declare const WORD_BG_OPACITY = 1;
1046
+ declare const WORD_BG_BORDER_RADIUS = 4;
1047
+ declare const WORD_BG_PADDING_RATIO = 0.12;
1043
1048
  interface RichCaptionGeneratorConfig {
1044
1049
  frameWidth: number;
1045
1050
  frameHeight: number;
@@ -1073,7 +1078,13 @@ interface BackgroundConfig {
1073
1078
  borderRadius: number;
1074
1079
  padding: number;
1075
1080
  }
1076
- declare function generateRichCaptionDrawOps(asset: CanvasRichCaptionAsset, layout: CaptionLayout, frameTimeMs: number, layoutEngine: CaptionLayoutEngine, _config: RichCaptionGeneratorConfig): DrawOp[];
1081
+ declare function extractCaptionPadding(asset: CanvasRichCaptionAsset): {
1082
+ top: number;
1083
+ right: number;
1084
+ bottom: number;
1085
+ left: number;
1086
+ };
1087
+ declare function generateRichCaptionDrawOps(asset: CanvasRichCaptionAsset, layout: CaptionLayout, frameTimeMs: number, layoutEngine: CaptionLayoutEngine, config: RichCaptionGeneratorConfig): DrawOp[];
1077
1088
  declare function generateRichCaptionFrame(asset: CanvasRichCaptionAsset, layout: CaptionLayout, frameTimeMs: number, layoutEngine: CaptionLayoutEngine, config: RichCaptionGeneratorConfig): {
1078
1089
  ops: DrawOp[];
1079
1090
  visibleWordCount: number;
@@ -1261,4 +1272,4 @@ declare function createTextEngine(opts?: {
1261
1272
  destroy(): void;
1262
1273
  }>;
1263
1274
 
1264
- export { 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, 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 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, WebCodecsEncoder, type WordAnimationConfig, type WordAnimationState, type WordTiming, WordTimingStore, arcToCubicBeziers, breakIntoLines, calculateAnimationStatesForGroup, commandsToPathString, computeSimplePathBounds, createDefaultGeneratorConfig, createFrameSchedule, createMediaRecorderFallback, createTextEngine, createVideoEncoder, createWebCodecsEncoder, createWebPainter, detectPlatform, detectSubtitleFormat, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, groupWordsByPause, initResvg, isDrawCaptionWordOp, isMediaRecorderSupported, isRTLText, isWebCodecsH264Supported, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, richCaptionAssetSchema, shapeToSvgString };
1275
+ 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 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, createDefaultGeneratorConfig, createFrameSchedule, createMediaRecorderFallback, createTextEngine, createVideoEncoder, createWebCodecsEncoder, createWebPainter, detectPlatform, detectSubtitleFormat, extractCaptionPadding, findWordAtTime, generateRichCaptionDrawOps, generateRichCaptionFrame, generateShapePathData, getDefaultAnimationConfig, getDrawCaptionWordOps, getEncoderCapabilities, getEncoderWarning, groupWordsByPause, initResvg, isDrawCaptionWordOp, isMediaRecorderSupported, isRTLText, isWebCodecsH264Supported, normalizePath, normalizePathString, parseSubtitleToWords, parseSvgPath, quadraticToCubic, renderSvgAssetToPng, renderSvgToPng, richCaptionAssetSchema, shapeToSvgString };