aptechka 0.67.1 → 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 +101 -102
- 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 B=(a,t,s)=>new Promise((i,c)=>{var w=E=>{try{v(s.next(E))}catch(V){c(V)}},x=E=>{try{v(s.throw(E))}catch(V){c(V)}},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(V=>x({value:V,done:E}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("../index-DekP7OZe.cjs"),O=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"),V=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:V,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,F,D,J,W,Y;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,F,null);o(this,D,null);o(this,J,null);o(this,W,null);o(this,Y,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,W))==null?void 0:t.abort(`[${this.pathname}] page loading cancelled`)}fetch(t){return B(this,null,function*(){if(!(e(this,q)&&!t)){if(e(this,Y))return e(this,Y);r(this,Y,new Promise(s=>B(this,null,function*(){try{r(this,W,new AbortController);const c=yield(yield fetch(`${this.pathname}${this.searchParameters?"?"+this.searchParameters:""}`,{signal:e(this,W).signal})).text(),w=$t.parseFromString(c,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{r(this,W,null),r(this,Y,null),s()}})))}})}cloneDocument(){r(this,D,(e(this,F)||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,F,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,F,null):r(this,F,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,F=new WeakMap,D=new WeakMap,J=new WeakMap,W=new WeakMap,Y=new WeakMap;var P,Q,g,I,d,nt,R,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,I);o(this,d,null);o(this,nt);o(this,R,[]);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=>B(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),O.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 B(this,null,function*(){if(e(this,R).length)return;const i=this.normalizePath(t),c=p(this,h,ut).call(this,i.pathname,i.parameters);c==null||c.fetch(s)})}navigate(V){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:w,keepSearchParameters:x,submorph:v,clearState:E}={}){var kt;if(e(this,R).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,I)===m||e(this,d)===m){e(this,C)||p(this,h,Pt).call(this,$||0,{centerScroll:i,offsetScroll:c,behavior:"smooth"});return}r(this,I,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,I)!==m){e(this,g).forEach(n=>{n.checkCurrent(e(this,d))});return}const ft={pathname:m,submorph:v};O.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,I)!==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)),O.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=>B(this,null,function*(){let A=0;try{for(var y=qt(gt),et,z,U;et=!(z=yield y.next()).done;et=!1){const ct=z.value;ct.onload=()=>{A++,A===gt.length&&n()}}}catch(z){U=[z]}finally{try{et&&(z=y.return)&&(yield z.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 z=[],U=[];v?v.forEach(u=>{const S=n.querySelector(u),M=y.querySelector(u);S&&M&&(U.push(S),z.push(M))}):(z.push(...y.childNodes),U.push(...n.childNodes)),U.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),z.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),v?z.forEach((u,S)=>{var M;(M=U[S].parentElement)==null||M.insertBefore(u,U[S])}):n.prepend(...z),Yt.requestIdleCallback(()=>{z.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};O.dispatchEvent(document,"morphNewChildrenAdded",{detail:ct});const Wt=new Promise(u=>{setTimeout(()=>{U.forEach(S=>S.remove()),z.forEach(S=>{var M;S instanceof HTMLElement&&((M=S.parentElement)==null||M.style.removeProperty("--new-content-height"),S.classList.remove("in","new"))}),O.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ct}),u()},(parseFloat(et)||0)*1e3+10)});e(this,R).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"),O.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,R)),Mt.forEach(n=>n.remove()),r(this,R,[]),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)})}),O.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,I,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,I=new WeakMap,d=new WeakMap,nt=new WeakMap,R=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
|
@@ -3,25 +3,25 @@ var xt = (a, t) => (t = Symbol[a]) ? t : Symbol.for("Symbol." + a), Mt = (a) =>
|
|
|
3
3
|
};
|
|
4
4
|
var gt = (a, t, s) => t.has(a) || Mt("Cannot " + s);
|
|
5
5
|
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) ? Mt("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);
|
|
6
|
-
var
|
|
6
|
+
var F = (a, t, s) => new Promise((i, c) => {
|
|
7
7
|
var y = (E) => {
|
|
8
8
|
try {
|
|
9
9
|
w(s.next(E));
|
|
10
|
-
} catch (
|
|
11
|
-
c(
|
|
10
|
+
} catch (z) {
|
|
11
|
+
c(z);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, M = (E) => {
|
|
14
14
|
try {
|
|
15
15
|
w(s.throw(E));
|
|
16
|
-
} catch (
|
|
17
|
-
c(
|
|
16
|
+
} catch (z) {
|
|
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
|
-
import { d as
|
|
24
|
+
import { d as O } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as Wt } from "../polyfills-DJrTJQky.js";
|
|
26
26
|
import { w as Yt, s as Xt } from "../scroll-DPkCFTxg.js";
|
|
27
27
|
import "construct-style-sheets-polyfill";
|
|
@@ -39,29 +39,29 @@ 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,
|
|
63
63
|
revalidate: E,
|
|
64
|
-
keepSearchParameters:
|
|
64
|
+
keepSearchParameters: z,
|
|
65
65
|
submorph: dt,
|
|
66
66
|
clearState: m
|
|
67
67
|
});
|
|
@@ -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,
|
|
97
|
-
o(this,
|
|
96
|
+
o(this, C, null);
|
|
97
|
+
o(this, W, null);
|
|
98
98
|
o(this, I, null);
|
|
99
99
|
o(this, J, null);
|
|
100
|
-
o(this, W, null);
|
|
101
100
|
o(this, Y, null);
|
|
102
|
-
|
|
101
|
+
o(this, R, null);
|
|
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,40 +114,39 @@ 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;
|
|
121
|
-
return (t = e(this,
|
|
121
|
+
return (t = e(this, Y)) == null ? void 0 : t.abort(
|
|
122
122
|
`[${this.pathname}] page loading cancelled`
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
fetch(t) {
|
|
126
|
-
return
|
|
127
|
-
if (!(e(this,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
r(this,
|
|
126
|
+
return F(this, null, function* () {
|
|
127
|
+
if (!(e(this, C) && !t && !e(this, C).documentElement.hasAttribute(
|
|
128
|
+
"data-always-revalidate"
|
|
129
|
+
)))
|
|
130
|
+
return e(this, R) ? e(this, R) : (r(this, R, new Promise((s) => F(this, null, function* () {
|
|
131
131
|
try {
|
|
132
|
-
r(this,
|
|
132
|
+
r(this, Y, new AbortController());
|
|
133
133
|
const c = yield (yield fetch(
|
|
134
134
|
`${this.pathname}${this.searchParameters ? "?" + this.searchParameters : ""}`,
|
|
135
135
|
{
|
|
136
|
-
signal: e(this,
|
|
136
|
+
signal: e(this, Y).signal
|
|
137
137
|
}
|
|
138
138
|
)).text(), y = Kt.parseFromString(c, "text/html");
|
|
139
139
|
this.setInitialDocument(y);
|
|
140
140
|
} catch (i) {
|
|
141
141
|
console.warn(i);
|
|
142
142
|
} finally {
|
|
143
|
-
r(this,
|
|
143
|
+
r(this, Y, null), r(this, R, null), s();
|
|
144
144
|
}
|
|
145
|
-
})));
|
|
146
|
-
}
|
|
145
|
+
}))), e(this, R));
|
|
147
146
|
});
|
|
148
147
|
}
|
|
149
148
|
cloneDocument() {
|
|
150
|
-
r(this, I, (e(this,
|
|
149
|
+
r(this, I, (e(this, W) || e(this, C)).cloneNode(!0));
|
|
151
150
|
}
|
|
152
151
|
get title() {
|
|
153
152
|
let t = "";
|
|
@@ -163,27 +162,27 @@ class Dt {
|
|
|
163
162
|
e(this, b).x = 0, e(this, b).y = 0;
|
|
164
163
|
}
|
|
165
164
|
clearDocumentState() {
|
|
166
|
-
r(this,
|
|
165
|
+
r(this, W, null);
|
|
167
166
|
}
|
|
168
167
|
saveScrollState() {
|
|
169
|
-
e(this,
|
|
168
|
+
e(this, C).documentElement.hasAttribute(
|
|
170
169
|
"data-no-scroll-restoration"
|
|
171
|
-
) ? (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);
|
|
172
171
|
}
|
|
173
172
|
restoreScrollPosition() {
|
|
174
|
-
e(this,
|
|
173
|
+
e(this, D).scrollElement.scroll({
|
|
175
174
|
top: e(this, b).y,
|
|
176
175
|
left: e(this, b).x,
|
|
177
176
|
behavior: "instant"
|
|
178
177
|
});
|
|
179
178
|
}
|
|
180
179
|
saveDocumentState() {
|
|
181
|
-
e(this,
|
|
180
|
+
e(this, C).documentElement.hasAttribute(
|
|
182
181
|
"data-no-page-restoration"
|
|
183
|
-
) ? r(this,
|
|
182
|
+
) ? r(this, W, null) : r(this, W, document.cloneNode(!0));
|
|
184
183
|
}
|
|
185
184
|
renewScrollPosition() {
|
|
186
|
-
e(this,
|
|
185
|
+
e(this, D).scrollElement.scroll({
|
|
187
186
|
top: 0,
|
|
188
187
|
left: 0,
|
|
189
188
|
behavior: "instant"
|
|
@@ -197,22 +196,22 @@ class Dt {
|
|
|
197
196
|
return r(this, J, null), t;
|
|
198
197
|
}
|
|
199
198
|
}
|
|
200
|
-
|
|
201
|
-
var P, Q, g,
|
|
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;
|
|
202
201
|
const st = class st {
|
|
203
202
|
constructor(t) {
|
|
204
203
|
o(this, h);
|
|
205
204
|
o(this, P, null);
|
|
206
205
|
o(this, Q, null);
|
|
207
206
|
o(this, g, []);
|
|
208
|
-
o(this,
|
|
207
|
+
o(this, V);
|
|
209
208
|
o(this, d, null);
|
|
210
209
|
o(this, nt);
|
|
211
|
-
o(this,
|
|
212
|
-
o(this,
|
|
210
|
+
o(this, q, []);
|
|
211
|
+
o(this, T, !1);
|
|
213
212
|
o(this, L, null);
|
|
214
213
|
o(this, ot, !1);
|
|
215
|
-
o(this,
|
|
214
|
+
o(this, x, /* @__PURE__ */ new Map());
|
|
216
215
|
o(this, X, null);
|
|
217
216
|
o(this, Z, 0);
|
|
218
217
|
o(this, _, 0);
|
|
@@ -220,9 +219,9 @@ const st = class st {
|
|
|
220
219
|
var s;
|
|
221
220
|
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";
|
|
222
221
|
});
|
|
223
|
-
o(this, ut, (t) =>
|
|
222
|
+
o(this, ut, (t) => F(this, null, function* () {
|
|
224
223
|
var s;
|
|
225
|
-
(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));
|
|
226
225
|
}));
|
|
227
226
|
o(this, tt, () => {
|
|
228
227
|
const { left: t, top: s } = this.scrollValue, i = s - e(this, _), c = t - e(this, Z);
|
|
@@ -238,7 +237,7 @@ const st = class st {
|
|
|
238
237
|
), document.documentElement.classList.toggle(
|
|
239
238
|
"scroll-x-backward",
|
|
240
239
|
c < 0
|
|
241
|
-
),
|
|
240
|
+
), O(document, "morphScroll", {
|
|
242
241
|
detail: {
|
|
243
242
|
left: t,
|
|
244
243
|
top: s
|
|
@@ -259,7 +258,7 @@ const st = class st {
|
|
|
259
258
|
);
|
|
260
259
|
r(this, d, s.pathname);
|
|
261
260
|
const i = new Dt(this, e(this, d));
|
|
262
|
-
i.setInitialDocument(document), e(this,
|
|
261
|
+
i.setInitialDocument(document), e(this, x).set(e(this, d), i), document.documentElement.setAttribute(
|
|
263
262
|
"data-current-pathname",
|
|
264
263
|
e(this, d)
|
|
265
264
|
), document.documentElement.setAttribute(
|
|
@@ -286,18 +285,18 @@ const st = class st {
|
|
|
286
285
|
return e(this, L);
|
|
287
286
|
}
|
|
288
287
|
get isPopstateNavigation() {
|
|
289
|
-
return e(this,
|
|
288
|
+
return e(this, T);
|
|
290
289
|
}
|
|
291
290
|
get scrollValue() {
|
|
292
291
|
let t = 0, s = 0;
|
|
293
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 };
|
|
294
293
|
}
|
|
295
294
|
saveState(t) {
|
|
296
|
-
const s = e(this,
|
|
295
|
+
const s = e(this, x).get(e(this, d));
|
|
297
296
|
s && s.saveState(t);
|
|
298
297
|
}
|
|
299
298
|
getState() {
|
|
300
|
-
const t = e(this,
|
|
299
|
+
const t = e(this, x).get(e(this, d));
|
|
301
300
|
return t == null ? void 0 : t.clearState();
|
|
302
301
|
}
|
|
303
302
|
normalizePath(t) {
|
|
@@ -307,37 +306,37 @@ const st = class st {
|
|
|
307
306
|
});
|
|
308
307
|
}
|
|
309
308
|
prefetch(t, s) {
|
|
310
|
-
return
|
|
311
|
-
if (e(this,
|
|
309
|
+
return F(this, null, function* () {
|
|
310
|
+
if (e(this, q).length)
|
|
312
311
|
return;
|
|
313
312
|
const i = this.normalizePath(t), c = p(this, h, ht).call(this, i.pathname, i.parameters);
|
|
314
313
|
c == null || c.fetch(s);
|
|
315
314
|
});
|
|
316
315
|
}
|
|
317
|
-
navigate(
|
|
318
|
-
return
|
|
316
|
+
navigate(z) {
|
|
317
|
+
return F(this, arguments, function* (t, {
|
|
319
318
|
historyAction: s = "push",
|
|
320
319
|
centerScroll: i,
|
|
321
320
|
offsetScroll: c,
|
|
322
321
|
revalidate: y,
|
|
323
|
-
keepSearchParameters:
|
|
322
|
+
keepSearchParameters: M,
|
|
324
323
|
submorph: w,
|
|
325
324
|
clearState: E
|
|
326
325
|
} = {}) {
|
|
327
326
|
var Pt;
|
|
328
|
-
if (e(this,
|
|
327
|
+
if (e(this, q).length)
|
|
329
328
|
return;
|
|
330
329
|
const dt = this.normalizePath(((Pt = this.pathnameModifier) == null ? void 0 : Pt.call(this, t)) || t);
|
|
331
330
|
let { pathname: m, hash: $, parameters: Lt, leaf: zt } = dt;
|
|
332
|
-
if (e(this,
|
|
333
|
-
e(this,
|
|
331
|
+
if (e(this, V) === m || e(this, d) === m) {
|
|
332
|
+
e(this, T) || p(this, h, bt).call(this, $ || 0, {
|
|
334
333
|
centerScroll: i,
|
|
335
334
|
offsetScroll: c,
|
|
336
335
|
behavior: "smooth"
|
|
337
336
|
});
|
|
338
337
|
return;
|
|
339
338
|
}
|
|
340
|
-
r(this,
|
|
339
|
+
r(this, V, m), e(this, g).forEach((U) => {
|
|
341
340
|
U.checkCurrent(m);
|
|
342
341
|
});
|
|
343
342
|
try {
|
|
@@ -356,7 +355,7 @@ const st = class st {
|
|
|
356
355
|
} catch (n) {
|
|
357
356
|
n ? console.error(n) : console.log("Route change canceled"), U = !1;
|
|
358
357
|
}
|
|
359
|
-
if (!U || e(this,
|
|
358
|
+
if (!U || e(this, V) !== m) {
|
|
360
359
|
e(this, g).forEach((n) => {
|
|
361
360
|
n.checkCurrent(e(this, d));
|
|
362
361
|
});
|
|
@@ -366,19 +365,19 @@ const st = class st {
|
|
|
366
365
|
pathname: m,
|
|
367
366
|
submorph: w
|
|
368
367
|
};
|
|
369
|
-
|
|
368
|
+
O(document, "morphNavigation", {
|
|
370
369
|
detail: mt
|
|
371
370
|
});
|
|
372
371
|
const ft = p(this, h, ht).call(this, e(this, d)), f = p(this, h, ht).call(this, m, Lt);
|
|
373
|
-
if (e(this,
|
|
372
|
+
if (e(this, x).forEach((n) => {
|
|
374
373
|
n.pathname !== m && n.abort();
|
|
375
|
-
}), yield f == null ? void 0 : f.fetch(y), e(this,
|
|
374
|
+
}), yield f == null ? void 0 : f.fetch(y), e(this, V) !== m) {
|
|
376
375
|
e(this, g).forEach((n) => {
|
|
377
376
|
n.checkCurrent(e(this, d));
|
|
378
377
|
});
|
|
379
378
|
return;
|
|
380
379
|
}
|
|
381
|
-
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", {
|
|
382
381
|
detail: mt
|
|
383
382
|
});
|
|
384
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);
|
|
@@ -396,20 +395,20 @@ const st = class st {
|
|
|
396
395
|
if (p(this, h, yt).call(this, n))
|
|
397
396
|
return !0;
|
|
398
397
|
});
|
|
399
|
-
e(this, P).waitForHeadToLoad && pt.length && (yield new Promise((n) =>
|
|
398
|
+
e(this, P).waitForHeadToLoad && pt.length && (yield new Promise((n) => F(this, null, function* () {
|
|
400
399
|
let A = 0;
|
|
401
400
|
try {
|
|
402
|
-
for (var v = Nt(pt), et,
|
|
403
|
-
const ct =
|
|
401
|
+
for (var v = Nt(pt), et, B, j; et = !(B = yield v.next()).done; et = !1) {
|
|
402
|
+
const ct = B.value;
|
|
404
403
|
ct.onload = () => {
|
|
405
404
|
A++, A === pt.length && n();
|
|
406
405
|
};
|
|
407
406
|
}
|
|
408
|
-
} catch (
|
|
409
|
-
j = [
|
|
407
|
+
} catch (B) {
|
|
408
|
+
j = [B];
|
|
410
409
|
} finally {
|
|
411
410
|
try {
|
|
412
|
-
et && (
|
|
411
|
+
et && (B = v.return) && (yield B.call(v));
|
|
413
412
|
} finally {
|
|
414
413
|
if (j)
|
|
415
414
|
throw j[0];
|
|
@@ -424,26 +423,26 @@ const st = class st {
|
|
|
424
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({
|
|
425
424
|
action: s,
|
|
426
425
|
pathname: m,
|
|
427
|
-
searchParameters: Lt || (
|
|
426
|
+
searchParameters: Lt || (M ? location.search : ""),
|
|
428
427
|
hash: $
|
|
429
428
|
}), e(this, X).remove(), r(this, nt, e(this, d)), r(this, d, m), e(this, Q).forEach((n, A) => {
|
|
430
429
|
const v = Ft[A], et = getComputedStyle(n).getPropertyValue("--morph-duration");
|
|
431
|
-
let
|
|
430
|
+
let B = [], j = [];
|
|
432
431
|
w ? w.forEach((u) => {
|
|
433
|
-
const S = n.querySelector(u),
|
|
434
|
-
S &&
|
|
435
|
-
}) : (
|
|
432
|
+
const S = n.querySelector(u), N = v.querySelector(u);
|
|
433
|
+
S && N && (j.push(S), B.push(N));
|
|
434
|
+
}) : (B.push(...v.childNodes), j.push(...n.childNodes)), j.forEach((u) => {
|
|
436
435
|
u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
|
|
437
|
-
}),
|
|
436
|
+
}), B.forEach((u) => {
|
|
438
437
|
u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
|
|
439
|
-
}), w ?
|
|
440
|
-
var
|
|
441
|
-
(
|
|
438
|
+
}), w ? B.forEach((u, S) => {
|
|
439
|
+
var N;
|
|
440
|
+
(N = j[S].parentElement) == null || N.insertBefore(
|
|
442
441
|
u,
|
|
443
442
|
j[S]
|
|
444
443
|
);
|
|
445
|
-
}) : n.prepend(...
|
|
446
|
-
|
|
444
|
+
}) : n.prepend(...B), Wt(() => {
|
|
445
|
+
B.forEach((u) => {
|
|
447
446
|
var S;
|
|
448
447
|
u instanceof HTMLElement && ((S = u.parentElement) == null || S.style.setProperty(
|
|
449
448
|
"--new-content-height",
|
|
@@ -455,36 +454,36 @@ const st = class st {
|
|
|
455
454
|
morphElement: n,
|
|
456
455
|
pathname: m
|
|
457
456
|
};
|
|
458
|
-
|
|
457
|
+
O(document, "morphNewChildrenAdded", {
|
|
459
458
|
detail: ct
|
|
460
459
|
});
|
|
461
460
|
const Ot = new Promise((u) => {
|
|
462
461
|
setTimeout(() => {
|
|
463
|
-
j.forEach((S) => S.remove()),
|
|
464
|
-
var
|
|
465
|
-
S instanceof HTMLElement && ((
|
|
462
|
+
j.forEach((S) => S.remove()), B.forEach((S) => {
|
|
463
|
+
var N;
|
|
464
|
+
S instanceof HTMLElement && ((N = S.parentElement) == null || N.style.removeProperty(
|
|
466
465
|
"--new-content-height"
|
|
467
466
|
), S.classList.remove("in", "new"));
|
|
468
|
-
}),
|
|
467
|
+
}), O(document, "morphOldChildrenRemoved", {
|
|
469
468
|
detail: ct
|
|
470
469
|
}), u();
|
|
471
470
|
}, (parseFloat(et) || 0) * 1e3 + 10);
|
|
472
471
|
});
|
|
473
|
-
e(this,
|
|
472
|
+
e(this, q).push(Ot);
|
|
474
473
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
475
474
|
"--new-document-scroll-position",
|
|
476
475
|
(this.scrollValue.top - f.scrollState.y) * 1 + "px"
|
|
477
476
|
) : document.documentElement.style.setProperty(
|
|
478
477
|
"--new-document-scroll-position",
|
|
479
478
|
this.scrollValue.top + "px"
|
|
480
|
-
),
|
|
479
|
+
), O(document, "morphBeforeNavigationScroll", {
|
|
481
480
|
detail: f.scrollState
|
|
482
|
-
}), $ ? (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) => {
|
|
483
482
|
n.querySelectorAll("script").forEach((v) => {
|
|
484
483
|
const et = document.createElement("script");
|
|
485
484
|
et.type = "module", et.src = v.getAttribute("src"), v.replaceWith(et);
|
|
486
485
|
});
|
|
487
|
-
}),
|
|
486
|
+
}), O(document, "morphComplete", {
|
|
488
487
|
detail: mt
|
|
489
488
|
}), document.documentElement.style.removeProperty(
|
|
490
489
|
"--new-document-scroll-position"
|
|
@@ -492,7 +491,7 @@ const st = class st {
|
|
|
492
491
|
} catch (U) {
|
|
493
492
|
console.error(U);
|
|
494
493
|
}
|
|
495
|
-
r(this,
|
|
494
|
+
r(this, V, void 0);
|
|
496
495
|
});
|
|
497
496
|
}
|
|
498
497
|
addLink(t) {
|
|
@@ -524,9 +523,9 @@ const st = class st {
|
|
|
524
523
|
e(this, g).forEach((s) => s.destroy()), r(this, g, t.map((s) => new Et(s, this)));
|
|
525
524
|
}
|
|
526
525
|
};
|
|
527
|
-
P = new WeakMap(), Q = new WeakMap(), g = new WeakMap(),
|
|
528
|
-
let i = e(this,
|
|
529
|
-
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;
|
|
530
529
|
}, St = function(t) {
|
|
531
530
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
532
531
|
return s.length ? s : [t];
|