aptechka 0.72.0 → 0.72.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 +232 -227
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Qt=Object.defineProperty,Zt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var It=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Ot=r=>{throw TypeError(r)};var Vt=(r,t,s)=>t in r?Qt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,dt=(r,t)=>{for(var s in t||(t={}))te.call(t,s)&&Vt(r,s,t[s]);if(zt)for(var s of zt(t))ee.call(t,s)&&Vt(r,s,t[s]);return r},St=(r,t)=>Zt(r,_t(t));var wt=(r,t,s)=>t.has(r)||Ot("Cannot "+s);var e=(r,t,s)=>(wt(r,t,"read from private field"),s?s.call(r):t.get(r)),o=(r,t,s)=>t.has(r)?Ot("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(wt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),E=(r,t,s)=>(wt(r,t,"access private method"),s);var B=(r,t,s)=>new Promise((i,h)=>{var v=S=>{try{f(s.next(S))}catch(O){h(O)}},b=S=>{try{f(s.throw(S))}catch(O){h(O)}},f=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,b);f((s=s.apply(r,t)).next())});var Ft=(r,t,s)=>(t=r[It("asyncIterator")])?t.call(r):(r=r[It("iterator")](),t={},s=(i,h)=>(h=r[i])&&(t[i]=v=>new Promise((b,f,S)=>(v=h.call(r,v),S=v.done,Promise.resolve(v.value).then(O=>b({value:O,done:S}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Xt=require("../index-DekP7OZe.cjs"),C=require("../events-KVanG9sR.cjs"),se=require("../polyfills-Df4r-ETT.cjs"),Bt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const et=require("../url-YEESIcRn.cjs"),ie=require("../css-value-parser/index.cjs");class Yt 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)}}Xt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Yt);var H,l,q,it,G;class Lt{constructor(t,s){o(this,H);o(this,l);o(this,q);o(this,it,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{n(this,q,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=b?ie.cssValueParser.parse(b):void 0,S=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),lt=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ht=>ht.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,H).navigate(e(this,q),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:S,keepSearchParameters:O,submorph:lt,clearState:c})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,H).prefetch(e(this,q),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,H,s),n(this,l,t),n(this,q,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,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,H).normalizePath(t),i=e(this,H).normalizePath(e(this,q));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"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?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,G)),e(this,l).classList.remove("current")}}H=new WeakMap,l=new WeakMap,q=new WeakMap,it=new WeakMap,G=new WeakMap;const ne=new DOMParser;var M,W,L,P,X,D,J,Y,U,Q,nt;class Wt{constructor(t,s){o(this,M);o(this,W);o(this,L,{x:0,y:0});o(this,P,null);o(this,X,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,U,null);o(this,Q);o(this,nt);n(this,M,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,L)}get document(){return e(this,D)}setHeaders(t){n(this,nt,t)}setInitialDocument(t){n(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,U)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,P)&&e(this,M).isPopstateNavigation?e(this,U):(n(this,Q,t),n(this,U,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const b=yield(yield fetch(t,{signal:e(this,Y).signal,headers:dt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,nt))})).text(),f=ne.parseFromString(b,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,U,null),h()}}))),e(this,U))})}cloneDocument(){n(this,D,(e(this,X)||e(this,P)).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,W)}return t}clearScrollState(){e(this,L).x=0,e(this,L).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,L).x=0,e(this,L).y=0):(e(this,L).x=e(this,M).scrollValue.left,e(this,L).y=e(this,M).scrollValue.top)}restoreScrollPosition(){e(this,M).scrollElement.scroll({top:e(this,L).y,left:e(this,L).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,M).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}M=new WeakMap,W=new WeakMap,L=new WeakMap,P=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,U=new WeakMap,Q=new WeakMap,nt=new WeakMap;var A,rt,g,z,m,j,I,V,y,at,R,K,Z,_,u,bt,ot,mt,Pt,jt,At,kt,Ct,Ht,ft,tt;const st=class st{constructor(t){o(this,u);o(this,A,null);o(this,rt,null);o(this,g,[]);o(this,z);o(this,m,null);o(this,j);o(this,I,[]);o(this,V,!1);o(this,y,null);o(this,at,!1);o(this,R,new Map);o(this,K,null);o(this,Z,0);o(this,_,0);o(this,ot,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,ft,t=>B(this,null,function*(){t.preventDefault(),n(this,V,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t.state.submorph}),n(this,V,!1)}));o(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),h=t-e(this,Z);n(this,_,s),n(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",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),C.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Xt.isBrowser&&!st.instance){st.instance=this,n(this,A,{base:et.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,rt,E(this,u,Pt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,m,s);const i=new Wt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,R).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ft)),et.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new Yt),E(this,u,Ct).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,y)}get isPopstateNavigation(){return e(this,V)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,y).scrollTop,s=e(this,y).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,R).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,R).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return et.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,I).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,mt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate(O){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:b,submorph:f,clearState:S}={}){var ht,Mt,Rt,Tt;if(e(this,I).length)return;const lt=((ht=this.pathnameModifier)==null?void 0:ht.call(this,t))||t,c=this.normalizePath(lt);if(((Mt=e(this,z))==null?void 0:Mt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Ht).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),C.dispatchEvent(document,"morphSamePath",{custom:!0}),((Rt=e(this,m))==null?void 0:Rt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),et.changeHistory({action:((Tt=e(this,m))==null?void 0:Tt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash,state:{submorph:f}}),C.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,z,c),e(this,g).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:c,resolve:a,reject:k,submorph:f})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,z).pathname!==c.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).pathname)});return}const xt={url:c,submorph:f};C.dispatchEvent(document,"morphNavigation",{detail:xt});const pt=E(this,u,mt).call(this,e(this,m).pathname),p=E(this,u,mt).call(this,c.pathname);if(e(this,R).forEach(a=>{a.pathname!==c.pathname&&a.abort()}),yield p==null?void 0:p.fetch(lt,e(this,m).path,v),e(this,z).pathname!==c.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).path)});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,V)||(p.clearScrollState(),p.clearDocumentState()),S&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const Et=St(dt({},xt),{document:p.document});C.dispatchEvent(document,"morphStart",{detail:Et});const Nt=Array.from(document.head.children),qt=Array.from(p.document.head.children),Dt=E(this,u,jt).call(this,Nt,qt),Kt=E(this,u,At).call(this,Nt,Dt),ct=E(this,u,At).call(this,qt,Dt).filter(a=>!this.excludeHeadChild(a));ct.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ct[k]=E(this,u,bt).call(this,a))}),ct.forEach(a=>{document.head.appendChild(a)});const gt=ct.filter(a=>{if(a.hasAttribute("data-no-waiting"))return!1;if(E(this,u,kt).call(this,a))return!0});e(this,A).waitForHeadToLoad&>.length&&(yield new Promise(a=>B(this,null,function*(){let k=0;try{for(var T=Ft(gt),Gt,F,x;Gt=!(F=yield T.next()).done;Gt=!1){const ut=F.value;ut.onload=()=>{k++,k===gt.length&&a()}}}catch(F){x=[F]}finally{try{Gt&&(F=T.return)&&(yield F.call(T))}finally{if(x)throw x[0]}}}))),yield Bt.wait(10);const Ut=[];Kt.forEach(a=>{a.hasAttribute("data-permanent")||(E(this,u,kt).call(this,a)?Ut.push(a):a.remove())});const $t=E(this,u,Pt).call(this,p.document.body);!e(this,A).morphInsideScrollContainer&&!f&&E(this,u,Ct).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),et.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(b?location.search:""),hash:c.hash,state:{submorph:f}}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const vt=[];e(this,rt).forEach((a,k)=>{const T=$t[k],Gt=getComputedStyle(a).getPropertyValue("--morph-duration");let F=[],x=[];f?(f.forEach(d=>{const w=a.querySelector(d),N=T.querySelector(d);w&&N&&(x.push(w),F.push(N))}),x.forEach(d=>{d.parentElement&&vt.push(d.parentElement)})):(F.push(...T.childNodes),x.push(...a.childNodes),vt.push(a)),x.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var N;(N=x[w].parentElement)==null||N.insertBefore(d,x[w])}):a.prepend(...F),se.requestIdleCallback(()=>{x.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const ut=St(dt({},Et),{morphElement:a});C.dispatchEvent(document,"morphNewChildrenAdded",{detail:ut});const Jt=new Promise(d=>{setTimeout(()=>{x.forEach(w=>w.remove()),F.forEach(w=>{var N;w instanceof HTMLElement&&((N=w.parentElement)==null||N.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),C.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ut}),d()},(parseFloat(Gt)||0)*1e3+10)});e(this,I).push(Jt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),C.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Ht).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,V)?p.restoreScrollPosition():p.renewScrollPosition(),yield Promise.all(e(this,I)),Ut.forEach(a=>a.remove()),n(this,I,[]),vt.forEach(a=>{a.querySelectorAll("script").forEach(T=>{T.replaceWith(E(this,u,bt).call(this,T))})}),e(this,g).forEach(a=>{a.checkCurrent(e(this,m).path)}),C.dispatchEvent(document,"morphComplete",{detail:Et}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,z,void 0)})}addLink(t){e(this,g).push(new Lt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(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,ot));e(this,g).push(...s.map(i=>new Lt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,ot));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new Lt(s,this)))}};A=new WeakMap,rt=new WeakMap,g=new WeakMap,z=new WeakMap,m=new WeakMap,j=new WeakMap,I=new WeakMap,V=new WeakMap,y=new WeakMap,at=new WeakMap,R=new WeakMap,K=new WeakMap,Z=new WeakMap,_=new WeakMap,u=new WeakSet,bt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},ot=new WeakMap,mt=function(t){const s=this.normalizePath(t);let i=e(this,R).get(s.pathname);return i||(i=new Wt(this,s.pathname),e(this,R).set(s.pathname,i)),i},Pt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},jt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},At=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ct=function(t){var s,i;(s=e(this,y))==null||s.removeEventListener("scroll",e(this,tt)),n(this,_,0),n(this,Z,0),n(this,y,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,at,e(this,y)===window),(i=e(this,y))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Ht=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Bt.scrollToElement(i,{scrollElement:e(this,y),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ft=new WeakMap,tt=new WeakMap,st.instance=null;let yt=st;exports.Morph=yt;
|
|
1
|
+
"use strict";var Zt=Object.defineProperty,_t=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var It=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var Vt=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Ft=a=>{throw TypeError(a)};var Ot=(a,t,s)=>t in a?Zt(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,ft=(a,t)=>{for(var s in t||(t={}))ee.call(t,s)&&Ot(a,s,t[s]);if(It)for(var s of It(t))se.call(t,s)&&Ot(a,s,t[s]);return a},Lt=(a,t)=>_t(a,te(t));var wt=(a,t,s)=>t.has(a)||Ft("Cannot "+s);var e=(a,t,s)=>(wt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),n=(a,t,s,i)=>(wt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),E=(a,t,s)=>(wt(a,t,"access private method"),s);var B=(a,t,s)=>new Promise((i,h)=>{var v=L=>{try{f(s.next(L))}catch(O){h(O)}},A=L=>{try{f(s.throw(L))}catch(O){h(O)}},f=L=>L.done?i(L.value):Promise.resolve(L.value).then(v,A);f((s=s.apply(a,t)).next())});var Bt=(a,t,s)=>(t=a[Vt("asyncIterator")])?t.call(a):(a=a[Vt("iterator")](),t={},s=(i,h)=>(h=a[i])&&(t[i]=v=>new Promise((A,f,L)=>(v=h.call(a,v),L=v.done,Promise.resolve(v.value).then(O=>A({value:O,done:L}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yt=require("../index-DekP7OZe.cjs"),H=require("../events-KVanG9sR.cjs"),ie=require("../polyfills-Df4r-ETT.cjs"),Wt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),re=require("../css-value-parser/index.cjs");class jt 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)}}Yt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",jt);var M,l,q,rt,G;class yt{constructor(t,s){o(this,M);o(this,l);o(this,q);o(this,rt,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,M).previousURL)history.back();else{n(this,q,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),A=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=A?re.cssValueParser.parse(A):void 0,L=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),ht=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ct=>ct.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,M).navigate(e(this,q),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:L,keepSearchParameters:O,submorph:ht,clearState:c})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,M).prefetch(e(this,q),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,M,s),n(this,l,t),n(this,q,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,rt)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,M).normalizePath(t),i=e(this,M).normalizePath(e(this,q));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"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,rt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}M=new WeakMap,l=new WeakMap,q=new WeakMap,rt=new WeakMap,G=new WeakMap;const ne=new DOMParser;var R,W,y,k,X,D,J,Y,U,Q,nt;class Xt{constructor(t,s){o(this,R);o(this,W);o(this,y,{x:0,y:0});o(this,k,null);o(this,X,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,U,null);o(this,Q);o(this,nt);n(this,R,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,D)}setHeaders(t){n(this,nt,t)}setInitialDocument(t){n(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,U)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,k)&&e(this,R).isPopstateNavigation?e(this,U):(n(this,Q,t),n(this,U,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const A=yield(yield fetch(t,{signal:e(this,Y).signal,headers:ft({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,nt))})).text(),f=ne.parseFromString(A,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,U,null),h()}}))),e(this,U))})}cloneDocument(){n(this,D,(e(this,X)||e(this,k)).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,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,R).scrollValue.left,e(this,y).y=e(this,R).scrollValue.top)}restoreScrollPosition(){e(this,R).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,R).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}R=new WeakMap,W=new WeakMap,y=new WeakMap,k=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,U=new WeakMap,Q=new WeakMap,nt=new WeakMap;var C,Z,g,z,m,j,I,V,P,at,T,K,_,tt,ot,u,Pt,lt,pt,At,Kt,kt,Ct,Ht,Mt,Et,et;const it=class it{constructor(t){o(this,u);o(this,C,null);o(this,Z,null);o(this,g,[]);o(this,z);o(this,m,null);o(this,j);o(this,I,[]);o(this,V,!1);o(this,P,null);o(this,at,!1);o(this,T,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,ot,null);o(this,lt,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,Et,t=>B(this,null,function*(){t.preventDefault(),n(this,V,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:e(this,ot)||void 0}),n(this,V,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),h=t-e(this,_);n(this,tt,s),n(this,_,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",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),H.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Yt.isBrowser&&!it.instance){it.instance=this,n(this,C,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Z,E(this,u,At).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,m,s);const i=new Xt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,T).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,Et)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new jt),E(this,u,Ht).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,V)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,T).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,T).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,I).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,pt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate(O){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:A,submorph:f,clearState:L}={}){var ct,Rt,Tt,xt;if(e(this,I).length)return;n(this,ot,f||null);const ht=((ct=this.pathnameModifier)==null?void 0:ct.call(this,t))||t,c=this.normalizePath(ht);if(((Rt=e(this,z))==null?void 0:Rt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Mt).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),H.dispatchEvent(document,"morphSamePath",{custom:!0}),((Tt=e(this,m))==null?void 0:Tt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),st.changeHistory({action:((xt=e(this,m))==null?void 0:xt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),H.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,z,c),e(this,g).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var b;(b=this.preprocessor)==null||b.call(this,{url:c,resolve:r,reject:S,submorph:f})})}catch(r){r?console.error(r):console.log("Route change canceled"),$=!1}if(!$||e(this,z).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).pathname)});return}const Nt={url:c,submorph:f};f?f.forEach(r=>{document.querySelectorAll(r).forEach(S=>{S.classList.add("out"),S.setAttribute("data-morph-out","")})}):e(this,Z).forEach(r=>{var S,b;(S=r.firstElementChild)==null||S.classList.add("out"),(b=r.firstElementChild)==null||b.setAttribute("data-morph-out","")}),H.dispatchEvent(document,"morphNavigation",{detail:Nt});const gt=E(this,u,pt).call(this,e(this,m).pathname),p=E(this,u,pt).call(this,c.pathname);if(e(this,T).forEach(r=>{r.pathname!==c.pathname&&r.abort()}),yield p==null?void 0:p.fetch(ht,e(this,m).path,v),e(this,z).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)});return}gt.clearState(),gt.saveScrollState(),gt.saveDocumentState(),e(this,V)||(p.clearScrollState(),p.clearDocumentState()),L&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const ut=Lt(ft({},Nt),{document:p.document});ut.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),H.dispatchEvent(document,"morphStart",{detail:ut});const qt=Array.from(document.head.children),Dt=Array.from(p.document.head.children),Ut=E(this,u,Kt).call(this,qt,Dt),$t=E(this,u,kt).call(this,qt,Ut),dt=E(this,u,kt).call(this,Dt,Ut).filter(r=>!this.excludeHeadChild(r));dt.forEach((r,S)=>{r.tagName==="SCRIPT"&&(dt[S]=E(this,u,Pt).call(this,r))}),dt.forEach(r=>{document.head.appendChild(r)});const vt=dt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,u,Ct).call(this,r))return!0});e(this,C).waitForHeadToLoad&&vt.length&&(yield new Promise(r=>B(this,null,function*(){let S=0;try{for(var b=Bt(vt),Jt,F,x;Jt=!(F=yield b.next()).done;Jt=!1){const mt=F.value;mt.onload=()=>{S++,S===vt.length&&r()}}}catch(F){x=[F]}finally{try{Jt&&(F=b.return)&&(yield F.call(b))}finally{if(x)throw x[0]}}}))),yield Wt.wait(10);const zt=[];$t.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,u,Ct).call(this,r)?zt.push(r):r.remove())});const Gt=E(this,u,At).call(this,p.document.body);!e(this,C).morphInsideScrollContainer&&!f&&E(this,u,Ht).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),st.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(A?location.search:""),hash:c.hash}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const St=[];e(this,Z).forEach((r,S)=>{const b=Gt[S],Jt=getComputedStyle(r).getPropertyValue("--morph-duration");let F=[],x=[];f?(f.forEach(d=>{const w=r.querySelector(d),N=b.querySelector(d);w&&N&&(x.push(w),F.push(N))}),x.forEach(d=>{d.parentElement&&St.push(d.parentElement)})):(F.push(...b.childNodes),x.push(...r.childNodes),St.push(r)),x.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var N;(N=x[w].parentElement)==null||N.insertBefore(d,x[w])}):r.prepend(...F),ie.requestIdleCallback(()=>{x.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const mt=Lt(ft({},ut),{morphElement:r});H.dispatchEvent(document,"morphNewChildrenAdded",{detail:mt});const Qt=new Promise(d=>{setTimeout(()=>{x.forEach(w=>w.remove()),F.forEach(w=>{var N;w instanceof HTMLElement&&((N=w.parentElement)==null||N.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),H.dispatchEvent(document,"morphOldChildrenRemoved",{detail:mt}),d()},(parseFloat(Jt)||0)*1e3+10)});e(this,I).push(Qt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),H.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Mt).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,V)?p.restoreScrollPosition():p.renewScrollPosition(),yield Promise.all(e(this,I)),zt.forEach(r=>r.remove()),n(this,I,[]),St.forEach(r=>{r.querySelectorAll("script").forEach(b=>{b.replaceWith(E(this,u,Pt).call(this,b))})}),e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)}),H.dispatchEvent(document,"morphComplete",{detail:ut}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,z,void 0)})}addLink(t){e(this,g).push(new yt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(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,lt));e(this,g).push(...s.map(i=>new yt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,lt));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new yt(s,this)))}};C=new WeakMap,Z=new WeakMap,g=new WeakMap,z=new WeakMap,m=new WeakMap,j=new WeakMap,I=new WeakMap,V=new WeakMap,P=new WeakMap,at=new WeakMap,T=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,ot=new WeakMap,u=new WeakSet,Pt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},lt=new WeakMap,pt=function(t){const s=this.normalizePath(t);let i=e(this,T).get(s.pathname);return i||(i=new Xt(this,s.pathname),e(this,T).set(s.pathname,i)),i},At=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Kt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},Ct=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ht=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,et)),n(this,tt,0),n(this,_,0),n(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),n(this,at,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},Mt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Wt.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Et=new WeakMap,et=new WeakMap,it.instance=null;let bt=it;exports.Morph=bt;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Qt = Object.defineProperty, Zt = Object.defineProperties;
|
|
2
|
+
var _t = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var zt = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var It = (
|
|
6
|
-
throw TypeError(
|
|
4
|
+
var te = Object.prototype.hasOwnProperty, ee = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var It = (a, t) => (t = Symbol[a]) ? t : Symbol.for("Symbol." + a), Ot = (a) => {
|
|
6
|
+
throw TypeError(a);
|
|
7
7
|
};
|
|
8
|
-
var Vt = (
|
|
8
|
+
var Vt = (a, t, s) => t in a ? Qt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s, mt = (a, t) => {
|
|
9
9
|
for (var s in t || (t = {}))
|
|
10
|
-
|
|
10
|
+
te.call(t, s) && Vt(a, s, t[s]);
|
|
11
11
|
if (zt)
|
|
12
12
|
for (var s of zt(t))
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
var wt = (
|
|
17
|
-
var e = (
|
|
18
|
-
var W = (
|
|
13
|
+
ee.call(t, s) && Vt(a, s, t[s]);
|
|
14
|
+
return a;
|
|
15
|
+
}, Lt = (a, t) => Zt(a, _t(t));
|
|
16
|
+
var wt = (a, t, s) => t.has(a) || Ot("Cannot " + s);
|
|
17
|
+
var e = (a, t, s) => (wt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), o = (a, t, s) => t.has(a) ? Ot("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, s), n = (a, t, s, i) => (wt(a, t, "write to private field"), i ? i.call(a, s) : t.set(a, s), s), E = (a, t, s) => (wt(a, t, "access private method"), s);
|
|
18
|
+
var W = (a, t, s) => new Promise((i, h) => {
|
|
19
19
|
var S = (w) => {
|
|
20
20
|
try {
|
|
21
21
|
f(s.next(w));
|
|
22
22
|
} catch (O) {
|
|
23
23
|
h(O);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
25
|
+
}, P = (w) => {
|
|
26
26
|
try {
|
|
27
27
|
f(s.throw(w));
|
|
28
28
|
} catch (O) {
|
|
29
29
|
h(O);
|
|
30
30
|
}
|
|
31
|
-
}, f = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(S,
|
|
32
|
-
f((s = s.apply(
|
|
31
|
+
}, f = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(S, P);
|
|
32
|
+
f((s = s.apply(a, t)).next());
|
|
33
33
|
});
|
|
34
|
-
var
|
|
35
|
-
import { i as
|
|
36
|
-
import { d as
|
|
37
|
-
import { r as
|
|
38
|
-
import { w as
|
|
34
|
+
var Ft = (a, t, s) => (t = a[It("asyncIterator")]) ? t.call(a) : (a = a[It("iterator")](), t = {}, s = (i, h) => (h = a[i]) && (t[i] = (S) => new Promise((P, f, w) => (S = h.call(a, S), w = S.done, Promise.resolve(S.value).then((O) => P({ value: O, done: w }), f)))), s("next"), s("return"), t);
|
|
35
|
+
import { i as Bt } from "../index-Bv9zgfdb.js";
|
|
36
|
+
import { d as H } from "../events-CsVF98U6.js";
|
|
37
|
+
import { r as se } from "../polyfills-DJrTJQky.js";
|
|
38
|
+
import { w as ie, s as re } from "../scroll-DPkCFTxg.js";
|
|
39
39
|
import "construct-style-sheets-polyfill";
|
|
40
|
-
import { n as ne, c as
|
|
41
|
-
import { cssValueParser as
|
|
42
|
-
class
|
|
40
|
+
import { n as ne, c as vt, s as ae } from "../url-UL9zSCHb.js";
|
|
41
|
+
import { cssValueParser as oe } from "../css-value-parser/index.js";
|
|
42
|
+
class Yt extends HTMLElement {
|
|
43
43
|
connectedCallback() {
|
|
44
44
|
const t = {
|
|
45
45
|
"aria-live": "assertive",
|
|
@@ -50,87 +50,87 @@ class Bt extends HTMLElement {
|
|
|
50
50
|
this.setAttribute(s, i);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
class
|
|
53
|
+
Bt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Yt);
|
|
54
|
+
var R, l, D, it, G;
|
|
55
|
+
class yt {
|
|
56
56
|
constructor(t, s) {
|
|
57
|
-
o(this,
|
|
57
|
+
o(this, R);
|
|
58
58
|
o(this, l);
|
|
59
59
|
o(this, D);
|
|
60
|
-
o(this,
|
|
60
|
+
o(this, it, (t) => {
|
|
61
61
|
var i;
|
|
62
62
|
if (t.preventDefault(), document.documentElement.classList.contains("click-disabled"))
|
|
63
63
|
return;
|
|
64
|
-
if (e(this, l).hasAttribute("data-back") && e(this,
|
|
64
|
+
if (e(this, l).hasAttribute("data-back") && e(this, R).previousURL)
|
|
65
65
|
history.back();
|
|
66
66
|
else {
|
|
67
67
|
n(this, D, e(this, l).getAttribute("href") || "/");
|
|
68
68
|
const h = e(this, l).getAttribute(
|
|
69
69
|
"data-history-action"
|
|
70
|
-
) || "push", S = e(this, l).hasAttribute("data-center-scroll"),
|
|
70
|
+
) || "push", S = e(this, l).hasAttribute("data-center-scroll"), P = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), f = P ? oe.parse(P) : void 0, w = e(this, l).hasAttribute("data-revalidate"), O = e(this, l).hasAttribute(
|
|
71
71
|
"data-keep-search-parameters"
|
|
72
|
-
),
|
|
73
|
-
e(this,
|
|
72
|
+
), lt = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((ht) => ht.trim()), c = e(this, l).hasAttribute("data-clear-state");
|
|
73
|
+
e(this, R).navigate(e(this, D), {
|
|
74
74
|
historyAction: h,
|
|
75
75
|
centerScroll: S,
|
|
76
76
|
offsetScroll: f,
|
|
77
77
|
revalidate: w,
|
|
78
78
|
keepSearchParameters: O,
|
|
79
|
-
submorph:
|
|
79
|
+
submorph: lt,
|
|
80
80
|
clearState: c
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
o(this, G, () => {
|
|
85
85
|
const t = e(this, l).hasAttribute("data-revalidate");
|
|
86
|
-
e(this,
|
|
86
|
+
e(this, R).prefetch(e(this, D), t), e(this, l).removeEventListener("pointerenter", e(this, G));
|
|
87
87
|
});
|
|
88
|
-
n(this,
|
|
88
|
+
n(this, R, s), n(this, l, t), n(this, D, 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, G));
|
|
89
89
|
}
|
|
90
90
|
get element() {
|
|
91
91
|
return e(this, l);
|
|
92
92
|
}
|
|
93
93
|
checkCurrent(t) {
|
|
94
94
|
var h;
|
|
95
|
-
const s = e(this,
|
|
95
|
+
const s = e(this, R).normalizePath(t), i = e(this, R).normalizePath(e(this, D));
|
|
96
96
|
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") : (h = e(this, l).getAttribute("data-associated-paths")) != null && h.split(",").find((S) => s.pathname.includes(S)) ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
|
|
97
97
|
}
|
|
98
98
|
destroy() {
|
|
99
|
-
e(this, l).removeEventListener("click", e(this,
|
|
99
|
+
e(this, l).removeEventListener("click", e(this, it)), e(this, l).removeEventListener("pointerenter", e(this, G)), e(this, l).classList.remove("current");
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
var
|
|
105
|
-
class
|
|
102
|
+
R = new WeakMap(), l = new WeakMap(), D = new WeakMap(), it = new WeakMap(), G = new WeakMap();
|
|
103
|
+
const le = new DOMParser();
|
|
104
|
+
var M, X, y, k, B, U, J, Y, q, Q, rt;
|
|
105
|
+
class Wt {
|
|
106
106
|
constructor(t, s) {
|
|
107
|
-
o(this,
|
|
107
|
+
o(this, M);
|
|
108
108
|
o(this, X);
|
|
109
|
-
o(this,
|
|
110
|
-
o(this,
|
|
109
|
+
o(this, y, { x: 0, y: 0 });
|
|
110
|
+
o(this, k, null);
|
|
111
111
|
o(this, B, null);
|
|
112
112
|
o(this, U, null);
|
|
113
113
|
o(this, J, null);
|
|
114
114
|
o(this, Y, null);
|
|
115
|
-
o(this,
|
|
115
|
+
o(this, q, null);
|
|
116
116
|
o(this, Q);
|
|
117
|
-
o(this,
|
|
118
|
-
n(this,
|
|
117
|
+
o(this, rt);
|
|
118
|
+
n(this, M, t), n(this, X, s), n(this, Q, s);
|
|
119
119
|
}
|
|
120
120
|
get pathname() {
|
|
121
121
|
return e(this, X);
|
|
122
122
|
}
|
|
123
123
|
get scrollState() {
|
|
124
|
-
return e(this,
|
|
124
|
+
return e(this, y);
|
|
125
125
|
}
|
|
126
126
|
get document() {
|
|
127
127
|
return e(this, U);
|
|
128
128
|
}
|
|
129
129
|
setHeaders(t) {
|
|
130
|
-
n(this,
|
|
130
|
+
n(this, rt, t);
|
|
131
131
|
}
|
|
132
132
|
setInitialDocument(t) {
|
|
133
|
-
n(this,
|
|
133
|
+
n(this, k, t.cloneNode(!0));
|
|
134
134
|
}
|
|
135
135
|
abort() {
|
|
136
136
|
var t;
|
|
@@ -140,28 +140,28 @@ class Ft {
|
|
|
140
140
|
}
|
|
141
141
|
fetch(t, s, i) {
|
|
142
142
|
return W(this, null, function* () {
|
|
143
|
-
return e(this,
|
|
143
|
+
return e(this, q) || e(this, k) && e(this, k).documentElement.hasAttribute("data-cache") && (!i || e(this, Q) !== t) || e(this, k) && e(this, M).isPopstateNavigation ? e(this, q) : (n(this, Q, t), n(this, q, new Promise((h) => W(this, null, function* () {
|
|
144
144
|
try {
|
|
145
145
|
n(this, Y, new AbortController());
|
|
146
|
-
const
|
|
146
|
+
const P = yield (yield fetch(t, {
|
|
147
147
|
signal: e(this, Y).signal,
|
|
148
|
-
headers:
|
|
148
|
+
headers: mt({
|
|
149
149
|
"X-MORPH": "true",
|
|
150
150
|
"X-MORPH-CURRENT-PATH": s,
|
|
151
151
|
"X-MORPH-NEW-PATH": t
|
|
152
|
-
}, e(this,
|
|
153
|
-
})).text(), f =
|
|
152
|
+
}, e(this, rt))
|
|
153
|
+
})).text(), f = le.parseFromString(P, "text/html");
|
|
154
154
|
this.setInitialDocument(f);
|
|
155
155
|
} catch (S) {
|
|
156
156
|
console.warn(S);
|
|
157
157
|
} finally {
|
|
158
|
-
n(this, Y, null), n(this,
|
|
158
|
+
n(this, Y, null), n(this, q, null), h();
|
|
159
159
|
}
|
|
160
|
-
}))), e(this,
|
|
160
|
+
}))), e(this, q));
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
cloneDocument() {
|
|
164
|
-
n(this, U, (e(this, B) || e(this,
|
|
164
|
+
n(this, U, (e(this, B) || e(this, k)).cloneNode(!0));
|
|
165
165
|
}
|
|
166
166
|
get title() {
|
|
167
167
|
let t = "";
|
|
@@ -174,30 +174,30 @@ class Ft {
|
|
|
174
174
|
return t;
|
|
175
175
|
}
|
|
176
176
|
clearScrollState() {
|
|
177
|
-
e(this,
|
|
177
|
+
e(this, y).x = 0, e(this, y).y = 0;
|
|
178
178
|
}
|
|
179
179
|
clearDocumentState() {
|
|
180
180
|
n(this, B, null);
|
|
181
181
|
}
|
|
182
182
|
saveScrollState() {
|
|
183
|
-
e(this,
|
|
183
|
+
e(this, k).documentElement.hasAttribute(
|
|
184
184
|
"data-no-scroll-restoration"
|
|
185
|
-
) ? (e(this,
|
|
185
|
+
) ? (e(this, y).x = 0, e(this, y).y = 0) : (e(this, y).x = e(this, M).scrollValue.left, e(this, y).y = e(this, M).scrollValue.top);
|
|
186
186
|
}
|
|
187
187
|
restoreScrollPosition() {
|
|
188
|
-
e(this,
|
|
189
|
-
top: e(this,
|
|
190
|
-
left: e(this,
|
|
188
|
+
e(this, M).scrollElement.scroll({
|
|
189
|
+
top: e(this, y).y,
|
|
190
|
+
left: e(this, y).x,
|
|
191
191
|
behavior: "instant"
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
saveDocumentState() {
|
|
195
|
-
e(this,
|
|
195
|
+
e(this, k).documentElement.hasAttribute(
|
|
196
196
|
"data-no-page-restoration"
|
|
197
197
|
) ? n(this, B, null) : n(this, B, document.cloneNode(!0));
|
|
198
198
|
}
|
|
199
199
|
renewScrollPosition() {
|
|
200
|
-
e(this,
|
|
200
|
+
e(this, M).scrollElement.scroll({
|
|
201
201
|
top: 0,
|
|
202
202
|
left: 0,
|
|
203
203
|
behavior: "instant"
|
|
@@ -211,38 +211,39 @@ class Ft {
|
|
|
211
211
|
return n(this, J, null), t;
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
var
|
|
216
|
-
const
|
|
214
|
+
M = new WeakMap(), X = new WeakMap(), y = new WeakMap(), k = new WeakMap(), B = new WeakMap(), U = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), q = new WeakMap(), Q = new WeakMap(), rt = new WeakMap();
|
|
215
|
+
var C, Z, g, z, m, j, I, V, A, nt, T, K, _, tt, at, u, bt, ot, ft, At, jt, Pt, kt, Ct, Ht, pt, et;
|
|
216
|
+
const st = class st {
|
|
217
217
|
constructor(t) {
|
|
218
218
|
o(this, u);
|
|
219
|
-
o(this,
|
|
220
|
-
o(this,
|
|
219
|
+
o(this, C, null);
|
|
220
|
+
o(this, Z, null);
|
|
221
221
|
o(this, g, []);
|
|
222
|
-
o(this,
|
|
222
|
+
o(this, z);
|
|
223
223
|
o(this, m, null);
|
|
224
224
|
o(this, j);
|
|
225
|
-
o(this,
|
|
226
|
-
o(this,
|
|
227
|
-
o(this,
|
|
228
|
-
o(this,
|
|
229
|
-
o(this,
|
|
225
|
+
o(this, I, []);
|
|
226
|
+
o(this, V, !1);
|
|
227
|
+
o(this, A, null);
|
|
228
|
+
o(this, nt, !1);
|
|
229
|
+
o(this, T, /* @__PURE__ */ new Map());
|
|
230
230
|
o(this, K, null);
|
|
231
|
-
o(this, Z, 0);
|
|
232
231
|
o(this, _, 0);
|
|
233
|
-
o(this,
|
|
232
|
+
o(this, tt, 0);
|
|
233
|
+
o(this, at, null);
|
|
234
|
+
o(this, ot, (t) => {
|
|
234
235
|
var s;
|
|
235
236
|
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";
|
|
236
237
|
});
|
|
237
|
-
o(this,
|
|
238
|
-
t.preventDefault(), n(this,
|
|
238
|
+
o(this, pt, (t) => W(this, null, function* () {
|
|
239
|
+
t.preventDefault(), n(this, V, !0), yield this.navigate(location.href.replace(location.origin, ""), {
|
|
239
240
|
historyAction: "none",
|
|
240
|
-
submorph:
|
|
241
|
-
}), n(this,
|
|
241
|
+
submorph: e(this, at) || void 0
|
|
242
|
+
}), n(this, V, !1);
|
|
242
243
|
}));
|
|
243
|
-
o(this,
|
|
244
|
-
const { left: t, top: s } = this.scrollValue, i = s - e(this,
|
|
245
|
-
n(this,
|
|
244
|
+
o(this, et, () => {
|
|
245
|
+
const { left: t, top: s } = this.scrollValue, i = s - e(this, tt), h = t - e(this, _);
|
|
246
|
+
n(this, tt, s), n(this, _, t), document.documentElement.classList.toggle("scroll-y", s > 0), document.documentElement.classList.toggle("scroll-x", t > 0), document.documentElement.classList.toggle(
|
|
246
247
|
"scroll-y-forward",
|
|
247
248
|
i > 0
|
|
248
249
|
), document.documentElement.classList.toggle(
|
|
@@ -254,38 +255,38 @@ const et = class et {
|
|
|
254
255
|
), document.documentElement.classList.toggle(
|
|
255
256
|
"scroll-x-backward",
|
|
256
257
|
h < 0
|
|
257
|
-
),
|
|
258
|
+
), H(document, "morphScroll", {
|
|
258
259
|
detail: {
|
|
259
260
|
left: t,
|
|
260
261
|
top: s
|
|
261
262
|
}
|
|
262
263
|
});
|
|
263
264
|
});
|
|
264
|
-
if (
|
|
265
|
-
|
|
265
|
+
if (Bt && !st.instance) {
|
|
266
|
+
st.instance = this, n(this, C, {
|
|
266
267
|
base: ne(t == null ? void 0 : t.base),
|
|
267
268
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
268
269
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
269
270
|
scrollSelector: t == null ? void 0 : t.scrollSelector,
|
|
270
271
|
morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
|
|
271
|
-
}), n(this,
|
|
272
|
+
}), n(this, Z, E(this, u, At).call(this, document.body));
|
|
272
273
|
const s = this.normalizePath(
|
|
273
274
|
location.pathname + location.hash + location.search
|
|
274
275
|
);
|
|
275
276
|
n(this, m, s);
|
|
276
|
-
const i = new
|
|
277
|
-
i.setInitialDocument(document), e(this,
|
|
277
|
+
const i = new Wt(this, e(this, m).pathname);
|
|
278
|
+
i.setInitialDocument(document), e(this, T).set(e(this, m).pathname, i), document.documentElement.setAttribute(
|
|
278
279
|
"data-current-pathname",
|
|
279
280
|
e(this, m).pathname
|
|
280
281
|
), document.documentElement.setAttribute(
|
|
281
282
|
"data-current-leaf",
|
|
282
283
|
s.leaf
|
|
283
|
-
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this,
|
|
284
|
+
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, pt)), vt({
|
|
284
285
|
action: "replace",
|
|
285
286
|
pathname: s.pathname,
|
|
286
287
|
searchParameters: s.parameters,
|
|
287
288
|
hash: s.hash
|
|
288
|
-
}), n(this, K, new
|
|
289
|
+
}), n(this, K, new Yt()), E(this, u, Ct).call(this, document);
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
292
|
get currentURL() {
|
|
@@ -298,36 +299,36 @@ const et = class et {
|
|
|
298
299
|
return e(this, g);
|
|
299
300
|
}
|
|
300
301
|
get scrollElement() {
|
|
301
|
-
return e(this,
|
|
302
|
+
return e(this, A);
|
|
302
303
|
}
|
|
303
304
|
get isPopstateNavigation() {
|
|
304
|
-
return e(this,
|
|
305
|
+
return e(this, V);
|
|
305
306
|
}
|
|
306
307
|
get scrollValue() {
|
|
307
308
|
let t = 0, s = 0;
|
|
308
|
-
return e(this,
|
|
309
|
+
return e(this, nt) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, A).scrollTop, s = e(this, A).scrollLeft), { top: t, left: s };
|
|
309
310
|
}
|
|
310
311
|
saveState(t) {
|
|
311
|
-
const s = e(this,
|
|
312
|
+
const s = e(this, T).get(e(this, m).path);
|
|
312
313
|
s && s.saveState(t);
|
|
313
314
|
}
|
|
314
315
|
getState() {
|
|
315
|
-
const t = e(this,
|
|
316
|
+
const t = e(this, T).get(e(this, m).path);
|
|
316
317
|
return t == null ? void 0 : t.clearState();
|
|
317
318
|
}
|
|
318
319
|
normalizePath(t) {
|
|
319
|
-
return
|
|
320
|
-
base: e(this,
|
|
321
|
-
trailingSlash: e(this,
|
|
320
|
+
return ae(t, {
|
|
321
|
+
base: e(this, C).base,
|
|
322
|
+
trailingSlash: e(this, C).trailingSlash
|
|
322
323
|
});
|
|
323
324
|
}
|
|
324
325
|
prefetch(t, s) {
|
|
325
326
|
return W(this, null, function* () {
|
|
326
327
|
var h;
|
|
327
|
-
if (e(this,
|
|
328
|
+
if (e(this, I).length)
|
|
328
329
|
return;
|
|
329
330
|
t = ((h = this.pathnameModifier) == null ? void 0 : h.call(this, t)) || t;
|
|
330
|
-
const i = E(this, u,
|
|
331
|
+
const i = E(this, u, ft).call(this, t);
|
|
331
332
|
i == null || i.fetch(t, e(this, m).path, s);
|
|
332
333
|
});
|
|
333
334
|
}
|
|
@@ -342,30 +343,28 @@ const et = class et {
|
|
|
342
343
|
centerScroll: i,
|
|
343
344
|
offsetScroll: h,
|
|
344
345
|
revalidate: S,
|
|
345
|
-
keepSearchParameters:
|
|
346
|
+
keepSearchParameters: P,
|
|
346
347
|
submorph: f,
|
|
347
348
|
clearState: w
|
|
348
349
|
} = {}) {
|
|
349
|
-
var
|
|
350
|
-
if (e(this,
|
|
350
|
+
var ht, Rt, Mt, Tt;
|
|
351
|
+
if (e(this, I).length)
|
|
351
352
|
return;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
n(this, at, f || null);
|
|
354
|
+
const lt = ((ht = this.pathnameModifier) == null ? void 0 : ht.call(this, t)) || t, c = this.normalizePath(lt);
|
|
355
|
+
if (((Rt = e(this, z)) == null ? void 0 : Rt.pathname) === c.pathname || e(this, m).pathname === c.pathname) {
|
|
356
|
+
E(this, u, Ht).call(this, c.hash || 0, {
|
|
355
357
|
centerScroll: i,
|
|
356
358
|
offsetScroll: h,
|
|
357
359
|
behavior: "smooth"
|
|
358
|
-
}),
|
|
360
|
+
}), H(document, "morphSamePath", {
|
|
359
361
|
custom: !0
|
|
360
|
-
}), ((
|
|
361
|
-
action: ((
|
|
362
|
+
}), ((Mt = e(this, m)) == null ? void 0 : Mt.parameters) !== c.parameters && (n(this, j, e(this, m)), n(this, m, c), vt({
|
|
363
|
+
action: ((Tt = e(this, m)) == null ? void 0 : Tt.hash) !== c.hash ? "replace" : s,
|
|
362
364
|
pathname: c.pathname,
|
|
363
365
|
searchParameters: c.parameters,
|
|
364
|
-
hash: c.hash
|
|
365
|
-
|
|
366
|
-
submorph: f
|
|
367
|
-
}
|
|
368
|
-
}), C(document, "morphURLParametersChange", {
|
|
366
|
+
hash: c.hash
|
|
367
|
+
}), H(document, "morphURLParametersChange", {
|
|
369
368
|
detail: {
|
|
370
369
|
newURL: e(this, m),
|
|
371
370
|
previousURL: e(this, j)
|
|
@@ -373,185 +372,191 @@ const et = class et {
|
|
|
373
372
|
}));
|
|
374
373
|
return;
|
|
375
374
|
}
|
|
376
|
-
n(this,
|
|
375
|
+
n(this, z, c), e(this, g).forEach(($) => {
|
|
377
376
|
$.checkCurrent(c.pathname);
|
|
378
377
|
});
|
|
379
378
|
try {
|
|
380
379
|
let $ = !0;
|
|
381
380
|
if (this.preprocessor)
|
|
382
381
|
try {
|
|
383
|
-
yield new Promise((
|
|
384
|
-
var
|
|
385
|
-
(
|
|
382
|
+
yield new Promise((r, L) => {
|
|
383
|
+
var b;
|
|
384
|
+
(b = this.preprocessor) == null || b.call(this, {
|
|
386
385
|
url: c,
|
|
387
|
-
resolve:
|
|
388
|
-
reject:
|
|
386
|
+
resolve: r,
|
|
387
|
+
reject: L,
|
|
389
388
|
submorph: f
|
|
390
389
|
});
|
|
391
390
|
});
|
|
392
|
-
} catch (
|
|
393
|
-
|
|
391
|
+
} catch (r) {
|
|
392
|
+
r ? console.error(r) : console.log("Route change canceled"), $ = !1;
|
|
394
393
|
}
|
|
395
|
-
if (!$ || e(this,
|
|
396
|
-
e(this, g).forEach((
|
|
397
|
-
|
|
394
|
+
if (!$ || e(this, z).pathname !== c.pathname) {
|
|
395
|
+
e(this, g).forEach((r) => {
|
|
396
|
+
r.checkCurrent(e(this, m).pathname);
|
|
398
397
|
});
|
|
399
398
|
return;
|
|
400
399
|
}
|
|
401
|
-
const
|
|
400
|
+
const xt = {
|
|
402
401
|
url: c,
|
|
403
402
|
submorph: f
|
|
404
403
|
};
|
|
405
|
-
|
|
406
|
-
|
|
404
|
+
f ? f.forEach((r) => {
|
|
405
|
+
document.querySelectorAll(r).forEach((L) => {
|
|
406
|
+
L.classList.add("out"), L.setAttribute("data-morph-out", "");
|
|
407
|
+
});
|
|
408
|
+
}) : e(this, Z).forEach((r) => {
|
|
409
|
+
var L, b;
|
|
410
|
+
(L = r.firstElementChild) == null || L.classList.add("out"), (b = r.firstElementChild) == null || b.setAttribute("data-morph-out", "");
|
|
411
|
+
}), H(document, "morphNavigation", {
|
|
412
|
+
detail: xt
|
|
407
413
|
});
|
|
408
|
-
const
|
|
409
|
-
if (e(this,
|
|
410
|
-
|
|
411
|
-
}), yield p == null ? void 0 : p.fetch(
|
|
412
|
-
e(this, g).forEach((
|
|
413
|
-
|
|
414
|
+
const Et = E(this, u, ft).call(this, e(this, m).pathname), p = E(this, u, ft).call(this, c.pathname);
|
|
415
|
+
if (e(this, T).forEach((r) => {
|
|
416
|
+
r.pathname !== c.pathname && r.abort();
|
|
417
|
+
}), yield p == null ? void 0 : p.fetch(lt, e(this, m).path, S), e(this, z).pathname !== c.pathname) {
|
|
418
|
+
e(this, g).forEach((r) => {
|
|
419
|
+
r.checkCurrent(e(this, m).path);
|
|
414
420
|
});
|
|
415
421
|
return;
|
|
416
422
|
}
|
|
417
|
-
|
|
418
|
-
const
|
|
423
|
+
Et.clearState(), Et.saveScrollState(), Et.saveDocumentState(), e(this, V) || (p.clearScrollState(), p.clearDocumentState()), w && p.clearState(), p.cloneDocument(), e(this, K).textContent = p.title, document.body.appendChild(e(this, K));
|
|
424
|
+
const ct = Lt(mt({}, xt), {
|
|
419
425
|
document: p.document
|
|
420
426
|
});
|
|
421
|
-
|
|
422
|
-
|
|
427
|
+
ct.document.querySelectorAll("[data-morph-out]").forEach((r) => {
|
|
428
|
+
r.classList.remove("out");
|
|
429
|
+
}), H(document, "morphStart", {
|
|
430
|
+
detail: ct
|
|
423
431
|
});
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}),
|
|
428
|
-
document.head.appendChild(
|
|
432
|
+
const Nt = Array.from(document.head.children), Dt = Array.from(p.document.head.children), Ut = E(this, u, jt).call(this, Nt, Dt), Kt = E(this, u, Pt).call(this, Nt, Ut), ut = E(this, u, Pt).call(this, Dt, Ut).filter((r) => !this.excludeHeadChild(r));
|
|
433
|
+
ut.forEach((r, L) => {
|
|
434
|
+
r.tagName === "SCRIPT" && (ut[L] = E(this, u, bt).call(this, r));
|
|
435
|
+
}), ut.forEach((r) => {
|
|
436
|
+
document.head.appendChild(r);
|
|
429
437
|
});
|
|
430
|
-
const
|
|
431
|
-
if (
|
|
438
|
+
const gt = ut.filter((r) => {
|
|
439
|
+
if (r.hasAttribute("data-no-waiting"))
|
|
432
440
|
return !1;
|
|
433
|
-
if (E(this, u,
|
|
441
|
+
if (E(this, u, kt).call(this, r))
|
|
434
442
|
return !0;
|
|
435
443
|
});
|
|
436
|
-
e(this,
|
|
437
|
-
let
|
|
444
|
+
e(this, C).waitForHeadToLoad && gt.length && (yield new Promise((r) => W(this, null, function* () {
|
|
445
|
+
let L = 0;
|
|
438
446
|
try {
|
|
439
|
-
for (var
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
447
|
+
for (var b = Ft(gt), Gt, F, x; Gt = !(F = yield b.next()).done; Gt = !1) {
|
|
448
|
+
const dt = F.value;
|
|
449
|
+
dt.onload = () => {
|
|
450
|
+
L++, L === gt.length && r();
|
|
443
451
|
};
|
|
444
452
|
}
|
|
445
453
|
} catch (F) {
|
|
446
454
|
x = [F];
|
|
447
455
|
} finally {
|
|
448
456
|
try {
|
|
449
|
-
|
|
457
|
+
Gt && (F = b.return) && (yield F.call(b));
|
|
450
458
|
} finally {
|
|
451
459
|
if (x)
|
|
452
460
|
throw x[0];
|
|
453
461
|
}
|
|
454
462
|
}
|
|
455
|
-
}))), yield
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
463
|
+
}))), yield ie(10);
|
|
464
|
+
const qt = [];
|
|
465
|
+
Kt.forEach((r) => {
|
|
466
|
+
r.hasAttribute("data-permanent") || (E(this, u, kt).call(this, r) ? qt.push(r) : r.remove());
|
|
459
467
|
});
|
|
460
|
-
const
|
|
461
|
-
!e(this,
|
|
468
|
+
const $t = E(this, u, At).call(this, p.document.body);
|
|
469
|
+
!e(this, C).morphInsideScrollContainer && !f && E(this, u, Ct).call(this, p.document), document.documentElement.setAttribute(
|
|
462
470
|
"data-current-pathname",
|
|
463
471
|
c.pathname
|
|
464
472
|
), document.documentElement.setAttribute(
|
|
465
473
|
"data-current-leaf",
|
|
466
474
|
c.leaf
|
|
467
|
-
),
|
|
475
|
+
), vt({
|
|
468
476
|
action: s,
|
|
469
477
|
pathname: c.pathname,
|
|
470
|
-
searchParameters: c.parameters || (
|
|
471
|
-
hash: c.hash
|
|
472
|
-
state: {
|
|
473
|
-
submorph: f
|
|
474
|
-
}
|
|
478
|
+
searchParameters: c.parameters || (P ? location.search : ""),
|
|
479
|
+
hash: c.hash
|
|
475
480
|
}), e(this, K).remove(), n(this, j, e(this, m)), n(this, m, c);
|
|
476
|
-
const
|
|
477
|
-
e(this,
|
|
478
|
-
const
|
|
481
|
+
const St = [];
|
|
482
|
+
e(this, Z).forEach((r, L) => {
|
|
483
|
+
const b = $t[L], Gt = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
479
484
|
let F = [], x = [];
|
|
480
485
|
f ? (f.forEach((d) => {
|
|
481
|
-
const
|
|
482
|
-
|
|
486
|
+
const v = r.querySelector(d), N = b.querySelector(d);
|
|
487
|
+
v && N && (x.push(v), F.push(N));
|
|
483
488
|
}), x.forEach((d) => {
|
|
484
|
-
d.parentElement &&
|
|
485
|
-
})) : (F.push(...
|
|
489
|
+
d.parentElement && St.push(d.parentElement);
|
|
490
|
+
})) : (F.push(...b.childNodes), x.push(...r.childNodes), St.push(r)), x.forEach((d) => {
|
|
486
491
|
d instanceof HTMLElement && (this.destroyOldLinks(d), d.classList.add("old"));
|
|
487
492
|
}), F.forEach((d) => {
|
|
488
493
|
d instanceof HTMLElement && (this.findNewLinks(d), d.classList.add("new"));
|
|
489
|
-
}), f ? F.forEach((d,
|
|
494
|
+
}), f ? F.forEach((d, v) => {
|
|
490
495
|
var N;
|
|
491
|
-
(N = x[
|
|
496
|
+
(N = x[v].parentElement) == null || N.insertBefore(
|
|
492
497
|
d,
|
|
493
|
-
x[
|
|
498
|
+
x[v]
|
|
494
499
|
);
|
|
495
|
-
}) :
|
|
500
|
+
}) : r.prepend(...F), se(() => {
|
|
496
501
|
x.forEach((d) => {
|
|
497
502
|
d instanceof HTMLElement && d.classList.add("old-idle");
|
|
498
503
|
}), F.forEach((d) => {
|
|
499
|
-
var
|
|
500
|
-
d instanceof HTMLElement && ((
|
|
504
|
+
var v;
|
|
505
|
+
d instanceof HTMLElement && ((v = d.parentElement) == null || v.style.setProperty(
|
|
501
506
|
"--new-content-height",
|
|
502
507
|
d.offsetHeight + "px"
|
|
503
508
|
), d.classList.add("new-idle"));
|
|
504
509
|
});
|
|
505
510
|
});
|
|
506
|
-
const
|
|
507
|
-
morphElement:
|
|
511
|
+
const dt = Lt(mt({}, ct), {
|
|
512
|
+
morphElement: r
|
|
508
513
|
});
|
|
509
|
-
|
|
510
|
-
detail:
|
|
514
|
+
H(document, "morphNewChildrenAdded", {
|
|
515
|
+
detail: dt
|
|
511
516
|
});
|
|
512
|
-
const
|
|
517
|
+
const Jt = new Promise((d) => {
|
|
513
518
|
setTimeout(() => {
|
|
514
|
-
x.forEach((
|
|
519
|
+
x.forEach((v) => v.remove()), F.forEach((v) => {
|
|
515
520
|
var N;
|
|
516
|
-
|
|
521
|
+
v instanceof HTMLElement && ((N = v.parentElement) == null || N.style.removeProperty(
|
|
517
522
|
"--new-content-height"
|
|
518
|
-
),
|
|
519
|
-
}),
|
|
520
|
-
detail:
|
|
523
|
+
), v.classList.remove("new-idle", "new"));
|
|
524
|
+
}), H(document, "morphOldChildrenRemoved", {
|
|
525
|
+
detail: dt
|
|
521
526
|
}), d();
|
|
522
|
-
}, (parseFloat(
|
|
527
|
+
}, (parseFloat(Gt) || 0) * 1e3 + 10);
|
|
523
528
|
});
|
|
524
|
-
e(this,
|
|
529
|
+
e(this, I).push(Jt);
|
|
525
530
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
526
531
|
"--new-document-scroll-position",
|
|
527
532
|
(this.scrollValue.top - p.scrollState.y) * 1 + "px"
|
|
528
533
|
) : document.documentElement.style.setProperty(
|
|
529
534
|
"--new-document-scroll-position",
|
|
530
535
|
this.scrollValue.top + "px"
|
|
531
|
-
),
|
|
536
|
+
), H(document, "morphBeforeNavigationScroll", {
|
|
532
537
|
detail: p.scrollState
|
|
533
|
-
}), c.hash ? (p.clearScrollState(), E(this, u,
|
|
538
|
+
}), c.hash ? (p.clearScrollState(), E(this, u, Ht).call(this, c.hash, {
|
|
534
539
|
centerScroll: i,
|
|
535
540
|
offsetScroll: h
|
|
536
|
-
})) : e(this,
|
|
537
|
-
|
|
538
|
-
|
|
541
|
+
})) : e(this, V) ? p.restoreScrollPosition() : p.renewScrollPosition(), yield Promise.all(e(this, I)), qt.forEach((r) => r.remove()), n(this, I, []), St.forEach((r) => {
|
|
542
|
+
r.querySelectorAll("script").forEach((b) => {
|
|
543
|
+
b.replaceWith(E(this, u, bt).call(this, b));
|
|
539
544
|
});
|
|
540
|
-
}), e(this, g).forEach((
|
|
541
|
-
|
|
542
|
-
}),
|
|
543
|
-
detail:
|
|
545
|
+
}), e(this, g).forEach((r) => {
|
|
546
|
+
r.checkCurrent(e(this, m).path);
|
|
547
|
+
}), H(document, "morphComplete", {
|
|
548
|
+
detail: ct
|
|
544
549
|
}), document.documentElement.style.removeProperty(
|
|
545
550
|
"--new-document-scroll-position"
|
|
546
551
|
), window.dispatchEvent(new Event("resize"));
|
|
547
552
|
} catch ($) {
|
|
548
553
|
console.error($);
|
|
549
554
|
}
|
|
550
|
-
n(this,
|
|
555
|
+
n(this, z, void 0);
|
|
551
556
|
});
|
|
552
557
|
}
|
|
553
558
|
addLink(t) {
|
|
554
|
-
e(this, g).push(new
|
|
559
|
+
e(this, g).push(new yt(t, this));
|
|
555
560
|
}
|
|
556
561
|
addLinks(t) {
|
|
557
562
|
t.forEach((s) => {
|
|
@@ -566,34 +571,34 @@ const et = class et {
|
|
|
566
571
|
}
|
|
567
572
|
findNewLinks(t) {
|
|
568
573
|
const s = [...t.querySelectorAll("a")].filter(
|
|
569
|
-
e(this,
|
|
574
|
+
e(this, ot)
|
|
570
575
|
);
|
|
571
576
|
e(this, g).push(
|
|
572
|
-
...s.map((i) => new
|
|
577
|
+
...s.map((i) => new yt(i, this))
|
|
573
578
|
);
|
|
574
579
|
}
|
|
575
580
|
findLinks() {
|
|
576
581
|
const t = [
|
|
577
582
|
...document.documentElement.querySelectorAll("a")
|
|
578
|
-
].filter(e(this,
|
|
579
|
-
e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new
|
|
583
|
+
].filter(e(this, ot));
|
|
584
|
+
e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new yt(s, this)));
|
|
580
585
|
}
|
|
581
586
|
};
|
|
582
|
-
|
|
587
|
+
C = new WeakMap(), Z = new WeakMap(), g = new WeakMap(), z = new WeakMap(), m = new WeakMap(), j = new WeakMap(), I = new WeakMap(), V = new WeakMap(), A = new WeakMap(), nt = new WeakMap(), T = new WeakMap(), K = new WeakMap(), _ = new WeakMap(), tt = new WeakMap(), at = new WeakMap(), u = new WeakSet(), bt = function(t) {
|
|
583
588
|
const s = document.createElement("script");
|
|
584
589
|
for (let i = 0; i < t.attributes.length; i++) {
|
|
585
590
|
const h = t.attributes[i];
|
|
586
591
|
s.setAttribute(h.name, h.value);
|
|
587
592
|
}
|
|
588
593
|
return t.hasAttribute("src") || (s.innerHTML = t.innerHTML), s;
|
|
589
|
-
},
|
|
594
|
+
}, ot = new WeakMap(), ft = function(t) {
|
|
590
595
|
const s = this.normalizePath(t);
|
|
591
|
-
let i = e(this,
|
|
592
|
-
return i || (i = new
|
|
593
|
-
},
|
|
596
|
+
let i = e(this, T).get(s.pathname);
|
|
597
|
+
return i || (i = new Wt(this, s.pathname), e(this, T).set(s.pathname, i)), i;
|
|
598
|
+
}, At = function(t) {
|
|
594
599
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
595
600
|
return s.length ? s : [t];
|
|
596
|
-
},
|
|
601
|
+
}, jt = function(t, s) {
|
|
597
602
|
return t.filter(
|
|
598
603
|
(i) => s.find(
|
|
599
604
|
(h) => h.outerHTML === i.outerHTML
|
|
@@ -605,24 +610,24 @@ A = new WeakMap(), nt = new WeakMap(), g = new WeakMap(), I = new WeakMap(), m =
|
|
|
605
610
|
(h) => h.outerHTML === i.outerHTML
|
|
606
611
|
)
|
|
607
612
|
);
|
|
608
|
-
}, At = function(t) {
|
|
609
|
-
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
610
613
|
}, kt = function(t) {
|
|
614
|
+
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
615
|
+
}, Ct = function(t) {
|
|
611
616
|
var s, i;
|
|
612
|
-
(s = e(this,
|
|
617
|
+
(s = e(this, A)) == null || s.removeEventListener(
|
|
613
618
|
"scroll",
|
|
614
|
-
e(this,
|
|
615
|
-
), n(this,
|
|
616
|
-
},
|
|
619
|
+
e(this, et)
|
|
620
|
+
), n(this, tt, 0), n(this, _, 0), n(this, A, e(this, C).scrollSelector && t.querySelector(e(this, C).scrollSelector) || window), n(this, nt, e(this, A) === window), (i = e(this, A)) == null || i.addEventListener("scroll", e(this, et)), e(this, et).call(this);
|
|
621
|
+
}, Ht = function(t, s) {
|
|
617
622
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
618
|
-
(typeof i == "number" || i) &&
|
|
619
|
-
scrollElement: e(this,
|
|
623
|
+
(typeof i == "number" || i) && re(i, {
|
|
624
|
+
scrollElement: e(this, A),
|
|
620
625
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
621
626
|
center: s == null ? void 0 : s.centerScroll,
|
|
622
627
|
offset: s == null ? void 0 : s.offsetScroll
|
|
623
628
|
});
|
|
624
|
-
},
|
|
625
|
-
let
|
|
629
|
+
}, pt = new WeakMap(), et = new WeakMap(), st.instance = null;
|
|
630
|
+
let Xt = st;
|
|
626
631
|
export {
|
|
627
|
-
|
|
632
|
+
Xt as Morph
|
|
628
633
|
};
|