aptechka 0.67.1 → 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 +62 -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 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 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, W, null);
|
|
101
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, Y);
|
|
130
|
-
r(this, Y, new Promise((s) => B(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,15 +304,15 @@ const st = class st {
|
|
|
307
304
|
});
|
|
308
305
|
}
|
|
309
306
|
prefetch(t, s) {
|
|
310
|
-
return
|
|
311
|
-
if (e(this,
|
|
307
|
+
return F(this, null, function* () {
|
|
308
|
+
if (e(this, q).length)
|
|
312
309
|
return;
|
|
313
310
|
const i = this.normalizePath(t), c = p(this, h, ht).call(this, i.pathname, i.parameters);
|
|
314
311
|
c == null || c.fetch(s);
|
|
315
312
|
});
|
|
316
313
|
}
|
|
317
|
-
navigate(
|
|
318
|
-
return
|
|
314
|
+
navigate(z) {
|
|
315
|
+
return F(this, arguments, function* (t, {
|
|
319
316
|
historyAction: s = "push",
|
|
320
317
|
centerScroll: i,
|
|
321
318
|
offsetScroll: c,
|
|
@@ -325,11 +322,11 @@ const st = class st {
|
|
|
325
322
|
clearState: E
|
|
326
323
|
} = {}) {
|
|
327
324
|
var Pt;
|
|
328
|
-
if (e(this,
|
|
325
|
+
if (e(this, q).length)
|
|
329
326
|
return;
|
|
330
327
|
const dt = this.normalizePath(((Pt = this.pathnameModifier) == null ? void 0 : Pt.call(this, t)) || t);
|
|
331
328
|
let { pathname: m, hash: $, parameters: Lt, leaf: zt } = dt;
|
|
332
|
-
if (e(this,
|
|
329
|
+
if (e(this, V) === m || e(this, d) === m) {
|
|
333
330
|
e(this, C) || p(this, h, bt).call(this, $ || 0, {
|
|
334
331
|
centerScroll: i,
|
|
335
332
|
offsetScroll: c,
|
|
@@ -337,7 +334,7 @@ const st = class st {
|
|
|
337
334
|
});
|
|
338
335
|
return;
|
|
339
336
|
}
|
|
340
|
-
r(this,
|
|
337
|
+
r(this, V, m), e(this, g).forEach((U) => {
|
|
341
338
|
U.checkCurrent(m);
|
|
342
339
|
});
|
|
343
340
|
try {
|
|
@@ -356,7 +353,7 @@ const st = class st {
|
|
|
356
353
|
} catch (n) {
|
|
357
354
|
n ? console.error(n) : console.log("Route change canceled"), U = !1;
|
|
358
355
|
}
|
|
359
|
-
if (!U || e(this,
|
|
356
|
+
if (!U || e(this, V) !== m) {
|
|
360
357
|
e(this, g).forEach((n) => {
|
|
361
358
|
n.checkCurrent(e(this, d));
|
|
362
359
|
});
|
|
@@ -366,19 +363,19 @@ const st = class st {
|
|
|
366
363
|
pathname: m,
|
|
367
364
|
submorph: w
|
|
368
365
|
};
|
|
369
|
-
|
|
366
|
+
O(document, "morphNavigation", {
|
|
370
367
|
detail: mt
|
|
371
368
|
});
|
|
372
369
|
const ft = p(this, h, ht).call(this, e(this, d)), f = p(this, h, ht).call(this, m, Lt);
|
|
373
370
|
if (e(this, T).forEach((n) => {
|
|
374
371
|
n.pathname !== m && n.abort();
|
|
375
|
-
}), yield f == null ? void 0 : f.fetch(y), e(this,
|
|
372
|
+
}), yield f == null ? void 0 : f.fetch(y), e(this, V) !== m) {
|
|
376
373
|
e(this, g).forEach((n) => {
|
|
377
374
|
n.checkCurrent(e(this, d));
|
|
378
375
|
});
|
|
379
376
|
return;
|
|
380
377
|
}
|
|
381
|
-
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", {
|
|
382
379
|
detail: mt
|
|
383
380
|
});
|
|
384
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);
|
|
@@ -396,20 +393,20 @@ const st = class st {
|
|
|
396
393
|
if (p(this, h, yt).call(this, n))
|
|
397
394
|
return !0;
|
|
398
395
|
});
|
|
399
|
-
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* () {
|
|
400
397
|
let A = 0;
|
|
401
398
|
try {
|
|
402
|
-
for (var v = Nt(pt), et,
|
|
403
|
-
const ct =
|
|
399
|
+
for (var v = Nt(pt), et, B, j; et = !(B = yield v.next()).done; et = !1) {
|
|
400
|
+
const ct = B.value;
|
|
404
401
|
ct.onload = () => {
|
|
405
402
|
A++, A === pt.length && n();
|
|
406
403
|
};
|
|
407
404
|
}
|
|
408
|
-
} catch (
|
|
409
|
-
j = [
|
|
405
|
+
} catch (B) {
|
|
406
|
+
j = [B];
|
|
410
407
|
} finally {
|
|
411
408
|
try {
|
|
412
|
-
et && (
|
|
409
|
+
et && (B = v.return) && (yield B.call(v));
|
|
413
410
|
} finally {
|
|
414
411
|
if (j)
|
|
415
412
|
throw j[0];
|
|
@@ -428,22 +425,22 @@ const st = class st {
|
|
|
428
425
|
hash: $
|
|
429
426
|
}), e(this, X).remove(), r(this, nt, e(this, d)), r(this, d, m), e(this, Q).forEach((n, A) => {
|
|
430
427
|
const v = Ft[A], et = getComputedStyle(n).getPropertyValue("--morph-duration");
|
|
431
|
-
let
|
|
428
|
+
let B = [], j = [];
|
|
432
429
|
w ? w.forEach((u) => {
|
|
433
430
|
const S = n.querySelector(u), M = v.querySelector(u);
|
|
434
|
-
S && M && (j.push(S),
|
|
435
|
-
}) : (
|
|
431
|
+
S && M && (j.push(S), B.push(M));
|
|
432
|
+
}) : (B.push(...v.childNodes), j.push(...n.childNodes)), j.forEach((u) => {
|
|
436
433
|
u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
|
|
437
|
-
}),
|
|
434
|
+
}), B.forEach((u) => {
|
|
438
435
|
u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
|
|
439
|
-
}), w ?
|
|
436
|
+
}), w ? B.forEach((u, S) => {
|
|
440
437
|
var M;
|
|
441
438
|
(M = j[S].parentElement) == null || M.insertBefore(
|
|
442
439
|
u,
|
|
443
440
|
j[S]
|
|
444
441
|
);
|
|
445
|
-
}) : n.prepend(...
|
|
446
|
-
|
|
442
|
+
}) : n.prepend(...B), Wt(() => {
|
|
443
|
+
B.forEach((u) => {
|
|
447
444
|
var S;
|
|
448
445
|
u instanceof HTMLElement && ((S = u.parentElement) == null || S.style.setProperty(
|
|
449
446
|
"--new-content-height",
|
|
@@ -455,36 +452,36 @@ const st = class st {
|
|
|
455
452
|
morphElement: n,
|
|
456
453
|
pathname: m
|
|
457
454
|
};
|
|
458
|
-
|
|
455
|
+
O(document, "morphNewChildrenAdded", {
|
|
459
456
|
detail: ct
|
|
460
457
|
});
|
|
461
458
|
const Ot = new Promise((u) => {
|
|
462
459
|
setTimeout(() => {
|
|
463
|
-
j.forEach((S) => S.remove()),
|
|
460
|
+
j.forEach((S) => S.remove()), B.forEach((S) => {
|
|
464
461
|
var M;
|
|
465
462
|
S instanceof HTMLElement && ((M = S.parentElement) == null || M.style.removeProperty(
|
|
466
463
|
"--new-content-height"
|
|
467
464
|
), S.classList.remove("in", "new"));
|
|
468
|
-
}),
|
|
465
|
+
}), O(document, "morphOldChildrenRemoved", {
|
|
469
466
|
detail: ct
|
|
470
467
|
}), u();
|
|
471
468
|
}, (parseFloat(et) || 0) * 1e3 + 10);
|
|
472
469
|
});
|
|
473
|
-
e(this,
|
|
470
|
+
e(this, q).push(Ot);
|
|
474
471
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
475
472
|
"--new-document-scroll-position",
|
|
476
473
|
(this.scrollValue.top - f.scrollState.y) * 1 + "px"
|
|
477
474
|
) : document.documentElement.style.setProperty(
|
|
478
475
|
"--new-document-scroll-position",
|
|
479
476
|
this.scrollValue.top + "px"
|
|
480
|
-
),
|
|
477
|
+
), O(document, "morphBeforeNavigationScroll", {
|
|
481
478
|
detail: f.scrollState
|
|
482
|
-
}), $ ? (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) => {
|
|
483
480
|
n.querySelectorAll("script").forEach((v) => {
|
|
484
481
|
const et = document.createElement("script");
|
|
485
482
|
et.type = "module", et.src = v.getAttribute("src"), v.replaceWith(et);
|
|
486
483
|
});
|
|
487
|
-
}),
|
|
484
|
+
}), O(document, "morphComplete", {
|
|
488
485
|
detail: mt
|
|
489
486
|
}), document.documentElement.style.removeProperty(
|
|
490
487
|
"--new-document-scroll-position"
|
|
@@ -492,7 +489,7 @@ const st = class st {
|
|
|
492
489
|
} catch (U) {
|
|
493
490
|
console.error(U);
|
|
494
491
|
}
|
|
495
|
-
r(this,
|
|
492
|
+
r(this, V, void 0);
|
|
496
493
|
});
|
|
497
494
|
}
|
|
498
495
|
addLink(t) {
|
|
@@ -524,7 +521,7 @@ const st = class st {
|
|
|
524
521
|
e(this, g).forEach((s) => s.destroy()), r(this, g, t.map((s) => new Et(s, this)));
|
|
525
522
|
}
|
|
526
523
|
};
|
|
527
|
-
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) {
|
|
528
525
|
let i = e(this, T).get(t);
|
|
529
526
|
return i || (i = new Dt(this, t, s), e(this, T).set(t, i)), i;
|
|
530
527
|
}, St = function(t) {
|