aptechka 0.72.4 → 0.72.6
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/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +47 -47
- package/lib/video/index.cjs +1 -1
- package/lib/video/index.js +1 -1
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _t=Object.defineProperty,te=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var Vt=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Ft=a=>{throw TypeError(a)};var Ot=(a,t,s)=>t in a?_t(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,ft=(a,t)=>{for(var s in t||(t={}))se.call(t,s)&&Ot(a,s,t[s]);if(zt)for(var s of zt(t))ie.call(t,s)&&Ot(a,s,t[s]);return a},Lt=(a,t)=>te(a,ee(t));var wt=(a,t,s)=>t.has(a)||Ft("Cannot "+s);var e=(a,t,s)=>(wt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),r=(a,t,s,i)=>(wt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),E=(a,t,s)=>(wt(a,t,"access private method"),s);var B=(a,t,s)=>new Promise((i,h)=>{var v=L=>{try{f(s.next(L))}catch(H){h(H)}},A=L=>{try{f(s.throw(L))}catch(H){h(H)}},f=L=>L.done?i(L.value):Promise.resolve(L.value).then(v,A);f((s=s.apply(a,t)).next())});var Bt=(a,t,s)=>(t=a[Vt("asyncIterator")])?t.call(a):(a=a[Vt("iterator")](),t={},s=(i,h)=>(h=a[i])&&(t[i]=v=>new Promise((A,f,L)=>(v=h.call(a,v),L=v.done,Promise.resolve(v.value).then(H=>A({value:H,done:L}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yt=require("../index-DekP7OZe.cjs"),R=require("../events-KVanG9sR.cjs"),ne=require("../polyfills-Df4r-ETT.cjs"),Wt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),re=require("../css-value-parser/index.cjs");class jt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Yt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",jt);var M,l,U,nt,G;class yt{constructor(t,s){o(this,M);o(this,l);o(this,U);o(this,nt,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,M).previousURL)history.back();else{r(this,U,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),A=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=A?re.cssValueParser.parse(A):void 0,L=e(this,l).hasAttribute("data-revalidate"),H=e(this,l).hasAttribute("data-keep-search-parameters"),$t=e(this,l).hasAttribute("data-keep-scroll-position"),ht=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ct=>ct.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,M).navigate(e(this,U),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:L,keepSearchParameters:H,submorph:ht,clearState:c,keepScrollPosition:$t})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,M).prefetch(e(this,U),t),e(this,l).removeEventListener("pointerenter",e(this,G))});r(this,M,s),r(this,l,t),r(this,U,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,nt)),this.checkCurrent(location.href.replace(location.origin,"")),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,M).normalizePath(t),i=e(this,M).normalizePath(e(this,U));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?e(this,l).classList.add("current"):e(this,l).classList.remove("current"),s.path===i.path?e(this,l).classList.add("exact"):e(this,l).classList.remove("exact")}destroy(){e(this,l).removeEventListener("click",e(this,nt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}M=new WeakMap,l=new WeakMap,U=new WeakMap,nt=new WeakMap,G=new WeakMap;const ae=new DOMParser;var T,W,y,k,X,D,J,Y,I,Q,rt;class Xt{constructor(t,s){o(this,T);o(this,W);o(this,y,{x:0,y:0});o(this,k,null);o(this,X,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,I,null);o(this,Q);o(this,rt);r(this,T,t),r(this,W,s),r(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,D)}setHeaders(t){r(this,rt,t)}setInitialDocument(t){r(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,I)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,k)&&e(this,T).isPopstateNavigation?e(this,I):(r(this,Q,t),r(this,I,new Promise(h=>B(this,null,function*(){try{r(this,Y,new AbortController);const A=yield(yield fetch(t,{signal:e(this,Y).signal,headers:ft({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(t)},e(this,rt))})).text(),f=ae.parseFromString(A,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{r(this,Y,null),r(this,I,null),h()}}))),e(this,I))})}cloneDocument(){r(this,D,(e(this,X)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,D).title)t=e(this,D).title;else{const s=e(this,D).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){r(this,X,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,T).scrollValue.left,e(this,y).y=e(this,T).scrollValue.top)}restoreScrollPosition(){e(this,T).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?r(this,X,null):r(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){r(this,J,t)}clearState(){const t=e(this,J);return r(this,J,null),t}}T=new WeakMap,W=new WeakMap,y=new WeakMap,k=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,I=new WeakMap,Q=new WeakMap,rt=new WeakMap;var C,Z,g,z,m,j,V,O,P,at,x,K,_,tt,ot,u,Pt,lt,pt,At,Kt,kt,Ct,Ht,Rt,Et,et;const it=class it{constructor(t){o(this,u);o(this,C,null);o(this,Z,null);o(this,g,[]);o(this,z);o(this,m,null);o(this,j);o(this,V,[]);o(this,O,!1);o(this,P,null);o(this,at,!1);o(this,x,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,ot,null);o(this,lt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,Et,t=>B(this,null,function*(){t.preventDefault(),r(this,O,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:e(this,ot)||void 0}),r(this,O,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),h=t-e(this,_);r(this,tt,s),r(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),R.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Yt.isBrowser&&!it.instance){it.instance=this,r(this,C,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),r(this,Z,E(this,u,At).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);r(this,m,s);const i=new Xt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,x).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,Et)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),r(this,K,new jt),E(this,u,Ht).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,O)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,x).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,x).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,V).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,pt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate($t){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:A,submorph:f,clearState:L,keepScrollPosition:H}={}){var ct,Mt,Tt,xt;if(e(this,V).length)return;r(this,ot,f||null);const ht=((ct=this.pathnameModifier)==null?void 0:ct.call(this,t))||t,c=this.normalizePath(ht);if(e(this,g).forEach($=>{$.checkCurrent(c.path)}),((Mt=e(this,z))==null?void 0:Mt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Rt).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),R.dispatchEvent(document,"morphSamePath",{custom:!0}),((Tt=e(this,m))==null?void 0:Tt.parameters)!==c.parameters&&(r(this,j,e(this,m)),r(this,m,c),st.changeHistory({action:((xt=e(this,m))==null?void 0:xt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),R.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}r(this,z,c);try{let $=!0;if(this.preprocessor)try{yield new Promise((n,S)=>{var b;(b=this.preprocessor)==null||b.call(this,{url:c,resolve:n,reject:S,submorph:f})})}catch(n){n?console.error(n):console.log("Route change canceled"),$=!1}if(!$||e(this,z).pathname!==c.pathname){e(this,g).forEach(n=>{n.checkCurrent(e(this,m).path)});return}const Nt={url:c,submorph:f};f?f.forEach(n=>{document.querySelectorAll(n).forEach(S=>{S.classList.add("out"),S.setAttribute("data-morph-out","")})}):e(this,Z).forEach(n=>{var S,b;(S=n.firstElementChild)==null||S.classList.add("out"),(b=n.firstElementChild)==null||b.setAttribute("data-morph-out","")}),R.dispatchEvent(document,"morphNavigation",{detail:Nt});const gt=E(this,u,pt).call(this,e(this,m).pathname),p=E(this,u,pt).call(this,c.pathname);if(e(this,x).forEach(n=>{n.pathname!==c.pathname&&n.abort()}),yield p==null?void 0:p.fetch(ht,e(this,m).path,v),e(this,z).pathname!==c.pathname){e(this,g).forEach(n=>{n.checkCurrent(e(this,m).path)});return}gt.clearState(),gt.saveScrollState(),gt.saveDocumentState(),e(this,O)||(p.clearScrollState(),p.clearDocumentState()),L&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const ut=Lt(ft({},Nt),{document:p.document});ut.document.querySelectorAll("[data-morph-out]").forEach(n=>{n.classList.remove("out")}),R.dispatchEvent(document,"morphStart",{detail:ut});const qt=Array.from(document.head.children),Ut=Array.from(p.document.head.children),Dt=E(this,u,Kt).call(this,qt,Ut),Gt=E(this,u,kt).call(this,qt,Dt),dt=E(this,u,kt).call(this,Ut,Dt).filter(n=>!this.excludeHeadChild(n));dt.forEach((n,S)=>{n.tagName==="SCRIPT"&&(dt[S]=E(this,u,Pt).call(this,n))}),dt.forEach(n=>{document.head.appendChild(n)});const vt=dt.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(E(this,u,Ct).call(this,n))return!0});e(this,C).waitForHeadToLoad&&vt.length&&(yield new Promise(n=>B(this,null,function*(){let S=0;try{for(var b=Bt(vt),Qt,F,N;Qt=!(F=yield b.next()).done;Qt=!1){const mt=F.value;mt.onload=()=>{S++,S===vt.length&&n()}}}catch(F){N=[F]}finally{try{Qt&&(F=b.return)&&(yield F.call(b))}finally{if(N)throw N[0]}}}))),yield Wt.wait(10);const It=[];Gt.forEach(n=>{n.hasAttribute("data-permanent")||(E(this,u,Ct).call(this,n)?It.push(n):n.remove())});const Jt=E(this,u,At).call(this,p.document.body);!e(this,C).morphInsideScrollContainer&&!f&&E(this,u,Ht).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),st.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(A?location.search:""),hash:c.hash}),e(this,K).remove(),r(this,j,e(this,m)),r(this,m,c);const St=[];e(this,Z).forEach((n,S)=>{const b=Jt[S],Qt=getComputedStyle(n).getPropertyValue("--morph-duration");let F=[],N=[];f?(f.forEach(d=>{const w=n.querySelector(d),q=b.querySelector(d);w&&q&&(N.push(w),F.push(q))}),N.forEach(d=>{d.parentElement&&St.push(d.parentElement)})):(F.push(...b.childNodes),N.push(...n.childNodes),St.push(n)),N.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var q;(q=N[w].parentElement)==null||q.insertBefore(d,N[w])}):n.prepend(...F),ne.requestIdleCallback(()=>{N.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const mt=Lt(ft({},ut),{morphElement:n});R.dispatchEvent(document,"morphNewChildrenAdded",{detail:mt});const Zt=new Promise(d=>{setTimeout(()=>{N.forEach(w=>w.remove()),F.forEach(w=>{var q;w instanceof HTMLElement&&((q=w.parentElement)==null||q.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),R.dispatchEvent(document,"morphOldChildrenRemoved",{detail:mt}),d()},(parseFloat(Qt)||0)*1e3+10)});e(this,V).push(Zt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),R.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Rt).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,O)?p.restoreScrollPosition():H||p.renewScrollPosition(),yield Promise.all(e(this,V)),It.forEach(n=>n.remove()),r(this,V,[]),St.forEach(n=>{n.querySelectorAll("script").forEach(b=>{b.replaceWith(E(this,u,Pt).call(this,b))})}),e(this,g).forEach(n=>{n.checkCurrent(e(this,m).path)}),R.dispatchEvent(document,"morphComplete",{detail:ut}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}r(this,z,void 0)})}addLink(t){e(this,g).push(new yt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){r(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){r(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,lt));e(this,g).push(...s.map(i=>new yt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,lt));e(this,g).forEach(s=>s.destroy()),r(this,g,t.map(s=>new yt(s,this)))}};C=new WeakMap,Z=new WeakMap,g=new WeakMap,z=new WeakMap,m=new WeakMap,j=new WeakMap,V=new WeakMap,O=new WeakMap,P=new WeakMap,at=new WeakMap,x=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,ot=new WeakMap,u=new WeakSet,Pt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},lt=new WeakMap,pt=function(t){const s=this.normalizePath(t);let i=e(this,x).get(s.pathname);return i||(i=new Xt(this,s.pathname),e(this,x).set(s.pathname,i)),i},At=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Kt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},Ct=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ht=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,et)),r(this,tt,0),r(this,_,0),r(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),r(this,at,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},Rt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Wt.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Et=new WeakMap,et=new WeakMap,it.instance=null;let bt=it;exports.Morph=bt;
|
|
1
|
+
"use strict";var _t=Object.defineProperty,te=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var Vt=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Ft=a=>{throw TypeError(a)};var Ot=(a,t,s)=>t in a?_t(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,ft=(a,t)=>{for(var s in t||(t={}))se.call(t,s)&&Ot(a,s,t[s]);if(zt)for(var s of zt(t))ie.call(t,s)&&Ot(a,s,t[s]);return a},Lt=(a,t)=>te(a,ee(t));var wt=(a,t,s)=>t.has(a)||Ft("Cannot "+s);var e=(a,t,s)=>(wt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),r=(a,t,s,i)=>(wt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),E=(a,t,s)=>(wt(a,t,"access private method"),s);var B=(a,t,s)=>new Promise((i,h)=>{var g=L=>{try{f(s.next(L))}catch(H){h(H)}},A=L=>{try{f(s.throw(L))}catch(H){h(H)}},f=L=>L.done?i(L.value):Promise.resolve(L.value).then(g,A);f((s=s.apply(a,t)).next())});var Bt=(a,t,s)=>(t=a[Vt("asyncIterator")])?t.call(a):(a=a[Vt("iterator")](),t={},s=(i,h)=>(h=a[i])&&(t[i]=g=>new Promise((A,f,L)=>(g=h.call(a,g),L=g.done,Promise.resolve(g.value).then(H=>A({value:H,done:L}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yt=require("../index-DekP7OZe.cjs"),R=require("../events-KVanG9sR.cjs"),ne=require("../polyfills-Df4r-ETT.cjs"),Wt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),re=require("../css-value-parser/index.cjs");class jt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Yt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",jt);var M,l,U,nt,G;class yt{constructor(t,s){o(this,M);o(this,l);o(this,U);o(this,nt,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,M).previousURL)history.back();else{r(this,U,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",g=e(this,l).hasAttribute("data-center-scroll"),A=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=A?re.cssValueParser.parse(A):void 0,L=e(this,l).hasAttribute("data-revalidate"),H=e(this,l).hasAttribute("data-keep-search-parameters"),$t=e(this,l).hasAttribute("data-keep-scroll-position"),ht=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ct=>ct.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,M).navigate(e(this,U),{historyAction:h,centerScroll:g,offsetScroll:f,revalidate:L,keepSearchParameters:H,submorph:ht,clearState:c,keepScrollPosition:$t})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,M).prefetch(e(this,U),t),e(this,l).removeEventListener("pointerenter",e(this,G))});r(this,M,s),r(this,l,t),r(this,U,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,nt)),this.checkCurrent(location.href.replace(location.origin,"")),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,M).normalizePath(t),i=e(this,M).normalizePath(e(this,U));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(g=>s.pathname.includes(g))?e(this,l).classList.add("current"):e(this,l).classList.remove("current"),s.path===i.path?e(this,l).classList.add("exact"):e(this,l).classList.remove("exact")}destroy(){e(this,l).removeEventListener("click",e(this,nt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}M=new WeakMap,l=new WeakMap,U=new WeakMap,nt=new WeakMap,G=new WeakMap;const ae=new DOMParser;var T,W,y,k,X,D,J,Y,I,Q,rt;class Xt{constructor(t,s){o(this,T);o(this,W);o(this,y,{x:0,y:0});o(this,k,null);o(this,X,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,I,null);o(this,Q);o(this,rt);r(this,T,t),r(this,W,s),r(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,D)}setHeaders(t){r(this,rt,t)}setInitialDocument(t){r(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return!i&&(e(this,I)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&e(this,Q)!==t||e(this,k)&&e(this,T).isPopstateNavigation)?e(this,I):(r(this,Q,t),r(this,I,new Promise(h=>B(this,null,function*(){try{r(this,Y,new AbortController);const A=yield(yield fetch(t,{signal:e(this,Y).signal,headers:ft({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(t)},e(this,rt))})).text(),f=ae.parseFromString(A,"text/html");this.setInitialDocument(f)}catch(g){console.warn(g)}finally{r(this,Y,null),r(this,I,null),h()}}))),e(this,I))})}cloneDocument(){r(this,D,(e(this,X)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,D).title)t=e(this,D).title;else{const s=e(this,D).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){r(this,X,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,T).scrollValue.left,e(this,y).y=e(this,T).scrollValue.top)}restoreScrollPosition(){e(this,T).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?r(this,X,null):r(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){r(this,J,t)}clearState(){const t=e(this,J);return r(this,J,null),t}}T=new WeakMap,W=new WeakMap,y=new WeakMap,k=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,I=new WeakMap,Q=new WeakMap,rt=new WeakMap;var C,Z,v,z,m,j,V,O,P,at,x,K,_,tt,ot,u,Pt,lt,pt,At,Kt,kt,Ct,Ht,Rt,Et,et;const it=class it{constructor(t){o(this,u);o(this,C,null);o(this,Z,null);o(this,v,[]);o(this,z);o(this,m,null);o(this,j);o(this,V,[]);o(this,O,!1);o(this,P,null);o(this,at,!1);o(this,x,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,ot,null);o(this,lt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,Et,t=>B(this,null,function*(){t.preventDefault(),r(this,O,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:e(this,ot)||void 0}),r(this,O,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),h=t-e(this,_);r(this,tt,s),r(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),R.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Yt.isBrowser&&!it.instance){it.instance=this,r(this,C,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),r(this,Z,E(this,u,At).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);r(this,m,s);const i=new Xt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,x).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,Et)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),r(this,K,new jt),E(this,u,Ht).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,v)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,O)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,x).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,x).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,V).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,pt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate($t){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:g,keepSearchParameters:A,submorph:f,clearState:L,keepScrollPosition:H}={}){var ct,Mt,Tt,xt;if(e(this,V).length)return;r(this,ot,f||null);const ht=((ct=this.pathnameModifier)==null?void 0:ct.call(this,t))||t,c=this.normalizePath(ht);if(e(this,v).forEach($=>{$.checkCurrent(c.path)}),!g&&(((Mt=e(this,z))==null?void 0:Mt.pathname)===c.pathname||e(this,m).pathname===c.pathname)){E(this,u,Rt).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),R.dispatchEvent(document,"morphSamePath",{custom:!0}),((Tt=e(this,m))==null?void 0:Tt.parameters)!==c.parameters&&(r(this,j,e(this,m)),r(this,m,c),st.changeHistory({action:((xt=e(this,m))==null?void 0:xt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),R.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}r(this,z,c);try{let $=!0;if(this.preprocessor)try{yield new Promise((n,S)=>{var b;(b=this.preprocessor)==null||b.call(this,{url:c,resolve:n,reject:S,submorph:f})})}catch(n){n?console.error(n):console.log("Route change canceled"),$=!1}if(!$||e(this,z).pathname!==c.pathname){e(this,v).forEach(n=>{n.checkCurrent(e(this,m).path)});return}const Nt={url:c,submorph:f};f?f.forEach(n=>{document.querySelectorAll(n).forEach(S=>{S.classList.add("out"),S.setAttribute("data-morph-out","")})}):e(this,Z).forEach(n=>{var S,b;(S=n.firstElementChild)==null||S.classList.add("out"),(b=n.firstElementChild)==null||b.setAttribute("data-morph-out","")}),R.dispatchEvent(document,"morphNavigation",{detail:Nt});const gt=E(this,u,pt).call(this,e(this,m).pathname),p=E(this,u,pt).call(this,c.pathname);if(e(this,x).forEach(n=>{n.pathname!==c.pathname&&n.abort()}),yield p==null?void 0:p.fetch(ht,e(this,m).path,g),e(this,z).pathname!==c.pathname){e(this,v).forEach(n=>{n.checkCurrent(e(this,m).path)});return}gt.clearState(),gt.saveScrollState(),gt.saveDocumentState(),e(this,O)||(p.clearScrollState(),p.clearDocumentState()),L&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const ut=Lt(ft({},Nt),{document:p.document});ut.document.querySelectorAll("[data-morph-out]").forEach(n=>{n.classList.remove("out")}),R.dispatchEvent(document,"morphStart",{detail:ut});const qt=Array.from(document.head.children),Ut=Array.from(p.document.head.children),Dt=E(this,u,Kt).call(this,qt,Ut),Gt=E(this,u,kt).call(this,qt,Dt),dt=E(this,u,kt).call(this,Ut,Dt).filter(n=>!this.excludeHeadChild(n));dt.forEach((n,S)=>{n.tagName==="SCRIPT"&&(dt[S]=E(this,u,Pt).call(this,n))}),dt.forEach(n=>{document.head.appendChild(n)});const vt=dt.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(E(this,u,Ct).call(this,n))return!0});e(this,C).waitForHeadToLoad&&vt.length&&(yield new Promise(n=>B(this,null,function*(){let S=0;try{for(var b=Bt(vt),Qt,F,N;Qt=!(F=yield b.next()).done;Qt=!1){const mt=F.value;mt.onload=()=>{S++,S===vt.length&&n()}}}catch(F){N=[F]}finally{try{Qt&&(F=b.return)&&(yield F.call(b))}finally{if(N)throw N[0]}}}))),yield Wt.wait(10);const It=[];Gt.forEach(n=>{n.hasAttribute("data-permanent")||(E(this,u,Ct).call(this,n)?It.push(n):n.remove())});const Jt=E(this,u,At).call(this,p.document.body);!e(this,C).morphInsideScrollContainer&&!f&&E(this,u,Ht).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),st.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(A?location.search:""),hash:c.hash}),e(this,K).remove(),r(this,j,e(this,m)),r(this,m,c);const St=[];e(this,Z).forEach((n,S)=>{const b=Jt[S],Qt=getComputedStyle(n).getPropertyValue("--morph-duration");let F=[],N=[];f?(f.forEach(d=>{const w=n.querySelector(d),q=b.querySelector(d);w&&q&&(N.push(w),F.push(q))}),N.forEach(d=>{d.parentElement&&St.push(d.parentElement)})):(F.push(...b.childNodes),N.push(...n.childNodes),St.push(n)),N.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var q;(q=N[w].parentElement)==null||q.insertBefore(d,N[w])}):n.prepend(...F),ne.requestIdleCallback(()=>{N.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const mt=Lt(ft({},ut),{morphElement:n});R.dispatchEvent(document,"morphNewChildrenAdded",{detail:mt});const Zt=new Promise(d=>{setTimeout(()=>{N.forEach(w=>w.remove()),F.forEach(w=>{var q;w instanceof HTMLElement&&((q=w.parentElement)==null||q.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),R.dispatchEvent(document,"morphOldChildrenRemoved",{detail:mt}),d()},(parseFloat(Qt)||0)*1e3+10)});e(this,V).push(Zt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),R.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Rt).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,O)?p.restoreScrollPosition():H||p.renewScrollPosition(),yield Promise.all(e(this,V)),It.forEach(n=>n.remove()),r(this,V,[]),St.forEach(n=>{n.querySelectorAll("script").forEach(b=>{b.replaceWith(E(this,u,Pt).call(this,b))})}),e(this,v).forEach(n=>{n.checkCurrent(e(this,m).path)}),R.dispatchEvent(document,"morphComplete",{detail:ut}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}r(this,z,void 0)})}addLink(t){e(this,v).push(new yt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){r(this,v,e(this,v).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){r(this,v,e(this,v).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,lt));e(this,v).push(...s.map(i=>new yt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,lt));e(this,v).forEach(s=>s.destroy()),r(this,v,t.map(s=>new yt(s,this)))}};C=new WeakMap,Z=new WeakMap,v=new WeakMap,z=new WeakMap,m=new WeakMap,j=new WeakMap,V=new WeakMap,O=new WeakMap,P=new WeakMap,at=new WeakMap,x=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,ot=new WeakMap,u=new WeakSet,Pt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},lt=new WeakMap,pt=function(t){const s=this.normalizePath(t);let i=e(this,x).get(s.pathname);return i||(i=new Xt(this,s.pathname),e(this,x).set(s.pathname,i)),i},At=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Kt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},Ct=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ht=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,et)),r(this,tt,0),r(this,_,0),r(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),r(this,at,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},Rt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Wt.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Et=new WeakMap,et=new WeakMap,it.instance=null;let bt=it;exports.Morph=bt;
|
package/lib/morph/index.js
CHANGED
|
@@ -13,31 +13,31 @@ var Vt = (a, t, s) => t in a ? Zt(a, t, { enumerable: !0, configurable: !0, writ
|
|
|
13
13
|
se.call(t, s) && Vt(a, s, t[s]);
|
|
14
14
|
return a;
|
|
15
15
|
}, Lt = (a, t) => _t(a, te(t));
|
|
16
|
-
var
|
|
17
|
-
var e = (a, t, s) => (
|
|
16
|
+
var wt = (a, t, s) => t.has(a) || Ot("Cannot " + s);
|
|
17
|
+
var e = (a, t, s) => (wt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), o = (a, t, s) => t.has(a) ? Ot("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, s), n = (a, t, s, i) => (wt(a, t, "write to private field"), i ? i.call(a, s) : t.set(a, s), s), E = (a, t, s) => (wt(a, t, "access private method"), s);
|
|
18
18
|
var W = (a, t, s) => new Promise((i, h) => {
|
|
19
|
-
var
|
|
19
|
+
var g = (w) => {
|
|
20
20
|
try {
|
|
21
|
-
f(s.next(
|
|
21
|
+
f(s.next(w));
|
|
22
22
|
} catch (H) {
|
|
23
23
|
h(H);
|
|
24
24
|
}
|
|
25
|
-
}, P = (
|
|
25
|
+
}, P = (w) => {
|
|
26
26
|
try {
|
|
27
|
-
f(s.throw(
|
|
27
|
+
f(s.throw(w));
|
|
28
28
|
} catch (H) {
|
|
29
29
|
h(H);
|
|
30
30
|
}
|
|
31
|
-
}, f = (
|
|
31
|
+
}, f = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(g, P);
|
|
32
32
|
f((s = s.apply(a, t)).next());
|
|
33
33
|
});
|
|
34
|
-
var Ft = (a, t, s) => (t = a[zt("asyncIterator")]) ? t.call(a) : (a = a[zt("iterator")](), t = {}, s = (i, h) => (h = a[i]) && (t[i] = (
|
|
34
|
+
var Ft = (a, t, s) => (t = a[zt("asyncIterator")]) ? t.call(a) : (a = a[zt("iterator")](), t = {}, s = (i, h) => (h = a[i]) && (t[i] = (g) => new Promise((P, f, w) => (g = h.call(a, g), w = g.done, Promise.resolve(g.value).then((H) => P({ value: H, done: w }), f)))), s("next"), s("return"), t);
|
|
35
35
|
import { i as Bt } from "../index-Bv9zgfdb.js";
|
|
36
36
|
import { d as R } from "../events-CsVF98U6.js";
|
|
37
37
|
import { r as ie } from "../polyfills-DJrTJQky.js";
|
|
38
38
|
import { w as re, s as ne } from "../scroll-DPkCFTxg.js";
|
|
39
39
|
import "construct-style-sheets-polyfill";
|
|
40
|
-
import { n as ae, c as
|
|
40
|
+
import { n as ae, c as vt, s as oe } from "../url-UL9zSCHb.js";
|
|
41
41
|
import { cssValueParser as le } from "../css-value-parser/index.js";
|
|
42
42
|
class Yt extends HTMLElement {
|
|
43
43
|
connectedCallback() {
|
|
@@ -67,16 +67,16 @@ class yt {
|
|
|
67
67
|
n(this, D, e(this, l).getAttribute("href") || "/");
|
|
68
68
|
const h = e(this, l).getAttribute(
|
|
69
69
|
"data-history-action"
|
|
70
|
-
) || "push",
|
|
70
|
+
) || "push", g = e(this, l).hasAttribute("data-center-scroll"), P = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), f = P ? le.parse(P) : void 0, w = e(this, l).hasAttribute("data-revalidate"), H = e(this, l).hasAttribute(
|
|
71
71
|
"data-keep-search-parameters"
|
|
72
72
|
), Kt = e(this, l).hasAttribute(
|
|
73
73
|
"data-keep-scroll-position"
|
|
74
74
|
), lt = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((ht) => ht.trim()), c = e(this, l).hasAttribute("data-clear-state");
|
|
75
75
|
e(this, M).navigate(e(this, D), {
|
|
76
76
|
historyAction: h,
|
|
77
|
-
centerScroll:
|
|
77
|
+
centerScroll: g,
|
|
78
78
|
offsetScroll: f,
|
|
79
|
-
revalidate:
|
|
79
|
+
revalidate: w,
|
|
80
80
|
keepSearchParameters: H,
|
|
81
81
|
submorph: lt,
|
|
82
82
|
clearState: c,
|
|
@@ -96,7 +96,7 @@ class yt {
|
|
|
96
96
|
checkCurrent(t) {
|
|
97
97
|
var h;
|
|
98
98
|
const s = e(this, M).normalizePath(t), i = e(this, M).normalizePath(e(this, D));
|
|
99
|
-
e(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, l).classList.add("current") : i.pathname === s.pathname ? e(this, l).classList.add("current") : (h = e(this, l).getAttribute("data-associated-paths")) != null && h.split(",").find((
|
|
99
|
+
e(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, l).classList.add("current") : i.pathname === s.pathname ? e(this, l).classList.add("current") : (h = e(this, l).getAttribute("data-associated-paths")) != null && h.split(",").find((g) => s.pathname.includes(g)) ? e(this, l).classList.add("current") : e(this, l).classList.remove("current"), s.path === i.path ? e(this, l).classList.add("exact") : e(this, l).classList.remove("exact");
|
|
100
100
|
}
|
|
101
101
|
destroy() {
|
|
102
102
|
e(this, l).removeEventListener("click", e(this, it)), e(this, l).removeEventListener("pointerenter", e(this, G)), e(this, l).classList.remove("current");
|
|
@@ -143,7 +143,7 @@ class Wt {
|
|
|
143
143
|
}
|
|
144
144
|
fetch(t, s, i) {
|
|
145
145
|
return W(this, null, function* () {
|
|
146
|
-
return e(this, q) || e(this, k) && e(this, k).documentElement.hasAttribute("data-cache") &&
|
|
146
|
+
return !i && (e(this, q) || e(this, k) && e(this, k).documentElement.hasAttribute("data-cache") && e(this, Q) !== t || e(this, k) && e(this, T).isPopstateNavigation) ? e(this, q) : (n(this, Q, t), n(this, q, new Promise((h) => W(this, null, function* () {
|
|
147
147
|
try {
|
|
148
148
|
n(this, Y, new AbortController());
|
|
149
149
|
const P = yield (yield fetch(t, {
|
|
@@ -155,8 +155,8 @@ class Wt {
|
|
|
155
155
|
}, e(this, rt))
|
|
156
156
|
})).text(), f = he.parseFromString(P, "text/html");
|
|
157
157
|
this.setInitialDocument(f);
|
|
158
|
-
} catch (
|
|
159
|
-
console.warn(
|
|
158
|
+
} catch (g) {
|
|
159
|
+
console.warn(g);
|
|
160
160
|
} finally {
|
|
161
161
|
n(this, Y, null), n(this, q, null), h();
|
|
162
162
|
}
|
|
@@ -215,13 +215,13 @@ class Wt {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
T = new WeakMap(), X = new WeakMap(), y = new WeakMap(), k = new WeakMap(), B = new WeakMap(), I = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), q = new WeakMap(), Q = new WeakMap(), rt = new WeakMap();
|
|
218
|
-
var C, Z,
|
|
218
|
+
var C, Z, S, z, m, j, V, O, A, nt, x, K, _, tt, at, u, bt, ot, ft, At, jt, Pt, kt, Ct, Ht, pt, et;
|
|
219
219
|
const st = class st {
|
|
220
220
|
constructor(t) {
|
|
221
221
|
o(this, u);
|
|
222
222
|
o(this, C, null);
|
|
223
223
|
o(this, Z, null);
|
|
224
|
-
o(this,
|
|
224
|
+
o(this, S, []);
|
|
225
225
|
o(this, z);
|
|
226
226
|
o(this, m, null);
|
|
227
227
|
o(this, j);
|
|
@@ -284,7 +284,7 @@ const st = class st {
|
|
|
284
284
|
), document.documentElement.setAttribute(
|
|
285
285
|
"data-current-leaf",
|
|
286
286
|
s.leaf
|
|
287
|
-
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, pt)),
|
|
287
|
+
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, pt)), vt({
|
|
288
288
|
action: "replace",
|
|
289
289
|
pathname: s.pathname,
|
|
290
290
|
searchParameters: s.parameters,
|
|
@@ -299,7 +299,7 @@ const st = class st {
|
|
|
299
299
|
return e(this, j);
|
|
300
300
|
}
|
|
301
301
|
get links() {
|
|
302
|
-
return e(this,
|
|
302
|
+
return e(this, S);
|
|
303
303
|
}
|
|
304
304
|
get scrollElement() {
|
|
305
305
|
return e(this, A);
|
|
@@ -345,10 +345,10 @@ const st = class st {
|
|
|
345
345
|
historyAction: s = "push",
|
|
346
346
|
centerScroll: i,
|
|
347
347
|
offsetScroll: h,
|
|
348
|
-
revalidate:
|
|
348
|
+
revalidate: g,
|
|
349
349
|
keepSearchParameters: P,
|
|
350
350
|
submorph: f,
|
|
351
|
-
clearState:
|
|
351
|
+
clearState: w,
|
|
352
352
|
keepScrollPosition: H
|
|
353
353
|
} = {}) {
|
|
354
354
|
var ht, Rt, Mt, Tt;
|
|
@@ -356,16 +356,16 @@ const st = class st {
|
|
|
356
356
|
return;
|
|
357
357
|
n(this, at, f || null);
|
|
358
358
|
const lt = ((ht = this.pathnameModifier) == null ? void 0 : ht.call(this, t)) || t, c = this.normalizePath(lt);
|
|
359
|
-
if (e(this,
|
|
359
|
+
if (e(this, S).forEach(($) => {
|
|
360
360
|
$.checkCurrent(c.path);
|
|
361
|
-
}), ((Rt = e(this, z)) == null ? void 0 : Rt.pathname) === c.pathname || e(this, m).pathname === c.pathname) {
|
|
361
|
+
}), !g && (((Rt = e(this, z)) == null ? void 0 : Rt.pathname) === c.pathname || e(this, m).pathname === c.pathname)) {
|
|
362
362
|
E(this, u, Ht).call(this, c.hash || 0, {
|
|
363
363
|
centerScroll: i,
|
|
364
364
|
offsetScroll: h,
|
|
365
365
|
behavior: "smooth"
|
|
366
366
|
}), R(document, "morphSamePath", {
|
|
367
367
|
custom: !0
|
|
368
|
-
}), ((Mt = e(this, m)) == null ? void 0 : Mt.parameters) !== c.parameters && (n(this, j, e(this, m)), n(this, m, c),
|
|
368
|
+
}), ((Mt = e(this, m)) == null ? void 0 : Mt.parameters) !== c.parameters && (n(this, j, e(this, m)), n(this, m, c), vt({
|
|
369
369
|
action: ((Tt = e(this, m)) == null ? void 0 : Tt.hash) !== c.hash ? "replace" : s,
|
|
370
370
|
pathname: c.pathname,
|
|
371
371
|
searchParameters: c.parameters,
|
|
@@ -396,7 +396,7 @@ const st = class st {
|
|
|
396
396
|
r ? console.error(r) : console.log("Route change canceled"), $ = !1;
|
|
397
397
|
}
|
|
398
398
|
if (!$ || e(this, z).pathname !== c.pathname) {
|
|
399
|
-
e(this,
|
|
399
|
+
e(this, S).forEach((r) => {
|
|
400
400
|
r.checkCurrent(e(this, m).path);
|
|
401
401
|
});
|
|
402
402
|
return;
|
|
@@ -418,13 +418,13 @@ const st = class st {
|
|
|
418
418
|
const Et = E(this, u, ft).call(this, e(this, m).pathname), p = E(this, u, ft).call(this, c.pathname);
|
|
419
419
|
if (e(this, x).forEach((r) => {
|
|
420
420
|
r.pathname !== c.pathname && r.abort();
|
|
421
|
-
}), yield p == null ? void 0 : p.fetch(lt, e(this, m).path,
|
|
422
|
-
e(this,
|
|
421
|
+
}), yield p == null ? void 0 : p.fetch(lt, e(this, m).path, g), e(this, z).pathname !== c.pathname) {
|
|
422
|
+
e(this, S).forEach((r) => {
|
|
423
423
|
r.checkCurrent(e(this, m).path);
|
|
424
424
|
});
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
427
|
-
Et.clearState(), Et.saveScrollState(), Et.saveDocumentState(), e(this, O) || (p.clearScrollState(), p.clearDocumentState()),
|
|
427
|
+
Et.clearState(), Et.saveScrollState(), Et.saveDocumentState(), e(this, O) || (p.clearScrollState(), p.clearDocumentState()), w && p.clearState(), p.cloneDocument(), e(this, K).textContent = p.title, document.body.appendChild(e(this, K));
|
|
428
428
|
const ct = Lt(mt({}, xt), {
|
|
429
429
|
document: p.document
|
|
430
430
|
});
|
|
@@ -476,7 +476,7 @@ const st = class st {
|
|
|
476
476
|
), document.documentElement.setAttribute(
|
|
477
477
|
"data-current-leaf",
|
|
478
478
|
c.leaf
|
|
479
|
-
),
|
|
479
|
+
), vt({
|
|
480
480
|
action: s,
|
|
481
481
|
pathname: c.pathname,
|
|
482
482
|
searchParameters: c.parameters || (P ? location.search : ""),
|
|
@@ -487,26 +487,26 @@ const st = class st {
|
|
|
487
487
|
const b = Gt[L], Jt = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
488
488
|
let F = [], N = [];
|
|
489
489
|
f ? (f.forEach((d) => {
|
|
490
|
-
const
|
|
491
|
-
|
|
490
|
+
const v = r.querySelector(d), U = b.querySelector(d);
|
|
491
|
+
v && U && (N.push(v), F.push(U));
|
|
492
492
|
}), N.forEach((d) => {
|
|
493
493
|
d.parentElement && St.push(d.parentElement);
|
|
494
494
|
})) : (F.push(...b.childNodes), N.push(...r.childNodes), St.push(r)), N.forEach((d) => {
|
|
495
495
|
d instanceof HTMLElement && (this.destroyOldLinks(d), d.classList.add("old"));
|
|
496
496
|
}), F.forEach((d) => {
|
|
497
497
|
d instanceof HTMLElement && (this.findNewLinks(d), d.classList.add("new"));
|
|
498
|
-
}), f ? F.forEach((d,
|
|
498
|
+
}), f ? F.forEach((d, v) => {
|
|
499
499
|
var U;
|
|
500
|
-
(U = N[
|
|
500
|
+
(U = N[v].parentElement) == null || U.insertBefore(
|
|
501
501
|
d,
|
|
502
|
-
N[
|
|
502
|
+
N[v]
|
|
503
503
|
);
|
|
504
504
|
}) : r.prepend(...F), ie(() => {
|
|
505
505
|
N.forEach((d) => {
|
|
506
506
|
d instanceof HTMLElement && d.classList.add("old-idle");
|
|
507
507
|
}), F.forEach((d) => {
|
|
508
|
-
var
|
|
509
|
-
d instanceof HTMLElement && ((
|
|
508
|
+
var v;
|
|
509
|
+
d instanceof HTMLElement && ((v = d.parentElement) == null || v.style.setProperty(
|
|
510
510
|
"--new-content-height",
|
|
511
511
|
d.offsetHeight + "px"
|
|
512
512
|
), d.classList.add("new-idle"));
|
|
@@ -520,11 +520,11 @@ const st = class st {
|
|
|
520
520
|
});
|
|
521
521
|
const Qt = new Promise((d) => {
|
|
522
522
|
setTimeout(() => {
|
|
523
|
-
N.forEach((
|
|
523
|
+
N.forEach((v) => v.remove()), F.forEach((v) => {
|
|
524
524
|
var U;
|
|
525
|
-
|
|
525
|
+
v instanceof HTMLElement && ((U = v.parentElement) == null || U.style.removeProperty(
|
|
526
526
|
"--new-content-height"
|
|
527
|
-
),
|
|
527
|
+
), v.classList.remove("new-idle", "new"));
|
|
528
528
|
}), R(document, "morphOldChildrenRemoved", {
|
|
529
529
|
detail: dt
|
|
530
530
|
}), d();
|
|
@@ -546,7 +546,7 @@ const st = class st {
|
|
|
546
546
|
r.querySelectorAll("script").forEach((b) => {
|
|
547
547
|
b.replaceWith(E(this, u, bt).call(this, b));
|
|
548
548
|
});
|
|
549
|
-
}), e(this,
|
|
549
|
+
}), e(this, S).forEach((r) => {
|
|
550
550
|
r.checkCurrent(e(this, m).path);
|
|
551
551
|
}), R(document, "morphComplete", {
|
|
552
552
|
detail: ct
|
|
@@ -560,7 +560,7 @@ const st = class st {
|
|
|
560
560
|
});
|
|
561
561
|
}
|
|
562
562
|
addLink(t) {
|
|
563
|
-
e(this,
|
|
563
|
+
e(this, S).push(new yt(t, this));
|
|
564
564
|
}
|
|
565
565
|
addLinks(t) {
|
|
566
566
|
t.forEach((s) => {
|
|
@@ -568,16 +568,16 @@ const st = class st {
|
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
570
|
removeLink(t) {
|
|
571
|
-
n(this,
|
|
571
|
+
n(this, S, e(this, S).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
572
572
|
}
|
|
573
573
|
destroyOldLinks(t) {
|
|
574
|
-
n(this,
|
|
574
|
+
n(this, S, e(this, S).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
|
|
575
575
|
}
|
|
576
576
|
findNewLinks(t) {
|
|
577
577
|
const s = [...t.querySelectorAll("a")].filter(
|
|
578
578
|
e(this, ot)
|
|
579
579
|
);
|
|
580
|
-
e(this,
|
|
580
|
+
e(this, S).push(
|
|
581
581
|
...s.map((i) => new yt(i, this))
|
|
582
582
|
);
|
|
583
583
|
}
|
|
@@ -585,10 +585,10 @@ const st = class st {
|
|
|
585
585
|
const t = [
|
|
586
586
|
...document.documentElement.querySelectorAll("a")
|
|
587
587
|
].filter(e(this, ot));
|
|
588
|
-
e(this,
|
|
588
|
+
e(this, S).forEach((s) => s.destroy()), n(this, S, t.map((s) => new yt(s, this)));
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
|
-
C = new WeakMap(), Z = new WeakMap(),
|
|
591
|
+
C = new WeakMap(), Z = new WeakMap(), S = new WeakMap(), z = new WeakMap(), m = new WeakMap(), j = new WeakMap(), V = new WeakMap(), O = new WeakMap(), A = new WeakMap(), nt = new WeakMap(), x = new WeakMap(), K = new WeakMap(), _ = new WeakMap(), tt = new WeakMap(), at = new WeakMap(), u = new WeakSet(), bt = function(t) {
|
|
592
592
|
const s = document.createElement("script");
|
|
593
593
|
for (let i = 0; i < t.attributes.length; i++) {
|
|
594
594
|
const h = t.attributes[i];
|
package/lib/video/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=t=>{throw TypeError(t)};var m=(t,s,e)=>s.has(t)||h("Cannot "+e);var i=(t,s,e)=>(m(t,s,"read from private field"),e?e.call(t):s.get(t)),u=(t,s,e)=>s.has(t)?h("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),c=(t,s,e,l)=>(m(t,s,"write to private field"),l?l.call(t,e):s.set(t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../SourceElement-0vRhCW3O.cjs");require("../window-resizer/index.cjs");require("../Store-Cd1GlEmZ.cjs");const p=require("../index-DekP7OZe.cjs"),b=require("../events-KVanG9sR.cjs");require("construct-style-sheets-polyfill");const o=require("../ticker/index.cjs");var r,n,a;class d extends E.SourceElement{constructor(){super(...arguments);u(this,r,0);u(this,n,!1);u(this,a,()=>{this.classList.add(`state-${this.consumerElement.readyState}`);const e=this.consumerElement.readyState/4;e!==i(this,r)&&b.dispatchEvent(this,"videoReadyStateChange",{detail:{readyState:this.consumerElement.readyState,progress:i(this,r)}}),e>i(this,r)&&c(this,r,e),this.consumerElement.readyState===4&&(o.ticker.unsubscribe(i(this,a)),i(this,n)&&this.sourceManager.current&&this.consumerElement.play())})}connectedCallback(){super.connectedCallback(),this.addEventListener("sourceCapture",()=>{c(this,n,!1),this.hasAttribute("capture-autoplay")&&(this.sourceManager.current?this.consumerElement.play():c(this,n,!0)),o.ticker.subscribe(i(this,a))}),this.addEventListener("sourceRelease",()=>{this.hasAttribute("capture-autoplay")&&this.consumerElement.pause(),this.hasAttribute("release-pause")&&this.consumerElement.pause(),this.hasAttribute("release-stop")&&(this.consumerElement.pause(),this.consumerElement.currentTime=0),this.hasAttribute("replay")&&(this.consumerElement.currentTime=0),this.hasAttribute("reload-source")&&this.classList.remove("state-0","state-1","state-2","state-3","state-4")}),this.addEventListener("click",()=>{this.hasAttribute("click-controls")&&(this.consumerElement.paused?this.consumerElement.play():this.consumerElement.pause())})}disconnectedCallback(){super.disconnectedCallback(),o.ticker.unsubscribe(i(this,a)),c(this,r,0)}createConsumer(){return document.createElement("video")}consumeSource(e){this.consumerElement.src=e||"",e&&this.hasAttribute("volume")&&(this.consumerElement.volume=parseFloat(this.getAttribute("volume")||"1"))}}r=new WeakMap,n=new WeakMap,a=new WeakMap;p.isBrowser&&!customElements.get("e-video")&&customElements.define("e-video",d);exports.VideoElement=d;
|
|
1
|
+
"use strict";var h=t=>{throw TypeError(t)};var m=(t,s,e)=>s.has(t)||h("Cannot "+e);var i=(t,s,e)=>(m(t,s,"read from private field"),e?e.call(t):s.get(t)),u=(t,s,e)=>s.has(t)?h("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),c=(t,s,e,l)=>(m(t,s,"write to private field"),l?l.call(t,e):s.set(t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../SourceElement-0vRhCW3O.cjs");require("../window-resizer/index.cjs");require("../Store-Cd1GlEmZ.cjs");const p=require("../index-DekP7OZe.cjs"),b=require("../events-KVanG9sR.cjs");require("construct-style-sheets-polyfill");const o=require("../ticker/index.cjs");var r,n,a;class d extends E.SourceElement{constructor(){super(...arguments);u(this,r,0);u(this,n,!1);u(this,a,()=>{this.classList.add(`state-${this.consumerElement.readyState}`);const e=this.consumerElement.readyState/4;e!==i(this,r)&&b.dispatchEvent(this,"videoReadyStateChange",{detail:{readyState:this.consumerElement.readyState,progress:i(this,r)}}),e>i(this,r)&&c(this,r,e),this.consumerElement.readyState===4&&(o.ticker.unsubscribe(i(this,a)),i(this,n)&&this.sourceManager.current&&this.consumerElement.play())})}connectedCallback(){super.connectedCallback(),this.addEventListener("sourceCapture",()=>{c(this,n,!1),this.hasAttribute("capture-autoplay")&&(this.sourceManager.current?this.consumerElement.play():c(this,n,!0)),o.ticker.subscribe(i(this,a))}),this.addEventListener("sourceRelease",()=>{this.hasAttribute("capture-autoplay")&&this.consumerElement.pause(),this.hasAttribute("release-pause")&&this.consumerElement.pause(),this.hasAttribute("release-stop")&&(this.consumerElement.pause(),this.consumerElement.currentTime=0),this.hasAttribute("replay")&&(this.consumerElement.currentTime=0),this.hasAttribute("reload-source")&&this.classList.remove("state-0","state-1","state-2","state-3","state-4")}),this.addEventListener("click",()=>{this.hasAttribute("click-controls")&&(this.consumerElement.paused?this.consumerElement.play():this.hasAttribute("controls")||this.consumerElement.pause())})}disconnectedCallback(){super.disconnectedCallback(),o.ticker.unsubscribe(i(this,a)),c(this,r,0)}createConsumer(){return document.createElement("video")}consumeSource(e){this.consumerElement.src=e||"",e&&this.hasAttribute("volume")&&(this.consumerElement.volume=parseFloat(this.getAttribute("volume")||"1"))}}r=new WeakMap,n=new WeakMap,a=new WeakMap;p.isBrowser&&!customElements.get("e-video")&&customElements.define("e-video",d);exports.VideoElement=d;
|
package/lib/video/index.js
CHANGED
|
@@ -39,7 +39,7 @@ class f extends d {
|
|
|
39
39
|
"state-4"
|
|
40
40
|
);
|
|
41
41
|
}), this.addEventListener("click", () => {
|
|
42
|
-
this.hasAttribute("click-controls") && (this.consumerElement.paused ? this.consumerElement.play() : this.consumerElement.pause());
|
|
42
|
+
this.hasAttribute("click-controls") && (this.consumerElement.paused ? this.consumerElement.play() : this.hasAttribute("controls") || this.consumerElement.pause());
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
disconnectedCallback() {
|