aptechka 0.54.1 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +155 -152
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var vt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Lt=r=>{throw TypeError(r)};var et=(r,t,s)=>t.has(r)||Lt("Cannot "+s);var e=(r,t,s)=>(et(r,t,"read from private field"),s?s.call(r):t.get(r)),o=(r,t,s)=>t.has(r)?Lt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),a=(r,t,s,i)=>(et(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),d=(r,t,s)=>(et(r,t,"access private method"),s);var H=(r,t,s)=>new Promise((i,u)=>{var f=p=>{try{T(s.next(p))}catch(h){u(h)}},M=p=>{try{T(s.throw(p))}catch(h){u(h)}},T=p=>p.done?i(p.value):Promise.resolve(p.value).then(f,M);T((s=s.apply(r,t)).next())});var St=(r,t,s)=>(t=r[vt("asyncIterator")])?t.call(r):(r=r[vt("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=f=>new Promise((M,T,p)=>(f=u.call(r,f),p=f.done,Promise.resolve(f.value).then(h=>M({value:h,done:p}),T)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Pt=require("../index-Cqw2NKev.cjs"),_=require("../events-KVanG9sR.cjs"),Nt=require("../polyfills-Df4r-ETT.cjs"),yt=require("../scroll-DAhSpkhR.cjs"),X=require("../url-D1CgmwZ_.cjs"),Dt=require("../css-value-parser/index.cjs");class At 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)}}Pt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",At);var P,c,x,j,I;class wt{constructor(t,s){o(this,P);o(this,c);o(this,x);o(this,j,t=>{t.preventDefault();const s=e(this,c).getAttribute("data-history-action")||"push",i=e(this,c).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,c)).getPropertyValue("--offset-scroll").trim(),f=u?Dt.cssValueParser.parse(u):void 0,M=e(this,c).hasAttribute("data-revalidate"),T=e(this,c).hasAttribute("data-keep-search-parameters");e(this,P).navigate(e(this,x),{historyAction:s,centerScroll:i,offsetScroll:f,revalidate:M,keepSearchParameters:T})});o(this,I,()=>{e(this,P).prefetch(e(this,x)),e(this,c).removeEventListener("pointerenter",e(this,I))});a(this,P,s),a(this,c,t),a(this,x,e(this,c).getAttribute("href")||"/"),e(this,c).addEventListener("click",e(this,j)),this.checkCurrent(location.pathname),e(this,c).hasAttribute("data-prefetch")&&e(this,c).addEventListener("pointerenter",e(this,I))}get element(){return e(this,c)}checkCurrent(t){const s=e(this,P).normalizePath(t),i=e(this,P).normalizePath(e(this,x));e(this,c).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,c).classList.add("current"):i.pathname===s.pathname?e(this,c).classList.add("current"):e(this,c).classList.remove("current")}destroy(){e(this,c).removeEventListener("click",e(this,j)),e(this,c).removeEventListener("pointerenter",e(this,I)),e(this,c).classList.remove("current")}}P=new WeakMap,c=new WeakMap,x=new WeakMap,j=new WeakMap,I=new WeakMap;var N,V,E,D,R,A;class bt{constructor(t,s,i){o(this,N);o(this,V);o(this,E,{x:0,y:0});o(this,D);o(this,R,null);o(this,A,null);a(this,N,t),a(this,V,s),a(this,D,i.cloneNode(!0))}get pathname(){return e(this,V)}get scrollState(){return e(this,E)}get document(){return e(this,A)}cloneDocument(){a(this,A,(e(this,R)||e(this,D)).cloneNode(!0))}get title(){let t="";if(e(this,A).title)t=e(this,A).title;else{const s=e(this,A).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,V)}return t}clearScrollState(){e(this,E).x=0,e(this,E).y=0}clearDocumentState(){a(this,R,null)}saveScrollState(){e(this,D).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,E).x=0,e(this,E).y=0):(e(this,E).x=e(this,N).scrollElement.scrollLeft,e(this,E).y=e(this,N).scrollElement.scrollTop)}saveDocumentState(){e(this,D).documentElement.hasAttribute("data-no-page-restoration")?a(this,R,null):a(this,R,document.cloneNode(!0))}restoreScrollPosition(){e(this,N).scrollElement.scroll({top:e(this,E).y,left:e(this,E).x})}}N=new WeakMap,V=new WeakMap,E=new WeakMap,D=new WeakMap,R=new WeakMap,A=new WeakMap;var k,U,g,Z,C,m,K,q,y,L,B,z,l,st,it,rt,kt,nt,ot,at,lt,$,O;class Rt{constructor(t){o(this,l);o(this,k,null);o(this,U,null);o(this,g,[]);o(this,Z,new DOMParser);o(this,C);o(this,m,null);o(this,K);o(this,q,[]);o(this,y,!1);o(this,L,null);o(this,B,new Map);o(this,z,null);o(this,$,t=>H(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,y,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,y,!1))}));o(this,O,()=>{const t=e(this,L).scrollTop,s=e(this,L).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),_.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Pt.isBrowser){a(this,k,{base:X.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body"}),a(this,U,d(this,l,rt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,m,s.pathname),e(this,B).set(e(this,m),new bt(this,e(this,m),document)),document.documentElement.setAttribute("data-current-pathname",e(this,m)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,$)),X.changeHistory({action:"replace",pathname:e(this,m),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,z,new At),d(this,l,at).call(this,document)}}get currentPathname(){return e(this,m)}get previousPathname(){return e(this,K)}get links(){return e(this,g)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,y)}normalizePath(t){return X.splitPath(t,{base:e(this,k).base,trailingSlash:e(this,k).trailingSlash})}prefetch(t){return H(this,null,function*(){const s=this.normalizePath(t);d(this,l,it).call(this,s.pathname)})}navigate(T){return H(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:f,keepSearchParameters:M}={}){var ct;if(e(this,q).length)return;const p=this.normalizePath(((ct=this.pathnameModifier)==null?void 0:ct.call(this,t))||t);let{pathname:h,hash:Y,parameters:Ct,leaf:Mt}=p;if(e(this,C)===h||e(this,m)===h){e(this,y)||d(this,l,lt).call(this,Y||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,C,h),e(this,g).forEach(F=>{F.checkCurrent(h)});try{let F=!0;if(this.preprocessor)try{yield new Promise((n,w)=>{var b;(b=this.preprocessor)==null||b.call(this,{pathname:h,resolve:n,reject:w})})}catch(n){n?console.error(n):console.log("Route change canceled"),F=!1}if(!F||e(this,C)!==h){e(this,g).forEach(n=>{n.checkCurrent(e(this,m))});return}const ht=yield d(this,l,st).call(this,e(this,m)),S=yield d(this,l,st).call(this,h,f);if(e(this,C)!==h){e(this,g).forEach(n=>{n.checkCurrent(e(this,m))});return}ht.saveScrollState(),ht.saveDocumentState(),e(this,y)||(S.clearScrollState(),S.clearDocumentState()),S.cloneDocument(),e(this,z).textContent=S.title,document.body.appendChild(e(this,z));const ut={pathname:h};_.dispatchEvent(document,"morphStart",{detail:ut});const dt=Array.from(document.head.children),mt=Array.from(S.document.head.children),ft=d(this,l,kt).call(this,dt,mt),Tt=d(this,l,nt).call(this,dt,ft),G=d(this,l,nt).call(this,mt,ft);G.forEach((n,w)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const b=document.createElement("script");b.type="module",b.src=n.getAttribute("src"),G[w]=b}}),G.forEach(n=>{document.head.appendChild(n)});const tt=G.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(d(this,l,ot).call(this,n))return!0});e(this,k).waitForHeadToLoad&&tt.length&&(yield new Promise(n=>H(this,null,function*(){let w=0;try{for(var b=St(tt),Et,W,gt;Et=!(W=yield b.next()).done;Et=!1){const J=W.value;J.onload=()=>{w++,w===tt.length&&n()}}}catch(W){gt=[W]}finally{try{Et&&(W=b.return)&&(yield W.call(b))}finally{if(gt)throw gt[0]}}}))),yield yt.wait(10);const pt=[];Tt.forEach(n=>{n.hasAttribute("data-permanent")||(d(this,l,ot).call(this,n)?pt.push(n):n.remove())});const Ht=d(this,l,rt).call(this,S.document.body);d(this,l,at).call(this,S.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Mt),X.changeHistory({action:s,pathname:h,searchParameters:Ct||(M?location.search:""),hash:Y}),e(this,z).remove(),a(this,K,e(this,m)),a(this,m,h),e(this,U).forEach((n,w)=>{const b=Ht[w],Et=getComputedStyle(n).getPropertyValue("--morph-duration"),W=[...b.childNodes];if(Et){const gt=[...n.childNodes];gt.forEach(v=>{v instanceof HTMLElement&&v.classList.add("old")}),W.forEach(v=>{v instanceof HTMLElement&&v.classList.add("new")}),n.prepend(...W),Nt.requestIdleCallback(()=>{W.forEach(v=>{v instanceof HTMLElement&&v.classList.add("in")})});const J={morphElement:n,pathname:h};_.dispatchEvent(document,"morphNewChildrenAdded",{detail:J});const xt=new Promise(v=>{setTimeout(()=>{gt.forEach(Q=>Q.remove()),W.forEach(Q=>{Q instanceof HTMLElement&&Q.classList.remove("in","new")}),_.dispatchEvent(document,"morphOldChildrenRemoved",{detail:J}),v()},(parseFloat(Et)||0)*1e3+10)});e(this,q).push(xt)}else n.innerHTML="",n.append(...W)}),Y?(S.clearScrollState(),d(this,l,lt).call(this,Y,{centerScroll:i,offsetScroll:u})):e(this,y)&&S.restoreScrollPosition(),yield Promise.all(e(this,q)),pt.forEach(n=>n.remove()),a(this,q,[]),this.findLinks(),_.dispatchEvent(document,"morphComplete",{detail:ut}),window.dispatchEvent(new Event("resize"))}catch(F){console.error(F)}a(this,C,void 0)})}addLink(t){e(this,g).push(new wt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")&&s.getAttribute("target")!=="_blank"});e(this,g).forEach(s=>s.destroy()),a(this,g,t.map(s=>new wt(s,this)))}}k=new WeakMap,U=new WeakMap,g=new WeakMap,Z=new WeakMap,C=new WeakMap,m=new WeakMap,K=new WeakMap,q=new WeakMap,y=new WeakMap,L=new WeakMap,B=new WeakMap,z=new WeakMap,l=new WeakSet,st=function(t,s=!1){return H(this,null,function*(){let i=e(this,B).get(t);return(!i||s)&&(i=yield d(this,l,it).call(this,t)),i})},it=function(t){return H(this,null,function*(){const i=yield(yield fetch(t)).text(),u=e(this,Z).parseFromString(i,"text/html"),f=new bt(this,t,u);return e(this,B).set(t,f),f})},rt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},kt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},nt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ot=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},at=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,O)),a(this,L,t.querySelector(e(this,k).scrollSelector)||t.documentElement),(i=e(this,L))==null||i.addEventListener("scroll",e(this,O)),e(this,O).call(this)},lt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&yt.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})},$=new WeakMap,O=new WeakMap;exports.Morph=Rt;
|
|
1
|
+
"use strict";var vt=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),Lt=r=>{throw TypeError(r)};var et=(r,e,s)=>e.has(r)||Lt("Cannot "+s);var t=(r,e,s)=>(et(r,e,"read from private field"),s?s.call(r):e.get(r)),o=(r,e,s)=>e.has(r)?Lt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,s),a=(r,e,s,i)=>(et(r,e,"write to private field"),i?i.call(r,s):e.set(r,s),s),d=(r,e,s)=>(et(r,e,"access private method"),s);var H=(r,e,s)=>new Promise((i,u)=>{var f=p=>{try{T(s.next(p))}catch(h){u(h)}},M=p=>{try{T(s.throw(p))}catch(h){u(h)}},T=p=>p.done?i(p.value):Promise.resolve(p.value).then(f,M);T((s=s.apply(r,e)).next())});var St=(r,e,s)=>(e=r[vt("asyncIterator")])?e.call(r):(r=r[vt("iterator")](),e={},s=(i,u)=>(u=r[i])&&(e[i]=f=>new Promise((M,T,p)=>(f=u.call(r,f),p=f.done,Promise.resolve(f.value).then(h=>M({value:h,done:p}),T)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Pt=require("../index-Cqw2NKev.cjs"),_=require("../events-KVanG9sR.cjs"),Nt=require("../polyfills-Df4r-ETT.cjs"),yt=require("../scroll-DAhSpkhR.cjs"),X=require("../url-D1CgmwZ_.cjs"),Dt=require("../css-value-parser/index.cjs");class At extends HTMLElement{connectedCallback(){const e={"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(e))this.setAttribute(s,i)}}Pt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",At);var y,c,x,j,I;class bt{constructor(e,s){o(this,y);o(this,c);o(this,x);o(this,j,e=>{if(e.preventDefault(),t(this,c).hasAttribute("data-back")&&t(this,y).previousPathname)history.back();else{const i=t(this,c).getAttribute("data-history-action")||"push",u=t(this,c).hasAttribute("data-center-scroll"),f=getComputedStyle(t(this,c)).getPropertyValue("--offset-scroll").trim(),M=f?Dt.cssValueParser.parse(f):void 0,T=t(this,c).hasAttribute("data-revalidate"),p=t(this,c).hasAttribute("data-keep-search-parameters");t(this,y).navigate(t(this,x),{historyAction:i,centerScroll:u,offsetScroll:M,revalidate:T,keepSearchParameters:p})}});o(this,I,()=>{t(this,y).prefetch(t(this,x)),t(this,c).removeEventListener("pointerenter",t(this,I))});a(this,y,s),a(this,c,e),a(this,x,t(this,c).getAttribute("href")||"/"),t(this,c).addEventListener("click",t(this,j)),this.checkCurrent(location.pathname),t(this,c).hasAttribute("data-prefetch")&&t(this,c).addEventListener("pointerenter",t(this,I))}get element(){return t(this,c)}checkCurrent(e){const s=t(this,y).normalizePath(e),i=t(this,y).normalizePath(t(this,x));t(this,c).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?t(this,c).classList.add("current"):i.pathname===s.pathname?t(this,c).classList.add("current"):t(this,c).classList.remove("current")}destroy(){t(this,c).removeEventListener("click",t(this,j)),t(this,c).removeEventListener("pointerenter",t(this,I)),t(this,c).classList.remove("current")}}y=new WeakMap,c=new WeakMap,x=new WeakMap,j=new WeakMap,I=new WeakMap;var N,V,E,D,R,A;class wt{constructor(e,s,i){o(this,N);o(this,V);o(this,E,{x:0,y:0});o(this,D);o(this,R,null);o(this,A,null);a(this,N,e),a(this,V,s),a(this,D,i.cloneNode(!0))}get pathname(){return t(this,V)}get scrollState(){return t(this,E)}get document(){return t(this,A)}cloneDocument(){a(this,A,(t(this,R)||t(this,D)).cloneNode(!0))}get title(){let e="";if(t(this,A).title)e=t(this,A).title;else{const s=t(this,A).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,V)}return e}clearScrollState(){t(this,E).x=0,t(this,E).y=0}clearDocumentState(){a(this,R,null)}saveScrollState(){t(this,D).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,E).x=0,t(this,E).y=0):(t(this,E).x=t(this,N).scrollElement.scrollLeft,t(this,E).y=t(this,N).scrollElement.scrollTop)}saveDocumentState(){t(this,D).documentElement.hasAttribute("data-no-page-restoration")?a(this,R,null):a(this,R,document.cloneNode(!0))}restoreScrollPosition(){t(this,N).scrollElement.scroll({top:t(this,E).y,left:t(this,E).x})}}N=new WeakMap,V=new WeakMap,E=new WeakMap,D=new WeakMap,R=new WeakMap,A=new WeakMap;var k,U,g,Z,C,m,K,q,b,L,B,z,l,st,it,rt,kt,nt,ot,at,lt,$,O;class Rt{constructor(e){o(this,l);o(this,k,null);o(this,U,null);o(this,g,[]);o(this,Z,new DOMParser);o(this,C);o(this,m,null);o(this,K);o(this,q,[]);o(this,b,!1);o(this,L,null);o(this,B,new Map);o(this,z,null);o(this,$,e=>H(this,null,function*(){var s;(s=e.state)!=null&&s.path&&(e.preventDefault(),a(this,b,!0),yield this.navigate(e.state.path,{historyAction:"none"}),a(this,b,!1))}));o(this,O,()=>{const e=t(this,L).scrollTop,s=t(this,L).scrollLeft;document.documentElement.classList.toggle("top-scrolled",e>0),document.documentElement.classList.toggle("left-scrolled",s>0),_.dispatchEvent(document,"morphScroll",{detail:{left:s,top:e}})});if(Pt.isBrowser){a(this,k,{base:X.normalizeBase(e==null?void 0:e.base),waitForHeadToLoad:(e==null?void 0:e.waitForHeadToLoad)!==!1,cachePages:(e==null?void 0:e.cachePages)!==!1,trailingSlash:(e==null?void 0:e.trailingSlash)||!1,scrollSelector:(e==null?void 0:e.scrollSelector)||"body"}),a(this,U,d(this,l,rt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,m,s.pathname),t(this,B).set(t(this,m),new wt(this,t(this,m),document)),document.documentElement.setAttribute("data-current-pathname",t(this,m)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",t(this,$)),X.changeHistory({action:"replace",pathname:t(this,m),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,z,new At),d(this,l,at).call(this,document)}}get currentPathname(){return t(this,m)}get previousPathname(){return t(this,K)}get links(){return t(this,g)}get scrollElement(){return t(this,L)}get isPopstateNavigation(){return t(this,b)}normalizePath(e){return X.splitPath(e,{base:t(this,k).base,trailingSlash:t(this,k).trailingSlash})}prefetch(e){return H(this,null,function*(){const s=this.normalizePath(e);d(this,l,it).call(this,s.pathname)})}navigate(T){return H(this,arguments,function*(e,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:f,keepSearchParameters:M}={}){var ct;if(t(this,q).length)return;const p=this.normalizePath(((ct=this.pathnameModifier)==null?void 0:ct.call(this,e))||e);let{pathname:h,hash:Y,parameters:Ct,leaf:Mt}=p;if(t(this,C)===h||t(this,m)===h){t(this,b)||d(this,l,lt).call(this,Y||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,C,h),t(this,g).forEach(F=>{F.checkCurrent(h)});try{let F=!0;if(this.preprocessor)try{yield new Promise((n,w)=>{var P;(P=this.preprocessor)==null||P.call(this,{pathname:h,resolve:n,reject:w})})}catch(n){n?console.error(n):console.log("Route change canceled"),F=!1}if(!F||t(this,C)!==h){t(this,g).forEach(n=>{n.checkCurrent(t(this,m))});return}const ht=yield d(this,l,st).call(this,t(this,m)),S=yield d(this,l,st).call(this,h,f);if(t(this,C)!==h){t(this,g).forEach(n=>{n.checkCurrent(t(this,m))});return}ht.saveScrollState(),ht.saveDocumentState(),t(this,b)||(S.clearScrollState(),S.clearDocumentState()),S.cloneDocument(),t(this,z).textContent=S.title,document.body.appendChild(t(this,z));const ut={pathname:h};_.dispatchEvent(document,"morphStart",{detail:ut});const dt=Array.from(document.head.children),mt=Array.from(S.document.head.children),ft=d(this,l,kt).call(this,dt,mt),Tt=d(this,l,nt).call(this,dt,ft),G=d(this,l,nt).call(this,mt,ft);G.forEach((n,w)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const P=document.createElement("script");P.type="module",P.src=n.getAttribute("src"),G[w]=P}}),G.forEach(n=>{document.head.appendChild(n)});const tt=G.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(d(this,l,ot).call(this,n))return!0});t(this,k).waitForHeadToLoad&&tt.length&&(yield new Promise(n=>H(this,null,function*(){let w=0;try{for(var P=St(tt),Et,W,gt;Et=!(W=yield P.next()).done;Et=!1){const J=W.value;J.onload=()=>{w++,w===tt.length&&n()}}}catch(W){gt=[W]}finally{try{Et&&(W=P.return)&&(yield W.call(P))}finally{if(gt)throw gt[0]}}}))),yield yt.wait(10);const pt=[];Tt.forEach(n=>{n.hasAttribute("data-permanent")||(d(this,l,ot).call(this,n)?pt.push(n):n.remove())});const Ht=d(this,l,rt).call(this,S.document.body);d(this,l,at).call(this,S.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Mt),X.changeHistory({action:s,pathname:h,searchParameters:Ct||(M?location.search:""),hash:Y}),t(this,z).remove(),a(this,K,t(this,m)),a(this,m,h),t(this,U).forEach((n,w)=>{const P=Ht[w],Et=getComputedStyle(n).getPropertyValue("--morph-duration"),W=[...P.childNodes];if(Et){const gt=[...n.childNodes];gt.forEach(v=>{v instanceof HTMLElement&&v.classList.add("old")}),W.forEach(v=>{v instanceof HTMLElement&&v.classList.add("new")}),n.prepend(...W),Nt.requestIdleCallback(()=>{W.forEach(v=>{v instanceof HTMLElement&&v.classList.add("in")})});const J={morphElement:n,pathname:h};_.dispatchEvent(document,"morphNewChildrenAdded",{detail:J});const xt=new Promise(v=>{setTimeout(()=>{gt.forEach(Q=>Q.remove()),W.forEach(Q=>{Q instanceof HTMLElement&&Q.classList.remove("in","new")}),_.dispatchEvent(document,"morphOldChildrenRemoved",{detail:J}),v()},(parseFloat(Et)||0)*1e3+10)});t(this,q).push(xt)}else n.innerHTML="",n.append(...W)}),Y?(S.clearScrollState(),d(this,l,lt).call(this,Y,{centerScroll:i,offsetScroll:u})):t(this,b)&&S.restoreScrollPosition(),yield Promise.all(t(this,q)),pt.forEach(n=>n.remove()),a(this,q,[]),this.findLinks(),_.dispatchEvent(document,"morphComplete",{detail:ut}),window.dispatchEvent(new Event("resize"))}catch(F){console.error(F)}a(this,C,void 0)})}addLink(e){t(this,g).push(new bt(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){a(this,g,t(this,g).filter(s=>s.element===e?(s.destroy(),!1):!0))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")&&s.getAttribute("target")!=="_blank"});t(this,g).forEach(s=>s.destroy()),a(this,g,e.map(s=>new bt(s,this)))}}k=new WeakMap,U=new WeakMap,g=new WeakMap,Z=new WeakMap,C=new WeakMap,m=new WeakMap,K=new WeakMap,q=new WeakMap,b=new WeakMap,L=new WeakMap,B=new WeakMap,z=new WeakMap,l=new WeakSet,st=function(e,s=!1){return H(this,null,function*(){let i=t(this,B).get(e);return(!i||s)&&(i=yield d(this,l,it).call(this,e)),i})},it=function(e){return H(this,null,function*(){const i=yield(yield fetch(e)).text(),u=t(this,Z).parseFromString(i,"text/html"),f=new wt(this,e,u);return t(this,B).set(e,f),f})},rt=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},kt=function(e,s){return e.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},nt=function(e,s){return e.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ot=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},at=function(e){var s,i;(s=t(this,L))==null||s.removeEventListener("scroll",t(this,O)),a(this,L,e.querySelector(t(this,k).scrollSelector)||e.documentElement),(i=t(this,L))==null||i.addEventListener("scroll",t(this,O)),t(this,O).call(this)},lt=function(e,s){const i=typeof e=="string"?document.getElementById(e):e;(typeof i=="number"||i)&&yt.scrollToElement(i,{scrollElement:t(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},$=new WeakMap,O=new WeakMap;exports.Morph=Rt;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var gt = (r,
|
|
1
|
+
var gt = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), vt = (r) => {
|
|
2
2
|
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var tt = (r,
|
|
5
|
-
var
|
|
6
|
-
var H = (r,
|
|
4
|
+
var tt = (r, e, s) => e.has(r) || vt("Cannot " + s);
|
|
5
|
+
var t = (r, e, s) => (tt(r, e, "read from private field"), s ? s.call(r) : e.get(r)), o = (r, e, s) => e.has(r) ? vt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, s), a = (r, e, s, i) => (tt(r, e, "write to private field"), i ? i.call(r, s) : e.set(r, s), s), d = (r, e, s) => (tt(r, e, "access private method"), s);
|
|
6
|
+
var H = (r, e, s) => new Promise((i, u) => {
|
|
7
7
|
var f = (p) => {
|
|
8
8
|
try {
|
|
9
9
|
M(s.next(p));
|
|
@@ -17,10 +17,10 @@ var H = (r, t, s) => new Promise((i, u) => {
|
|
|
17
17
|
u(c);
|
|
18
18
|
}
|
|
19
19
|
}, M = (p) => p.done ? i(p.value) : Promise.resolve(p.value).then(f, T);
|
|
20
|
-
M((s = s.apply(r,
|
|
20
|
+
M((s = s.apply(r, e)).next());
|
|
21
21
|
});
|
|
22
|
-
var Lt = (r,
|
|
23
|
-
import { i as
|
|
22
|
+
var Lt = (r, e, s) => (e = r[gt("asyncIterator")]) ? e.call(r) : (r = r[gt("iterator")](), e = {}, s = (i, u) => (u = r[i]) && (e[i] = (f) => new Promise((T, M, p) => (f = u.call(r, f), p = f.done, Promise.resolve(f.value).then((c) => T({ value: c, done: p }), M)))), s("next"), s("return"), e);
|
|
23
|
+
import { i as yt } from "../index-euf5anj6.js";
|
|
24
24
|
import { d as U } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as xt } from "../polyfills-DJrTJQky.js";
|
|
26
26
|
import { w as Nt, s as Dt } from "../scroll-Benkuq-t.js";
|
|
@@ -28,115 +28,118 @@ import { n as Rt, c as St, s as zt } from "../url-B6BNcw6_.js";
|
|
|
28
28
|
import { cssValueParser as qt } from "../css-value-parser/index.js";
|
|
29
29
|
class Pt extends HTMLElement {
|
|
30
30
|
connectedCallback() {
|
|
31
|
-
const
|
|
31
|
+
const e = {
|
|
32
32
|
"aria-live": "assertive",
|
|
33
33
|
"aria-atomic": "true",
|
|
34
34
|
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"
|
|
35
35
|
};
|
|
36
|
-
for (const [s, i] of Object.entries(
|
|
36
|
+
for (const [s, i] of Object.entries(e))
|
|
37
37
|
this.setAttribute(s, i);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
class
|
|
43
|
-
constructor(
|
|
44
|
-
o(this,
|
|
45
|
-
o(this,
|
|
40
|
+
yt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Pt);
|
|
41
|
+
var b, l, x, j, I;
|
|
42
|
+
class bt {
|
|
43
|
+
constructor(e, s) {
|
|
44
|
+
o(this, b);
|
|
45
|
+
o(this, l);
|
|
46
46
|
o(this, x);
|
|
47
|
-
o(this, j, (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
o(this, j, (e) => {
|
|
48
|
+
if (e.preventDefault(), t(this, l).hasAttribute("data-back") && t(this, b).previousPathname)
|
|
49
|
+
history.back();
|
|
50
|
+
else {
|
|
51
|
+
const i = t(this, l).getAttribute(
|
|
52
|
+
"data-history-action"
|
|
53
|
+
) || "push", u = t(this, l).hasAttribute("data-center-scroll"), f = getComputedStyle(t(this, l)).getPropertyValue("--offset-scroll").trim(), T = f ? qt.parse(f) : void 0, M = t(this, l).hasAttribute("data-revalidate"), p = t(this, l).hasAttribute(
|
|
54
|
+
"data-keep-search-parameters"
|
|
55
|
+
);
|
|
56
|
+
t(this, b).navigate(t(this, x), {
|
|
57
|
+
historyAction: i,
|
|
58
|
+
centerScroll: u,
|
|
59
|
+
offsetScroll: T,
|
|
60
|
+
revalidate: M,
|
|
61
|
+
keepSearchParameters: p
|
|
62
|
+
});
|
|
63
|
+
}
|
|
61
64
|
});
|
|
62
65
|
o(this, I, () => {
|
|
63
|
-
|
|
66
|
+
t(this, b).prefetch(t(this, x)), t(this, l).removeEventListener("pointerenter", t(this, I));
|
|
64
67
|
});
|
|
65
|
-
a(this,
|
|
68
|
+
a(this, b, s), a(this, l, e), a(this, x, t(this, l).getAttribute("href") || "/"), t(this, l).addEventListener("click", t(this, j)), this.checkCurrent(location.pathname), t(this, l).hasAttribute("data-prefetch") && t(this, l).addEventListener("pointerenter", t(this, I));
|
|
66
69
|
}
|
|
67
70
|
get element() {
|
|
68
|
-
return
|
|
71
|
+
return t(this, l);
|
|
69
72
|
}
|
|
70
|
-
checkCurrent(
|
|
71
|
-
const s =
|
|
72
|
-
|
|
73
|
+
checkCurrent(e) {
|
|
74
|
+
const s = t(this, b).normalizePath(e), i = t(this, b).normalizePath(t(this, x));
|
|
75
|
+
t(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? t(this, l).classList.add("current") : i.pathname === s.pathname ? t(this, l).classList.add("current") : t(this, l).classList.remove("current");
|
|
73
76
|
}
|
|
74
77
|
destroy() {
|
|
75
|
-
|
|
78
|
+
t(this, l).removeEventListener("click", t(this, j)), t(this, l).removeEventListener("pointerenter", t(this, I)), t(this, l).classList.remove("current");
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
|
-
|
|
81
|
+
b = new WeakMap(), l = new WeakMap(), x = new WeakMap(), j = new WeakMap(), I = new WeakMap();
|
|
79
82
|
var N, V, E, D, R, A;
|
|
80
|
-
class
|
|
81
|
-
constructor(
|
|
83
|
+
class wt {
|
|
84
|
+
constructor(e, s, i) {
|
|
82
85
|
o(this, N);
|
|
83
86
|
o(this, V);
|
|
84
87
|
o(this, E, { x: 0, y: 0 });
|
|
85
88
|
o(this, D);
|
|
86
89
|
o(this, R, null);
|
|
87
90
|
o(this, A, null);
|
|
88
|
-
a(this, N,
|
|
91
|
+
a(this, N, e), a(this, V, s), a(this, D, i.cloneNode(!0));
|
|
89
92
|
}
|
|
90
93
|
get pathname() {
|
|
91
|
-
return
|
|
94
|
+
return t(this, V);
|
|
92
95
|
}
|
|
93
96
|
get scrollState() {
|
|
94
|
-
return
|
|
97
|
+
return t(this, E);
|
|
95
98
|
}
|
|
96
99
|
get document() {
|
|
97
|
-
return
|
|
100
|
+
return t(this, A);
|
|
98
101
|
}
|
|
99
102
|
cloneDocument() {
|
|
100
|
-
a(this, A, (
|
|
103
|
+
a(this, A, (t(this, R) || t(this, D)).cloneNode(!0));
|
|
101
104
|
}
|
|
102
105
|
get title() {
|
|
103
|
-
let
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
+
let e = "";
|
|
107
|
+
if (t(this, A).title)
|
|
108
|
+
e = t(this, A).title;
|
|
106
109
|
else {
|
|
107
|
-
const s =
|
|
108
|
-
|
|
110
|
+
const s = t(this, A).querySelector("h1");
|
|
111
|
+
e = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || t(this, V);
|
|
109
112
|
}
|
|
110
|
-
return
|
|
113
|
+
return e;
|
|
111
114
|
}
|
|
112
115
|
clearScrollState() {
|
|
113
|
-
|
|
116
|
+
t(this, E).x = 0, t(this, E).y = 0;
|
|
114
117
|
}
|
|
115
118
|
clearDocumentState() {
|
|
116
119
|
a(this, R, null);
|
|
117
120
|
}
|
|
118
121
|
saveScrollState() {
|
|
119
|
-
|
|
122
|
+
t(this, D).documentElement.hasAttribute(
|
|
120
123
|
"data-no-scroll-restoration"
|
|
121
|
-
) ? (
|
|
124
|
+
) ? (t(this, E).x = 0, t(this, E).y = 0) : (t(this, E).x = t(this, N).scrollElement.scrollLeft, t(this, E).y = t(this, N).scrollElement.scrollTop);
|
|
122
125
|
}
|
|
123
126
|
saveDocumentState() {
|
|
124
|
-
|
|
127
|
+
t(this, D).documentElement.hasAttribute(
|
|
125
128
|
"data-no-page-restoration"
|
|
126
129
|
) ? a(this, R, null) : a(this, R, document.cloneNode(!0));
|
|
127
130
|
}
|
|
128
131
|
restoreScrollPosition() {
|
|
129
|
-
|
|
130
|
-
top:
|
|
131
|
-
left:
|
|
132
|
+
t(this, N).scrollElement.scroll({
|
|
133
|
+
top: t(this, E).y,
|
|
134
|
+
left: t(this, E).x
|
|
132
135
|
});
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
N = new WeakMap(), V = new WeakMap(), E = new WeakMap(), D = new WeakMap(), R = new WeakMap(), A = new WeakMap();
|
|
136
|
-
var k, K, g, X, C, m, Y, z, w, L, B, q,
|
|
139
|
+
var k, K, g, X, C, m, Y, z, w, L, B, q, h, et, st, it, At, rt, nt, ot, at, Z, O;
|
|
137
140
|
class jt {
|
|
138
|
-
constructor(
|
|
139
|
-
o(this,
|
|
141
|
+
constructor(e) {
|
|
142
|
+
o(this, h);
|
|
140
143
|
o(this, k, null);
|
|
141
144
|
o(this, K, null);
|
|
142
145
|
o(this, g, []);
|
|
@@ -149,96 +152,96 @@ class jt {
|
|
|
149
152
|
o(this, L, null);
|
|
150
153
|
o(this, B, /* @__PURE__ */ new Map());
|
|
151
154
|
o(this, q, null);
|
|
152
|
-
o(this, Z, (
|
|
155
|
+
o(this, Z, (e) => H(this, null, function* () {
|
|
153
156
|
var s;
|
|
154
|
-
(s =
|
|
157
|
+
(s = e.state) != null && s.path && (e.preventDefault(), a(this, w, !0), yield this.navigate(e.state.path, { historyAction: "none" }), a(this, w, !1));
|
|
155
158
|
}));
|
|
156
159
|
o(this, O, () => {
|
|
157
|
-
const
|
|
158
|
-
document.documentElement.classList.toggle("top-scrolled",
|
|
160
|
+
const e = t(this, L).scrollTop, s = t(this, L).scrollLeft;
|
|
161
|
+
document.documentElement.classList.toggle("top-scrolled", e > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), U(document, "morphScroll", {
|
|
159
162
|
detail: {
|
|
160
163
|
left: s,
|
|
161
|
-
top:
|
|
164
|
+
top: e
|
|
162
165
|
}
|
|
163
166
|
});
|
|
164
167
|
});
|
|
165
|
-
if (
|
|
168
|
+
if (yt) {
|
|
166
169
|
a(this, k, {
|
|
167
|
-
base: Rt(
|
|
168
|
-
waitForHeadToLoad: (
|
|
169
|
-
cachePages: (
|
|
170
|
-
trailingSlash: (
|
|
171
|
-
scrollSelector: (
|
|
172
|
-
}), a(this, K, d(this,
|
|
170
|
+
base: Rt(e == null ? void 0 : e.base),
|
|
171
|
+
waitForHeadToLoad: (e == null ? void 0 : e.waitForHeadToLoad) !== !1,
|
|
172
|
+
cachePages: (e == null ? void 0 : e.cachePages) !== !1,
|
|
173
|
+
trailingSlash: (e == null ? void 0 : e.trailingSlash) || !1,
|
|
174
|
+
scrollSelector: (e == null ? void 0 : e.scrollSelector) || "body"
|
|
175
|
+
}), a(this, K, d(this, h, it).call(this, document.body));
|
|
173
176
|
const s = this.normalizePath(
|
|
174
177
|
location.pathname + location.hash
|
|
175
178
|
);
|
|
176
|
-
a(this, m, s.pathname),
|
|
177
|
-
|
|
178
|
-
new
|
|
179
|
+
a(this, m, s.pathname), t(this, B).set(
|
|
180
|
+
t(this, m),
|
|
181
|
+
new wt(this, t(this, m), document)
|
|
179
182
|
), document.documentElement.setAttribute(
|
|
180
183
|
"data-current-pathname",
|
|
181
|
-
|
|
184
|
+
t(this, m)
|
|
182
185
|
), document.documentElement.setAttribute(
|
|
183
186
|
"data-current-leaf",
|
|
184
187
|
s.leaf
|
|
185
|
-
), this.findLinks(), addEventListener("popstate",
|
|
188
|
+
), this.findLinks(), addEventListener("popstate", t(this, Z)), St({
|
|
186
189
|
action: "replace",
|
|
187
|
-
pathname:
|
|
190
|
+
pathname: t(this, m),
|
|
188
191
|
searchParameters: s.parameters || location.search,
|
|
189
192
|
hash: s.hash
|
|
190
|
-
}), a(this, q, new Pt()), d(this,
|
|
193
|
+
}), a(this, q, new Pt()), d(this, h, ot).call(this, document);
|
|
191
194
|
}
|
|
192
195
|
}
|
|
193
196
|
get currentPathname() {
|
|
194
|
-
return
|
|
197
|
+
return t(this, m);
|
|
195
198
|
}
|
|
196
199
|
get previousPathname() {
|
|
197
|
-
return
|
|
200
|
+
return t(this, Y);
|
|
198
201
|
}
|
|
199
202
|
get links() {
|
|
200
|
-
return
|
|
203
|
+
return t(this, g);
|
|
201
204
|
}
|
|
202
205
|
get scrollElement() {
|
|
203
|
-
return
|
|
206
|
+
return t(this, L);
|
|
204
207
|
}
|
|
205
208
|
get isPopstateNavigation() {
|
|
206
|
-
return
|
|
209
|
+
return t(this, w);
|
|
207
210
|
}
|
|
208
|
-
normalizePath(
|
|
209
|
-
return zt(
|
|
210
|
-
base:
|
|
211
|
-
trailingSlash:
|
|
211
|
+
normalizePath(e) {
|
|
212
|
+
return zt(e, {
|
|
213
|
+
base: t(this, k).base,
|
|
214
|
+
trailingSlash: t(this, k).trailingSlash
|
|
212
215
|
});
|
|
213
216
|
}
|
|
214
|
-
prefetch(
|
|
217
|
+
prefetch(e) {
|
|
215
218
|
return H(this, null, function* () {
|
|
216
|
-
const s = this.normalizePath(
|
|
217
|
-
d(this,
|
|
219
|
+
const s = this.normalizePath(e);
|
|
220
|
+
d(this, h, st).call(this, s.pathname);
|
|
218
221
|
});
|
|
219
222
|
}
|
|
220
223
|
navigate(M) {
|
|
221
|
-
return H(this, arguments, function* (
|
|
224
|
+
return H(this, arguments, function* (e, {
|
|
222
225
|
historyAction: s = "push",
|
|
223
226
|
centerScroll: i,
|
|
224
227
|
offsetScroll: u,
|
|
225
228
|
revalidate: f,
|
|
226
229
|
keepSearchParameters: T
|
|
227
230
|
} = {}) {
|
|
228
|
-
var
|
|
229
|
-
if (
|
|
231
|
+
var ht;
|
|
232
|
+
if (t(this, z).length)
|
|
230
233
|
return;
|
|
231
|
-
const p = this.normalizePath(((
|
|
234
|
+
const p = this.normalizePath(((ht = this.pathnameModifier) == null ? void 0 : ht.call(this, e)) || e);
|
|
232
235
|
let { pathname: c, hash: _, parameters: kt, leaf: Ct } = p;
|
|
233
|
-
if (
|
|
234
|
-
|
|
236
|
+
if (t(this, C) === c || t(this, m) === c) {
|
|
237
|
+
t(this, w) || d(this, h, at).call(this, _ || 0, {
|
|
235
238
|
centerScroll: i,
|
|
236
239
|
offsetScroll: u,
|
|
237
240
|
behavior: "smooth"
|
|
238
241
|
});
|
|
239
242
|
return;
|
|
240
243
|
}
|
|
241
|
-
a(this, C, c),
|
|
244
|
+
a(this, C, c), t(this, g).forEach((F) => {
|
|
242
245
|
F.checkCurrent(c);
|
|
243
246
|
});
|
|
244
247
|
try {
|
|
@@ -246,8 +249,8 @@ class jt {
|
|
|
246
249
|
if (this.preprocessor)
|
|
247
250
|
try {
|
|
248
251
|
yield new Promise((n, y) => {
|
|
249
|
-
var
|
|
250
|
-
(
|
|
252
|
+
var P;
|
|
253
|
+
(P = this.preprocessor) == null || P.call(this, {
|
|
251
254
|
pathname: c,
|
|
252
255
|
resolve: n,
|
|
253
256
|
reject: y
|
|
@@ -256,31 +259,31 @@ class jt {
|
|
|
256
259
|
} catch (n) {
|
|
257
260
|
n ? console.error(n) : console.log("Route change canceled"), F = !1;
|
|
258
261
|
}
|
|
259
|
-
if (!F ||
|
|
260
|
-
|
|
261
|
-
n.checkCurrent(
|
|
262
|
+
if (!F || t(this, C) !== c) {
|
|
263
|
+
t(this, g).forEach((n) => {
|
|
264
|
+
n.checkCurrent(t(this, m));
|
|
262
265
|
});
|
|
263
266
|
return;
|
|
264
267
|
}
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
n.checkCurrent(
|
|
268
|
+
const lt = yield d(this, h, et).call(this, t(this, m)), S = yield d(this, h, et).call(this, c, f);
|
|
269
|
+
if (t(this, C) !== c) {
|
|
270
|
+
t(this, g).forEach((n) => {
|
|
271
|
+
n.checkCurrent(t(this, m));
|
|
269
272
|
});
|
|
270
273
|
return;
|
|
271
274
|
}
|
|
272
|
-
|
|
275
|
+
lt.saveScrollState(), lt.saveDocumentState(), t(this, w) || (S.clearScrollState(), S.clearDocumentState()), S.cloneDocument(), t(this, q).textContent = S.title, document.body.appendChild(t(this, q));
|
|
273
276
|
const ct = {
|
|
274
277
|
pathname: c
|
|
275
278
|
};
|
|
276
279
|
U(document, "morphStart", {
|
|
277
280
|
detail: ct
|
|
278
281
|
});
|
|
279
|
-
const ut = Array.from(document.head.children), dt = Array.from(S.document.head.children), mt = d(this,
|
|
282
|
+
const ut = Array.from(document.head.children), dt = Array.from(S.document.head.children), mt = d(this, h, At).call(this, ut, dt), Tt = d(this, h, rt).call(this, ut, mt), G = d(this, h, rt).call(this, dt, mt);
|
|
280
283
|
G.forEach((n, y) => {
|
|
281
284
|
if (n.tagName === "SCRIPT" && n.getAttribute("src")) {
|
|
282
|
-
const
|
|
283
|
-
|
|
285
|
+
const P = document.createElement("script");
|
|
286
|
+
P.type = "module", P.src = n.getAttribute("src"), G[y] = P;
|
|
284
287
|
}
|
|
285
288
|
}), G.forEach((n) => {
|
|
286
289
|
document.head.appendChild(n);
|
|
@@ -288,13 +291,13 @@ class jt {
|
|
|
288
291
|
const $ = G.filter((n) => {
|
|
289
292
|
if (n.hasAttribute("data-no-waiting"))
|
|
290
293
|
return !1;
|
|
291
|
-
if (d(this,
|
|
294
|
+
if (d(this, h, nt).call(this, n))
|
|
292
295
|
return !0;
|
|
293
296
|
});
|
|
294
|
-
|
|
297
|
+
t(this, k).waitForHeadToLoad && $.length && (yield new Promise((n) => H(this, null, function* () {
|
|
295
298
|
let y = 0;
|
|
296
299
|
try {
|
|
297
|
-
for (var
|
|
300
|
+
for (var P = Lt($), pt, W, Et; pt = !(W = yield P.next()).done; pt = !1) {
|
|
298
301
|
const J = W.value;
|
|
299
302
|
J.onload = () => {
|
|
300
303
|
y++, y === $.length && n();
|
|
@@ -304,7 +307,7 @@ class jt {
|
|
|
304
307
|
Et = [W];
|
|
305
308
|
} finally {
|
|
306
309
|
try {
|
|
307
|
-
pt && (W =
|
|
310
|
+
pt && (W = P.return) && (yield W.call(P));
|
|
308
311
|
} finally {
|
|
309
312
|
if (Et)
|
|
310
313
|
throw Et[0];
|
|
@@ -313,16 +316,16 @@ class jt {
|
|
|
313
316
|
}))), yield Nt(10);
|
|
314
317
|
const ft = [];
|
|
315
318
|
Tt.forEach((n) => {
|
|
316
|
-
n.hasAttribute("data-permanent") || (d(this,
|
|
319
|
+
n.hasAttribute("data-permanent") || (d(this, h, nt).call(this, n) ? ft.push(n) : n.remove());
|
|
317
320
|
});
|
|
318
|
-
const Mt = d(this,
|
|
319
|
-
d(this,
|
|
321
|
+
const Mt = d(this, h, it).call(this, S.document.body);
|
|
322
|
+
d(this, h, ot).call(this, S.document), document.documentElement.setAttribute("data-current-pathname", c), document.documentElement.setAttribute("data-current-leaf", Ct), St({
|
|
320
323
|
action: s,
|
|
321
324
|
pathname: c,
|
|
322
325
|
searchParameters: kt || (T ? location.search : ""),
|
|
323
326
|
hash: _
|
|
324
|
-
}),
|
|
325
|
-
const
|
|
327
|
+
}), t(this, q).remove(), a(this, Y, t(this, m)), a(this, m, c), t(this, K).forEach((n, y) => {
|
|
328
|
+
const P = Mt[y], pt = getComputedStyle(n).getPropertyValue("--morph-duration"), W = [...P.childNodes];
|
|
326
329
|
if (pt) {
|
|
327
330
|
const Et = [...n.childNodes];
|
|
328
331
|
Et.forEach((v) => {
|
|
@@ -350,10 +353,10 @@ class jt {
|
|
|
350
353
|
}), v();
|
|
351
354
|
}, (parseFloat(pt) || 0) * 1e3 + 10);
|
|
352
355
|
});
|
|
353
|
-
|
|
356
|
+
t(this, z).push(Ht);
|
|
354
357
|
} else
|
|
355
358
|
n.innerHTML = "", n.append(...W);
|
|
356
|
-
}), _ ? (S.clearScrollState(), d(this,
|
|
359
|
+
}), _ ? (S.clearScrollState(), d(this, h, at).call(this, _, { centerScroll: i, offsetScroll: u })) : t(this, w) && S.restoreScrollPosition(), yield Promise.all(t(this, z)), ft.forEach((n) => n.remove()), a(this, z, []), this.findLinks(), U(document, "morphComplete", {
|
|
357
360
|
detail: ct
|
|
358
361
|
}), window.dispatchEvent(new Event("resize"));
|
|
359
362
|
} catch (F) {
|
|
@@ -362,19 +365,19 @@ class jt {
|
|
|
362
365
|
a(this, C, void 0);
|
|
363
366
|
});
|
|
364
367
|
}
|
|
365
|
-
addLink(
|
|
366
|
-
|
|
368
|
+
addLink(e) {
|
|
369
|
+
t(this, g).push(new bt(e, this));
|
|
367
370
|
}
|
|
368
|
-
addLinks(
|
|
369
|
-
|
|
371
|
+
addLinks(e) {
|
|
372
|
+
e.forEach((s) => {
|
|
370
373
|
this.addLink(s);
|
|
371
374
|
});
|
|
372
375
|
}
|
|
373
|
-
removeLink(
|
|
374
|
-
a(this, g,
|
|
376
|
+
removeLink(e) {
|
|
377
|
+
a(this, g, t(this, g).filter((s) => s.element === e ? (s.destroy(), !1) : !0));
|
|
375
378
|
}
|
|
376
379
|
findLinks() {
|
|
377
|
-
const
|
|
380
|
+
const e = [
|
|
378
381
|
...document.documentElement.querySelectorAll("a")
|
|
379
382
|
].filter(
|
|
380
383
|
(s) => {
|
|
@@ -382,46 +385,46 @@ class jt {
|
|
|
382
385
|
return ((i = s.getAttribute("href")) == null ? void 0 : i.startsWith("/")) && !s.hasAttribute("download") && !s.hasAttribute("data-morph-skip") && !s.closest("[data-morph-skip]") && s.getAttribute("target") !== "_blank";
|
|
383
386
|
}
|
|
384
387
|
);
|
|
385
|
-
|
|
388
|
+
t(this, g).forEach((s) => s.destroy()), a(this, g, e.map((s) => new bt(s, this)));
|
|
386
389
|
}
|
|
387
390
|
}
|
|
388
|
-
k = new WeakMap(), K = new WeakMap(), g = new WeakMap(), X = new WeakMap(), C = new WeakMap(), m = new WeakMap(), Y = new WeakMap(), z = new WeakMap(), w = new WeakMap(), L = new WeakMap(), B = new WeakMap(), q = new WeakMap(),
|
|
391
|
+
k = new WeakMap(), K = new WeakMap(), g = new WeakMap(), X = new WeakMap(), C = new WeakMap(), m = new WeakMap(), Y = new WeakMap(), z = new WeakMap(), w = new WeakMap(), L = new WeakMap(), B = new WeakMap(), q = new WeakMap(), h = new WeakSet(), et = function(e, s = !1) {
|
|
389
392
|
return H(this, null, function* () {
|
|
390
|
-
let i =
|
|
391
|
-
return (!i || s) && (i = yield d(this,
|
|
393
|
+
let i = t(this, B).get(e);
|
|
394
|
+
return (!i || s) && (i = yield d(this, h, st).call(this, e)), i;
|
|
392
395
|
});
|
|
393
|
-
}, st = function(
|
|
396
|
+
}, st = function(e) {
|
|
394
397
|
return H(this, null, function* () {
|
|
395
|
-
const i = yield (yield fetch(
|
|
396
|
-
return
|
|
398
|
+
const i = yield (yield fetch(e)).text(), u = t(this, X).parseFromString(i, "text/html"), f = new wt(this, e, u);
|
|
399
|
+
return t(this, B).set(e, f), f;
|
|
397
400
|
});
|
|
398
|
-
}, it = function(
|
|
399
|
-
const s = [...
|
|
400
|
-
return s.length ? s : [
|
|
401
|
-
}, At = function(
|
|
402
|
-
return
|
|
401
|
+
}, it = function(e) {
|
|
402
|
+
const s = [...e.querySelectorAll("[data-morph]")];
|
|
403
|
+
return s.length ? s : [e];
|
|
404
|
+
}, At = function(e, s) {
|
|
405
|
+
return e.filter(
|
|
403
406
|
(i) => s.find(
|
|
404
407
|
(u) => u.outerHTML === i.outerHTML
|
|
405
408
|
)
|
|
406
409
|
);
|
|
407
|
-
}, rt = function(
|
|
408
|
-
return
|
|
410
|
+
}, rt = function(e, s) {
|
|
411
|
+
return e.filter(
|
|
409
412
|
(i) => !s.find(
|
|
410
413
|
(u) => u.outerHTML === i.outerHTML
|
|
411
414
|
)
|
|
412
415
|
);
|
|
413
|
-
}, nt = function(
|
|
414
|
-
return
|
|
415
|
-
}, ot = function(
|
|
416
|
+
}, nt = function(e) {
|
|
417
|
+
return e.tagName === "SCRIPT" || e.tagName === "STYLE" || e.tagName === "LINK" && e.getAttribute("rel") === "stylesheet";
|
|
418
|
+
}, ot = function(e) {
|
|
416
419
|
var s, i;
|
|
417
|
-
(s =
|
|
420
|
+
(s = t(this, L)) == null || s.removeEventListener(
|
|
418
421
|
"scroll",
|
|
419
|
-
|
|
420
|
-
), a(this, L,
|
|
421
|
-
}, at = function(
|
|
422
|
-
const i = typeof
|
|
422
|
+
t(this, O)
|
|
423
|
+
), a(this, L, e.querySelector(t(this, k).scrollSelector) || e.documentElement), (i = t(this, L)) == null || i.addEventListener("scroll", t(this, O)), t(this, O).call(this);
|
|
424
|
+
}, at = function(e, s) {
|
|
425
|
+
const i = typeof e == "string" ? document.getElementById(e) : e;
|
|
423
426
|
(typeof i == "number" || i) && Dt(i, {
|
|
424
|
-
scrollElement:
|
|
427
|
+
scrollElement: t(this, L),
|
|
425
428
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
426
429
|
center: s == null ? void 0 : s.centerScroll,
|
|
427
430
|
offset: s == null ? void 0 : s.offsetScroll
|