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