@reuse-sh/lightbox 0.1.1 → 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.
- package/dist/browser/audio.js +1 -1
- package/dist/browser/carousel-link.js +1 -1
- package/dist/browser/embed.js +1 -1
- package/dist/browser/html.js +1 -1
- package/dist/browser/iframe.js +1 -1
- package/dist/browser/lightbox.js +2 -2
- package/dist/browser/lightbox.js.map +1 -1
- package/dist/browser/video.js +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +53 -4
- package/package.json +1 -1
package/dist/browser/audio.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.2.0 | MIT License */
|
|
2
2
|
import{playerOf as e}from"./video.js";function t(){return{type:`audio`,mount(t,{item:n,signal:r,autoplay:i}){let a=t.ownerDocument.createElement(`audio`);return a.className=`re-lightbox-audio`,a.controls=!0,a.preload=`metadata`,a.src=n.src??``,n.alt&&a.setAttribute(`aria-label`,n.alt),t.append(a),e(a,i,r)}}}export{t as audio};
|
|
3
3
|
//# sourceMappingURL=audio.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.2.0 | MIT License */
|
|
2
2
|
function e(e,t,{slideOf:n=e=>e}={}){let r=e=>t.hold(`lightbox`,e),i=e=>t.goTo(n(e.index),`instant`),a=[e.on(`open`,()=>r(!0)),e.on(`settle`,i),e.on(`beforeclose`,i),e.on(`closed`,()=>r(!1))];return e.getState().isOpen&&r(!0),()=>{for(let e of a)e();r(!1)}}export{e as connectCarousel};
|
|
3
3
|
//# sourceMappingURL=carousel-link.js.map
|
package/dist/browser/embed.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.2.0 | MIT License */
|
|
2
2
|
import{frameOf as e,loaded as t}from"./iframe.js";const n=e=>{try{let t=typeof e==`string`?JSON.parse(e):e;return typeof t==`object`&&t?t:void 0}catch{return}},r={greet:e=>e({event:`listening`,id:1,channel:`widget`}),command:e=>({event:`command`,func:e===`mute`?`mute`:`${e}Video`,args:[]}),state(e){let t=e.info?.playerState;return t===1?`playing`:t===3?`waiting`:t===2||t===0?`paused`:t===-1||t===5?`unstarted`:void 0}},i={greet(e){for(let t of[`play`,`pause`,`ended`])e({method:`addEventListener`,value:t})},command:e=>e===`mute`?{method:`setVolume`,value:0}:{method:e},state:e=>e.event===`play`?`playing`:e.event===`pause`||e.event===`ended`?`paused`:void 0},a=/* @__PURE__ */ new WeakMap,o=e=>`https://www.youtube-nocookie.com/embed/${e}?enablejsapi=1&playsinline=1`,s=[{name:`youtube-shorts`,pattern:/^https?:\/\/(?:www\.|m\.)?youtube\.com\/shorts\/([\w-]+)/,url:e=>o(e[1]),aspect:9/16},{name:`youtube`,pattern:/^https?:\/\/(?:(?:www\.|m\.)?youtube(?:-nocookie)?\.com\/(?:watch\?(?:.*&)?v=|embed\/|live\/)|youtu\.be\/)([\w-]+)/,url:e=>o(e[1])},{name:`vimeo`,pattern:/^https?:\/\/(?:player\.)?vimeo\.com\/(?:video\/)?(\d+)(?:\/([\da-f]+))?/,url:e=>`https://player.vimeo.com/video/${e[1]}${e[2]?`?h=${e[2]}`:``}`}];a.set(s[0],r),a.set(s[1],r),a.set(s[2],i);function c(e,t){try{let n=new URL(e);for(let[e,r]of new URL(t).searchParams)if(!(e===`v`||n.searchParams.has(e===`t`?`start`:e))){if(e!==`t`)n.searchParams.set(e,r);else{let[,e=0,t=0,i=0]=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/.exec(r)??[],a=Number(e)*3600+Number(t)*60+Number(i);a&&n.searchParams.set(`start`,String(a))}}return n.href}catch{return e}}function l(r={}){let i=[...r.providers??[],...s];return{type:`embed`,mount(o,{item:s,signal:l,autoplay:u}){let d=s.src??``,f,p=null;for(let e of i)if(p=e.pattern.exec(d),p){f=e;break}let m=f&&p?c(f.url(p,s),d):``,h=e(o,m,s.alt??f?.name??``,r.sandbox),g=t(h,l),_={interactive:!0,aspect:f?.aspect,ready:g,unmount:()=>h.remove()},v=f&&a.get(f);if(!v)return _;let y=new URL(m).origin,b=e=>h.contentWindow?.postMessage(JSON.stringify(e),y),x=u,S=!1,C,w;return o.ownerDocument.defaultView?.addEventListener(`message`,e=>{if(e.source!==h.contentWindow||e.origin!==y)return;let t=n(e.data);C=(t&&v.state(t))??C,C===`playing`&&(x=!1,clearTimeout(w))},{signal:l}),l.addEventListener(`abort`,()=>clearTimeout(w)),g.then(()=>v.greet(b)),{..._,pause(){S=!1,clearTimeout(w),b(v.command(`pause`))},resume(){S=!0,x&&(x=!1,g.then(()=>{!l.aborted&&S&&(b(v.command(`play`)),w=setTimeout(()=>{C!==`playing`&&C!==`waiting`&&(b(v.command(`mute`)),b(v.command(`play`)))},1e3))}))}}}}}export{l as embed};
|
|
3
3
|
//# sourceMappingURL=embed.js.map
|
package/dist/browser/html.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.2.0 | MIT License */
|
|
2
2
|
function e(){return{type:`html`,mount(e,{item:t}){let n=e.ownerDocument.createElement(`div`);n.className=`re-lightbox-html`;let r=t.html?.();return r&&n.append(r),e.append(n),{interactive:!0,unmount:()=>n.remove()}}}}export{e as html};
|
|
3
3
|
//# sourceMappingURL=html.js.map
|
package/dist/browser/iframe.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.2.0 | MIT License */
|
|
2
2
|
function e(e,t,n,r){let i=e.ownerDocument,a=i.createElement(`iframe`);if(a.className=`re-lightbox-iframe`,a.allow=`autoplay; fullscreen; picture-in-picture`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.loading=`lazy`,a.title=n,a.src=`about:blank`,t.trim())try{let e=new URL(t,i.baseURI);/^https?:$/.test(e.protocol)&&(a.src=e.href),e.origin!==i.location.origin&&(r??=`allow-scripts allow-same-origin allow-forms allow-presentation allow-popups`)}catch{}return r!=null&&(a.sandbox=r),e.append(a),a}function t(e,t){return new Promise(n=>e.addEventListener(`load`,n,{once:!0,signal:t}))}function n(n={}){return{type:`iframe`,mount(r,{item:i,signal:a}){let o=e(r,i.src??``,i.alt??``,n.sandbox);return{interactive:!0,ready:t(o,a),unmount:()=>o.remove()}}}}export{e as frameOf,n as iframe,t as loaded};
|
|
3
3
|
//# sourceMappingURL=iframe.js.map
|