@bendyline/squisq-cli 2.0.0 → 2.0.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.
@@ -1,24 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ CapturedFrameBudgetError,
3
4
  ConversionError,
5
+ MAX_CAPTURED_FRAME_BYTES,
4
6
  MemoryContentContainer,
5
7
  convert,
6
8
  createCliRegistry,
7
9
  extractThumbnails,
10
+ prepareConversion,
8
11
  readInput,
9
12
  renderDocToGif,
10
13
  renderDocToMp4
11
- } from "./chunk-JEE26SZS.js";
14
+ } from "./chunk-FVFK4ZJU.js";
12
15
  import {
13
16
  GIF_EXPORT_DEFAULTS,
14
17
  framesToGifNative,
15
18
  framesToGifNativeBytes,
16
19
  framesToMp4Native,
17
20
  framesToMp4NativeBytes
18
- } from "./chunk-VM3ZFP3J.js";
21
+ } from "./chunk-JDHONKFZ.js";
19
22
  export {
23
+ CapturedFrameBudgetError,
20
24
  ConversionError,
21
25
  GIF_EXPORT_DEFAULTS,
26
+ MAX_CAPTURED_FRAME_BYTES,
22
27
  MemoryContentContainer,
23
28
  convert,
24
29
  createCliRegistry,
@@ -27,8 +32,9 @@ export {
27
32
  framesToGifNativeBytes,
28
33
  framesToMp4Native,
29
34
  framesToMp4NativeBytes,
35
+ prepareConversion,
30
36
  readInput,
31
37
  renderDocToGif,
32
38
  renderDocToMp4
33
39
  };
34
- //# sourceMappingURL=api-6KN3F6IQ.js.map
40
+ //# sourceMappingURL=api-LE75OSRQ.js.map
package/dist/api.d.ts CHANGED
@@ -3,8 +3,8 @@ import { ContentContainer } from '@bendyline/squisq/storage';
3
3
  export { MemoryContentContainer } from '@bendyline/squisq/storage';
4
4
  import { VideoQuality, VideoOrientation, GifDither, VideoExportOptions } from '@bendyline/squisq-video';
5
5
  export { GifDither, VideoOrientation, VideoQuality } from '@bendyline/squisq-video';
6
- import { FormatRegistry, FormatId, ConvertOptions, ConvertSource, ConversionResult } from '@bendyline/squisq-formats';
7
- export { ConversionError, ConversionErrorCode, ConversionErrorOptions, ConversionResult, ConvertOptions, ConvertSource, FormatDefinition, FormatId, FormatRegistry, NormalizedInput } from '@bendyline/squisq-formats';
6
+ import { FormatRegistry, FormatId, ConvertOptions, ConvertSource, ConversionResult, PreparedConversion } from '@bendyline/squisq-formats';
7
+ export { ConversionError, ConversionErrorCode, ConversionErrorOptions, ConversionResult, ConvertOptions, ConvertSource, FormatDefinition, FormatId, FormatRegistry, NormalizedInput, PreparedConversion, PreparedExportOptions } from '@bendyline/squisq-formats';
8
8
  import { MarkdownDocument } from '@bendyline/squisq/markdown';
9
9
 
10
10
  /**
@@ -17,6 +17,7 @@ import { MarkdownDocument } from '@bendyline/squisq/markdown';
17
17
  */
18
18
 
19
19
  interface Mp4FormatOptions {
20
+ onProgress?: (phase: string, percent: number) => void;
20
21
  fps?: number;
21
22
  quality?: VideoQuality;
22
23
  orientation?: VideoOrientation;
@@ -28,6 +29,7 @@ interface Mp4FormatOptions {
28
29
  }
29
30
  /** Per-export options for `convert(..., 'gif')`. */
30
31
  interface GifFormatOptions {
32
+ onProgress?: (phase: string, percent: number) => void;
31
33
  fps?: number;
32
34
  orientation?: VideoOrientation;
33
35
  width?: number;
@@ -77,6 +79,8 @@ interface ReadInputResult {
77
79
  sourceFormat: FormatId;
78
80
  }
79
81
  interface ReadInputOptions {
82
+ /** Cancel filesystem traversal, import, or audio resolution at a bounded boundary. */
83
+ signal?: AbortSignal;
80
84
  /**
81
85
  * Infer a Squisq theme from an OOXML source's theme part (PPTX today).
82
86
  * Default true — the importer carries it as frontmatter.
@@ -92,6 +96,24 @@ interface ReadInputOptions {
92
96
  */
93
97
  declare function readInput(inputPath: string, options?: ReadInputOptions): Promise<ReadInputResult>;
94
98
 
99
+ /**
100
+ * Hard retained-memory ceiling for PNG frames captured before native encoding.
101
+ *
102
+ * The Node renderer currently keeps captured PNGs in memory while FFmpeg is
103
+ * prepared. Bounding the actual encoded PNG bytes prevents visually complex
104
+ * documents from exhausting the process even when their dimensions and frame
105
+ * counts satisfy higher-level render budgets.
106
+ */
107
+ declare const MAX_CAPTURED_FRAME_BYTES: number;
108
+ /** Stable failure raised before another captured frame is retained. */
109
+ declare class CapturedFrameBudgetError extends Error {
110
+ readonly capturedBytes: number;
111
+ readonly attemptedFrameBytes: number;
112
+ readonly maximumBytes: number;
113
+ readonly code = "captured-frame-budget-exceeded";
114
+ constructor(capturedBytes: number, attemptedFrameBytes: number, maximumBytes: number);
115
+ }
116
+
95
117
  /**
96
118
  * Native FFmpeg Encoder
97
119
  *
@@ -103,8 +125,14 @@ declare function readInput(inputPath: string, options?: ReadInputOptions): Promi
103
125
  * callers use the WebCodecs/ffmpeg.wasm paths in the video packages instead.
104
126
  */
105
127
 
128
+ /** Node-native video options with cooperative and child-process cancellation. */
129
+ interface NativeVideoExportOptions extends VideoExportOptions {
130
+ signal?: AbortSignal;
131
+ }
106
132
  /** Options for native animated-GIF encoding. */
107
133
  interface GifExportOptions {
134
+ /** Cancel staging or encoding and terminate the native FFmpeg process. */
135
+ signal?: AbortSignal;
108
136
  /** Frames per second (default: 10; GIF timing is centisecond-based). */
109
137
  fps?: number;
110
138
  /** Output width in pixels (default: 960 landscape / 540 portrait). */
@@ -142,12 +170,12 @@ declare const GIF_EXPORT_DEFAULTS: {
142
170
  * @param outputPath - Where to write the final MP4
143
171
  * @param options - Encoding options (fps, quality, dimensions, progress)
144
172
  */
145
- declare function framesToMp4Native(ffmpegPath: string, frames: Uint8Array[], audio: Uint8Array | null, outputPath: string, options?: VideoExportOptions): Promise<void>;
173
+ declare function framesToMp4Native(ffmpegPath: string, frames: Uint8Array[], audio: Uint8Array | null, outputPath: string, options?: NativeVideoExportOptions): Promise<void>;
146
174
  /**
147
175
  * Encode frames using native ffmpeg and return the MP4 bytes (instead of writing to disk).
148
176
  * Useful when the caller needs the bytes in memory.
149
177
  */
150
- declare function framesToMp4NativeBytes(ffmpegPath: string, frames: Uint8Array[], audio: Uint8Array | null, options?: VideoExportOptions): Promise<Uint8Array>;
178
+ declare function framesToMp4NativeBytes(ffmpegPath: string, frames: Uint8Array[], audio: Uint8Array | null, options?: NativeVideoExportOptions): Promise<Uint8Array>;
151
179
  /**
152
180
  * Encode PNG frames to an animated GIF using native FFmpeg.
153
181
  *
@@ -212,8 +240,12 @@ type CliConvertOptions = Omit<ConvertOptions, 'formatOptions'> & {
212
240
  * @throws {@link ConversionError} on any failure, with a stable `code`.
213
241
  */
214
242
  declare function convert(source: ConvertSource, to: FormatId, options?: CliConvertOptions): Promise<ConversionResult>;
243
+ /** Normalize and transform once using the CLI registry, then export one or more targets. */
244
+ declare function prepareConversion(source: ConvertSource, options?: CliConvertOptions): Promise<PreparedConversion>;
215
245
  /** Options for renderDocToMp4. */
216
246
  interface RenderDocToMp4Options {
247
+ /** Cancel capture/encoding and terminate browser and FFmpeg work. */
248
+ signal?: AbortSignal;
217
249
  /** Output file path for the MP4. */
218
250
  outputPath: string;
219
251
  /** Frames per second (default: 30). */
@@ -245,6 +277,8 @@ interface RenderDocToMp4Options {
245
277
  }
246
278
  /** Options for rendering a document to an animated GIF. */
247
279
  interface RenderDocToGifOptions {
280
+ /** Cancel capture/encoding and terminate browser and FFmpeg work. */
281
+ signal?: AbortSignal;
248
282
  /** Output file path for the GIF. */
249
283
  outputPath: string;
250
284
  /** Frames per second (default: 10). */
@@ -303,7 +337,7 @@ interface ThumbnailSpec {
303
337
  }
304
338
  /** Options for extractThumbnails. */
305
339
  interface ExtractThumbnailsOptions {
306
- /** Path to the source MP4 video. */
340
+ /** Path to the source MP4 or animated GIF. */
307
341
  videoPath: string;
308
342
  /** Directory to write thumbnails into. */
309
343
  outputDir: string;
@@ -313,11 +347,13 @@ interface ExtractThumbnailsOptions {
313
347
  sizes: ThumbnailSpec[];
314
348
  /** Overwrite existing thumbnails (default: false). */
315
349
  force?: boolean;
350
+ /** Cancels FFmpeg and rejects with the caller's exact abort reason. */
351
+ signal?: AbortSignal;
316
352
  }
317
353
  /**
318
- * Extract thumbnail images from the first frame of an MP4 video.
354
+ * Extract thumbnail images from the first frame of an MP4 or animated GIF.
319
355
  * Produces JPEG files at each specified size using FFmpeg video filters.
320
356
  */
321
357
  declare function extractThumbnails(options: ExtractThumbnailsOptions): Promise<void>;
322
358
 
323
- export { type CliConvertOptions, type ExtractThumbnailsOptions, GIF_EXPORT_DEFAULTS, type GifExportOptions, type GifFormatOptions, type Mp4FormatOptions, type ReadInputResult, type RenderDocToGifOptions, type RenderDocToGifResult, type RenderDocToMp4Options, type RenderDocToMp4Result, type ThumbnailSpec, convert, createCliRegistry, extractThumbnails, framesToGifNative, framesToGifNativeBytes, framesToMp4Native, framesToMp4NativeBytes, readInput, renderDocToGif, renderDocToMp4 };
359
+ export { CapturedFrameBudgetError, type CliConvertOptions, type ExtractThumbnailsOptions, GIF_EXPORT_DEFAULTS, type GifExportOptions, type GifFormatOptions, MAX_CAPTURED_FRAME_BYTES, type Mp4FormatOptions, type NativeVideoExportOptions, type ReadInputResult, type RenderDocToGifOptions, type RenderDocToGifResult, type RenderDocToMp4Options, type RenderDocToMp4Result, type ThumbnailSpec, convert, createCliRegistry, extractThumbnails, framesToGifNative, framesToGifNativeBytes, framesToMp4Native, framesToMp4NativeBytes, prepareConversion, readInput, renderDocToGif, renderDocToMp4 };