@shotstack/shotstack-canvas 2.0.11 → 2.0.13

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.
@@ -618,6 +618,7 @@ var richCaptionAssetSchema = import_zod.z.object({
618
618
  align: canvasAlignmentSchema.optional(),
619
619
  active: richCaptionActiveSchema.optional(),
620
620
  wordAnimation: richCaptionWordAnimationSchema.optional(),
621
+ pauseThreshold: import_zod.z.number().min(0).default(500).optional(),
621
622
  customFonts: import_zod.z.array(customFontSchema).optional()
622
623
  }).superRefine((data, ctx) => {
623
624
  if (!data.src && !data.words) {
@@ -1219,10 +1220,9 @@ var FontRegistry = class _FontRegistry {
1219
1220
  return;
1220
1221
  }
1221
1222
  try {
1222
- const moduleName = "canvas";
1223
1223
  const canvasMod = await import(
1224
1224
  /* @vite-ignore */
1225
- moduleName
1225
+ "canvas"
1226
1226
  );
1227
1227
  const GlobalFonts = canvasMod.GlobalFonts;
1228
1228
  if (GlobalFonts && typeof GlobalFonts.register === "function") {
@@ -5760,7 +5760,19 @@ var NodeRawEncoder = class _NodeRawEncoder {
5760
5760
  this.ffmpegProcess.on("error", (err) => {
5761
5761
  this.ffmpegError = err;
5762
5762
  });
5763
- this.ffmpegProcess.stderr?.on("data", () => {
5763
+ let stderrOutput = "";
5764
+ this.ffmpegProcess.stderr?.on("data", (data) => {
5765
+ stderrOutput += data.toString();
5766
+ });
5767
+ this.ffmpegProcess.on("close", (code) => {
5768
+ if (code !== 0 && stderrOutput) {
5769
+ this.ffmpegError = new Error(`FFmpeg exited with code ${code}: ${stderrOutput.slice(-500)}`);
5770
+ }
5771
+ });
5772
+ this.ffmpegProcess.stdin?.on("error", (err) => {
5773
+ if (!this.ffmpegError) {
5774
+ this.ffmpegError = new Error(`FFmpeg stdin error: ${err.message}. stderr: ${stderrOutput.slice(-500)}`);
5775
+ }
5764
5776
  });
5765
5777
  }
5766
5778
  async encodeFrame(frameData, _frameIndex) {
@@ -5975,7 +5987,7 @@ var RichCaptionRenderer = class {
5975
5987
  wordSpacing: typeof style?.wordSpacing === "number" ? style.wordSpacing : 0,
5976
5988
  lineHeight,
5977
5989
  textTransform: style?.textTransform ?? "none",
5978
- pauseThreshold: 500,
5990
+ pauseThreshold: this.currentAsset?.pauseThreshold ?? 500,
5979
5991
  measureTextWidth
5980
5992
  };
5981
5993
  this.currentLayout = await this.layoutEngine.layoutCaption(words, layoutConfig);
@@ -372,6 +372,7 @@ declare const richCaptionAssetSchema: z.ZodObject<{
372
372
  down: "down";
373
373
  }>>;
374
374
  }, z.core.$strict>>;
375
+ pauseThreshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
375
376
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
376
377
  src: z.ZodString;
377
378
  family: z.ZodString;
@@ -497,6 +498,7 @@ declare const CanvasRichCaptionAssetSchema: z.ZodObject<{
497
498
  down: "down";
498
499
  }>>;
499
500
  }, z.core.$strict>>;
501
+ pauseThreshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
500
502
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
501
503
  src: z.ZodString;
502
504
  family: z.ZodString;
@@ -372,6 +372,7 @@ declare const richCaptionAssetSchema: z.ZodObject<{
372
372
  down: "down";
373
373
  }>>;
374
374
  }, z.core.$strict>>;
375
+ pauseThreshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
375
376
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
376
377
  src: z.ZodString;
377
378
  family: z.ZodString;
@@ -497,6 +498,7 @@ declare const CanvasRichCaptionAssetSchema: z.ZodObject<{
497
498
  down: "down";
498
499
  }>>;
499
500
  }, z.core.$strict>>;
501
+ pauseThreshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
500
502
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
501
503
  src: z.ZodString;
502
504
  family: z.ZodString;
@@ -222,6 +222,7 @@ var richCaptionAssetSchema = z.object({
222
222
  align: canvasAlignmentSchema.optional(),
223
223
  active: richCaptionActiveSchema.optional(),
224
224
  wordAnimation: richCaptionWordAnimationSchema.optional(),
225
+ pauseThreshold: z.number().min(0).default(500).optional(),
225
226
  customFonts: z.array(customFontSchema).optional()
226
227
  }).superRefine((data, ctx) => {
227
228
  if (!data.src && !data.words) {
@@ -822,10 +823,9 @@ var FontRegistry = class _FontRegistry {
822
823
  return;
823
824
  }
824
825
  try {
825
- const moduleName = "canvas";
826
826
  const canvasMod = await import(
827
827
  /* @vite-ignore */
828
- moduleName
828
+ "canvas"
829
829
  );
830
830
  const GlobalFonts = canvasMod.GlobalFonts;
831
831
  if (GlobalFonts && typeof GlobalFonts.register === "function") {
@@ -5363,7 +5363,19 @@ var NodeRawEncoder = class _NodeRawEncoder {
5363
5363
  this.ffmpegProcess.on("error", (err) => {
5364
5364
  this.ffmpegError = err;
5365
5365
  });
5366
- this.ffmpegProcess.stderr?.on("data", () => {
5366
+ let stderrOutput = "";
5367
+ this.ffmpegProcess.stderr?.on("data", (data) => {
5368
+ stderrOutput += data.toString();
5369
+ });
5370
+ this.ffmpegProcess.on("close", (code) => {
5371
+ if (code !== 0 && stderrOutput) {
5372
+ this.ffmpegError = new Error(`FFmpeg exited with code ${code}: ${stderrOutput.slice(-500)}`);
5373
+ }
5374
+ });
5375
+ this.ffmpegProcess.stdin?.on("error", (err) => {
5376
+ if (!this.ffmpegError) {
5377
+ this.ffmpegError = new Error(`FFmpeg stdin error: ${err.message}. stderr: ${stderrOutput.slice(-500)}`);
5378
+ }
5367
5379
  });
5368
5380
  }
5369
5381
  async encodeFrame(frameData, _frameIndex) {
@@ -5578,7 +5590,7 @@ var RichCaptionRenderer = class {
5578
5590
  wordSpacing: typeof style?.wordSpacing === "number" ? style.wordSpacing : 0,
5579
5591
  lineHeight,
5580
5592
  textTransform: style?.textTransform ?? "none",
5581
- pauseThreshold: 500,
5593
+ pauseThreshold: this.currentAsset?.pauseThreshold ?? 500,
5582
5594
  measureTextWidth
5583
5595
  };
5584
5596
  this.currentLayout = await this.layoutEngine.layoutCaption(words, layoutConfig);
@@ -372,6 +372,7 @@ declare const richCaptionAssetSchema: z.ZodObject<{
372
372
  down: "down";
373
373
  }>>;
374
374
  }, z.core.$strict>>;
375
+ pauseThreshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
375
376
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
376
377
  src: z.ZodString;
377
378
  family: z.ZodString;
@@ -497,6 +498,7 @@ declare const CanvasRichCaptionAssetSchema: z.ZodObject<{
497
498
  down: "down";
498
499
  }>>;
499
500
  }, z.core.$strict>>;
501
+ pauseThreshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
500
502
  customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
501
503
  src: z.ZodString;
502
504
  family: z.ZodString;
package/dist/entry.web.js CHANGED
@@ -18100,6 +18100,7 @@ var richCaptionAssetSchema = external_exports.object({
18100
18100
  align: canvasAlignmentSchema.optional(),
18101
18101
  active: richCaptionActiveSchema.optional(),
18102
18102
  wordAnimation: richCaptionWordAnimationSchema.optional(),
18103
+ pauseThreshold: external_exports.number().min(0).default(500).optional(),
18103
18104
  customFonts: external_exports.array(customFontSchema).optional()
18104
18105
  }).superRefine((data, ctx) => {
18105
18106
  if (!data.src && !data.words) {
@@ -32090,11 +32091,7 @@ var _FontRegistry = class _FontRegistry {
32090
32091
  return;
32091
32092
  }
32092
32093
  try {
32093
- const moduleName = "canvas";
32094
- const canvasMod = await import(
32095
- /* @vite-ignore */
32096
- moduleName
32097
- );
32094
+ const canvasMod = { GlobalFonts: void 0 };
32098
32095
  const GlobalFonts = canvasMod.GlobalFonts;
32099
32096
  if (GlobalFonts && typeof GlobalFonts.register === "function") {
32100
32097
  const buffer = Buffer.from(bytes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotstack/shotstack-canvas",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
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",