Files
bridget/bundled/js/BMxMXX.js
Sped0n 268159e7d2 refactor: unify bundled assets with subdirs and Hugo mounts
Move bundled outputs to dedicated css/js subdirs. Update Vite
config to output directly to bundled/ with simplified naming.
Add Hugo module mounts to expose as assets/bundled and
static/bundled. Adjust gitignore and partial accordingly.

Signed-off-by: Sped0n <hi@sped0n.com>
2025-11-14 18:15:24 +08:00

2 lines
7.5 KiB
JavaScript

import{c as C,o as j,a as se,t as L,i as _,b as B,s as ae,u as M,d as k,e as O,f as G,g as E,F as p,h as re,j as y,l as oe,k as ee,m as te,n as ne,p as K,S as q}from"./main.js";var ie=L("<div class=cursor><div class=cursorInner>");function le(e){let t;const[n,h]=C({x:0,y:0}),x=i=>{const{clientX:u,clientY:g}=i;h({x:u,y:g})};return j(()=>{t=new AbortController;const i=t.signal;window.addEventListener("mousemove",x,{passive:!0,signal:i})}),se(()=>{t?.abort()}),(()=>{var i=ie(),u=i.firstChild;return _(u,()=>e.cursorText()),B(g=>{var m=!!e.active(),v=`translate3d(${n().x}px, ${n().y}px, 0)`;return m!==g.e&&i.classList.toggle("active",g.e=m),v!==g.t&&ae(i,"transform",g.t=v),g},{e:void 0,t:void 0}),i})()}const U=document.getElementsByClassName("threshold")[0],ce=Array.from(U.getElementsByClassName("num")),de=U.getElementsByClassName("dec").item(0),ue=U.getElementsByClassName("inc").item(0),ge=document.getElementsByClassName("index").item(0),he=Array.from(ge.getElementsByClassName("num"));function ve(e){ce.forEach((t,n)=>{t.innerText=e[n]})}function fe(e,t){he.forEach((n,h)=>{h<4?n.innerText=e[h]:n.innerText=t[h-4]})}function xe(){const[e,{incThreshold:t,decThreshold:n}]=M();return k(()=>{fe(O(e().index+1),O(e().length)),ve(O(e().threshold))}),de.onclick=n,ue.onclick=t,null}var me=L("<div class=stage>"),ye=L("<img>");function D(e){return e.map(t=>t.i)}function Ie(e,t){return D(e).slice(-t.trailLength)}function J(e,t){return Ie(e,t).slice(0,-1)}function N(e){return D(e).slice(-1)[0]}function $(e,t){return ne(e.slice(-1)[0].i,t.length)}function S(e,t){return te(e.slice(-1)[0].i,t.length)}function I(e,t){return t.map(n=>e[n])}function Q(e){e.forEach(t=>{t.src!==t.dataset.hiUrl&&(t.src=t.dataset.hiUrl,t.height=parseInt(t.dataset.hiImgH),t.width=parseInt(t.dataset.hiImgW))})}function Z(e){e.forEach(t=>{t.src!==t.dataset.loUrl&&(t.src=t.dataset.loUrl,t.height=parseInt(t.dataset.loImgH),t.width=parseInt(t.dataset.loImgW))})}function we(e,t,n={attributes:!0}){new MutationObserver((h,x)=>{for(const i of h)if(t(i)){x.disconnect();break}}).observe(e,n)}function Te(e){let t;const n=Array(e.ijs.length);let h={x:0,y:0},x,i=!1;const[u,{incIndex:g}]=M(),m=u().length;let v=!1;const A=s=>{if(e.isOpen()||e.isAnimating()||!i||!v)return;const a={x:s.clientX,y:s.clientY};if(Math.hypot(a.x-h.x,a.y-h.y)>u().threshold){h=a,g();const c={i:u().index,...a};e.setCordHist(r=>[...r,c].slice(-m))}},b=()=>{e.isAnimating()||e.setIsOpen(!0)},l=()=>{if(!v||n.length===0)return;const s=e.cordHist(),a=D(s);if(a.length===0)return;const d=I(n,a),o=e.isOpen(),c=u();if(t.set(d,{x:r=>s[r].x-window.innerWidth/2,y:r=>s[r].y-window.innerHeight/2,opacity:r=>Math.max((r+1+c.trailLength<=s.length?0:1)-(o?1:0),0),zIndex:r=>r,scale:.6}),o){const r=I(n,[N(s)])[0],T=[],H=[];switch(e.navVector()){case"prev":T.push($(s,c)),H.push(S(s,c));break;case"next":T.push(S(s,c)),H.push($(s,c));break}Q(I(n,T)),t.set(I(n,H),{opacity:0}),t.set(r,{x:0,y:0,scale:1}),W(r)}else Z(d)},f=async()=>{if(!v||!i)throw new Error("not mounted or gsap not loaded");e.setIsAnimating(!0);const s=e.cordHist(),a=u(),d=N(s),o=n[d];Q(I(n,[d,$(s,a),S(s,a)])),W(o);const c=t.timeline(),r=I(n,J(s,a));return c.to(r,{y:"+=20",ease:"power3.in",stagger:.075,duration:.3,delay:.1,opacity:0}),c.to(o,{x:0,y:0,ease:"power3.inOut",duration:.7,delay:.3}),c.to(o,{delay:.1,scale:1,ease:"power3.inOut"}),await c.then(()=>{e.setIsAnimating(!1)})},w=async()=>{if(!v||!i)throw new Error("not mounted or gsap not loaded");e.setIsAnimating(!0),e.setNavVector("none");const s=e.cordHist(),a=u(),d=N(s),o=J(s,a);Z(I(n,[...o,d]));const c=t.timeline(),r=I(n,[d])[0],T=I(n,o);return c.to(r,{scale:.6,duration:.6,ease:"power3.inOut"}),c.to(r,{delay:.3,duration:.7,ease:"power3.inOut",x:s.slice(-1)[0].x-window.innerWidth/2,y:s.slice(-1)[0].y-window.innerHeight/2}),c.to(T,{y:"-=20",ease:"power3.out",stagger:-.1,duration:.3,opacity:1}),await c.then(()=>{e.setIsAnimating(!1)})};function W(s){if(!(!v||!i))if(s.complete)t.set(s,{opacity:1}).then(()=>{e.setIsLoading(!1)}).catch(a=>{console.log(a)});else{e.setIsLoading(!0);const a=new AbortController,d=a.signal;s.addEventListener("load",()=>{t.to(s,{opacity:1,ease:"power3.out",duration:.5}).then(()=>{e.setIsLoading(!1)}).catch(o=>{console.log(o)}).finally(()=>{a.abort()})},{once:!0,passive:!0,signal:d}),s.addEventListener("error",()=>{t.set(s,{opacity:1}).then(()=>{e.setIsLoading(!1)}).catch(o=>{console.log(o)}).finally(()=>{a.abort()})},{once:!0,passive:!0,signal:d})}}return j(()=>{n.forEach((a,d)=>{d<5&&(a.src=a.dataset.loUrl),we(a,o=>e.isOpen()||e.isAnimating()||o.attributeName!=="style"||parseFloat(a.style.opacity)!==1?!1:(d+5<n.length&&(n[d+5].src=n[d+5].dataset.loUrl),!0))}),window.addEventListener("mousemove",()=>{oe().then(a=>{t=a,i=!0}).catch(a=>{console.log(a)})},{passive:!0,once:!0}),x=new AbortController;const s=x.signal;window.addEventListener("mousemove",A,{passive:!0,signal:s}),v=!0}),k(G(()=>e.cordHist(),()=>{l()},{defer:!0})),k(G(()=>e.isOpen(),async()=>{e.isAnimating()||(e.isOpen()?await f().catch(()=>{}).then(()=>{x?.abort()}):await w().catch(()=>{}).then(()=>{x=new AbortController;const s=x.signal;window.addEventListener("mousemove",A,{passive:!0,signal:s}),e.setIsLoading(!1)}))},{defer:!0})),(()=>{var s=me();return s.$$keydown=b,s.$$click=b,_(s,E(p,{get each(){return e.ijs},children:(a,d)=>(()=>{var o=ye(),c=n[d()];return typeof c=="function"?re(c,o):n[d()]=o,B(r=>{var T=a.loImgH,H=a.loImgW,V=a.hiUrl,F=a.hiImgH,P=a.hiImgW,X=a.loUrl,z=a.loImgH,R=a.loImgW,Y=a.alt;return T!==r.e&&y(o,"height",r.e=T),H!==r.t&&y(o,"width",r.t=H),V!==r.a&&y(o,"data-hi-url",r.a=V),F!==r.o&&y(o,"data-hi-img-h",r.o=F),P!==r.i&&y(o,"data-hi-img-w",r.i=P),X!==r.n&&y(o,"data-lo-url",r.n=X),z!==r.s&&y(o,"data-lo-img-h",r.s=z),R!==r.h&&y(o,"data-lo-img-w",r.h=R),Y!==r.r&&y(o,"alt",r.r=Y),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),o})()})),s})()}ee(["click","keydown"]);var Ee=L("<div class=navOverlay>"),be=L("<div class=overlay tabindex=-1>");function Ce(e){let t;const n=[e.prevText,e.closeText,e.nextText],[h,{incIndex:x,decIndex:i}]=M(),u=h().length,g=()=>{e.setNavVector("prev"),e.setCordHist(l=>l.map(f=>({...f,i:ne(f.i,u)}))),i()},m=()=>{e.setIsOpen(!1)},v=()=>{e.setNavVector("next"),e.setCordHist(l=>l.map(f=>({...f,i:te(f.i,u)}))),x()},A=l=>{!e.isOpen()||e.isAnimating()||(l===n[0]?g():l===n[1]?m():v())},b=l=>{!e.isOpen()||e.isAnimating()||(l.key==="ArrowLeft"?g():l.key==="Escape"?m():l.key==="ArrowRight"&&v())};return k(()=>{if(e.isOpen()){t=new AbortController;const l=t.signal;window.addEventListener("keydown",b,{passive:!0,signal:l})}else t?.abort()}),(()=>{var l=Ee();return _(l,E(p,{each:n,children:f=>(()=>{var w=be();return w.$$mouseover=()=>e.setHoverText(f),w.addEventListener("focus",()=>e.setHoverText(f)),w.$$click=()=>{A(f)},w})()})),B(()=>l.classList.toggle("active",!!e.active())),l})()}ee(["click","mouseover"]);function He(e){const[t,n]=C([]),[h,x]=C(!1),[i,u]=C(!1),[g,m]=C(!1),[v,A]=C(""),[b,l]=C("none"),f=K(()=>i()&&!g()),w=K(()=>h()?e.loadingText:v());return[E(xe,{}),E(q,{get when(){return e.ijs.length>0},get children(){return[E(Te,{get ijs(){return e.ijs},setIsLoading:x,isOpen:i,setIsOpen:u,isAnimating:g,setIsAnimating:m,cordHist:t,setCordHist:n,navVector:b,setNavVector:l}),E(q,{get when(){return i()},get children(){return[E(le,{cursorText:w,active:f,isOpen:i}),E(Ce,{get prevText(){return e.prevText},get closeText(){return e.closeText},get nextText(){return e.nextText},get loadingText(){return e.loadingText},active:f,isAnimating:g,setCordHist:n,isOpen:i,setIsOpen:u,setHoverText:A,navVector:b,setNavVector:l})]}})]}})]}export{He as default};