@neobyzantine/video-embed 0.2.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.
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+
3
+ interface VideoEmbedProps {
4
+ videoId: string;
5
+ platform?: 'youtube' | 'vimeo' | 'dailymotion';
6
+ title?: string;
7
+ lazy?: boolean;
8
+ aspectRatio?: '16/9' | '4/3';
9
+ className?: string;
10
+ }
11
+ declare function VideoEmbed({ videoId, platform, title, lazy, aspectRatio, className, }: VideoEmbedProps): React.JSX.Element;
12
+
13
+ export { VideoEmbed, type VideoEmbedProps };
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+
3
+ interface VideoEmbedProps {
4
+ videoId: string;
5
+ platform?: 'youtube' | 'vimeo' | 'dailymotion';
6
+ title?: string;
7
+ lazy?: boolean;
8
+ aspectRatio?: '16/9' | '4/3';
9
+ className?: string;
10
+ }
11
+ declare function VideoEmbed({ videoId, platform, title, lazy, aspectRatio, className, }: VideoEmbedProps): React.JSX.Element;
12
+
13
+ export { VideoEmbed, type VideoEmbedProps };
package/dist/index.js ADDED
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ VideoEmbed: () => VideoEmbed
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/VideoEmbed.tsx
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ function buildSrc(videoId, platform) {
30
+ if (platform === "vimeo") return `https://player.vimeo.com/video/${videoId}`;
31
+ if (platform === "dailymotion") return `https://www.dailymotion.com/embed/video/${videoId}`;
32
+ return `https://www.youtube-nocookie.com/embed/${videoId}?rel=0&modestbranding=1`;
33
+ }
34
+ function VideoEmbed({
35
+ videoId,
36
+ platform = "youtube",
37
+ title = "Video",
38
+ lazy = true,
39
+ aspectRatio = "16/9",
40
+ className
41
+ }) {
42
+ const paddingBottom = aspectRatio === "4/3" ? "75%" : "56.25%";
43
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44
+ "div",
45
+ {
46
+ role: "region",
47
+ "aria-label": title,
48
+ style: { position: "relative", paddingBottom, height: 0, overflow: "hidden" },
49
+ className,
50
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
51
+ "iframe",
52
+ {
53
+ src: buildSrc(videoId, platform),
54
+ title,
55
+ loading: lazy ? "lazy" : "eager",
56
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
57
+ allowFullScreen: true,
58
+ style: { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", border: 0 }
59
+ }
60
+ )
61
+ }
62
+ );
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ VideoEmbed
67
+ });
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/VideoEmbed.tsx"],"sourcesContent":["export { VideoEmbed } from './VideoEmbed';\nexport type { VideoEmbedProps } from './VideoEmbed';\n","import * as React from 'react';\n\nexport interface VideoEmbedProps {\n videoId: string;\n platform?: 'youtube' | 'vimeo' | 'dailymotion';\n title?: string;\n lazy?: boolean;\n aspectRatio?: '16/9' | '4/3';\n className?: string;\n}\n\nfunction buildSrc(videoId: string, platform: VideoEmbedProps['platform']): string {\n if (platform === 'vimeo') return `https://player.vimeo.com/video/${videoId}`;\n if (platform === 'dailymotion') return `https://www.dailymotion.com/embed/video/${videoId}`;\n return `https://www.youtube-nocookie.com/embed/${videoId}?rel=0&modestbranding=1`;\n}\n\nexport function VideoEmbed({\n videoId,\n platform = 'youtube',\n title = 'Video',\n lazy = true,\n aspectRatio = '16/9',\n className,\n}: VideoEmbedProps) {\n const paddingBottom = aspectRatio === '4/3' ? '75%' : '56.25%';\n\n return (\n <div\n role=\"region\"\n aria-label={title}\n style={{ position: 'relative', paddingBottom, height: 0, overflow: 'hidden' }}\n className={className}\n >\n <iframe\n src={buildSrc(videoId, platform)}\n title={title}\n loading={lazy ? 'lazy' : 'eager'}\n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\"\n allowFullScreen\n style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', border: 0 }}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkCM;AAvBN,SAAS,SAAS,SAAiB,UAA+C;AAChF,MAAI,aAAa,QAAS,QAAO,kCAAkC,OAAO;AAC1E,MAAI,aAAa,cAAe,QAAO,2CAA2C,OAAO;AACzF,SAAO,0CAA0C,OAAO;AAC1D;AAEO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,cAAc;AAAA,EACd;AACF,GAAoB;AAClB,QAAM,gBAAgB,gBAAgB,QAAQ,QAAQ;AAEtD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,OAAO,EAAE,UAAU,YAAY,eAAe,QAAQ,GAAG,UAAU,SAAS;AAAA,MAC5E;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,KAAK,SAAS,SAAS,QAAQ;AAAA,UAC/B;AAAA,UACA,SAAS,OAAO,SAAS;AAAA,UACzB,OAAM;AAAA,UACN,iBAAe;AAAA,UACf,OAAO,EAAE,UAAU,YAAY,KAAK,GAAG,MAAM,GAAG,OAAO,QAAQ,QAAQ,QAAQ,QAAQ,EAAE;AAAA;AAAA,MAC3F;AAAA;AAAA,EACF;AAEJ;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,41 @@
1
+ // src/VideoEmbed.tsx
2
+ import { jsx } from "react/jsx-runtime";
3
+ function buildSrc(videoId, platform) {
4
+ if (platform === "vimeo") return `https://player.vimeo.com/video/${videoId}`;
5
+ if (platform === "dailymotion") return `https://www.dailymotion.com/embed/video/${videoId}`;
6
+ return `https://www.youtube-nocookie.com/embed/${videoId}?rel=0&modestbranding=1`;
7
+ }
8
+ function VideoEmbed({
9
+ videoId,
10
+ platform = "youtube",
11
+ title = "Video",
12
+ lazy = true,
13
+ aspectRatio = "16/9",
14
+ className
15
+ }) {
16
+ const paddingBottom = aspectRatio === "4/3" ? "75%" : "56.25%";
17
+ return /* @__PURE__ */ jsx(
18
+ "div",
19
+ {
20
+ role: "region",
21
+ "aria-label": title,
22
+ style: { position: "relative", paddingBottom, height: 0, overflow: "hidden" },
23
+ className,
24
+ children: /* @__PURE__ */ jsx(
25
+ "iframe",
26
+ {
27
+ src: buildSrc(videoId, platform),
28
+ title,
29
+ loading: lazy ? "lazy" : "eager",
30
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
31
+ allowFullScreen: true,
32
+ style: { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", border: 0 }
33
+ }
34
+ )
35
+ }
36
+ );
37
+ }
38
+ export {
39
+ VideoEmbed
40
+ };
41
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/VideoEmbed.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport interface VideoEmbedProps {\n videoId: string;\n platform?: 'youtube' | 'vimeo' | 'dailymotion';\n title?: string;\n lazy?: boolean;\n aspectRatio?: '16/9' | '4/3';\n className?: string;\n}\n\nfunction buildSrc(videoId: string, platform: VideoEmbedProps['platform']): string {\n if (platform === 'vimeo') return `https://player.vimeo.com/video/${videoId}`;\n if (platform === 'dailymotion') return `https://www.dailymotion.com/embed/video/${videoId}`;\n return `https://www.youtube-nocookie.com/embed/${videoId}?rel=0&modestbranding=1`;\n}\n\nexport function VideoEmbed({\n videoId,\n platform = 'youtube',\n title = 'Video',\n lazy = true,\n aspectRatio = '16/9',\n className,\n}: VideoEmbedProps) {\n const paddingBottom = aspectRatio === '4/3' ? '75%' : '56.25%';\n\n return (\n <div\n role=\"region\"\n aria-label={title}\n style={{ position: 'relative', paddingBottom, height: 0, overflow: 'hidden' }}\n className={className}\n >\n <iframe\n src={buildSrc(videoId, platform)}\n title={title}\n loading={lazy ? 'lazy' : 'eager'}\n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\"\n allowFullScreen\n style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', border: 0 }}\n />\n </div>\n );\n}\n"],"mappings":";AAkCM;AAvBN,SAAS,SAAS,SAAiB,UAA+C;AAChF,MAAI,aAAa,QAAS,QAAO,kCAAkC,OAAO;AAC1E,MAAI,aAAa,cAAe,QAAO,2CAA2C,OAAO;AACzF,SAAO,0CAA0C,OAAO;AAC1D;AAEO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,cAAc;AAAA,EACd;AACF,GAAoB;AAClB,QAAM,gBAAgB,gBAAgB,QAAQ,QAAQ;AAEtD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,OAAO,EAAE,UAAU,YAAY,eAAe,QAAQ,GAAG,UAAU,SAAS;AAAA,MAC5E;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,KAAK,SAAS,SAAS,QAAQ;AAAA,UAC/B;AAAA,UACA,SAAS,OAAO,SAAS;AAAA,UACzB,OAAM;AAAA,UACN,iBAAe;AAAA,UACf,OAAO,EAAE,UAAU,YAAY,KAAK,GAAG,MAAM,GAAG,OAAO,QAAQ,QAAQ,QAAQ,QAAQ,EAAE;AAAA;AAAA,MAC3F;AAAA;AAAA,EACF;AAEJ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@neobyzantine/video-embed",
3
+ "version": "0.2.0",
4
+ "description": "Privacy-enhanced YouTube/Vimeo/Dailymotion embed component",
5
+ "license": "MIT",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@neobyzantine/types": "0.2.0"
21
+ },
22
+ "devDependencies": {
23
+ "@testing-library/jest-dom": "^6.6.3",
24
+ "@testing-library/react": "^16.3.0",
25
+ "@types/react": "^18.3.23",
26
+ "jsdom": "^26.1.0",
27
+ "react": "^18.3.1",
28
+ "react-dom": "^18.3.1",
29
+ "tsup": "^8.5.1",
30
+ "typescript": "^5.8.0",
31
+ "vitest": "^3.2.3"
32
+ },
33
+ "peerDependencies": {
34
+ "react": ">=18",
35
+ "react-dom": ">=18"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "dev": "tsup --watch",
43
+ "test": "vitest run",
44
+ "lint": "tsc --noEmit"
45
+ }
46
+ }