aptechka 0.69.9 → 0.69.10
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 +4 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +246 -232
- package/package.json +1 -1
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export interface MorphNavigationEntry {
|
|
|
12
12
|
path: string;
|
|
13
13
|
submorph?: Array<string>;
|
|
14
14
|
}
|
|
15
|
+
export interface MorphCompleteEntry extends MorphNavigationEntry {
|
|
16
|
+
document: Document;
|
|
17
|
+
}
|
|
15
18
|
export interface MorphChildrenActionEntry {
|
|
16
19
|
morphElement: HTMLElement;
|
|
17
20
|
path: string;
|
|
@@ -38,7 +41,7 @@ export interface MorphScrollDetail {
|
|
|
38
41
|
export interface MorphEvents {
|
|
39
42
|
morphNavigation: CustomEvent<MorphNavigationEntry>;
|
|
40
43
|
morphStart: CustomEvent<MorphNavigationEntry>;
|
|
41
|
-
morphComplete: CustomEvent<
|
|
44
|
+
morphComplete: CustomEvent<MorphCompleteEntry>;
|
|
42
45
|
morphNewChildrenAdded: CustomEvent<MorphChildrenActionEntry>;
|
|
43
46
|
morphOldChildrenRemoved: CustomEvent<MorphChildrenActionEntry>;
|
|
44
47
|
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 Wt=Object.defineProperty,Yt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var Ct=Object.getOwnPropertySymbols;var jt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable;var Tt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Mt=r=>{throw TypeError(r)};var xt=(r,t,s)=>t in r?Wt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,Nt=(r,t)=>{for(var s in t||(t={}))jt.call(t,s)&&xt(r,s,t[s]);if(Ct)for(var s of Ct(t))Ut.call(t,s)&&xt(r,s,t[s]);return r},Ht=(r,t)=>Yt(r,Xt(t));var pt=(r,t,s)=>t.has(r)||Mt("Cannot "+s);var e=(r,t,s)=>(pt(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)=>(pt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),p=(r,t,s)=>(pt(r,t,"access private method"),s);var W=(r,t,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(r,t)).next())});var qt=(r,t,s)=>(t=r[Tt("asyncIterator")])?t.call(r):(r=r[Tt("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=w=>new Promise((N,v,g)=>(w=u.call(r,w),g=w.done,Promise.resolve(w.value).then(O=>N({value:O,done:g}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("../index-DekP7OZe.cjs"),Y=require("../events-KVanG9sR.cjs"),Kt=require("../polyfills-Df4r-ETT.cjs"),Dt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ct=require("../url-BT4fssbO.cjs"),$t=require("../css-value-parser/index.cjs");class Vt 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)}}Rt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Vt);var C,l,D,st,$;class Et{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 u=e(this,l).getAttribute("data-history-action")||"push",w=e(this,l).hasAttribute("data-center-scroll"),N=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=N?$t.cssValueParser.parse(N):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,C).navigate(e(this,D),{historyAction:u,centerScroll:w,offsetScroll:v,revalidate:g,keepSearchParameters:O,submorph:h,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 Gt=new DOMParser;var T,I,b,P,X,R,G,j,V;class It{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 u=yield(yield fetch(e(this,I),{signal:e(this,j).signal})).text(),w=Gt.parseFromString(u,"text/html");this.setInitialDocument(w)}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,St,zt,vt,wt,yt,bt,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),u=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",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),Y.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Rt.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,St).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,f,s.path);const i=new It(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 Vt),p(this,c,yt).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(O){return W(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:w,keepSearchParameters:N,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,f)===h.path){e(this,x)||p(this,c,bt).call(this,h.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}n(this,z,h.path),e(this,E).forEach(H=>{H.checkCurrent(h.path)});try{let H=!0;if(this.preprocessor)try{yield new Promise((o,k)=>{var y;(y=this.preprocessor)==null||y.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)!==h.path){e(this,E).forEach(o=>{o.checkCurrent(e(this,f))});return}const dt={path:h.path,submorph:v};Y.dispatchEvent(document,"morphNavigation",{detail:dt});const mt=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!==h.path&&o.abort()}),yield m==null?void 0:m.fetch(w),e(this,z)!==h.path){e(this,E).forEach(o=>{o.checkCurrent(e(this,f))});return}mt.clearState(),mt.saveScrollState(),mt.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:dt});const Lt=Array.from(document.head.children),Pt=Array.from(m.document.head.children),At=p(this,c,zt).call(this,Lt,Pt),Bt=p(this,c,vt).call(this,Lt,At),at=p(this,c,vt).call(this,Pt,At);at.forEach((o,k)=>{if(o.tagName==="SCRIPT"&&o.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=o.getAttribute("src"),at[k]=y}}),at.forEach(o=>{document.head.appendChild(o)});const ft=at.filter(o=>{if(o.hasAttribute("data-no-waiting"))return!1;if(p(this,c,wt).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 y=qt(ft),tt,F,K;tt=!(F=yield y.next()).done;tt=!1){const lt=F.value;lt.onload=()=>{k++,k===ft.length&&o()}}}catch(F){K=[F]}finally{try{tt&&(F=y.return)&&(yield F.call(y))}finally{if(K)throw K[0]}}}))),yield Dt.wait(10);const kt=[];Bt.forEach(o=>{o.hasAttribute("data-permanent")||(p(this,c,wt).call(this,o)?kt.push(o):o.remove())});const Ot=p(this,c,St).call(this,m.document.body);e(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}),e(this,U).remove(),n(this,it,e(this,f)),n(this,f,h.path),e(this,J).forEach((o,k)=>{const y=Ot[k],tt=getComputedStyle(o).getPropertyValue("--morph-duration");let F=[],K=[];v?v.forEach(d=>{const S=o.querySelector(d),q=y.querySelector(d);S&&q&&(K.push(S),F.push(q))}):(F.push(...y.childNodes),K.push(...o.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])}):o.prepend(...F),Kt.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:o,path:h.path};Y.dispatchEvent(document,"morphNewChildrenAdded",{detail:lt});const Ft=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)});e(this,B).push(Ft)}),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})):e(this,x)?m.restoreScrollPosition():m.renewScrollPosition(),yield Promise.all(e(this,B)),kt.forEach(o=>o.remove()),n(this,B,[]),e(this,J).forEach(o=>{o.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:Ht(Nt({},dt),{document:m.document})}),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 Et(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 Et(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 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(t){let s=e(this,M).get(t);return s||(s=new It(this,t),e(this,M).set(t,s)),s},St=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},zt=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,_)),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)},bt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Dt.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;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
1
|
+
var Ot = Object.defineProperty, Wt = Object.defineProperties;
|
|
2
|
+
var Yt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var At = Object.getOwnPropertySymbols;
|
|
4
|
+
var Xt = Object.prototype.hasOwnProperty, Ut = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var kt = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), Tt = (r) => {
|
|
6
|
+
throw TypeError(r);
|
|
3
7
|
};
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
var Ct = (r, t, s) => t in r ? Ot(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s, xt = (r, t) => {
|
|
9
|
+
for (var s in t || (t = {}))
|
|
10
|
+
Xt.call(t, s) && Ct(r, s, t[s]);
|
|
11
|
+
if (At)
|
|
12
|
+
for (var s of At(t))
|
|
13
|
+
Ut.call(t, s) && Ct(r, s, t[s]);
|
|
14
|
+
return r;
|
|
15
|
+
}, Nt = (r, t) => Wt(r, Yt(t));
|
|
16
|
+
var ft = (r, t, s) => t.has(r) || Tt("Cannot " + s);
|
|
17
|
+
var e = (r, t, s) => (ft(r, t, "read from private field"), s ? s.call(r) : t.get(r)), a = (r, t, s) => t.has(r) ? Tt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, s), n = (r, t, s, i) => (ft(r, t, "write to private field"), i ? i.call(r, s) : t.set(r, s), s), p = (r, t, s) => (ft(r, t, "access private method"), s);
|
|
18
|
+
var W = (r, t, s) => new Promise((i, u) => {
|
|
7
19
|
var y = (E) => {
|
|
8
20
|
try {
|
|
9
21
|
w(s.next(E));
|
|
@@ -17,46 +29,46 @@ var W = (a, e, s) => new Promise((i, u) => {
|
|
|
17
29
|
u(F);
|
|
18
30
|
}
|
|
19
31
|
}, w = (E) => E.done ? i(E.value) : Promise.resolve(E.value).then(y, M);
|
|
20
|
-
w((s = s.apply(
|
|
32
|
+
w((s = s.apply(r, t)).next());
|
|
21
33
|
});
|
|
22
|
-
var
|
|
23
|
-
import { i as
|
|
34
|
+
var Mt = (r, t, s) => (t = r[kt("asyncIterator")]) ? t.call(r) : (r = r[kt("iterator")](), t = {}, s = (i, u) => (u = r[i]) && (t[i] = (y) => new Promise((M, w, E) => (y = u.call(r, y), E = y.done, Promise.resolve(y.value).then((F) => M({ value: F, done: E }), w)))), s("next"), s("return"), t);
|
|
35
|
+
import { i as Rt } 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 jt } from "../polyfills-DJrTJQky.js";
|
|
38
|
+
import { w as Kt, s as $t } 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 Gt, c as Ht, s as Jt } from "../url-Cb0SFRMc.js";
|
|
41
|
+
import { cssValueParser as Qt } from "../css-value-parser/index.js";
|
|
42
|
+
class Vt 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
|
+
Rt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Vt);
|
|
42
54
|
var C, l, I, st, $;
|
|
43
55
|
class pt {
|
|
44
|
-
constructor(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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 u =
|
|
65
|
+
n(this, I, e(this, l).getAttribute("href") || "/");
|
|
66
|
+
const u = 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 ? Qt.parse(M) : void 0, E = e(this, l).hasAttribute("data-revalidate"), F = e(this, l).hasAttribute(
|
|
57
69
|
"data-keep-search-parameters"
|
|
58
|
-
), c = (i =
|
|
59
|
-
|
|
70
|
+
), c = (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), {
|
|
60
72
|
historyAction: u,
|
|
61
73
|
centerScroll: y,
|
|
62
74
|
offsetScroll: w,
|
|
@@ -67,155 +79,155 @@ class pt {
|
|
|
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 Zt = 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 Dt {
|
|
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 u = yield (yield fetch(
|
|
127
|
-
signal:
|
|
128
|
-
})).text(), y =
|
|
137
|
+
n(this, U, new AbortController());
|
|
138
|
+
const u = yield (yield fetch(e(this, R), {
|
|
139
|
+
signal: e(this, U).signal
|
|
140
|
+
})).text(), y = Zt.parseFromString(u, "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, g, z, f, it, B, x, L, rt, N, j, Q, Z, nt, h, ht, gt,
|
|
202
|
+
var A, J, g, z, f, it, B, x, L, rt, N, j, Q, Z, nt, h, ht, gt, qt, Et, St, wt, yt, ct, _;
|
|
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, h);
|
|
206
|
+
a(this, A, null);
|
|
207
|
+
a(this, J, null);
|
|
208
|
+
a(this, g, []);
|
|
209
|
+
a(this, z);
|
|
210
|
+
a(this, f, null);
|
|
211
|
+
a(this, it);
|
|
212
|
+
a(this, B, []);
|
|
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, ct, (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), u = 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(
|
|
@@ -229,81 +241,81 @@ const et = class et {
|
|
|
229
241
|
u < 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 (Rt && !et.instance) {
|
|
250
|
+
et.instance = this, n(this, A, {
|
|
251
|
+
base: Gt(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, h, gt).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 Dt(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, ct)), Ht({
|
|
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 Vt()), p(this, h, wt).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, g);
|
|
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 Jt(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, B).length)
|
|
300
312
|
return;
|
|
301
|
-
const i = p(this, h, ht).call(this,
|
|
313
|
+
const i = p(this, h, ht).call(this, t);
|
|
302
314
|
i == null || i.fetch(s);
|
|
303
315
|
});
|
|
304
316
|
}
|
|
305
317
|
navigate(F) {
|
|
306
|
-
return W(this, arguments, function* (
|
|
318
|
+
return W(this, arguments, function* (t, {
|
|
307
319
|
historyAction: s = "push",
|
|
308
320
|
centerScroll: i,
|
|
309
321
|
offsetScroll: u,
|
|
@@ -313,41 +325,41 @@ const et = class et {
|
|
|
313
325
|
clearState: E
|
|
314
326
|
} = {}) {
|
|
315
327
|
var ot;
|
|
316
|
-
if (
|
|
328
|
+
if (e(this, B).length)
|
|
317
329
|
return;
|
|
318
330
|
const c = this.normalizePath(
|
|
319
|
-
((ot = this.pathnameModifier) == null ? void 0 : ot.call(this,
|
|
331
|
+
((ot = this.pathnameModifier) == null ? void 0 : ot.call(this, t)) || t
|
|
320
332
|
);
|
|
321
|
-
if (
|
|
322
|
-
|
|
333
|
+
if (e(this, z) === c.path || e(this, f) === c.path) {
|
|
334
|
+
e(this, x) || p(this, h, yt).call(this, c.hash || 0, {
|
|
323
335
|
centerScroll: i,
|
|
324
336
|
offsetScroll: u,
|
|
325
337
|
behavior: "smooth"
|
|
326
338
|
});
|
|
327
339
|
return;
|
|
328
340
|
}
|
|
329
|
-
|
|
341
|
+
n(this, z, c.path), e(this, g).forEach((H) => {
|
|
330
342
|
H.checkCurrent(c.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) !== c.path) {
|
|
361
|
+
e(this, g).forEach((o) => {
|
|
362
|
+
o.checkCurrent(e(this, f));
|
|
351
363
|
});
|
|
352
364
|
return;
|
|
353
365
|
}
|
|
@@ -358,40 +370,40 @@ const et = class et {
|
|
|
358
370
|
Y(document, "morphNavigation", {
|
|
359
371
|
detail: ut
|
|
360
372
|
});
|
|
361
|
-
const dt = p(this, h, ht).call(this,
|
|
362
|
-
if (
|
|
363
|
-
|
|
364
|
-
}), yield m == null ? void 0 : m.fetch(y),
|
|
365
|
-
|
|
366
|
-
|
|
373
|
+
const dt = p(this, h, ht).call(this, e(this, f)), m = p(this, h, ht).call(this, t);
|
|
374
|
+
if (e(this, N).forEach((o) => {
|
|
375
|
+
o.path !== c.path && o.abort();
|
|
376
|
+
}), yield m == null ? void 0 : m.fetch(y), e(this, z) !== c.path) {
|
|
377
|
+
e(this, g).forEach((o) => {
|
|
378
|
+
o.checkCurrent(e(this, f));
|
|
367
379
|
});
|
|
368
380
|
return;
|
|
369
381
|
}
|
|
370
|
-
dt.clearState(), dt.saveScrollState(), dt.saveDocumentState(),
|
|
382
|
+
dt.clearState(), dt.saveScrollState(), dt.saveDocumentState(), e(this, x) || (m.clearScrollState(), m.clearDocumentState()), E && m.clearState(), m.cloneDocument(), e(this, j).textContent = m.title, document.body.appendChild(e(this, j)), Y(document, "morphStart", {
|
|
371
383
|
detail: ut
|
|
372
384
|
});
|
|
373
|
-
const vt = Array.from(document.head.children), bt = Array.from(m.document.head.children), Lt = p(this, h,
|
|
374
|
-
at.forEach((
|
|
375
|
-
if (
|
|
385
|
+
const vt = Array.from(document.head.children), bt = Array.from(m.document.head.children), Lt = p(this, h, qt).call(this, vt, bt), zt = p(this, h, Et).call(this, vt, Lt), at = p(this, h, Et).call(this, bt, Lt);
|
|
386
|
+
at.forEach((o, k) => {
|
|
387
|
+
if (o.tagName === "SCRIPT" && o.getAttribute("src")) {
|
|
376
388
|
const v = document.createElement("script");
|
|
377
|
-
v.type = "module", v.src =
|
|
389
|
+
v.type = "module", v.src = o.getAttribute("src"), at[k] = v;
|
|
378
390
|
}
|
|
379
|
-
}), at.forEach((
|
|
380
|
-
document.head.appendChild(
|
|
391
|
+
}), at.forEach((o) => {
|
|
392
|
+
document.head.appendChild(o);
|
|
381
393
|
});
|
|
382
|
-
const mt = at.filter((
|
|
383
|
-
if (
|
|
394
|
+
const mt = at.filter((o) => {
|
|
395
|
+
if (o.hasAttribute("data-no-waiting"))
|
|
384
396
|
return !1;
|
|
385
|
-
if (p(this, h, St).call(this,
|
|
397
|
+
if (p(this, h, St).call(this, o))
|
|
386
398
|
return !0;
|
|
387
399
|
});
|
|
388
|
-
|
|
400
|
+
e(this, A).waitForHeadToLoad && mt.length && (yield new Promise((o) => W(this, null, function* () {
|
|
389
401
|
let k = 0;
|
|
390
402
|
try {
|
|
391
|
-
for (var v =
|
|
403
|
+
for (var v = Mt(mt), tt, O, K; tt = !(O = yield v.next()).done; tt = !1) {
|
|
392
404
|
const lt = O.value;
|
|
393
405
|
lt.onload = () => {
|
|
394
|
-
k++, k === mt.length &&
|
|
406
|
+
k++, k === mt.length && o();
|
|
395
407
|
};
|
|
396
408
|
}
|
|
397
409
|
} catch (O) {
|
|
@@ -404,30 +416,30 @@ const et = class et {
|
|
|
404
416
|
throw K[0];
|
|
405
417
|
}
|
|
406
418
|
}
|
|
407
|
-
}))), yield
|
|
419
|
+
}))), yield Kt(10);
|
|
408
420
|
const Pt = [];
|
|
409
|
-
|
|
410
|
-
|
|
421
|
+
zt.forEach((o) => {
|
|
422
|
+
o.hasAttribute("data-permanent") || (p(this, h, St).call(this, o) ? Pt.push(o) : o.remove());
|
|
411
423
|
});
|
|
412
|
-
const
|
|
413
|
-
|
|
424
|
+
const Bt = p(this, h, gt).call(this, m.document.body);
|
|
425
|
+
e(this, A).morphInsideScrollContainer || p(this, h, wt).call(this, m.document), document.documentElement.setAttribute(
|
|
414
426
|
"data-current-pathname",
|
|
415
427
|
c.pathname
|
|
416
428
|
), document.documentElement.setAttribute(
|
|
417
429
|
"data-current-leaf",
|
|
418
430
|
c.leaf
|
|
419
|
-
),
|
|
431
|
+
), Ht({
|
|
420
432
|
action: s,
|
|
421
433
|
pathname: c.pathname,
|
|
422
434
|
searchParameters: c.parameters || (M ? location.search : ""),
|
|
423
435
|
hash: c.hash
|
|
424
|
-
}),
|
|
425
|
-
const v =
|
|
436
|
+
}), e(this, j).remove(), n(this, it, e(this, f)), n(this, f, c.path), e(this, J).forEach((o, k) => {
|
|
437
|
+
const v = Bt[k], tt = getComputedStyle(o).getPropertyValue("--morph-duration");
|
|
426
438
|
let O = [], K = [];
|
|
427
439
|
w ? w.forEach((d) => {
|
|
428
|
-
const S =
|
|
440
|
+
const S = o.querySelector(d), D = v.querySelector(d);
|
|
429
441
|
S && D && (K.push(S), O.push(D));
|
|
430
|
-
}) : (O.push(...v.childNodes), K.push(...
|
|
442
|
+
}) : (O.push(...v.childNodes), K.push(...o.childNodes)), K.forEach((d) => {
|
|
431
443
|
d instanceof HTMLElement && (this.destroyOldLinks(d), d.classList.add("old"));
|
|
432
444
|
}), O.forEach((d) => {
|
|
433
445
|
d instanceof HTMLElement && (this.findNewLinks(d), d.classList.add("new"));
|
|
@@ -437,7 +449,7 @@ const et = class et {
|
|
|
437
449
|
d,
|
|
438
450
|
K[S]
|
|
439
451
|
);
|
|
440
|
-
}) :
|
|
452
|
+
}) : o.prepend(...O), jt(() => {
|
|
441
453
|
O.forEach((d) => {
|
|
442
454
|
var S;
|
|
443
455
|
d instanceof HTMLElement && ((S = d.parentElement) == null || S.style.setProperty(
|
|
@@ -447,13 +459,13 @@ const et = class et {
|
|
|
447
459
|
});
|
|
448
460
|
});
|
|
449
461
|
const lt = {
|
|
450
|
-
morphElement:
|
|
462
|
+
morphElement: o,
|
|
451
463
|
path: c.path
|
|
452
464
|
};
|
|
453
465
|
Y(document, "morphNewChildrenAdded", {
|
|
454
466
|
detail: lt
|
|
455
467
|
});
|
|
456
|
-
const
|
|
468
|
+
const Ft = new Promise((d) => {
|
|
457
469
|
setTimeout(() => {
|
|
458
470
|
K.forEach((S) => S.remove()), O.forEach((S) => {
|
|
459
471
|
var D;
|
|
@@ -465,7 +477,7 @@ const et = class et {
|
|
|
465
477
|
}), d();
|
|
466
478
|
}, (parseFloat(tt) || 0) * 1e3 + 10);
|
|
467
479
|
});
|
|
468
|
-
|
|
480
|
+
e(this, B).push(Ft);
|
|
469
481
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
470
482
|
"--new-document-scroll-position",
|
|
471
483
|
(this.scrollValue.top - m.scrollState.y) * 1 + "px"
|
|
@@ -477,87 +489,89 @@ const et = class et {
|
|
|
477
489
|
}), c.hash ? (m.clearScrollState(), p(this, h, yt).call(this, c.hash, {
|
|
478
490
|
centerScroll: i,
|
|
479
491
|
offsetScroll: u
|
|
480
|
-
})) :
|
|
481
|
-
|
|
492
|
+
})) : e(this, x) ? m.restoreScrollPosition() : m.renewScrollPosition(), yield Promise.all(e(this, B)), Pt.forEach((o) => o.remove()), n(this, B, []), e(this, J).forEach((o) => {
|
|
493
|
+
o.querySelectorAll("script").forEach((v) => {
|
|
482
494
|
const tt = document.createElement("script");
|
|
483
495
|
tt.type = "module", tt.src = v.getAttribute("src"), v.replaceWith(tt);
|
|
484
496
|
});
|
|
485
497
|
}), Y(document, "morphComplete", {
|
|
486
|
-
detail: ut
|
|
498
|
+
detail: Nt(xt({}, ut), {
|
|
499
|
+
document: m.document
|
|
500
|
+
})
|
|
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, g).push(new pt(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, g, e(this, g).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
506
520
|
}
|
|
507
|
-
destroyOldLinks(
|
|
508
|
-
|
|
521
|
+
destroyOldLinks(t) {
|
|
522
|
+
n(this, g, e(this, g).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
|
-
|
|
528
|
+
e(this, g).push(
|
|
515
529
|
...s.map((i) => new pt(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, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new pt(s, this)));
|
|
523
537
|
}
|
|
524
538
|
};
|
|
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(
|
|
526
|
-
let s =
|
|
527
|
-
return s || (s = new
|
|
528
|
-
}, gt = function(
|
|
529
|
-
const s = [...
|
|
530
|
-
return s.length ? s : [
|
|
531
|
-
},
|
|
532
|
-
return
|
|
539
|
+
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(t) {
|
|
540
|
+
let s = e(this, N).get(t);
|
|
541
|
+
return s || (s = new Dt(this, t), e(this, N).set(t, s)), s;
|
|
542
|
+
}, gt = function(t) {
|
|
543
|
+
const s = [...t.querySelectorAll("[data-morph]")];
|
|
544
|
+
return s.length ? s : [t];
|
|
545
|
+
}, qt = function(t, s) {
|
|
546
|
+
return t.filter(
|
|
533
547
|
(i) => s.find(
|
|
534
548
|
(u) => u.outerHTML === i.outerHTML
|
|
535
549
|
)
|
|
536
550
|
);
|
|
537
|
-
}, Et = function(
|
|
538
|
-
return
|
|
551
|
+
}, Et = function(t, s) {
|
|
552
|
+
return t.filter(
|
|
539
553
|
(i) => !s.find(
|
|
540
554
|
(u) => u.outerHTML === i.outerHTML
|
|
541
555
|
)
|
|
542
556
|
);
|
|
543
|
-
}, St = function(
|
|
544
|
-
return
|
|
545
|
-
}, wt = function(
|
|
557
|
+
}, St = function(t) {
|
|
558
|
+
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
559
|
+
}, wt = function(t) {
|
|
546
560
|
var s, i;
|
|
547
|
-
(s =
|
|
561
|
+
(s = e(this, L)) == null || s.removeEventListener(
|
|
548
562
|
"scroll",
|
|
549
|
-
|
|
550
|
-
),
|
|
551
|
-
}, yt = function(
|
|
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
|
+
}, yt = function(t, s) {
|
|
566
|
+
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
567
|
+
(typeof i == "number" || i) && $t(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
573
|
}, ct = new WeakMap(), _ = new WeakMap(), et.instance = null;
|
|
560
|
-
let
|
|
574
|
+
let It = et;
|
|
561
575
|
export {
|
|
562
|
-
|
|
576
|
+
It as Morph
|
|
563
577
|
};
|