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