captions.js 0.4.0 → 0.4.2

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/README.md CHANGED
@@ -1,92 +1,39 @@
1
- # 📖 captions.js Monorepo Scripts Cheat Sheet
1
+ > [!WARNING]
2
+ > 🚧 **Captions.js is nearing its first public release**
3
+ > The library is under active development and a full-featured version is expected around **November 2025**.
2
4
 
3
- This cheat sheet summarizes all the key scripts for working with the `captions.js` monorepo. Use `pnpm` to run scripts in individual packages.
5
+ 💌 Want to know when Captions.js is released?
6
+ Star or watch the repo on GitHub to get updates!
4
7
 
5
- ---
8
+ # Captions.js
6
9
 
7
- ## 🌟 General `pnpm` Commands
10
+ Render styled animated captions on canvas — works both on client and server side using Node.js and FFmpeg.
8
11
 
9
- | Command | Description |
10
- | ------------------------------------------- | ------------------------------------------------------------ |
11
- | `pnpm install` | Installs all dependencies for all packages in the monorepo. |
12
- | `pnpm --filter <package> run <script>` | Runs a script `<script>` for a specific package `<package>`. |
13
- | `pnpm build` | Builds all packages that have a `build` script. |
14
- | `pnpm clean` | Cleans build artifacts if a `clean` script is defined. |
12
+ [**Live Demo**](https://maskin25.github.io/captions.js/)
15
13
 
16
- > **Note:** `<package>` refers to the package name in `packages/`, e.g., `@captions/core`, `captions-demo`, or `captions-storybook`.
14
+ [**Docs & API Reference**](https://maskin25.github.io/captions.js/docs/)
17
15
 
18
- ---
16
+ <!-- [![Storybook](https://raw.githubusercontent.com/storybookjs/brand/refs/heads/main/badge/badge-storybook.svg)](https://main--68e681805917843931c33a87.chromatic.com/) -->
19
17
 
20
- ## 📦 Package: `@captions/core`
18
+ ## Features
21
19
 
22
- | Script | Command | Description |
23
- | ------- | ----------------------------------------- | ------------------------------------------------------------------------ |
24
- | `build` | `pnpm --filter @captions/core run build` | Builds the library using `tsup` (CJS, ESM, and TypeScript declarations). |
25
- | `clean` | `pnpm --filter @captions/core run clean` | Deletes the build folder (`dist`). |
20
+ - **Easy Integration**: Simple API to add captions to your videos.
21
+ - **Customizable Styles**: Fully customizable caption styles via configurations.
22
+ - **Multiple Formats**: Supports various caption formats including WebVTT and SRT.
23
+ - **Responsive Design**: Captions adapt to different screen sizes and orientations.
26
24
 
27
- **Example:**
28
- ```bash
29
- pnpm --filter @captions/core run build
30
- ```
31
-
32
- ---
25
+ ## Installation
33
26
 
34
- ## 🎨 Demo App: `captions-demo`
27
+ To install Captions.js, use npm or yarn:
35
28
 
36
- | Script | Command | Description |
37
- | --------- | --------------------------------------- | ------------------------------------------------------------------ |
38
- | `dev` | `pnpm --filter captions-demo run dev` | Runs the demo locally with Vite (default: `http://localhost:5173`). |
39
- | `build` | `pnpm --filter captions-demo run build` | Builds the demo for production into the `dist` folder. |
40
- | `preview` | `pnpm --filter captions-demo run preview` | Serves the built demo locally for preview. |
41
-
42
- **Example:**
43
29
  ```bash
44
- pnpm --filter captions-demo run dev
30
+ npm install captions.js
45
31
  ```
46
32
 
47
- ---
48
-
49
- ## 📚 Storybook: `captions-storybook`
50
-
51
- | Script | Command | Description |
52
- | ----------------- | ------------------------------------------------- | ---------------------------------------------------------- |
53
- | `storybook` | `pnpm --filter captions-storybook run storybook` | Runs Storybook locally with Vite (`http://localhost:6006`). |
54
- | `build-storybook` | `pnpm --filter captions-storybook run build-storybook` | Builds a static Storybook site into `storybook-static`. |
55
- | `deploy` | `pnpm --filter captions-storybook run deploy` | Builds and deploys Storybook to GitHub Pages. |
33
+ or
56
34
 
57
- **Example:**
58
35
  ```bash
59
- pnpm --filter captions-storybook run storybook
36
+ yarn add captions.js
60
37
  ```
61
38
 
62
- ---
63
-
64
- ## ⚡ Tips & Recommendations
65
-
66
- 1. **Targeted Scripts:** Always run scripts using `pnpm --filter` to ensure you're using the correct local binaries for that package.
67
- ```bash
68
- pnpm --filter <package> run <script>
69
- ```
70
-
71
- 2. **Troubleshooting:** If you encounter issues after updating packages, run this sequence to perform a clean reinstall:
72
- ```bash
73
- # Clean up all node_modules and lockfile
74
- rm -rf node_modules packages/*/node_modules
75
- rm pnpm-lock.yaml
76
-
77
- # Prune the pnpm store and reinstall
78
- pnpm store prune
79
- pnpm install
80
- ```
81
-
82
- 3. **Global Build Script (Optional):** For convenience, you can add a global `build` script to the root `package.json` to build the entire monorepo with one command.
83
-
84
- ```json
85
- "scripts": {
86
- "build": "pnpm --filter @captions/core run build && pnpm --filter captions-demo run build && pnpm --filter captions-storybook run build-storybook"
87
- }
88
- ```
89
- Then, you can simply run:
90
- ```bash
91
- pnpm run build
92
- ```
39
+ For development see [DEVELOPMENT.md](./DEVELOPMENT.md).
package/dist/index.d.mts CHANGED
@@ -1,3 +1,262 @@
1
+ import Konva from 'konva';
2
+
3
+ /**
4
+ * Whitelisted Google Fonts that the renderer knows how to lazy-load.
5
+ *
6
+ * @remarks
7
+ * Restricting the list keeps bundle size predictable across consumers.
8
+ *
9
+ * @public
10
+ */
11
+ declare const googleFontsList: readonly ["Roboto", "Open Sans", "Lato", "Montserrat", "Nunito", "Poppins", "Ubuntu", "PT Sans", "Merriweather Sans", "Lobster", "Amatic SC", "Pacifico", "Raleway", "Cinzel", "Quicksand", "Zilla Slab", "Caveat", "Crimson Pro", "Bebas Neue", "Comfortaa", "Satisfy", "Permanent Marker", "Oswald", "Onset", "Bangers", "Kanit", "Work Sans", "Fira Sans", "Anton", "Playfair Display", "Rubik", "Alumni Sans", "Righteous", "Comico", "Excon", "Kalam", "Tanker", "Arsenal", "Balsamiq Sans", "Bona Nova SC"];
12
+
13
+ /**
14
+ * Shared schema describing how a preset styles captions plus rough layout hints.
15
+ *
16
+ * @public
17
+ */
18
+ interface StylePreset {
19
+ id: number;
20
+ captionsSettings: {
21
+ style: {
22
+ font: {
23
+ italic: boolean;
24
+ fontSize: number;
25
+ fontColor: string;
26
+ underline: boolean;
27
+ fontFamily: string;
28
+ fontWeight: string;
29
+ fontCapitalize: boolean;
30
+ fontStrokeColor: string;
31
+ fontStrokeWidth: number;
32
+ shadow?: {
33
+ fontShadowBlur: number;
34
+ fontShadowColor: string;
35
+ fontShadowOffsetX: number;
36
+ fontShadowOffsetY: number;
37
+ };
38
+ };
39
+ name: string;
40
+ backgroundColor: string;
41
+ verticalCoverImg: string;
42
+ aplifiedWordColor: string;
43
+ };
44
+ position: string;
45
+ animation: string;
46
+ linesPerPage: number;
47
+ positionTopOffset?: number;
48
+ };
49
+ layoutSettings: {
50
+ aspectRatio: string;
51
+ aIAutoLayout: string[];
52
+ fitLayoutAspectRatio: string;
53
+ };
54
+ }
55
+ /**
56
+ * Names of all available style presets.
57
+ */
58
+ type StylePresetName = "Karaoke" | "Beasty" | "Safari" | "Acid" | "Popline" | "Desert" | "Hook" | "Sky" | "Flamingo" | "Deep Diver B&W" | "New" | "Banger" | "Catchy" | "Karaoke 2" | "Karaoke 3" | "From" | "Classic" | "Classic Big" | "Crazy" | "Acid 2" | "Marvel" | "Lovly" | "Old Money" | "Cinema" | "Marker";
59
+ /**
60
+ * Curated set of presets that ship with captions.js out of the box.
61
+ *
62
+ * @remarks
63
+ * Downstream apps can reference them directly or clone/extend as needed.
64
+ *
65
+ * @public
66
+ */
67
+ declare const stylePresets: StylePreset[];
68
+
69
+ /**
70
+ * Server/worker-friendly helper that paints a text string onto a provided canvas.
71
+ *
72
+ * @remarks
73
+ * Uses the same Konva pipeline as the video overlay renderer so the results
74
+ * match what users see in the browser.
75
+ *
76
+ * @param canvas - Destination canvas that should receive the rendered text.
77
+ * @param text - Arbitrary content that needs to be painted.
78
+ * @param options - Rendering options that include the style preset.
79
+ * @returns Resolves once the frame has been painted (always resolves to `true`).
80
+ */
81
+ declare function renderString(canvas: HTMLCanvasElement, text: string, options: {
82
+ preset: StylePreset;
83
+ }): Promise<boolean>;
84
+
85
+ /**
86
+ * Full styling + animation configuration for a single captions track.
87
+ *
88
+ * @public
89
+ */
90
+ interface CaptionsSettings {
91
+ style: {
92
+ name: string;
93
+ font: {
94
+ fontFamily: string;
95
+ fontSize: number;
96
+ fontWeight: "thin" | "light" | "regular" | "medium" | "bold" | "black";
97
+ fontColor: string;
98
+ fontCapitalize: boolean;
99
+ italic: boolean;
100
+ underline: boolean;
101
+ fontStrokeColor: string;
102
+ fontStrokeWidth: number;
103
+ shadow: {
104
+ fontShadowColor: string;
105
+ fontShadowBlur: number;
106
+ fontShadowOffsetX: number;
107
+ fontShadowOffsetY: number;
108
+ };
109
+ };
110
+ aplifiedWordColor: string;
111
+ backgroundColor: string;
112
+ };
113
+ linesPerPage: number;
114
+ lineSpacing?: number | null;
115
+ position: "auto" | "top" | "middle" | "bottom";
116
+ positionTopOffset: number;
117
+ animation: "none" | "bounce" | "underline" | "box" | "pop" | "scale" | "slide-left" | "slide-up" | "slide-down" | "box-word";
118
+ }
119
+ /**
120
+ * Single timed word/segment that will be highlighted as audio plays.
121
+ *
122
+ * @public
123
+ */
124
+ interface Caption {
125
+ word: string;
126
+ startTime: number;
127
+ endTime: number;
128
+ highlightColor?: string;
129
+ }
130
+
131
+ /**
132
+ * Configuration passed to the captions runtime when binding to a video element.
133
+ *
134
+ * @public
135
+ */
136
+ type CaptionsOptions = {
137
+ /** Video element that should receive overlays. */
138
+ video: HTMLVideoElement;
139
+ /** Optional custom container to host the Konva stage. */
140
+ container?: HTMLDivElement;
141
+ /** Initial preset controlling font, colors, animations. */
142
+ preset: StylePreset;
143
+ /** Initial caption track. */
144
+ captions?: Caption[] | null;
145
+ /** When false, caller must invoke {@link Captions.enable} manually. */
146
+ autoEnable?: boolean;
147
+ /** Show debug bounding boxes around lines/blocks. */
148
+ debug?: boolean;
149
+ };
150
+ /**
151
+ * Imperative controller that owns the Konva stage lifecycle for a single video element.
152
+ *
153
+ * @public
154
+ */
155
+ declare class Captions {
156
+ private enabled;
157
+ private readonly video;
158
+ private readonly providedContainer?;
159
+ private presetState;
160
+ private captionsState;
161
+ private containerElement?;
162
+ private ownsContainer;
163
+ private stage;
164
+ private layer;
165
+ private resizeObserver?;
166
+ private animationFrameId;
167
+ private videoWidth;
168
+ private videoHeight;
169
+ private readonly debug;
170
+ private readonly handleResize;
171
+ private readonly handleMetadata;
172
+ private readonly animationLoop;
173
+ /**
174
+ * Create a controller bound to the provided video element and preset.
175
+ *
176
+ * @param options - Complete configuration for the controller.
177
+ */
178
+ constructor(options: CaptionsOptions);
179
+ /**
180
+ * Mount caption overlays onto the configured video if they are not active yet.
181
+ */
182
+ enable(): void;
183
+ /**
184
+ * Tear down overlays, observers and animation loops to free resources.
185
+ */
186
+ disable(): void;
187
+ /**
188
+ * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
189
+ */
190
+ destroy(): void;
191
+ /**
192
+ * Swap the active preset and re-render with updated typography/colors.
193
+ *
194
+ * @param nextPreset - Preset that becomes the new render baseline.
195
+ */
196
+ preset(nextPreset: StylePreset): void;
197
+ /**
198
+ * Replace the current caption track and repaint without reloading fonts.
199
+ *
200
+ * @param nextCaptions - Timed words that should drive the overlay.
201
+ */
202
+ captions(nextCaptions: Caption[] | null): void;
203
+ /**
204
+ * Whether the Konva overlay is currently attached to the video element.
205
+ *
206
+ * @returns `true` when the overlay is mounted on top of the video.
207
+ */
208
+ isEnabled(): boolean;
209
+ private refreshFrame;
210
+ private loadFontForCurrentPreset;
211
+ private updateFrame;
212
+ private syncStageDimensions;
213
+ private createOverlay;
214
+ }
215
+ /**
216
+ * Convenience alias for the concrete controller class.
217
+ *
218
+ * @public
219
+ */
220
+ type CaptionsInstance = Captions;
221
+ /**
222
+ * Factory mirroring the legacy default export for ergonomic imports.
223
+ *
224
+ * @param options - Same options accepted by the {@link Captions} constructor.
225
+ * @returns New controller instance.
226
+ */
227
+ declare function captionsjs(options: CaptionsOptions): Captions;
228
+
229
+ declare enum LayoutType {
230
+ 'Fill' = "fill",
231
+ 'Fit' = "fit",
232
+ 'Split' = "split",
233
+ 'Three' = "three",
234
+ 'Four' = "four",
235
+ 'ScreenShare' = "screenShare"
236
+ }
237
+ type AspectRatioType = typeof aspectRatios[number];
238
+ interface LayoutSettings {
239
+ aspectRatio: AspectRatioType;
240
+ aIAutoLayout: LayoutType[];
241
+ fitLayoutCropAspectRatio: AspectRatioType;
242
+ }
243
+ declare const aspectRatios: readonly ["1:1", "9:16", "16:9"];
244
+
245
+ type RenderFrameFn = (captionsSettings: CaptionsSettings, layoutSettings: LayoutSettings, captions: Caption[], currentTime: number, targetSize: [number, number], layer: Konva.Layer, toCoef?: number, debug?: boolean) => void;
246
+
247
+ declare const renderFrame: RenderFrameFn;
248
+
249
+ /**
250
+ * Simple canvas demo renderer used only for the docs playground.
251
+ *
252
+ * @remarks
253
+ * Keeps a reference implementation of drawing raw text to a canvas so we can
254
+ * showcase caption styling without a video element.
255
+ *
256
+ * @param ctx - Target 2D context to draw on.
257
+ * @param text - Arbitrary string that should be painted on the canvas.
258
+ * @returns Always returns `true` to match the historical API surface.
259
+ */
1
260
  declare function renderCaptions(ctx: CanvasRenderingContext2D, text: string): boolean;
2
261
 
3
- export { renderCaptions };
262
+ export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type CaptionsSettings, type StylePreset, type StylePresetName, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderFrame, renderString, stylePresets };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,262 @@
1
+ import Konva from 'konva';
2
+
3
+ /**
4
+ * Whitelisted Google Fonts that the renderer knows how to lazy-load.
5
+ *
6
+ * @remarks
7
+ * Restricting the list keeps bundle size predictable across consumers.
8
+ *
9
+ * @public
10
+ */
11
+ declare const googleFontsList: readonly ["Roboto", "Open Sans", "Lato", "Montserrat", "Nunito", "Poppins", "Ubuntu", "PT Sans", "Merriweather Sans", "Lobster", "Amatic SC", "Pacifico", "Raleway", "Cinzel", "Quicksand", "Zilla Slab", "Caveat", "Crimson Pro", "Bebas Neue", "Comfortaa", "Satisfy", "Permanent Marker", "Oswald", "Onset", "Bangers", "Kanit", "Work Sans", "Fira Sans", "Anton", "Playfair Display", "Rubik", "Alumni Sans", "Righteous", "Comico", "Excon", "Kalam", "Tanker", "Arsenal", "Balsamiq Sans", "Bona Nova SC"];
12
+
13
+ /**
14
+ * Shared schema describing how a preset styles captions plus rough layout hints.
15
+ *
16
+ * @public
17
+ */
18
+ interface StylePreset {
19
+ id: number;
20
+ captionsSettings: {
21
+ style: {
22
+ font: {
23
+ italic: boolean;
24
+ fontSize: number;
25
+ fontColor: string;
26
+ underline: boolean;
27
+ fontFamily: string;
28
+ fontWeight: string;
29
+ fontCapitalize: boolean;
30
+ fontStrokeColor: string;
31
+ fontStrokeWidth: number;
32
+ shadow?: {
33
+ fontShadowBlur: number;
34
+ fontShadowColor: string;
35
+ fontShadowOffsetX: number;
36
+ fontShadowOffsetY: number;
37
+ };
38
+ };
39
+ name: string;
40
+ backgroundColor: string;
41
+ verticalCoverImg: string;
42
+ aplifiedWordColor: string;
43
+ };
44
+ position: string;
45
+ animation: string;
46
+ linesPerPage: number;
47
+ positionTopOffset?: number;
48
+ };
49
+ layoutSettings: {
50
+ aspectRatio: string;
51
+ aIAutoLayout: string[];
52
+ fitLayoutAspectRatio: string;
53
+ };
54
+ }
55
+ /**
56
+ * Names of all available style presets.
57
+ */
58
+ type StylePresetName = "Karaoke" | "Beasty" | "Safari" | "Acid" | "Popline" | "Desert" | "Hook" | "Sky" | "Flamingo" | "Deep Diver B&W" | "New" | "Banger" | "Catchy" | "Karaoke 2" | "Karaoke 3" | "From" | "Classic" | "Classic Big" | "Crazy" | "Acid 2" | "Marvel" | "Lovly" | "Old Money" | "Cinema" | "Marker";
59
+ /**
60
+ * Curated set of presets that ship with captions.js out of the box.
61
+ *
62
+ * @remarks
63
+ * Downstream apps can reference them directly or clone/extend as needed.
64
+ *
65
+ * @public
66
+ */
67
+ declare const stylePresets: StylePreset[];
68
+
69
+ /**
70
+ * Server/worker-friendly helper that paints a text string onto a provided canvas.
71
+ *
72
+ * @remarks
73
+ * Uses the same Konva pipeline as the video overlay renderer so the results
74
+ * match what users see in the browser.
75
+ *
76
+ * @param canvas - Destination canvas that should receive the rendered text.
77
+ * @param text - Arbitrary content that needs to be painted.
78
+ * @param options - Rendering options that include the style preset.
79
+ * @returns Resolves once the frame has been painted (always resolves to `true`).
80
+ */
81
+ declare function renderString(canvas: HTMLCanvasElement, text: string, options: {
82
+ preset: StylePreset;
83
+ }): Promise<boolean>;
84
+
85
+ /**
86
+ * Full styling + animation configuration for a single captions track.
87
+ *
88
+ * @public
89
+ */
90
+ interface CaptionsSettings {
91
+ style: {
92
+ name: string;
93
+ font: {
94
+ fontFamily: string;
95
+ fontSize: number;
96
+ fontWeight: "thin" | "light" | "regular" | "medium" | "bold" | "black";
97
+ fontColor: string;
98
+ fontCapitalize: boolean;
99
+ italic: boolean;
100
+ underline: boolean;
101
+ fontStrokeColor: string;
102
+ fontStrokeWidth: number;
103
+ shadow: {
104
+ fontShadowColor: string;
105
+ fontShadowBlur: number;
106
+ fontShadowOffsetX: number;
107
+ fontShadowOffsetY: number;
108
+ };
109
+ };
110
+ aplifiedWordColor: string;
111
+ backgroundColor: string;
112
+ };
113
+ linesPerPage: number;
114
+ lineSpacing?: number | null;
115
+ position: "auto" | "top" | "middle" | "bottom";
116
+ positionTopOffset: number;
117
+ animation: "none" | "bounce" | "underline" | "box" | "pop" | "scale" | "slide-left" | "slide-up" | "slide-down" | "box-word";
118
+ }
119
+ /**
120
+ * Single timed word/segment that will be highlighted as audio plays.
121
+ *
122
+ * @public
123
+ */
124
+ interface Caption {
125
+ word: string;
126
+ startTime: number;
127
+ endTime: number;
128
+ highlightColor?: string;
129
+ }
130
+
131
+ /**
132
+ * Configuration passed to the captions runtime when binding to a video element.
133
+ *
134
+ * @public
135
+ */
136
+ type CaptionsOptions = {
137
+ /** Video element that should receive overlays. */
138
+ video: HTMLVideoElement;
139
+ /** Optional custom container to host the Konva stage. */
140
+ container?: HTMLDivElement;
141
+ /** Initial preset controlling font, colors, animations. */
142
+ preset: StylePreset;
143
+ /** Initial caption track. */
144
+ captions?: Caption[] | null;
145
+ /** When false, caller must invoke {@link Captions.enable} manually. */
146
+ autoEnable?: boolean;
147
+ /** Show debug bounding boxes around lines/blocks. */
148
+ debug?: boolean;
149
+ };
150
+ /**
151
+ * Imperative controller that owns the Konva stage lifecycle for a single video element.
152
+ *
153
+ * @public
154
+ */
155
+ declare class Captions {
156
+ private enabled;
157
+ private readonly video;
158
+ private readonly providedContainer?;
159
+ private presetState;
160
+ private captionsState;
161
+ private containerElement?;
162
+ private ownsContainer;
163
+ private stage;
164
+ private layer;
165
+ private resizeObserver?;
166
+ private animationFrameId;
167
+ private videoWidth;
168
+ private videoHeight;
169
+ private readonly debug;
170
+ private readonly handleResize;
171
+ private readonly handleMetadata;
172
+ private readonly animationLoop;
173
+ /**
174
+ * Create a controller bound to the provided video element and preset.
175
+ *
176
+ * @param options - Complete configuration for the controller.
177
+ */
178
+ constructor(options: CaptionsOptions);
179
+ /**
180
+ * Mount caption overlays onto the configured video if they are not active yet.
181
+ */
182
+ enable(): void;
183
+ /**
184
+ * Tear down overlays, observers and animation loops to free resources.
185
+ */
186
+ disable(): void;
187
+ /**
188
+ * Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
189
+ */
190
+ destroy(): void;
191
+ /**
192
+ * Swap the active preset and re-render with updated typography/colors.
193
+ *
194
+ * @param nextPreset - Preset that becomes the new render baseline.
195
+ */
196
+ preset(nextPreset: StylePreset): void;
197
+ /**
198
+ * Replace the current caption track and repaint without reloading fonts.
199
+ *
200
+ * @param nextCaptions - Timed words that should drive the overlay.
201
+ */
202
+ captions(nextCaptions: Caption[] | null): void;
203
+ /**
204
+ * Whether the Konva overlay is currently attached to the video element.
205
+ *
206
+ * @returns `true` when the overlay is mounted on top of the video.
207
+ */
208
+ isEnabled(): boolean;
209
+ private refreshFrame;
210
+ private loadFontForCurrentPreset;
211
+ private updateFrame;
212
+ private syncStageDimensions;
213
+ private createOverlay;
214
+ }
215
+ /**
216
+ * Convenience alias for the concrete controller class.
217
+ *
218
+ * @public
219
+ */
220
+ type CaptionsInstance = Captions;
221
+ /**
222
+ * Factory mirroring the legacy default export for ergonomic imports.
223
+ *
224
+ * @param options - Same options accepted by the {@link Captions} constructor.
225
+ * @returns New controller instance.
226
+ */
227
+ declare function captionsjs(options: CaptionsOptions): Captions;
228
+
229
+ declare enum LayoutType {
230
+ 'Fill' = "fill",
231
+ 'Fit' = "fit",
232
+ 'Split' = "split",
233
+ 'Three' = "three",
234
+ 'Four' = "four",
235
+ 'ScreenShare' = "screenShare"
236
+ }
237
+ type AspectRatioType = typeof aspectRatios[number];
238
+ interface LayoutSettings {
239
+ aspectRatio: AspectRatioType;
240
+ aIAutoLayout: LayoutType[];
241
+ fitLayoutCropAspectRatio: AspectRatioType;
242
+ }
243
+ declare const aspectRatios: readonly ["1:1", "9:16", "16:9"];
244
+
245
+ type RenderFrameFn = (captionsSettings: CaptionsSettings, layoutSettings: LayoutSettings, captions: Caption[], currentTime: number, targetSize: [number, number], layer: Konva.Layer, toCoef?: number, debug?: boolean) => void;
246
+
247
+ declare const renderFrame: RenderFrameFn;
248
+
249
+ /**
250
+ * Simple canvas demo renderer used only for the docs playground.
251
+ *
252
+ * @remarks
253
+ * Keeps a reference implementation of drawing raw text to a canvas so we can
254
+ * showcase caption styling without a video element.
255
+ *
256
+ * @param ctx - Target 2D context to draw on.
257
+ * @param text - Arbitrary string that should be painted on the canvas.
258
+ * @returns Always returns `true` to match the historical API surface.
259
+ */
1
260
  declare function renderCaptions(ctx: CanvasRenderingContext2D, text: string): boolean;
2
261
 
3
- export { renderCaptions };
262
+ export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type CaptionsSettings, type StylePreset, type StylePresetName, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderFrame, renderString, stylePresets };