@overlap.ai/react-video-subtitles 1.0.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 ADDED
@@ -0,0 +1,94 @@
1
+ # React Video Subtitles
2
+ A powerful and flexible React component for rendering customizable video subtitles with advanced styling and animation capabilities.
3
+
4
+ ## Table of Contents
5
+ - [Installation](#installation)
6
+ - [Quick Start](#quick-start)
7
+ - [Core Concepts](#core-concepts)
8
+ - [Props Reference](#props-reference)
9
+ - [Style Configuration](#style-configuration)
10
+ - [Highlighting Words](#highlighting-words)
11
+ - [Adding Custom Fonts](#adding-custom-fonts)
12
+ - [Development](#development)
13
+ - [Testing](#testing)
14
+
15
+ ## Installation
16
+ To install the package, run:
17
+ ```bash
18
+ npm install react-video-subtitles
19
+ ```
20
+
21
+ ## Quick Start
22
+ To get started, import the `Subtitles` component into your React application and provide the necessary props.
23
+
24
+ ```jsx
25
+ import { Subtitles } from 'react-video-subtitles';
26
+ ```
27
+
28
+ ## Core Concepts
29
+ The main components of the subtitle system include:
30
+ - **Phrase Interface**: Represents a single subtitle phrase with timing and text.
31
+ - **StyleConfig Interface**: Defines how subtitles are styled and displayed.
32
+ - **Subtitles Component**: The main component that renders the subtitles based on the provided props.
33
+
34
+ ## Props Reference
35
+
36
+ ### SubtitlesProps
37
+ The `SubtitlesProps` interface defines the props that can be passed to the `Subtitles` component:
38
+
39
+ - **phrases**: `Phrase[]` - An array of subtitle phrases to display.
40
+ - **maxCharsPerLine**: `number` (optional) - Maximum characters allowed per line of subtitle text.
41
+ - **styleConfig**: `StyleConfig` - Configuration object for styling the subtitles.
42
+ - **x**: `number` - The x-coordinate for positioning the subtitles.
43
+ - **y**: `number` - The y-coordinate for positioning the subtitles.
44
+ - **currentFrame**: `number` - The current frame of the video.
45
+ - **currentTime**: `number` - The current time of the video in seconds.
46
+ - **fps**: `number` - Frames per second of the video.
47
+ - **startTime**: `number` (optional) - The start time for displaying subtitles.
48
+ - **endTime**: `number` (optional) - The end time for displaying subtitles.
49
+ - **highlightWords**: `string[]` (optional) - An array of words to highlight in the subtitles.
50
+ - **highlightWordsColor**: `string` (optional) - The color used for highlighting words.
51
+ - **width**: `number` - The width of the subtitle container.
52
+ - **height**: `number` - The height of the subtitle container.
53
+ - **devMode**: `boolean` (optional) - Enables development mode features.
54
+
55
+ ### Phrase Interface
56
+ The `Phrase` interface defines the structure of a subtitle phrase:
57
+
58
+ - **start**: `number` - The start time of the phrase in seconds.
59
+ - **end**: `number` - The end time of the phrase in seconds.
60
+ - **text**: `string` - The text of the subtitle.
61
+ - **words**: `any[]` (optional) - An array of words in the phrase for additional processing.
62
+ - **startFrame**: `number` (optional) - The frame at which the phrase starts.
63
+ - **durationInFrames**: `number` (optional) - The duration of the phrase in frames.
64
+ - **subType**: `string` (optional) - The subtype of the subtitle (if applicable).
65
+
66
+ ## Style Configuration
67
+ To add a new subtitle format, you need to modify the `StyleConfig` interface. The Firebase collection for storing subtitle styles is called `company-subtitles`.
68
+
69
+ ### Highlighting Words
70
+ To highlight a word in the subtitles, wrap the word in HTML tags like this:
71
+ ```html
72
+ <h>word</h>
73
+ ```
74
+
75
+
76
+ ## Adding Custom Fonts
77
+ To add custom fonts, modify the `fontLoader.js` file. This file contains the logic for loading fonts based on the specified font family.
78
+
79
+ ## Development
80
+ To test out the subtitles, run:
81
+ ```bash
82
+ npm run start
83
+ ```
84
+
85
+ This command opens a test suite where you can see every subtitle format in Firebase, preview them, and check if any changes you made break anything or if you need to add fonts.
86
+
87
+ ## Testing
88
+ To see if your package builds correctly, run:
89
+ ```bash
90
+ npm run test-build
91
+ ```
92
+
93
+ This command will build the package and run the test suite in the `test-subtitles` folder, as opposed to the start command which runs it in the dev server
94
+
@@ -0,0 +1,2 @@
1
+ export const SubtitleText: React.NamedExoticComponent<object>;
2
+ import React from "react";
@@ -0,0 +1,2 @@
1
+ import { SubtitlesProps } from '../types/subtitles.js';
2
+ export declare const Subtitles: (props: SubtitlesProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export function loadDocumentFonts(fontFamily: any): Promise<void>;
@@ -0,0 +1,10 @@
1
+ export function useAdjustedPhrases(subtitlesData: any, maxCharsPerLine: any, fps: any, segmentData?: any[]): {
2
+ startFrame: number;
3
+ endFrame: number;
4
+ durationInFrames: number;
5
+ text: string;
6
+ words: any[];
7
+ start: any;
8
+ end: any;
9
+ segmentIndex: number;
10
+ }[];
@@ -0,0 +1,4 @@
1
+ export function useAdjustedPosition(y: any, faceData: any): {
2
+ currentFaceEvent: any;
3
+ adjustedY: any;
4
+ };
@@ -0,0 +1,2 @@
1
+ import { StyleConfig } from '../types/subtitles';
2
+ export declare const useStyleConfig: (subtitleStyle: string, baseStyle: StyleConfig, textStyle: StyleConfig) => StyleConfig;
@@ -0,0 +1,41 @@
1
+ export function useTextStyle(preset: any, x: any, adjustedY: any, videoWidth: any): {
2
+ position: string;
3
+ left: string;
4
+ top: string;
5
+ transform: string;
6
+ fontFamily: any;
7
+ fontSize: string;
8
+ fontWeight: any;
9
+ color: any;
10
+ amplifiedColor: any;
11
+ amplifiedColors: any;
12
+ amplifySpokenWords: any;
13
+ textTransform: any;
14
+ fontStyle: string;
15
+ textAlign: string;
16
+ letterSpacing: string;
17
+ backgroundColor: any;
18
+ backgroundPadding: string;
19
+ backgroundBorderRadius: any;
20
+ verticalStretch: any;
21
+ transformOrigin: string;
22
+ width: string;
23
+ maxWidth: string;
24
+ whiteSpace: string;
25
+ overflow: string;
26
+ outlineColor: any;
27
+ outlineWidth: any;
28
+ filter: string;
29
+ display: string;
30
+ textHighlightPersists: any;
31
+ amplifiedOpacity: any;
32
+ unAmplifiedOpacity: any;
33
+ currentWordBlock: any;
34
+ currentWordBlockBackgroundColor: any;
35
+ currentWordBlockOpacity: any;
36
+ currentWordBlockPadding: any;
37
+ currentWordBlockBorderRadius: any;
38
+ amplifyOpacityTransitionDuration: any;
39
+ textShadow: string;
40
+ shadowIntensity: any;
41
+ };
@@ -0,0 +1,10 @@
1
+ import { Subtitles } from './components/Subtitles';
2
+ import { SubtitleText } from './components/SubtitleText';
3
+ import { useStyleConfig } from './hooks/useStyleConfig';
4
+ import { useAdjustedPosition } from './hooks/useAdjustedPosition';
5
+ import { useAdjustedPhrases } from './hooks/useAdjustedPhrases';
6
+ import { useTextStyle } from './hooks/useTextStyle';
7
+ import subtitlePresets from './constants/subtitle-presets.json';
8
+ import type { StyleConfig, SubtitlesProps, Phrase, SubtitleComponent, SubtitleTextProps } from './types';
9
+ export { Subtitles, SubtitleText, useStyleConfig, useAdjustedPosition, useAdjustedPhrases, useTextStyle, subtitlePresets, };
10
+ export type { StyleConfig, SubtitlesProps, Phrase, SubtitleComponent, SubtitleTextProps, };