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