aptechka 0.71.12 → 0.71.14
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 +35 -33
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Gt=Object.defineProperty,Jt=Object.defineProperties;var Qt=Object.getOwnPropertyDescriptors;var Dt=Object.getOwnPropertySymbols;var Zt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var Ut=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),It=r=>{throw TypeError(r)};var zt=(r,t,s)=>t in r?Gt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,dt=(r,t)=>{for(var s in t||(t={}))Zt.call(t,s)&&zt(r,s,t[s]);if(Dt)for(var s of Dt(t))_t.call(t,s)&&zt(r,s,t[s]);return r},vt=(r,t)=>Jt(r,Qt(t));var St=(r,t,s)=>t.has(r)||It("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)?It("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,u)=>{var E=S=>{try{g(s.next(S))}catch(V){u(V)}},b=S=>{try{g(s.throw(S))}catch(V){u(V)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(E,b);g((s=s.apply(r,t)).next())});var Vt=(r,t,s)=>(t=r[Ut("asyncIterator")])?t.call(r):(r=r[Ut("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=E=>new Promise((b,g,S)=>(E=u.call(r,E),S=E.done,Promise.resolve(E.value).then(V=>b({value:V,done:S}),g)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Bt=require("../index-DekP7OZe.cjs"),C=require("../events-KVanG9sR.cjs"),te=require("../polyfills-Df4r-ETT.cjs"),Ot=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),ee=require("../css-value-parser/index.cjs");class Wt 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)}}Bt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Wt);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(),e(this,l).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{n(this,N,e(this,l).getAttribute("href")||"/");const u=e(this,l).getAttribute("data-history-action")||"push",E=e(this,l).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),g=b?ee.cssValueParser.parse(b):void 0,S=e(this,l).hasAttribute("data-revalidate"),V=e(this,l).hasAttribute("data-keep-search-parameters"),h=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ht=>ht.trim()),lt=e(this,l).hasAttribute("data-clear-state");e(this,H).navigate(e(this,N),{historyAction:u,centerScroll:E,offsetScroll:g,revalidate:S,keepSearchParameters:V,submorph:h,clearState:lt})}});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 u;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"):(u=e(this,l).getAttribute("data-associated-paths"))!=null&&u.split(",").find(E=>E.includes(s.pathname))?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 se=new DOMParser;var M,W,y,P,X,q,J,Y,D,Q,rt;class Ft{constructor(t,s){o(this,M);o(this,W);o(this,y,{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,y)}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(u=>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(),g=se.parseFromString(b,"text/html");this.setInitialDocument(g)}catch(E){console.warn(E)}finally{n(this,Y,null),n(this,D,null),u()}}))),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,y).x=0,e(this,y).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(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)}restoreScrollPosition(){e(this,M).scrollElement.scroll({top:e(this,y).y,left:e(this,y).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,y=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,v,U,d,j,z,I,L,at,R,K,_,tt,c,Lt,ot,mt,bt,Xt,Pt,At,kt,Ct,ft,et;const it=class it{constructor(t){o(this,c);o(this,A,null);o(this,Z,null);o(this,v,[]);o(this,U);o(this,d,null);o(this,j);o(this,z,[]);o(this,I,!1);o(this,L,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),u=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",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),C.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Bt.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,c,bt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,d,s);const i=new Ft(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 Wt),p(this,c,kt).call(this,document)}}get currentURL(){return e(this,d)}get previousURL(){return e(this,j)}get links(){return e(this,v)}get scrollElement(){return e(this,L)}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,L).scrollTop,s=e(this,L).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*(){if(e(this,z).length)return;const i=p(this,c,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:u,revalidate:E,keepSearchParameters:b,submorph:g,clearState:S}={}){var lt,ht,Ht,Mt;if(e(this,z).length)return;const h=this.normalizePath(((lt=this.pathnameModifier)==null?void 0:lt.call(this,t))||t);if(((ht=e(this,U))==null?void 0:ht.pathname)===h.pathname||e(this,d).pathname===h.pathname){p(this,c,Ct).call(this,h.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"}),C.dispatchEvent(document,"morphSamePath",{custom:!0}),((Ht=e(this,d))==null?void 0:Ht.parameters)!==h.parameters&&(n(this,j,e(this,d)),n(this,d,h),st.changeHistory({action:((Mt=e(this,d))==null?void 0:Mt.hash)!==h.hash?"replace":s,pathname:h.pathname,searchParameters:h.parameters,hash:h.hash}),C.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,d),previousURL:e(this,j)}}));return}n(this,U,h),e(this,v).forEach($=>{$.checkCurrent(h.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:h,resolve:a,reject:k,submorph:g})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,U).pathname!==h.pathname){e(this,v).forEach(a=>{a.checkCurrent(e(this,d).pathname)});return}const Rt={url:h,submorph:g};C.dispatchEvent(document,"morphNavigation",{detail:Rt});const pt=p(this,c,mt).call(this,e(this,d).pathname),f=p(this,c,mt).call(this,h.pathname);if(e(this,R).forEach(a=>{a.pathname!==h.pathname&&a.abort()}),yield f==null?void 0:f.fetch(t,e(this,d).path,E),e(this,U).pathname!==h.pathname){e(this,v).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({},Rt),{document:f.document});C.dispatchEvent(document,"morphStart",{detail:Et});const Tt=Array.from(document.head.children),xt=Array.from(f.document.head.children),Nt=p(this,c,Xt).call(this,Tt,xt),Yt=p(this,c,Pt).call(this,Tt,Nt),ct=p(this,c,Pt).call(this,xt,Nt).filter(a=>!this.excludeHeadChild(a));ct.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ct[k]=p(this,c,Lt).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,c,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=Vt(gt),Kt,O,F;Kt=!(O=yield T.next()).done;Kt=!1){const ut=O.value;ut.onload=()=>{k++,k===gt.length&&a()}}}catch(O){F=[O]}finally{try{Kt&&(O=T.return)&&(yield O.call(T))}finally{if(F)throw F[0]}}}))),yield Ot.wait(10);const qt=[];Yt.forEach(a=>{a.hasAttribute("data-permanent")||(p(this,c,At).call(this,a)?qt.push(a):a.remove())});const jt=p(this,c,bt).call(this,f.document.body);e(this,A).morphInsideScrollContainer||p(this,c,kt).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",h.pathname),document.documentElement.setAttribute("data-current-leaf",h.leaf),st.changeHistory({action:s,pathname:h.pathname,searchParameters:h.parameters||(b?location.search:""),hash:h.hash}),e(this,K).remove(),n(this,j,e(this,d)),n(this,d,h),e(this,Z).forEach((a,k)=>{const T=jt[k],Kt=getComputedStyle(a).getPropertyValue("--morph-duration");let O=[],F=[];g?g.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"))}),g?O.forEach((m,w)=>{var x;(x=F[w].parentElement)==null||x.insertBefore(m,F[w])}):a.prepend(...O),te.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 $t=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(Kt)||0)*1e3+10)});e(this,z).push($t)}),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}),h.hash?(f.clearScrollState(),p(this,c,Ct).call(this,h.hash,{centerScroll:i,offsetScroll:u})):e(this,I)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,z)),qt.forEach(a=>a.remove()),n(this,z,[]),e(this,Z).forEach(a=>{a.querySelectorAll("script").forEach(T=>{T.replaceWith(p(this,c,Lt).call(this,T))})}),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,v).push(new wt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,v,e(this,v).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,v,e(this,v).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,ot));e(this,v).push(...s.map(i=>new wt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,ot));e(this,v).forEach(s=>s.destroy()),n(this,v,t.map(s=>new wt(s,this)))}};A=new WeakMap,Z=new WeakMap,v=new WeakMap,U=new WeakMap,d=new WeakMap,j=new WeakMap,z=new WeakMap,I=new WeakMap,L=new WeakMap,at=new WeakMap,R=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,c=new WeakSet,Lt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const u=t.attributes[i];s.setAttribute(u.name,u.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 Ft(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]},Xt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},Pt=function(t,s){return t.filter(i=>!s.find(u=>u.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,L))==null||s.removeEventListener("scroll",e(this,et)),n(this,tt,0),n(this,_,0),n(this,L,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,at,e(this,L)===window),(i=e(this,L))==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)&&Ot.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ft=new WeakMap,et=new WeakMap,it.instance=null;let yt=it;exports.Morph=yt;
|
|
1
|
+
"use strict";var Gt=Object.defineProperty,Jt=Object.defineProperties;var Qt=Object.getOwnPropertyDescriptors;var Dt=Object.getOwnPropertySymbols;var Zt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var Ut=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),It=r=>{throw TypeError(r)};var zt=(r,t,s)=>t in r?Gt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,dt=(r,t)=>{for(var s in t||(t={}))Zt.call(t,s)&&zt(r,s,t[s]);if(Dt)for(var s of Dt(t))_t.call(t,s)&&zt(r,s,t[s]);return r},vt=(r,t)=>Jt(r,Qt(t));var St=(r,t,s)=>t.has(r)||It("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)?It("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,u)=>{var g=S=>{try{v(s.next(S))}catch(V){u(V)}},b=S=>{try{v(s.throw(S))}catch(V){u(V)}},v=S=>S.done?i(S.value):Promise.resolve(S.value).then(g,b);v((s=s.apply(r,t)).next())});var Vt=(r,t,s)=>(t=r[Ut("asyncIterator")])?t.call(r):(r=r[Ut("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=g=>new Promise((b,v,S)=>(g=u.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 Bt=require("../index-DekP7OZe.cjs"),C=require("../events-KVanG9sR.cjs"),te=require("../polyfills-Df4r-ETT.cjs"),Ot=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),ee=require("../css-value-parser/index.cjs");class Wt 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)}}Bt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Wt);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(),e(this,l).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{n(this,N,e(this,l).getAttribute("href")||"/");const u=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?ee.cssValueParser.parse(b):void 0,S=e(this,l).hasAttribute("data-revalidate"),V=e(this,l).hasAttribute("data-keep-search-parameters"),h=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ht=>ht.trim()),lt=e(this,l).hasAttribute("data-clear-state");e(this,H).navigate(e(this,N),{historyAction:u,centerScroll:g,offsetScroll:v,revalidate:S,keepSearchParameters:V,submorph:h,clearState:lt})}});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 u;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"):(u=e(this,l).getAttribute("data-associated-paths"))!=null&&u.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 se=new DOMParser;var M,W,y,P,X,q,J,Y,D,Q,rt;class Ft{constructor(t,s){o(this,M);o(this,W);o(this,y,{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,y)}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(u=>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=se.parseFromString(b,"text/html");this.setInitialDocument(v)}catch(g){console.warn(g)}finally{n(this,Y,null),n(this,D,null),u()}}))),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,y).x=0,e(this,y).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(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)}restoreScrollPosition(){e(this,M).scrollElement.scroll({top:e(this,y).y,left:e(this,y).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,y=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,L,at,R,K,_,tt,c,Lt,ot,mt,bt,Xt,Pt,At,kt,Ct,ft,et;const it=class it{constructor(t){o(this,c);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,L,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),u=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",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),C.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Bt.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,c,bt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,d,s);const i=new Ft(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 Wt),p(this,c,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,L)}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,L).scrollTop,s=e(this,L).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*(){if(e(this,z).length)return;const i=p(this,c,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:u,revalidate:g,keepSearchParameters:b,submorph:v,clearState:S}={}){var lt,ht,Ht,Mt;if(e(this,z).length)return;const h=this.normalizePath(((lt=this.pathnameModifier)==null?void 0:lt.call(this,t))||t);if(((ht=e(this,U))==null?void 0:ht.pathname)===h.pathname||e(this,d).pathname===h.pathname){p(this,c,Ct).call(this,h.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"}),C.dispatchEvent(document,"morphSamePath",{custom:!0}),((Ht=e(this,d))==null?void 0:Ht.parameters)!==h.parameters&&(n(this,j,e(this,d)),n(this,d,h),st.changeHistory({action:((Mt=e(this,d))==null?void 0:Mt.hash)!==h.hash?"replace":s,pathname:h.pathname,searchParameters:h.parameters,hash:h.hash}),C.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,d),previousURL:e(this,j)}}));return}n(this,U,h),e(this,E).forEach($=>{$.checkCurrent(h.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:h,resolve:a,reject:k,submorph:v})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,U).pathname!==h.pathname){e(this,E).forEach(a=>{a.checkCurrent(e(this,d).pathname)});return}const Rt={url:h,submorph:v};C.dispatchEvent(document,"morphNavigation",{detail:Rt});const pt=p(this,c,mt).call(this,e(this,d).pathname),f=p(this,c,mt).call(this,h.pathname);if(e(this,R).forEach(a=>{a.pathname!==h.pathname&&a.abort()}),yield f==null?void 0:f.fetch(t,e(this,d).path,g),e(this,U).pathname!==h.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({},Rt),{document:f.document});C.dispatchEvent(document,"morphStart",{detail:Et});const Tt=Array.from(document.head.children),xt=Array.from(f.document.head.children),Nt=p(this,c,Xt).call(this,Tt,xt),Yt=p(this,c,Pt).call(this,Tt,Nt),ct=p(this,c,Pt).call(this,xt,Nt).filter(a=>!this.excludeHeadChild(a));ct.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ct[k]=p(this,c,Lt).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,c,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=Vt(gt),Kt,O,F;Kt=!(O=yield T.next()).done;Kt=!1){const ut=O.value;ut.onload=()=>{k++,k===gt.length&&a()}}}catch(O){F=[O]}finally{try{Kt&&(O=T.return)&&(yield O.call(T))}finally{if(F)throw F[0]}}}))),yield Ot.wait(10);const qt=[];Yt.forEach(a=>{a.hasAttribute("data-permanent")||(p(this,c,At).call(this,a)?qt.push(a):a.remove())});const jt=p(this,c,bt).call(this,f.document.body);e(this,A).morphInsideScrollContainer||p(this,c,kt).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",h.pathname),document.documentElement.setAttribute("data-current-leaf",h.leaf),st.changeHistory({action:s,pathname:h.pathname,searchParameters:h.parameters||(b?location.search:""),hash:h.hash}),e(this,K).remove(),n(this,j,e(this,d)),n(this,d,h),e(this,Z).forEach((a,k)=>{const T=jt[k],Kt=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),te.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 $t=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(Kt)||0)*1e3+10)});e(this,z).push($t)}),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}),h.hash?(f.clearScrollState(),p(this,c,Ct).call(this,h.hash,{centerScroll:i,offsetScroll:u})):e(this,I)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,z)),qt.forEach(a=>a.remove()),n(this,z,[]),e(this,Z).forEach(a=>{a.querySelectorAll("script").forEach(T=>{T.replaceWith(p(this,c,Lt).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,L=new WeakMap,at=new WeakMap,R=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,c=new WeakSet,Lt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const u=t.attributes[i];s.setAttribute(u.name,u.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 Ft(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]},Xt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},Pt=function(t,s){return t.filter(i=>!s.find(u=>u.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,L))==null||s.removeEventListener("scroll",e(this,et)),n(this,tt,0),n(this,_,0),n(this,L,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,at,e(this,L)===window),(i=e(this,L))==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)&&Ot.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ft=new WeakMap,et=new WeakMap,it.instance=null;let yt=it;exports.Morph=yt;
|
package/lib/morph/index.js
CHANGED
|
@@ -16,22 +16,22 @@ var zt = (n, t, s) => t in n ? $t(n, t, { enumerable: !0, configurable: !0, writ
|
|
|
16
16
|
var St = (n, t, s) => t.has(n) || It("Cannot " + s);
|
|
17
17
|
var e = (n, t, s) => (St(n, t, "read from private field"), s ? s.call(n) : t.get(n)), o = (n, t, s) => t.has(n) ? It("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), r = (n, t, s, i) => (St(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), p = (n, t, s) => (St(n, t, "access private method"), s);
|
|
18
18
|
var W = (n, t, s) => new Promise((i, u) => {
|
|
19
|
-
var
|
|
19
|
+
var g = (w) => {
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
S(s.next(w));
|
|
22
22
|
} catch (q) {
|
|
23
23
|
u(q);
|
|
24
24
|
}
|
|
25
25
|
}, b = (w) => {
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
S(s.throw(w));
|
|
28
28
|
} catch (q) {
|
|
29
29
|
u(q);
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
31
|
+
}, S = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(g, b);
|
|
32
|
+
S((s = s.apply(n, t)).next());
|
|
33
33
|
});
|
|
34
|
-
var Vt = (n, t, s) => (t = n[Ut("asyncIterator")]) ? t.call(n) : (n = n[Ut("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (
|
|
34
|
+
var Vt = (n, t, s) => (t = n[Ut("asyncIterator")]) ? t.call(n) : (n = n[Ut("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (g) => new Promise((b, S, w) => (g = u.call(n, g), w = g.done, Promise.resolve(g.value).then((q) => b({ value: q, done: w }), S)))), s("next"), s("return"), t);
|
|
35
35
|
import { i as Ft } from "../index-Bv9zgfdb.js";
|
|
36
36
|
import { d as C } from "../events-CsVF98U6.js";
|
|
37
37
|
import { r as _t } from "../polyfills-DJrTJQky.js";
|
|
@@ -65,13 +65,13 @@ class Lt {
|
|
|
65
65
|
r(this, N, e(this, l).getAttribute("href") || "/");
|
|
66
66
|
const u = e(this, l).getAttribute(
|
|
67
67
|
"data-history-action"
|
|
68
|
-
) || "push",
|
|
68
|
+
) || "push", g = e(this, l).hasAttribute("data-center-scroll"), b = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), S = b ? re.parse(b) : void 0, w = e(this, l).hasAttribute("data-revalidate"), q = e(this, l).hasAttribute(
|
|
69
69
|
"data-keep-search-parameters"
|
|
70
70
|
), h = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((lt) => lt.trim()), ot = e(this, l).hasAttribute("data-clear-state");
|
|
71
71
|
e(this, H).navigate(e(this, N), {
|
|
72
72
|
historyAction: u,
|
|
73
|
-
centerScroll:
|
|
74
|
-
offsetScroll:
|
|
73
|
+
centerScroll: g,
|
|
74
|
+
offsetScroll: S,
|
|
75
75
|
revalidate: w,
|
|
76
76
|
keepSearchParameters: q,
|
|
77
77
|
submorph: h,
|
|
@@ -91,7 +91,7 @@ class Lt {
|
|
|
91
91
|
checkCurrent(t) {
|
|
92
92
|
var u;
|
|
93
93
|
const s = e(this, H).normalizePath(t), i = e(this, H).normalizePath(e(this, N));
|
|
94
|
-
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") : (u = e(this, l).getAttribute("data-associated-paths")) != null && u.split(",").find((
|
|
94
|
+
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") : (u = e(this, l).getAttribute("data-associated-paths")) != null && u.split(",").find((g) => s.pathname.includes(g)) ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
|
|
95
95
|
}
|
|
96
96
|
destroy() {
|
|
97
97
|
e(this, l).removeEventListener("click", e(this, it)), e(this, l).removeEventListener("pointerenter", e(this, G)), e(this, l).classList.remove("current");
|
|
@@ -148,10 +148,10 @@ class qt {
|
|
|
148
148
|
"X-MORPH-CURRENT-PATH": s,
|
|
149
149
|
"X-MORPH-NEW-PATH": t
|
|
150
150
|
}, e(this, rt))
|
|
151
|
-
})).text(),
|
|
152
|
-
this.setInitialDocument(
|
|
153
|
-
} catch (
|
|
154
|
-
console.warn(
|
|
151
|
+
})).text(), S = ne.parseFromString(b, "text/html");
|
|
152
|
+
this.setInitialDocument(S);
|
|
153
|
+
} catch (g) {
|
|
154
|
+
console.warn(g);
|
|
155
155
|
} finally {
|
|
156
156
|
r(this, Y, null), r(this, U, null), u();
|
|
157
157
|
}
|
|
@@ -210,13 +210,13 @@ class qt {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
R = new WeakMap(), X = new WeakMap(), v = new WeakMap(), P = new WeakMap(), B = new WeakMap(), D = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), U = new WeakMap(), Q = new WeakMap(), rt = new WeakMap();
|
|
213
|
-
var A, Z,
|
|
213
|
+
var A, Z, E, z, d, j, I, V, y, nt, T, K, _, tt, c, vt, at, dt, yt, Xt, bt, Pt, At, kt, mt, et;
|
|
214
214
|
const st = class st {
|
|
215
215
|
constructor(t) {
|
|
216
216
|
o(this, c);
|
|
217
217
|
o(this, A, null);
|
|
218
218
|
o(this, Z, null);
|
|
219
|
-
o(this,
|
|
219
|
+
o(this, E, []);
|
|
220
220
|
o(this, z);
|
|
221
221
|
o(this, d, null);
|
|
222
222
|
o(this, j);
|
|
@@ -292,7 +292,7 @@ const st = class st {
|
|
|
292
292
|
return e(this, j);
|
|
293
293
|
}
|
|
294
294
|
get links() {
|
|
295
|
-
return e(this,
|
|
295
|
+
return e(this, E);
|
|
296
296
|
}
|
|
297
297
|
get scrollElement() {
|
|
298
298
|
return e(this, y);
|
|
@@ -336,9 +336,9 @@ const st = class st {
|
|
|
336
336
|
historyAction: s = "push",
|
|
337
337
|
centerScroll: i,
|
|
338
338
|
offsetScroll: u,
|
|
339
|
-
revalidate:
|
|
339
|
+
revalidate: g,
|
|
340
340
|
keepSearchParameters: b,
|
|
341
|
-
submorph:
|
|
341
|
+
submorph: S,
|
|
342
342
|
clearState: w
|
|
343
343
|
} = {}) {
|
|
344
344
|
var ot, lt, Ct, Ht;
|
|
@@ -367,7 +367,7 @@ const st = class st {
|
|
|
367
367
|
}));
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
|
-
r(this, z, h), e(this,
|
|
370
|
+
r(this, z, h), e(this, E).forEach(($) => {
|
|
371
371
|
$.checkCurrent(h.pathname);
|
|
372
372
|
});
|
|
373
373
|
try {
|
|
@@ -380,21 +380,21 @@ const st = class st {
|
|
|
380
380
|
url: h,
|
|
381
381
|
resolve: a,
|
|
382
382
|
reject: k,
|
|
383
|
-
submorph:
|
|
383
|
+
submorph: S
|
|
384
384
|
});
|
|
385
385
|
});
|
|
386
386
|
} catch (a) {
|
|
387
387
|
a ? console.error(a) : console.log("Route change canceled"), $ = !1;
|
|
388
388
|
}
|
|
389
389
|
if (!$ || e(this, z).pathname !== h.pathname) {
|
|
390
|
-
e(this,
|
|
390
|
+
e(this, E).forEach((a) => {
|
|
391
391
|
a.checkCurrent(e(this, d).pathname);
|
|
392
392
|
});
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
395
|
const Rt = {
|
|
396
396
|
url: h,
|
|
397
|
-
submorph:
|
|
397
|
+
submorph: S
|
|
398
398
|
};
|
|
399
399
|
C(document, "morphNavigation", {
|
|
400
400
|
detail: Rt
|
|
@@ -402,8 +402,8 @@ const st = class st {
|
|
|
402
402
|
const ft = p(this, c, dt).call(this, e(this, d).pathname), f = p(this, c, dt).call(this, h.pathname);
|
|
403
403
|
if (e(this, T).forEach((a) => {
|
|
404
404
|
a.pathname !== h.pathname && a.abort();
|
|
405
|
-
}), yield f == null ? void 0 : f.fetch(t, e(this, d).path,
|
|
406
|
-
e(this,
|
|
405
|
+
}), yield f == null ? void 0 : f.fetch(t, e(this, d).path, g), e(this, z).pathname !== h.pathname) {
|
|
406
|
+
e(this, E).forEach((a) => {
|
|
407
407
|
a.checkCurrent(e(this, d).path);
|
|
408
408
|
});
|
|
409
409
|
return;
|
|
@@ -466,14 +466,14 @@ const st = class st {
|
|
|
466
466
|
}), e(this, K).remove(), r(this, j, e(this, d)), r(this, d, h), e(this, Z).forEach((a, k) => {
|
|
467
467
|
const M = Yt[k], jt = getComputedStyle(a).getPropertyValue("--morph-duration");
|
|
468
468
|
let O = [], F = [];
|
|
469
|
-
|
|
469
|
+
S ? S.forEach((m) => {
|
|
470
470
|
const L = a.querySelector(m), x = M.querySelector(m);
|
|
471
471
|
L && x && (F.push(L), O.push(x));
|
|
472
472
|
}) : (O.push(...M.childNodes), F.push(...a.childNodes)), F.forEach((m) => {
|
|
473
473
|
m instanceof HTMLElement && (this.destroyOldLinks(m), m.classList.add("old"));
|
|
474
474
|
}), O.forEach((m) => {
|
|
475
475
|
m instanceof HTMLElement && (this.findNewLinks(m), m.classList.add("new"));
|
|
476
|
-
}),
|
|
476
|
+
}), S ? O.forEach((m, L) => {
|
|
477
477
|
var x;
|
|
478
478
|
(x = F[L].parentElement) == null || x.insertBefore(
|
|
479
479
|
m,
|
|
@@ -524,6 +524,8 @@ const st = class st {
|
|
|
524
524
|
a.querySelectorAll("script").forEach((M) => {
|
|
525
525
|
M.replaceWith(p(this, c, vt).call(this, M));
|
|
526
526
|
});
|
|
527
|
+
}), e(this, E).forEach((a) => {
|
|
528
|
+
a.checkCurrent(e(this, d).path);
|
|
527
529
|
}), C(document, "morphComplete", {
|
|
528
530
|
detail: pt
|
|
529
531
|
}), document.documentElement.style.removeProperty(
|
|
@@ -536,7 +538,7 @@ const st = class st {
|
|
|
536
538
|
});
|
|
537
539
|
}
|
|
538
540
|
addLink(t) {
|
|
539
|
-
e(this,
|
|
541
|
+
e(this, E).push(new Lt(t, this));
|
|
540
542
|
}
|
|
541
543
|
addLinks(t) {
|
|
542
544
|
t.forEach((s) => {
|
|
@@ -544,16 +546,16 @@ const st = class st {
|
|
|
544
546
|
});
|
|
545
547
|
}
|
|
546
548
|
removeLink(t) {
|
|
547
|
-
r(this,
|
|
549
|
+
r(this, E, e(this, E).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
548
550
|
}
|
|
549
551
|
destroyOldLinks(t) {
|
|
550
|
-
r(this,
|
|
552
|
+
r(this, E, e(this, E).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
|
|
551
553
|
}
|
|
552
554
|
findNewLinks(t) {
|
|
553
555
|
const s = [...t.querySelectorAll("a")].filter(
|
|
554
556
|
e(this, at)
|
|
555
557
|
);
|
|
556
|
-
e(this,
|
|
558
|
+
e(this, E).push(
|
|
557
559
|
...s.map((i) => new Lt(i, this))
|
|
558
560
|
);
|
|
559
561
|
}
|
|
@@ -561,10 +563,10 @@ const st = class st {
|
|
|
561
563
|
const t = [
|
|
562
564
|
...document.documentElement.querySelectorAll("a")
|
|
563
565
|
].filter(e(this, at));
|
|
564
|
-
e(this,
|
|
566
|
+
e(this, E).forEach((s) => s.destroy()), r(this, E, t.map((s) => new Lt(s, this)));
|
|
565
567
|
}
|
|
566
568
|
};
|
|
567
|
-
A = new WeakMap(), Z = new WeakMap(),
|
|
569
|
+
A = new WeakMap(), Z = new WeakMap(), E = new WeakMap(), z = new WeakMap(), d = new WeakMap(), j = new WeakMap(), I = new WeakMap(), V = new WeakMap(), y = new WeakMap(), nt = new WeakMap(), T = new WeakMap(), K = new WeakMap(), _ = new WeakMap(), tt = new WeakMap(), c = new WeakSet(), vt = function(t) {
|
|
568
570
|
const s = document.createElement("script");
|
|
569
571
|
for (let i = 0; i < t.attributes.length; i++) {
|
|
570
572
|
const u = t.attributes[i];
|