@glightbox/video
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
@@ -1,7 +0,7 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class b{init(){}destroy(){}match(e){return!1}build({index:e,slide:t,config:s}){return Promise.resolve(!1)}cssStyle(){return""}assets(){return{}}}class g extends b{constructor(e={}){super(),this.name="video",this.type="slide",this.players=new Map,this.defaults={maxWidth:"840px",autoPlay:!0,injectAssets:!0,assets:{css:["https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/theme.min.css","https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/layouts/video.min.css"],js:[{src:"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/cdn/vidstack.js",module:!0}]},vistack:{}},this.options={...this.defaults,...e}}init(){this.instance.on("slide_before_change",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);t&&(t==null||t.pause())}),this.options.autoPlay&&this.instance.on("slide_changed",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);if(t){if(t!=null&&t.paused&&(t!=null&&t.duration))return t==null?void 0:t.play();t.addEventListener("can-play",()=>t==null?void 0:t.play())}})}match(e){let t=!1;return(e.match(/vimeo\.com\/([0-9]*)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)||e.match(/\.(mpg|avi|webm|mov|ogv|mp4)/)!==null)&&(t=!0),t}async build({index:e,slide:t,config:s}){var r,c,d,l;const o=Math.floor(Math.random()*Date.now())+e,m={id:`gl-player-${o}`,class:"gl-video-player",viewType:"video",controls:!0,aspectRatio:"16/9",src:s.url,crossorigin:""},y=` | ||
<media-player ${Object.entries(m).reduce((a,[i,u])=>{const v=u?`${i}="${String(u)}"`:i;return`${a} ${v}`},"")}> | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class m{init(){}destroy(){}match(e){return!1}build({index:e,slide:t,config:s}){return Promise.resolve(!1)}cssStyle(){return""}assets(){return{}}}class y extends m{constructor(e={}){super(),this.name="video",this.type="slide",this.players=new Map,this.defaults={maxWidth:"840px",autoPlay:!0,injectAssets:!0,vistack:{}},this.options={...this.defaults,...e},this.playerAssets={css:["https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/theme.min.css","https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/layouts/video.min.css"],js:[{src:"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/cdn/vidstack.js",module:!0}]}}init(){this.instance.on("slide_before_change",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);t&&(t==null||t.pause())}),this.options.autoPlay&&this.instance.on("slide_changed",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);if(t){if(t!=null&&t.paused&&(t!=null&&t.duration))return t==null?void 0:t.play();t.addEventListener("can-play",()=>t==null?void 0:t.play())}})}match(e){let t=!1;return(e.match(/vimeo\.com\/([0-9]*)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)||e.match(/\.(mpg|avi|webm|mov|ogv|mp4)/)!==null)&&(t=!0),t}async build({index:e,slide:t,config:s}){const i=Math.floor(Math.random()*Date.now())+e,d={id:`gl-player-${i}`,class:"gl-video-player",viewType:"video",controls:!0,aspectRatio:"16/9",src:s.url,crossorigin:""},c=` | ||
<media-player ${Object.entries(d).reduce((u,[a,r])=>{const h=r?`${a}="${String(r)}"`:a;return`${u} ${h}`},"")}> | ||
<media-provider></media-provider> | ||
<media-audio-layout></media-audio-layout> | ||
<media-video-layout></media-video-layout> | ||
</media-player>`,n=(s==null?void 0:s.width)||this.options.maxWidth;if(t==null||t.insertAdjacentHTML("beforeend",y),n&&(t==null||t.style.setProperty("--gl-video-max-width",n)),(r=this.options)!=null&&r.injectAssets&&((c=this.options)!=null&&c.assets)){const a=((d=this.options.assets)==null?void 0:d.css)||[],i=((l=this.options.assets)==null?void 0:l.js)||[];await this.instance.injectAssets([...a,...i])}const p=document.getElementById(`gl-player-${o}`);return this.players.set(`player-${e}`,p),!0}slideHasPlayer(e){return this.players.has(`player-${e}`)?this.players.get(`player-${e}`):!1}cssStyle(){return` | ||
</media-player>`,o=(s==null?void 0:s.width)||this.options.maxWidth;t==null||t.insertAdjacentHTML("beforeend",c),o&&(t==null||t.style.setProperty("--gl-video-max-width",o));const l=document.getElementById(`gl-player-${i}`);return this.players.set(`player-${e}`,l),!0}slideHasPlayer(e){return this.players.has(`player-${e}`)?this.players.get(`player-${e}`):!1}assets(){var e;return this.options.injectAssets?(e=this.options)!=null&&e.customAssets?this.options.customAssets:this.playerAssets:!1}cssStyle(){return` | ||
.gl-type-video iframe.vds-youtube[data-no-controls] { | ||
@@ -19,2 +19,2 @@ height: 100%; | ||
} | ||
`}}exports.VideoSlide=g; | ||
`}}exports.VideoSlide=y; |
@@ -1,2 +0,2 @@ | ||
class b { | ||
class m { | ||
/** | ||
@@ -41,2 +41,3 @@ * This method is called when the lightbox is opened | ||
* or a CSS file | ||
* return false to stop the injection of assets | ||
*/ | ||
@@ -47,3 +48,3 @@ assets() { | ||
} | ||
class f extends b { | ||
class y extends m { | ||
constructor(e = {}) { | ||
@@ -54,14 +55,13 @@ super(), this.name = "video", this.type = "slide", this.players = /* @__PURE__ */ new Map(), this.defaults = { | ||
injectAssets: !0, | ||
assets: { | ||
css: [ | ||
"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/theme.min.css", | ||
"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/layouts/video.min.css" | ||
], | ||
js: [{ | ||
src: "https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/cdn/vidstack.js", | ||
module: !0 | ||
}] | ||
}, | ||
vistack: {} | ||
}, this.options = { ...this.defaults, ...e }; | ||
}, this.options = { ...this.defaults, ...e }, this.playerAssets = { | ||
css: [ | ||
"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/theme.min.css", | ||
"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/layouts/video.min.css" | ||
], | ||
js: [{ | ||
src: "https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/cdn/vidstack.js", | ||
module: !0 | ||
}] | ||
}; | ||
} | ||
@@ -86,5 +86,4 @@ init() { | ||
async build({ index: e, slide: t, config: s }) { | ||
var r, c, d, l; | ||
const o = Math.floor(Math.random() * Date.now()) + e, m = { | ||
id: `gl-player-${o}`, | ||
const i = Math.floor(Math.random() * Date.now()) + e, c = { | ||
id: `gl-player-${i}`, | ||
class: "gl-video-player", | ||
@@ -96,6 +95,6 @@ viewType: "video", | ||
crossorigin: "" | ||
}, p = ` | ||
<media-player ${Object.entries(m).reduce((a, [i, u]) => { | ||
const v = u ? `${i}="${String(u)}"` : i; | ||
return `${a} ${v}`; | ||
}, d = ` | ||
<media-player ${Object.entries(c).reduce((u, [o, r]) => { | ||
const h = r ? `${o}="${String(r)}"` : o; | ||
return `${u} ${h}`; | ||
}, "")}> | ||
@@ -105,9 +104,6 @@ <media-provider></media-provider> | ||
<media-video-layout></media-video-layout> | ||
</media-player>`, n = (s == null ? void 0 : s.width) || this.options.maxWidth; | ||
if (t == null || t.insertAdjacentHTML("beforeend", p), n && (t == null || t.style.setProperty("--gl-video-max-width", n)), (r = this.options) != null && r.injectAssets && ((c = this.options) != null && c.assets)) { | ||
const a = ((d = this.options.assets) == null ? void 0 : d.css) || [], i = ((l = this.options.assets) == null ? void 0 : l.js) || []; | ||
await this.instance.injectAssets([...a, ...i]); | ||
} | ||
const y = document.getElementById(`gl-player-${o}`); | ||
return this.players.set(`player-${e}`, y), !0; | ||
</media-player>`, a = (s == null ? void 0 : s.width) || this.options.maxWidth; | ||
t == null || t.insertAdjacentHTML("beforeend", d), a && (t == null || t.style.setProperty("--gl-video-max-width", a)); | ||
const l = document.getElementById(`gl-player-${i}`); | ||
return this.players.set(`player-${e}`, l), !0; | ||
} | ||
@@ -117,2 +113,6 @@ slideHasPlayer(e) { | ||
} | ||
assets() { | ||
var e; | ||
return this.options.injectAssets ? (e = this.options) != null && e.customAssets ? this.options.customAssets : this.playerAssets : !1; | ||
} | ||
cssStyle() { | ||
@@ -136,3 +136,3 @@ return ` | ||
export { | ||
f as VideoSlide | ||
y as VideoSlide | ||
}; |
@@ -1,7 +0,7 @@ | ||
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s.ImagePlugin={}))})(this,function(s){"use strict";class i{init(){}destroy(){}match(e){return!1}build({index:e,slide:t,config:o}){return Promise.resolve(!1)}cssStyle(){return""}assets(){return{}}}class p extends i{constructor(e={}){super(),this.name="video",this.type="slide",this.players=new Map,this.defaults={maxWidth:"840px",autoPlay:!0,injectAssets:!0,assets:{css:["https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/theme.min.css","https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/layouts/video.min.css"],js:[{src:"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/cdn/vidstack.js",module:!0}]},vistack:{}},this.options={...this.defaults,...e}}init(){this.instance.on("slide_before_change",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);t&&(t==null||t.pause())}),this.options.autoPlay&&this.instance.on("slide_changed",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);if(t){if(t!=null&&t.paused&&(t!=null&&t.duration))return t==null?void 0:t.play();t.addEventListener("can-play",()=>t==null?void 0:t.play())}})}match(e){let t=!1;return(e.match(/vimeo\.com\/([0-9]*)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)||e.match(/\.(mpg|avi|webm|mov|ogv|mp4)/)!==null)&&(t=!0),t}async build({index:e,slide:t,config:o}){var c,l,u,h;const d=Math.floor(Math.random()*Date.now())+e,v={id:`gl-player-${d}`,class:"gl-video-player",viewType:"video",controls:!0,aspectRatio:"16/9",src:o.url,crossorigin:""},f=` | ||
<media-player ${Object.entries(v).reduce((n,[a,m])=>{const b=m?`${a}="${String(m)}"`:a;return`${n} ${b}`},"")}> | ||
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s.ImagePlugin={}))})(this,function(s){"use strict";class i{init(){}destroy(){}match(e){return!1}build({index:e,slide:t,config:o}){return Promise.resolve(!1)}cssStyle(){return""}assets(){return{}}}class c extends i{constructor(e={}){super(),this.name="video",this.type="slide",this.players=new Map,this.defaults={maxWidth:"840px",autoPlay:!0,injectAssets:!0,vistack:{}},this.options={...this.defaults,...e},this.playerAssets={css:["https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/theme.min.css","https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/player/styles/default/layouts/video.min.css"],js:[{src:"https://cdn.jsdelivr.net/npm/vidstack@^1.0.0/cdn/vidstack.js",module:!0}]}}init(){this.instance.on("slide_before_change",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);t&&(t==null||t.pause())}),this.options.autoPlay&&this.instance.on("slide_changed",()=>{const e=this.instance.getActiveSlideIndex(),t=this.slideHasPlayer(e);if(t){if(t!=null&&t.paused&&(t!=null&&t.duration))return t==null?void 0:t.play();t.addEventListener("can-play",()=>t==null?void 0:t.play())}})}match(e){let t=!1;return(e.match(/vimeo\.com\/([0-9]*)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)||e.match(/\.(mpg|avi|webm|mov|ogv|mp4)/)!==null)&&(t=!0),t}async build({index:e,slide:t,config:o}){const a=Math.floor(Math.random()*Date.now())+e,u={id:`gl-player-${a}`,class:"gl-video-player",viewType:"video",controls:!0,aspectRatio:"16/9",src:o.url,crossorigin:""},h=` | ||
<media-player ${Object.entries(u).reduce((p,[r,d])=>{const y=d?`${r}="${String(d)}"`:r;return`${p} ${y}`},"")}> | ||
<media-provider></media-provider> | ||
<media-audio-layout></media-audio-layout> | ||
<media-video-layout></media-video-layout> | ||
</media-player>`,r=(o==null?void 0:o.width)||this.options.maxWidth;if(t==null||t.insertAdjacentHTML("beforeend",f),r&&(t==null||t.style.setProperty("--gl-video-max-width",r)),(c=this.options)!=null&&c.injectAssets&&((l=this.options)!=null&&l.assets)){const n=((u=this.options.assets)==null?void 0:u.css)||[],a=((h=this.options.assets)==null?void 0:h.js)||[];await this.instance.injectAssets([...n,...a])}const g=document.getElementById(`gl-player-${d}`);return this.players.set(`player-${e}`,g),!0}slideHasPlayer(e){return this.players.has(`player-${e}`)?this.players.get(`player-${e}`):!1}cssStyle(){return` | ||
</media-player>`,n=(o==null?void 0:o.width)||this.options.maxWidth;t==null||t.insertAdjacentHTML("beforeend",h),n&&(t==null||t.style.setProperty("--gl-video-max-width",n));const m=document.getElementById(`gl-player-${a}`);return this.players.set(`player-${e}`,m),!0}slideHasPlayer(e){return this.players.has(`player-${e}`)?this.players.get(`player-${e}`):!1}assets(){var e;return this.options.injectAssets?(e=this.options)!=null&&e.customAssets?this.options.customAssets:this.playerAssets:!1}cssStyle(){return` | ||
.gl-type-video iframe.vds-youtube[data-no-controls] { | ||
@@ -19,2 +19,2 @@ height: 100%; | ||
} | ||
`}}s.VideoSlide=p,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}); | ||
`}}s.VideoSlide=c,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}); |
@@ -1,3 +0,3 @@ | ||
import type { BuildParams, PluginOptions, PluginType } from '@glightbox/plugin-core'; | ||
import { GLightboxPlugin } from '@glightbox/plugin-core'; | ||
import { BuildParams, PluginAssets, PluginOptions, PluginType, GLightboxPlugin } from '@glightbox/plugin-core'; | ||
export interface VideoOptions extends PluginOptions { | ||
@@ -7,3 +7,3 @@ maxWidth?: string; | ||
injectAssets?: boolean; | ||
assets?: { | ||
customAssets?: { | ||
css?: string[]; | ||
@@ -32,2 +32,3 @@ js?: ({ | ||
players: Map<string, unknown>; | ||
playerAssets: PluginAssets; | ||
defaults: VideoOptions; | ||
@@ -39,3 +40,4 @@ constructor(options?: Partial<VideoOptions>); | ||
private slideHasPlayer; | ||
assets(): false | PluginAssets; | ||
cssStyle(): string; | ||
} |
{ | ||
"name": "@glightbox/video", | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"description": "GLightbox plugin to add support for displaying videos in the lightbox", | ||
@@ -31,5 +31,5 @@ "author": "Biati Digital", | ||
"dependencies": { | ||
"@glightbox/plugin-core": "1.0.0-beta.2" | ||
"@glightbox/plugin-core": "1.0.0-beta.3" | ||
}, | ||
"license": "GPLV3" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12831
224
+ Added@glightbox/plugin-core@1.0.0-beta.3(transitive)
- Removed@glightbox/plugin-core@1.0.0-beta.2(transitive)