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