aptechka 0.67.2 → 0.67.3
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 +50 -48
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ht=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Nt=a=>{throw TypeError(a)};var Et=(a,t,s)=>t.has(a)||Nt("Cannot "+s);var e=(a,t,s)=>(Et(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Nt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),r=(a,t,s,i)=>(Et(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),p=(a,t,s)=>(Et(a,t,"access private method"),s);var O=(a,t,s)=>new Promise((i,c)=>{var w=E=>{try{v(s.next(E))}catch(z){c(z)}},x=E=>{try{v(s.throw(E))}catch(z){c(z)}},v=E=>E.done?i(E.value):Promise.resolve(E.value).then(w,x);v((s=s.apply(a,t)).next())});var qt=(a,t,s)=>(t=a[Ht("asyncIterator")])?t.call(a):(a=a[Ht("iterator")](),t={},s=(i,c)=>(c=a[i])&&(t[i]=w=>new Promise((x,v,E)=>(w=c.call(a,w),E=w.done,Promise.resolve(w.value).then(z=>x({value:z,done:E}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("../index-DekP7OZe.cjs"),F=require("../events-KVanG9sR.cjs"),Yt=require("../polyfills-Df4r-ETT.cjs"),Dt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ht=require("../url-lnBE_6yf.cjs"),Xt=require("../css-value-parser/index.cjs");class Vt 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)}}Rt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Vt);var k,l,H,it,K;class St{constructor(t,s){o(this,k);o(this,l);o(this,H);o(this,it,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,k).previousPathname)history.back();else{r(this,H,e(this,l).getAttribute("href")||"/");const c=e(this,l).getAttribute("data-history-action")||"push",w=e(this,l).hasAttribute("data-center-scroll"),x=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=x?Xt.cssValueParser.parse(x):void 0,E=e(this,l).hasAttribute("data-revalidate"),z=e(this,l).hasAttribute("data-keep-search-parameters"),mt=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map($=>$.trim()),m=e(this,l).hasAttribute("data-clear-state");e(this,k).navigate(e(this,H),{historyAction:c,centerScroll:w,offsetScroll:v,revalidate:E,keepSearchParameters:z,submorph:mt,clearState:m})}});o(this,K,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,k).prefetch(e(this,H),t),e(this,l).removeEventListener("pointerenter",e(this,K))});r(this,k,s),r(this,l,t),r(this,H,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,it)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,K))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,k).normalizePath(t),i=e(this,k).normalizePath(e(this,H));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"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,it)),e(this,l).removeEventListener("pointerenter",e(this,K)),e(this,l).classList.remove("current")}}k=new WeakMap,l=new WeakMap,H=new WeakMap,it=new WeakMap,K=new WeakMap;const $t=new DOMParser;var N,G,rt,b,q,W,D,J,Y,I;class It{constructor(t,s,i){o(this,N);o(this,G);o(this,rt);o(this,b,{x:0,y:0});o(this,q,null);o(this,W,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,I,null);r(this,N,t),r(this,G,s),r(this,rt,i)}get pathname(){return e(this,G)}get searchParameters(){return e(this,rt)}get scrollState(){return e(this,b)}get document(){return e(this,D)}setInitialDocument(t){r(this,q,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${this.pathname}] page loading cancelled`)}fetch(t){return O(this,null,function*(){if(!(e(this,q)&&!t))return e(this,I)?e(this,I):(r(this,I,new Promise(s=>O(this,null,function*(){try{r(this,Y,new AbortController);const c=yield(yield fetch(`${this.pathname}${this.searchParameters?"?"+this.searchParameters:""}`,{signal:e(this,Y).signal})).text(),w=$t.parseFromString(c,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{r(this,Y,null),r(this,I,null),s()}}))),e(this,I))})}cloneDocument(){r(this,D,(e(this,W)||e(this,q)).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,G)}return t}clearScrollState(){e(this,b).x=0,e(this,b).y=0}clearDocumentState(){r(this,W,null)}saveScrollState(){e(this,q).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,b).x=0,e(this,b).y=0):(e(this,b).x=e(this,N).scrollValue.left,e(this,b).y=e(this,N).scrollValue.top)}restoreScrollPosition(){e(this,N).scrollElement.scroll({top:e(this,b).y,left:e(this,b).x,behavior:"instant"})}saveDocumentState(){e(this,q).documentElement.hasAttribute("data-no-page-restoration")?r(this,W,null):r(this,W,document.cloneNode(!0))}renewScrollPosition(){e(this,N).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}}N=new WeakMap,G=new WeakMap,rt=new WeakMap,b=new WeakMap,q=new WeakMap,W=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,I=new WeakMap;var P,Q,g,R,d,nt,V,C,L,ot,T,X,Z,_,at,h,ut,wt,zt,yt,bt,Lt,Pt,dt,tt;const st=class st{constructor(t){o(this,h);o(this,P,null);o(this,Q,null);o(this,g,[]);o(this,R);o(this,d,null);o(this,nt);o(this,V,[]);o(this,C,!1);o(this,L,null);o(this,ot,!1);o(this,T,new Map);o(this,X,null);o(this,Z,0);o(this,_,0);o(this,at,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,dt,t=>O(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),r(this,C,!0),yield this.navigate(t.state.path,{historyAction:"none"}),r(this,C,!1))}));o(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),c=t-e(this,Z);r(this,_,s),r(this,Z,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",c>0),document.documentElement.classList.toggle("scroll-x-backward",c<0),F.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Rt.isBrowser&&!st.instance){st.instance=this,r(this,P,{base:ht.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!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,Q,p(this,h,wt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);r(this,d,s.pathname);const i=new It(this,e(this,d));i.setInitialDocument(document),e(this,T).set(e(this,d),i),document.documentElement.setAttribute("data-current-pathname",e(this,d)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,dt)),ht.changeHistory({action:"replace",pathname:e(this,d),searchParameters:s.parameters||location.search,hash:s.hash}),r(this,X,new Vt),p(this,h,Lt).call(this,document)}}get currentPathname(){return e(this,d)}get previousPathname(){return e(this,nt)}get links(){return e(this,g)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,C)}get scrollValue(){let t=0,s=0;return e(this,ot)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,T).get(e(this,d));s&&s.saveState(t)}getState(){const t=e(this,T).get(e(this,d));return t==null?void 0:t.clearState()}normalizePath(t){return ht.splitPath(t,{base:e(this,P).base,trailingSlash:e(this,P).trailingSlash})}prefetch(t,s){return O(this,null,function*(){if(e(this,V).length)return;const i=this.normalizePath(t),c=p(this,h,ut).call(this,i.pathname,i.parameters);c==null||c.fetch(s)})}navigate(z){return O(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:w,keepSearchParameters:x,submorph:v,clearState:E}={}){var kt;if(e(this,V).length)return;const mt=this.normalizePath(((kt=this.pathnameModifier)==null?void 0:kt.call(this,t))||t);let{pathname:m,hash:$,parameters:At,leaf:Bt}=mt;if(e(this,R)===m||e(this,d)===m){e(this,C)||p(this,h,Pt).call(this,$||0,{centerScroll:i,offsetScroll:c,behavior:"smooth"});return}r(this,R,m),e(this,g).forEach(j=>{j.checkCurrent(m)});try{let j=!0;if(this.preprocessor)try{yield new Promise((n,A)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:n,reject:A,submorph:v})})}catch(n){n?console.error(n):console.log("Route change canceled"),j=!1}if(!j||e(this,R)!==m){e(this,g).forEach(n=>{n.checkCurrent(e(this,d))});return}const ft={pathname:m,submorph:v};F.dispatchEvent(document,"morphNavigation",{detail:ft});const pt=p(this,h,ut).call(this,e(this,d)),f=p(this,h,ut).call(this,m,At);if(e(this,T).forEach(n=>{n.pathname!==m&&n.abort()}),yield f==null?void 0:f.fetch(w),e(this,R)!==m){e(this,g).forEach(n=>{n.checkCurrent(e(this,d))});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,C)||(f.clearScrollState(),f.clearDocumentState()),E&&f.clearState(),f.cloneDocument(),e(this,X).textContent=f.title,document.body.appendChild(e(this,X)),F.dispatchEvent(document,"morphStart",{detail:ft});const Ct=Array.from(document.head.children),Tt=Array.from(f.document.head.children),xt=p(this,h,zt).call(this,Ct,Tt),Ot=p(this,h,yt).call(this,Ct,xt),lt=p(this,h,yt).call(this,Tt,xt);lt.forEach((n,A)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=n.getAttribute("src"),lt[A]=y}}),lt.forEach(n=>{document.head.appendChild(n)});const gt=lt.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(p(this,h,bt).call(this,n))return!0});e(this,P).waitForHeadToLoad&>.length&&(yield new Promise(n=>O(this,null,function*(){let A=0;try{for(var y=qt(gt),et,B,U;et=!(B=yield y.next()).done;et=!1){const ct=B.value;ct.onload=()=>{A++,A===gt.length&&n()}}}catch(B){U=[B]}finally{try{et&&(B=y.return)&&(yield B.call(y))}finally{if(U)throw U[0]}}}))),yield Dt.wait(10);const Mt=[];Ot.forEach(n=>{n.hasAttribute("data-permanent")||(p(this,h,bt).call(this,n)?Mt.push(n):n.remove())});const Ft=p(this,h,wt).call(this,f.document.body);e(this,P).morphInsideScrollContainer||p(this,h,Lt).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",Bt),ht.changeHistory({action:s,pathname:m,searchParameters:At||(x?location.search:""),hash:$}),e(this,X).remove(),r(this,nt,e(this,d)),r(this,d,m),e(this,Q).forEach((n,A)=>{const y=Ft[A],et=getComputedStyle(n).getPropertyValue("--morph-duration");let B=[],U=[];v?v.forEach(u=>{const S=n.querySelector(u),M=y.querySelector(u);S&&M&&(U.push(S),B.push(M))}):(B.push(...y.childNodes),U.push(...n.childNodes)),U.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),B.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),v?B.forEach((u,S)=>{var M;(M=U[S].parentElement)==null||M.insertBefore(u,U[S])}):n.prepend(...B),Yt.requestIdleCallback(()=>{B.forEach(u=>{var S;u instanceof HTMLElement&&((S=u.parentElement)==null||S.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("in"))})});const ct={morphElement:n,pathname:m};F.dispatchEvent(document,"morphNewChildrenAdded",{detail:ct});const Wt=new Promise(u=>{setTimeout(()=>{U.forEach(S=>S.remove()),B.forEach(S=>{var M;S instanceof HTMLElement&&((M=S.parentElement)==null||M.style.removeProperty("--new-content-height"),S.classList.remove("in","new"))}),F.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ct}),u()},(parseFloat(et)||0)*1e3+10)});e(this,V).push(Wt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-f.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),F.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:f.scrollState}),$?(f.clearScrollState(),p(this,h,Pt).call(this,$,{centerScroll:i,offsetScroll:c})):e(this,C)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,V)),Mt.forEach(n=>n.remove()),r(this,V,[]),e(this,Q).forEach(n=>{n.querySelectorAll("script").forEach(y=>{const et=document.createElement("script");et.type="module",et.src=y.getAttribute("src"),y.replaceWith(et)})}),F.dispatchEvent(document,"morphComplete",{detail:ft}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(j){console.error(j)}r(this,R,void 0)})}addLink(t){e(this,g).push(new St(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,at));e(this,g).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,at));e(this,g).forEach(s=>s.destroy()),r(this,g,t.map(s=>new St(s,this)))}};P=new WeakMap,Q=new WeakMap,g=new WeakMap,R=new WeakMap,d=new WeakMap,nt=new WeakMap,V=new WeakMap,C=new WeakMap,L=new WeakMap,ot=new WeakMap,T=new WeakMap,X=new WeakMap,Z=new WeakMap,_=new WeakMap,at=new WeakMap,h=new WeakSet,ut=function(t,s){let i=e(this,T).get(t);return i||(i=new It(this,t,s),e(this,T).set(t,i)),i},wt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},zt=function(t,s){return t.filter(i=>s.find(c=>c.outerHTML===i.outerHTML))},yt=function(t,s){return t.filter(i=>!s.find(c=>c.outerHTML===i.outerHTML))},bt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Lt=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,tt)),r(this,_,0),r(this,Z,0),r(this,L,e(this,P).scrollSelector&&t.querySelector(e(this,P).scrollSelector)||window),r(this,ot,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Pt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Dt.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},dt=new WeakMap,tt=new WeakMap,st.instance=null;let vt=st;exports.Morph=vt;
|
|
1
|
+
"use strict";var Ht=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Nt=a=>{throw TypeError(a)};var gt=(a,t,s)=>t.has(a)||Nt("Cannot "+s);var e=(a,t,s)=>(gt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Nt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),r=(a,t,s,i)=>(gt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),p=(a,t,s)=>(gt(a,t,"access private method"),s);var O=(a,t,s)=>new Promise((i,c)=>{var w=g=>{try{v(s.next(g))}catch(z){c(z)}},M=g=>{try{v(s.throw(g))}catch(z){c(z)}},v=g=>g.done?i(g.value):Promise.resolve(g.value).then(w,M);v((s=s.apply(a,t)).next())});var qt=(a,t,s)=>(t=a[Ht("asyncIterator")])?t.call(a):(a=a[Ht("iterator")](),t={},s=(i,c)=>(c=a[i])&&(t[i]=w=>new Promise((M,v,g)=>(w=c.call(a,w),g=w.done,Promise.resolve(w.value).then(z=>M({value:z,done:g}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("../index-DekP7OZe.cjs"),F=require("../events-KVanG9sR.cjs"),Yt=require("../polyfills-Df4r-ETT.cjs"),Dt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ht=require("../url-lnBE_6yf.cjs"),Xt=require("../css-value-parser/index.cjs");class Vt 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)}}Rt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Vt);var k,l,N,it,K;class St{constructor(t,s){o(this,k);o(this,l);o(this,N);o(this,it,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,k).previousPathname)history.back();else{r(this,N,e(this,l).getAttribute("href")||"/");const c=e(this,l).getAttribute("data-history-action")||"push",w=e(this,l).hasAttribute("data-center-scroll"),M=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=M?Xt.cssValueParser.parse(M):void 0,g=e(this,l).hasAttribute("data-revalidate"),z=e(this,l).hasAttribute("data-keep-search-parameters"),mt=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map($=>$.trim()),m=e(this,l).hasAttribute("data-clear-state");e(this,k).navigate(e(this,N),{historyAction:c,centerScroll:w,offsetScroll:v,revalidate:g,keepSearchParameters:z,submorph:mt,clearState:m})}});o(this,K,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,k).prefetch(e(this,N),t),e(this,l).removeEventListener("pointerenter",e(this,K))});r(this,k,s),r(this,l,t),r(this,N,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,it)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,K))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,k).normalizePath(t),i=e(this,k).normalizePath(e(this,N));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"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,it)),e(this,l).removeEventListener("pointerenter",e(this,K)),e(this,l).classList.remove("current")}}k=new WeakMap,l=new WeakMap,N=new WeakMap,it=new WeakMap,K=new WeakMap;const $t=new DOMParser;var q,G,rt,b,C,W,D,J,Y,I;class It{constructor(t,s,i){o(this,q);o(this,G);o(this,rt);o(this,b,{x:0,y:0});o(this,C,null);o(this,W,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,I,null);r(this,q,t),r(this,G,s),r(this,rt,i)}get pathname(){return e(this,G)}get searchParameters(){return e(this,rt)}get scrollState(){return e(this,b)}get document(){return e(this,D)}setInitialDocument(t){r(this,C,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${this.pathname}] page loading cancelled`)}fetch(t){return O(this,null,function*(){if(!(e(this,C)&&!t&&!e(this,C).documentElement.hasAttribute("data-always-revalidate")))return e(this,I)?e(this,I):(r(this,I,new Promise(s=>O(this,null,function*(){try{r(this,Y,new AbortController);const c=yield(yield fetch(`${this.pathname}${this.searchParameters?"?"+this.searchParameters:""}`,{signal:e(this,Y).signal})).text(),w=$t.parseFromString(c,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{r(this,Y,null),r(this,I,null),s()}}))),e(this,I))})}cloneDocument(){r(this,D,(e(this,W)||e(this,C)).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,G)}return t}clearScrollState(){e(this,b).x=0,e(this,b).y=0}clearDocumentState(){r(this,W,null)}saveScrollState(){e(this,C).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,b).x=0,e(this,b).y=0):(e(this,b).x=e(this,q).scrollValue.left,e(this,b).y=e(this,q).scrollValue.top)}restoreScrollPosition(){e(this,q).scrollElement.scroll({top:e(this,b).y,left:e(this,b).x,behavior:"instant"})}saveDocumentState(){e(this,C).documentElement.hasAttribute("data-no-page-restoration")?r(this,W,null):r(this,W,document.cloneNode(!0))}renewScrollPosition(){e(this,q).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}}q=new WeakMap,G=new WeakMap,rt=new WeakMap,b=new WeakMap,C=new WeakMap,W=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,I=new WeakMap;var P,Q,E,R,d,nt,V,T,L,ot,x,X,Z,_,at,h,ut,wt,zt,yt,bt,Lt,Pt,dt,tt;const st=class st{constructor(t){o(this,h);o(this,P,null);o(this,Q,null);o(this,E,[]);o(this,R);o(this,d,null);o(this,nt);o(this,V,[]);o(this,T,!1);o(this,L,null);o(this,ot,!1);o(this,x,new Map);o(this,X,null);o(this,Z,0);o(this,_,0);o(this,at,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,dt,t=>O(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),r(this,T,!0),yield this.navigate(t.state.path,{historyAction:"none"}),r(this,T,!1))}));o(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),c=t-e(this,Z);r(this,_,s),r(this,Z,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",c>0),document.documentElement.classList.toggle("scroll-x-backward",c<0),F.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Rt.isBrowser&&!st.instance){st.instance=this,r(this,P,{base:ht.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!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,Q,p(this,h,wt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);r(this,d,s.pathname);const i=new It(this,e(this,d));i.setInitialDocument(document),e(this,x).set(e(this,d),i),document.documentElement.setAttribute("data-current-pathname",e(this,d)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,dt)),ht.changeHistory({action:"replace",pathname:e(this,d),searchParameters:s.parameters||location.search,hash:s.hash}),r(this,X,new Vt),p(this,h,Lt).call(this,document)}}get currentPathname(){return e(this,d)}get previousPathname(){return e(this,nt)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,T)}get scrollValue(){let t=0,s=0;return e(this,ot)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,x).get(e(this,d));s&&s.saveState(t)}getState(){const t=e(this,x).get(e(this,d));return t==null?void 0:t.clearState()}normalizePath(t){return ht.splitPath(t,{base:e(this,P).base,trailingSlash:e(this,P).trailingSlash})}prefetch(t,s){return O(this,null,function*(){if(e(this,V).length)return;const i=this.normalizePath(t),c=p(this,h,ut).call(this,i.pathname,i.parameters);c==null||c.fetch(s)})}navigate(z){return O(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:w,keepSearchParameters:M,submorph:v,clearState:g}={}){var kt;if(e(this,V).length)return;const mt=this.normalizePath(((kt=this.pathnameModifier)==null?void 0:kt.call(this,t))||t);let{pathname:m,hash:$,parameters:At,leaf:Bt}=mt;if(e(this,R)===m||e(this,d)===m){e(this,T)||p(this,h,Pt).call(this,$||0,{centerScroll:i,offsetScroll:c,behavior:"smooth"});return}r(this,R,m),e(this,E).forEach(j=>{j.checkCurrent(m)});try{let j=!0;if(this.preprocessor)try{yield new Promise((n,A)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:n,reject:A,submorph:v})})}catch(n){n?console.error(n):console.log("Route change canceled"),j=!1}if(!j||e(this,R)!==m){e(this,E).forEach(n=>{n.checkCurrent(e(this,d))});return}const ft={pathname:m,submorph:v};F.dispatchEvent(document,"morphNavigation",{detail:ft});const pt=p(this,h,ut).call(this,e(this,d)),f=p(this,h,ut).call(this,m,At);if(e(this,x).forEach(n=>{n.pathname!==m&&n.abort()}),yield f==null?void 0:f.fetch(w),e(this,R)!==m){e(this,E).forEach(n=>{n.checkCurrent(e(this,d))});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,T)||(f.clearScrollState(),f.clearDocumentState()),g&&f.clearState(),f.cloneDocument(),e(this,X).textContent=f.title,document.body.appendChild(e(this,X)),F.dispatchEvent(document,"morphStart",{detail:ft});const Ct=Array.from(document.head.children),Tt=Array.from(f.document.head.children),xt=p(this,h,zt).call(this,Ct,Tt),Ot=p(this,h,yt).call(this,Ct,xt),lt=p(this,h,yt).call(this,Tt,xt);lt.forEach((n,A)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=n.getAttribute("src"),lt[A]=y}}),lt.forEach(n=>{document.head.appendChild(n)});const Et=lt.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(p(this,h,bt).call(this,n))return!0});e(this,P).waitForHeadToLoad&&Et.length&&(yield new Promise(n=>O(this,null,function*(){let A=0;try{for(var y=qt(Et),et,B,U;et=!(B=yield y.next()).done;et=!1){const ct=B.value;ct.onload=()=>{A++,A===Et.length&&n()}}}catch(B){U=[B]}finally{try{et&&(B=y.return)&&(yield B.call(y))}finally{if(U)throw U[0]}}}))),yield Dt.wait(10);const Mt=[];Ot.forEach(n=>{n.hasAttribute("data-permanent")||(p(this,h,bt).call(this,n)?Mt.push(n):n.remove())});const Ft=p(this,h,wt).call(this,f.document.body);e(this,P).morphInsideScrollContainer||p(this,h,Lt).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",Bt),ht.changeHistory({action:s,pathname:m,searchParameters:At||(M?location.search:""),hash:$}),e(this,X).remove(),r(this,nt,e(this,d)),r(this,d,m),e(this,Q).forEach((n,A)=>{const y=Ft[A],et=getComputedStyle(n).getPropertyValue("--morph-duration");let B=[],U=[];v?v.forEach(u=>{const S=n.querySelector(u),H=y.querySelector(u);S&&H&&(U.push(S),B.push(H))}):(B.push(...y.childNodes),U.push(...n.childNodes)),U.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),B.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),v?B.forEach((u,S)=>{var H;(H=U[S].parentElement)==null||H.insertBefore(u,U[S])}):n.prepend(...B),Yt.requestIdleCallback(()=>{B.forEach(u=>{var S;u instanceof HTMLElement&&((S=u.parentElement)==null||S.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("in"))})});const ct={morphElement:n,pathname:m};F.dispatchEvent(document,"morphNewChildrenAdded",{detail:ct});const Wt=new Promise(u=>{setTimeout(()=>{U.forEach(S=>S.remove()),B.forEach(S=>{var H;S instanceof HTMLElement&&((H=S.parentElement)==null||H.style.removeProperty("--new-content-height"),S.classList.remove("in","new"))}),F.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ct}),u()},(parseFloat(et)||0)*1e3+10)});e(this,V).push(Wt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-f.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),F.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:f.scrollState}),$?(f.clearScrollState(),p(this,h,Pt).call(this,$,{centerScroll:i,offsetScroll:c})):e(this,T)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,V)),Mt.forEach(n=>n.remove()),r(this,V,[]),e(this,Q).forEach(n=>{n.querySelectorAll("script").forEach(y=>{const et=document.createElement("script");et.type="module",et.src=y.getAttribute("src"),y.replaceWith(et)})}),F.dispatchEvent(document,"morphComplete",{detail:ft}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(j){console.error(j)}r(this,R,void 0)})}addLink(t){e(this,E).push(new St(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){r(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){r(this,E,e(this,E).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,at));e(this,E).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,at));e(this,E).forEach(s=>s.destroy()),r(this,E,t.map(s=>new St(s,this)))}};P=new WeakMap,Q=new WeakMap,E=new WeakMap,R=new WeakMap,d=new WeakMap,nt=new WeakMap,V=new WeakMap,T=new WeakMap,L=new WeakMap,ot=new WeakMap,x=new WeakMap,X=new WeakMap,Z=new WeakMap,_=new WeakMap,at=new WeakMap,h=new WeakSet,ut=function(t,s){let i=e(this,x).get(t);return i||(i=new It(this,t,s),e(this,x).set(t,i)),i},wt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},zt=function(t,s){return t.filter(i=>s.find(c=>c.outerHTML===i.outerHTML))},yt=function(t,s){return t.filter(i=>!s.find(c=>c.outerHTML===i.outerHTML))},bt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Lt=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,tt)),r(this,_,0),r(this,Z,0),r(this,L,e(this,P).scrollSelector&&t.querySelector(e(this,P).scrollSelector)||window),r(this,ot,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Pt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Dt.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},dt=new WeakMap,tt=new WeakMap,st.instance=null;let vt=st;exports.Morph=vt;
|
package/lib/morph/index.js
CHANGED
|
@@ -10,16 +10,16 @@ var F = (a, t, s) => new Promise((i, c) => {
|
|
|
10
10
|
} catch (z) {
|
|
11
11
|
c(z);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, M = (E) => {
|
|
14
14
|
try {
|
|
15
15
|
w(s.throw(E));
|
|
16
16
|
} catch (z) {
|
|
17
17
|
c(z);
|
|
18
18
|
}
|
|
19
|
-
}, w = (E) => E.done ? i(E.value) : Promise.resolve(E.value).then(y,
|
|
19
|
+
}, w = (E) => E.done ? i(E.value) : Promise.resolve(E.value).then(y, M);
|
|
20
20
|
w((s = s.apply(a, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var Nt = (a, t, s) => (t = a[xt("asyncIterator")]) ? t.call(a) : (a = a[xt("iterator")](), t = {}, s = (i, c) => (c = a[i]) && (t[i] = (y) => new Promise((
|
|
22
|
+
var Nt = (a, t, s) => (t = a[xt("asyncIterator")]) ? t.call(a) : (a = a[xt("iterator")](), t = {}, s = (i, c) => (c = a[i]) && (t[i] = (y) => new Promise((M, w, E) => (y = c.call(a, y), E = y.done, Promise.resolve(y.value).then((z) => M({ value: z, done: E }), w)))), s("next"), s("return"), t);
|
|
23
23
|
import { i as Rt } from "../index-Bv9zgfdb.js";
|
|
24
24
|
import { d as O } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as Wt } from "../polyfills-DJrTJQky.js";
|
|
@@ -39,24 +39,24 @@ class Vt extends HTMLElement {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
Rt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Vt);
|
|
42
|
-
var k, l,
|
|
42
|
+
var k, l, H, it, K;
|
|
43
43
|
class Et {
|
|
44
44
|
constructor(t, s) {
|
|
45
45
|
o(this, k);
|
|
46
46
|
o(this, l);
|
|
47
|
-
o(this,
|
|
47
|
+
o(this, H);
|
|
48
48
|
o(this, it, (t) => {
|
|
49
49
|
var i;
|
|
50
50
|
if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, k).previousPathname)
|
|
51
51
|
history.back();
|
|
52
52
|
else {
|
|
53
|
-
r(this,
|
|
53
|
+
r(this, H, e(this, l).getAttribute("href") || "/");
|
|
54
54
|
const c = e(this, l).getAttribute(
|
|
55
55
|
"data-history-action"
|
|
56
|
-
) || "push", y = e(this, l).hasAttribute("data-center-scroll"),
|
|
56
|
+
) || "push", y = e(this, l).hasAttribute("data-center-scroll"), M = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), w = M ? jt.parse(M) : void 0, E = e(this, l).hasAttribute("data-revalidate"), z = e(this, l).hasAttribute(
|
|
57
57
|
"data-keep-search-parameters"
|
|
58
58
|
), dt = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map(($) => $.trim()), m = e(this, l).hasAttribute("data-clear-state");
|
|
59
|
-
e(this, k).navigate(e(this,
|
|
59
|
+
e(this, k).navigate(e(this, H), {
|
|
60
60
|
historyAction: c,
|
|
61
61
|
centerScroll: y,
|
|
62
62
|
offsetScroll: w,
|
|
@@ -69,37 +69,37 @@ class Et {
|
|
|
69
69
|
});
|
|
70
70
|
o(this, K, () => {
|
|
71
71
|
const t = e(this, l).hasAttribute("data-revalidate");
|
|
72
|
-
e(this, k).prefetch(e(this,
|
|
72
|
+
e(this, k).prefetch(e(this, H), t), e(this, l).removeEventListener("pointerenter", e(this, K));
|
|
73
73
|
});
|
|
74
|
-
r(this, k, s), r(this, l, t), r(this,
|
|
74
|
+
r(this, k, s), r(this, l, t), r(this, H, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, it)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, K));
|
|
75
75
|
}
|
|
76
76
|
get element() {
|
|
77
77
|
return e(this, l);
|
|
78
78
|
}
|
|
79
79
|
checkCurrent(t) {
|
|
80
|
-
const s = e(this, k).normalizePath(t), i = e(this, k).normalizePath(e(this,
|
|
80
|
+
const s = e(this, k).normalizePath(t), i = e(this, k).normalizePath(e(this, H));
|
|
81
81
|
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") : e(this, l).classList.remove("current");
|
|
82
82
|
}
|
|
83
83
|
destroy() {
|
|
84
84
|
e(this, l).removeEventListener("click", e(this, it)), e(this, l).removeEventListener("pointerenter", e(this, K)), e(this, l).classList.remove("current");
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
k = new WeakMap(), l = new WeakMap(),
|
|
87
|
+
k = new WeakMap(), l = new WeakMap(), H = new WeakMap(), it = new WeakMap(), K = new WeakMap();
|
|
88
88
|
const Kt = new DOMParser();
|
|
89
|
-
var
|
|
89
|
+
var D, G, rt, b, C, W, I, J, Y, R;
|
|
90
90
|
class Dt {
|
|
91
91
|
constructor(t, s, i) {
|
|
92
|
-
o(this,
|
|
92
|
+
o(this, D);
|
|
93
93
|
o(this, G);
|
|
94
94
|
o(this, rt);
|
|
95
95
|
o(this, b, { x: 0, y: 0 });
|
|
96
|
-
o(this,
|
|
96
|
+
o(this, C, null);
|
|
97
97
|
o(this, W, null);
|
|
98
98
|
o(this, I, null);
|
|
99
99
|
o(this, J, null);
|
|
100
100
|
o(this, Y, null);
|
|
101
101
|
o(this, R, null);
|
|
102
|
-
r(this,
|
|
102
|
+
r(this, D, t), r(this, G, s), r(this, rt, i);
|
|
103
103
|
}
|
|
104
104
|
get pathname() {
|
|
105
105
|
return e(this, G);
|
|
@@ -114,7 +114,7 @@ class Dt {
|
|
|
114
114
|
return e(this, I);
|
|
115
115
|
}
|
|
116
116
|
setInitialDocument(t) {
|
|
117
|
-
r(this,
|
|
117
|
+
r(this, C, t.cloneNode(!0));
|
|
118
118
|
}
|
|
119
119
|
abort() {
|
|
120
120
|
var t;
|
|
@@ -124,7 +124,9 @@ class Dt {
|
|
|
124
124
|
}
|
|
125
125
|
fetch(t) {
|
|
126
126
|
return F(this, null, function* () {
|
|
127
|
-
if (!(e(this,
|
|
127
|
+
if (!(e(this, C) && !t && !e(this, C).documentElement.hasAttribute(
|
|
128
|
+
"data-always-revalidate"
|
|
129
|
+
)))
|
|
128
130
|
return e(this, R) ? e(this, R) : (r(this, R, new Promise((s) => F(this, null, function* () {
|
|
129
131
|
try {
|
|
130
132
|
r(this, Y, new AbortController());
|
|
@@ -144,7 +146,7 @@ class Dt {
|
|
|
144
146
|
});
|
|
145
147
|
}
|
|
146
148
|
cloneDocument() {
|
|
147
|
-
r(this, I, (e(this, W) || e(this,
|
|
149
|
+
r(this, I, (e(this, W) || e(this, C)).cloneNode(!0));
|
|
148
150
|
}
|
|
149
151
|
get title() {
|
|
150
152
|
let t = "";
|
|
@@ -163,24 +165,24 @@ class Dt {
|
|
|
163
165
|
r(this, W, null);
|
|
164
166
|
}
|
|
165
167
|
saveScrollState() {
|
|
166
|
-
e(this,
|
|
168
|
+
e(this, C).documentElement.hasAttribute(
|
|
167
169
|
"data-no-scroll-restoration"
|
|
168
|
-
) ? (e(this, b).x = 0, e(this, b).y = 0) : (e(this, b).x = e(this,
|
|
170
|
+
) ? (e(this, b).x = 0, e(this, b).y = 0) : (e(this, b).x = e(this, D).scrollValue.left, e(this, b).y = e(this, D).scrollValue.top);
|
|
169
171
|
}
|
|
170
172
|
restoreScrollPosition() {
|
|
171
|
-
e(this,
|
|
173
|
+
e(this, D).scrollElement.scroll({
|
|
172
174
|
top: e(this, b).y,
|
|
173
175
|
left: e(this, b).x,
|
|
174
176
|
behavior: "instant"
|
|
175
177
|
});
|
|
176
178
|
}
|
|
177
179
|
saveDocumentState() {
|
|
178
|
-
e(this,
|
|
180
|
+
e(this, C).documentElement.hasAttribute(
|
|
179
181
|
"data-no-page-restoration"
|
|
180
182
|
) ? r(this, W, null) : r(this, W, document.cloneNode(!0));
|
|
181
183
|
}
|
|
182
184
|
renewScrollPosition() {
|
|
183
|
-
e(this,
|
|
185
|
+
e(this, D).scrollElement.scroll({
|
|
184
186
|
top: 0,
|
|
185
187
|
left: 0,
|
|
186
188
|
behavior: "instant"
|
|
@@ -194,8 +196,8 @@ class Dt {
|
|
|
194
196
|
return r(this, J, null), t;
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
|
-
|
|
198
|
-
var P, Q, g, V, d, nt, q,
|
|
199
|
+
D = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), b = new WeakMap(), C = new WeakMap(), W = new WeakMap(), I = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), R = new WeakMap();
|
|
200
|
+
var P, Q, g, V, d, nt, q, T, L, ot, x, X, Z, _, at, h, ht, St, qt, wt, yt, vt, bt, ut, tt;
|
|
199
201
|
const st = class st {
|
|
200
202
|
constructor(t) {
|
|
201
203
|
o(this, h);
|
|
@@ -206,10 +208,10 @@ const st = class st {
|
|
|
206
208
|
o(this, d, null);
|
|
207
209
|
o(this, nt);
|
|
208
210
|
o(this, q, []);
|
|
209
|
-
o(this,
|
|
211
|
+
o(this, T, !1);
|
|
210
212
|
o(this, L, null);
|
|
211
213
|
o(this, ot, !1);
|
|
212
|
-
o(this,
|
|
214
|
+
o(this, x, /* @__PURE__ */ new Map());
|
|
213
215
|
o(this, X, null);
|
|
214
216
|
o(this, Z, 0);
|
|
215
217
|
o(this, _, 0);
|
|
@@ -219,7 +221,7 @@ const st = class st {
|
|
|
219
221
|
});
|
|
220
222
|
o(this, ut, (t) => F(this, null, function* () {
|
|
221
223
|
var s;
|
|
222
|
-
(s = t.state) != null && s.path && (t.preventDefault(), r(this,
|
|
224
|
+
(s = t.state) != null && s.path && (t.preventDefault(), r(this, T, !0), yield this.navigate(t.state.path, { historyAction: "none" }), r(this, T, !1));
|
|
223
225
|
}));
|
|
224
226
|
o(this, tt, () => {
|
|
225
227
|
const { left: t, top: s } = this.scrollValue, i = s - e(this, _), c = t - e(this, Z);
|
|
@@ -256,7 +258,7 @@ const st = class st {
|
|
|
256
258
|
);
|
|
257
259
|
r(this, d, s.pathname);
|
|
258
260
|
const i = new Dt(this, e(this, d));
|
|
259
|
-
i.setInitialDocument(document), e(this,
|
|
261
|
+
i.setInitialDocument(document), e(this, x).set(e(this, d), i), document.documentElement.setAttribute(
|
|
260
262
|
"data-current-pathname",
|
|
261
263
|
e(this, d)
|
|
262
264
|
), document.documentElement.setAttribute(
|
|
@@ -283,18 +285,18 @@ const st = class st {
|
|
|
283
285
|
return e(this, L);
|
|
284
286
|
}
|
|
285
287
|
get isPopstateNavigation() {
|
|
286
|
-
return e(this,
|
|
288
|
+
return e(this, T);
|
|
287
289
|
}
|
|
288
290
|
get scrollValue() {
|
|
289
291
|
let t = 0, s = 0;
|
|
290
292
|
return e(this, ot) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, L).scrollTop, s = e(this, L).scrollLeft), { top: t, left: s };
|
|
291
293
|
}
|
|
292
294
|
saveState(t) {
|
|
293
|
-
const s = e(this,
|
|
295
|
+
const s = e(this, x).get(e(this, d));
|
|
294
296
|
s && s.saveState(t);
|
|
295
297
|
}
|
|
296
298
|
getState() {
|
|
297
|
-
const t = e(this,
|
|
299
|
+
const t = e(this, x).get(e(this, d));
|
|
298
300
|
return t == null ? void 0 : t.clearState();
|
|
299
301
|
}
|
|
300
302
|
normalizePath(t) {
|
|
@@ -317,7 +319,7 @@ const st = class st {
|
|
|
317
319
|
centerScroll: i,
|
|
318
320
|
offsetScroll: c,
|
|
319
321
|
revalidate: y,
|
|
320
|
-
keepSearchParameters:
|
|
322
|
+
keepSearchParameters: M,
|
|
321
323
|
submorph: w,
|
|
322
324
|
clearState: E
|
|
323
325
|
} = {}) {
|
|
@@ -327,7 +329,7 @@ const st = class st {
|
|
|
327
329
|
const dt = this.normalizePath(((Pt = this.pathnameModifier) == null ? void 0 : Pt.call(this, t)) || t);
|
|
328
330
|
let { pathname: m, hash: $, parameters: Lt, leaf: zt } = dt;
|
|
329
331
|
if (e(this, V) === m || e(this, d) === m) {
|
|
330
|
-
e(this,
|
|
332
|
+
e(this, T) || p(this, h, bt).call(this, $ || 0, {
|
|
331
333
|
centerScroll: i,
|
|
332
334
|
offsetScroll: c,
|
|
333
335
|
behavior: "smooth"
|
|
@@ -367,7 +369,7 @@ const st = class st {
|
|
|
367
369
|
detail: mt
|
|
368
370
|
});
|
|
369
371
|
const ft = p(this, h, ht).call(this, e(this, d)), f = p(this, h, ht).call(this, m, Lt);
|
|
370
|
-
if (e(this,
|
|
372
|
+
if (e(this, x).forEach((n) => {
|
|
371
373
|
n.pathname !== m && n.abort();
|
|
372
374
|
}), yield f == null ? void 0 : f.fetch(y), e(this, V) !== m) {
|
|
373
375
|
e(this, g).forEach((n) => {
|
|
@@ -375,7 +377,7 @@ const st = class st {
|
|
|
375
377
|
});
|
|
376
378
|
return;
|
|
377
379
|
}
|
|
378
|
-
ft.clearState(), ft.saveScrollState(), ft.saveDocumentState(), e(this,
|
|
380
|
+
ft.clearState(), ft.saveScrollState(), ft.saveDocumentState(), e(this, T) || (f.clearScrollState(), f.clearDocumentState()), E && f.clearState(), f.cloneDocument(), e(this, X).textContent = f.title, document.body.appendChild(e(this, X)), O(document, "morphStart", {
|
|
379
381
|
detail: mt
|
|
380
382
|
});
|
|
381
383
|
const At = Array.from(document.head.children), kt = Array.from(f.document.head.children), Ct = p(this, h, qt).call(this, At, kt), Bt = p(this, h, wt).call(this, At, Ct), lt = p(this, h, wt).call(this, kt, Ct);
|
|
@@ -421,21 +423,21 @@ const st = class st {
|
|
|
421
423
|
e(this, P).morphInsideScrollContainer || p(this, h, vt).call(this, f.document), document.documentElement.setAttribute("data-current-pathname", m), document.documentElement.setAttribute("data-current-leaf", zt), Ht({
|
|
422
424
|
action: s,
|
|
423
425
|
pathname: m,
|
|
424
|
-
searchParameters: Lt || (
|
|
426
|
+
searchParameters: Lt || (M ? location.search : ""),
|
|
425
427
|
hash: $
|
|
426
428
|
}), e(this, X).remove(), r(this, nt, e(this, d)), r(this, d, m), e(this, Q).forEach((n, A) => {
|
|
427
429
|
const v = Ft[A], et = getComputedStyle(n).getPropertyValue("--morph-duration");
|
|
428
430
|
let B = [], j = [];
|
|
429
431
|
w ? w.forEach((u) => {
|
|
430
|
-
const S = n.querySelector(u),
|
|
431
|
-
S &&
|
|
432
|
+
const S = n.querySelector(u), N = v.querySelector(u);
|
|
433
|
+
S && N && (j.push(S), B.push(N));
|
|
432
434
|
}) : (B.push(...v.childNodes), j.push(...n.childNodes)), j.forEach((u) => {
|
|
433
435
|
u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
|
|
434
436
|
}), B.forEach((u) => {
|
|
435
437
|
u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
|
|
436
438
|
}), w ? B.forEach((u, S) => {
|
|
437
|
-
var
|
|
438
|
-
(
|
|
439
|
+
var N;
|
|
440
|
+
(N = j[S].parentElement) == null || N.insertBefore(
|
|
439
441
|
u,
|
|
440
442
|
j[S]
|
|
441
443
|
);
|
|
@@ -458,8 +460,8 @@ const st = class st {
|
|
|
458
460
|
const Ot = new Promise((u) => {
|
|
459
461
|
setTimeout(() => {
|
|
460
462
|
j.forEach((S) => S.remove()), B.forEach((S) => {
|
|
461
|
-
var
|
|
462
|
-
S instanceof HTMLElement && ((
|
|
463
|
+
var N;
|
|
464
|
+
S instanceof HTMLElement && ((N = S.parentElement) == null || N.style.removeProperty(
|
|
463
465
|
"--new-content-height"
|
|
464
466
|
), S.classList.remove("in", "new"));
|
|
465
467
|
}), O(document, "morphOldChildrenRemoved", {
|
|
@@ -476,7 +478,7 @@ const st = class st {
|
|
|
476
478
|
this.scrollValue.top + "px"
|
|
477
479
|
), O(document, "morphBeforeNavigationScroll", {
|
|
478
480
|
detail: f.scrollState
|
|
479
|
-
}), $ ? (f.clearScrollState(), p(this, h, bt).call(this, $, { centerScroll: i, offsetScroll: c })) : e(this,
|
|
481
|
+
}), $ ? (f.clearScrollState(), p(this, h, bt).call(this, $, { centerScroll: i, offsetScroll: c })) : e(this, T) ? f.restoreScrollPosition() : f.renewScrollPosition(), yield Promise.all(e(this, q)), Tt.forEach((n) => n.remove()), r(this, q, []), e(this, Q).forEach((n) => {
|
|
480
482
|
n.querySelectorAll("script").forEach((v) => {
|
|
481
483
|
const et = document.createElement("script");
|
|
482
484
|
et.type = "module", et.src = v.getAttribute("src"), v.replaceWith(et);
|
|
@@ -521,9 +523,9 @@ const st = class st {
|
|
|
521
523
|
e(this, g).forEach((s) => s.destroy()), r(this, g, t.map((s) => new Et(s, this)));
|
|
522
524
|
}
|
|
523
525
|
};
|
|
524
|
-
P = new WeakMap(), Q = new WeakMap(), g = new WeakMap(), V = new WeakMap(), d = new WeakMap(), nt = new WeakMap(), q = new WeakMap(),
|
|
525
|
-
let i = e(this,
|
|
526
|
-
return i || (i = new Dt(this, t, s), e(this,
|
|
526
|
+
P = new WeakMap(), Q = new WeakMap(), g = new WeakMap(), V = new WeakMap(), d = new WeakMap(), nt = new WeakMap(), q = new WeakMap(), T = new WeakMap(), L = new WeakMap(), ot = new WeakMap(), x = new WeakMap(), X = new WeakMap(), Z = new WeakMap(), _ = new WeakMap(), at = new WeakMap(), h = new WeakSet(), ht = function(t, s) {
|
|
527
|
+
let i = e(this, x).get(t);
|
|
528
|
+
return i || (i = new Dt(this, t, s), e(this, x).set(t, i)), i;
|
|
527
529
|
}, St = function(t) {
|
|
528
530
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
529
531
|
return s.length ? s : [t];
|