captions.js 0.3.0 → 0.3.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/README.md +39 -0
- package/dist/index.d.mts +231 -1
- package/dist/index.d.ts +231 -1
- package/dist/index.js +1730 -4
- package/dist/index.mjs +1712 -3
- package/package.json +25 -2
- package/src/index.ts +0 -6
- package/tsconfig.json +0 -10
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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**.
|
|
4
|
+
|
|
5
|
+
💌 Want to know when Captions.js is released?
|
|
6
|
+
Star or watch the repo on GitHub to get updates!
|
|
7
|
+
|
|
8
|
+
# Captions.js
|
|
9
|
+
|
|
10
|
+
A modern JavaScript library for adding captions to HTML5 videos with ease.
|
|
11
|
+
|
|
12
|
+
[**Live Demo**](https://maskin25.github.io/captions.js/)
|
|
13
|
+
|
|
14
|
+
[**Docs & API Reference**](https://maskin25.github.io/captions.js/docs/)
|
|
15
|
+
|
|
16
|
+
<!-- [](https://main--68e681805917843931c33a87.chromatic.com/) -->
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
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.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
To install Captions.js, use npm or yarn:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install captions.js
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
or
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yarn add captions.js
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For development see [DEVELOPMENT.md](./DEVELOPMENT.md).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whitelisted Google Fonts that the renderer knows how to lazy-load.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Restricting the list keeps bundle size predictable across consumers.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
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"];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Shared schema describing how a preset styles captions plus rough layout hints.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
interface StylePreset {
|
|
17
|
+
id: number;
|
|
18
|
+
captionsSettings: {
|
|
19
|
+
style: {
|
|
20
|
+
font: {
|
|
21
|
+
italic: boolean;
|
|
22
|
+
fontSize: number;
|
|
23
|
+
fontColor: string;
|
|
24
|
+
underline: boolean;
|
|
25
|
+
fontFamily: string;
|
|
26
|
+
fontWeight: string;
|
|
27
|
+
fontCapitalize: boolean;
|
|
28
|
+
fontStrokeColor: string;
|
|
29
|
+
fontStrokeWidth: number;
|
|
30
|
+
shadow?: {
|
|
31
|
+
fontShadowBlur: number;
|
|
32
|
+
fontShadowColor: string;
|
|
33
|
+
fontShadowOffsetX: number;
|
|
34
|
+
fontShadowOffsetY: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
name: string;
|
|
38
|
+
backgroundColor: string;
|
|
39
|
+
verticalCoverImg: string;
|
|
40
|
+
aplifiedWordColor: string;
|
|
41
|
+
};
|
|
42
|
+
position: string;
|
|
43
|
+
animation: string;
|
|
44
|
+
linesPerPage: number;
|
|
45
|
+
positionTopOffset?: number;
|
|
46
|
+
};
|
|
47
|
+
layoutSettings: {
|
|
48
|
+
aspectRatio: string;
|
|
49
|
+
aIAutoLayout: string[];
|
|
50
|
+
fitLayoutAspectRatio: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Curated set of presets that ship with captions.js out of the box.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Downstream apps can reference them directly or clone/extend as needed.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
declare const stylePresets: StylePreset[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Server/worker-friendly helper that paints a text string onto a provided canvas.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Uses the same Konva pipeline as the video overlay renderer so the results
|
|
68
|
+
* match what users see in the browser.
|
|
69
|
+
*
|
|
70
|
+
* @param canvas - Destination canvas that should receive the rendered text.
|
|
71
|
+
* @param text - Arbitrary content that needs to be painted.
|
|
72
|
+
* @param options - Rendering options that include the style preset.
|
|
73
|
+
* @returns Resolves once the frame has been painted (always resolves to `true`).
|
|
74
|
+
*/
|
|
75
|
+
declare function renderString(canvas: HTMLCanvasElement, text: string, options: {
|
|
76
|
+
preset: StylePreset;
|
|
77
|
+
}): Promise<boolean>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Full styling + animation configuration for a single captions track.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
interface CaptionsSettings {
|
|
85
|
+
style: {
|
|
86
|
+
name: string;
|
|
87
|
+
font: {
|
|
88
|
+
fontFamily: string;
|
|
89
|
+
fontSize: number;
|
|
90
|
+
fontWeight: "thin" | "light" | "regular" | "medium" | "bold" | "black";
|
|
91
|
+
fontColor: string;
|
|
92
|
+
fontCapitalize: boolean;
|
|
93
|
+
italic: boolean;
|
|
94
|
+
underline: boolean;
|
|
95
|
+
fontStrokeColor: string;
|
|
96
|
+
fontStrokeWidth: number;
|
|
97
|
+
shadow: {
|
|
98
|
+
fontShadowColor: string;
|
|
99
|
+
fontShadowBlur: number;
|
|
100
|
+
fontShadowOffsetX: number;
|
|
101
|
+
fontShadowOffsetY: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
aplifiedWordColor: string;
|
|
105
|
+
backgroundColor: string;
|
|
106
|
+
};
|
|
107
|
+
linesPerPage: number;
|
|
108
|
+
lineSpacing?: number | null;
|
|
109
|
+
position: "auto" | "top" | "middle" | "bottom";
|
|
110
|
+
positionTopOffset: number;
|
|
111
|
+
animation: "none" | "bounce" | "underline" | "box" | "pop" | "scale" | "slide-left" | "slide-up" | "slide-down" | "box-word";
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Single timed word/segment that will be highlighted as audio plays.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
interface Caption {
|
|
119
|
+
word: string;
|
|
120
|
+
startTime: number;
|
|
121
|
+
endTime: number;
|
|
122
|
+
highlightColor?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Configuration passed to the captions runtime when binding to a video element.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
type CaptionsOptions = {
|
|
131
|
+
/** Video element that should receive overlays. */
|
|
132
|
+
video: HTMLVideoElement;
|
|
133
|
+
/** Optional custom container to host the Konva stage. */
|
|
134
|
+
container?: HTMLDivElement;
|
|
135
|
+
/** Initial preset controlling font, colors, animations. */
|
|
136
|
+
preset: StylePreset;
|
|
137
|
+
/** Initial caption track. */
|
|
138
|
+
captions?: Caption[] | null;
|
|
139
|
+
/** When false, caller must invoke {@link Captions.enable} manually. */
|
|
140
|
+
autoEnable?: boolean;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Imperative controller that owns the Konva stage lifecycle for a single video element.
|
|
144
|
+
*
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
declare class Captions {
|
|
148
|
+
private enabled;
|
|
149
|
+
private readonly video;
|
|
150
|
+
private readonly providedContainer?;
|
|
151
|
+
private presetState;
|
|
152
|
+
private captionsState;
|
|
153
|
+
private containerElement?;
|
|
154
|
+
private ownsContainer;
|
|
155
|
+
private stage;
|
|
156
|
+
private layer;
|
|
157
|
+
private resizeObserver?;
|
|
158
|
+
private animationFrameId;
|
|
159
|
+
private videoWidth;
|
|
160
|
+
private videoHeight;
|
|
161
|
+
private readonly handleResize;
|
|
162
|
+
private readonly handleMetadata;
|
|
163
|
+
private readonly animationLoop;
|
|
164
|
+
/**
|
|
165
|
+
* Create a controller bound to the provided video element and preset.
|
|
166
|
+
*
|
|
167
|
+
* @param options - Complete configuration for the controller.
|
|
168
|
+
*/
|
|
169
|
+
constructor(options: CaptionsOptions);
|
|
170
|
+
/**
|
|
171
|
+
* Mount caption overlays onto the configured video if they are not active yet.
|
|
172
|
+
*/
|
|
173
|
+
enable(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Tear down overlays, observers and animation loops to free resources.
|
|
176
|
+
*/
|
|
177
|
+
disable(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
|
|
180
|
+
*/
|
|
181
|
+
destroy(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Swap the active preset and re-render with updated typography/colors.
|
|
184
|
+
*
|
|
185
|
+
* @param nextPreset - Preset that becomes the new render baseline.
|
|
186
|
+
*/
|
|
187
|
+
preset(nextPreset: StylePreset): void;
|
|
188
|
+
/**
|
|
189
|
+
* Replace the current caption track and repaint without reloading fonts.
|
|
190
|
+
*
|
|
191
|
+
* @param nextCaptions - Timed words that should drive the overlay.
|
|
192
|
+
*/
|
|
193
|
+
captions(nextCaptions: Caption[] | null): void;
|
|
194
|
+
/**
|
|
195
|
+
* Whether the Konva overlay is currently attached to the video element.
|
|
196
|
+
*
|
|
197
|
+
* @returns `true` when the overlay is mounted on top of the video.
|
|
198
|
+
*/
|
|
199
|
+
isEnabled(): boolean;
|
|
200
|
+
private refreshFrame;
|
|
201
|
+
private loadFontForCurrentPreset;
|
|
202
|
+
private updateFrame;
|
|
203
|
+
private syncStageDimensions;
|
|
204
|
+
private createOverlay;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Convenience alias for the concrete controller class.
|
|
208
|
+
*
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
type CaptionsInstance = Captions;
|
|
212
|
+
/**
|
|
213
|
+
* Factory mirroring the legacy default export for ergonomic imports.
|
|
214
|
+
*
|
|
215
|
+
* @param options - Same options accepted by the {@link Captions} constructor.
|
|
216
|
+
* @returns New controller instance.
|
|
217
|
+
*/
|
|
218
|
+
declare function captionsjs(options: CaptionsOptions): Captions;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Simple canvas demo renderer used only for the docs playground.
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* Keeps a reference implementation of drawing raw text to a canvas so we can
|
|
225
|
+
* showcase caption styling without a video element.
|
|
226
|
+
*
|
|
227
|
+
* @param ctx - Target 2D context to draw on.
|
|
228
|
+
* @param text - Arbitrary string that should be painted on the canvas.
|
|
229
|
+
* @returns Always returns `true` to match the historical API surface.
|
|
230
|
+
*/
|
|
1
231
|
declare function renderCaptions(ctx: CanvasRenderingContext2D, text: string): boolean;
|
|
2
232
|
|
|
3
|
-
export { renderCaptions };
|
|
233
|
+
export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type CaptionsSettings, type StylePreset, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderString, stylePresets };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whitelisted Google Fonts that the renderer knows how to lazy-load.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Restricting the list keeps bundle size predictable across consumers.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
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"];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Shared schema describing how a preset styles captions plus rough layout hints.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
interface StylePreset {
|
|
17
|
+
id: number;
|
|
18
|
+
captionsSettings: {
|
|
19
|
+
style: {
|
|
20
|
+
font: {
|
|
21
|
+
italic: boolean;
|
|
22
|
+
fontSize: number;
|
|
23
|
+
fontColor: string;
|
|
24
|
+
underline: boolean;
|
|
25
|
+
fontFamily: string;
|
|
26
|
+
fontWeight: string;
|
|
27
|
+
fontCapitalize: boolean;
|
|
28
|
+
fontStrokeColor: string;
|
|
29
|
+
fontStrokeWidth: number;
|
|
30
|
+
shadow?: {
|
|
31
|
+
fontShadowBlur: number;
|
|
32
|
+
fontShadowColor: string;
|
|
33
|
+
fontShadowOffsetX: number;
|
|
34
|
+
fontShadowOffsetY: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
name: string;
|
|
38
|
+
backgroundColor: string;
|
|
39
|
+
verticalCoverImg: string;
|
|
40
|
+
aplifiedWordColor: string;
|
|
41
|
+
};
|
|
42
|
+
position: string;
|
|
43
|
+
animation: string;
|
|
44
|
+
linesPerPage: number;
|
|
45
|
+
positionTopOffset?: number;
|
|
46
|
+
};
|
|
47
|
+
layoutSettings: {
|
|
48
|
+
aspectRatio: string;
|
|
49
|
+
aIAutoLayout: string[];
|
|
50
|
+
fitLayoutAspectRatio: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Curated set of presets that ship with captions.js out of the box.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Downstream apps can reference them directly or clone/extend as needed.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
declare const stylePresets: StylePreset[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Server/worker-friendly helper that paints a text string onto a provided canvas.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Uses the same Konva pipeline as the video overlay renderer so the results
|
|
68
|
+
* match what users see in the browser.
|
|
69
|
+
*
|
|
70
|
+
* @param canvas - Destination canvas that should receive the rendered text.
|
|
71
|
+
* @param text - Arbitrary content that needs to be painted.
|
|
72
|
+
* @param options - Rendering options that include the style preset.
|
|
73
|
+
* @returns Resolves once the frame has been painted (always resolves to `true`).
|
|
74
|
+
*/
|
|
75
|
+
declare function renderString(canvas: HTMLCanvasElement, text: string, options: {
|
|
76
|
+
preset: StylePreset;
|
|
77
|
+
}): Promise<boolean>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Full styling + animation configuration for a single captions track.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
interface CaptionsSettings {
|
|
85
|
+
style: {
|
|
86
|
+
name: string;
|
|
87
|
+
font: {
|
|
88
|
+
fontFamily: string;
|
|
89
|
+
fontSize: number;
|
|
90
|
+
fontWeight: "thin" | "light" | "regular" | "medium" | "bold" | "black";
|
|
91
|
+
fontColor: string;
|
|
92
|
+
fontCapitalize: boolean;
|
|
93
|
+
italic: boolean;
|
|
94
|
+
underline: boolean;
|
|
95
|
+
fontStrokeColor: string;
|
|
96
|
+
fontStrokeWidth: number;
|
|
97
|
+
shadow: {
|
|
98
|
+
fontShadowColor: string;
|
|
99
|
+
fontShadowBlur: number;
|
|
100
|
+
fontShadowOffsetX: number;
|
|
101
|
+
fontShadowOffsetY: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
aplifiedWordColor: string;
|
|
105
|
+
backgroundColor: string;
|
|
106
|
+
};
|
|
107
|
+
linesPerPage: number;
|
|
108
|
+
lineSpacing?: number | null;
|
|
109
|
+
position: "auto" | "top" | "middle" | "bottom";
|
|
110
|
+
positionTopOffset: number;
|
|
111
|
+
animation: "none" | "bounce" | "underline" | "box" | "pop" | "scale" | "slide-left" | "slide-up" | "slide-down" | "box-word";
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Single timed word/segment that will be highlighted as audio plays.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
interface Caption {
|
|
119
|
+
word: string;
|
|
120
|
+
startTime: number;
|
|
121
|
+
endTime: number;
|
|
122
|
+
highlightColor?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Configuration passed to the captions runtime when binding to a video element.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
type CaptionsOptions = {
|
|
131
|
+
/** Video element that should receive overlays. */
|
|
132
|
+
video: HTMLVideoElement;
|
|
133
|
+
/** Optional custom container to host the Konva stage. */
|
|
134
|
+
container?: HTMLDivElement;
|
|
135
|
+
/** Initial preset controlling font, colors, animations. */
|
|
136
|
+
preset: StylePreset;
|
|
137
|
+
/** Initial caption track. */
|
|
138
|
+
captions?: Caption[] | null;
|
|
139
|
+
/** When false, caller must invoke {@link Captions.enable} manually. */
|
|
140
|
+
autoEnable?: boolean;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Imperative controller that owns the Konva stage lifecycle for a single video element.
|
|
144
|
+
*
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
declare class Captions {
|
|
148
|
+
private enabled;
|
|
149
|
+
private readonly video;
|
|
150
|
+
private readonly providedContainer?;
|
|
151
|
+
private presetState;
|
|
152
|
+
private captionsState;
|
|
153
|
+
private containerElement?;
|
|
154
|
+
private ownsContainer;
|
|
155
|
+
private stage;
|
|
156
|
+
private layer;
|
|
157
|
+
private resizeObserver?;
|
|
158
|
+
private animationFrameId;
|
|
159
|
+
private videoWidth;
|
|
160
|
+
private videoHeight;
|
|
161
|
+
private readonly handleResize;
|
|
162
|
+
private readonly handleMetadata;
|
|
163
|
+
private readonly animationLoop;
|
|
164
|
+
/**
|
|
165
|
+
* Create a controller bound to the provided video element and preset.
|
|
166
|
+
*
|
|
167
|
+
* @param options - Complete configuration for the controller.
|
|
168
|
+
*/
|
|
169
|
+
constructor(options: CaptionsOptions);
|
|
170
|
+
/**
|
|
171
|
+
* Mount caption overlays onto the configured video if they are not active yet.
|
|
172
|
+
*/
|
|
173
|
+
enable(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Tear down overlays, observers and animation loops to free resources.
|
|
176
|
+
*/
|
|
177
|
+
disable(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Alias for {@link Captions.disable | disable()} to match typical imperative controller APIs.
|
|
180
|
+
*/
|
|
181
|
+
destroy(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Swap the active preset and re-render with updated typography/colors.
|
|
184
|
+
*
|
|
185
|
+
* @param nextPreset - Preset that becomes the new render baseline.
|
|
186
|
+
*/
|
|
187
|
+
preset(nextPreset: StylePreset): void;
|
|
188
|
+
/**
|
|
189
|
+
* Replace the current caption track and repaint without reloading fonts.
|
|
190
|
+
*
|
|
191
|
+
* @param nextCaptions - Timed words that should drive the overlay.
|
|
192
|
+
*/
|
|
193
|
+
captions(nextCaptions: Caption[] | null): void;
|
|
194
|
+
/**
|
|
195
|
+
* Whether the Konva overlay is currently attached to the video element.
|
|
196
|
+
*
|
|
197
|
+
* @returns `true` when the overlay is mounted on top of the video.
|
|
198
|
+
*/
|
|
199
|
+
isEnabled(): boolean;
|
|
200
|
+
private refreshFrame;
|
|
201
|
+
private loadFontForCurrentPreset;
|
|
202
|
+
private updateFrame;
|
|
203
|
+
private syncStageDimensions;
|
|
204
|
+
private createOverlay;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Convenience alias for the concrete controller class.
|
|
208
|
+
*
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
type CaptionsInstance = Captions;
|
|
212
|
+
/**
|
|
213
|
+
* Factory mirroring the legacy default export for ergonomic imports.
|
|
214
|
+
*
|
|
215
|
+
* @param options - Same options accepted by the {@link Captions} constructor.
|
|
216
|
+
* @returns New controller instance.
|
|
217
|
+
*/
|
|
218
|
+
declare function captionsjs(options: CaptionsOptions): Captions;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Simple canvas demo renderer used only for the docs playground.
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* Keeps a reference implementation of drawing raw text to a canvas so we can
|
|
225
|
+
* showcase caption styling without a video element.
|
|
226
|
+
*
|
|
227
|
+
* @param ctx - Target 2D context to draw on.
|
|
228
|
+
* @param text - Arbitrary string that should be painted on the canvas.
|
|
229
|
+
* @returns Always returns `true` to match the historical API surface.
|
|
230
|
+
*/
|
|
1
231
|
declare function renderCaptions(ctx: CanvasRenderingContext2D, text: string): boolean;
|
|
2
232
|
|
|
3
|
-
export { renderCaptions };
|
|
233
|
+
export { type Caption, Captions, type CaptionsInstance, type CaptionsOptions, type CaptionsSettings, type StylePreset, captionsjs, captionsjs as default, googleFontsList, renderCaptions, renderString, stylePresets };
|