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