react-create-html-video 1.1.0 โ 1.3.0
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/LICENSE +21 -0
- package/README.md +44 -2
- package/dist/index.cjs.js +1291 -350
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1291 -350
- package/dist/index.esm.js.map +1 -1
- package/dist/video-component/__mocks__/use-video.d.ts +4 -0
- package/dist/video-component/test/index.test.d.ts +1 -0
- package/package.json +13 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sricharan Krishnan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
2
6
|
## React Create HTML Video
|
|
7
|
+
|
|
3
8
|
A lightweight React component that programmatically generates and plays an HTML `<video>` element with a clean, reusable API. This library does not rely on CSS-in-JS, with styles are intentionally kept minimal. Created with Typescript support.
|
|
4
9
|
|
|
5
10
|
### ๐ฆ Installation
|
|
11
|
+
|
|
6
12
|
```console
|
|
7
13
|
npm install react-create-html-video
|
|
8
14
|
```
|
|
9
15
|
|
|
10
16
|
### ๐ฒ Features
|
|
17
|
+
|
|
11
18
|
1. Built for modern React with support for Typescript
|
|
12
19
|
2. A lightweight API surface that is easy to understand
|
|
13
20
|
3. Helps render a native HTML `<video>` element on the browser
|
|
@@ -15,27 +22,33 @@ npm install react-create-html-video
|
|
|
15
22
|
5. No manual CSS import is required โ styles are bundled with the package.
|
|
16
23
|
|
|
17
24
|
### ๐ API Type Signature
|
|
25
|
+
|
|
18
26
|
```javascript
|
|
19
27
|
export type TReactCreateHTMLVideo = {
|
|
20
28
|
mp4: string;
|
|
21
29
|
webm: string;
|
|
22
30
|
};
|
|
23
31
|
```
|
|
32
|
+
|
|
24
33
|
### ๐ค Peer Dependencies
|
|
34
|
+
|
|
25
35
|
```javascript
|
|
26
36
|
"peerDependencies": {
|
|
27
37
|
"react": ">=17",
|
|
28
38
|
"react-dom": ">=17"
|
|
29
39
|
}
|
|
30
40
|
```
|
|
41
|
+
|
|
31
42
|
### ๐งช How This Works
|
|
32
|
-
|
|
43
|
+
|
|
44
|
+
1. Detects browser support using `HTMLVideoElement.canPlayType`
|
|
33
45
|
2. Prefers MP4 if supported
|
|
34
46
|
3. Falls back to WebM if MP4 is unavailable
|
|
35
47
|
4. Disables video rendering on Internet Explorer
|
|
36
|
-
5. Returns
|
|
48
|
+
5. Returns `null` when no supported format is available
|
|
37
49
|
|
|
38
50
|
### ๐ค Example Usage
|
|
51
|
+
|
|
39
52
|
```javascript
|
|
40
53
|
/* node modules */
|
|
41
54
|
import { ReactCreateHTMLVideo } from "react-create-html-video";
|
|
@@ -56,9 +69,38 @@ function UIComponent() {
|
|
|
56
69
|
/* exports */
|
|
57
70
|
export default UIComponent;
|
|
58
71
|
```
|
|
72
|
+
|
|
73
|
+
### ๐ Test Coverage
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
PASS src/video-component/test/index.test.tsx
|
|
77
|
+
RCHV Test Suite:
|
|
78
|
+
โ renders null when videoSource is null
|
|
79
|
+
โ renders video container when videoSource is provided
|
|
80
|
+
โ renders video element with correct attributes
|
|
81
|
+
โ sets video src to the videoSource from useVideo hook
|
|
82
|
+
โ passes correct props to useVideo hook
|
|
83
|
+
โ memoizes component and does not re-render with same props
|
|
84
|
+
โ renders video element inside parent container
|
|
85
|
+
โ updates when videoSource changes
|
|
86
|
+
โ returns null when videoSource is falsy
|
|
87
|
+
โ renders only one video element
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
-----------|---------|----------|---------|---------|-------------------
|
|
92
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
93
|
+
-----------|---------|----------|---------|---------|-------------------
|
|
94
|
+
All files | 100 | 100 | 100 | 100 |
|
|
95
|
+
index.tsx | 100 | 100 | 100 | 100 |
|
|
96
|
+
-----------|---------|----------|---------|---------|-------------------
|
|
97
|
+
```
|
|
98
|
+
|
|
59
99
|
### ๐ Contributing
|
|
100
|
+
|
|
60
101
|
Contributions, suggestions, and improvements are welcome.<br/>
|
|
61
102
|
Feel free to open issues or pull requests.
|
|
62
103
|
|
|
63
104
|
### โค๏ธ Support
|
|
105
|
+
|
|
64
106
|
Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.
|