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