@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 +94 -0
- package/dist/components/SubtitleText.d.ts +2 -0
- package/dist/components/Subtitles.d.ts +2 -0
- package/dist/hooks/fontLoader.d.ts +1 -0
- package/dist/hooks/useAdjustedPhrases.d.ts +10 -0
- package/dist/hooks/useAdjustedPosition.d.ts +4 -0
- package/dist/hooks/useStyleConfig.d.ts +2 -0
- package/dist/hooks/useTextStyle.d.ts +41 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +2509 -0
- package/dist/index.js +2517 -0
- package/dist/test/TestComponent.d.ts +1 -0
- package/dist/test/main.d.ts +1 -0
- package/dist/test/utils/loadSubtitlePresets.d.ts +1 -0
- package/dist/types/components.d.ts +19 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/subtitles.d.ts +83 -0
- package/dist/utils/findPhrasesInRange.d.ts +2 -0
- package/package.json +84 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TestComponent: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const loadSubtitlePresets: () => Promise<any[]>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleConfig } from './subtitles';
|
|
3
|
+
export interface SubtitleTextProps {
|
|
4
|
+
text: string;
|
|
5
|
+
style: StyleConfig;
|
|
6
|
+
frame: number;
|
|
7
|
+
startFrame: number;
|
|
8
|
+
words?: Array<{
|
|
9
|
+
word: string;
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
}>;
|
|
13
|
+
fps: number;
|
|
14
|
+
animationStyle?: string;
|
|
15
|
+
randomColors?: StyleConfig['randomColors'];
|
|
16
|
+
highlightWords?: string[];
|
|
17
|
+
highlightWordsColor?: string;
|
|
18
|
+
}
|
|
19
|
+
export type SubtitleComponent = React.ComponentType<SubtitleTextProps> | React.MemoExoticComponent<React.ComponentType<SubtitleTextProps>>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface Phrase {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
text: string;
|
|
5
|
+
words?: any[];
|
|
6
|
+
startFrame?: number;
|
|
7
|
+
durationInFrames?: number;
|
|
8
|
+
subType?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface StyleConfig {
|
|
11
|
+
name: string;
|
|
12
|
+
captionPosition: "bottom" | "middle";
|
|
13
|
+
amplifiedColor: string;
|
|
14
|
+
amplifiedOpacity?: string;
|
|
15
|
+
amplifySpokenWords: boolean;
|
|
16
|
+
fontFamily: string;
|
|
17
|
+
fontWeight: string;
|
|
18
|
+
fontColor: string;
|
|
19
|
+
fontSize: string;
|
|
20
|
+
textCase: string;
|
|
21
|
+
outlineColor: string;
|
|
22
|
+
outlineWidth: string;
|
|
23
|
+
outlineStyle?: string;
|
|
24
|
+
shadowColor: string;
|
|
25
|
+
shadowBlur: string;
|
|
26
|
+
shadowOffsetX: string;
|
|
27
|
+
shadowOffsetY: string;
|
|
28
|
+
shadowEnabled?: boolean;
|
|
29
|
+
shadowIntensity?: number;
|
|
30
|
+
backgroundColor?: string;
|
|
31
|
+
backgroundOpacity?: string | number;
|
|
32
|
+
backgroundPadding?: string | number;
|
|
33
|
+
backgroundPaddingX?: string | number;
|
|
34
|
+
backgroundPaddingY?: string | number;
|
|
35
|
+
backgroundBorderRadius?: string | number;
|
|
36
|
+
backgroundFillStyle?: "wrap" | "none";
|
|
37
|
+
textSpacing?: string | number;
|
|
38
|
+
animationStyle?: string;
|
|
39
|
+
isItalic?: boolean;
|
|
40
|
+
shinyWordHighlight?: boolean;
|
|
41
|
+
shinySegmentHighlight?: boolean;
|
|
42
|
+
verticalStretch?: string | number;
|
|
43
|
+
opacity?: string | number;
|
|
44
|
+
textHighlightPersists?: boolean;
|
|
45
|
+
currentWordBlock?: boolean;
|
|
46
|
+
currentWordBlockBorderRadius?: string | number;
|
|
47
|
+
currentWordBlockBackgroundColor?: string;
|
|
48
|
+
currentWordBlockOpacity?: string | number;
|
|
49
|
+
currentWordBlockPadding?: string | number;
|
|
50
|
+
amplifyOpacityTransitionDuration?: string;
|
|
51
|
+
randomColors?: {
|
|
52
|
+
enabled?: boolean | string;
|
|
53
|
+
colors?: Array<{
|
|
54
|
+
type: string;
|
|
55
|
+
color: string;
|
|
56
|
+
}>;
|
|
57
|
+
avoidFillers?: boolean;
|
|
58
|
+
pctApplied?: number;
|
|
59
|
+
randomWordCountRange?: [number, number];
|
|
60
|
+
};
|
|
61
|
+
amplifiedColors?: Array<{
|
|
62
|
+
type: string;
|
|
63
|
+
colors: string[];
|
|
64
|
+
angle?: number;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
export interface SubtitlesProps {
|
|
68
|
+
phrases: Phrase[];
|
|
69
|
+
maxCharsPerLine?: number;
|
|
70
|
+
styleConfig: StyleConfig;
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
currentFrame: number;
|
|
74
|
+
currentTime: number;
|
|
75
|
+
fps: number;
|
|
76
|
+
startTime?: number;
|
|
77
|
+
endTime?: number;
|
|
78
|
+
highlightWords?: string[];
|
|
79
|
+
highlightWordsColor?: string;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
devMode?: boolean;
|
|
83
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@overlap.ai/react-video-subtitles",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "A React component for rendering animated subtitles in videos",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"dist/styles",
|
|
11
|
+
"dist/fonts"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "npx rollup -c",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"test-build": "rm -rf react-video-subtitles-1.0.0.tgz && rm -rf dist && npm run build && npm pack && cd test-subtitles && npm uninstall react-video-subtitles && rm -rf node_modules && npm install && npm install ../react-video-subtitles-1.0.0.tgz && npm start",
|
|
17
|
+
"dev": "vite",
|
|
18
|
+
"test:build": "cd test-subtitles && npm start",
|
|
19
|
+
"test:both": "concurrently \"npm run dev\" \"npm run test:build\""
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"framer-motion": ">=4.0.0",
|
|
23
|
+
"react": ">=16.8.0",
|
|
24
|
+
"react-dom": ">=16.8.0"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@fontsource/inter": "^5.1.1",
|
|
28
|
+
"@remotion/player": "^3.3.103",
|
|
29
|
+
"react-router-dom": "^7.1.5",
|
|
30
|
+
"remotion": "^3.3.103"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@babel/core": "^7.23.0",
|
|
34
|
+
"@babel/preset-env": "^7.22.0",
|
|
35
|
+
"@babel/preset-react": "^7.22.0",
|
|
36
|
+
"@rollup/plugin-babel": "^6.0.0",
|
|
37
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
38
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
39
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
40
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
41
|
+
"@rollup/plugin-url": "^8.0.2",
|
|
42
|
+
"@types/jest": "^27.0.0",
|
|
43
|
+
"@types/node": "^22.13.1",
|
|
44
|
+
"@types/react": "^18.0.0",
|
|
45
|
+
"@types/react-dom": "^18.0.0",
|
|
46
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
47
|
+
"concurrently": "^8.0.0",
|
|
48
|
+
"firebase": "^10.14.1",
|
|
49
|
+
"postcss": "^8.4.0",
|
|
50
|
+
"rollup": "^3.0.0",
|
|
51
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
52
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
53
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
54
|
+
"rollup-plugin-url": "^3.0.1",
|
|
55
|
+
"tslib": "^2.3.0",
|
|
56
|
+
"typescript": "^4.9.0",
|
|
57
|
+
"vite": "^4.5.9"
|
|
58
|
+
},
|
|
59
|
+
"resolutions": {
|
|
60
|
+
"@types/react": "^18.0.0"
|
|
61
|
+
},
|
|
62
|
+
"keywords": [
|
|
63
|
+
"react",
|
|
64
|
+
"subtitles",
|
|
65
|
+
"video",
|
|
66
|
+
"animation",
|
|
67
|
+
"captions"
|
|
68
|
+
],
|
|
69
|
+
"author": "Your Name",
|
|
70
|
+
"license": "MIT",
|
|
71
|
+
"type": "module",
|
|
72
|
+
"exports": {
|
|
73
|
+
".": {
|
|
74
|
+
"types": "./dist/index.d.ts",
|
|
75
|
+
"import": "./dist/index.esm.js",
|
|
76
|
+
"require": "./dist/index.js",
|
|
77
|
+
"default": "./dist/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./fonts.css": "./dist/fonts.css"
|
|
80
|
+
},
|
|
81
|
+
"sideEffects": [
|
|
82
|
+
"*.css"
|
|
83
|
+
]
|
|
84
|
+
}
|