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