Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

embedia-vue

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

embedia-vue - npm Package Compare versions

Comparing version 1.2.3 to 1.2.5

274

dist/index.es.js

@@ -1,109 +0,147 @@

import { ref as p, onMounted as w, watch as f, openBlock as y, createElementBlock as b, normalizeClass as g, normalizeStyle as v, pushScopeId as $, popScopeId as E, createElementVNode as U } from "vue";
let u = 1;
const C = (e, t, o, s) => {
const r = e.videoUrl, i = Number(e.width) + 140, c = I(r);
import { ref as b, onMounted as v, watch as E, openBlock as $, createElementBlock as x, normalizeClass as C, normalizeStyle as I, pushScopeId as k, popScopeId as U, createElementVNode as _ } from "vue";
let w = 1;
const T = (e, t, o, s) => {
const n = e.videoUrl;
let d, r;
e.width == "", r = 370, e.height == "", d = 630;
const c = V(n);
if (!c)
throw new Error("Invalid Instagram video URL");
let n = document.getElementById(t);
n || (n = document.createElement("div"), n.id = t, document.body.appendChild(n));
let a = document.querySelector(`.${o}`);
a || (a = document.createElement("div"), a.className = `video-${s} ${o}`, n.appendChild(a));
const l = document.createElement("blockquote");
l.className = "instagram-media", l.setAttribute("data-instgrm-permalink", `https://www.instagram.com/p/${c}/`), l.setAttribute("data-instgrm-version", "13"), l.style.width = `${e.width}px`, l.style.height = `${i}px`, l.style.maxWidth = "380px", l.style.maxheight = "520px";
const d = document.createElement("a");
if (d.href = r, l.appendChild(d), a.appendChild(l), !document.getElementById("instagramEmbedScript")) {
const m = document.createElement("script");
m.async = !0, m.id = "instagramEmbedScript", m.src = "//www.instagram.com/embed.js", n.appendChild(m);
let i = document.getElementById(t);
i || (i = document.createElement("div"), i.id = t, document.body.appendChild(i));
let l = document.querySelector(`.${o}`);
l || (l = document.createElement("div"), l.className = `video-${s} ${o}`, i.appendChild(l));
const a = document.createElement("blockquote");
a.className = "instagram-media", a.setAttribute("data-instgrm-permalink", `https://www.instagram.com/p/${c}/`), a.setAttribute("data-instgrm-version", "13"), a.style.width = `${r}px`, a.style.height = `${d}px`, a.style.maxWidth = "380px", a.style.maxheight = "630px";
const m = document.createElement("a");
if (m.href = n, a.appendChild(m), l.appendChild(a), !document.getElementById("instagramEmbedScript")) {
const u = document.createElement("script");
u.async = !0, u.id = "instagramEmbedScript", u.src = "//www.instagram.com/embed.js", i.appendChild(u);
}
}, I = (e) => {
}, V = (e) => {
const t = /\/([a-zA-Z0-9_-]+)\/?$/, o = e.match(t);
return o ? o[1] : null;
}, _ = (e) => {
const t = e.match(/\/(?:video|hub)\/([^_]+)/) || e.match(/(?:^|\/)([a-z0-9]+)(?:_[\w-]*)?$/i);
}, S = (e) => {
const t = e.match(/(?:video|hub)\/([^_]+)/) || e.match(/(?:^|\/)([a-z0-9]+)(?:_[\w-]*)?$/i);
if (t && t[1])
return t[1];
throw new Error("Invalid Dailymotion video URL");
}, k = (e, t, o) => {
const s = e.videoUrl, r = _(s), i = e.autoplay ? "1" : "0", c = e.controls ? "1" : "0", n = e.fullscreen ? "1" : "0", a = document.createElement("iframe");
a.src = `https://www.dailymotion.com/embed/video/${r}?autoplay=${i}&controls=${c}&fullscreen=${n}`, a.width = e.width || 640, a.height = e.height || 360, a.frameBorder = "0", a.allowFullscreen = !0, a.className = o, t.appendChild(a);
}, x = (e) => {
}, N = (e, t, o) => {
const s = e.videoUrl, n = S(s), d = e.width || 640, r = e.height || 360;
window.handleDailymotionResponse = (i) => {
if (console.log("Dailymotion Response:", i), i.html) {
const l = document.createElement("div");
l.className = `${o} custom-dailymotion`, l.innerHTML = i.html;
const a = l.querySelector("iframe");
if (a) {
a.style.width = `${d}px`, a.style.height = `${r}px`;
const m = a.getAttribute("allow");
m ? a.setAttribute("allow", m.replace("autoplay", "")) : a.setAttribute("allow", "fullscreen; picture-in-picture; muted");
}
t.appendChild(l);
}
};
const c = document.createElement("script");
c.src = `https://www.dailymotion.com/services/oembed?url=https://www.dailymotion.com/video/${n}&maxwidth=${d}&maxheight=${r}&format=json&callback=handleDailymotionResponse`, document.body.appendChild(c);
}, R = (e) => {
const t = e.match(/\/(\d+)/);
return t && t[1] ? t[1] : (console.error("Invalid Vimeo video URL"), "");
}, T = (e, t, o) => {
const s = e.width || 640, r = e.height || 360, i = e.controls, c = e.autoplay === "true", n = e.loop === "true", a = x(e.videoUrl), l = document.createElement("div");
l.className = `video-${u} ${o}`, l.dataset.eWidth = s, l.dataset.eHeight = r, l.dataset.efullscreen = e.fullscreen, l.dataset.eVideoId = a, t.appendChild(l);
const d = document.createElement("script");
return d.src = "https://player.vimeo.com/api/player.js", d.async = !0, d.onload = () => {
new window.Vimeo.Player(l, {
id: a,
}, L = (e, t, o) => {
const s = e.width || 640, n = e.height || 360, d = e.controls !== void 0 ? e.controls : !0, r = e.autoplay === !0, c = e.loop === "true", i = e.fullscreen === !0, l = R(e.videoUrl), a = document.createElement("div");
a.className = `video-${l} ${o}`, a.dataset.eWidth = s, a.dataset.eHeight = n, a.dataset.efullscreen = i, a.dataset.eVideoId = l, t.appendChild(a);
const m = document.createElement("script");
return m.src = "https://player.vimeo.com/api/player.js", m.async = !0, m.onload = () => {
new window.Vimeo.Player(a, {
id: l,
width: s,
height: r,
controls: i,
autoplay: c,
muted: c,
loop: n
// Set loop based on boolean value
height: n,
controls: d,
// Show controls
autoplay: r,
// Autoplay based on the passed value (true/false)
muted: r,
// Mute if autoplay is true (to comply with browser restrictions)
loop: c,
// Loop based on the loop value
fullscreen: i
}).ready().then(() => {
if (console.log("Vimeo player is ready"), i === !1) {
const h = a.querySelector("iframe"), y = h.contentDocument || h.contentWindow.document, g = setInterval(() => {
const f = y.querySelector(".vimeo-control-bar .fullscreen");
f && (f.style.display = "none", clearInterval(g));
}, 100);
}
}).catch((h) => {
console.error("Error loading Vimeo player:", h);
});
}, document.body.appendChild(d), () => {
l && (l.innerHTML = ""), document.body.removeChild(d);
}, document.body.appendChild(m), () => {
a && (a.innerHTML = ""), m && m.parentNode && document.body.removeChild(m);
};
}, V = (e, t, o) => {
const s = (r) => {
const i = /\/status\/(\d+)/, c = r.match(i);
return c && c[1] ? c[1] : null;
}, q = (e, t, o) => {
const s = (n) => {
const d = /\/status\/(\d+)/, r = n.match(d);
return r && r[1] ? r[1] : null;
};
try {
const r = e.videoUrl, i = s(r), c = document.createElement("div");
c.className = `video-${u} ${o}`, c.id = `tweet-${i}`;
const n = document.createElement("script");
n.src = "https://platform.twitter.com/widgets.js", n.charset = "utf-8", n.async = !0, n.addEventListener("load", () => {
window.twttr.widgets.createTweet(i, c);
}), t.appendChild(c), t.appendChild(n);
} catch (r) {
console.error("Error embedding Twitter content:", r);
const n = e.videoUrl, d = s(n), r = document.createElement("div");
r.className = `video-${w} ${o}`, r.id = `tweet-${d}`;
const c = document.createElement("script");
c.src = "https://platform.twitter.com/widgets.js", c.charset = "utf-8", c.async = !0, c.addEventListener("load", () => {
window.twttr.widgets.createTweet(d, r);
}), t.appendChild(r), t.appendChild(c);
} catch (n) {
console.error("Error embedding Twitter content:", n);
}
}, S = (e, t, o) => {
const s = (r) => {
const i = /\/status\/(\d+)/, c = r.match(i);
return c ? c[1] : null;
}, A = (e, t, o) => {
const s = (n) => {
n = n.replace("x.com", "twitter.com");
const d = /\/(?:i\/)?status\/(\d+)/, r = n.match(d);
return r ? r[1] : null;
};
try {
const r = e.videoUrl, i = s(r);
if (!i)
throw new Error("Invalid video URL");
const c = document.createElement("div");
c.className = `video-${u} ${o}`, c.id = `tweet-${i}`;
const n = document.createElement("script");
n.src = "https://platform.twitter.com/widgets.js", n.charset = "utf-8", n.async = !0, n.addEventListener("load", () => {
window.twttr.widgets.createTweet(i, c);
}), t.appendChild(c), t.appendChild(n);
} catch (r) {
console.error("Error embedding Twitter content:", r);
if (!(t instanceof Node)) {
console.error("Container is not a valid DOM node.");
return;
}
const n = e.videoUrl, d = s(n), r = document.createElement("blockquote");
r.className = `twitter-tweet ${o}`, r.innerHTML = `
<p lang="en" style="min-width">
<a href="https://twitter.com/i/status/${d}" style="display: inline-block; min-width: ${e.width}px;">
</a>
</p>
`, t.appendChild(r);
const c = document.createElement("script");
c.src = "https://platform.x.com/widgets.js", c.charset = "utf-8", c.async = !0, c.addEventListener("load", () => {
window.twttr.widgets.load();
}), t.appendChild(c);
} catch (n) {
console.error("Error embedding Twitter content:", n);
}
}, h = /* @__PURE__ */ new Map(), A = (e, t, o) => {
}, p = /* @__PURE__ */ new Map(), D = (e, t, o) => {
const s = e.videoUrl;
if (h.has(s) || h.has(s))
if (p.has(s) || p.has(s))
return;
h.set(s, !0);
const r = e.width || "100%", i = e.height || "100%", c = new XMLHttpRequest();
c.open("GET", `https://www.tiktok.com/oembed?url=${encodeURIComponent(s)}`, !0), c.onload = function() {
if (c.status >= 200 && c.status < 300) {
const n = JSON.parse(c.responseText);
n.html && (n.html = n.html.replace(/<script[^>]*>.*<\/script>/gi, ""));
const a = document.createElement("div"), l = Date.now();
if (a.className = `video-${l} ${o}`, a.style.width = r, a.style.height = i, a.innerHTML = n.html, !document.querySelector('script[src="https://www.tiktok.com/embed.js"]')) {
const d = document.createElement("script");
d.src = "https://www.tiktok.com/embed.js", document.body.appendChild(d);
p.set(s, !0);
const n = e.width || "100%", d = e.height || "100%", r = new XMLHttpRequest();
r.open("GET", `https://www.tiktok.com/oembed?url=${encodeURIComponent(s)}`, !0), r.onload = function() {
if (r.status >= 200 && r.status < 300) {
const c = JSON.parse(r.responseText);
c.html && (c.html = c.html.replace(/<script[^>]*>.*<\/script>/gi, ""));
const i = document.createElement("div"), l = Date.now();
if (i.className = `video-${l} ${o}`, i.style.width = n, i.style.height = d, i.innerHTML = c.html, !document.querySelector('script[src="https://www.tiktok.com/embed.js"]')) {
const a = document.createElement("script");
a.src = "https://www.tiktok.com/embed.js", document.body.appendChild(a);
}
t ? t.appendChild(a) : document.body && document.body.appendChild(a);
t ? t.appendChild(i) : document.body && document.body.appendChild(i);
} else
console.error("Failed to fetch TikTok oEmbed data: " + c.statusText);
}, c.onerror = function() {
console.error("Failed to fetch TikTok oEmbed data: " + r.statusText);
}, r.onerror = function() {
console.error("An error occurred while embedding TikTok video.");
}, c.send();
}, N = (e, t, o) => {
const s = e.videoUrl, r = e.autoplay ? "autoplay=true" : "autoplay=false", i = r ? "muted=true" : "muted=false", c = e.width || 640, n = e.height || 360, a = document.createElement("iframe");
a.setAttribute("src", `https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(s)}&width=${c}&height=${n}&show_text=false&${r}&${i}`), a.setAttribute("width", c), a.setAttribute("height", n), a.setAttribute("frameborder", "0"), e.fullscreen && a.setAttribute("allowfullscreen", "true"), a.className = `video-${u} ${o} custom-facebook`, u++, t.appendChild(a);
}, R = (e) => {
}, r.send();
}, M = (e, t, o) => {
const s = e.videoUrl, n = e.autoplay ?? !0, d = n, r = e.width || 640, c = e.height || 360, i = new URL("https://www.facebook.com/plugins/video.php");
i.searchParams.set("href", s), i.searchParams.set("width", r), i.searchParams.set("height", c), i.searchParams.set("show_text", "false"), i.searchParams.set("autoplay", n ? "true" : "false"), i.searchParams.set("muted", d ? "1" : "0");
const l = document.createElement("iframe");
l.src = i.toString(), l.width = r, l.height = c, l.frameBorder = "0", l.allow = "autoplay; fullscreen", l.allowFullscreen = e.fullscreen !== !1, l.className = `video-${w} ${o} custom-facebook`, w++, t.appendChild(l);
}, B = (e) => {
const t = e.match(/(?:shorts\/|v=)([a-zA-Z0-9_-]{11})/);

@@ -116,3 +154,3 @@ if (t && t[1])

throw new Error("Invalid YouTube video URL");
}, L = (e, t, o) => {
}, P = (e, t, o) => {
if (!t) {

@@ -122,5 +160,5 @@ console.error("Container element not found.");

}
const s = e.autoplay ? 1 : 0, r = e.autoplay || e.muted ? 1 : 0, i = e.autoplay || e.loop ? 1 : 0, c = R(e.videoUrl), n = document.createElement("iframe");
n.src = `https://www.youtube.com/embed/${c}?autoplay=${s}&mute=${r}&loop=${i ? 1 : 0}&controls=${e.controls ? 1 : 0}`, n.width = e.width || 640, n.height = e.height || 360, n.frameborder = "0", n.style.border = "none", e.fullscreen && n.setAttribute("allow", "fullscreen"), n.className = o, t.appendChild(n);
}, B = (e) => {
const s = e.autoplay ? 1 : 0, n = e.autoplay || e.muted ? 1 : 0, d = e.autoplay || e.loop ? 1 : 0, r = B(e.videoUrl), c = document.createElement("iframe");
c.src = `https://www.youtube.com/embed/${r}?autoplay=${s}&mute=${n}&loop=${d ? 1 : 0}&controls=${e.controls ? 1 : 0}`, c.width = e.width || 640, c.height = e.height || 360, c.frameborder = "0", c.style.border = "none", e.fullscreen && c.setAttribute("allow", "fullscreen"), c.className = o, t.appendChild(c);
}, j = (e) => {
var s;

@@ -131,4 +169,4 @@ const t = ((s = e.cssname) == null ? void 0 : s.trim()) || "";

if (!document.querySelector(`#default-style-${t}`)) {
const r = document.createElement("style");
r.id = `default-style-${t}`, r.textContent = `
const n = document.createElement("style");
n.id = `default-style-${t}`, n.textContent = `
.${t} {

@@ -142,3 +180,3 @@ display: flex;

}
`, document.head.appendChild(r);
`, document.head.appendChild(n);
}

@@ -151,26 +189,26 @@ const o = document.querySelector(`.${t}`);

if (e.videoUrl.includes("youtube.com") || e.videoUrl.includes("youtu.be"))
L(e, o, t);
P(e, o, t);
else if (e.videoUrl.includes("facebook.com") || e.videoUrl.includes("fb.com"))
N(e, o, t);
M(e, o, t);
else if (e.videoUrl.includes("tiktok.com") || e.videoUrl.includes("tiktok"))
A(e, o, t);
D(e, o, t);
else if (e.videoUrl.includes("twitter.com"))
V(e, o, t);
q(e, o, t);
else if (e.videoUrl.includes("x.com"))
S(e, o, t);
A(e, o, t);
else if (e.videoUrl.includes("vimeo.com"))
T(e, o, t);
L(e, o, t);
else if (e.videoUrl.includes("dailymotion.com") || e.videoUrl.includes("dailymotion"))
k(e, o, t);
N(e, o, t);
else if (e.videoUrl.includes("instagram.com") || e.videoUrl.includes("instagram"))
C(e, o, t);
T(e, o, t);
else
throw new Error("Invalid video URL");
};
const M = (e, t) => {
const H = (e, t) => {
const o = e.__vccOpts || e;
for (const [s, r] of t)
o[s] = r;
for (const [s, n] of t)
o[s] = n;
return o;
}, q = {
}, W = {
name: "EmbediaVue",

@@ -208,5 +246,5 @@ props: {

setup(e) {
const t = p("56.25%");
w(() => {
B({
const t = b("56.25%");
v(() => {
j({
videoUrl: e.clip,

@@ -220,7 +258,7 @@ width: e.width,

}), o(e.width, e.height);
}), f(() => [e.width, e.height], ([s, r]) => {
o(s, r);
}), E(() => [e.width, e.height], ([s, n]) => {
o(s, n);
}, { immediate: !0 });
function o(s, r) {
s && r ? t.value = `${r / s * 100}%` : t.value = "56.25%";
function o(s, n) {
s && n ? t.value = `${n / s * 100}%` : t.value = "56.25%";
}

@@ -231,14 +269,14 @@ return {

}
}, j = (e) => ($("data-v-d26b150f"), e = e(), E(), e), W = /* @__PURE__ */ j(() => /* @__PURE__ */ U("div", { class: "video-content" }, null, -1)), z = [
W
}, z = (e) => (k("data-v-d26b150f"), e = e(), U(), e), F = /* @__PURE__ */ z(() => /* @__PURE__ */ _("div", { class: "video-content" }, null, -1)), O = [
F
];
function D(e, t, o, s, r, i) {
return y(), b("div", {
class: g([o.cssname, "responsive-container"]),
style: v({ "--aspect-ratio": s.aspectRatio, width: "auto", maxWidth: "100%" })
}, z, 6);
function Y(e, t, o, s, n, d) {
return $(), x("div", {
class: C([o.cssname, "responsive-container"]),
style: I({ "--aspect-ratio": s.aspectRatio, width: "auto", maxWidth: "100%" })
}, O, 6);
}
const F = /* @__PURE__ */ M(q, [["render", D], ["__scopeId", "data-v-d26b150f"]]);
const X = /* @__PURE__ */ H(W, [["render", Y], ["__scopeId", "data-v-d26b150f"]]);
export {
F as EmbediaVue
X as EmbediaVue
};

@@ -1,2 +0,7 @@

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("vue");let h=1;const w=(e,t,o,s)=>{const r=e.videoUrl,i=Number(e.width)+140,c=f(r);if(!c)throw new Error("Invalid Instagram video URL");let n=document.getElementById(t);n||(n=document.createElement("div"),n.id=t,document.body.appendChild(n));let a=document.querySelector(`.${o}`);a||(a=document.createElement("div"),a.className=`video-${s} ${o}`,n.appendChild(a));const l=document.createElement("blockquote");l.className="instagram-media",l.setAttribute("data-instgrm-permalink",`https://www.instagram.com/p/${c}/`),l.setAttribute("data-instgrm-version","13"),l.style.width=`${e.width}px`,l.style.height=`${i}px`,l.style.maxWidth="380px",l.style.maxheight="520px";const d=document.createElement("a");if(d.href=r,l.appendChild(d),a.appendChild(l),!document.getElementById("instagramEmbedScript")){const u=document.createElement("script");u.async=!0,u.id="instagramEmbedScript",u.src="//www.instagram.com/embed.js",n.appendChild(u)}},f=e=>{const t=/\/([a-zA-Z0-9_-]+)\/?$/,o=e.match(t);return o?o[1]:null},y=e=>{const t=e.match(/\/(?:video|hub)\/([^_]+)/)||e.match(/(?:^|\/)([a-z0-9]+)(?:_[\w-]*)?$/i);if(t&&t[1])return t[1];throw new Error("Invalid Dailymotion video URL")},b=(e,t,o)=>{const s=e.videoUrl,r=y(s),i=e.autoplay?"1":"0",c=e.controls?"1":"0",n=e.fullscreen?"1":"0",a=document.createElement("iframe");a.src=`https://www.dailymotion.com/embed/video/${r}?autoplay=${i}&controls=${c}&fullscreen=${n}`,a.width=e.width||640,a.height=e.height||360,a.frameBorder="0",a.allowFullscreen=!0,a.className=o,t.appendChild(a)},g=e=>{const t=e.match(/\/(\d+)/);return t&&t[1]?t[1]:(console.error("Invalid Vimeo video URL"),"")},v=(e,t,o)=>{const s=e.width||640,r=e.height||360,i=e.controls,c=e.autoplay==="true",n=e.loop==="true",a=g(e.videoUrl),l=document.createElement("div");l.className=`video-${h} ${o}`,l.dataset.eWidth=s,l.dataset.eHeight=r,l.dataset.efullscreen=e.fullscreen,l.dataset.eVideoId=a,t.appendChild(l);const d=document.createElement("script");return d.src="https://player.vimeo.com/api/player.js",d.async=!0,d.onload=()=>{new window.Vimeo.Player(l,{id:a,width:s,height:r,controls:i,autoplay:c,muted:c,loop:n}).ready().then(()=>{})},document.body.appendChild(d),()=>{l&&(l.innerHTML=""),document.body.removeChild(d)}},$=(e,t,o)=>{const s=r=>{const i=/\/status\/(\d+)/,c=r.match(i);return c&&c[1]?c[1]:null};try{const r=e.videoUrl,i=s(r),c=document.createElement("div");c.className=`video-${h} ${o}`,c.id=`tweet-${i}`;const n=document.createElement("script");n.src="https://platform.twitter.com/widgets.js",n.charset="utf-8",n.async=!0,n.addEventListener("load",()=>{window.twttr.widgets.createTweet(i,c)}),t.appendChild(c),t.appendChild(n)}catch(r){console.error("Error embedding Twitter content:",r)}},E=(e,t,o)=>{const s=r=>{const i=/\/status\/(\d+)/,c=r.match(i);return c?c[1]:null};try{const r=e.videoUrl,i=s(r);if(!i)throw new Error("Invalid video URL");const c=document.createElement("div");c.className=`video-${h} ${o}`,c.id=`tweet-${i}`;const n=document.createElement("script");n.src="https://platform.twitter.com/widgets.js",n.charset="utf-8",n.async=!0,n.addEventListener("load",()=>{window.twttr.widgets.createTweet(i,c)}),t.appendChild(c),t.appendChild(n)}catch(r){console.error("Error embedding Twitter content:",r)}},p=new Map,U=(e,t,o)=>{const s=e.videoUrl;if(p.has(s)||p.has(s))return;p.set(s,!0);const r=e.width||"100%",i=e.height||"100%",c=new XMLHttpRequest;c.open("GET",`https://www.tiktok.com/oembed?url=${encodeURIComponent(s)}`,!0),c.onload=function(){if(c.status>=200&&c.status<300){const n=JSON.parse(c.responseText);n.html&&(n.html=n.html.replace(/<script[^>]*>.*<\/script>/gi,""));const a=document.createElement("div"),l=Date.now();if(a.className=`video-${l} ${o}`,a.style.width=r,a.style.height=i,a.innerHTML=n.html,!document.querySelector('script[src="https://www.tiktok.com/embed.js"]')){const d=document.createElement("script");d.src="https://www.tiktok.com/embed.js",document.body.appendChild(d)}t?t.appendChild(a):document.body&&document.body.appendChild(a)}else console.error("Failed to fetch TikTok oEmbed data: "+c.statusText)},c.onerror=function(){console.error("An error occurred while embedding TikTok video.")},c.send()},C=(e,t,o)=>{const s=e.videoUrl,r=e.autoplay?"autoplay=true":"autoplay=false",i=r?"muted=true":"muted=false",c=e.width||640,n=e.height||360,a=document.createElement("iframe");a.setAttribute("src",`https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(s)}&width=${c}&height=${n}&show_text=false&${r}&${i}`),a.setAttribute("width",c),a.setAttribute("height",n),a.setAttribute("frameborder","0"),e.fullscreen&&a.setAttribute("allowfullscreen","true"),a.className=`video-${h} ${o} custom-facebook`,h++,t.appendChild(a)},I=e=>{const t=e.match(/(?:shorts\/|v=)([a-zA-Z0-9_-]{11})/);if(t&&t[1])return t[1];const o=e.match(/(\?v=|\/embed\/|\/watch\?v=|\/v\/|\/e\/|youtu.be\/)([^#&?]*).*/);if(o&&o[2].length===11)return o[2];throw new Error("Invalid YouTube video URL")},_=(e,t,o)=>{if(!t){console.error("Container element not found.");return}const s=e.autoplay?1:0,r=e.autoplay||e.muted?1:0,i=e.autoplay||e.loop?1:0,c=I(e.videoUrl),n=document.createElement("iframe");n.src=`https://www.youtube.com/embed/${c}?autoplay=${s}&mute=${r}&loop=${i?1:0}&controls=${e.controls?1:0}`,n.width=e.width||640,n.height=e.height||360,n.frameborder="0",n.style.border="none",e.fullscreen&&n.setAttribute("allow","fullscreen"),n.className=o,t.appendChild(n)},k=e=>{var s;const t=((s=e.cssname)==null?void 0:s.trim())||"";if(!t.match(/^[a-zA-Z_][\w-]*$/))throw console.error("Invalid class name:",t),new Error("Invalid class name");if(!document.querySelector(`#default-style-${t}`)){const r=document.createElement("style");r.id=`default-style-${t}`,r.textContent=`
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue");let f=1;const v=(e,t,o,s)=>{const n=e.videoUrl;let d,r;e.width=="",r=370,e.height=="",d=630;const c=E(n);if(!c)throw new Error("Invalid Instagram video URL");let i=document.getElementById(t);i||(i=document.createElement("div"),i.id=t,document.body.appendChild(i));let l=document.querySelector(`.${o}`);l||(l=document.createElement("div"),l.className=`video-${s} ${o}`,i.appendChild(l));const a=document.createElement("blockquote");a.className="instagram-media",a.setAttribute("data-instgrm-permalink",`https://www.instagram.com/p/${c}/`),a.setAttribute("data-instgrm-version","13"),a.style.width=`${r}px`,a.style.height=`${d}px`,a.style.maxWidth="380px",a.style.maxheight="630px";const m=document.createElement("a");if(m.href=n,a.appendChild(m),l.appendChild(a),!document.getElementById("instagramEmbedScript")){const h=document.createElement("script");h.async=!0,h.id="instagramEmbedScript",h.src="//www.instagram.com/embed.js",i.appendChild(h)}},E=e=>{const t=/\/([a-zA-Z0-9_-]+)\/?$/,o=e.match(t);return o?o[1]:null},$=e=>{const t=e.match(/(?:video|hub)\/([^_]+)/)||e.match(/(?:^|\/)([a-z0-9]+)(?:_[\w-]*)?$/i);if(t&&t[1])return t[1];throw new Error("Invalid Dailymotion video URL")},x=(e,t,o)=>{const s=e.videoUrl,n=$(s),d=e.width||640,r=e.height||360;window.handleDailymotionResponse=i=>{if(console.log("Dailymotion Response:",i),i.html){const l=document.createElement("div");l.className=`${o} custom-dailymotion`,l.innerHTML=i.html;const a=l.querySelector("iframe");if(a){a.style.width=`${d}px`,a.style.height=`${r}px`;const m=a.getAttribute("allow");m?a.setAttribute("allow",m.replace("autoplay","")):a.setAttribute("allow","fullscreen; picture-in-picture; muted")}t.appendChild(l)}};const c=document.createElement("script");c.src=`https://www.dailymotion.com/services/oembed?url=https://www.dailymotion.com/video/${n}&maxwidth=${d}&maxheight=${r}&format=json&callback=handleDailymotionResponse`,document.body.appendChild(c)},C=e=>{const t=e.match(/\/(\d+)/);return t&&t[1]?t[1]:(console.error("Invalid Vimeo video URL"),"")},I=(e,t,o)=>{const s=e.width||640,n=e.height||360,d=e.controls!==void 0?e.controls:!0,r=e.autoplay===!0,c=e.loop==="true",i=e.fullscreen===!0,l=C(e.videoUrl),a=document.createElement("div");a.className=`video-${l} ${o}`,a.dataset.eWidth=s,a.dataset.eHeight=n,a.dataset.efullscreen=i,a.dataset.eVideoId=l,t.appendChild(a);const m=document.createElement("script");return m.src="https://player.vimeo.com/api/player.js",m.async=!0,m.onload=()=>{new window.Vimeo.Player(a,{id:l,width:s,height:n,controls:d,autoplay:r,muted:r,loop:c,fullscreen:i}).ready().then(()=>{if(console.log("Vimeo player is ready"),i===!1){const p=a.querySelector("iframe"),b=p.contentDocument||p.contentWindow.document,g=setInterval(()=>{const y=b.querySelector(".vimeo-control-bar .fullscreen");y&&(y.style.display="none",clearInterval(g))},100)}}).catch(p=>{console.error("Error loading Vimeo player:",p)})},document.body.appendChild(m),()=>{a&&(a.innerHTML=""),m&&m.parentNode&&document.body.removeChild(m)}},k=(e,t,o)=>{const s=n=>{const d=/\/status\/(\d+)/,r=n.match(d);return r&&r[1]?r[1]:null};try{const n=e.videoUrl,d=s(n),r=document.createElement("div");r.className=`video-${f} ${o}`,r.id=`tweet-${d}`;const c=document.createElement("script");c.src="https://platform.twitter.com/widgets.js",c.charset="utf-8",c.async=!0,c.addEventListener("load",()=>{window.twttr.widgets.createTweet(d,r)}),t.appendChild(r),t.appendChild(c)}catch(n){console.error("Error embedding Twitter content:",n)}},U=(e,t,o)=>{const s=n=>{n=n.replace("x.com","twitter.com");const d=/\/(?:i\/)?status\/(\d+)/,r=n.match(d);return r?r[1]:null};try{if(!(t instanceof Node)){console.error("Container is not a valid DOM node.");return}const n=e.videoUrl,d=s(n),r=document.createElement("blockquote");r.className=`twitter-tweet ${o}`,r.innerHTML=`
<p lang="en" style="min-width">
<a href="https://twitter.com/i/status/${d}" style="display: inline-block; min-width: ${e.width}px;">
</a>
</p>
`,t.appendChild(r);const c=document.createElement("script");c.src="https://platform.x.com/widgets.js",c.charset="utf-8",c.async=!0,c.addEventListener("load",()=>{window.twttr.widgets.load()}),t.appendChild(c)}catch(n){console.error("Error embedding Twitter content:",n)}},w=new Map,_=(e,t,o)=>{const s=e.videoUrl;if(w.has(s)||w.has(s))return;w.set(s,!0);const n=e.width||"100%",d=e.height||"100%",r=new XMLHttpRequest;r.open("GET",`https://www.tiktok.com/oembed?url=${encodeURIComponent(s)}`,!0),r.onload=function(){if(r.status>=200&&r.status<300){const c=JSON.parse(r.responseText);c.html&&(c.html=c.html.replace(/<script[^>]*>.*<\/script>/gi,""));const i=document.createElement("div"),l=Date.now();if(i.className=`video-${l} ${o}`,i.style.width=n,i.style.height=d,i.innerHTML=c.html,!document.querySelector('script[src="https://www.tiktok.com/embed.js"]')){const a=document.createElement("script");a.src="https://www.tiktok.com/embed.js",document.body.appendChild(a)}t?t.appendChild(i):document.body&&document.body.appendChild(i)}else console.error("Failed to fetch TikTok oEmbed data: "+r.statusText)},r.onerror=function(){console.error("An error occurred while embedding TikTok video.")},r.send()},T=(e,t,o)=>{const s=e.videoUrl,n=e.autoplay??!0,d=n,r=e.width||640,c=e.height||360,i=new URL("https://www.facebook.com/plugins/video.php");i.searchParams.set("href",s),i.searchParams.set("width",r),i.searchParams.set("height",c),i.searchParams.set("show_text","false"),i.searchParams.set("autoplay",n?"true":"false"),i.searchParams.set("muted",d?"1":"0");const l=document.createElement("iframe");l.src=i.toString(),l.width=r,l.height=c,l.frameBorder="0",l.allow="autoplay; fullscreen",l.allowFullscreen=e.fullscreen!==!1,l.className=`video-${f} ${o} custom-facebook`,f++,t.appendChild(l)},S=e=>{const t=e.match(/(?:shorts\/|v=)([a-zA-Z0-9_-]{11})/);if(t&&t[1])return t[1];const o=e.match(/(\?v=|\/embed\/|\/watch\?v=|\/v\/|\/e\/|youtu.be\/)([^#&?]*).*/);if(o&&o[2].length===11)return o[2];throw new Error("Invalid YouTube video URL")},V=(e,t,o)=>{if(!t){console.error("Container element not found.");return}const s=e.autoplay?1:0,n=e.autoplay||e.muted?1:0,d=e.autoplay||e.loop?1:0,r=S(e.videoUrl),c=document.createElement("iframe");c.src=`https://www.youtube.com/embed/${r}?autoplay=${s}&mute=${n}&loop=${d?1:0}&controls=${e.controls?1:0}`,c.width=e.width||640,c.height=e.height||360,c.frameborder="0",c.style.border="none",e.fullscreen&&c.setAttribute("allow","fullscreen"),c.className=o,t.appendChild(c)},N=e=>{var s;const t=((s=e.cssname)==null?void 0:s.trim())||"";if(!t.match(/^[a-zA-Z_][\w-]*$/))throw console.error("Invalid class name:",t),new Error("Invalid class name");if(!document.querySelector(`#default-style-${t}`)){const n=document.createElement("style");n.id=`default-style-${t}`,n.textContent=`
.${t} {

@@ -10,2 +15,2 @@ display: flex;

}
`,document.head.appendChild(r)}const o=document.querySelector(`.${t}`);if(!o)throw console.error("Container not found for class:",t),new Error("Container not found");for(;o.firstChild;)o.removeChild(o.firstChild);if(e.videoUrl.includes("youtube.com")||e.videoUrl.includes("youtu.be"))_(e,o,t);else if(e.videoUrl.includes("facebook.com")||e.videoUrl.includes("fb.com"))C(e,o,t);else if(e.videoUrl.includes("tiktok.com")||e.videoUrl.includes("tiktok"))U(e,o,t);else if(e.videoUrl.includes("twitter.com"))$(e,o,t);else if(e.videoUrl.includes("x.com"))E(e,o,t);else if(e.videoUrl.includes("vimeo.com"))v(e,o,t);else if(e.videoUrl.includes("dailymotion.com")||e.videoUrl.includes("dailymotion"))b(e,o,t);else if(e.videoUrl.includes("instagram.com")||e.videoUrl.includes("instagram"))w(e,o,t);else throw new Error("Invalid video URL")};const x=(e,t)=>{const o=e.__vccOpts||e;for(const[s,r]of t)o[s]=r;return o},T={name:"EmbediaVue",props:{clip:{type:String,required:!0},width:{type:[Number,String],default:640},height:{type:[Number,String],default:""},autoplay:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},cssname:{type:String,default:"default-video-class"}},setup(e){const t=m.ref("56.25%");m.onMounted(()=>{k({videoUrl:e.clip,width:e.width,height:e.height,autoplay:e.autoplay,fullscreen:e.fullscreen,controls:e.controls,cssname:e.cssname}),o(e.width,e.height)}),m.watch(()=>[e.width,e.height],([s,r])=>{o(s,r)},{immediate:!0});function o(s,r){s&&r?t.value=`${r/s*100}%`:t.value="56.25%"}return{aspectRatio:t}}},V=e=>(m.pushScopeId("data-v-d26b150f"),e=e(),m.popScopeId(),e),S=V(()=>m.createElementVNode("div",{class:"video-content"},null,-1)),A=[S];function N(e,t,o,s,r,i){return m.openBlock(),m.createElementBlock("div",{class:m.normalizeClass([o.cssname,"responsive-container"]),style:m.normalizeStyle({"--aspect-ratio":s.aspectRatio,width:"auto",maxWidth:"100%"})},A,6)}const R=x(T,[["render",N],["__scopeId","data-v-d26b150f"]]);exports.EmbediaVue=R;
`,document.head.appendChild(n)}const o=document.querySelector(`.${t}`);if(!o)throw console.error("Container not found for class:",t),new Error("Container not found");for(;o.firstChild;)o.removeChild(o.firstChild);if(e.videoUrl.includes("youtube.com")||e.videoUrl.includes("youtu.be"))V(e,o,t);else if(e.videoUrl.includes("facebook.com")||e.videoUrl.includes("fb.com"))T(e,o,t);else if(e.videoUrl.includes("tiktok.com")||e.videoUrl.includes("tiktok"))_(e,o,t);else if(e.videoUrl.includes("twitter.com"))k(e,o,t);else if(e.videoUrl.includes("x.com"))U(e,o,t);else if(e.videoUrl.includes("vimeo.com"))I(e,o,t);else if(e.videoUrl.includes("dailymotion.com")||e.videoUrl.includes("dailymotion"))x(e,o,t);else if(e.videoUrl.includes("instagram.com")||e.videoUrl.includes("instagram"))v(e,o,t);else throw new Error("Invalid video URL")};const R=(e,t)=>{const o=e.__vccOpts||e;for(const[s,n]of t)o[s]=n;return o},q={name:"EmbediaVue",props:{clip:{type:String,required:!0},width:{type:[Number,String],default:640},height:{type:[Number,String],default:""},autoplay:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},cssname:{type:String,default:"default-video-class"}},setup(e){const t=u.ref("56.25%");u.onMounted(()=>{N({videoUrl:e.clip,width:e.width,height:e.height,autoplay:e.autoplay,fullscreen:e.fullscreen,controls:e.controls,cssname:e.cssname}),o(e.width,e.height)}),u.watch(()=>[e.width,e.height],([s,n])=>{o(s,n)},{immediate:!0});function o(s,n){s&&n?t.value=`${n/s*100}%`:t.value="56.25%"}return{aspectRatio:t}}},L=e=>(u.pushScopeId("data-v-d26b150f"),e=e(),u.popScopeId(),e),M=L(()=>u.createElementVNode("div",{class:"video-content"},null,-1)),A=[M];function D(e,t,o,s,n,d){return u.openBlock(),u.createElementBlock("div",{class:u.normalizeClass([o.cssname,"responsive-container"]),style:u.normalizeStyle({"--aspect-ratio":s.aspectRatio,width:"auto",maxWidth:"100%"})},A,6)}const B=R(q,[["render",D],["__scopeId","data-v-d26b150f"]]);exports.EmbediaVue=B;
{
"name": "embedia-vue",
"version": "1.2.3",
"version": "1.2.5",
"description": "A vue component package to embed videos such as Facebook, Instagram, TikTok, YouTube/Shorts, Twitter/X, Vimeo, and Dailymotion.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -74,21 +74,8 @@ <p align="center">

v1.2.3
- Fixed the issue with embedding x.com concerning the width.
v1.2.5
- Fixed the issue with embedding Vimeo videos regarding autoplay.
v1.2.2
- Fixed the issue with embedding x.com, which restores the embedded post with a card rather than just a video.
v1.1.1
- The border line has been removed from the embedded YouTube clip.
v1.1.2
- Fixed the issue with embedding x.com.
v1.1.3
- Fixed the issue with muted vimeo.
-------

@@ -122,5 +109,5 @@

------ | -------- | ----------|---------- |------------
Required? `width` | yes | yes | no | yes
Required? `height` | yes | no | no | no
Required? `fullscreen` | optional | no | no | no
Required? `width` | yes | | |
Required? `height` | yes | | |
Required? `fullscreen` | optional | | |
Required? `controls` | | | |

@@ -139,4 +126,4 @@ Required? `autoplay` | | | |

Required? `height` | yes | yes | yes
Required? `fullscreen` | optional | optional | optional
Required? `controls` | optional | optional | optional
Required? `fullscreen` | optional | optional |
Required? `controls` | optional | optional |
Required? `autoplay` | optional | optional |optional

@@ -143,0 +130,0 @@ Required? `cssname` | optional | optional | optional

@@ -31,5 +31,26 @@ /* # Embedia Vue core license

const embedInstagram = (video, containerId, cssClassName, videoCount) => {
const clipUrl = video.videoUrl;
const hc = Number(video.width) + 140;
let hc;
let wc;
if (video.width == '' ) {
wc = 370
}
else {
wc = 370
}
if (video.height == '' ) {
hc = 630;
}
else {
hc = 630;
}
// Extract the video ID from the URL

@@ -62,7 +83,8 @@ const videoId = extractInstagramVideoId(clipUrl);

blockquote.setAttribute('data-instgrm-version', '13');
blockquote.style.width = `${video.width}px`;
blockquote.style.width = `${wc}px`;
blockquote.style.height = `${hc}px`;
blockquote.style.maxWidth = '380px';
blockquote.style.maxheight = '520px';
blockquote.style.maxheight = '630px';
const anchor = document.createElement('a');

@@ -92,43 +114,64 @@ anchor.href = clipUrl;

// Function to extract the Dailymotion video ID from the URL
const extractDailymotionVideoId = (url) => {
const videoIdMatch = url.match(/(?:video|hub)\/([^_]+)/) || url.match(/(?:^|\/)([a-z0-9]+)(?:_[\w-]*)?$/i);
if (videoIdMatch && videoIdMatch[1]) {
return videoIdMatch[1];
}
throw new Error("Invalid Dailymotion video URL");
};
// Function to embed the Dailymotion video with autoplay disabled
const embedDailymotion = (video, container, cssname) => {
const videoUrl = video.videoUrl; // Ensure this is a valid Dailymotion URL
const videoId = extractDailymotionVideoId(videoUrl); // Extract video ID
const maxwidth = video.width || 640; // Default width if not provided
const maxheight = video.height || 360; // Default height if not provided
// Function to handle the oEmbed response from Dailymotion
window.handleDailymotionResponse = (data) => {
console.log("Dailymotion Response:", data);
if (data.html) {
// Create a container for the video
const videoContainer = document.createElement("div");
videoContainer.className = `${cssname} custom-dailymotion`;
videoContainer.innerHTML = data.html;
const extractDailymotionVideoId = (url) => {
const videoIdMatch = url.match(/\/(?:video|hub)\/([^_]+)/) || url.match(/(?:^|\/)([a-z0-9]+)(?:_[\w-]*)?$/i);
if (videoIdMatch && videoIdMatch[1]) {
return videoIdMatch[1];
const videoElement = videoContainer.querySelector('iframe');
if (videoElement) {
// Apply width and height to iframe
videoElement.style.width = `${maxwidth}px`;
videoElement.style.height = `${maxheight}px`;
// Manually modify the 'allow' attribute to remove autoplay
const allowAttr = videoElement.getAttribute('allow');
// Remove autoplay from the 'allow' attribute
if (allowAttr) {
videoElement.setAttribute('allow', allowAttr.replace('autoplay', ''));
} else {
// If 'allow' is not defined, we set the value without autoplay
videoElement.setAttribute('allow', 'fullscreen; picture-in-picture; muted');
}
}
throw new Error("Invalid Dailymotion video URL");
};
const embedDailymotion = (video, container, cssname) => {
const videoUrl = video.videoUrl;
const videoId = extractDailymotionVideoId(videoUrl);
const autoplayValue = video.autoplay ? '1' : '0';
const controlsValue = video.controls ? '1' : '0';
const fullscreenValue = video.fullscreen ? '1' : '0';
const iframe = document.createElement("iframe");
iframe.src = `https://www.dailymotion.com/embed/video/${videoId}?autoplay=${autoplayValue}&controls=${controlsValue}&fullscreen=${fullscreenValue}`;
iframe.width = video.width || 640;
iframe.height = video.height || 360;
iframe.frameBorder = "0";
iframe.allowFullscreen = true;
iframe.className = cssname;
container.appendChild(iframe);
};
// Function to extract Vimeo video ID from a URL
// Append the video container with the iframe to the provided container
container.appendChild(videoContainer);
}
};
// Make the oEmbed API request (without autoplay)
const script = document.createElement("script");
script.src = `https://www.dailymotion.com/services/oembed?url=https://www.dailymotion.com/video/${videoId}&maxwidth=${maxwidth}&maxheight=${maxheight}&format=json&callback=handleDailymotionResponse`;
// Append the script to the body to trigger the oEmbed request
document.body.appendChild(script);
};
// Function to extract Vimeo video ID from a URL
const extractVimeoVideoId = (url) => {

@@ -143,53 +186,83 @@ const videoIdMatch = url.match(/\/(\d+)/);

};
// Function to embed Vimeo video
const embedVimeo = (video, container, cssname) => {
const emWidth = video.width || 640; // Default width if not provided
const emHeight = video.height || 360; // Default height if not provided
const controlsValue = video.controls !== undefined ? video.controls : true; // Default to true if not provided
const autoplayValue = video.autoplay === true; // Autoplay set to boolean true
const loopValue = video.loop === "true"; // Convert loop to boolean
const fullscreenValue = video.fullscreen === true; // Fullscreen option, converted to boolean
// Extract the Vimeo video ID from the URL
const videoId = extractVimeoVideoId(video.videoUrl);
const embedVimeo = (video, container, cssname) => {
const emWidth = video.width || 640;
const emHeight = video.height || 360;
const controlsValue = video.controls;
const autoplayValue = video.autoplay === "true"; // Convert to boolean
const loopValue = video.loop === "true"; // Convert to boolean
const videoId = extractVimeoVideoId(video.videoUrl);
const playerDiv = document.createElement("div");
playerDiv.className = `video-${videoCount} ${cssname}`;
playerDiv.dataset.eWidth = emWidth;
playerDiv.dataset.eHeight = emHeight;
playerDiv.dataset.efullscreen = video.fullscreen;
playerDiv.dataset.eVideoId = videoId;
container.appendChild(playerDiv);
const script = document.createElement("script");
script.src = "https://player.vimeo.com/api/player.js";
script.async = true;
script.onload = () => {
const vimeoPlayer = new window.Vimeo.Player(playerDiv, {
id: videoId,
width: emWidth,
height: emHeight,
controls: controlsValue,
autoplay: autoplayValue,
muted: autoplayValue,
loop: loopValue, // Set loop based on boolean value
});
vimeoPlayer.ready().then(() => {
// Additional player methods can be used here if needed
});
};
document.body.appendChild(script);
return () => {
if (playerDiv) {
playerDiv.innerHTML = "";
// Create a div to hold the Vimeo player
const playerDiv = document.createElement("div");
playerDiv.className = `video-${videoId} ${cssname}`;
playerDiv.dataset.eWidth = emWidth;
playerDiv.dataset.eHeight = emHeight;
playerDiv.dataset.efullscreen = fullscreenValue; // Data attribute for fullscreen
playerDiv.dataset.eVideoId = videoId;
// Append the player container to the given container
container.appendChild(playerDiv);
// Load the Vimeo API script dynamically
const script = document.createElement("script");
script.src = "https://player.vimeo.com/api/player.js";
script.async = true;
script.onload = () => {
// Initialize the Vimeo player after the script has loaded
const vimeoPlayer = new window.Vimeo.Player(playerDiv, {
id: videoId,
width: emWidth,
height: emHeight,
controls: controlsValue, // Show controls
autoplay: autoplayValue, // Autoplay based on the passed value (true/false)
muted: autoplayValue, // Mute if autoplay is true (to comply with browser restrictions)
loop: loopValue, // Loop based on the loop value
fullscreen: fullscreenValue,
});
// Ready callback
vimeoPlayer.ready().then(() => {
console.log('Vimeo player is ready');
// If fullscreen is set to false, hide the fullscreen button from the controls
if (fullscreenValue === false) {
const iframe = playerDiv.querySelector("iframe");
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
// Wait for the player to load before attempting to hide fullscreen button
const interval = setInterval(() => {
const fullscreenButton = iframeDocument.querySelector('.vimeo-control-bar .fullscreen');
if (fullscreenButton) {
fullscreenButton.style.display = 'none'; // Hide fullscreen button in controls
clearInterval(interval);
}
}, 100);
}
}).catch((error) => {
console.error('Error loading Vimeo player:', error);
});
};
// Append the script to the body to load it
document.body.appendChild(script);
// Cleanup function to remove the player and script when no longer needed
return () => {
if (playerDiv) {
playerDiv.innerHTML = "";
}
if (script && script.parentNode) {
document.body.removeChild(script);
};
}
};
};
const embedTwitter = (video, container, cssname) => {

@@ -244,24 +317,33 @@

const embedX = (video, container, cssname) => {
const extractTwitterTweetId = (url) => {
const regex = /\/status\/(\d+)/;
url = url.replace("x.com", "twitter.com");
const regex = /\/(?:i\/)?status\/(\d+)/;
const match = url.match(regex);
return match ? match[1] : null; // Return tweet ID or null
return match ? match[1] : null;
};
try {
const videoUrl = video.videoUrl;
const tweetId = extractTwitterTweetId(videoUrl);
if (!tweetId) {
throw new Error("Invalid video URL"); // Throw error if tweet ID not found
if (!(container instanceof Node)) {
console.error("Container is not a valid DOM node.");
return;
}
const tweetContainer = document.createElement("div");
tweetContainer.className = `video-${videoCount} ${cssname}`;
tweetContainer.id = `tweet-${tweetId}`;
const clip = video.videoUrl;
const tweetId = extractTwitterTweetId(clip);
const tweetContainer = document.createElement("blockquote");
tweetContainer.className = `twitter-tweet ${cssname}`;
// Construct the <a> tag with the correct URL
tweetContainer.innerHTML = `
<p lang="en" style="min-width">
<a href="https://twitter.com/i/status/${tweetId}" style="display: inline-block; min-width: ${video.width}px;">
</a>
</p>
`;
container.appendChild(tweetContainer);
const twitterWidgetScript = document.createElement("script");
twitterWidgetScript.src = "https://platform.twitter.com/widgets.js";
twitterWidgetScript.src = "https://platform.x.com/widgets.js";
twitterWidgetScript.charset = "utf-8";

@@ -271,7 +353,7 @@ twitterWidgetScript.async = true;

twitterWidgetScript.addEventListener("load", () => {
window.twttr.widgets.createTweet(tweetId, tweetContainer);
window.twttr.widgets.load();
});
container.appendChild(tweetContainer);
container.appendChild(twitterWidgetScript);
} catch (error) {

@@ -282,11 +364,4 @@ console.error("Error embedding Twitter content:", error);

// Map to track embedded TikTok videos

@@ -433,22 +508,28 @@ const embeddedTikTokVideos = new Map();

const embedFacebook = (video, container, cssname) => {
const videoUrl = video.videoUrl;
const autoplay = video.autoplay ? 'autoplay=true' : 'autoplay=false';
const muted = autoplay ? 'muted=true' : 'muted=false';
const clip = video.videoUrl;
const autoplayc = video.autoplay ?? true; // Default to true if not specified
const muted = autoplayc; // Default to true if not specified
const emWidth = video.width || 640;
const emHeight = video.height || 360;
// Construct the video URL with parameters
const videoSrc = new URL('https://www.facebook.com/plugins/video.php');
videoSrc.searchParams.set('href', clip);
videoSrc.searchParams.set('width', emWidth);
videoSrc.searchParams.set('height', emHeight);
videoSrc.searchParams.set('show_text', 'false');
videoSrc.searchParams.set('autoplay', autoplayc ? 'true' : 'false'); // Autoplay only if muted
videoSrc.searchParams.set('muted', muted ? '1' : '0');
// Create an iframe element for the Facebook video
const iframe = document.createElement('iframe');
iframe.setAttribute('src', `https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(videoUrl)}&width=${emWidth}&height=${emHeight}&show_text=false&${autoplay}&${muted}`);
iframe.setAttribute('width', emWidth);
iframe.setAttribute('height', emHeight);
iframe.setAttribute('frameborder', '0');
iframe.src = videoSrc.toString();
iframe.width = emWidth;
iframe.height = emHeight;
iframe.frameBorder = '0';
// Allow autoplay and fullscreen permissions
iframe.allow = 'autoplay; fullscreen'; // Permissions for autoplay and fullscreen
iframe.allowFullscreen = video.fullscreen !== false; // Allow fullscreen unless explicitly disabled
if (video.fullscreen) {
iframe.setAttribute('allowfullscreen', 'true');
}
iframe.className = `video-${videoCount} ${cssname} custom-facebook`;

@@ -458,2 +539,3 @@

// Append iframe to the container
container.appendChild(iframe);

@@ -460,0 +542,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc