aptechka 0.67.0 → 0.67.1
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 +57 -55
- 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 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;
|
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 B = (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 (q) {
|
|
11
|
+
c(q);
|
|
12
12
|
}
|
|
13
13
|
}, x = (E) => {
|
|
14
14
|
try {
|
|
15
15
|
w(s.throw(E));
|
|
16
|
-
} catch (
|
|
17
|
-
c(
|
|
16
|
+
} catch (q) {
|
|
17
|
+
c(q);
|
|
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((q) => x({ value: q, 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 F } 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"), q = 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: q,
|
|
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, O, I, J, W, Y;
|
|
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, O, null);
|
|
98
98
|
o(this, I, null);
|
|
99
99
|
o(this, J, null);
|
|
100
|
-
o(this, O, null);
|
|
101
100
|
o(this, W, null);
|
|
101
|
+
o(this, Y, null);
|
|
102
102
|
r(this, H, t), r(this, G, s), r(this, rt, i);
|
|
103
103
|
}
|
|
104
104
|
get pathname() {
|
|
@@ -118,36 +118,36 @@ class Dt {
|
|
|
118
118
|
}
|
|
119
119
|
abort() {
|
|
120
120
|
var t;
|
|
121
|
-
return (t = e(this,
|
|
121
|
+
return (t = e(this, W)) == null ? void 0 : t.abort(
|
|
122
122
|
`[${this.pathname}] page loading cancelled`
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
fetch(t) {
|
|
126
|
-
return
|
|
126
|
+
return B(this, null, function* () {
|
|
127
127
|
if (!(e(this, D) && !t)) {
|
|
128
|
-
if (e(this,
|
|
129
|
-
return e(this,
|
|
130
|
-
r(this,
|
|
128
|
+
if (e(this, Y))
|
|
129
|
+
return e(this, Y);
|
|
130
|
+
r(this, Y, new Promise((s) => B(this, null, function* () {
|
|
131
131
|
try {
|
|
132
|
-
r(this,
|
|
132
|
+
r(this, W, new AbortController());
|
|
133
133
|
const c = yield (yield fetch(
|
|
134
134
|
`${this.pathname}${this.searchParameters ? "?" + this.searchParameters : ""}`,
|
|
135
135
|
{
|
|
136
|
-
signal: e(this,
|
|
136
|
+
signal: e(this, W).signal
|
|
137
137
|
}
|
|
138
138
|
)).text(), y = Kt.parseFromString(c, "text/html");
|
|
139
139
|
this.setInitialDocument(y);
|
|
140
140
|
} catch (i) {
|
|
141
141
|
console.warn(i);
|
|
142
142
|
} finally {
|
|
143
|
-
r(this,
|
|
143
|
+
r(this, W, null), r(this, Y, null), s();
|
|
144
144
|
}
|
|
145
145
|
})));
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
cloneDocument() {
|
|
150
|
-
r(this, I, (e(this,
|
|
150
|
+
r(this, I, (e(this, O) || e(this, D)).cloneNode(!0));
|
|
151
151
|
}
|
|
152
152
|
get title() {
|
|
153
153
|
let t = "";
|
|
@@ -163,7 +163,7 @@ class Dt {
|
|
|
163
163
|
e(this, b).x = 0, e(this, b).y = 0;
|
|
164
164
|
}
|
|
165
165
|
clearDocumentState() {
|
|
166
|
-
r(this,
|
|
166
|
+
r(this, O, null);
|
|
167
167
|
}
|
|
168
168
|
saveScrollState() {
|
|
169
169
|
e(this, D).documentElement.hasAttribute(
|
|
@@ -180,7 +180,7 @@ class Dt {
|
|
|
180
180
|
saveDocumentState() {
|
|
181
181
|
e(this, D).documentElement.hasAttribute(
|
|
182
182
|
"data-no-page-restoration"
|
|
183
|
-
) ? r(this,
|
|
183
|
+
) ? r(this, O, null) : r(this, O, document.cloneNode(!0));
|
|
184
184
|
}
|
|
185
185
|
renewScrollPosition() {
|
|
186
186
|
e(this, H).scrollElement.scroll({
|
|
@@ -197,8 +197,8 @@ class Dt {
|
|
|
197
197
|
return r(this, J, null), t;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
H = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), b = new WeakMap(), D = new WeakMap(),
|
|
201
|
-
var P, Q, g, R, d, nt,
|
|
200
|
+
H = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), b = new WeakMap(), D = new WeakMap(), O = new WeakMap(), I = new WeakMap(), J = new WeakMap(), W = new WeakMap(), Y = new WeakMap();
|
|
201
|
+
var P, Q, g, R, d, nt, V, C, L, ot, T, X, Z, _, at, h, ht, St, qt, wt, yt, vt, bt, ut, tt;
|
|
202
202
|
const st = class st {
|
|
203
203
|
constructor(t) {
|
|
204
204
|
o(this, h);
|
|
@@ -208,7 +208,7 @@ const st = class st {
|
|
|
208
208
|
o(this, R);
|
|
209
209
|
o(this, d, null);
|
|
210
210
|
o(this, nt);
|
|
211
|
-
o(this,
|
|
211
|
+
o(this, V, []);
|
|
212
212
|
o(this, C, !1);
|
|
213
213
|
o(this, L, null);
|
|
214
214
|
o(this, ot, !1);
|
|
@@ -220,7 +220,7 @@ const st = class st {
|
|
|
220
220
|
var s;
|
|
221
221
|
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
222
|
});
|
|
223
|
-
o(this, ut, (t) =>
|
|
223
|
+
o(this, ut, (t) => B(this, null, function* () {
|
|
224
224
|
var s;
|
|
225
225
|
(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
226
|
}));
|
|
@@ -238,7 +238,7 @@ const st = class st {
|
|
|
238
238
|
), document.documentElement.classList.toggle(
|
|
239
239
|
"scroll-x-backward",
|
|
240
240
|
c < 0
|
|
241
|
-
),
|
|
241
|
+
), F(document, "morphScroll", {
|
|
242
242
|
detail: {
|
|
243
243
|
left: t,
|
|
244
244
|
top: s
|
|
@@ -307,13 +307,15 @@ const st = class st {
|
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
prefetch(t, s) {
|
|
310
|
-
return
|
|
310
|
+
return B(this, null, function* () {
|
|
311
|
+
if (e(this, V).length)
|
|
312
|
+
return;
|
|
311
313
|
const i = this.normalizePath(t), c = p(this, h, ht).call(this, i.pathname, i.parameters);
|
|
312
314
|
c == null || c.fetch(s);
|
|
313
315
|
});
|
|
314
316
|
}
|
|
315
|
-
navigate(
|
|
316
|
-
return
|
|
317
|
+
navigate(q) {
|
|
318
|
+
return B(this, arguments, function* (t, {
|
|
317
319
|
historyAction: s = "push",
|
|
318
320
|
centerScroll: i,
|
|
319
321
|
offsetScroll: c,
|
|
@@ -323,7 +325,7 @@ const st = class st {
|
|
|
323
325
|
clearState: E
|
|
324
326
|
} = {}) {
|
|
325
327
|
var Pt;
|
|
326
|
-
if (e(this,
|
|
328
|
+
if (e(this, V).length)
|
|
327
329
|
return;
|
|
328
330
|
const dt = this.normalizePath(((Pt = this.pathnameModifier) == null ? void 0 : Pt.call(this, t)) || t);
|
|
329
331
|
let { pathname: m, hash: $, parameters: Lt, leaf: zt } = dt;
|
|
@@ -364,7 +366,7 @@ const st = class st {
|
|
|
364
366
|
pathname: m,
|
|
365
367
|
submorph: w
|
|
366
368
|
};
|
|
367
|
-
|
|
369
|
+
F(document, "morphNavigation", {
|
|
368
370
|
detail: mt
|
|
369
371
|
});
|
|
370
372
|
const ft = p(this, h, ht).call(this, e(this, d)), f = p(this, h, ht).call(this, m, Lt);
|
|
@@ -376,7 +378,7 @@ const st = class st {
|
|
|
376
378
|
});
|
|
377
379
|
return;
|
|
378
380
|
}
|
|
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)),
|
|
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)), F(document, "morphStart", {
|
|
380
382
|
detail: mt
|
|
381
383
|
});
|
|
382
384
|
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 +396,20 @@ const st = class st {
|
|
|
394
396
|
if (p(this, h, yt).call(this, n))
|
|
395
397
|
return !0;
|
|
396
398
|
});
|
|
397
|
-
e(this, P).waitForHeadToLoad && pt.length && (yield new Promise((n) =>
|
|
399
|
+
e(this, P).waitForHeadToLoad && pt.length && (yield new Promise((n) => B(this, null, function* () {
|
|
398
400
|
let A = 0;
|
|
399
401
|
try {
|
|
400
|
-
for (var v = Nt(pt), et,
|
|
401
|
-
const ct =
|
|
402
|
+
for (var v = Nt(pt), et, z, j; et = !(z = yield v.next()).done; et = !1) {
|
|
403
|
+
const ct = z.value;
|
|
402
404
|
ct.onload = () => {
|
|
403
405
|
A++, A === pt.length && n();
|
|
404
406
|
};
|
|
405
407
|
}
|
|
406
|
-
} catch (
|
|
407
|
-
j = [
|
|
408
|
+
} catch (z) {
|
|
409
|
+
j = [z];
|
|
408
410
|
} finally {
|
|
409
411
|
try {
|
|
410
|
-
et && (
|
|
412
|
+
et && (z = v.return) && (yield z.call(v));
|
|
411
413
|
} finally {
|
|
412
414
|
if (j)
|
|
413
415
|
throw j[0];
|
|
@@ -426,22 +428,22 @@ const st = class st {
|
|
|
426
428
|
hash: $
|
|
427
429
|
}), e(this, X).remove(), r(this, nt, e(this, d)), r(this, d, m), e(this, Q).forEach((n, A) => {
|
|
428
430
|
const v = Ft[A], et = getComputedStyle(n).getPropertyValue("--morph-duration");
|
|
429
|
-
let
|
|
431
|
+
let z = [], j = [];
|
|
430
432
|
w ? w.forEach((u) => {
|
|
431
433
|
const S = n.querySelector(u), M = v.querySelector(u);
|
|
432
|
-
S && M && (j.push(S),
|
|
433
|
-
}) : (
|
|
434
|
+
S && M && (j.push(S), z.push(M));
|
|
435
|
+
}) : (z.push(...v.childNodes), j.push(...n.childNodes)), j.forEach((u) => {
|
|
434
436
|
u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
|
|
435
|
-
}),
|
|
437
|
+
}), z.forEach((u) => {
|
|
436
438
|
u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
|
|
437
|
-
}), w ?
|
|
439
|
+
}), w ? z.forEach((u, S) => {
|
|
438
440
|
var M;
|
|
439
441
|
(M = j[S].parentElement) == null || M.insertBefore(
|
|
440
442
|
u,
|
|
441
443
|
j[S]
|
|
442
444
|
);
|
|
443
|
-
}) : n.prepend(...
|
|
444
|
-
|
|
445
|
+
}) : n.prepend(...z), Wt(() => {
|
|
446
|
+
z.forEach((u) => {
|
|
445
447
|
var S;
|
|
446
448
|
u instanceof HTMLElement && ((S = u.parentElement) == null || S.style.setProperty(
|
|
447
449
|
"--new-content-height",
|
|
@@ -453,36 +455,36 @@ const st = class st {
|
|
|
453
455
|
morphElement: n,
|
|
454
456
|
pathname: m
|
|
455
457
|
};
|
|
456
|
-
|
|
458
|
+
F(document, "morphNewChildrenAdded", {
|
|
457
459
|
detail: ct
|
|
458
460
|
});
|
|
459
461
|
const Ot = new Promise((u) => {
|
|
460
462
|
setTimeout(() => {
|
|
461
|
-
j.forEach((S) => S.remove()),
|
|
463
|
+
j.forEach((S) => S.remove()), z.forEach((S) => {
|
|
462
464
|
var M;
|
|
463
465
|
S instanceof HTMLElement && ((M = S.parentElement) == null || M.style.removeProperty(
|
|
464
466
|
"--new-content-height"
|
|
465
467
|
), S.classList.remove("in", "new"));
|
|
466
|
-
}),
|
|
468
|
+
}), F(document, "morphOldChildrenRemoved", {
|
|
467
469
|
detail: ct
|
|
468
470
|
}), u();
|
|
469
471
|
}, (parseFloat(et) || 0) * 1e3 + 10);
|
|
470
472
|
});
|
|
471
|
-
e(this,
|
|
473
|
+
e(this, V).push(Ot);
|
|
472
474
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
473
475
|
"--new-document-scroll-position",
|
|
474
476
|
(this.scrollValue.top - f.scrollState.y) * 1 + "px"
|
|
475
477
|
) : document.documentElement.style.setProperty(
|
|
476
478
|
"--new-document-scroll-position",
|
|
477
479
|
this.scrollValue.top + "px"
|
|
478
|
-
),
|
|
480
|
+
), F(document, "morphBeforeNavigationScroll", {
|
|
479
481
|
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,
|
|
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, V)), Tt.forEach((n) => n.remove()), r(this, V, []), e(this, Q).forEach((n) => {
|
|
481
483
|
n.querySelectorAll("script").forEach((v) => {
|
|
482
484
|
const et = document.createElement("script");
|
|
483
485
|
et.type = "module", et.src = v.getAttribute("src"), v.replaceWith(et);
|
|
484
486
|
});
|
|
485
|
-
}),
|
|
487
|
+
}), F(document, "morphComplete", {
|
|
486
488
|
detail: mt
|
|
487
489
|
}), document.documentElement.style.removeProperty(
|
|
488
490
|
"--new-document-scroll-position"
|
|
@@ -522,7 +524,7 @@ const st = class st {
|
|
|
522
524
|
e(this, g).forEach((s) => s.destroy()), r(this, g, t.map((s) => new Et(s, this)));
|
|
523
525
|
}
|
|
524
526
|
};
|
|
525
|
-
P = new WeakMap(), Q = new WeakMap(), g = new WeakMap(), R = new WeakMap(), d = new WeakMap(), nt = new WeakMap(),
|
|
527
|
+
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(), ht = function(t, s) {
|
|
526
528
|
let i = e(this, T).get(t);
|
|
527
529
|
return i || (i = new Dt(this, t, s), e(this, T).set(t, i)), i;
|
|
528
530
|
}, St = function(t) {
|