aptechka 0.67.0 → 0.67.2
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 +64 -65
- 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 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 z=(a,t,s)=>new Promise((i,c)=>{var w=g=>{try{v(s.next(g))}catch(R){c(R)}},x=g=>{try{v(s.throw(g))}catch(R){c(R)}},v=g=>g.done?i(g.value):Promise.resolve(g.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,g)=>(w=c.call(a,w),g=w.done,Promise.resolve(w.value).then(R=>x({value:R,done:g}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("../index-DekP7OZe.cjs"),B=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,g=e(this,l).hasAttribute("data-revalidate"),R=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:g,keepSearchParameters:R,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,O,D,J,F,W;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,O,null);o(this,D,null);o(this,J,null);o(this,F,null);o(this,W,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,F))==null?void 0:t.abort(`[${this.pathname}] page loading cancelled`)}fetch(t){return z(this,null,function*(){if(!(e(this,q)&&!t)){if(e(this,W))return e(this,W);r(this,W,new Promise(s=>z(this,null,function*(){try{r(this,F,new AbortController);const c=yield(yield fetch(`${this.pathname}${this.searchParameters?"?"+this.searchParameters:""}`,{signal:e(this,F).signal})).text(),w=$t.parseFromString(c,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{r(this,F,null),r(this,W,null),s()}})))}})}cloneDocument(){r(this,D,(e(this,O)||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,O,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,O,null):r(this,O,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,O=new WeakMap,D=new WeakMap,J=new WeakMap,F=new WeakMap,W=new WeakMap;var P,Q,E,I,d,nt,Y,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,E,[]);o(this,I);o(this,d,null);o(this,nt);o(this,Y,[]);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=>z(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),B.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,E)}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 z(this,null,function*(){const i=this.normalizePath(t),c=p(this,h,ut).call(this,i.pathname,i.parameters);c==null||c.fetch(s)})}navigate(R){return z(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:w,keepSearchParameters:x,submorph:v,clearState:g}={}){var kt;if(e(this,Y).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,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,I)!==m){e(this,E).forEach(n=>{n.checkCurrent(e(this,d))});return}const ft={pathname:m,submorph:v};B.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,E).forEach(n=>{n.checkCurrent(e(this,d))});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,C)||(f.clearScrollState(),f.clearDocumentState()),g&&f.clearState(),f.cloneDocument(),e(this,X).textContent=f.title,document.body.appendChild(e(this,X)),B.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=>z(this,null,function*(){let A=0;try{for(var y=qt(Et),et,V,U;et=!(V=yield y.next()).done;et=!1){const ct=V.value;ct.onload=()=>{A++,A===Et.length&&n()}}}catch(V){U=[V]}finally{try{et&&(V=y.return)&&(yield V.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 V=[],U=[];v?v.forEach(u=>{const S=n.querySelector(u),M=y.querySelector(u);S&&M&&(U.push(S),V.push(M))}):(V.push(...y.childNodes),U.push(...n.childNodes)),U.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),V.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),v?V.forEach((u,S)=>{var M;(M=U[S].parentElement)==null||M.insertBefore(u,U[S])}):n.prepend(...V),Yt.requestIdleCallback(()=>{V.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};B.dispatchEvent(document,"morphNewChildrenAdded",{detail:ct});const Wt=new Promise(u=>{setTimeout(()=>{U.forEach(S=>S.remove()),V.forEach(S=>{var M;S instanceof HTMLElement&&((M=S.parentElement)==null||M.style.removeProperty("--new-content-height"),S.classList.remove("in","new"))}),B.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ct}),u()},(parseFloat(et)||0)*1e3+10)});e(this,Y).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"),B.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,Y)),Mt.forEach(n=>n.remove()),r(this,Y,[]),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)})}),B.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,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,I=new WeakMap,d=new WeakMap,nt=new WeakMap,Y=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 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;
|
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
|
}, x = (E) => {
|
|
14
14
|
try {
|
|
15
15
|
w(s.throw(E));
|
|
16
|
-
} catch (
|
|
17
|
-
c(
|
|
16
|
+
} catch (z) {
|
|
17
|
+
c(z);
|
|
18
18
|
}
|
|
19
19
|
}, w = (E) => E.done ? i(E.value) : Promise.resolve(E.value).then(y, x);
|
|
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((x, w, E) => (y = c.call(a, y), E = y.done, Promise.resolve(y.value).then((
|
|
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((x, w, E) => (y = c.call(a, y), E = y.done, Promise.resolve(y.value).then((z) => x({ 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";
|
|
@@ -53,7 +53,7 @@ class Et {
|
|
|
53
53
|
r(this, N, 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"), x = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), w = x ? jt.parse(x) : void 0, E = e(this, l).hasAttribute("data-revalidate"),
|
|
56
|
+
) || "push", y = e(this, l).hasAttribute("data-center-scroll"), x = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), w = x ? jt.parse(x) : 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
59
|
e(this, k).navigate(e(this, N), {
|
|
@@ -61,7 +61,7 @@ class Et {
|
|
|
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
|
});
|
|
@@ -86,7 +86,7 @@ class Et {
|
|
|
86
86
|
}
|
|
87
87
|
k = new WeakMap(), l = new WeakMap(), N = new WeakMap(), it = new WeakMap(), K = new WeakMap();
|
|
88
88
|
const Kt = new DOMParser();
|
|
89
|
-
var H, G, rt, b, D,
|
|
89
|
+
var H, G, rt, b, D, W, I, J, Y, R;
|
|
90
90
|
class Dt {
|
|
91
91
|
constructor(t, s, i) {
|
|
92
92
|
o(this, H);
|
|
@@ -94,11 +94,11 @@ class Dt {
|
|
|
94
94
|
o(this, rt);
|
|
95
95
|
o(this, b, { x: 0, y: 0 });
|
|
96
96
|
o(this, D, null);
|
|
97
|
-
o(this,
|
|
97
|
+
o(this, W, null);
|
|
98
98
|
o(this, I, null);
|
|
99
99
|
o(this, J, null);
|
|
100
|
-
o(this,
|
|
101
|
-
o(this,
|
|
100
|
+
o(this, Y, null);
|
|
101
|
+
o(this, R, null);
|
|
102
102
|
r(this, H, t), r(this, G, s), r(this, rt, i);
|
|
103
103
|
}
|
|
104
104
|
get pathname() {
|
|
@@ -118,36 +118,33 @@ class Dt {
|
|
|
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, D) && !t))
|
|
128
|
-
|
|
129
|
-
return e(this, W);
|
|
130
|
-
r(this, W, new Promise((s) => z(this, null, function* () {
|
|
126
|
+
return F(this, null, function* () {
|
|
127
|
+
if (!(e(this, D) && !t))
|
|
128
|
+
return e(this, R) ? e(this, R) : (r(this, R, new Promise((s) => F(this, null, function* () {
|
|
131
129
|
try {
|
|
132
|
-
r(this,
|
|
130
|
+
r(this, Y, new AbortController());
|
|
133
131
|
const c = yield (yield fetch(
|
|
134
132
|
`${this.pathname}${this.searchParameters ? "?" + this.searchParameters : ""}`,
|
|
135
133
|
{
|
|
136
|
-
signal: e(this,
|
|
134
|
+
signal: e(this, Y).signal
|
|
137
135
|
}
|
|
138
136
|
)).text(), y = Kt.parseFromString(c, "text/html");
|
|
139
137
|
this.setInitialDocument(y);
|
|
140
138
|
} catch (i) {
|
|
141
139
|
console.warn(i);
|
|
142
140
|
} finally {
|
|
143
|
-
r(this,
|
|
141
|
+
r(this, Y, null), r(this, R, null), s();
|
|
144
142
|
}
|
|
145
|
-
})));
|
|
146
|
-
}
|
|
143
|
+
}))), e(this, R));
|
|
147
144
|
});
|
|
148
145
|
}
|
|
149
146
|
cloneDocument() {
|
|
150
|
-
r(this, I, (e(this,
|
|
147
|
+
r(this, I, (e(this, W) || e(this, D)).cloneNode(!0));
|
|
151
148
|
}
|
|
152
149
|
get title() {
|
|
153
150
|
let t = "";
|
|
@@ -163,7 +160,7 @@ class Dt {
|
|
|
163
160
|
e(this, b).x = 0, e(this, b).y = 0;
|
|
164
161
|
}
|
|
165
162
|
clearDocumentState() {
|
|
166
|
-
r(this,
|
|
163
|
+
r(this, W, null);
|
|
167
164
|
}
|
|
168
165
|
saveScrollState() {
|
|
169
166
|
e(this, D).documentElement.hasAttribute(
|
|
@@ -180,7 +177,7 @@ class Dt {
|
|
|
180
177
|
saveDocumentState() {
|
|
181
178
|
e(this, D).documentElement.hasAttribute(
|
|
182
179
|
"data-no-page-restoration"
|
|
183
|
-
) ? r(this,
|
|
180
|
+
) ? r(this, W, null) : r(this, W, document.cloneNode(!0));
|
|
184
181
|
}
|
|
185
182
|
renewScrollPosition() {
|
|
186
183
|
e(this, H).scrollElement.scroll({
|
|
@@ -197,18 +194,18 @@ class Dt {
|
|
|
197
194
|
return r(this, J, null), t;
|
|
198
195
|
}
|
|
199
196
|
}
|
|
200
|
-
H = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), b = new WeakMap(), D = new WeakMap(),
|
|
201
|
-
var P, Q, g,
|
|
197
|
+
H = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), b = new WeakMap(), D = new WeakMap(), W = new WeakMap(), I = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), R = new WeakMap();
|
|
198
|
+
var P, Q, g, V, d, nt, q, C, L, ot, T, X, Z, _, at, h, ht, St, qt, wt, yt, vt, bt, ut, tt;
|
|
202
199
|
const st = class st {
|
|
203
200
|
constructor(t) {
|
|
204
201
|
o(this, h);
|
|
205
202
|
o(this, P, null);
|
|
206
203
|
o(this, Q, null);
|
|
207
204
|
o(this, g, []);
|
|
208
|
-
o(this,
|
|
205
|
+
o(this, V);
|
|
209
206
|
o(this, d, null);
|
|
210
207
|
o(this, nt);
|
|
211
|
-
o(this,
|
|
208
|
+
o(this, q, []);
|
|
212
209
|
o(this, C, !1);
|
|
213
210
|
o(this, L, null);
|
|
214
211
|
o(this, ot, !1);
|
|
@@ -220,7 +217,7 @@ const st = class st {
|
|
|
220
217
|
var s;
|
|
221
218
|
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
219
|
});
|
|
223
|
-
o(this, ut, (t) =>
|
|
220
|
+
o(this, ut, (t) => F(this, null, function* () {
|
|
224
221
|
var s;
|
|
225
222
|
(s = t.state) != null && s.path && (t.preventDefault(), r(this, C, !0), yield this.navigate(t.state.path, { historyAction: "none" }), r(this, C, !1));
|
|
226
223
|
}));
|
|
@@ -238,7 +235,7 @@ const st = class st {
|
|
|
238
235
|
), document.documentElement.classList.toggle(
|
|
239
236
|
"scroll-x-backward",
|
|
240
237
|
c < 0
|
|
241
|
-
),
|
|
238
|
+
), O(document, "morphScroll", {
|
|
242
239
|
detail: {
|
|
243
240
|
left: t,
|
|
244
241
|
top: s
|
|
@@ -307,13 +304,15 @@ const st = class st {
|
|
|
307
304
|
});
|
|
308
305
|
}
|
|
309
306
|
prefetch(t, s) {
|
|
310
|
-
return
|
|
307
|
+
return F(this, null, function* () {
|
|
308
|
+
if (e(this, q).length)
|
|
309
|
+
return;
|
|
311
310
|
const i = this.normalizePath(t), c = p(this, h, ht).call(this, i.pathname, i.parameters);
|
|
312
311
|
c == null || c.fetch(s);
|
|
313
312
|
});
|
|
314
313
|
}
|
|
315
|
-
navigate(
|
|
316
|
-
return
|
|
314
|
+
navigate(z) {
|
|
315
|
+
return F(this, arguments, function* (t, {
|
|
317
316
|
historyAction: s = "push",
|
|
318
317
|
centerScroll: i,
|
|
319
318
|
offsetScroll: c,
|
|
@@ -323,11 +322,11 @@ const st = class st {
|
|
|
323
322
|
clearState: E
|
|
324
323
|
} = {}) {
|
|
325
324
|
var Pt;
|
|
326
|
-
if (e(this,
|
|
325
|
+
if (e(this, q).length)
|
|
327
326
|
return;
|
|
328
327
|
const dt = this.normalizePath(((Pt = this.pathnameModifier) == null ? void 0 : Pt.call(this, t)) || t);
|
|
329
328
|
let { pathname: m, hash: $, parameters: Lt, leaf: zt } = dt;
|
|
330
|
-
if (e(this,
|
|
329
|
+
if (e(this, V) === m || e(this, d) === m) {
|
|
331
330
|
e(this, C) || p(this, h, bt).call(this, $ || 0, {
|
|
332
331
|
centerScroll: i,
|
|
333
332
|
offsetScroll: c,
|
|
@@ -335,7 +334,7 @@ const st = class st {
|
|
|
335
334
|
});
|
|
336
335
|
return;
|
|
337
336
|
}
|
|
338
|
-
r(this,
|
|
337
|
+
r(this, V, m), e(this, g).forEach((U) => {
|
|
339
338
|
U.checkCurrent(m);
|
|
340
339
|
});
|
|
341
340
|
try {
|
|
@@ -354,7 +353,7 @@ const st = class st {
|
|
|
354
353
|
} catch (n) {
|
|
355
354
|
n ? console.error(n) : console.log("Route change canceled"), U = !1;
|
|
356
355
|
}
|
|
357
|
-
if (!U || e(this,
|
|
356
|
+
if (!U || e(this, V) !== m) {
|
|
358
357
|
e(this, g).forEach((n) => {
|
|
359
358
|
n.checkCurrent(e(this, d));
|
|
360
359
|
});
|
|
@@ -364,19 +363,19 @@ const st = class st {
|
|
|
364
363
|
pathname: m,
|
|
365
364
|
submorph: w
|
|
366
365
|
};
|
|
367
|
-
|
|
366
|
+
O(document, "morphNavigation", {
|
|
368
367
|
detail: mt
|
|
369
368
|
});
|
|
370
369
|
const ft = p(this, h, ht).call(this, e(this, d)), f = p(this, h, ht).call(this, m, Lt);
|
|
371
370
|
if (e(this, T).forEach((n) => {
|
|
372
371
|
n.pathname !== m && n.abort();
|
|
373
|
-
}), yield f == null ? void 0 : f.fetch(y), e(this,
|
|
372
|
+
}), yield f == null ? void 0 : f.fetch(y), e(this, V) !== m) {
|
|
374
373
|
e(this, g).forEach((n) => {
|
|
375
374
|
n.checkCurrent(e(this, d));
|
|
376
375
|
});
|
|
377
376
|
return;
|
|
378
377
|
}
|
|
379
|
-
ft.clearState(), ft.saveScrollState(), ft.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)),
|
|
378
|
+
ft.clearState(), ft.saveScrollState(), ft.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(document, "morphStart", {
|
|
380
379
|
detail: mt
|
|
381
380
|
});
|
|
382
381
|
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);
|
|
@@ -394,20 +393,20 @@ const st = class st {
|
|
|
394
393
|
if (p(this, h, yt).call(this, n))
|
|
395
394
|
return !0;
|
|
396
395
|
});
|
|
397
|
-
e(this, P).waitForHeadToLoad && pt.length && (yield new Promise((n) =>
|
|
396
|
+
e(this, P).waitForHeadToLoad && pt.length && (yield new Promise((n) => F(this, null, function* () {
|
|
398
397
|
let A = 0;
|
|
399
398
|
try {
|
|
400
|
-
for (var v = Nt(pt), et,
|
|
401
|
-
const ct =
|
|
399
|
+
for (var v = Nt(pt), et, B, j; et = !(B = yield v.next()).done; et = !1) {
|
|
400
|
+
const ct = B.value;
|
|
402
401
|
ct.onload = () => {
|
|
403
402
|
A++, A === pt.length && n();
|
|
404
403
|
};
|
|
405
404
|
}
|
|
406
|
-
} catch (
|
|
407
|
-
j = [
|
|
405
|
+
} catch (B) {
|
|
406
|
+
j = [B];
|
|
408
407
|
} finally {
|
|
409
408
|
try {
|
|
410
|
-
et && (
|
|
409
|
+
et && (B = v.return) && (yield B.call(v));
|
|
411
410
|
} finally {
|
|
412
411
|
if (j)
|
|
413
412
|
throw j[0];
|
|
@@ -426,22 +425,22 @@ const st = class st {
|
|
|
426
425
|
hash: $
|
|
427
426
|
}), e(this, X).remove(), r(this, nt, e(this, d)), r(this, d, m), e(this, Q).forEach((n, A) => {
|
|
428
427
|
const v = Ft[A], et = getComputedStyle(n).getPropertyValue("--morph-duration");
|
|
429
|
-
let
|
|
428
|
+
let B = [], j = [];
|
|
430
429
|
w ? w.forEach((u) => {
|
|
431
430
|
const S = n.querySelector(u), M = v.querySelector(u);
|
|
432
|
-
S && M && (j.push(S),
|
|
433
|
-
}) : (
|
|
431
|
+
S && M && (j.push(S), B.push(M));
|
|
432
|
+
}) : (B.push(...v.childNodes), j.push(...n.childNodes)), j.forEach((u) => {
|
|
434
433
|
u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
|
|
435
|
-
}),
|
|
434
|
+
}), B.forEach((u) => {
|
|
436
435
|
u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
|
|
437
|
-
}), w ?
|
|
436
|
+
}), w ? B.forEach((u, S) => {
|
|
438
437
|
var M;
|
|
439
438
|
(M = j[S].parentElement) == null || M.insertBefore(
|
|
440
439
|
u,
|
|
441
440
|
j[S]
|
|
442
441
|
);
|
|
443
|
-
}) : n.prepend(...
|
|
444
|
-
|
|
442
|
+
}) : n.prepend(...B), Wt(() => {
|
|
443
|
+
B.forEach((u) => {
|
|
445
444
|
var S;
|
|
446
445
|
u instanceof HTMLElement && ((S = u.parentElement) == null || S.style.setProperty(
|
|
447
446
|
"--new-content-height",
|
|
@@ -453,36 +452,36 @@ const st = class st {
|
|
|
453
452
|
morphElement: n,
|
|
454
453
|
pathname: m
|
|
455
454
|
};
|
|
456
|
-
|
|
455
|
+
O(document, "morphNewChildrenAdded", {
|
|
457
456
|
detail: ct
|
|
458
457
|
});
|
|
459
458
|
const Ot = new Promise((u) => {
|
|
460
459
|
setTimeout(() => {
|
|
461
|
-
j.forEach((S) => S.remove()),
|
|
460
|
+
j.forEach((S) => S.remove()), B.forEach((S) => {
|
|
462
461
|
var M;
|
|
463
462
|
S instanceof HTMLElement && ((M = S.parentElement) == null || M.style.removeProperty(
|
|
464
463
|
"--new-content-height"
|
|
465
464
|
), S.classList.remove("in", "new"));
|
|
466
|
-
}),
|
|
465
|
+
}), O(document, "morphOldChildrenRemoved", {
|
|
467
466
|
detail: ct
|
|
468
467
|
}), u();
|
|
469
468
|
}, (parseFloat(et) || 0) * 1e3 + 10);
|
|
470
469
|
});
|
|
471
|
-
e(this,
|
|
470
|
+
e(this, q).push(Ot);
|
|
472
471
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
473
472
|
"--new-document-scroll-position",
|
|
474
473
|
(this.scrollValue.top - f.scrollState.y) * 1 + "px"
|
|
475
474
|
) : document.documentElement.style.setProperty(
|
|
476
475
|
"--new-document-scroll-position",
|
|
477
476
|
this.scrollValue.top + "px"
|
|
478
|
-
),
|
|
477
|
+
), O(document, "morphBeforeNavigationScroll", {
|
|
479
478
|
detail: f.scrollState
|
|
480
|
-
}), $ ? (f.clearScrollState(), p(this, h, bt).call(this, $, { centerScroll: i, offsetScroll: c })) : e(this, C) ? f.restoreScrollPosition() : f.renewScrollPosition(), yield Promise.all(e(this,
|
|
479
|
+
}), $ ? (f.clearScrollState(), p(this, h, bt).call(this, $, { centerScroll: i, offsetScroll: c })) : e(this, C) ? f.restoreScrollPosition() : f.renewScrollPosition(), yield Promise.all(e(this, q)), Tt.forEach((n) => n.remove()), r(this, q, []), e(this, Q).forEach((n) => {
|
|
481
480
|
n.querySelectorAll("script").forEach((v) => {
|
|
482
481
|
const et = document.createElement("script");
|
|
483
482
|
et.type = "module", et.src = v.getAttribute("src"), v.replaceWith(et);
|
|
484
483
|
});
|
|
485
|
-
}),
|
|
484
|
+
}), O(document, "morphComplete", {
|
|
486
485
|
detail: mt
|
|
487
486
|
}), document.documentElement.style.removeProperty(
|
|
488
487
|
"--new-document-scroll-position"
|
|
@@ -490,7 +489,7 @@ const st = class st {
|
|
|
490
489
|
} catch (U) {
|
|
491
490
|
console.error(U);
|
|
492
491
|
}
|
|
493
|
-
r(this,
|
|
492
|
+
r(this, V, void 0);
|
|
494
493
|
});
|
|
495
494
|
}
|
|
496
495
|
addLink(t) {
|
|
@@ -522,7 +521,7 @@ const st = class st {
|
|
|
522
521
|
e(this, g).forEach((s) => s.destroy()), r(this, g, t.map((s) => new Et(s, this)));
|
|
523
522
|
}
|
|
524
523
|
};
|
|
525
|
-
P = new WeakMap(), Q = new WeakMap(), g = new WeakMap(),
|
|
524
|
+
P = new WeakMap(), Q = new WeakMap(), g = new WeakMap(), V = new WeakMap(), d = new WeakMap(), nt = new WeakMap(), q = 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(), ht = function(t, s) {
|
|
526
525
|
let i = e(this, T).get(t);
|
|
527
526
|
return i || (i = new Dt(this, t, s), e(this, T).set(t, i)), i;
|
|
528
527
|
}, St = function(t) {
|