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